@crystallize/design-system 1.24.8 → 1.24.9

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,11 @@
1
1
  # @crystallize/design-system
2
2
 
3
+ ## 1.24.9
4
+
5
+ ### Patch Changes
6
+
7
+ - f8a34c7: Adjust switch component to allow placing thumb to middle position when checked is null
8
+
3
9
  ## 1.24.8
4
10
 
5
11
  ### Patch Changes
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;
@@ -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
@@ -40336,12 +40336,13 @@ var switchStyles = (0, import_class_variance_authority23.cva)(["c-switch-root"],
40336
40336
  size: "sm"
40337
40337
  }
40338
40338
  });
40339
- function Switch2({ size, ...props }) {
40339
+ function Switch2({ size, checked, ...props }) {
40340
40340
  return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(RadixSwitch.Root, {
40341
40341
  ...props,
40342
+ checked,
40342
40343
  className: switchStyles({ size }),
40343
40344
  children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(RadixSwitch.Thumb, {
40344
- className: "c-switch-thumb"
40345
+ className: (0, import_class_variance_authority23.cx)("c-switch-thumb", checked === null ? "middle-position" : "")
40345
40346
  })
40346
40347
  });
40347
40348
  }
package/dist/index.mjs CHANGED
@@ -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
  }
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.9",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -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
  }