@caratlogic/design-system 0.1.9 → 0.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleSwitch.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/ToggleSwitch/ToggleSwitch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,wBAAgB,YAAY,CAAC,EAC3B,OAAe,EACf,eAAe,EACf,QAAgB,EAChB,EAAE,EACF,IAAI,EACJ,SAAS,EACT,KAAK,EACL,aAAuB,EACvB,IAAW,EACX,GAAG,KAAK,EACT,EAAE,iBAAiB,2CAyEnB"}
1
+ {"version":3,"file":"ToggleSwitch.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/ToggleSwitch/ToggleSwitch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,wBAAgB,YAAY,CAAC,EAC3B,OAAe,EACf,eAAe,EACf,QAAgB,EAChB,EAAE,EACF,IAAI,EACJ,SAAS,EACT,KAAK,EACL,aAAuB,EACvB,IAAW,EACX,GAAG,KAAK,EACT,EAAE,iBAAiB,2CAwEnB"}
@@ -1,3 +1,12 @@
1
1
  import type { SwitchSizeClasses, ToggleSwitchSize } from './ToggleSwitch.types';
2
+ /**
3
+ * Track, thumb and travel, sized so the thumb keeps an even 2px inset on all
4
+ * four sides. Travel is stated in px rather than `calc(100% - Npx)`: that form
5
+ * resolves against the thumb's own width, so the gap silently changed whenever a
6
+ * thumb size did — `md` ended up with a 0.2px vertical inset and no gap at
7
+ * either end, which read as a thumb bulging out of its track.
8
+ *
9
+ * inner = track - 2px border | thumb = innerHeight - 4 | on = innerWidth - thumb - 2
10
+ */
2
11
  export declare const switchSizes: Record<ToggleSwitchSize, SwitchSizeClasses>;
3
12
  //# sourceMappingURL=ToggleSwitch.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleSwitch.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/ToggleSwitch/ToggleSwitch.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAgBnE,CAAC"}
1
+ {"version":3,"file":"ToggleSwitch.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/ToggleSwitch/ToggleSwitch.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAsBnE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CreateFormPageShell.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/CreateFormPageShell/CreateFormPageShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAkB,EAClB,kBAAkB,GACnB,EAAE,wBAAwB,GAAG,YAAY,CAqBzC"}
1
+ {"version":3,"file":"CreateFormPageShell.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/CreateFormPageShell/CreateFormPageShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAkB,EAClB,kBAAkB,GACnB,EAAE,wBAAwB,GAAG,YAAY,CA2BzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/components/ui/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA+BD,QAAA,MAAM,MAAM,uFA4DX,CAAC;AAIF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/components/ui/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAqCD,QAAA,MAAM,MAAM,uFA4DX,CAAC;AAIF,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -5772,21 +5772,33 @@ const TextHyperlink = ({ to, href, children, showIcon = true, className, 'aria-l
5772
5772
  return (jsxRuntime.jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", "aria-label": ariaLabel, className: cn(LINK_CLASS, className), children: content }));
5773
5773
  };
5774
5774
 
5775
+ /**
5776
+ * Track, thumb and travel, sized so the thumb keeps an even 2px inset on all
5777
+ * four sides. Travel is stated in px rather than `calc(100% - Npx)`: that form
5778
+ * resolves against the thumb's own width, so the gap silently changed whenever a
5779
+ * thumb size did — `md` ended up with a 0.2px vertical inset and no gap at
5780
+ * either end, which read as a thumb bulging out of its track.
5781
+ *
5782
+ * inner = track - 2px border | thumb = innerHeight - 4 | on = innerWidth - thumb - 2
5783
+ */
5775
5784
  const switchSizes = {
5785
+ // track 28x16 → inner 26x14, thumb 10, on 14
5776
5786
  sm: {
5777
5787
  switch: 'h-4 w-7',
5778
- thumb: 'size-3',
5779
- translate: 'data-[state=checked]:translate-x-[calc(100%-1px)]',
5788
+ thumb: 'size-2.5',
5789
+ translate: 'data-[state=unchecked]:translate-x-[2px] data-[state=checked]:translate-x-[14px]',
5780
5790
  },
5791
+ // track 32x20 → inner 30x18, thumb 14, on 14
5781
5792
  md: {
5782
- switch: 'h-[1.15rem] w-8',
5783
- thumb: 'size-4',
5784
- translate: 'data-[state=checked]:translate-x-[calc(100%-2px)]',
5793
+ switch: 'h-5 w-8',
5794
+ thumb: 'size-3.5',
5795
+ translate: 'data-[state=unchecked]:translate-x-[2px] data-[state=checked]:translate-x-[14px]',
5785
5796
  },
5797
+ // track 44x24 → inner 42x22, thumb 18, on 22
5786
5798
  lg: {
5787
5799
  switch: 'h-6 w-11',
5788
- thumb: 'size-5',
5789
- translate: 'data-[state=checked]:translate-x-[calc(100%-3px)]',
5800
+ thumb: 'size-[1.125rem]',
5801
+ translate: 'data-[state=unchecked]:translate-x-[2px] data-[state=checked]:translate-x-[22px]',
5790
5802
  },
5791
5803
  };
5792
5804
 
@@ -5797,7 +5809,7 @@ function ToggleSwitch({ checked = false, onCheckedChange, disabled = false, id,
5797
5809
  }
5798
5810
  };
5799
5811
  const currentSize = switchSizes[size];
5800
- const switchButton = (jsxRuntime.jsx("button", { type: "button", role: "switch", "aria-checked": checked, "data-state": checked ? 'checked' : 'unchecked', value: checked ? 'on' : 'off', "data-slot": "switch", disabled: disabled, onClick: handleClick, id: id, name: name, className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-all outline-none', 'focus-visible:ring-ring/50 focus-visible:border-ring focus-visible:ring-[3px]', 'disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=unchecked]:bg-muted', 'data-[state=checked]:bg-primary', currentSize.switch, className), ...props, children: jsxRuntime.jsx("span", { "data-state": checked ? 'checked' : 'unchecked', "data-slot": "switch-thumb", className: cn('pointer-events-none block rounded-full ring-0 transition-transform', 'bg-card data-[state=checked]:bg-primary-foreground', 'data-[state=unchecked]:translate-x-0', currentSize.thumb, currentSize.translate) }) }));
5812
+ const switchButton = (jsxRuntime.jsx("button", { type: "button", role: "switch", "aria-checked": checked, "data-state": checked ? 'checked' : 'unchecked', value: checked ? 'on' : 'off', "data-slot": "switch", disabled: disabled, onClick: handleClick, id: id, name: name, className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-all outline-none', 'focus-visible:ring-ring/50 focus-visible:border-ring focus-visible:ring-[3px]', 'disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=unchecked]:bg-muted', 'data-[state=checked]:bg-primary', currentSize.switch, className), ...props, children: jsxRuntime.jsx("span", { "data-state": checked ? 'checked' : 'unchecked', "data-slot": "switch-thumb", className: cn('pointer-events-none block rounded-full ring-0 transition-transform', 'bg-card data-[state=checked]:bg-primary-foreground', currentSize.thumb, currentSize.translate) }) }));
5801
5813
  if (!label) {
5802
5814
  return switchButton;
5803
5815
  }
@@ -58466,33 +58478,39 @@ function ZoomSplitViewer({ src, alt = 'Preview', zoom = 2, lensSize = 160, paneO
58466
58478
  }) })), isTouchDevice && (jsxRuntime.jsx("p", { className: `text-xs text-muted-foreground text-center mt-2 ${isMobile ? 'text-2xs' : ''}`, children: isMobile ? 'Touch & hold to zoom' : 'Touch and hold to zoom' }))] }));
58467
58479
  }
58468
58480
 
58469
- const SIZE_MAP = {
58470
- sm: {
58471
- track: { width: 28, height: 16 },
58472
- thumb: 12,
58473
- on: 14,
58474
- off: 2,
58475
- },
58476
- md: {
58477
- track: { width: 44, height: 24 },
58478
- thumb: 20,
58479
- on: 22,
58480
- off: 2,
58481
- },
58482
- lg: {
58483
- track: { width: 52, height: 28 },
58484
- thumb: 24,
58485
- on: 26,
58486
- off: 2,
58487
- },
58481
+ /** 1px border on the track, and the gap between thumb and track. */
58482
+ const TRACK_BORDER = 1;
58483
+ const THUMB_INSET = 2;
58484
+ const TRACK_SIZE = {
58485
+ sm: { width: 28, height: 16 },
58486
+ md: { width: 44, height: 24 },
58487
+ lg: { width: 52, height: 28 },
58488
58488
  };
58489
+ /**
58490
+ * Thumb size and travel are derived from the track rather than listed per size:
58491
+ * hardcoding them left the thumb 1px from the top and bottom but flush against
58492
+ * the inner right edge when on, so it bulged past the track's rounded end.
58493
+ * Deriving keeps the inset equal on all four sides at every size.
58494
+ */
58495
+ function switchGeometry(size) {
58496
+ const track = TRACK_SIZE[size];
58497
+ const innerWidth = track.width - TRACK_BORDER * 2;
58498
+ const innerHeight = track.height - TRACK_BORDER * 2;
58499
+ const thumb = innerHeight - THUMB_INSET * 2;
58500
+ return {
58501
+ track,
58502
+ thumb,
58503
+ off: THUMB_INSET,
58504
+ on: innerWidth - thumb - THUMB_INSET,
58505
+ };
58506
+ }
58489
58507
  const Switch = React__namespace.forwardRef(({ checked = false, onCheckedChange, disabled = false, id, name, className, size = 'md', 'aria-label': ariaLabel, }, ref) => {
58490
58508
  const handleClick = () => {
58491
58509
  if (!disabled && onCheckedChange) {
58492
58510
  onCheckedChange(!checked);
58493
58511
  }
58494
58512
  };
58495
- const dims = SIZE_MAP[size];
58513
+ const dims = switchGeometry(size);
58496
58514
  return (jsxRuntime.jsx("button", { type: "button", role: "switch", "aria-checked": checked, "aria-label": ariaLabel, "data-state": checked ? 'checked' : 'unchecked', disabled: disabled, onClick: handleClick, ref: ref, id: id, name: name, style: {
58497
58515
  width: dims.track.width,
58498
58516
  height: dims.track.height,
@@ -66116,7 +66134,13 @@ function CreateFormPageHeader({ title, onBack, backLabel = 'Go back', }) {
66116
66134
  function CreateFormPageShell({ title, onBack, children, backLabel, scrollable = false, containerClassName, }) {
66117
66135
  const content = (jsxRuntime.jsxs("div", { className: cn('mx-auto w-full max-w-4xl px-4 py-4', containerClassName), children: [jsxRuntime.jsx(CreateFormPageHeader, { title: title, onBack: onBack, backLabel: backLabel }), children] }));
66118
66136
  if (scrollable) {
66119
- return (jsxRuntime.jsx("div", { className: "h-full min-h-0 overflow-y-auto bg-card", children: content }));
66137
+ // `shrink-0` is the load-bearing part. As a flex item in the shell's
66138
+ // `flex-col overflow-y-auto` parent this div was shrunk to the parent's
66139
+ // height while its content overflowed, so the background stopped one
66140
+ // screenful down and taller forms showed the page background below it.
66141
+ // `min-h-full` alone cannot fix that — it resolves to the same shrunken
66142
+ // height. The parent already scrolls, so no inner scroller is needed.
66143
+ return (jsxRuntime.jsx("div", { className: "min-h-full shrink-0 bg-card", children: content }));
66120
66144
  }
66121
66145
  return content;
66122
66146
  }