baseui 0.0.0-next-6bede4f → 0.0.0-next-e047a0a

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.
@@ -98,7 +98,7 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
98
98
  });
99
99
 
100
100
  _defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (e) {
101
- if (_this.props.clearOnEscape && e.key === 'Escape' && _this.inputRef.current) {
101
+ if (_this.props.clearOnEscape && e.key === 'Escape' && _this.inputRef.current && !_this.props.readOnly) {
102
102
  _this.clearValue(); // prevent event from closing modal or doing something unexpected
103
103
 
104
104
 
@@ -113,19 +113,23 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
113
113
  });
114
114
 
115
115
  _defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
116
- _this.setState({
117
- isFocused: true
118
- });
116
+ if (!_this.props.readOnly) {
117
+ _this.setState({
118
+ isFocused: true
119
+ });
119
120
 
120
- _this.props.onFocus(e);
121
+ _this.props.onFocus(e);
122
+ }
121
123
  });
122
124
 
123
125
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
124
- _this.setState({
125
- isFocused: false
126
- });
126
+ if (!_this.props.readOnly) {
127
+ _this.setState({
128
+ isFocused: false
129
+ });
127
130
 
128
- _this.props.onBlur(e);
131
+ _this.props.onBlur(e);
132
+ }
129
133
  });
130
134
 
131
135
  _defineProperty(_assertThisInitialized(_this), "handleFocusForMaskToggle", function (event) {
@@ -280,10 +284,11 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
280
284
  clearable = _this$props2.clearable,
281
285
  value = _this$props2.value,
282
286
  disabled = _this$props2.disabled,
287
+ readOnly = _this$props2.readOnly,
283
288
  _this$props2$override = _this$props2.overrides,
284
289
  overrides = _this$props2$override === void 0 ? {} : _this$props2$override;
285
290
 
286
- if (disabled || !clearable || value == null || typeof value === 'string' && value.length === 0) {
291
+ if (disabled || readOnly || !clearable || value == null || typeof value === 'string' && value.length === 0) {
287
292
  return null;
288
293
  }
289
294
 
@@ -373,6 +378,7 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
373
378
  "aria-required": this.props.required,
374
379
  autoComplete: autoComplete,
375
380
  disabled: this.props.disabled,
381
+ readOnly: this.props.readOnly,
376
382
  id: this.props.id,
377
383
  inputMode: this.props.inputMode,
378
384
  maxLength: this.props.maxLength,
@@ -432,7 +438,8 @@ _defineProperty(BaseInput, "defaultProps", {
432
438
  required: false,
433
439
  role: null,
434
440
  size: _constants.SIZE.default,
435
- type: 'text'
441
+ type: 'text',
442
+ readOnly: false
436
443
  });
437
444
 
438
445
  var _default = BaseInput;
@@ -64,6 +64,7 @@ class BaseInput<T: HTMLInputElement | HTMLTextAreaElement> extends React.Compone
64
64
  role: null,
65
65
  size: SIZE.default,
66
66
  type: 'text',
67
+ readOnly: false,
67
68
  };
68
69
 
69
70
  inputRef = this.props.inputRef || React.createRef<T>();
@@ -117,7 +118,12 @@ class BaseInput<T: HTMLInputElement | HTMLTextAreaElement> extends React.Compone
117
118
  }
118
119
 
119
120
  onInputKeyDown = (e: KeyboardEvent) => {
120
- if (this.props.clearOnEscape && e.key === 'Escape' && this.inputRef.current) {
121
+ if (
122
+ this.props.clearOnEscape &&
123
+ e.key === 'Escape' &&
124
+ this.inputRef.current &&
125
+ !this.props.readOnly
126
+ ) {
121
127
  this.clearValue();
122
128
  // prevent event from closing modal or doing something unexpected
123
129
  e.stopPropagation();
@@ -131,13 +137,17 @@ class BaseInput<T: HTMLInputElement | HTMLTextAreaElement> extends React.Compone
131
137
  };
132
138
 
133
139
  onFocus = (e: SyntheticFocusEvent<T>) => {
134
- this.setState({ isFocused: true });
135
- this.props.onFocus(e);
140
+ if (!this.props.readOnly) {
141
+ this.setState({ isFocused: true });
142
+ this.props.onFocus(e);
143
+ }
136
144
  };
137
145
 
138
146
  onBlur = (e: SyntheticFocusEvent<T>) => {
139
- this.setState({ isFocused: false });
140
- this.props.onBlur(e);
147
+ if (!this.props.readOnly) {
148
+ this.setState({ isFocused: false });
149
+ this.props.onBlur(e);
150
+ }
141
151
  };
142
152
 
143
153
  getInputType() {
@@ -219,9 +229,10 @@ class BaseInput<T: HTMLInputElement | HTMLTextAreaElement> extends React.Compone
219
229
  };
220
230
 
221
231
  renderClear() {
222
- const { clearable, value, disabled, overrides = {} } = this.props;
232
+ const { clearable, value, disabled, readOnly, overrides = {} } = this.props;
223
233
  if (
224
234
  disabled ||
235
+ readOnly ||
225
236
  !clearable ||
226
237
  value == null ||
227
238
  (typeof value === 'string' && value.length === 0)
@@ -320,6 +331,7 @@ class BaseInput<T: HTMLInputElement | HTMLTextAreaElement> extends React.Compone
320
331
  aria-required={this.props.required}
321
332
  autoComplete={autoComplete}
322
333
  disabled={this.props.disabled}
334
+ readOnly={this.props.readOnly}
323
335
  id={this.props.id}
324
336
  inputMode={this.props.inputMode}
325
337
  maxLength={this.props.maxLength}
package/input/index.d.ts CHANGED
@@ -70,6 +70,7 @@ export interface BaseInputProps<T> {
70
70
  min?: number;
71
71
  max?: number;
72
72
  step?: number | 'any';
73
+ readOnly?: boolean;
73
74
  }
74
75
 
75
76
  export interface State {
@@ -90,6 +91,8 @@ export type InputOverrides = BaseInputOverrides<SharedProps> & {
90
91
  export type SharedProps = {
91
92
  /** Renders UI in 'focus' state */
92
93
  $isFocused: boolean;
94
+ /** Renders UI in 'readOnly' state */
95
+ $isReadOnly: boolean;
93
96
  /** Renders UI in 'disabled' state */
94
97
  $disabled: boolean;
95
98
  /** Renders UI in 'error' state */
package/input/input.js CHANGED
@@ -82,23 +82,27 @@ var Input = /*#__PURE__*/function (_React$Component) {
82
82
  _this = _super.call.apply(_super, [this].concat(args));
83
83
 
84
84
  _defineProperty(_assertThisInitialized(_this), "state", {
85
- isFocused: _this.props.autoFocus || false
85
+ isFocused: _this.props.autoFocus && !_this.props.readOnly || false
86
86
  });
87
87
 
88
88
  _defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
89
- _this.setState({
90
- isFocused: true
91
- });
89
+ if (!_this.props.readOnly) {
90
+ _this.setState({
91
+ isFocused: true
92
+ });
92
93
 
93
- _this.props.onFocus(e);
94
+ _this.props.onFocus(e);
95
+ }
94
96
  });
95
97
 
96
98
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
97
- _this.setState({
98
- isFocused: false
99
- });
99
+ if (!_this.props.readOnly) {
100
+ _this.setState({
101
+ isFocused: false
102
+ });
100
103
 
101
- _this.props.onBlur(e);
104
+ _this.props.onBlur(e);
105
+ }
102
106
  });
103
107
 
104
108
  return _this;
@@ -175,7 +179,8 @@ _defineProperty(Input, "defaultProps", {
175
179
  startEnhancer: null,
176
180
  endEnhancer: null,
177
181
  clearable: false,
178
- type: 'text'
182
+ type: 'text',
183
+ readOnly: false
179
184
  });
180
185
 
181
186
  function getAdjoinedProp(startEnhancer, endEnhancer) {
@@ -28,6 +28,7 @@ class Input extends React.Component<InputPropsT, InternalStateT> {
28
28
  endEnhancer: null,
29
29
  clearable: false,
30
30
  type: 'text',
31
+ readOnly: false,
31
32
  };
32
33
 
33
34
  /**
@@ -35,17 +36,21 @@ class Input extends React.Component<InputPropsT, InternalStateT> {
35
36
  * customers shouldn't have to manage themselves, such as input's focus state.
36
37
  */
37
38
  state = {
38
- isFocused: this.props.autoFocus || false,
39
+ isFocused: (this.props.autoFocus && !this.props.readOnly) || false,
39
40
  };
40
41
 
41
42
  onFocus = (e: SyntheticFocusEvent<HTMLInputElement>) => {
42
- this.setState({ isFocused: true });
43
- this.props.onFocus(e);
43
+ if (!this.props.readOnly) {
44
+ this.setState({ isFocused: true });
45
+ this.props.onFocus(e);
46
+ }
44
47
  };
45
48
 
46
49
  onBlur = (e: SyntheticFocusEvent<HTMLInputElement>) => {
47
- this.setState({ isFocused: false });
48
- this.props.onBlur(e);
50
+ if (!this.props.readOnly) {
51
+ this.setState({ isFocused: false });
52
+ this.props.onBlur(e);
53
+ }
49
54
  };
50
55
 
51
56
  render() {
@@ -43,14 +43,16 @@ var MaskOverride = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
43
43
  onBlur = _ref.onBlur,
44
44
  value = _ref.value,
45
45
  disabled = _ref.disabled,
46
- restProps = _objectWithoutProperties(_ref, ["startEnhancer", "endEnhancer", "error", "positive", "onChange", "onFocus", "onBlur", "value", "disabled"]);
46
+ readOnly = _ref.readOnly,
47
+ restProps = _objectWithoutProperties(_ref, ["startEnhancer", "endEnhancer", "error", "positive", "onChange", "onFocus", "onBlur", "value", "disabled", "readOnly"]);
47
48
 
48
49
  return /*#__PURE__*/React.createElement(_reactInputMask.default, _extends({
49
50
  onChange: onChange,
50
51
  onFocus: onFocus,
51
52
  onBlur: onBlur,
52
53
  value: value,
53
- disabled: disabled
54
+ disabled: disabled,
55
+ readOnly: readOnly
54
56
  }, restProps), function (props) {
55
57
  return /*#__PURE__*/React.createElement(_styledComponents.Input, _extends({
56
58
  ref: ref,
@@ -58,7 +60,8 @@ var MaskOverride = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
58
60
  onFocus: onFocus,
59
61
  onBlur: onBlur,
60
62
  value: value,
61
- disabled: disabled
63
+ disabled: disabled,
64
+ readOnly: readOnly
62
65
  }, props));
63
66
  });
64
67
  });
@@ -28,6 +28,7 @@ const MaskOverride = React.forwardRef<MaskedInputPropsT, HTMLInputElement>(
28
28
  onBlur,
29
29
  value,
30
30
  disabled,
31
+ readOnly,
31
32
  ...restProps
32
33
  }: MaskedInputPropsT,
33
34
  ref
@@ -39,6 +40,7 @@ const MaskOverride = React.forwardRef<MaskedInputPropsT, HTMLInputElement>(
39
40
  onBlur={onBlur}
40
41
  value={value}
41
42
  disabled={disabled}
43
+ readOnly={readOnly}
42
44
  {...restProps}
43
45
  >
44
46
  {(props) => (
@@ -49,6 +51,7 @@ const MaskOverride = React.forwardRef<MaskedInputPropsT, HTMLInputElement>(
49
51
  onBlur={onBlur}
50
52
  value={value}
51
53
  disabled={disabled}
54
+ readOnly={readOnly}
52
55
  {...props}
53
56
  />
54
57
  )}
@@ -38,6 +38,8 @@ export type StateReducerT = (
38
38
  export type SharedPropsT = {|
39
39
  /** Renders UI in 'focus' state */
40
40
  $isFocused: boolean,
41
+ /** Renders UI in 'readOnly' state */
42
+ $isReadOnly: boolean,
41
43
  /** Renders UI in 'disabled' state */
42
44
  $disabled: boolean,
43
45
  /** Renders UI in 'error' state */
@@ -141,6 +143,8 @@ export type BaseInputPropsT<T> = {|
141
143
  max?: number,
142
144
  /** step value when used as input type=number */
143
145
  step?: number | 'any',
146
+ /** Renders component in 'readOnly' state. */
147
+ readOnly?: boolean,
144
148
  |};
145
149
 
146
150
  export type InputPropsT = {|
package/input/utils.js CHANGED
@@ -17,7 +17,8 @@ function getSharedProps(props, state) {
17
17
  positive = props.positive,
18
18
  adjoined = props.adjoined,
19
19
  size = props.size,
20
- required = props.required;
20
+ required = props.required,
21
+ readOnly = props.readOnly;
21
22
  var isFocused = state.isFocused;
22
23
  return {
23
24
  $isFocused: isFocused,
@@ -26,6 +27,7 @@ function getSharedProps(props, state) {
26
27
  $positive: positive,
27
28
  $adjoined: adjoined,
28
29
  $size: size,
29
- $required: required
30
+ $required: required,
31
+ $isReadOnly: readOnly
30
32
  };
31
33
  }
@@ -11,7 +11,7 @@ export function getSharedProps<T>(
11
11
  props: BaseInputPropsT<T> | InputPropsT,
12
12
  state: InternalStateT
13
13
  ): $Shape<SharedPropsT> {
14
- const { disabled, error, positive, adjoined, size, required } = props;
14
+ const { disabled, error, positive, adjoined, size, required, readOnly } = props;
15
15
  const { isFocused } = state;
16
16
  return {
17
17
  $isFocused: isFocused,
@@ -21,6 +21,7 @@ export function getSharedProps<T>(
21
21
  $adjoined: adjoined,
22
22
  $size: size,
23
23
  $required: required,
24
+ $isReadOnly: readOnly,
24
25
  };
25
26
  }
26
27
 
package/list/index.d.ts CHANGED
@@ -47,11 +47,11 @@ export interface LabelOverrides {
47
47
  }
48
48
 
49
49
  export interface PropsT {
50
- artwork?: React.ReactNode;
50
+ artwork?: (args: { size: number }) => React.ReactNode;
51
51
  artworkSize?: ArtworkSizesT | number;
52
52
  shape?: ShapeT;
53
53
  children: React.ReactNode;
54
- endEnhancer?: React.ReactNode;
54
+ endEnhancer?: () => React.ReactNode;
55
55
  overrides?: ListOverrides;
56
56
  sublist?: boolean;
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "0.0.0-next-6bede4f",
3
+ "version": "0.0.0-next-e047a0a",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -315,8 +315,10 @@ var Select = /*#__PURE__*/function (_React$Component) {
315
315
  if (containsNode(_this.anchor.current, event.relatedTarget) || containsNode(_this.dropdown.current, event.relatedTarget)) {
316
316
  return;
317
317
  }
318
- } else if (containsNode(_this.anchor.current, event.target)) {
319
- return;
318
+ } else if (event.type !== 'blur') {
319
+ if (containsNode(_this.anchor.current, event.target)) {
320
+ return;
321
+ }
320
322
  }
321
323
 
322
324
  if (_this.props.onBlur) {
@@ -697,6 +699,8 @@ var Select = /*#__PURE__*/function (_React$Component) {
697
699
  }, {
698
700
  key: "componentDidUpdate",
699
701
  value: function componentDidUpdate(prevProps, prevState) {
702
+ var _this2 = this;
703
+
700
704
  if (typeof document !== 'undefined') {
701
705
  if (prevState.isOpen !== this.state.isOpen) {
702
706
  if (this.state.isOpen) {
@@ -709,7 +713,9 @@ var Select = /*#__PURE__*/function (_React$Component) {
709
713
  }
710
714
 
711
715
  if (!prevState.isFocused && this.state.isFocused) {
712
- document.addEventListener('click', this.handleClickOutside);
716
+ setTimeout(function () {
717
+ return document.addEventListener('click', _this2.handleClickOutside);
718
+ }, 0);
713
719
  }
714
720
  }
715
721
  }
@@ -778,7 +784,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
778
784
  * Extends the value into an array from the given options
779
785
  */
780
786
  function getValueArray(value) {
781
- var _this2 = this;
787
+ var _this3 = this;
782
788
 
783
789
  if (!Array.isArray(value)) {
784
790
  if (value === null || value === undefined) return [];
@@ -786,7 +792,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
786
792
  }
787
793
 
788
794
  return value.map(function (value) {
789
- return (0, _index3.expandValue)(value, _this2.props);
795
+ return (0, _index3.expandValue)(value, _this3.props);
790
796
  });
791
797
  }
792
798
  }, {
@@ -831,7 +837,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
831
837
  }, {
832
838
  key: "renderValue",
833
839
  value: function renderValue(valueArray, isOpen, locale) {
834
- var _this3 = this;
840
+ var _this4 = this;
835
841
 
836
842
  var _this$props$overrides2 = this.props.overrides,
837
843
  overrides = _this$props$overrides2 === void 0 ? {} : _this$props$overrides2;
@@ -848,9 +854,9 @@ var Select = /*#__PURE__*/function (_React$Component) {
848
854
  var disabled = sharedProps.$disabled || value.clearableValue === false;
849
855
  return /*#__PURE__*/React.createElement(Value, _extends({
850
856
  value: value,
851
- key: "value-".concat(i, "-").concat(value[_this3.props.valueKey]),
857
+ key: "value-".concat(i, "-").concat(value[_this4.props.valueKey]),
852
858
  removeValue: function removeValue() {
853
- return _this3.removeValue(value);
859
+ return _this4.removeValue(value);
854
860
  },
855
861
  disabled: disabled,
856
862
  overrides: {
@@ -879,7 +885,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
879
885
  }, {
880
886
  key: "renderInput",
881
887
  value: function renderInput(listboxId) {
882
- var _this4 = this;
888
+ var _this5 = this;
883
889
 
884
890
  var _this$props$overrides3 = this.props.overrides,
885
891
  overrides = _this$props$overrides3 === void 0 ? {} : _this$props$overrides3;
@@ -892,7 +898,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
892
898
  var sharedProps = this.getSharedProps();
893
899
  var isOpen = this.state.isOpen;
894
900
  var selected = this.getValueArray(this.props.value).map(function (v) {
895
- return v[_this4.props.labelKey];
901
+ return v[_this5.props.labelKey];
896
902
  }).join(', ');
897
903
  var selectedLabel = selected.length ? "Selected ".concat(selected, ". ") : '';
898
904
  var label = "".concat(selectedLabel).concat(this.props['aria-label'] || '');
@@ -1053,7 +1059,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
1053
1059
  }, {
1054
1060
  key: "filterOptions",
1055
1061
  value: function filterOptions(excludeOptions) {
1056
- var _this5 = this;
1062
+ var _this6 = this;
1057
1063
 
1058
1064
  var filterValue = this.state.inputValue.trim(); // apply filter function
1059
1065
 
@@ -1066,9 +1072,9 @@ var Select = /*#__PURE__*/function (_React$Component) {
1066
1072
 
1067
1073
 
1068
1074
  var filterDoesNotMatchOption = this.props.ignoreCase ? function (opt) {
1069
- return opt[_this5.props.labelKey].toLowerCase() !== filterValue.toLowerCase().trim();
1075
+ return opt[_this6.props.labelKey].toLowerCase() !== filterValue.toLowerCase().trim();
1070
1076
  } : function (opt) {
1071
- return opt[_this5.props.labelKey] !== filterValue.trim();
1077
+ return opt[_this6.props.labelKey] !== filterValue.trim();
1072
1078
  };
1073
1079
 
1074
1080
  if (filterValue && this.props.creatable && this.options.concat(this.props.value).every(filterDoesNotMatchOption)) {
@@ -1123,7 +1129,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
1123
1129
  }, {
1124
1130
  key: "render",
1125
1131
  value: function render() {
1126
- var _this6 = this;
1132
+ var _this7 = this;
1127
1133
 
1128
1134
  this.options = (0, _index3.normalizeOptions)(this.props.options);
1129
1135
  var _this$props2 = this.props,
@@ -1195,55 +1201,55 @@ var Select = /*#__PURE__*/function (_React$Component) {
1195
1201
  , _extends({
1196
1202
  innerRef: function innerRef(ref) {
1197
1203
  if (!ref) return;
1198
- _this6.anchor = ref.anchorRef;
1204
+ _this7.anchor = ref.anchorRef;
1199
1205
  },
1200
1206
  autoFocus: false,
1201
1207
  focusLock: false,
1202
- mountNode: _this6.props.mountNode,
1208
+ mountNode: _this7.props.mountNode,
1203
1209
  onEsc: function onEsc() {
1204
- return _this6.closeMenu();
1210
+ return _this7.closeMenu();
1205
1211
  },
1206
1212
  isOpen: isOpen,
1207
1213
  popoverMargin: 0,
1208
1214
  content: function content() {
1209
1215
  var dropdownProps = {
1210
- error: _this6.props.error,
1211
- positive: _this6.props.positive,
1212
- getOptionLabel: _this6.props.getOptionLabel || _this6.getOptionLabel.bind(_this6, locale),
1216
+ error: _this7.props.error,
1217
+ positive: _this7.props.positive,
1218
+ getOptionLabel: _this7.props.getOptionLabel || _this7.getOptionLabel.bind(_this7, locale),
1213
1219
  id: listboxId,
1214
- isLoading: _this6.props.isLoading,
1215
- labelKey: _this6.props.labelKey,
1216
- maxDropdownHeight: _this6.props.maxDropdownHeight,
1220
+ isLoading: _this7.props.isLoading,
1221
+ labelKey: _this7.props.labelKey,
1222
+ maxDropdownHeight: _this7.props.maxDropdownHeight,
1217
1223
  multi: multi,
1218
1224
  noResultsMsg: noResultsMsg,
1219
- onActiveDescendantChange: _this6.handleActiveDescendantChange,
1220
- onItemSelect: _this6.selectValue,
1225
+ onActiveDescendantChange: _this7.handleActiveDescendantChange,
1226
+ onItemSelect: _this7.selectValue,
1221
1227
  options: options,
1222
1228
  overrides: overrides,
1223
- required: _this6.props.required,
1224
- searchable: _this6.props.searchable,
1225
- size: _this6.props.size,
1229
+ required: _this7.props.required,
1230
+ searchable: _this7.props.searchable,
1231
+ size: _this7.props.size,
1226
1232
  type: type,
1227
1233
  value: valueArray,
1228
- valueKey: _this6.props.valueKey,
1229
- width: _this6.anchor.current ? _this6.anchor.current.clientWidth : null,
1230
- keyboardControlNode: _this6.anchor
1234
+ valueKey: _this7.props.valueKey,
1235
+ width: _this7.anchor.current ? _this7.anchor.current.clientWidth : null,
1236
+ keyboardControlNode: _this7.anchor
1231
1237
  };
1232
1238
  return /*#__PURE__*/React.createElement(_dropdown.default, _extends({
1233
- innerRef: _this6.dropdown
1239
+ innerRef: _this7.dropdown
1234
1240
  }, dropdownProps));
1235
1241
  },
1236
1242
  placement: _index2.PLACEMENT.bottom
1237
1243
  }, popoverProps), /*#__PURE__*/React.createElement(Root, _extends({
1238
- onBlur: _this6.handleBlur,
1244
+ onBlur: _this7.handleBlur,
1239
1245
  "data-baseweb": "select"
1240
1246
  }, sharedProps, rootProps), /*#__PURE__*/React.createElement(ControlContainer, _extends({
1241
- onKeyDown: _this6.handleKeyDown,
1242
- onClick: _this6.handleClick,
1243
- onTouchEnd: _this6.handleTouchEnd,
1244
- onTouchMove: _this6.handleTouchMove,
1245
- onTouchStart: _this6.handleTouchStart
1246
- }, sharedProps, controlContainerProps), type === _constants.TYPE.search ? _this6.renderSearch() : null, /*#__PURE__*/React.createElement(ValueContainer, _extends({}, sharedProps, valueContainerProps), _this6.renderValue(valueArray, isOpen, locale), _this6.renderInput(listboxId), _this6.shouldShowPlaceholder() ? /*#__PURE__*/React.createElement(Placeholder, _extends({}, sharedProps, placeholderProps), typeof _this6.props.placeholder !== 'undefined' ? _this6.props.placeholder : locale.select.placeholder) : null), /*#__PURE__*/React.createElement(IconsContainer, _extends({}, sharedProps, iconsContainerProps), _this6.renderLoading(), _this6.renderClear(), type === _constants.TYPE.select ? _this6.renderArrow() : null))));
1247
+ onKeyDown: _this7.handleKeyDown,
1248
+ onClick: _this7.handleClick,
1249
+ onTouchEnd: _this7.handleTouchEnd,
1250
+ onTouchMove: _this7.handleTouchMove,
1251
+ onTouchStart: _this7.handleTouchStart
1252
+ }, sharedProps, controlContainerProps), type === _constants.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 === _constants.TYPE.select ? _this7.renderArrow() : null))));
1247
1253
  });
1248
1254
  });
1249
1255
  }
@@ -142,7 +142,7 @@ class Select extends React.Component<PropsT, SelectStateT> {
142
142
  }
143
143
 
144
144
  if (!prevState.isFocused && this.state.isFocused) {
145
- document.addEventListener('click', this.handleClickOutside);
145
+ setTimeout(() => document.addEventListener('click', this.handleClickOutside), 0);
146
146
  }
147
147
  }
148
148
  }
@@ -316,8 +316,10 @@ class Select extends React.Component<PropsT, SelectStateT> {
316
316
  ) {
317
317
  return;
318
318
  }
319
- } else if (containsNode(this.anchor.current, event.target)) {
320
- return;
319
+ } else if (event.type !== 'blur') {
320
+ if (containsNode(this.anchor.current, event.target)) {
321
+ return;
322
+ }
321
323
  }
322
324
 
323
325
  if (this.props.onBlur) {
@@ -72,23 +72,27 @@ var Textarea = /*#__PURE__*/function (_React$Component) {
72
72
  _this = _super.call.apply(_super, [this].concat(args));
73
73
 
74
74
  _defineProperty(_assertThisInitialized(_this), "state", {
75
- isFocused: _this.props.autoFocus || false
75
+ isFocused: _this.props.autoFocus && !_this.props.readOnly || false
76
76
  });
77
77
 
78
78
  _defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
79
- _this.setState({
80
- isFocused: true
81
- });
79
+ if (!_this.props.readOnly) {
80
+ _this.setState({
81
+ isFocused: true
82
+ });
82
83
 
83
- _this.props.onFocus(e);
84
+ _this.props.onFocus(e);
85
+ }
84
86
  });
85
87
 
86
88
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
87
- _this.setState({
88
- isFocused: false
89
- });
89
+ if (!_this.props.readOnly) {
90
+ _this.setState({
91
+ isFocused: false
92
+ });
90
93
 
91
- _this.props.onBlur(e);
94
+ _this.props.onBlur(e);
95
+ }
92
96
  });
93
97
 
94
98
  return _this;
@@ -116,6 +120,7 @@ var Textarea = /*#__PURE__*/function (_React$Component) {
116
120
  return /*#__PURE__*/React.createElement(Root, _extends({
117
121
  "data-baseweb": "textarea",
118
122
  $isFocused: this.state.isFocused,
123
+ $isReadOnly: this.props.readOnly,
119
124
  $disabled: this.props.disabled,
120
125
  $error: this.props.error,
121
126
  $positive: this.props.positive,
@@ -136,6 +141,7 @@ var Textarea = /*#__PURE__*/function (_React$Component) {
136
141
  _defineProperty(Textarea, "defaultProps", {
137
142
  autoFocus: false,
138
143
  disabled: false,
144
+ readOnly: false,
139
145
  error: false,
140
146
  name: '',
141
147
  onBlur: function onBlur() {},