carbon-react 153.0.2 → 153.0.3

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.
@@ -48,7 +48,9 @@ const SwitchSlider = ({
48
48
  };
49
49
  const sliderContent = /*#__PURE__*/React.createElement(SwitchSliderPanel, _extends({
50
50
  "data-role": "slider-panel"
51
- }, sliderPanelStyleProps), loading ? /*#__PURE__*/React.createElement(Loader, _extends({
51
+ }, sliderPanelStyleProps, {
52
+ "aria-live": "polite"
53
+ }), loading ? /*#__PURE__*/React.createElement(Loader, _extends({
52
54
  "data-role": "switch-slider-loader"
53
55
  }, loaderProps)) : panelContent);
54
56
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HiddenContent, {
@@ -60,9 +60,13 @@ export const Switch = /*#__PURE__*/React.forwardRef(({
60
60
  Logger.deprecate("Uncontrolled behaviour in `Switch` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
61
61
  }
62
62
  const onChangeInternal = useCallback(e => {
63
- setCheckedInternal(e.target.checked);
64
- onChange?.(e);
65
- }, [setCheckedInternal, onChange]);
63
+ if (loading) {
64
+ e.preventDefault();
65
+ } else {
66
+ setCheckedInternal(e.target.checked);
67
+ onChange?.(e);
68
+ }
69
+ }, [setCheckedInternal, onChange, loading]);
66
70
  const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
67
71
  let shouldLabelBeInline = labelInline;
68
72
  // Coverage has been ignored here as this functionality is covered in a Playwright test.
@@ -88,7 +92,7 @@ export const Switch = /*#__PURE__*/React.forwardRef(({
88
92
  };
89
93
  const switchSliderProps = {
90
94
  checked: isControlled ? checked : checkedInternal,
91
- disabled: disabled || loading,
95
+ disabled,
92
96
  loading,
93
97
  isDarkBackground,
94
98
  size,
@@ -102,7 +106,7 @@ export const Switch = /*#__PURE__*/React.forwardRef(({
102
106
  error,
103
107
  warning,
104
108
  info,
105
- disabled: disabled || loading,
109
+ disabled,
106
110
  loading,
107
111
  checked: isControlled ? checked : checkedInternal,
108
112
  label,
@@ -143,7 +147,7 @@ export const Switch = /*#__PURE__*/React.forwardRef(({
143
147
  };
144
148
  const switchSliderPropsForNewValidation = {
145
149
  checked: isControlled ? checked : checkedInternal,
146
- disabled: disabled || loading,
150
+ disabled,
147
151
  loading,
148
152
  isDarkBackground,
149
153
  size,
@@ -155,7 +159,7 @@ export const Switch = /*#__PURE__*/React.forwardRef(({
155
159
  // set aria-invalid but prevent validationIconId from being added to aria-describedby
156
160
  error: !!error,
157
161
  warning,
158
- disabled: disabled || loading,
162
+ disabled,
159
163
  loading,
160
164
  checked: isControlled ? checked : checkedInternal,
161
165
  onBlur,
@@ -55,7 +55,9 @@ const SwitchSlider = ({
55
55
  };
56
56
  const sliderContent = /*#__PURE__*/_react.default.createElement(_switchSliderPanel.default, _extends({
57
57
  "data-role": "slider-panel"
58
- }, sliderPanelStyleProps), loading ? /*#__PURE__*/_react.default.createElement(_loader.default, _extends({
58
+ }, sliderPanelStyleProps, {
59
+ "aria-live": "polite"
60
+ }), loading ? /*#__PURE__*/_react.default.createElement(_loader.default, _extends({
59
61
  "data-role": "switch-slider-loader"
60
62
  }, loaderProps)) : panelContent);
61
63
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_switchSlider.HiddenContent, {
@@ -69,9 +69,13 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
69
69
  _logger.default.deprecate("Uncontrolled behaviour in `Switch` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
70
70
  }
71
71
  const onChangeInternal = (0, _react.useCallback)(e => {
72
- setCheckedInternal(e.target.checked);
73
- onChange?.(e);
74
- }, [setCheckedInternal, onChange]);
72
+ if (loading) {
73
+ e.preventDefault();
74
+ } else {
75
+ setCheckedInternal(e.target.checked);
76
+ onChange?.(e);
77
+ }
78
+ }, [setCheckedInternal, onChange, loading]);
75
79
  const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveLabelBreakpoint);
76
80
  let shouldLabelBeInline = labelInline;
77
81
  // Coverage has been ignored here as this functionality is covered in a Playwright test.
@@ -97,7 +101,7 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
97
101
  };
98
102
  const switchSliderProps = {
99
103
  checked: isControlled ? checked : checkedInternal,
100
- disabled: disabled || loading,
104
+ disabled,
101
105
  loading,
102
106
  isDarkBackground,
103
107
  size,
@@ -111,7 +115,7 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
111
115
  error,
112
116
  warning,
113
117
  info,
114
- disabled: disabled || loading,
118
+ disabled,
115
119
  loading,
116
120
  checked: isControlled ? checked : checkedInternal,
117
121
  label,
@@ -152,7 +156,7 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
152
156
  };
153
157
  const switchSliderPropsForNewValidation = {
154
158
  checked: isControlled ? checked : checkedInternal,
155
- disabled: disabled || loading,
159
+ disabled,
156
160
  loading,
157
161
  isDarkBackground,
158
162
  size,
@@ -164,7 +168,7 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
164
168
  // set aria-invalid but prevent validationIconId from being added to aria-describedby
165
169
  error: !!error,
166
170
  warning,
167
- disabled: disabled || loading,
171
+ disabled,
168
172
  loading,
169
173
  checked: isControlled ? checked : checkedInternal,
170
174
  onBlur,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "153.0.2",
3
+ "version": "153.0.3",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",