@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.
- package/dist/components/atoms/ToggleSwitch/ToggleSwitch.d.ts.map +1 -1
- package/dist/components/atoms/ToggleSwitch/ToggleSwitch.utils.d.ts +9 -0
- package/dist/components/atoms/ToggleSwitch/ToggleSwitch.utils.d.ts.map +1 -1
- package/dist/components/layouts/CreateFormPageShell/CreateFormPageShell.d.ts.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/index.cjs.js +53 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +53 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/ui.cjs.js +26 -20
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +26 -20
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/ui.cjs.js
CHANGED
|
@@ -3361,33 +3361,39 @@ const Toaster = ({ theme = 'system', ...props }) => (jsxRuntime.jsx(sonner.Toast
|
|
|
3361
3361
|
},
|
|
3362
3362
|
}, ...props }));
|
|
3363
3363
|
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
},
|
|
3371
|
-
md: {
|
|
3372
|
-
track: { width: 44, height: 24 },
|
|
3373
|
-
thumb: 20,
|
|
3374
|
-
on: 22,
|
|
3375
|
-
off: 2,
|
|
3376
|
-
},
|
|
3377
|
-
lg: {
|
|
3378
|
-
track: { width: 52, height: 28 },
|
|
3379
|
-
thumb: 24,
|
|
3380
|
-
on: 26,
|
|
3381
|
-
off: 2,
|
|
3382
|
-
},
|
|
3364
|
+
/** 1px border on the track, and the gap between thumb and track. */
|
|
3365
|
+
const TRACK_BORDER = 1;
|
|
3366
|
+
const THUMB_INSET = 2;
|
|
3367
|
+
const TRACK_SIZE = {
|
|
3368
|
+
sm: { width: 28, height: 16 },
|
|
3369
|
+
md: { width: 44, height: 24 },
|
|
3370
|
+
lg: { width: 52, height: 28 },
|
|
3383
3371
|
};
|
|
3372
|
+
/**
|
|
3373
|
+
* Thumb size and travel are derived from the track rather than listed per size:
|
|
3374
|
+
* hardcoding them left the thumb 1px from the top and bottom but flush against
|
|
3375
|
+
* the inner right edge when on, so it bulged past the track's rounded end.
|
|
3376
|
+
* Deriving keeps the inset equal on all four sides at every size.
|
|
3377
|
+
*/
|
|
3378
|
+
function switchGeometry(size) {
|
|
3379
|
+
const track = TRACK_SIZE[size];
|
|
3380
|
+
const innerWidth = track.width - TRACK_BORDER * 2;
|
|
3381
|
+
const innerHeight = track.height - TRACK_BORDER * 2;
|
|
3382
|
+
const thumb = innerHeight - THUMB_INSET * 2;
|
|
3383
|
+
return {
|
|
3384
|
+
track,
|
|
3385
|
+
thumb,
|
|
3386
|
+
off: THUMB_INSET,
|
|
3387
|
+
on: innerWidth - thumb - THUMB_INSET,
|
|
3388
|
+
};
|
|
3389
|
+
}
|
|
3384
3390
|
const Switch = t__namespace.forwardRef(({ checked = false, onCheckedChange, disabled = false, id, name, className, size = 'md', 'aria-label': ariaLabel, }, ref) => {
|
|
3385
3391
|
const handleClick = () => {
|
|
3386
3392
|
if (!disabled && onCheckedChange) {
|
|
3387
3393
|
onCheckedChange(!checked);
|
|
3388
3394
|
}
|
|
3389
3395
|
};
|
|
3390
|
-
const dims =
|
|
3396
|
+
const dims = switchGeometry(size);
|
|
3391
3397
|
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: {
|
|
3392
3398
|
width: dims.track.width,
|
|
3393
3399
|
height: dims.track.height,
|