@caratlogic/design-system 0.1.9 → 0.1.11
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/organisms/MediaGallery/MediaGallery.d.ts +1 -1
- package/dist/components/organisms/MediaGallery/MediaGallery.d.ts.map +1 -1
- package/dist/components/organisms/MediaGallery/MediaGallery.utils.d.ts +6 -0
- package/dist/components/organisms/MediaGallery/MediaGallery.utils.d.ts.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/constants/filePatterns.d.ts +3 -0
- package/dist/constants/filePatterns.d.ts.map +1 -1
- package/dist/index.cjs.js +78 -32
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +78 -32
- 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.esm.js
CHANGED
|
@@ -3334,33 +3334,39 @@ const Toaster = ({ theme = 'system', ...props }) => (jsx(Toaster$1, { theme: the
|
|
|
3334
3334
|
},
|
|
3335
3335
|
}, ...props }));
|
|
3336
3336
|
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
},
|
|
3344
|
-
md: {
|
|
3345
|
-
track: { width: 44, height: 24 },
|
|
3346
|
-
thumb: 20,
|
|
3347
|
-
on: 22,
|
|
3348
|
-
off: 2,
|
|
3349
|
-
},
|
|
3350
|
-
lg: {
|
|
3351
|
-
track: { width: 52, height: 28 },
|
|
3352
|
-
thumb: 24,
|
|
3353
|
-
on: 26,
|
|
3354
|
-
off: 2,
|
|
3355
|
-
},
|
|
3337
|
+
/** 1px border on the track, and the gap between thumb and track. */
|
|
3338
|
+
const TRACK_BORDER = 1;
|
|
3339
|
+
const THUMB_INSET = 2;
|
|
3340
|
+
const TRACK_SIZE = {
|
|
3341
|
+
sm: { width: 28, height: 16 },
|
|
3342
|
+
md: { width: 44, height: 24 },
|
|
3343
|
+
lg: { width: 52, height: 28 },
|
|
3356
3344
|
};
|
|
3345
|
+
/**
|
|
3346
|
+
* Thumb size and travel are derived from the track rather than listed per size:
|
|
3347
|
+
* hardcoding them left the thumb 1px from the top and bottom but flush against
|
|
3348
|
+
* the inner right edge when on, so it bulged past the track's rounded end.
|
|
3349
|
+
* Deriving keeps the inset equal on all four sides at every size.
|
|
3350
|
+
*/
|
|
3351
|
+
function switchGeometry(size) {
|
|
3352
|
+
const track = TRACK_SIZE[size];
|
|
3353
|
+
const innerWidth = track.width - TRACK_BORDER * 2;
|
|
3354
|
+
const innerHeight = track.height - TRACK_BORDER * 2;
|
|
3355
|
+
const thumb = innerHeight - THUMB_INSET * 2;
|
|
3356
|
+
return {
|
|
3357
|
+
track,
|
|
3358
|
+
thumb,
|
|
3359
|
+
off: THUMB_INSET,
|
|
3360
|
+
on: innerWidth - thumb - THUMB_INSET,
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3357
3363
|
const Switch = t.forwardRef(({ checked = false, onCheckedChange, disabled = false, id, name, className, size = 'md', 'aria-label': ariaLabel, }, ref) => {
|
|
3358
3364
|
const handleClick = () => {
|
|
3359
3365
|
if (!disabled && onCheckedChange) {
|
|
3360
3366
|
onCheckedChange(!checked);
|
|
3361
3367
|
}
|
|
3362
3368
|
};
|
|
3363
|
-
const dims =
|
|
3369
|
+
const dims = switchGeometry(size);
|
|
3364
3370
|
return (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: {
|
|
3365
3371
|
width: dims.track.width,
|
|
3366
3372
|
height: dims.track.height,
|