@schemavaults/ui 0.38.1 → 0.40.0
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/ui/aspect-ratio/aspect-ratio.d.ts +39 -0
- package/dist/components/ui/aspect-ratio/aspect-ratio.js +73 -0
- package/dist/components/ui/aspect-ratio/aspect-ratio.js.map +1 -0
- package/dist/components/ui/aspect-ratio/index.d.ts +3 -0
- package/dist/components/ui/aspect-ratio/index.js +3 -0
- package/dist/components/ui/aspect-ratio/index.js.map +1 -0
- package/dist/components/ui/color-swatch/color-swatch-variants.d.ts +6 -0
- package/dist/components/ui/color-swatch/color-swatch-variants.js +18 -0
- package/dist/components/ui/color-swatch/color-swatch-variants.js.map +1 -0
- package/dist/components/ui/color-swatch/color-swatch.d.ts +47 -0
- package/dist/components/ui/color-swatch/color-swatch.js +120 -0
- package/dist/components/ui/color-swatch/color-swatch.js.map +1 -0
- package/dist/components/ui/color-swatch/index.d.ts +4 -0
- package/dist/components/ui/color-swatch/index.js +3 -0
- package/dist/components/ui/color-swatch/index.js.map +1 -0
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
3
|
+
export declare const aspectRatioPresetIds: ["square", "video", "photo", "wide", "ultrawide", "cinema", "portrait", "classic-portrait", "story"];
|
|
4
|
+
export type AspectRatioPresetId = (typeof aspectRatioPresetIds)[number];
|
|
5
|
+
/** Named, common aspect ratios resolved to width / height. */
|
|
6
|
+
export declare const ASPECT_RATIO_PRESETS: Record<AspectRatioPresetId, number>;
|
|
7
|
+
export declare const aspectRatioRadiusIds: ["none", "sm", "md", "lg", "xl", "2xl", "full"];
|
|
8
|
+
export type AspectRatioRadiusId = (typeof aspectRatioRadiusIds)[number];
|
|
9
|
+
export declare const aspectRatioVariants: (props?: ({
|
|
10
|
+
radius?: "sm" | "lg" | "xl" | "none" | "md" | "2xl" | "full" | null | undefined;
|
|
11
|
+
bordered?: boolean | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
|
+
export interface AspectRatioProps extends Omit<ComponentProps<"div">, "ratio">, VariantProps<typeof aspectRatioVariants> {
|
|
14
|
+
/**
|
|
15
|
+
* Aspect ratio as `width / height` (e.g. `16 / 9` for widescreen).
|
|
16
|
+
* Takes precedence over `preset`. If neither is provided, defaults to `video` (16:9).
|
|
17
|
+
*/
|
|
18
|
+
ratio?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Named ratio preset. Use `ratio` for arbitrary values.
|
|
21
|
+
* - `square` (1:1) - avatars, tiles
|
|
22
|
+
* - `video` (16:9) - HD video / modern displays
|
|
23
|
+
* - `photo` (4:3) - classic photo
|
|
24
|
+
* - `wide` (3:2) - DSLR
|
|
25
|
+
* - `ultrawide` (21:9) - cinematic banners
|
|
26
|
+
* - `cinema` (~2.35:1) - anamorphic widescreen
|
|
27
|
+
* - `portrait` (3:4)
|
|
28
|
+
* - `classic-portrait` (2:3)
|
|
29
|
+
* - `story` (9:16) - vertical / mobile story
|
|
30
|
+
*/
|
|
31
|
+
preset?: AspectRatioPresetId;
|
|
32
|
+
/** Render as the child element via Radix Slot. */
|
|
33
|
+
asChild?: boolean;
|
|
34
|
+
}
|
|
35
|
+
declare function AspectRatio({ className, ratio, preset, radius, bordered, asChild, style, children, ...props }: AspectRatioProps): ReactElement;
|
|
36
|
+
declare namespace AspectRatio {
|
|
37
|
+
var displayName: string;
|
|
38
|
+
}
|
|
39
|
+
export { AspectRatio };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
export const aspectRatioPresetIds = [
|
|
7
|
+
"square",
|
|
8
|
+
"video",
|
|
9
|
+
"photo",
|
|
10
|
+
"wide",
|
|
11
|
+
"ultrawide",
|
|
12
|
+
"cinema",
|
|
13
|
+
"portrait",
|
|
14
|
+
"classic-portrait",
|
|
15
|
+
"story",
|
|
16
|
+
];
|
|
17
|
+
/** Named, common aspect ratios resolved to width / height. */
|
|
18
|
+
export const ASPECT_RATIO_PRESETS = {
|
|
19
|
+
square: 1, // 1:1 - avatars, profile tiles, album art
|
|
20
|
+
video: 16 / 9, // 16:9 - HD video, modern displays
|
|
21
|
+
photo: 4 / 3, // 4:3 - classic photo / older displays
|
|
22
|
+
wide: 3 / 2, // 3:2 - DSLR photography
|
|
23
|
+
ultrawide: 21 / 9, // 21:9 - cinematic / banner heros
|
|
24
|
+
cinema: 2.35 / 1, // ~2.35:1 - anamorphic widescreen
|
|
25
|
+
portrait: 3 / 4, // 3:4 - portrait photo
|
|
26
|
+
"classic-portrait": 2 / 3, // 2:3 - portrait DSLR
|
|
27
|
+
story: 9 / 16, // 9:16 - vertical / mobile story
|
|
28
|
+
};
|
|
29
|
+
export const aspectRatioRadiusIds = [
|
|
30
|
+
"none",
|
|
31
|
+
"sm",
|
|
32
|
+
"md",
|
|
33
|
+
"lg",
|
|
34
|
+
"xl",
|
|
35
|
+
"2xl",
|
|
36
|
+
"full",
|
|
37
|
+
];
|
|
38
|
+
export const aspectRatioVariants = cva("relative w-full overflow-hidden [&>img]:h-full [&>img]:w-full [&>img]:object-cover [&>video]:h-full [&>video]:w-full [&>video]:object-cover [&>iframe]:h-full [&>iframe]:w-full [&>iframe]:border-0", {
|
|
39
|
+
variants: {
|
|
40
|
+
radius: {
|
|
41
|
+
none: "rounded-none",
|
|
42
|
+
sm: "rounded-sm",
|
|
43
|
+
md: "rounded-md",
|
|
44
|
+
lg: "rounded-lg",
|
|
45
|
+
xl: "rounded-xl",
|
|
46
|
+
"2xl": "rounded-2xl",
|
|
47
|
+
full: "rounded-full",
|
|
48
|
+
},
|
|
49
|
+
bordered: {
|
|
50
|
+
true: "border border-border",
|
|
51
|
+
false: "",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
radius: "md",
|
|
56
|
+
bordered: false,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
function AspectRatio({ className, ratio, preset, radius, bordered, asChild = false, style, children, ...props }) {
|
|
60
|
+
const Comp = asChild ? Slot : "div";
|
|
61
|
+
const resolvedRatio = ratio ??
|
|
62
|
+
(preset !== undefined
|
|
63
|
+
? ASPECT_RATIO_PRESETS[preset]
|
|
64
|
+
: ASPECT_RATIO_PRESETS.video);
|
|
65
|
+
const mergedStyle = {
|
|
66
|
+
aspectRatio: String(resolvedRatio),
|
|
67
|
+
...style,
|
|
68
|
+
};
|
|
69
|
+
return (_jsx(Comp, { "data-slot": "aspect-ratio", "data-preset": preset, className: cn(aspectRatioVariants({ radius, bordered }), className), style: mergedStyle, ...props, children: children }));
|
|
70
|
+
}
|
|
71
|
+
AspectRatio.displayName = "AspectRatio";
|
|
72
|
+
export { AspectRatio };
|
|
73
|
+
//# sourceMappingURL=aspect-ratio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspect-ratio.js","sourceRoot":"","sources":["../../../../src/components/ui/aspect-ratio/aspect-ratio.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,WAAW;IACX,QAAQ;IACR,UAAU;IACV,kBAAkB;IAClB,OAAO;CACoB,CAA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AK,EACS;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpC,MAAM,aAAa,GACjB,KAAK;QACL,CAAC,MAAM,KAAK,SAAS;YACnB,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC;YAC9B,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAElC,MAAM,WAAW,GAAkB;QACjC,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC;QAClC,GAAG,KAAK;KACT,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,iBACO,cAAc,iBACX,MAAM,EACnB,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,EACnE,KAAK,EAAE,WAAW,KACd,KAAK,YAER,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/aspect-ratio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const colorSwatchSizeIds: readonly ["xs", "sm", "default", "lg", "xl"];
|
|
2
|
+
export type ColorSwatchSize = (typeof colorSwatchSizeIds)[number];
|
|
3
|
+
export declare const colorSwatchShapeIds: readonly ["circle", "rounded", "square"];
|
|
4
|
+
export type ColorSwatchShape = (typeof colorSwatchShapeIds)[number];
|
|
5
|
+
export declare const colorSwatchVariantIds: readonly ["default", "outline", "ghost"];
|
|
6
|
+
export type ColorSwatchVariant = (typeof colorSwatchVariantIds)[number];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const colorSwatchSizeIds = [
|
|
2
|
+
"xs",
|
|
3
|
+
"sm",
|
|
4
|
+
"default",
|
|
5
|
+
"lg",
|
|
6
|
+
"xl",
|
|
7
|
+
];
|
|
8
|
+
export const colorSwatchShapeIds = [
|
|
9
|
+
"circle",
|
|
10
|
+
"rounded",
|
|
11
|
+
"square",
|
|
12
|
+
];
|
|
13
|
+
export const colorSwatchVariantIds = [
|
|
14
|
+
"default",
|
|
15
|
+
"outline",
|
|
16
|
+
"ghost",
|
|
17
|
+
];
|
|
18
|
+
//# sourceMappingURL=color-swatch-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-swatch-variants.js","sourceRoot":"","sources":["../../../../src/components/ui/color-swatch/color-swatch-variants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI;IACJ,IAAI;IACJ,SAAS;IACT,IAAI;IACJ,IAAI;CACgC,CAAC;AAGvC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ;IACR,SAAS;IACT,QAAQ;CAC4B,CAAC;AAGvC,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS;IACT,SAAS;IACT,OAAO;CAC6B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { type HTMLAttributes, type MouseEvent, type Ref } from "react";
|
|
3
|
+
import { colorSwatchShapeIds, colorSwatchSizeIds, colorSwatchVariantIds, type ColorSwatchShape, type ColorSwatchSize, type ColorSwatchVariant } from "./color-swatch-variants";
|
|
4
|
+
declare const colorSwatchVariants: (props?: ({
|
|
5
|
+
size?: "xs" | "sm" | "default" | "lg" | "xl" | null | undefined;
|
|
6
|
+
shape?: "circle" | "square" | "rounded" | null | undefined;
|
|
7
|
+
variant?: "default" | "ghost" | "outline" | null | undefined;
|
|
8
|
+
interactive?: boolean | null | undefined;
|
|
9
|
+
selected?: boolean | null | undefined;
|
|
10
|
+
disabled?: boolean | null | undefined;
|
|
11
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
12
|
+
export interface ColorSwatchProps extends Omit<HTMLAttributes<HTMLSpanElement>, "color">, Pick<VariantProps<typeof colorSwatchVariants>, "size" | "shape" | "variant"> {
|
|
13
|
+
/**
|
|
14
|
+
* The color to display. Accepts any CSS color value:
|
|
15
|
+
* - hex ("#7c3aed")
|
|
16
|
+
* - rgb / rgba / hsl / hsla
|
|
17
|
+
* - CSS variables ("hsl(var(--primary))")
|
|
18
|
+
* - named colors ("rebeccapurple")
|
|
19
|
+
*/
|
|
20
|
+
color: string;
|
|
21
|
+
/** Accessible label (e.g. "Indigo"). Strongly recommended. */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Marks the swatch as the active selection. Adds a focus ring and check icon. */
|
|
24
|
+
selected?: boolean;
|
|
25
|
+
/** Disables interaction and dims the swatch. */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Click handler — when set the swatch becomes a keyboard-focusable button. */
|
|
28
|
+
onClick?: (event: MouseEvent<HTMLSpanElement>) => void;
|
|
29
|
+
/** Hide the check icon shown when `selected` is true. */
|
|
30
|
+
hideSelectedIcon?: boolean;
|
|
31
|
+
/** Color for the check icon when selected. Defaults to a contrast-aware white/black. */
|
|
32
|
+
checkIconColor?: string;
|
|
33
|
+
/** Optional ref forwarded to the outer element. */
|
|
34
|
+
ref?: Ref<HTMLSpanElement>;
|
|
35
|
+
}
|
|
36
|
+
export declare const ColorSwatch: import("react").ForwardRefExoticComponent<Omit<ColorSwatchProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
37
|
+
export interface ColorSwatchGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
38
|
+
/** Visual gap between swatches. Maps to Tailwind's gap scale. */
|
|
39
|
+
gap?: "tight" | "default" | "loose";
|
|
40
|
+
/** Optional accessible label for the entire group (e.g. "Theme color"). */
|
|
41
|
+
label?: string;
|
|
42
|
+
/** Forwarded ref. */
|
|
43
|
+
ref?: Ref<HTMLDivElement>;
|
|
44
|
+
}
|
|
45
|
+
export declare const ColorSwatchGroup: import("react").ForwardRefExoticComponent<Omit<ColorSwatchGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
+
export { colorSwatchVariants, colorSwatchSizeIds, colorSwatchShapeIds, colorSwatchVariantIds, };
|
|
47
|
+
export type { ColorSwatchSize, ColorSwatchShape, ColorSwatchVariant };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { forwardRef, } from "react";
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
|
+
import { colorSwatchShapeIds, colorSwatchSizeIds, colorSwatchVariantIds, } from "./color-swatch-variants";
|
|
8
|
+
const colorSwatchVariants = cva("relative inline-flex shrink-0 items-center justify-center align-middle transition-[transform,box-shadow,opacity] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", {
|
|
9
|
+
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
xs: "size-4",
|
|
12
|
+
sm: "size-5",
|
|
13
|
+
default: "size-7",
|
|
14
|
+
lg: "size-9",
|
|
15
|
+
xl: "size-12",
|
|
16
|
+
},
|
|
17
|
+
shape: {
|
|
18
|
+
circle: "rounded-full",
|
|
19
|
+
rounded: "rounded-md",
|
|
20
|
+
square: "rounded-none",
|
|
21
|
+
},
|
|
22
|
+
variant: {
|
|
23
|
+
default: "border border-border/40 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.05)]",
|
|
24
|
+
outline: "border-2 border-border",
|
|
25
|
+
ghost: "border-0",
|
|
26
|
+
},
|
|
27
|
+
interactive: {
|
|
28
|
+
true: "cursor-pointer hover:scale-110 active:scale-95",
|
|
29
|
+
false: "",
|
|
30
|
+
},
|
|
31
|
+
selected: {
|
|
32
|
+
true: "ring-2 ring-ring ring-offset-2 ring-offset-background",
|
|
33
|
+
false: "",
|
|
34
|
+
},
|
|
35
|
+
disabled: {
|
|
36
|
+
true: "opacity-40 pointer-events-none",
|
|
37
|
+
false: "",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
size: "default",
|
|
42
|
+
shape: "circle",
|
|
43
|
+
variant: "default",
|
|
44
|
+
interactive: false,
|
|
45
|
+
selected: false,
|
|
46
|
+
disabled: false,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const checkIconSizeClass = {
|
|
50
|
+
xs: "size-2.5",
|
|
51
|
+
sm: "size-3",
|
|
52
|
+
default: "size-4",
|
|
53
|
+
lg: "size-5",
|
|
54
|
+
xl: "size-6",
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Heuristic — computes whether a CSS color is "light" so we can flip the
|
|
58
|
+
* contrast color of the selection check icon. Falls back to white for any
|
|
59
|
+
* non-hex value (CSS variables, names, etc).
|
|
60
|
+
*/
|
|
61
|
+
function getContrastingCheckColor(color) {
|
|
62
|
+
const trimmed = color.trim();
|
|
63
|
+
const hexMatch = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(trimmed);
|
|
64
|
+
if (!hexMatch)
|
|
65
|
+
return "#ffffff";
|
|
66
|
+
let hex = hexMatch[1];
|
|
67
|
+
if (hex.length === 3) {
|
|
68
|
+
hex = hex
|
|
69
|
+
.split("")
|
|
70
|
+
.map((c) => c + c)
|
|
71
|
+
.join("");
|
|
72
|
+
}
|
|
73
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
74
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
75
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
76
|
+
// Relative luminance — sRGB approximation.
|
|
77
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
78
|
+
return luminance > 0.6 ? "#0a0a0a" : "#ffffff";
|
|
79
|
+
}
|
|
80
|
+
function ColorSwatchImpl({ className, color, label, size, shape, variant, selected = false, disabled = false, onClick, onKeyDown, hideSelectedIcon = false, checkIconColor, style, role, tabIndex, "aria-label": ariaLabelProp, ...props }, ref) {
|
|
81
|
+
const interactive = Boolean(onClick) && !disabled;
|
|
82
|
+
const ariaLabel = ariaLabelProp ?? label ?? color;
|
|
83
|
+
const resolvedSize = size ?? "default";
|
|
84
|
+
const iconColor = checkIconColor ?? getContrastingCheckColor(color);
|
|
85
|
+
function handleKeyDown(event) {
|
|
86
|
+
onKeyDown?.(event);
|
|
87
|
+
if (!interactive || event.defaultPrevented)
|
|
88
|
+
return;
|
|
89
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
onClick?.(event);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const mergedStyle = {
|
|
95
|
+
backgroundColor: color,
|
|
96
|
+
...style,
|
|
97
|
+
};
|
|
98
|
+
return (_jsx("span", { ref: ref, "data-slot": "color-swatch", "data-color": color, "data-selected": selected || undefined, "data-disabled": disabled || undefined, "data-interactive": interactive || undefined, role: role ?? (interactive ? "button" : "img"), tabIndex: tabIndex ?? (interactive ? 0 : undefined), "aria-pressed": interactive ? selected : undefined, "aria-label": ariaLabel, "aria-disabled": disabled || undefined, onClick: interactive ? onClick : undefined, onKeyDown: handleKeyDown, style: mergedStyle, className: cn(colorSwatchVariants({
|
|
99
|
+
size,
|
|
100
|
+
shape,
|
|
101
|
+
variant,
|
|
102
|
+
interactive,
|
|
103
|
+
selected,
|
|
104
|
+
disabled,
|
|
105
|
+
}), className), ...props, children: selected && !hideSelectedIcon && (_jsx(Check, { "aria-hidden": "true", className: cn("drop-shadow-sm", checkIconSizeClass[resolvedSize]), style: { color: iconColor }, strokeWidth: 3 })) }));
|
|
106
|
+
}
|
|
107
|
+
export const ColorSwatch = forwardRef(ColorSwatchImpl);
|
|
108
|
+
ColorSwatch.displayName = "ColorSwatch";
|
|
109
|
+
const groupGapClass = {
|
|
110
|
+
tight: "gap-1",
|
|
111
|
+
default: "gap-2",
|
|
112
|
+
loose: "gap-3",
|
|
113
|
+
};
|
|
114
|
+
function ColorSwatchGroupImpl({ className, children, gap = "default", label, role, "aria-label": ariaLabelProp, ...props }, ref) {
|
|
115
|
+
return (_jsx("div", { ref: ref, "data-slot": "color-swatch-group", role: role ?? "group", "aria-label": ariaLabelProp ?? label, className: cn("flex flex-wrap items-center", groupGapClass[gap], className), ...props, children: children }));
|
|
116
|
+
}
|
|
117
|
+
export const ColorSwatchGroup = forwardRef(ColorSwatchGroupImpl);
|
|
118
|
+
ColorSwatchGroup.displayName = "ColorSwatchGroup";
|
|
119
|
+
export { colorSwatchVariants, colorSwatchSizeIds, colorSwatchShapeIds, colorSwatchVariantIds, };
|
|
120
|
+
//# sourceMappingURL=color-swatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-swatch.js","sourceRoot":"","sources":["../../../../src/components/ui/color-swatch/color-swatch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,UAAU,GAOX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GAItB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,mBAAmB,GAAG,GAAG,CAC7B,2PAA2P,EAC3P;IACE,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,EAAE,EAAE,QAAQ;YACZ,EAAE,EAAE,QAAQ;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,kBAAkB,CAAC,YAAY,CAAC,CAAC,EACjE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAC3B,WAAW,EAAE,CAAC,GACd,CACH,GACI,CACR,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,eAAe,CAChB,CAAC;AACF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAWxC,MAAM,aAAa,GAA8D;IAC/E,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,SAAS,oBAAoB,CAC3B,EACE,SAAS,EACT,QAAQ,EACR,GAAG,GAAG,SAAS,EACf,KAAK,EACL,IAAI,EACJ,YAAY,EAAE,aAAa,EAC3B,GAAG,KAAK,EACc,EACxB,GAAwB;IAExB,OAAO,CACL,cACE,GAAG,EAAE,GAAG,eACE,oBAAoB,EAC9B,IAAI,EAAE,IAAI,IAAI,OAAO,gBACT,aAAa,IAAI,KAAK,EAClC,SAAS,EAAE,EAAE,CAAC,6BAA6B,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,KACvE,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACxC,oBAAoB,CACrB,CAAC;AACF,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ColorSwatch, ColorSwatch as default, ColorSwatchGroup, colorSwatchVariants, } from "./color-swatch";
|
|
2
|
+
export type { ColorSwatchProps, ColorSwatchGroupProps, } from "./color-swatch";
|
|
3
|
+
export { colorSwatchSizeIds, colorSwatchShapeIds, colorSwatchVariantIds, } from "./color-swatch-variants";
|
|
4
|
+
export type { ColorSwatchSize, ColorSwatchShape, ColorSwatchVariant, } from "./color-swatch-variants";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/color-swatch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,IAAI,OAAO,EACtB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC"}
|
|
@@ -142,3 +142,7 @@ export * from "./number-ticker";
|
|
|
142
142
|
export type * from "./number-ticker";
|
|
143
143
|
export * from "./sparkline";
|
|
144
144
|
export type * from "./sparkline";
|
|
145
|
+
export * from "./aspect-ratio";
|
|
146
|
+
export type * from "./aspect-ratio";
|
|
147
|
+
export * from "./color-swatch";
|
|
148
|
+
export type * from "./color-swatch";
|
|
@@ -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,WAAW,CAAC;AAG1B,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;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