@crystallize/design-system 1.24.8 → 1.24.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @crystallize/design-system
2
2
 
3
+ ## 1.24.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d5ecee0: Extend the dropdown menu component to support the `open` prop.
8
+
9
+ ## 1.24.9
10
+
11
+ ### Patch Changes
12
+
13
+ - f8a34c7: Adjust switch component to allow placing thumb to middle position when checked is null
14
+
3
15
  ## 1.24.8
4
16
 
5
17
  ### Patch Changes
@@ -205,6 +205,7 @@ function DropdownMenuRoot({
205
205
  onOpenChange,
206
206
  container,
207
207
  modal,
208
+ open,
208
209
  ...delegated
209
210
  }) {
210
211
  const contentProps = {
@@ -217,6 +218,7 @@ function DropdownMenuRoot({
217
218
  return /* @__PURE__ */ jsxs3(DropdownMenuPrimitive3.Root, {
218
219
  onOpenChange,
219
220
  modal,
221
+ open,
220
222
  children: [
221
223
  /* @__PURE__ */ jsx5(DropdownMenuPrimitive3.Trigger, {
222
224
  disabled,
package/dist/index.css CHANGED
@@ -3531,6 +3531,9 @@
3531
3531
  height: 1rem;
3532
3532
  width: 1rem;
3533
3533
  }
3534
+ .c-switch-root-sm .c-switch-thumb.middle-position {
3535
+ transform: translateX(11px);
3536
+ }
3534
3537
  .c-switch-root-sm .c-switch-thumb[data-state=checked] {
3535
3538
  transform: translateX(20px);
3536
3539
  }
@@ -3542,6 +3545,9 @@
3542
3545
  height: 0.875rem;
3543
3546
  width: 0.875rem;
3544
3547
  }
3548
+ .c-switch-root-xs .c-switch-thumb.middle-position {
3549
+ transform: translateX(8px);
3550
+ }
3545
3551
  .c-switch-root-xs .c-switch-thumb[data-state=checked] {
3546
3552
  transform: translateX(16px);
3547
3553
  }
@@ -3552,12 +3558,15 @@
3552
3558
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
3553
3559
  border-radius: 9999px;
3554
3560
  --tw-bg-opacity: 1;
3555
- background-color: rgb(var(--c-color-purple-400-500) / var(--tw-bg-opacity));
3561
+ background-color: rgb(255 255 255 / var(--tw-bg-opacity));
3556
3562
  transition-property: all;
3557
3563
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
3558
3564
  transition-duration: 150ms;
3559
3565
  }
3560
3566
  .c-switch-thumb[data-state=checked] {
3561
3567
  --tw-bg-opacity: 1;
3562
- background-color: rgb(var(--c-color-green-500-400) / var(--tw-bg-opacity));
3568
+ background-color: rgb(255 255 255 / var(--tw-bg-opacity));
3569
+ }
3570
+ .c-switch-thumb {
3571
+ box-shadow: 0px 1px 2px 0px rgba(40, 41, 61, 0.2), 0px 2px 4px 0px rgba(96, 97, 112, 0.2);
3563
3572
  }
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ import * as _radix_ui_react_select from '@radix-ui/react-select';
15
15
  import * as SliderPrimitive from '@radix-ui/react-slider';
16
16
  export { Toaster } from 'sonner';
17
17
  import * as RadixTooltip from '@radix-ui/react-tooltip';
18
- import * as RadixSwitch from '@radix-ui/react-switch';
18
+ import { SwitchProps } from '@radix-ui/react-switch';
19
19
 
20
20
  type SeparatorProps = HTMLAttributes<HTMLLIElement>;
21
21
  declare function Separator({ className }: SeparatorProps): JSX.Element;
@@ -37,14 +37,14 @@ type DropdownMenuLabelProps = {
37
37
  declare function DropdownMenuLabel({ children }: DropdownMenuLabelProps): JSX.Element;
38
38
 
39
39
  type Container = HTMLElement | null | undefined;
40
- type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps & Pick<DropdownMenuPrimitive.DropdownMenuProps, 'onOpenChange' | 'modal'> & {
40
+ type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps & Pick<DropdownMenuPrimitive.DropdownMenuProps, 'onOpenChange' | 'modal' | 'open'> & {
41
41
  children: ReactNode;
42
42
  content: ReactNode;
43
43
  alignContent?: 'start' | 'center' | 'end';
44
44
  disabled?: boolean;
45
45
  container?: Container;
46
46
  };
47
- declare function DropdownMenuRoot({ children, content, alignContent, disabled, onOpenChange, container, modal, ...delegated }: DropdownMenuRootProps): JSX.Element;
47
+ declare function DropdownMenuRoot({ children, content, alignContent, disabled, onOpenChange, container, modal, open, ...delegated }: DropdownMenuRootProps): JSX.Element;
48
48
 
49
49
  declare const DropdownMenu: {
50
50
  Root: typeof DropdownMenuRoot;
@@ -466,8 +466,10 @@ type SwitchStylesProps = VariantProps<typeof switchStyles>;
466
466
  declare const switchStyles: (props?: ({
467
467
  size?: "xs" | "sm" | null | undefined;
468
468
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
469
- type SwitchProps = ComponentProps<typeof RadixSwitch.Root> & SwitchStylesProps;
470
- declare function Switch({ size, ...props }: SwitchProps): JSX.Element;
469
+ type CustomSwitchProps = SwitchStylesProps & Exclude<SwitchProps, 'checked'> & {
470
+ checked?: boolean | null;
471
+ };
472
+ declare function Switch({ size, checked, ...props }: CustomSwitchProps): JSX.Element;
471
473
 
472
474
  declare const Icon: {
473
475
  Add: react.ForwardRefExoticComponent<Pick<react.SVGProps<SVGSVGElement>, "string" | "style" | "clipPath" | "filter" | "mask" | "path" | "key" | "className" | "id" | "lang" | "tabIndex" | "role" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "width" | "height" | "stroke" | "strokeLinecap" | "name" | "type" | "to" | "href" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "end" | "orientation" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "alignmentBaseline" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "azimuth" | "baseFrequency" | "baselineShift" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clip" | "clipPathUnits" | "clipRule" | "colorInterpolation" | "colorInterpolationFilters" | "colorProfile" | "colorRendering" | "contentScriptType" | "contentStyleType" | "cursor" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "direction" | "display" | "divisor" | "dominantBaseline" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "exponent" | "externalResourcesRequired" | "fill" | "fillOpacity" | "fillRule" | "filterRes" | "filterUnits" | "floodColor" | "floodOpacity" | "focusable" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "format" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphOrientationVertical" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "imageRendering" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "letterSpacing" | "lightingColor" | "limitingConeAngle" | "local" | "markerEnd" | "markerHeight" | "markerMid" | "markerStart" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "offset" | "opacity" | "operator" | "order" | "orient" | "origin" | "overflow" | "overlinePosition" | "overlineThickness" | "paintOrder" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "pointerEvents" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rotate" | "rx" | "ry" | "scale" | "seed" | "shapeRendering" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "stopColor" | "stopOpacity" | "strikethroughPosition" | "strikethroughThickness" | "strokeDasharray" | "strokeDashoffset" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textAnchor" | "textDecoration" | "textLength" | "textRendering" | "transform" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeBidi" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "values" | "vectorEffect" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "visibility" | "vMathematical" | "widths" | "wordSpacing" | "writingMode" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan"> & react.RefAttributes<SVGSVGElement>>;
package/dist/index.js CHANGED
@@ -284,6 +284,7 @@ function DropdownMenuRoot({
284
284
  onOpenChange,
285
285
  container,
286
286
  modal,
287
+ open,
287
288
  ...delegated
288
289
  }) {
289
290
  const contentProps = {
@@ -296,6 +297,7 @@ function DropdownMenuRoot({
296
297
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenuPrimitive3.Root, {
297
298
  onOpenChange,
298
299
  modal,
300
+ open,
299
301
  children: [
300
302
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuPrimitive3.Trigger, {
301
303
  disabled,
@@ -40336,12 +40338,13 @@ var switchStyles = (0, import_class_variance_authority23.cva)(["c-switch-root"],
40336
40338
  size: "sm"
40337
40339
  }
40338
40340
  });
40339
- function Switch2({ size, ...props }) {
40341
+ function Switch2({ size, checked, ...props }) {
40340
40342
  return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(RadixSwitch.Root, {
40341
40343
  ...props,
40344
+ checked,
40342
40345
  className: switchStyles({ size }),
40343
40346
  children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(RadixSwitch.Thumb, {
40344
- className: "c-switch-thumb"
40347
+ className: (0, import_class_variance_authority23.cx)("c-switch-thumb", checked === null ? "middle-position" : "")
40345
40348
  })
40346
40349
  });
40347
40350
  }
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  showError,
18
18
  showInfo,
19
19
  showWarning
20
- } from "./chunk-LVKSZBWB.mjs";
20
+ } from "./chunk-WVH6ON3P.mjs";
21
21
  import "./chunk-NIH5ZMPE.mjs";
22
22
 
23
23
  // src/card/card.tsx
@@ -416,7 +416,7 @@ function Tag({
416
416
  // src/rich-text-editor/index.tsx
417
417
  import { lazy, Suspense } from "react";
418
418
  import { jsx as jsx13 } from "react/jsx-runtime";
419
- var LazyRichTextEditor = lazy(() => import("./rich-text-editor-ANU6NSC2.mjs"));
419
+ var LazyRichTextEditor = lazy(() => import("./rich-text-editor-CXM3OOQ5.mjs"));
420
420
  var RichTextEditor = (props) => {
421
421
  return /* @__PURE__ */ jsx13(Suspense, {
422
422
  fallback: null,
@@ -503,7 +503,7 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
503
503
  toast.dismiss = sonnerToast.dismiss;
504
504
 
505
505
  // src/switch/switch.tsx
506
- import { cva as cva7 } from "class-variance-authority";
506
+ import { cva as cva7, cx as cx8 } from "class-variance-authority";
507
507
  import * as RadixSwitch from "@radix-ui/react-switch";
508
508
  import { jsx as jsx15 } from "react/jsx-runtime";
509
509
  var switchStyles = cva7(["c-switch-root"], {
@@ -517,12 +517,13 @@ var switchStyles = cva7(["c-switch-root"], {
517
517
  size: "sm"
518
518
  }
519
519
  });
520
- function Switch({ size, ...props }) {
520
+ function Switch({ size, checked, ...props }) {
521
521
  return /* @__PURE__ */ jsx15(RadixSwitch.Root, {
522
522
  ...props,
523
+ checked,
523
524
  className: switchStyles({ size }),
524
525
  children: /* @__PURE__ */ jsx15(RadixSwitch.Thumb, {
525
- className: "c-switch-thumb"
526
+ className: cx8("c-switch-thumb", checked === null ? "middle-position" : "")
526
527
  })
527
528
  });
528
529
  }
@@ -6,7 +6,7 @@ import {
6
6
  Icon,
7
7
  IconButton,
8
8
  InputWithLabel
9
- } from "./chunk-LVKSZBWB.mjs";
9
+ } from "./chunk-WVH6ON3P.mjs";
10
10
  import "./chunk-NIH5ZMPE.mjs";
11
11
 
12
12
  // src/rich-text-editor/rich-text-editor.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.24.8",
3
+ "version": "1.24.10",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -4,7 +4,7 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
4
4
  export type Container = HTMLElement | null | undefined;
5
5
 
6
6
  export type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps &
7
- Pick<DropdownMenuPrimitive.DropdownMenuProps, 'onOpenChange' | 'modal'> & {
7
+ Pick<DropdownMenuPrimitive.DropdownMenuProps, 'onOpenChange' | 'modal' | 'open'> & {
8
8
  children: ReactNode;
9
9
  content: ReactNode;
10
10
  alignContent?: 'start' | 'center' | 'end';
@@ -20,6 +20,7 @@ export function DropdownMenuRoot({
20
20
  onOpenChange,
21
21
  container,
22
22
  modal,
23
+ open,
23
24
  ...delegated
24
25
  }: DropdownMenuRootProps) {
25
26
  const contentProps = {
@@ -31,7 +32,7 @@ export function DropdownMenuRoot({
31
32
  };
32
33
 
33
34
  return (
34
- <DropdownMenuPrimitive.Root onOpenChange={onOpenChange} modal={modal}>
35
+ <DropdownMenuPrimitive.Root onOpenChange={onOpenChange} modal={modal} open={open}>
35
36
  <DropdownMenuPrimitive.Trigger disabled={disabled} asChild className="c-dropdown-menu-trigger">
36
37
  {children}
37
38
  </DropdownMenuPrimitive.Trigger>
@@ -39,6 +39,20 @@ export function Controlled() {
39
39
  );
40
40
  }
41
41
 
42
+ export function DefaultCenter() {
43
+ const [checked, setChecked] = useState<boolean | null>(null);
44
+
45
+ return (
46
+ <div style={style}>
47
+ <Switch checked={checked} onCheckedChange={c => setChecked(c)} />
48
+
49
+ <button onClick={() => setChecked(null)} style={{ marginLeft: '16px' }}>
50
+ Set Null
51
+ </button>
52
+ </div>
53
+ );
54
+ }
55
+
42
56
  export const WithLabel = () => {
43
57
  return (
44
58
  <div style={{ display: 'flex', padding: '3rem', gap: '0.5rem', alignItems: 'center' }}>
@@ -7,6 +7,10 @@
7
7
  .c-switch-thumb {
8
8
  @apply h-4 w-4;
9
9
 
10
+ &.middle-position {
11
+ transform: translateX(11px);
12
+ }
13
+
10
14
  &[data-state='checked']  {
11
15
  transform: translateX(20px);
12
16
  }
@@ -19,6 +23,10 @@
19
23
  .c-switch-thumb {
20
24
  @apply h-3.5 w-3.5;
21
25
 
26
+ &.middle-position {
27
+ transform: translateX(8px);
28
+ }
29
+
22
30
  &[data-state='checked']  {
23
31
  transform: translateX(16px);
24
32
  }
@@ -27,8 +35,9 @@
27
35
  }
28
36
 
29
37
  .c-switch-thumb {
30
- @apply block origin-center translate-x-1 rounded-full bg-purple-400-500 transition-all;
38
+ @apply block origin-center translate-x-1 rounded-full bg-white transition-all;
31
39
  &[data-state='checked']  {
32
- @apply bg-green-500-400;
40
+ @apply bg-white;
33
41
  }
42
+ box-shadow: 0px 1px 2px 0px rgba(40, 41, 61, 0.2), 0px 2px 4px 0px rgba(96, 97, 112, 0.2);
34
43
  }
@@ -1,6 +1,6 @@
1
- import type { ComponentProps } from 'react';
2
- import { cva, VariantProps } from 'class-variance-authority';
1
+ import { cva, VariantProps, cx } from 'class-variance-authority';
3
2
  import * as RadixSwitch from '@radix-ui/react-switch';
3
+ import type { SwitchProps } from '@radix-ui/react-switch';
4
4
 
5
5
  type SwitchStylesProps = VariantProps<typeof switchStyles>;
6
6
  const switchStyles = cva(['c-switch-root'], {
@@ -15,12 +15,15 @@ const switchStyles = cva(['c-switch-root'], {
15
15
  },
16
16
  });
17
17
 
18
- export type SwitchProps = ComponentProps<typeof RadixSwitch.Root> & SwitchStylesProps;
18
+ export type CustomSwitchProps = SwitchStylesProps &
19
+ Exclude<SwitchProps, 'checked'> & {
20
+ checked?: boolean | null;
21
+ };
19
22
 
20
- export function Switch({ size, ...props }: SwitchProps) {
23
+ export function Switch({ size, checked, ...props }: CustomSwitchProps) {
21
24
  return (
22
- <RadixSwitch.Root {...props} className={switchStyles({ size })}>
23
- <RadixSwitch.Thumb className="c-switch-thumb" />
25
+ <RadixSwitch.Root {...props} checked={checked} className={switchStyles({ size })}>
26
+ <RadixSwitch.Thumb className={cx('c-switch-thumb', checked === null ? 'middle-position' : '')} />
24
27
  </RadixSwitch.Root>
25
28
  );
26
29
  }