@instructure/ui-checkbox 11.7.3-snapshot-7 → 11.7.3-snapshot-26

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/es/Checkbox/v1/CheckboxFacade/index.js +30 -30
  3. package/es/Checkbox/v1/CheckboxFacade/styles.js +8 -6
  4. package/es/Checkbox/v1/CheckboxFacade/theme.js +29 -28
  5. package/es/Checkbox/v1/ToggleFacade/index.js +39 -37
  6. package/es/Checkbox/v1/ToggleFacade/styles.js +8 -6
  7. package/es/Checkbox/v1/ToggleFacade/theme.js +37 -36
  8. package/es/Checkbox/v1/index.js +121 -116
  9. package/es/Checkbox/v1/styles.js +4 -2
  10. package/es/Checkbox/v1/theme.js +8 -7
  11. package/es/Checkbox/v2/CheckboxFacade/index.js +34 -33
  12. package/es/Checkbox/v2/CheckboxFacade/styles.js +12 -11
  13. package/es/Checkbox/v2/ToggleFacade/index.js +39 -37
  14. package/es/Checkbox/v2/ToggleFacade/styles.js +13 -12
  15. package/es/Checkbox/v2/index.js +123 -119
  16. package/es/Checkbox/v2/styles.js +6 -5
  17. package/es/CheckboxGroup/v1/index.js +46 -41
  18. package/es/CheckboxGroup/v2/index.js +46 -41
  19. package/lib/Checkbox/v1/CheckboxFacade/index.js +32 -32
  20. package/lib/Checkbox/v1/CheckboxFacade/styles.js +8 -6
  21. package/lib/Checkbox/v1/CheckboxFacade/theme.js +29 -28
  22. package/lib/Checkbox/v1/ToggleFacade/index.js +39 -37
  23. package/lib/Checkbox/v1/ToggleFacade/styles.js +8 -6
  24. package/lib/Checkbox/v1/ToggleFacade/theme.js +37 -36
  25. package/lib/Checkbox/v1/index.js +121 -116
  26. package/lib/Checkbox/v1/styles.js +4 -2
  27. package/lib/Checkbox/v1/theme.js +8 -7
  28. package/lib/Checkbox/v2/CheckboxFacade/index.js +34 -33
  29. package/lib/Checkbox/v2/CheckboxFacade/styles.js +12 -11
  30. package/lib/Checkbox/v2/ToggleFacade/index.js +39 -37
  31. package/lib/Checkbox/v2/ToggleFacade/styles.js +13 -12
  32. package/lib/Checkbox/v2/index.js +123 -119
  33. package/lib/Checkbox/v2/styles.js +6 -5
  34. package/lib/CheckboxGroup/v1/index.js +46 -41
  35. package/lib/CheckboxGroup/v2/index.js +46 -41
  36. package/package.json +17 -17
  37. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class, _Checkbox;
1
+ var _dec, _dec2, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -44,70 +44,25 @@ category: components
44
44
  tags: toggle, switch
45
45
  ---
46
46
  **/
47
- let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_Checkbox = class Checkbox extends Component {
47
+ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class Checkbox extends Component {
48
+ static displayName = "Checkbox";
49
+ static componentId = 'Checkbox';
50
+ static allowedProps = allowedProps;
51
+ static defaultProps = {
52
+ size: 'medium',
53
+ variant: 'simple',
54
+ disabled: false,
55
+ inline: false,
56
+ indeterminate: false,
57
+ readOnly: false,
58
+ labelPlacement: 'end'
59
+ };
48
60
  constructor(props) {
49
61
  super(props);
50
- this._defaultId = void 0;
51
- this._input = null;
52
- this.ref = null;
53
- this.handleRef = el => {
54
- this.ref = el;
55
- };
56
- this.handleInputRef = el => {
57
- this._input = el;
58
- if (typeof this.props.inputRef === 'function') {
59
- this.props.inputRef(el);
60
- }
61
- };
62
- this.handleChange = e => {
63
- const _this$props = this.props,
64
- onChange = _this$props.onChange,
65
- disabled = _this$props.disabled,
66
- checked = _this$props.checked,
67
- readOnly = _this$props.readOnly;
68
- if (disabled || readOnly) {
69
- e.preventDefault();
70
- return;
71
- }
72
- if (typeof checked === 'undefined') {
73
- this.setState({
74
- checked: !this.state.checked
75
- });
76
- }
77
- if (typeof onChange === 'function') {
78
- onChange(e);
79
- }
80
- };
81
- this.handleKeyDown = e => {
82
- if (this.props.variant === 'toggle' && e.keyCode === keycode.codes.enter) {
83
- this._input && this._input.click();
84
- e.preventDefault();
85
- }
86
- };
87
- this.handleFocus = () => {
88
- this.setState({
89
- focused: true
90
- });
91
- };
92
- this.handleBlur = () => {
93
- this.setState({
94
- focused: false
95
- });
96
- };
97
- this.handleMouseOver = () => {
98
- !this.props.disabled && this.setState({
99
- hovered: true
100
- });
101
- };
102
- this.handleMouseOut = () => {
103
- this.setState({
104
- hovered: false
105
- });
106
- };
107
62
  this.state = {
108
63
  focused: false,
109
64
  hovered: false,
110
- checked: typeof props.checked === 'undefined' ? !!props.defaultChecked : void 0
65
+ checked: typeof props.checked === 'undefined' ? !!props.defaultChecked : undefined
111
66
  };
112
67
  if (typeof props.checked === 'undefined') {
113
68
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'checked' does not exist on type 'Readonl... Remove this comment to see the full error message
@@ -115,20 +70,76 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
115
70
  }
116
71
  this._defaultId = props.deterministicId();
117
72
  }
73
+ _defaultId;
74
+ _input = null;
75
+ ref = null;
76
+ handleRef = el => {
77
+ this.ref = el;
78
+ };
79
+ handleInputRef = el => {
80
+ this._input = el;
81
+ if (typeof this.props.inputRef === 'function') {
82
+ this.props.inputRef(el);
83
+ }
84
+ };
118
85
  componentDidMount() {
119
- var _this$props$makeStyle, _this$props2;
120
86
  if (this._input) {
121
87
  this._input.indeterminate = this.props.indeterminate;
122
88
  }
123
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
89
+ this.props.makeStyles?.();
124
90
  }
125
91
  componentDidUpdate(prevProps) {
126
- var _this$props$makeStyle2, _this$props3;
127
92
  if (prevProps.indeterminate !== this.props.indeterminate && this._input) {
128
93
  this._input.indeterminate = this.props.indeterminate || false;
129
94
  }
130
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
95
+ this.props.makeStyles?.();
131
96
  }
97
+ handleChange = e => {
98
+ const {
99
+ onChange,
100
+ disabled,
101
+ checked,
102
+ readOnly
103
+ } = this.props;
104
+ if (disabled || readOnly) {
105
+ e.preventDefault();
106
+ return;
107
+ }
108
+ if (typeof checked === 'undefined') {
109
+ this.setState({
110
+ checked: !this.state.checked
111
+ });
112
+ }
113
+ if (typeof onChange === 'function') {
114
+ onChange(e);
115
+ }
116
+ };
117
+ handleKeyDown = e => {
118
+ if (this.props.variant === 'toggle' && e.keyCode === keycode.codes.enter) {
119
+ this._input && this._input.click();
120
+ e.preventDefault();
121
+ }
122
+ };
123
+ handleFocus = () => {
124
+ this.setState({
125
+ focused: true
126
+ });
127
+ };
128
+ handleBlur = () => {
129
+ this.setState({
130
+ focused: false
131
+ });
132
+ };
133
+ handleMouseOver = () => {
134
+ !this.props.disabled && this.setState({
135
+ hovered: true
136
+ });
137
+ };
138
+ handleMouseOut = () => {
139
+ this.setState({
140
+ hovered: false
141
+ });
142
+ };
132
143
  get id() {
133
144
  return this.props.id || this._defaultId;
134
145
  }
@@ -139,31 +150,31 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
139
150
  return isActiveElement(this._input);
140
151
  }
141
152
  get isNewError() {
142
- var _this$props$messages;
143
- return !!((_this$props$messages = this.props.messages) !== null && _this$props$messages !== void 0 && _this$props$messages.find(m => m.type === 'newError'));
153
+ return !!this.props.messages?.find(m => m.type === 'newError');
144
154
  }
145
155
  get invalid() {
146
- var _this$props$messages2;
147
- return !!((_this$props$messages2 = this.props.messages) !== null && _this$props$messages2 !== void 0 && _this$props$messages2.find(m => m.type === 'newError' || m.type === 'error'));
156
+ return !!this.props.messages?.find(m => m.type === 'newError' || m.type === 'error');
148
157
  }
149
158
  focus() {
150
159
  this._input && this._input.focus();
151
160
  }
152
161
  renderFacade() {
153
- const _this$props4 = this.props,
154
- size = _this$props4.size,
155
- disabled = _this$props4.disabled,
156
- variant = _this$props4.variant,
157
- label = _this$props4.label,
158
- readOnly = _this$props4.readOnly,
159
- indeterminate = _this$props4.indeterminate,
160
- labelPlacement = _this$props4.labelPlacement,
161
- themeOverride = _this$props4.themeOverride,
162
- isRequired = _this$props4.isRequired,
163
- styles = _this$props4.styles;
164
- const _this$state = this.state,
165
- hovered = _this$state.hovered,
166
- focused = _this$state.focused;
162
+ const {
163
+ size,
164
+ disabled,
165
+ variant,
166
+ label,
167
+ readOnly,
168
+ indeterminate,
169
+ labelPlacement,
170
+ themeOverride,
171
+ isRequired,
172
+ styles
173
+ } = this.props;
174
+ const {
175
+ hovered,
176
+ focused
177
+ } = this.state;
167
178
  error(!(variant === 'simple' && labelPlacement !== 'end'), `[Checkbox] The \`simple\` variant does not support the \`labelPlacement\` property. Use the \`toggle\` variant instead.`);
168
179
  if (variant === 'toggle') {
169
180
  return _jsxs(ToggleFacade, {
@@ -176,7 +187,7 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
176
187
  themeOverride: themeOverride,
177
188
  invalid: this.invalid,
178
189
  children: [label, isRequired && label && _jsxs("span", {
179
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
190
+ css: this.invalid ? styles?.requiredInvalid : {},
180
191
  "aria-hidden": true,
181
192
  children: [' ', "*"]
182
193
  })]
@@ -191,7 +202,7 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
191
202
  themeOverride: themeOverride,
192
203
  invalid: this.invalid,
193
204
  children: [label, isRequired && label && _jsxs("span", {
194
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
205
+ css: this.invalid ? styles?.requiredInvalid : {},
195
206
  "aria-hidden": true,
196
207
  children: [' ', "*"]
197
208
  })]
@@ -199,37 +210,39 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
199
210
  }
200
211
  }
201
212
  renderMessages() {
202
- const _this$props5 = this.props,
203
- messages = _this$props5.messages,
204
- styles = _this$props5.styles,
205
- variant = _this$props5.variant;
213
+ const {
214
+ messages,
215
+ styles,
216
+ variant
217
+ } = this.props;
206
218
  return messages && messages.length > 0 ? _jsx(View, {
207
219
  display: "block",
208
220
  margin: "small 0 0",
209
- css: this.isNewError && (variant === 'toggle' ? styles === null || styles === void 0 ? void 0 : styles.indentedToggleError : styles === null || styles === void 0 ? void 0 : styles.indentedError),
221
+ css: this.isNewError && (variant === 'toggle' ? styles?.indentedToggleError : styles?.indentedError),
210
222
  children: _jsx(FormFieldMessages, {
211
223
  messages: messages
212
224
  })
213
225
  }) : null;
214
226
  }
215
227
  render() {
216
- const _this$props6 = this.props,
217
- disabled = _this$props6.disabled,
218
- readOnly = _this$props6.readOnly,
219
- value = _this$props6.value,
220
- onKeyDown = _this$props6.onKeyDown,
221
- onFocus = _this$props6.onFocus,
222
- onBlur = _this$props6.onBlur,
223
- onMouseOver = _this$props6.onMouseOver,
224
- onMouseOut = _this$props6.onMouseOut,
225
- indeterminate = _this$props6.indeterminate,
226
- variant = _this$props6.variant,
227
- styles = _this$props6.styles,
228
- isRequired = _this$props6.isRequired;
228
+ const {
229
+ disabled,
230
+ readOnly,
231
+ value,
232
+ onKeyDown,
233
+ onFocus,
234
+ onBlur,
235
+ onMouseOver,
236
+ onMouseOut,
237
+ indeterminate,
238
+ variant,
239
+ styles,
240
+ isRequired
241
+ } = this.props;
229
242
  const props = omitProps(this.props, Checkbox.allowedProps);
230
243
  error(!(variant === 'toggle' && indeterminate), `[Checkbox] The \`toggle\` variant does not support the \`indeterminate\` property. Use the \`simple\` variant instead.`);
231
244
  return _jsx("div", {
232
- css: styles === null || styles === void 0 ? void 0 : styles.checkbox
245
+ css: styles?.checkbox
233
246
  /* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
234
247
  onMouseOver: createChainedFunction(onMouseOver, this.handleMouseOver)
235
248
  /* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
@@ -237,7 +250,7 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
237
250
  ref: this.handleRef,
238
251
  "data-cid": "Checkbox",
239
252
  children: _jsxs("div", {
240
- css: styles === null || styles === void 0 ? void 0 : styles.container,
253
+ css: styles?.container,
241
254
  children: [_jsx("input", {
242
255
  ...props,
243
256
  id: this.id,
@@ -246,8 +259,8 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
246
259
  ref: this.handleInputRef,
247
260
  required: isRequired,
248
261
  disabled: disabled || readOnly,
249
- "aria-checked": indeterminate ? 'mixed' : void 0,
250
- css: styles === null || styles === void 0 ? void 0 : styles.input,
262
+ "aria-checked": indeterminate ? 'mixed' : undefined,
263
+ css: styles?.input,
251
264
  onChange: this.handleChange,
252
265
  onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
253
266
  onFocus: createChainedFunction(onFocus, this.handleFocus),
@@ -255,20 +268,12 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
255
268
  checked: this.checked
256
269
  }), _jsxs("label", {
257
270
  htmlFor: this.id,
258
- css: styles === null || styles === void 0 ? void 0 : styles.control,
271
+ css: styles?.control,
259
272
  children: [this.renderFacade(), this.renderMessages()]
260
273
  })]
261
274
  })
262
275
  });
263
276
  }
264
- }, _Checkbox.displayName = "Checkbox", _Checkbox.componentId = 'Checkbox', _Checkbox.allowedProps = allowedProps, _Checkbox.defaultProps = {
265
- size: 'medium',
266
- variant: 'simple',
267
- disabled: false,
268
- inline: false,
269
- indeterminate: false,
270
- readOnly: false,
271
- labelPlacement: 'end'
272
- }, _Checkbox)) || _class) || _class);
277
+ }) || _class) || _class);
273
278
  export default Checkbox;
274
279
  export { Checkbox, CheckboxFacade, ToggleFacade };
@@ -33,8 +33,10 @@
33
33
  * @return {Object} The final style object, which will be used in the component
34
34
  */
35
35
  const generateStyle = (componentTheme, props) => {
36
- const inline = props.inline,
37
- disabled = props.disabled;
36
+ const {
37
+ inline,
38
+ disabled
39
+ } = props;
38
40
  return {
39
41
  requiredInvalid: {
40
42
  color: componentTheme.requiredInvalidColor
@@ -28,14 +28,15 @@
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
- var _colors$contrasts;
32
- const colors = theme.colors,
33
- forms = theme.forms,
34
- spacing = theme.spacing;
31
+ const {
32
+ colors,
33
+ forms,
34
+ spacing
35
+ } = theme;
35
36
  const componentVariables = {
36
- requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.red5782,
37
- toggleErrorInsetWidth: `calc(${forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall}*1.5 + ${spacing === null || spacing === void 0 ? void 0 : spacing.small})`,
38
- checkErrorInsetWidth: `calc(1.25em + ${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall})`
37
+ requiredInvalidColor: colors?.contrasts?.red5782,
38
+ toggleErrorInsetWidth: `calc(${forms?.inputHeightSmall}*1.5 + ${spacing?.small})`,
39
+ checkErrorInsetWidth: `calc(1.25em + ${spacing?.xSmall})`
39
40
  };
40
41
  return {
41
42
  ...componentVariables
@@ -1,4 +1,4 @@
1
- var _dec, _class, _CheckboxFacade;
1
+ var _dec, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -34,28 +34,36 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
34
34
  parent: Checkbox
35
35
  ---
36
36
  **/
37
- let CheckboxFacade = (_dec = withStyle(generateStyle, 'Checkbox'), _dec(_class = (_CheckboxFacade = class CheckboxFacade extends Component {
38
- constructor(...args) {
39
- super(...args);
40
- this.ref = null;
41
- this.handleRef = el => {
42
- this.ref = el;
43
- };
44
- }
37
+ let CheckboxFacade = (_dec = withStyle(generateStyle, 'Checkbox'), _dec(_class = class CheckboxFacade extends Component {
38
+ static displayName = "CheckboxFacade";
39
+ static componentId = 'CheckboxFacade';
40
+ static allowedProps = allowedProps;
41
+ static defaultProps = {
42
+ checked: false,
43
+ disabled: false,
44
+ readOnly: false,
45
+ focused: false,
46
+ hovered: false,
47
+ size: 'medium',
48
+ indeterminate: false
49
+ };
50
+ ref = null;
51
+ handleRef = el => {
52
+ this.ref = el;
53
+ };
45
54
  componentDidMount() {
46
- var _this$props$makeStyle, _this$props;
47
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
55
+ this.props.makeStyles?.();
48
56
  }
49
57
  componentDidUpdate() {
50
- var _this$props$makeStyle2, _this$props2;
51
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
58
+ this.props.makeStyles?.();
52
59
  }
53
60
  renderIcon() {
54
- const _this$props3 = this.props,
55
- disabled = _this$props3.disabled,
56
- readOnly = _this$props3.readOnly,
57
- indeterminate = _this$props3.indeterminate,
58
- checked = _this$props3.checked;
61
+ const {
62
+ disabled,
63
+ readOnly,
64
+ indeterminate,
65
+ checked
66
+ } = this.props;
59
67
  const getIconColor = () => {
60
68
  if (disabled) {
61
69
  return 'disabledBaseColor';
@@ -75,30 +83,23 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, 'Checkbox'), _dec(_class =
75
83
  }
76
84
  }
77
85
  render() {
78
- const _this$props4 = this.props,
79
- children = _this$props4.children,
80
- styles = _this$props4.styles;
86
+ const {
87
+ children,
88
+ styles
89
+ } = this.props;
81
90
  return _jsxs("span", {
82
- css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
91
+ css: styles?.checkboxFacade,
83
92
  ref: this.handleRef,
84
93
  children: [_jsx("span", {
85
- css: styles === null || styles === void 0 ? void 0 : styles.facade,
94
+ css: styles?.facade,
86
95
  "aria-hidden": "true",
87
96
  children: this.renderIcon()
88
97
  }), _jsx("span", {
89
- css: styles === null || styles === void 0 ? void 0 : styles.label,
98
+ css: styles?.label,
90
99
  children: children
91
100
  })]
92
101
  });
93
102
  }
94
- }, _CheckboxFacade.displayName = "CheckboxFacade", _CheckboxFacade.componentId = 'CheckboxFacade', _CheckboxFacade.allowedProps = allowedProps, _CheckboxFacade.defaultProps = {
95
- checked: false,
96
- disabled: false,
97
- readOnly: false,
98
- focused: false,
99
- hovered: false,
100
- size: 'medium',
101
- indeterminate: false
102
- }, _CheckboxFacade)) || _class);
103
+ }) || _class);
103
104
  export default CheckboxFacade;
104
105
  export { CheckboxFacade };
@@ -35,15 +35,16 @@ import { calcFocusOutlineStyles } from '@instructure/emotion';
35
35
  * @return {Object} The final style object, which will be used in the component
36
36
  */
37
37
  const generateStyle = (componentTheme, props, sharedTokens) => {
38
- var _sizeVariants;
39
- const size = props.size,
40
- checked = props.checked,
41
- disabled = props.disabled,
42
- readOnly = props.readOnly,
43
- focused = props.focused,
44
- hovered = props.hovered,
45
- indeterminate = props.indeterminate,
46
- invalid = props.invalid;
38
+ const {
39
+ size,
40
+ checked,
41
+ disabled,
42
+ readOnly,
43
+ focused,
44
+ hovered,
45
+ indeterminate,
46
+ invalid
47
+ } = props;
47
48
  const isChecked = checked || indeterminate;
48
49
  const sizeVariants = {
49
50
  small: {
@@ -78,7 +79,7 @@ const generateStyle = (componentTheme, props, sharedTokens) => {
78
79
  }
79
80
  }
80
81
  };
81
- const sizeVariant = (_sizeVariants = sizeVariants[size]) !== null && _sizeVariants !== void 0 ? _sizeVariants : sizeVariants.medium;
82
+ const sizeVariant = sizeVariants[size] ?? sizeVariants.medium;
82
83
  const getLabelColor = () => {
83
84
  if (disabled) {
84
85
  return componentTheme.labelDisabledColor;
@@ -157,7 +158,7 @@ const generateStyle = (componentTheme, props, sharedTokens) => {
157
158
  facade: {
158
159
  label: 'checkboxFacade__facade',
159
160
  ...getFacadeStyles(),
160
- ...(sharedTokens !== null && sharedTokens !== void 0 && sharedTokens.focusOutline ? calcFocusOutlineStyles(sharedTokens.focusOutline, {
161
+ ...(sharedTokens?.focusOutline ? calcFocusOutlineStyles(sharedTokens.focusOutline, {
161
162
  withFocusOutline: focused
162
163
  }) : {})
163
164
  },
@@ -1,4 +1,4 @@
1
- var _dec, _class, _ToggleFacade;
1
+ var _dec, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -34,27 +34,35 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
34
34
  parent: Checkbox
35
35
  ---
36
36
  **/
37
- let ToggleFacade = (_dec = withStyle(generateStyle, 'Toggle'), _dec(_class = (_ToggleFacade = class ToggleFacade extends Component {
38
- constructor(...args) {
39
- super(...args);
40
- this.ref = null;
41
- this.handleRef = el => {
42
- this.ref = el;
43
- };
44
- }
37
+ let ToggleFacade = (_dec = withStyle(generateStyle, 'Toggle'), _dec(_class = class ToggleFacade extends Component {
38
+ static displayName = "ToggleFacade";
39
+ static componentId = 'ToggleFacade';
40
+ static allowedProps = allowedProps;
41
+ static defaultProps = {
42
+ checked: false,
43
+ focused: false,
44
+ hovered: false,
45
+ size: 'medium',
46
+ disabled: false,
47
+ readOnly: false,
48
+ labelPlacement: 'end'
49
+ };
50
+ ref = null;
51
+ handleRef = el => {
52
+ this.ref = el;
53
+ };
45
54
  componentDidMount() {
46
- var _this$props$makeStyle, _this$props;
47
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
55
+ this.props.makeStyles?.();
48
56
  }
49
57
  componentDidUpdate() {
50
- var _this$props$makeStyle2, _this$props2;
51
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
58
+ this.props.makeStyles?.();
52
59
  }
53
60
  renderIcon() {
54
- const _this$props3 = this.props,
55
- disabled = _this$props3.disabled,
56
- readOnly = _this$props3.readOnly,
57
- checked = _this$props3.checked;
61
+ const {
62
+ disabled,
63
+ readOnly,
64
+ checked
65
+ } = this.props;
58
66
  const getIconColor = () => {
59
67
  if (disabled) {
60
68
  return 'disabledBaseColor';
@@ -75,42 +83,36 @@ let ToggleFacade = (_dec = withStyle(generateStyle, 'Toggle'), _dec(_class = (_T
75
83
  }
76
84
  }
77
85
  renderLabel() {
78
- const _this$props4 = this.props,
79
- children = _this$props4.children,
80
- styles = _this$props4.styles;
86
+ const {
87
+ children,
88
+ styles
89
+ } = this.props;
81
90
  return _jsx("span", {
82
- css: styles === null || styles === void 0 ? void 0 : styles.label,
91
+ css: styles?.label,
83
92
  children: children
84
93
  });
85
94
  }
86
95
  render() {
87
- const _this$props5 = this.props,
88
- labelPlacement = _this$props5.labelPlacement,
89
- styles = _this$props5.styles;
96
+ const {
97
+ labelPlacement,
98
+ styles
99
+ } = this.props;
90
100
  return _jsxs("span", {
91
- css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade,
101
+ css: styles?.toggleFacade,
92
102
  ref: this.handleRef,
93
103
  children: [(labelPlacement === 'top' || labelPlacement === 'start') && this.renderLabel(), _jsx("span", {
94
- css: styles === null || styles === void 0 ? void 0 : styles.facade,
104
+ css: styles?.facade,
95
105
  "aria-hidden": "true",
96
106
  children: _jsx("span", {
97
- css: styles === null || styles === void 0 ? void 0 : styles.icon,
107
+ css: styles?.icon,
98
108
  children: _jsx("span", {
99
- css: styles === null || styles === void 0 ? void 0 : styles.iconToggle,
109
+ css: styles?.iconToggle,
100
110
  children: this.renderIcon()
101
111
  })
102
112
  })
103
113
  }), labelPlacement === 'end' && this.renderLabel()]
104
114
  });
105
115
  }
106
- }, _ToggleFacade.displayName = "ToggleFacade", _ToggleFacade.componentId = 'ToggleFacade', _ToggleFacade.allowedProps = allowedProps, _ToggleFacade.defaultProps = {
107
- checked: false,
108
- focused: false,
109
- hovered: false,
110
- size: 'medium',
111
- disabled: false,
112
- readOnly: false,
113
- labelPlacement: 'end'
114
- }, _ToggleFacade)) || _class);
116
+ }) || _class);
115
117
  export default ToggleFacade;
116
118
  export { ToggleFacade };