@spear-ai/spectral 1.0.0 → 1.0.2

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/index.js CHANGED
@@ -1,276 +1,33 @@
1
- "use client"
2
-
3
- // src/utils/twUtils.ts
4
- import { clsx } from "clsx";
5
- import { twMerge } from "tailwind-merge";
6
- function cn(...inputs) {
7
- return twMerge(clsx(inputs));
8
- }
9
- function pxToRem(px) {
10
- return `${px / 16}rem`;
11
- }
12
-
13
- // src/components/Button/Button.tsx
14
- import { cva } from "class-variance-authority";
15
- import { Loader2 } from "lucide-react";
16
- import { forwardRef } from "react";
17
- import { jsx, jsxs } from "react/jsx-runtime";
18
- var buttonVariants = cva(
19
- `
20
- flex relative items-center justify-center gap-2 whitespace-nowrap transition-colors cursor-pointer py-2 px-6 rounded-lg border font-semibold
21
- focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus:ring-2 focus:ring-ring focus:ring-offset-2
22
- focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0
23
- `,
24
- {
25
- variants: {
26
- variant: {
27
- primary: "bg-button-primary-bg text-button-primary-text border-button-primary-border disabled:bg-button-primary-bg--disabled disabled:text-button-primary-text--disabled disabled:border-button-primary-border--disabled",
28
- secondary: "bg-button-secondary-bg border-button-secondary-border text-button-secondary-text disabled:bg-button-secondary-bg--disabled disabled:text-button-secondary-text--disabled disabled:border-button-secondary-border--disabled",
29
- outline: "bg-button-outline-bg border-button-outline-border text-button-outline-text disabled:text-button-outline-text--disabled disabled:border-button-outline-border--disabled"
30
- },
31
- state: {
32
- default: "",
33
- error: "bg-button-danger text-button-primary-text transition pointer-events-none",
34
- loading: "cursor-wait pointer-events-none"
35
- }
36
- },
37
- defaultVariants: {
38
- variant: "primary",
39
- state: "default"
40
- }
41
- }
42
- );
43
- var Button = forwardRef(
44
- ({
45
- className,
46
- variant,
47
- label,
48
- endIcon,
49
- state,
50
- errorMessage,
51
- startIcon,
52
- disabled,
53
- type = "button",
54
- dataTestId = `button-${variant}`,
55
- isFullWidth,
56
- ...props
57
- }, ref) => {
58
- const stateStyles = {
59
- error: {
60
- primary: "bg-button-danger border-button-danger text-button-primary-text pointer-events-none",
61
- secondary: "bg-button-danger border-button-danger text-button-secondary-text pointer-events-none",
62
- outline: "bg-transparent border-button-danger text-button-danger pointer-events-none"
63
- },
64
- loading: {
65
- primary: "bg-button-primary-bg--disabled border-button-primary-border--disabled text-button-primary-text--disabled pointer-events-none",
66
- secondary: "bg-button-secondary-bg--disabled border-button-secondary-border--disabled text-button-secondary-text--disabled pointer-events-none",
67
- outline: "bg-button-outline-bg--disabled border-button-outline-border--disabled text-button-outline-text--disabled pointer-events-none"
68
- }
69
- };
70
- const widthClass = isFullWidth ? "w-full" : "w-auto";
71
- const classes = cn(
72
- buttonVariants({ variant, state }),
73
- state === "error" && stateStyles.error[variant || "primary"],
74
- state === "loading" && stateStyles.loading[variant || "primary"],
75
- widthClass,
76
- className
77
- );
78
- return /* @__PURE__ */ jsxs("div", { className: cn("flex justify-items-center", widthClass), children: [
79
- /* @__PURE__ */ jsxs(
80
- "button",
81
- {
82
- className: classes,
83
- ref,
84
- type,
85
- "aria-disabled": disabled,
86
- disabled,
87
- "data-testid": dataTestId,
88
- ...props,
89
- "data-state": state,
90
- children: [
91
- startIcon && /* @__PURE__ */ jsx("span", { className: "flex pr-2", "aria-hidden": true, children: startIcon }),
92
- label,
93
- state === "loading" && /* @__PURE__ */ jsx(Loader2, { className: "ml-2 animate-spin", size: 16 }),
94
- endIcon && state !== "loading" && /* @__PURE__ */ jsx("span", { className: "flex pl-2", "aria-hidden": true, children: endIcon })
95
- ]
96
- }
97
- ),
98
- state === "error" && errorMessage && /* @__PURE__ */ jsx("p", { className: "text-danger text-xs", role: "alert", "aria-live": "polite", children: errorMessage })
99
- ] });
100
- }
101
- );
102
- Button.displayName = "Button";
103
-
104
- // src/components/Card/Card.tsx
105
- import { Loader2 as Loader22 } from "lucide-react";
106
- import { forwardRef as forwardRef2 } from "react";
107
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
108
- var Card = forwardRef2(
109
- ({ className, title, icon, width = "full", isLoading = false, children, ...props }, ref) => {
110
- const hasHeader = title || icon;
111
- const cardClasses = cn(
112
- "relative bg-card-bg rounded-2xl p-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
113
- width === "full" ? "w-full" : "w-fit",
114
- className
115
- );
116
- return /* @__PURE__ */ jsxs2("div", { ref, className: cardClasses, ...props, children: [
117
- isLoading && /* @__PURE__ */ jsx2("div", { className: "bg-card-bg/50 absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ jsx2(Loader22, { className: "text-muted-foreground animate-spin", size: 24 }) }),
118
- hasHeader && /* @__PURE__ */ jsxs2("div", { className: cn("flex items-center pb-4", title ? "justify-between" : "justify-end"), children: [
119
- title && /* @__PURE__ */ jsx2("h3", { className: "text-card-text truncate text-base font-semibold", children: title }),
120
- icon && /* @__PURE__ */ jsx2("div", { className: "flex-shrink-0", "aria-hidden": "true", children: icon })
121
- ] }),
122
- /* @__PURE__ */ jsx2("div", { className: cn("min-h-40 p-4", hasHeader && "pt-0"), children })
123
- ] });
124
- }
125
- );
126
- Card.displayName = "Card";
127
-
128
- // src/components/Drawer/Drawer.tsx
129
- import { Drawer as DrawerBase } from "vaul";
130
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
131
- var Drawer = ({ trigger, title, description, children, direction = "right", size = "320px" }) => {
132
- const baseStyles = "fixed";
133
- const directionStyles = {
134
- left: {
135
- className: `${baseStyles} top-0 bottom-0 left-0 shadow-[20px_0_20px_rgba(0,0,0,0.4)]`,
136
- style: { width: size }
137
- },
138
- right: {
139
- className: `${baseStyles} top-0 bottom-0 right-0 shadow-[-20px_0_20px_rgba(0,0,0,0.4)]`,
140
- style: { width: size }
141
- },
142
- top: {
143
- className: `${baseStyles} top-0 left-0 right-0 shadow-[0_20px_20px_rgba(0,0,0,0.4)]`,
144
- style: { height: size }
145
- },
146
- bottom: {
147
- className: `${baseStyles} bottom-0 left-0 right-0 shadow-[0_-20px_20px_rgba(0,0,0,0.4)]`,
148
- style: { height: size }
149
- }
1
+ "use client";
2
+ import "./assets/spectral.css";
3
+ import { Button as i } from "./Button.js";
4
+ import { Card as p } from "./Card.js";
5
+ import { Drawer as g } from "./Drawer.js";
6
+ import { Skeleton as k } from "./Skeleton.js";
7
+ import { Slider as w } from "./Slider.js";
8
+ import { useState as n, useEffect as s } from "react";
9
+ import { c as E, p as I } from "./twUtils-B9ArqCOv.js";
10
+ const d = (o = "dark") => {
11
+ const [t, m] = n(() => {
12
+ if (typeof window > "u") return o;
13
+ const e = localStorage.getItem("theme");
14
+ return e === "light" || e === "dark" ? e : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
15
+ }), r = (e) => {
16
+ m(e);
17
+ }, a = () => {
18
+ r(t === "dark" ? "light" : "dark");
150
19
  };
151
- const { className, style } = directionStyles[direction];
152
- return /* @__PURE__ */ jsxs3(DrawerBase.Root, { direction, children: [
153
- /* @__PURE__ */ jsx3(DrawerBase.Trigger, { asChild: true, children: trigger }),
154
- /* @__PURE__ */ jsxs3(DrawerBase.Portal, { children: [
155
- /* @__PURE__ */ jsx3(DrawerBase.Overlay, { className: "fixed inset-0 bg-transparent" }),
156
- /* @__PURE__ */ jsxs3(DrawerBase.Content, { className: `bg-drawer-bg z-10 flex flex-col p-4 outline-none ${className}`, style, children: [
157
- /* @__PURE__ */ jsx3(DrawerBase.Close, {}),
158
- /* @__PURE__ */ jsx3(DrawerBase.Title, { className: "text-text-primary mb-2 text-lg font-semibold", children: title }),
159
- /* @__PURE__ */ jsx3(DrawerBase.Description, { className: "!text-text-secondary mb-2 !text-xs uppercase", children: description }),
160
- /* @__PURE__ */ jsx3("div", { className: "pt-2", children })
161
- ] })
162
- ] })
163
- ] });
164
- };
165
-
166
- // src/components/Skeleton/Skeleton.tsx
167
- import "react";
168
- import { jsx as jsx4 } from "react/jsx-runtime";
169
- function Skeleton({ className, ...props }) {
170
- return /* @__PURE__ */ jsx4("div", { "data-slot": "skeleton", className: cn("bg-accent animate-pulse rounded-md", className), ...props });
171
- }
172
-
173
- // src/components/Slider/Slider.tsx
174
- import * as SliderPrimitive from "@radix-ui/react-slider";
175
- import "react";
176
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
177
- function Slider({
178
- className,
179
- defaultValue,
180
- value,
181
- min = 0,
182
- max = 100,
183
- step = 1,
184
- minStepsBetweenThumbs = 1,
185
- onValueChange,
186
- orientation = "horizontal",
187
- onValueCommit,
188
- disabled,
189
- name,
190
- ...props
191
- }) {
192
- const _values = value || defaultValue || [min];
193
- return /* @__PURE__ */ jsxs4(
194
- SliderPrimitive.Root,
195
- {
196
- "data-slot": "slider",
197
- defaultValue,
198
- value,
199
- min,
200
- max,
201
- step,
202
- minStepsBetweenThumbs,
203
- onValueChange,
204
- orientation,
205
- onValueCommit,
206
- disabled,
207
- name,
208
- className: cn(
209
- "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
210
- className
211
- ),
212
- ...props,
213
- children: [
214
- /* @__PURE__ */ jsx5(
215
- SliderPrimitive.Track,
216
- {
217
- "data-slot": "slider-track",
218
- className: cn(
219
- "bg-slider-track relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
220
- ),
221
- children: /* @__PURE__ */ jsx5(
222
- SliderPrimitive.Range,
223
- {
224
- "data-slot": "slider-range",
225
- className: cn(
226
- "bg-slider-range absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
227
- )
228
- }
229
- )
230
- }
231
- ),
232
- Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ jsx5(
233
- SliderPrimitive.Thumb,
234
- {
235
- "data-slot": "slider-thumb",
236
- className: "border-slider-thumb-border bg-slider-thumb-bg ring-slider-thumb-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
237
- },
238
- index
239
- ))
240
- ]
241
- }
242
- );
243
- }
244
-
245
- // src/hooks/useTheme.ts
246
- import { useEffect, useState } from "react";
247
- var useTheme = (defaultTheme = "dark") => {
248
- const [theme, setThemeState] = useState(() => {
249
- if (typeof window === "undefined") return defaultTheme;
250
- const stored = localStorage.getItem("theme");
251
- if (stored === "light" || stored === "dark") return stored;
252
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
253
- });
254
- const setTheme = (newTheme) => {
255
- setThemeState(newTheme);
256
- };
257
- const toggleTheme = () => {
258
- setTheme(theme === "dark" ? "light" : "dark");
259
- };
260
- useEffect(() => {
261
- const root = document.documentElement;
262
- root.setAttribute("data-theme", theme);
263
- localStorage.setItem("theme", theme);
264
- }, [theme]);
265
- return { theme, setTheme, toggleTheme };
20
+ return s(() => {
21
+ document.documentElement.setAttribute("data-theme", t), localStorage.setItem("theme", t);
22
+ }, [t]), { theme: t, setTheme: r, toggleTheme: a };
266
23
  };
267
24
  export {
268
- Button,
269
- Card,
270
- Drawer,
271
- Skeleton,
272
- Slider,
273
- cn,
274
- pxToRem,
275
- useTheme
25
+ i as Button,
26
+ p as Card,
27
+ g as Drawer,
28
+ k as Skeleton,
29
+ w as Slider,
30
+ E as cn,
31
+ I as pxToRem,
32
+ d as useTheme
276
33
  };
@@ -0,0 +1,101 @@
1
+ import { forwardRef as l, createElement as n } from "react";
2
+ /**
3
+ * @license lucide-react v0.542.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */
8
+ const h = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), w = (t) => t.replace(
9
+ /^([A-Z])|[\s-_]+(\w)/g,
10
+ (e, r, o) => o ? o.toUpperCase() : r.toLowerCase()
11
+ ), i = (t) => {
12
+ const e = w(t);
13
+ return e.charAt(0).toUpperCase() + e.slice(1);
14
+ }, u = (...t) => t.filter((e, r, o) => !!e && e.trim() !== "" && o.indexOf(e) === r).join(" ").trim(), f = (t) => {
15
+ for (const e in t)
16
+ if (e.startsWith("aria-") || e === "role" || e === "title")
17
+ return !0;
18
+ };
19
+ /**
20
+ * @license lucide-react v0.542.0 - ISC
21
+ *
22
+ * This source code is licensed under the ISC license.
23
+ * See the LICENSE file in the root directory of this source tree.
24
+ */
25
+ var g = {
26
+ xmlns: "http://www.w3.org/2000/svg",
27
+ width: 24,
28
+ height: 24,
29
+ viewBox: "0 0 24 24",
30
+ fill: "none",
31
+ stroke: "currentColor",
32
+ strokeWidth: 2,
33
+ strokeLinecap: "round",
34
+ strokeLinejoin: "round"
35
+ };
36
+ /**
37
+ * @license lucide-react v0.542.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */
42
+ const A = l(
43
+ ({
44
+ color: t = "currentColor",
45
+ size: e = 24,
46
+ strokeWidth: r = 2,
47
+ absoluteStrokeWidth: o,
48
+ className: s = "",
49
+ children: a,
50
+ iconNode: d,
51
+ ...c
52
+ }, p) => n(
53
+ "svg",
54
+ {
55
+ ref: p,
56
+ ...g,
57
+ width: e,
58
+ height: e,
59
+ stroke: t,
60
+ strokeWidth: o ? Number(r) * 24 / Number(e) : r,
61
+ className: u("lucide", s),
62
+ ...!a && !f(c) && { "aria-hidden": "true" },
63
+ ...c
64
+ },
65
+ [
66
+ ...d.map(([C, m]) => n(C, m)),
67
+ ...Array.isArray(a) ? a : [a]
68
+ ]
69
+ )
70
+ );
71
+ /**
72
+ * @license lucide-react v0.542.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */
77
+ const L = (t, e) => {
78
+ const r = l(
79
+ ({ className: o, ...s }, a) => n(A, {
80
+ ref: a,
81
+ iconNode: e,
82
+ className: u(
83
+ `lucide-${h(i(t))}`,
84
+ `lucide-${t}`,
85
+ o
86
+ ),
87
+ ...s
88
+ })
89
+ );
90
+ return r.displayName = i(t), r;
91
+ };
92
+ /**
93
+ * @license lucide-react v0.542.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */
98
+ const k = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], y = L("loader-circle", k);
99
+ export {
100
+ y as L
101
+ };
@@ -0,0 +1,10 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import { ComponentProps } from 'react';
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "secondary" | "outline" | "default" | "link" | "destructive" | "ghost" | null | undefined;
5
+ size?: "default" | "icon" | "sm" | "lg" | null | undefined;
6
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
+ declare function ButtonPrimitive({ className, variant, size, asChild, ...props }: ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
8
+ asChild?: boolean;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ export { ButtonPrimitive, buttonVariants };
@@ -0,0 +1,3 @@
1
+ import { ComponentProps } from 'react';
2
+ declare function InputPrimitive({ className, type, ...props }: ComponentProps<'input'>): import("react/jsx-runtime").JSX.Element;
3
+ export { InputPrimitive };
@@ -0,0 +1,7 @@
1
+ import { ComponentProps } from 'react';
2
+ import * as TooltipRadix from '@radix-ui/react-tooltip';
3
+ declare function TooltipPrimitiveProvider({ delayDuration, ...props }: ComponentProps<typeof TooltipRadix.Provider>): import("react/jsx-runtime").JSX.Element;
4
+ declare function TooltipPrimitive({ ...props }: ComponentProps<typeof TooltipRadix.Root>): import("react/jsx-runtime").JSX.Element;
5
+ declare function TooltipPrimitiveTrigger({ ...props }: ComponentProps<typeof TooltipRadix.Trigger>): import("react/jsx-runtime").JSX.Element;
6
+ declare function TooltipPrimitiveContent({ className, sideOffset, children, ...props }: ComponentProps<typeof TooltipRadix.Content>): import("react/jsx-runtime").JSX.Element;
7
+ export { TooltipPrimitive, TooltipPrimitiveTrigger, TooltipPrimitiveContent, TooltipPrimitiveProvider };