baseui 0.0.0-next-dfcbae6 → 0.0.0-next-71e4b32
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/es/input/base-input.js +18 -11
- package/es/input/input.js +15 -10
- package/es/input/masked-input.js +5 -2
- package/es/input/utils.js +4 -2
- package/es/select/select-component.js +5 -3
- package/es/textarea/textarea.js +15 -9
- package/esm/input/base-input.js +18 -11
- package/esm/input/input.js +15 -10
- package/esm/input/masked-input.js +6 -3
- package/esm/input/utils.js +4 -2
- package/esm/select/select-component.js +45 -39
- package/esm/textarea/textarea.js +15 -9
- package/input/base-input.js +18 -11
- package/input/base-input.js.flow +18 -6
- package/input/index.d.ts +3 -0
- package/input/input.js +15 -10
- package/input/input.js.flow +10 -5
- package/input/masked-input.js +6 -3
- package/input/masked-input.js.flow +3 -0
- package/input/types.js.flow +4 -0
- package/input/utils.js +4 -2
- package/input/utils.js.flow +2 -1
- package/package.json +1 -1
- package/select/select-component.js +45 -39
- package/select/select-component.js.flow +5 -3
- package/textarea/textarea.js +15 -9
- package/textarea/textarea.js.flow +11 -5
- package/textarea/types.js.flow +1 -0
package/es/input/base-input.js
CHANGED
|
@@ -37,7 +37,7 @@ class BaseInput extends React.Component {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
_defineProperty(this, "onInputKeyDown", e => {
|
|
40
|
-
if (this.props.clearOnEscape && e.key === 'Escape' && this.inputRef.current) {
|
|
40
|
+
if (this.props.clearOnEscape && e.key === 'Escape' && this.inputRef.current && !this.props.readOnly) {
|
|
41
41
|
this.clearValue(); // prevent event from closing modal or doing something unexpected
|
|
42
42
|
|
|
43
43
|
e.stopPropagation();
|
|
@@ -51,17 +51,21 @@ class BaseInput extends React.Component {
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
_defineProperty(this, "onFocus", e => {
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (!this.props.readOnly) {
|
|
55
|
+
this.setState({
|
|
56
|
+
isFocused: true
|
|
57
|
+
});
|
|
58
|
+
this.props.onFocus(e);
|
|
59
|
+
}
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
_defineProperty(this, "onBlur", e => {
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (!this.props.readOnly) {
|
|
64
|
+
this.setState({
|
|
65
|
+
isFocused: false
|
|
66
|
+
});
|
|
67
|
+
this.props.onBlur(e);
|
|
68
|
+
}
|
|
65
69
|
});
|
|
66
70
|
|
|
67
71
|
_defineProperty(this, "handleFocusForMaskToggle", event => {
|
|
@@ -192,10 +196,11 @@ class BaseInput extends React.Component {
|
|
|
192
196
|
clearable,
|
|
193
197
|
value,
|
|
194
198
|
disabled,
|
|
199
|
+
readOnly,
|
|
195
200
|
overrides = {}
|
|
196
201
|
} = this.props;
|
|
197
202
|
|
|
198
|
-
if (disabled || !clearable || value == null || typeof value === 'string' && value.length === 0) {
|
|
203
|
+
if (disabled || readOnly || !clearable || value == null || typeof value === 'string' && value.length === 0) {
|
|
199
204
|
return null;
|
|
200
205
|
}
|
|
201
206
|
|
|
@@ -265,6 +270,7 @@ class BaseInput extends React.Component {
|
|
|
265
270
|
"aria-required": this.props.required,
|
|
266
271
|
autoComplete: autoComplete,
|
|
267
272
|
disabled: this.props.disabled,
|
|
273
|
+
readOnly: this.props.readOnly,
|
|
268
274
|
id: this.props.id,
|
|
269
275
|
inputMode: this.props.inputMode,
|
|
270
276
|
maxLength: this.props.maxLength,
|
|
@@ -322,7 +328,8 @@ _defineProperty(BaseInput, "defaultProps", {
|
|
|
322
328
|
required: false,
|
|
323
329
|
role: null,
|
|
324
330
|
size: SIZE.default,
|
|
325
|
-
type: 'text'
|
|
331
|
+
type: 'text',
|
|
332
|
+
readOnly: false
|
|
326
333
|
});
|
|
327
334
|
|
|
328
335
|
export default BaseInput;
|
package/es/input/input.js
CHANGED
|
@@ -20,21 +20,25 @@ class Input extends React.Component {
|
|
|
20
20
|
super(...args);
|
|
21
21
|
|
|
22
22
|
_defineProperty(this, "state", {
|
|
23
|
-
isFocused: this.props.autoFocus || false
|
|
23
|
+
isFocused: this.props.autoFocus && !this.props.readOnly || false
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
_defineProperty(this, "onFocus", e => {
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (!this.props.readOnly) {
|
|
28
|
+
this.setState({
|
|
29
|
+
isFocused: true
|
|
30
|
+
});
|
|
31
|
+
this.props.onFocus(e);
|
|
32
|
+
}
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
_defineProperty(this, "onBlur", e => {
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
if (!this.props.readOnly) {
|
|
37
|
+
this.setState({
|
|
38
|
+
isFocused: false
|
|
39
|
+
});
|
|
40
|
+
this.props.onBlur(e);
|
|
41
|
+
}
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -94,7 +98,8 @@ _defineProperty(Input, "defaultProps", {
|
|
|
94
98
|
startEnhancer: null,
|
|
95
99
|
endEnhancer: null,
|
|
96
100
|
clearable: false,
|
|
97
|
-
type: 'text'
|
|
101
|
+
type: 'text',
|
|
102
|
+
readOnly: false
|
|
98
103
|
});
|
|
99
104
|
|
|
100
105
|
function getAdjoinedProp(startEnhancer, endEnhancer) {
|
package/es/input/masked-input.js
CHANGED
|
@@ -23,6 +23,7 @@ const MaskOverride = /*#__PURE__*/React.forwardRef(({
|
|
|
23
23
|
onBlur,
|
|
24
24
|
value,
|
|
25
25
|
disabled,
|
|
26
|
+
readOnly,
|
|
26
27
|
...restProps
|
|
27
28
|
}, ref) => {
|
|
28
29
|
return /*#__PURE__*/React.createElement(InputMask, _extends({
|
|
@@ -30,14 +31,16 @@ const MaskOverride = /*#__PURE__*/React.forwardRef(({
|
|
|
30
31
|
onFocus: onFocus,
|
|
31
32
|
onBlur: onBlur,
|
|
32
33
|
value: value,
|
|
33
|
-
disabled: disabled
|
|
34
|
+
disabled: disabled,
|
|
35
|
+
readOnly: readOnly
|
|
34
36
|
}, restProps), props => /*#__PURE__*/React.createElement(StyledInput, _extends({
|
|
35
37
|
ref: ref,
|
|
36
38
|
onChange: onChange,
|
|
37
39
|
onFocus: onFocus,
|
|
38
40
|
onBlur: onBlur,
|
|
39
41
|
value: value,
|
|
40
|
-
disabled: disabled
|
|
42
|
+
disabled: disabled,
|
|
43
|
+
readOnly: readOnly
|
|
41
44
|
}, props)));
|
|
42
45
|
});
|
|
43
46
|
MaskOverride.displayName = 'MaskOverride';
|
package/es/input/utils.js
CHANGED
|
@@ -11,7 +11,8 @@ export function getSharedProps(props, state) {
|
|
|
11
11
|
positive,
|
|
12
12
|
adjoined,
|
|
13
13
|
size,
|
|
14
|
-
required
|
|
14
|
+
required,
|
|
15
|
+
readOnly
|
|
15
16
|
} = props;
|
|
16
17
|
const {
|
|
17
18
|
isFocused
|
|
@@ -23,6 +24,7 @@ export function getSharedProps(props, state) {
|
|
|
23
24
|
$positive: positive,
|
|
24
25
|
$adjoined: adjoined,
|
|
25
26
|
$size: size,
|
|
26
|
-
$required: required
|
|
27
|
+
$required: required,
|
|
28
|
+
$isReadOnly: readOnly
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -224,8 +224,10 @@ class Select extends React.Component {
|
|
|
224
224
|
if (containsNode(this.anchor.current, event.relatedTarget) || containsNode(this.dropdown.current, event.relatedTarget)) {
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
|
-
} else if (
|
|
228
|
-
|
|
227
|
+
} else if (event.type !== 'blur') {
|
|
228
|
+
if (containsNode(this.anchor.current, event.target)) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
if (this.props.onBlur) {
|
|
@@ -592,7 +594,7 @@ class Select extends React.Component {
|
|
|
592
594
|
}
|
|
593
595
|
|
|
594
596
|
if (!prevState.isFocused && this.state.isFocused) {
|
|
595
|
-
document.addEventListener('click', this.handleClickOutside);
|
|
597
|
+
setTimeout(() => document.addEventListener('click', this.handleClickOutside), 0);
|
|
596
598
|
}
|
|
597
599
|
}
|
|
598
600
|
}
|
package/es/textarea/textarea.js
CHANGED
|
@@ -18,21 +18,25 @@ class Textarea extends React.Component {
|
|
|
18
18
|
super(...args);
|
|
19
19
|
|
|
20
20
|
_defineProperty(this, "state", {
|
|
21
|
-
isFocused: this.props.autoFocus || false
|
|
21
|
+
isFocused: this.props.autoFocus && !this.props.readOnly || false
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
_defineProperty(this, "onFocus", e => {
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (!this.props.readOnly) {
|
|
26
|
+
this.setState({
|
|
27
|
+
isFocused: true
|
|
28
|
+
});
|
|
29
|
+
this.props.onFocus(e);
|
|
30
|
+
}
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
_defineProperty(this, "onBlur", e => {
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (!this.props.readOnly) {
|
|
35
|
+
this.setState({
|
|
36
|
+
isFocused: false
|
|
37
|
+
});
|
|
38
|
+
this.props.onBlur(e);
|
|
39
|
+
}
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -52,6 +56,7 @@ class Textarea extends React.Component {
|
|
|
52
56
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
53
57
|
"data-baseweb": "textarea",
|
|
54
58
|
$isFocused: this.state.isFocused,
|
|
59
|
+
$isReadOnly: this.props.readOnly,
|
|
55
60
|
$disabled: this.props.disabled,
|
|
56
61
|
$error: this.props.error,
|
|
57
62
|
$positive: this.props.positive,
|
|
@@ -70,6 +75,7 @@ class Textarea extends React.Component {
|
|
|
70
75
|
_defineProperty(Textarea, "defaultProps", {
|
|
71
76
|
autoFocus: false,
|
|
72
77
|
disabled: false,
|
|
78
|
+
readOnly: false,
|
|
73
79
|
error: false,
|
|
74
80
|
name: '',
|
|
75
81
|
onBlur: () => {},
|
package/esm/input/base-input.js
CHANGED
|
@@ -85,7 +85,7 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
_defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (e) {
|
|
88
|
-
if (_this.props.clearOnEscape && e.key === 'Escape' && _this.inputRef.current) {
|
|
88
|
+
if (_this.props.clearOnEscape && e.key === 'Escape' && _this.inputRef.current && !_this.props.readOnly) {
|
|
89
89
|
_this.clearValue(); // prevent event from closing modal or doing something unexpected
|
|
90
90
|
|
|
91
91
|
|
|
@@ -100,19 +100,23 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
103
|
-
_this.
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
if (!_this.props.readOnly) {
|
|
104
|
+
_this.setState({
|
|
105
|
+
isFocused: true
|
|
106
|
+
});
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
_this.props.onFocus(e);
|
|
109
|
+
}
|
|
108
110
|
});
|
|
109
111
|
|
|
110
112
|
_defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
|
|
111
|
-
_this.
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
if (!_this.props.readOnly) {
|
|
114
|
+
_this.setState({
|
|
115
|
+
isFocused: false
|
|
116
|
+
});
|
|
114
117
|
|
|
115
|
-
|
|
118
|
+
_this.props.onBlur(e);
|
|
119
|
+
}
|
|
116
120
|
});
|
|
117
121
|
|
|
118
122
|
_defineProperty(_assertThisInitialized(_this), "handleFocusForMaskToggle", function (event) {
|
|
@@ -267,10 +271,11 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
|
|
|
267
271
|
clearable = _this$props2.clearable,
|
|
268
272
|
value = _this$props2.value,
|
|
269
273
|
disabled = _this$props2.disabled,
|
|
274
|
+
readOnly = _this$props2.readOnly,
|
|
270
275
|
_this$props2$override = _this$props2.overrides,
|
|
271
276
|
overrides = _this$props2$override === void 0 ? {} : _this$props2$override;
|
|
272
277
|
|
|
273
|
-
if (disabled || !clearable || value == null || typeof value === 'string' && value.length === 0) {
|
|
278
|
+
if (disabled || readOnly || !clearable || value == null || typeof value === 'string' && value.length === 0) {
|
|
274
279
|
return null;
|
|
275
280
|
}
|
|
276
281
|
|
|
@@ -360,6 +365,7 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
|
|
|
360
365
|
"aria-required": this.props.required,
|
|
361
366
|
autoComplete: autoComplete,
|
|
362
367
|
disabled: this.props.disabled,
|
|
368
|
+
readOnly: this.props.readOnly,
|
|
363
369
|
id: this.props.id,
|
|
364
370
|
inputMode: this.props.inputMode,
|
|
365
371
|
maxLength: this.props.maxLength,
|
|
@@ -419,7 +425,8 @@ _defineProperty(BaseInput, "defaultProps", {
|
|
|
419
425
|
required: false,
|
|
420
426
|
role: null,
|
|
421
427
|
size: SIZE.default,
|
|
422
|
-
type: 'text'
|
|
428
|
+
type: 'text',
|
|
429
|
+
readOnly: false
|
|
423
430
|
});
|
|
424
431
|
|
|
425
432
|
export default BaseInput;
|
package/esm/input/input.js
CHANGED
|
@@ -70,23 +70,27 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
70
70
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
71
71
|
|
|
72
72
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
73
|
-
isFocused: _this.props.autoFocus || false
|
|
73
|
+
isFocused: _this.props.autoFocus && !_this.props.readOnly || false
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
77
|
-
_this.
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
if (!_this.props.readOnly) {
|
|
78
|
+
_this.setState({
|
|
79
|
+
isFocused: true
|
|
80
|
+
});
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
_this.props.onFocus(e);
|
|
83
|
+
}
|
|
82
84
|
});
|
|
83
85
|
|
|
84
86
|
_defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
|
|
85
|
-
_this.
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
if (!_this.props.readOnly) {
|
|
88
|
+
_this.setState({
|
|
89
|
+
isFocused: false
|
|
90
|
+
});
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
_this.props.onBlur(e);
|
|
93
|
+
}
|
|
90
94
|
});
|
|
91
95
|
|
|
92
96
|
return _this;
|
|
@@ -163,7 +167,8 @@ _defineProperty(Input, "defaultProps", {
|
|
|
163
167
|
startEnhancer: null,
|
|
164
168
|
endEnhancer: null,
|
|
165
169
|
clearable: false,
|
|
166
|
-
type: 'text'
|
|
170
|
+
type: 'text',
|
|
171
|
+
readOnly: false
|
|
167
172
|
});
|
|
168
173
|
|
|
169
174
|
function getAdjoinedProp(startEnhancer, endEnhancer) {
|
|
@@ -32,14 +32,16 @@ var MaskOverride = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
32
32
|
onBlur = _ref.onBlur,
|
|
33
33
|
value = _ref.value,
|
|
34
34
|
disabled = _ref.disabled,
|
|
35
|
-
|
|
35
|
+
readOnly = _ref.readOnly,
|
|
36
|
+
restProps = _objectWithoutProperties(_ref, ["startEnhancer", "endEnhancer", "error", "positive", "onChange", "onFocus", "onBlur", "value", "disabled", "readOnly"]);
|
|
36
37
|
|
|
37
38
|
return /*#__PURE__*/React.createElement(InputMask, _extends({
|
|
38
39
|
onChange: onChange,
|
|
39
40
|
onFocus: onFocus,
|
|
40
41
|
onBlur: onBlur,
|
|
41
42
|
value: value,
|
|
42
|
-
disabled: disabled
|
|
43
|
+
disabled: disabled,
|
|
44
|
+
readOnly: readOnly
|
|
43
45
|
}, restProps), function (props) {
|
|
44
46
|
return /*#__PURE__*/React.createElement(StyledInput, _extends({
|
|
45
47
|
ref: ref,
|
|
@@ -47,7 +49,8 @@ var MaskOverride = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
47
49
|
onFocus: onFocus,
|
|
48
50
|
onBlur: onBlur,
|
|
49
51
|
value: value,
|
|
50
|
-
disabled: disabled
|
|
52
|
+
disabled: disabled,
|
|
53
|
+
readOnly: readOnly
|
|
51
54
|
}, props));
|
|
52
55
|
});
|
|
53
56
|
});
|
package/esm/input/utils.js
CHANGED
|
@@ -10,7 +10,8 @@ export function getSharedProps(props, state) {
|
|
|
10
10
|
positive = props.positive,
|
|
11
11
|
adjoined = props.adjoined,
|
|
12
12
|
size = props.size,
|
|
13
|
-
required = props.required
|
|
13
|
+
required = props.required,
|
|
14
|
+
readOnly = props.readOnly;
|
|
14
15
|
var isFocused = state.isFocused;
|
|
15
16
|
return {
|
|
16
17
|
$isFocused: isFocused,
|
|
@@ -19,6 +20,7 @@ export function getSharedProps(props, state) {
|
|
|
19
20
|
$positive: positive,
|
|
20
21
|
$adjoined: adjoined,
|
|
21
22
|
$size: size,
|
|
22
|
-
$required: required
|
|
23
|
+
$required: required,
|
|
24
|
+
$isReadOnly: readOnly
|
|
23
25
|
};
|
|
24
26
|
}
|
|
@@ -296,8 +296,10 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
296
296
|
if (containsNode(_this.anchor.current, event.relatedTarget) || containsNode(_this.dropdown.current, event.relatedTarget)) {
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
|
-
} else if (
|
|
300
|
-
|
|
299
|
+
} else if (event.type !== 'blur') {
|
|
300
|
+
if (containsNode(_this.anchor.current, event.target)) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
301
303
|
}
|
|
302
304
|
|
|
303
305
|
if (_this.props.onBlur) {
|
|
@@ -678,6 +680,8 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
678
680
|
}, {
|
|
679
681
|
key: "componentDidUpdate",
|
|
680
682
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
683
|
+
var _this2 = this;
|
|
684
|
+
|
|
681
685
|
if (typeof document !== 'undefined') {
|
|
682
686
|
if (prevState.isOpen !== this.state.isOpen) {
|
|
683
687
|
if (this.state.isOpen) {
|
|
@@ -690,7 +694,9 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
690
694
|
}
|
|
691
695
|
|
|
692
696
|
if (!prevState.isFocused && this.state.isFocused) {
|
|
693
|
-
|
|
697
|
+
setTimeout(function () {
|
|
698
|
+
return document.addEventListener('click', _this2.handleClickOutside);
|
|
699
|
+
}, 0);
|
|
694
700
|
}
|
|
695
701
|
}
|
|
696
702
|
}
|
|
@@ -759,7 +765,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
759
765
|
* Extends the value into an array from the given options
|
|
760
766
|
*/
|
|
761
767
|
function getValueArray(value) {
|
|
762
|
-
var
|
|
768
|
+
var _this3 = this;
|
|
763
769
|
|
|
764
770
|
if (!Array.isArray(value)) {
|
|
765
771
|
if (value === null || value === undefined) return [];
|
|
@@ -767,7 +773,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
767
773
|
}
|
|
768
774
|
|
|
769
775
|
return value.map(function (value) {
|
|
770
|
-
return expandValue(value,
|
|
776
|
+
return expandValue(value, _this3.props);
|
|
771
777
|
});
|
|
772
778
|
}
|
|
773
779
|
}, {
|
|
@@ -812,7 +818,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
812
818
|
}, {
|
|
813
819
|
key: "renderValue",
|
|
814
820
|
value: function renderValue(valueArray, isOpen, locale) {
|
|
815
|
-
var
|
|
821
|
+
var _this4 = this;
|
|
816
822
|
|
|
817
823
|
var _this$props$overrides2 = this.props.overrides,
|
|
818
824
|
overrides = _this$props$overrides2 === void 0 ? {} : _this$props$overrides2;
|
|
@@ -829,9 +835,9 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
829
835
|
var disabled = sharedProps.$disabled || value.clearableValue === false;
|
|
830
836
|
return /*#__PURE__*/React.createElement(Value, _extends({
|
|
831
837
|
value: value,
|
|
832
|
-
key: "value-".concat(i, "-").concat(value[
|
|
838
|
+
key: "value-".concat(i, "-").concat(value[_this4.props.valueKey]),
|
|
833
839
|
removeValue: function removeValue() {
|
|
834
|
-
return
|
|
840
|
+
return _this4.removeValue(value);
|
|
835
841
|
},
|
|
836
842
|
disabled: disabled,
|
|
837
843
|
overrides: {
|
|
@@ -860,7 +866,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
860
866
|
}, {
|
|
861
867
|
key: "renderInput",
|
|
862
868
|
value: function renderInput(listboxId) {
|
|
863
|
-
var
|
|
869
|
+
var _this5 = this;
|
|
864
870
|
|
|
865
871
|
var _this$props$overrides3 = this.props.overrides,
|
|
866
872
|
overrides = _this$props$overrides3 === void 0 ? {} : _this$props$overrides3;
|
|
@@ -873,7 +879,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
873
879
|
var sharedProps = this.getSharedProps();
|
|
874
880
|
var isOpen = this.state.isOpen;
|
|
875
881
|
var selected = this.getValueArray(this.props.value).map(function (v) {
|
|
876
|
-
return v[
|
|
882
|
+
return v[_this5.props.labelKey];
|
|
877
883
|
}).join(', ');
|
|
878
884
|
var selectedLabel = selected.length ? "Selected ".concat(selected, ". ") : '';
|
|
879
885
|
var label = "".concat(selectedLabel).concat(this.props['aria-label'] || '');
|
|
@@ -1034,7 +1040,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
1034
1040
|
}, {
|
|
1035
1041
|
key: "filterOptions",
|
|
1036
1042
|
value: function filterOptions(excludeOptions) {
|
|
1037
|
-
var
|
|
1043
|
+
var _this6 = this;
|
|
1038
1044
|
|
|
1039
1045
|
var filterValue = this.state.inputValue.trim(); // apply filter function
|
|
1040
1046
|
|
|
@@ -1047,9 +1053,9 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
1047
1053
|
|
|
1048
1054
|
|
|
1049
1055
|
var filterDoesNotMatchOption = this.props.ignoreCase ? function (opt) {
|
|
1050
|
-
return opt[
|
|
1056
|
+
return opt[_this6.props.labelKey].toLowerCase() !== filterValue.toLowerCase().trim();
|
|
1051
1057
|
} : function (opt) {
|
|
1052
|
-
return opt[
|
|
1058
|
+
return opt[_this6.props.labelKey] !== filterValue.trim();
|
|
1053
1059
|
};
|
|
1054
1060
|
|
|
1055
1061
|
if (filterValue && this.props.creatable && this.options.concat(this.props.value).every(filterDoesNotMatchOption)) {
|
|
@@ -1104,7 +1110,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
1104
1110
|
}, {
|
|
1105
1111
|
key: "render",
|
|
1106
1112
|
value: function render() {
|
|
1107
|
-
var
|
|
1113
|
+
var _this7 = this;
|
|
1108
1114
|
|
|
1109
1115
|
this.options = normalizeOptions(this.props.options);
|
|
1110
1116
|
var _this$props2 = this.props,
|
|
@@ -1176,55 +1182,55 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
1176
1182
|
, _extends({
|
|
1177
1183
|
innerRef: function innerRef(ref) {
|
|
1178
1184
|
if (!ref) return;
|
|
1179
|
-
|
|
1185
|
+
_this7.anchor = ref.anchorRef;
|
|
1180
1186
|
},
|
|
1181
1187
|
autoFocus: false,
|
|
1182
1188
|
focusLock: false,
|
|
1183
|
-
mountNode:
|
|
1189
|
+
mountNode: _this7.props.mountNode,
|
|
1184
1190
|
onEsc: function onEsc() {
|
|
1185
|
-
return
|
|
1191
|
+
return _this7.closeMenu();
|
|
1186
1192
|
},
|
|
1187
1193
|
isOpen: isOpen,
|
|
1188
1194
|
popoverMargin: 0,
|
|
1189
1195
|
content: function content() {
|
|
1190
1196
|
var dropdownProps = {
|
|
1191
|
-
error:
|
|
1192
|
-
positive:
|
|
1193
|
-
getOptionLabel:
|
|
1197
|
+
error: _this7.props.error,
|
|
1198
|
+
positive: _this7.props.positive,
|
|
1199
|
+
getOptionLabel: _this7.props.getOptionLabel || _this7.getOptionLabel.bind(_this7, locale),
|
|
1194
1200
|
id: listboxId,
|
|
1195
|
-
isLoading:
|
|
1196
|
-
labelKey:
|
|
1197
|
-
maxDropdownHeight:
|
|
1201
|
+
isLoading: _this7.props.isLoading,
|
|
1202
|
+
labelKey: _this7.props.labelKey,
|
|
1203
|
+
maxDropdownHeight: _this7.props.maxDropdownHeight,
|
|
1198
1204
|
multi: multi,
|
|
1199
1205
|
noResultsMsg: noResultsMsg,
|
|
1200
|
-
onActiveDescendantChange:
|
|
1201
|
-
onItemSelect:
|
|
1206
|
+
onActiveDescendantChange: _this7.handleActiveDescendantChange,
|
|
1207
|
+
onItemSelect: _this7.selectValue,
|
|
1202
1208
|
options: options,
|
|
1203
1209
|
overrides: overrides,
|
|
1204
|
-
required:
|
|
1205
|
-
searchable:
|
|
1206
|
-
size:
|
|
1210
|
+
required: _this7.props.required,
|
|
1211
|
+
searchable: _this7.props.searchable,
|
|
1212
|
+
size: _this7.props.size,
|
|
1207
1213
|
type: type,
|
|
1208
1214
|
value: valueArray,
|
|
1209
|
-
valueKey:
|
|
1210
|
-
width:
|
|
1211
|
-
keyboardControlNode:
|
|
1215
|
+
valueKey: _this7.props.valueKey,
|
|
1216
|
+
width: _this7.anchor.current ? _this7.anchor.current.clientWidth : null,
|
|
1217
|
+
keyboardControlNode: _this7.anchor
|
|
1212
1218
|
};
|
|
1213
1219
|
return /*#__PURE__*/React.createElement(SelectDropdown, _extends({
|
|
1214
|
-
innerRef:
|
|
1220
|
+
innerRef: _this7.dropdown
|
|
1215
1221
|
}, dropdownProps));
|
|
1216
1222
|
},
|
|
1217
1223
|
placement: PLACEMENT.bottom
|
|
1218
1224
|
}, popoverProps), /*#__PURE__*/React.createElement(Root, _extends({
|
|
1219
|
-
onBlur:
|
|
1225
|
+
onBlur: _this7.handleBlur,
|
|
1220
1226
|
"data-baseweb": "select"
|
|
1221
1227
|
}, sharedProps, rootProps), /*#__PURE__*/React.createElement(ControlContainer, _extends({
|
|
1222
|
-
onKeyDown:
|
|
1223
|
-
onClick:
|
|
1224
|
-
onTouchEnd:
|
|
1225
|
-
onTouchMove:
|
|
1226
|
-
onTouchStart:
|
|
1227
|
-
}, sharedProps, controlContainerProps), type === TYPE.search ?
|
|
1228
|
+
onKeyDown: _this7.handleKeyDown,
|
|
1229
|
+
onClick: _this7.handleClick,
|
|
1230
|
+
onTouchEnd: _this7.handleTouchEnd,
|
|
1231
|
+
onTouchMove: _this7.handleTouchMove,
|
|
1232
|
+
onTouchStart: _this7.handleTouchStart
|
|
1233
|
+
}, sharedProps, controlContainerProps), type === TYPE.search ? _this7.renderSearch() : null, /*#__PURE__*/React.createElement(ValueContainer, _extends({}, sharedProps, valueContainerProps), _this7.renderValue(valueArray, isOpen, locale), _this7.renderInput(listboxId), _this7.shouldShowPlaceholder() ? /*#__PURE__*/React.createElement(Placeholder, _extends({}, sharedProps, placeholderProps), typeof _this7.props.placeholder !== 'undefined' ? _this7.props.placeholder : locale.select.placeholder) : null), /*#__PURE__*/React.createElement(IconsContainer, _extends({}, sharedProps, iconsContainerProps), _this7.renderLoading(), _this7.renderClear(), type === TYPE.select ? _this7.renderArrow() : null))));
|
|
1228
1234
|
});
|
|
1229
1235
|
});
|
|
1230
1236
|
}
|
package/esm/textarea/textarea.js
CHANGED
|
@@ -64,23 +64,27 @@ var Textarea = /*#__PURE__*/function (_React$Component) {
|
|
|
64
64
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
65
65
|
|
|
66
66
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
67
|
-
isFocused: _this.props.autoFocus || false
|
|
67
|
+
isFocused: _this.props.autoFocus && !_this.props.readOnly || false
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
71
|
-
_this.
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (!_this.props.readOnly) {
|
|
72
|
+
_this.setState({
|
|
73
|
+
isFocused: true
|
|
74
|
+
});
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
_this.props.onFocus(e);
|
|
77
|
+
}
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
_defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
|
|
79
|
-
_this.
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
if (!_this.props.readOnly) {
|
|
82
|
+
_this.setState({
|
|
83
|
+
isFocused: false
|
|
84
|
+
});
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
_this.props.onBlur(e);
|
|
87
|
+
}
|
|
84
88
|
});
|
|
85
89
|
|
|
86
90
|
return _this;
|
|
@@ -108,6 +112,7 @@ var Textarea = /*#__PURE__*/function (_React$Component) {
|
|
|
108
112
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
109
113
|
"data-baseweb": "textarea",
|
|
110
114
|
$isFocused: this.state.isFocused,
|
|
115
|
+
$isReadOnly: this.props.readOnly,
|
|
111
116
|
$disabled: this.props.disabled,
|
|
112
117
|
$error: this.props.error,
|
|
113
118
|
$positive: this.props.positive,
|
|
@@ -128,6 +133,7 @@ var Textarea = /*#__PURE__*/function (_React$Component) {
|
|
|
128
133
|
_defineProperty(Textarea, "defaultProps", {
|
|
129
134
|
autoFocus: false,
|
|
130
135
|
disabled: false,
|
|
136
|
+
readOnly: false,
|
|
131
137
|
error: false,
|
|
132
138
|
name: '',
|
|
133
139
|
onBlur: function onBlur() {},
|