@schemavaults/ui 0.28.2 → 0.30.1

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.
@@ -124,3 +124,7 @@ export * from "./code-block";
124
124
  export type * from "./code-block";
125
125
  export * from "./segmented-control";
126
126
  export type * from "./segmented-control";
127
+ export * from "./marquee";
128
+ export type * from "./marquee";
129
+ export * from "./toggle";
130
+ export type * from "./toggle";
@@ -61,4 +61,6 @@ export * from "./rating";
61
61
  export * from "./number-input";
62
62
  export * from "./code-block";
63
63
  export * from "./segmented-control";
64
+ export * from "./marquee";
65
+ export * from "./toggle";
64
66
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,UAAU,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,kBAAkB,CAAC;AAGjC,cAAc,aAAa,CAAC;AAG5B,cAAc,kCAAkC,CAAC;AAGjD,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAExB,cAAc,WAAW,CAAC;AAG1B,cAAc,YAAY,CAAC;AAG3B,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAG5B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B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c,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,cAAc,CAAC;AAG7B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Marquee, MarqueeItem, marqueeDirectionIds, marqueeFadeIds, marqueeGapIds, } from "./marquee";
2
+ export type { MarqueeProps, MarqueeItemProps, MarqueeDirectionId, MarqueeFadeId, MarqueeGapId, } from "./marquee";
@@ -0,0 +1,2 @@
1
+ export { Marquee, MarqueeItem, marqueeDirectionIds, marqueeFadeIds, marqueeGapIds, } from "./marquee";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/marquee/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ export declare const marqueeDirectionIds: readonly ["left", "right", "up", "down"];
4
+ export type MarqueeDirectionId = (typeof marqueeDirectionIds)[number];
5
+ export declare const marqueeFadeIds: readonly ["none", "background", "muted", "card"];
6
+ export type MarqueeFadeId = (typeof marqueeFadeIds)[number];
7
+ export declare const marqueeGapIds: readonly ["sm", "default", "lg", "xl"];
8
+ export type MarqueeGapId = (typeof marqueeGapIds)[number];
9
+ declare const marqueeRootVariants: (props?: ({
10
+ orientation?: "horizontal" | "vertical" | null | undefined;
11
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
12
+ export interface MarqueeProps extends Omit<HTMLAttributes<HTMLDivElement>, "children">, VariantProps<typeof marqueeRootVariants> {
13
+ /** Items to scroll. Each child is rendered as one cell of the rail. */
14
+ children: ReactNode;
15
+ /** Scroll direction. `left`/`right` scroll horizontally, `up`/`down` scroll vertically. Default: `"left"`. */
16
+ direction?: MarqueeDirectionId;
17
+ /** Seconds for one full loop. Lower = faster. Default: `30`. */
18
+ duration?: number;
19
+ /** How many copies of the content to render for a seamless loop. Default: `2`. Minimum: `2`. */
20
+ repeat?: number;
21
+ /** Pause animation on hover. Default: `true`. */
22
+ pauseOnHover?: boolean;
23
+ /** Edge fade mask color. Match this to the surface the marquee sits on. Default: `"none"`. */
24
+ fade?: MarqueeFadeId;
25
+ /** Length of the fade mask in pixels. Default: `64`. */
26
+ fadeSize?: number;
27
+ /** Spacing between items. Default: `"default"` (32px). */
28
+ gap?: MarqueeGapId;
29
+ }
30
+ export declare function Marquee({ className, children, direction, duration, repeat, pauseOnHover, fade, fadeSize, gap, ...props }: MarqueeProps): ReactElement;
31
+ export declare namespace Marquee {
32
+ var displayName: string;
33
+ }
34
+ export interface MarqueeItemProps extends HTMLAttributes<HTMLDivElement> {
35
+ children: ReactNode;
36
+ }
37
+ /**
38
+ * Optional convenience wrapper. You can pass plain children to <Marquee /> directly,
39
+ * but <MarqueeItem> gives you a styled, theme-aware "card" cell out of the box.
40
+ */
41
+ export declare function MarqueeItem({ className, children, ...props }: MarqueeItemProps): ReactElement;
42
+ export declare namespace MarqueeItem {
43
+ var displayName: string;
44
+ }
45
+ export default Marquee;
@@ -0,0 +1,119 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Children, useCallback, useRef, } from "react";
4
+ import { cva } from "class-variance-authority";
5
+ import { domAnimation, LazyMotion, m, useAnimationFrame, useMotionValue, useReducedMotion, } from "../../../framer-motion";
6
+ import { cn } from "../../../lib/utils";
7
+ export const marqueeDirectionIds = [
8
+ "left",
9
+ "right",
10
+ "up",
11
+ "down",
12
+ ];
13
+ export const marqueeFadeIds = [
14
+ "none",
15
+ "background",
16
+ "muted",
17
+ "card",
18
+ ];
19
+ export const marqueeGapIds = [
20
+ "sm",
21
+ "default",
22
+ "lg",
23
+ "xl",
24
+ ];
25
+ const gapPx = {
26
+ sm: 16,
27
+ default: 32,
28
+ lg: 48,
29
+ xl: 64,
30
+ };
31
+ const fadeFromColor = {
32
+ none: "",
33
+ background: "from-background",
34
+ muted: "from-muted",
35
+ card: "from-card",
36
+ };
37
+ const marqueeRootVariants = cva("group/marquee relative flex overflow-hidden", {
38
+ variants: {
39
+ orientation: {
40
+ horizontal: "w-full flex-row",
41
+ vertical: "h-full flex-col",
42
+ },
43
+ },
44
+ defaultVariants: {
45
+ orientation: "horizontal",
46
+ },
47
+ });
48
+ function FadeMasks({ orientation, fade, size }) {
49
+ const fromClass = fadeFromColor[fade];
50
+ if (orientation === "horizontal") {
51
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none absolute inset-y-0 left-0 z-10 bg-gradient-to-r to-transparent", fromClass), style: { width: size } }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none absolute inset-y-0 right-0 z-10 bg-gradient-to-l to-transparent", fromClass), style: { width: size } })] }));
52
+ }
53
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none absolute inset-x-0 top-0 z-10 bg-gradient-to-b to-transparent", fromClass), style: { height: size } }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t to-transparent", fromClass), style: { height: size } })] }));
54
+ }
55
+ export function Marquee({ className, children, direction = "left", duration = 30, repeat = 2, pauseOnHover = true, fade = "none", fadeSize = 64, gap = "default", ...props }) {
56
+ const prefersReducedMotion = useReducedMotion();
57
+ const orientation = direction === "up" || direction === "down" ? "vertical" : "horizontal";
58
+ const isReversed = direction === "right" || direction === "down";
59
+ const childArray = Children.toArray(children);
60
+ const safeRepeat = Math.max(2, Math.floor(repeat));
61
+ const gapSize = gapPx[gap];
62
+ // Spacing is baked into each item via margin so the total track size is an exact
63
+ // integer multiple of one copy's size. This is what makes the modulo wrap seamless.
64
+ const itemSpacingStyle = orientation === "horizontal"
65
+ ? { marginRight: gapSize }
66
+ : { marginBottom: gapSize };
67
+ const copies = Array.from({ length: safeRepeat }, (_, copyIndex) => (_jsx("div", { "aria-hidden": copyIndex > 0 ? "true" : undefined, className: cn("flex shrink-0", orientation === "horizontal" ? "flex-row" : "flex-col"), children: childArray.map((child, itemIndex) => (_jsx("div", { className: "shrink-0", style: itemSpacingStyle, children: child }, `marquee-item-${copyIndex}-${itemIndex}`))) }, `marquee-copy-${copyIndex}`)));
68
+ // We drive the transform manually with useAnimationFrame so we can wrap with
69
+ // strict modulo arithmetic at the copy boundary — there's no array→array
70
+ // restart frame, no "snap back to start" between cycles, and no
71
+ // whileHover-induced reset. The result is a perfectly seamless loop in either
72
+ // direction at any duration, including when the user hovers in/out.
73
+ const offset = useMotionValue(0);
74
+ const trackRef = useRef(null);
75
+ const isHoveredRef = useRef(false);
76
+ useAnimationFrame((_t, deltaMs) => {
77
+ if (prefersReducedMotion)
78
+ return;
79
+ if (pauseOnHover && isHoveredRef.current)
80
+ return;
81
+ const el = trackRef.current;
82
+ if (!el)
83
+ return;
84
+ const fullSize = orientation === "horizontal" ? el.scrollWidth : el.scrollHeight;
85
+ const oneCopy = fullSize / safeRepeat;
86
+ if (oneCopy <= 0 || duration <= 0)
87
+ return;
88
+ const pxPerMs = oneCopy / (duration * 1000);
89
+ // Negative direction (left / up) walks toward -oneCopy then wraps to 0.
90
+ // Positive direction (right / down) walks toward +oneCopy then wraps to 0.
91
+ const sign = isReversed ? 1 : -1;
92
+ let next = offset.get() + sign * pxPerMs * deltaMs;
93
+ if (next <= -oneCopy)
94
+ next += oneCopy;
95
+ else if (next >= oneCopy)
96
+ next -= oneCopy;
97
+ offset.set(next);
98
+ });
99
+ const handleMouseEnter = useCallback(() => {
100
+ isHoveredRef.current = true;
101
+ }, []);
102
+ const handleMouseLeave = useCallback(() => {
103
+ isHoveredRef.current = false;
104
+ }, []);
105
+ return (_jsx(LazyMotion, { features: domAnimation, strict: true, children: _jsxs("div", { role: "marquee", "aria-label": props["aria-label"] ?? "Scrolling content", onMouseEnter: pauseOnHover ? handleMouseEnter : undefined, onMouseLeave: pauseOnHover ? handleMouseLeave : undefined, className: cn(marqueeRootVariants({ orientation }), className), ...props, children: [fade !== "none" ? (_jsx(FadeMasks, { orientation: orientation, fade: fade, size: fadeSize })) : null, _jsx(m.div, { ref: trackRef, className: cn("flex w-max", orientation === "horizontal" ? "flex-row" : "h-max flex-col"), style: orientation === "horizontal"
106
+ ? { x: offset, willChange: "transform" }
107
+ : { y: offset, willChange: "transform" }, children: copies })] }) }));
108
+ }
109
+ Marquee.displayName = "Marquee";
110
+ /**
111
+ * Optional convenience wrapper. You can pass plain children to <Marquee /> directly,
112
+ * but <MarqueeItem> gives you a styled, theme-aware "card" cell out of the box.
113
+ */
114
+ export function MarqueeItem({ className, children, ...props }) {
115
+ return (_jsx("div", { className: cn("flex items-center justify-center rounded-md border border-border bg-card px-4 py-2 text-sm text-card-foreground shadow-sm", className), ...props, children: children }));
116
+ }
117
+ MarqueeItem.displayName = "MarqueeItem";
118
+ export default Marquee;
119
+ //# sourceMappingURL=marquee.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marquee.js","sourceRoot":"","sources":["../../../../src/components/ui/marquee/marquee.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,QAAQ,EAKR,WAAW,EACX,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,CAAC,EACD,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM;IACN,OA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E,CAAC,CAAC,CAAC,IAAI,EAER,KAAC,CAAC,CAAC,GAAG,IACJ,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,EAAE,CACX,YAAY,EACZ,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAC7D,EACD,KAAK,EACH,WAAW,KAAK,YAAY;wBAC1B,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE;wBACxC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,YAG3C,MAAM,GACD,IACJ,GACK,CACd,CAAC;AACJ,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAMhC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACS;IACjB,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CACX,2HAA2H,EAC3H,SAAS,CACV,KACG,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Toggle, toggleVariants, toggleVariantIds, toggleSizeIds, } from "./toggle";
2
+ export type { ToggleProps, ToggleVariantId, ToggleSizeId, } from "./toggle";
3
+ export { ToggleGroup, ToggleGroupItem } from "./toggle-group";
4
+ export type { ToggleGroupProps, ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps, } from "./toggle-group";
5
+ export { Toggle as default } from "./toggle";
@@ -0,0 +1,4 @@
1
+ export { Toggle, toggleVariants, toggleVariantIds, toggleSizeIds, } from "./toggle";
2
+ export { ToggleGroup, ToggleGroupItem } from "./toggle-group";
3
+ export { Toggle as default } from "./toggle";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/toggle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQ9D,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type HTMLAttributes, type ReactElement, type Ref } from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ import { toggleVariants, type ToggleProps } from "./toggle";
4
+ type ToggleGroupBaseProps = Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & VariantProps<typeof toggleVariants> & {
5
+ /** Whether all items are disabled. */
6
+ disabled?: boolean;
7
+ ref?: Ref<HTMLDivElement>;
8
+ };
9
+ export type ToggleGroupSingleProps = ToggleGroupBaseProps & {
10
+ type: "single";
11
+ value?: string;
12
+ defaultValue?: string;
13
+ onValueChange?: (value: string) => void;
14
+ };
15
+ export type ToggleGroupMultipleProps = ToggleGroupBaseProps & {
16
+ type: "multiple";
17
+ value?: string[];
18
+ defaultValue?: string[];
19
+ onValueChange?: (value: string[]) => void;
20
+ };
21
+ export type ToggleGroupProps = ToggleGroupSingleProps | ToggleGroupMultipleProps;
22
+ declare function ToggleGroup(props: ToggleGroupProps): ReactElement;
23
+ declare namespace ToggleGroup {
24
+ var displayName: string;
25
+ }
26
+ export interface ToggleGroupItemProps extends Omit<ToggleProps, "pressed" | "defaultPressed" | "onPressedChange"> {
27
+ /** Stable identifier for this item within the group. */
28
+ value: string;
29
+ }
30
+ declare function ToggleGroupItem({ value, variant, size, disabled, onClick, ...props }: ToggleGroupItemProps): ReactElement;
31
+ declare namespace ToggleGroupItem {
32
+ var displayName: string;
33
+ }
34
+ export { ToggleGroup, ToggleGroupItem };
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext, useMemo, useState, } from "react";
4
+ import { cn } from "../../../lib/utils";
5
+ import { Toggle, } from "./toggle";
6
+ const ToggleGroupContext = createContext(null);
7
+ function useToggleGroupContext() {
8
+ return useContext(ToggleGroupContext);
9
+ }
10
+ function ToggleGroup(props) {
11
+ const { className, variant, size, disabled = false, children, ref, ...rest } = props;
12
+ const [internalSingle, setInternalSingle] = useState(props.type === "single" ? (props.defaultValue ?? "") : "");
13
+ const [internalMultiple, setInternalMultiple] = useState(props.type === "multiple" ? (props.defaultValue ?? []) : []);
14
+ const isControlledSingle = props.type === "single" && props.value !== undefined;
15
+ const isControlledMultiple = props.type === "multiple" && props.value !== undefined;
16
+ const propsType = props.type;
17
+ const singlePropValue = props.type === "single" ? props.value : undefined;
18
+ const multiplePropValue = props.type === "multiple" ? props.value : undefined;
19
+ const singleValue = useMemo(() => {
20
+ if (propsType !== "single")
21
+ return "";
22
+ return isControlledSingle ? (singlePropValue ?? "") : internalSingle;
23
+ }, [propsType, isControlledSingle, singlePropValue, internalSingle]);
24
+ const multipleValue = useMemo(() => {
25
+ if (propsType !== "multiple")
26
+ return [];
27
+ return isControlledMultiple ? (multiplePropValue ?? []) : internalMultiple;
28
+ }, [propsType, isControlledMultiple, multiplePropValue, internalMultiple]);
29
+ const isItemPressed = useCallback((value) => {
30
+ if (props.type === "single") {
31
+ return singleValue === value;
32
+ }
33
+ return multipleValue.includes(value);
34
+ }, [props.type, singleValue, multipleValue]);
35
+ const toggleItem = useCallback((value) => {
36
+ if (props.type === "single") {
37
+ const next = singleValue === value ? "" : value;
38
+ if (!isControlledSingle) {
39
+ setInternalSingle(next);
40
+ }
41
+ props.onValueChange?.(next);
42
+ return;
43
+ }
44
+ const exists = multipleValue.includes(value);
45
+ const next = exists
46
+ ? multipleValue.filter((v) => v !== value)
47
+ : [...multipleValue, value];
48
+ if (!isControlledMultiple) {
49
+ setInternalMultiple(next);
50
+ }
51
+ props.onValueChange?.(next);
52
+ }, [
53
+ props,
54
+ singleValue,
55
+ multipleValue,
56
+ isControlledSingle,
57
+ isControlledMultiple,
58
+ ]);
59
+ const ctx = useMemo(() => ({
60
+ variant,
61
+ size,
62
+ isItemPressed,
63
+ toggleItem,
64
+ disabled,
65
+ }), [variant, size, isItemPressed, toggleItem, disabled]);
66
+ // Strip out single/multiple specific props before spreading on div.
67
+ const divProps = {};
68
+ for (const key of Object.keys(rest)) {
69
+ if (key === "type" ||
70
+ key === "value" ||
71
+ key === "defaultValue" ||
72
+ key === "onValueChange") {
73
+ continue;
74
+ }
75
+ divProps[key] = rest[key];
76
+ }
77
+ return (_jsx(ToggleGroupContext.Provider, { value: ctx, children: _jsx("div", { ref: ref, "data-slot": "toggle-group", "data-type": props.type, role: "group", className: cn("inline-flex items-center gap-1", className), ...divProps, children: children }) }));
78
+ }
79
+ ToggleGroup.displayName = "ToggleGroup";
80
+ function ToggleGroupItem({ value, variant, size, disabled, onClick, ...props }) {
81
+ const ctx = useToggleGroupContext();
82
+ if (!ctx) {
83
+ // Fallback: render as a standalone Toggle if not inside a group.
84
+ return (_jsx(Toggle, { variant: variant, size: size, disabled: disabled, onClick: onClick, ...props }));
85
+ }
86
+ const pressed = ctx.isItemPressed(value);
87
+ return (_jsx(Toggle, { variant: variant ?? ctx.variant, size: size ?? ctx.size, disabled: disabled || ctx.disabled, pressed: pressed, onClick: (event) => {
88
+ onClick?.(event);
89
+ if (event.defaultPrevented)
90
+ return;
91
+ ctx.toggleItem(value);
92
+ }, ...props }));
93
+ }
94
+ ToggleGroupItem.displayName = "ToggleGroupItem";
95
+ export { ToggleGroup, ToggleGroupItem };
96
+ //# sourceMappingURL=toggle-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-group.js","sourceRoot":"","sources":["../../../../src/components/ui/toggle/toggle-group.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,GAIT,MAAM,OAAO,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type ReactElement, type Ref } from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ export declare const toggleVariantIds: readonly ["default", "outline", "ghost", "primary", "destructive"];
4
+ export type ToggleVariantId = (typeof toggleVariantIds)[number];
5
+ export declare const toggleSizeIds: readonly ["sm", "default", "lg", "icon"];
6
+ export type ToggleSizeId = (typeof toggleSizeIds)[number];
7
+ export declare const toggleVariants: (props?: ({
8
+ variant?: "default" | "ghost" | "destructive" | "outline" | "primary" | null | undefined;
9
+ size?: "sm" | "default" | "lg" | "icon" | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ export interface ToggleProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onChange">, VariantProps<typeof toggleVariants> {
12
+ /** Controlled pressed state. */
13
+ pressed?: boolean;
14
+ /** Initial pressed state when uncontrolled. */
15
+ defaultPressed?: boolean;
16
+ /** Called when the pressed state changes. */
17
+ onPressedChange?: (pressed: boolean) => void;
18
+ ref?: Ref<HTMLButtonElement>;
19
+ }
20
+ declare function Toggle({ className, variant, size, pressed: pressedProp, defaultPressed, onPressedChange, onClick, disabled, type, ref, ...props }: ToggleProps): ReactElement;
21
+ declare namespace Toggle {
22
+ var displayName: string;
23
+ }
24
+ export { Toggle };
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useCallback, useState, } from "react";
4
+ import { cva } from "class-variance-authority";
5
+ import { cn } from "../../../lib/utils";
6
+ export const toggleVariantIds = [
7
+ "default",
8
+ "outline",
9
+ "ghost",
10
+ "primary",
11
+ "destructive",
12
+ ];
13
+ export const toggleSizeIds = [
14
+ "sm",
15
+ "default",
16
+ "lg",
17
+ "icon",
18
+ ];
19
+ export const toggleVariants = cva("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 select-none", {
20
+ variants: {
21
+ variant: {
22
+ default: "bg-transparent text-foreground data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
23
+ outline: "border border-input bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground data-[state=on]:bg-accent data-[state=on]:text-accent-foreground data-[state=on]:border-accent",
24
+ ghost: "bg-transparent text-muted-foreground hover:text-foreground data-[state=on]:bg-muted data-[state=on]:text-foreground",
25
+ primary: "bg-transparent text-foreground hover:bg-primary/10 hover:text-primary data-[state=on]:bg-primary data-[state=on]:text-primary-foreground data-[state=on]:hover:bg-primary/90 data-[state=on]:hover:text-primary-foreground",
26
+ destructive: "bg-transparent text-foreground hover:bg-destructive/10 hover:text-destructive data-[state=on]:bg-destructive data-[state=on]:text-destructive-foreground data-[state=on]:hover:bg-destructive/90 data-[state=on]:hover:text-destructive-foreground",
27
+ },
28
+ size: {
29
+ sm: "h-8 px-2 text-xs",
30
+ default: "h-9 px-3",
31
+ lg: "h-10 px-4",
32
+ icon: "h-9 w-9 p-0",
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: "default",
37
+ size: "default",
38
+ },
39
+ });
40
+ function Toggle({ className, variant, size, pressed: pressedProp, defaultPressed = false, onPressedChange, onClick, disabled, type, ref, ...props }) {
41
+ const [internalPressed, setInternalPressed] = useState(defaultPressed);
42
+ const isControlled = pressedProp !== undefined;
43
+ const pressed = isControlled ? pressedProp : internalPressed;
44
+ const handleClick = useCallback((event) => {
45
+ onClick?.(event);
46
+ if (event.defaultPrevented)
47
+ return;
48
+ const next = !pressed;
49
+ if (!isControlled) {
50
+ setInternalPressed(next);
51
+ }
52
+ onPressedChange?.(next);
53
+ }, [pressed, isControlled, onClick, onPressedChange]);
54
+ return (_jsx("button", { ref: ref, type: type ?? "button", "data-slot": "toggle", "data-state": pressed ? "on" : "off", "aria-pressed": pressed, disabled: disabled, onClick: handleClick, className: cn(toggleVariants({ variant, size }), className), ...props }));
55
+ }
56
+ Toggle.displayName = "Toggle";
57
+ export { Toggle };
58
+ //# sourceMappingURL=toggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../../../src/components/ui/toggle/toggle.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,WAAW,EACX,QAAQ,GAKT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,SAAS;IACT,OAAO;IACP,SAAS;IACT,aAAa;CACuB,CAAC;AAGvC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI;IACJ,SAAS;IACT,IAAI;IACJ,MAAM;CAC8B,CAAC;AAGvC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAC/B,+XAA+X,EAC/X;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EACL,iGAAiG;YACnG,OAAO,EACL,gMAAgM;YAClM,KAAK,EACH,qHAAqH;YACvH,OAAO,EACL,4NAA4N;YAC9N,WAAW,EACT,oPAAoP;SAC7M;QAC3C,IAAI,EAAE;YACJ,EAAE,EAAE,kBAAkB;YACtB,OAAO,EAAE,UAAU;YACnB,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,aAAa;SACmB;KACzC;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;KAChB;CACF,CACF,CAAC;AAcF,SAAS,MAAM,CAAC,EACd,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,EAAE,WAAW,EACpB,cAAc,GAAG,KAAK,EACtB,eAAe,EACf,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,GAAG,KAAK,EACI;IACZ,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAU,cAAc,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,WAAW,KAAK,SAAS,CAAC;IAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC;IAE7D,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,KAAoC,EAAQ,EAAE;QAC7C,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACjB,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAO;QACnC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC;QACtB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QACD,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,EACD,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,CAAC,CAClD,CAAC;IAEF,OAAO,CACL,iBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,IAAI,QAAQ,eACZ,QAAQ,gBACN,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,kBACpB,OAAO,EACrB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,KACvD,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AACD,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1,2 +1,2 @@
1
- export { m, AnimatePresence, domAnimation, LazyMotion, useAnimate, useTransform, useMotionValue, usePresence, useScroll, useMotionValueEvent, useReducedMotion, } from "framer-motion";
1
+ export { m, AnimatePresence, domAnimation, LazyMotion, useAnimate, useAnimationFrame, useTransform, useMotionValue, usePresence, useScroll, useMotionValueEvent, useReducedMotion, } from "framer-motion";
2
2
  export type { MotionValue, AnimationScope } from "framer-motion";
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- export { m, AnimatePresence, domAnimation, LazyMotion, useAnimate, useTransform, useMotionValue, usePresence, useScroll, useMotionValueEvent, useReducedMotion, } from "framer-motion";
2
+ export { m, AnimatePresence, domAnimation, LazyMotion, useAnimate, useAnimationFrame, useTransform, useMotionValue, usePresence, useScroll, useMotionValueEvent, useReducedMotion, } from "framer-motion";
3
3
  //# sourceMappingURL=framer-motion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"framer-motion.js","sourceRoot":"","sources":["../src/framer-motion.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EACL,CAAC,EACD,eAAe,EACf,YAAY,EACZ,UAAU,EACV,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"framer-motion.js","sourceRoot":"","sources":["../src/framer-motion.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EACL,CAAC,EACD,eAAe,EACf,YAAY,EACZ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schemavaults/ui",
3
- "version": "0.28.2",
3
+ "version": "0.30.1",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "description": "React.js UI components for SchemaVaults frontend applications",
@@ -78,7 +78,7 @@
78
78
  "eslint-plugin-react": "7.37.5",
79
79
  "eslint-plugin-react-hooks": "7.0.1",
80
80
  "eslint-plugin-jsx-a11y": "6.10.2",
81
- "@schemavaults/send-email": "0.0.16"
81
+ "@schemavaults/send-email": "0.0.18"
82
82
  },
83
83
  "scripts": {
84
84
  "build:pkg": "tsc --project tsconfig.pkg.json && tsc-alias --project tsconfig.pkg.json",