@basic-ui/material 1.0.0-alpha.30 → 1.0.0-alpha.32

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.
@@ -5178,6 +5178,9 @@ const SwitchCircle = ({
5178
5178
  }) => /*#__PURE__*/jsxRuntime.jsx(Box, {
5179
5179
  __css: {
5180
5180
  position: 'absolute',
5181
+ display: 'inline-flex',
5182
+ alignItems: 'center',
5183
+ justifyContent: 'center',
5181
5184
  width: checked ? CIRCLE_SIZE_INACTIVE_CHECKED : CIRCLE_SIZE_INACTIVE_UNCHECKED,
5182
5185
  height: checked ? CIRCLE_SIZE_INACTIVE_CHECKED : CIRCLE_SIZE_INACTIVE_UNCHECKED,
5183
5186
  boxSizing: 'border-box',
@@ -5185,12 +5188,14 @@ const SwitchCircle = ({
5185
5188
  pointerEvents: 'none',
5186
5189
  zIndex: 1,
5187
5190
  backgroundColor: checked ? 'on.primary' : 'outline',
5191
+ color: checked ? 'primary' : 'on.outline',
5188
5192
  top: '50%',
5189
5193
  left: '50%',
5190
5194
  transform: 'translate(-50%, -50%)',
5191
5195
  transition: 'inherit',
5192
5196
  '[data-switch-thumb=""]:active ~ &, [data-switch-thumb=""]:focus-visible ~ &, [data-switch-thumb=""]:hover ~ &': {
5193
- backgroundColor: checked ? 'primary-container' : 'on.surface-variant'
5197
+ backgroundColor: checked ? 'primary-container' : 'on.surface-variant',
5198
+ color: checked ? 'on.primary-container' : 'surface-variant'
5194
5199
  },
5195
5200
  '[data-switch-thumb=""]:active ~ &, [data-switch-thumb=""]:focus-visible ~ &': {
5196
5201
  height: checked ? CIRCLE_SIZE_ACTIVE_CHECKED : CIRCLE_SIZE_ACTIVE_UNCHECKED,
@@ -5199,6 +5204,7 @@ const SwitchCircle = ({
5199
5204
  '[data-switch-thumb=""]:disabled ~ &': {
5200
5205
  opacity: checked ? 1 : 0.38,
5201
5206
  backgroundColor: checked ? 'surface' : 'on.surface',
5207
+ color: checked ? 'on.surface' : 'surface',
5202
5208
  height: checked ? CIRCLE_SIZE_INACTIVE_CHECKED : CIRCLE_SIZE_INACTIVE_UNCHECKED,
5203
5209
  width: checked ? CIRCLE_SIZE_INACTIVE_CHECKED : CIRCLE_SIZE_INACTIVE_UNCHECKED
5204
5210
  }
@@ -5211,7 +5217,7 @@ const SwitchCircle = ({
5211
5217
 
5212
5218
  const CheckBoxCore = core.CheckBox;
5213
5219
 
5214
- function getSizeCssVariables(size) {
5220
+ function getSizeCssVariables(size, hasIcon) {
5215
5221
  const multiplier = size === 'small' ? 0.75 : 1;
5216
5222
  const BORDER_WIDTH = 2;
5217
5223
  const TRAIL_WIDTH = 52 * multiplier;
@@ -5220,11 +5226,16 @@ function getSizeCssVariables(size) {
5220
5226
  ['--switch-border-width']: polished.rem(BORDER_WIDTH),
5221
5227
  ['--switch-trail-width']: polished.rem(TRAIL_WIDTH),
5222
5228
  ['--switch-trail-height']: polished.rem(TRAIL_HEIGHT),
5229
+ ['--switch-icon-size']: polished.rem(TRAIL_HEIGHT / 2),
5223
5230
  ['--switch-state-layer-size']: polished.rem(40 * multiplier),
5224
5231
  ['--switch-thumb-size-checked-inactive']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 4),
5225
5232
  ['--switch-thumb-size-checked-active']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 2),
5226
5233
  ['--switch-thumb-size-unchecked-inactive']: polished.rem(TRAIL_HEIGHT / 2),
5227
- ['--switch-thumb-size-unchecked-active']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 2)
5234
+ ['--switch-thumb-size-unchecked-active']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 2),
5235
+ ...(hasIcon && {
5236
+ ['--switch-thumb-size-unchecked-inactive']: 'var(--switch-thumb-size-checked-inactive)',
5237
+ ['--switch-thumb-size-unchecked-active']: 'var(--switch-thumb-size-checked-active)'
5238
+ })
5228
5239
  };
5229
5240
  }
5230
5241
 
@@ -5236,6 +5247,7 @@ const SwitchInner = /*#__PURE__*/react$1.forwardRef(function SwitchInner(props,
5236
5247
  onChange,
5237
5248
  size = 'default',
5238
5249
  __css,
5250
+ icon,
5239
5251
  ...otherProps
5240
5252
  } = props;
5241
5253
  const color = checked ? 'primary' : 'on.surface';
@@ -5244,7 +5256,7 @@ const SwitchInner = /*#__PURE__*/react$1.forwardRef(function SwitchInner(props,
5244
5256
  display: "inline-block",
5245
5257
  position: "relative",
5246
5258
  minWidth: "auto",
5247
- sx: getSizeCssVariables(size),
5259
+ sx: getSizeCssVariables(size, Boolean(icon)),
5248
5260
  children: [/*#__PURE__*/jsxRuntime.jsx(SwitchTrail, {
5249
5261
  checked: checked,
5250
5262
  disabled: disabled
@@ -5285,7 +5297,12 @@ const SwitchInner = /*#__PURE__*/react$1.forwardRef(function SwitchInner(props,
5285
5297
  ...__css
5286
5298
  }
5287
5299
  }), /*#__PURE__*/jsxRuntime.jsx(SwitchCircle, {
5288
- checked: checked
5300
+ checked: checked,
5301
+ children: icon ? /*#__PURE__*/react$1.cloneElement(icon, {
5302
+ checked,
5303
+ ['data-checkbox-icon']: '',
5304
+ disabled
5305
+ }) : null
5289
5306
  })]
5290
5307
  })]
5291
5308
  });
@@ -5293,6 +5310,7 @@ const SwitchInner = /*#__PURE__*/react$1.forwardRef(function SwitchInner(props,
5293
5310
  const Switch = /*#__PURE__*/react$1.forwardRef(function Switch(props, forwardedRef) {
5294
5311
  const {
5295
5312
  as = 'input',
5313
+ icon,
5296
5314
  disabled,
5297
5315
  children,
5298
5316
  ...otherProps
@@ -5302,6 +5320,7 @@ const Switch = /*#__PURE__*/react$1.forwardRef(function Switch(props, forwardedR
5302
5320
  as: SwitchInner,
5303
5321
  innerAs: as,
5304
5322
  ref: forwardedRef,
5323
+ icon: icon,
5305
5324
  disabled: disabled,
5306
5325
  ...otherProps
5307
5326
  });