@spear-ai/spectral 1.4.47 → 1.5.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.
package/dist/Button.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { AsChildProp } from './primitives/slot';
1
2
  import { VariantProps } from 'class-variance-authority';
2
3
  import { ButtonHTMLAttributes, MouseEvent, ReactNode, Ref } from 'react';
3
4
  declare const buttonVariants: (props?: ({
@@ -5,13 +6,13 @@ declare const buttonVariants: (props?: ({
5
6
  size?: "small" | "default" | "fullWidth" | null | undefined;
6
7
  state?: "default" | "error" | "loading" | null | undefined;
7
8
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
- export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color'>, VariantProps<typeof buttonVariants> {
9
+ export interface ButtonProps extends AsChildProp, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color'>, VariantProps<typeof buttonVariants> {
9
10
  disabled?: boolean;
10
11
  endIcon?: ReactNode;
11
12
  errorMessage?: string | ReactNode;
12
- onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
13
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
13
14
  dataTestId?: string;
14
- label: string;
15
+ label?: string;
15
16
  size?: 'small' | 'default' | 'fullWidth';
16
17
  startIcon?: ReactNode;
17
18
  state?: 'default' | 'error' | 'loading';
@@ -19,7 +20,7 @@ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
19
20
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
20
21
  }
21
22
  export declare const Button: {
22
- ({ ref, className, dataTestId, disabled, endIcon, errorMessage, label, size, startIcon, state, type, variant, ...props }: ButtonProps & {
23
+ ({ ref, asChild, className, dataTestId, disabled, endIcon, errorMessage, label, onClick, size, startIcon, state, type, variant, children, ...props }: ButtonProps & {
23
24
  ref?: Ref<HTMLButtonElement>;
24
25
  }): import("react/jsx-runtime").JSX.Element;
25
26
  displayName: string;
package/dist/Button.js CHANGED
@@ -1,11 +1,13 @@
1
+ "use client";
1
2
  import "./styles/main.css";
2
- import { jsxs as s, jsx as o } from "react/jsx-runtime";
3
- import { ErrorMessage as h } from "./utils/formFieldUtils.js";
4
- import { cn as u } from "./utils/twUtils.js";
5
- import { c as y } from "./index-D29mdTf5.js";
6
- import "react";
7
- import { c as f } from "./createLucideIcon-D4r5Phnh.js";
8
- const N = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], w = f("loader-circle", N), _ = y(
3
+ import { jsxs as p, jsx as r, Fragment as k } from "react/jsx-runtime";
4
+ import { Slot as z } from "./primitives/slot.js";
5
+ import { ErrorMessage as B } from "./utils/formFieldUtils.js";
6
+ import { cn as i } from "./utils/twUtils.js";
7
+ import { c as E } from "./index-D29mdTf5.js";
8
+ import { isValidElement as V, Children as D } from "react";
9
+ import { c as L } from "./createLucideIcon-D4r5Phnh.js";
10
+ const S = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], q = L("loader-circle", S), A = E(
9
11
  `
10
12
  !font-sans flex relative items-center justify-center gap-2 whitespace-nowrap transition-colors cursor-pointer rounded-lg border font-semibold focus:outline-none focus:outline-none
11
13
  focus-visible:outline-1 focus-visible:outline-offset-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 disabled:pointer-events-none
@@ -38,22 +40,25 @@ const N = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], w = f
38
40
  size: "default"
39
41
  }
40
42
  }
41
- ), j = ({
42
- ref: l,
43
- className: g,
44
- dataTestId: c,
45
- disabled: r,
46
- endIcon: n,
47
- errorMessage: b,
48
- label: p,
49
- size: a,
50
- startIcon: d,
51
- state: t,
52
- type: x = "button",
53
- variant: e = "primary",
54
- ...m
43
+ ), F = ({
44
+ ref: x,
45
+ asChild: m = !1,
46
+ className: v,
47
+ dataTestId: h,
48
+ disabled: o,
49
+ endIcon: b,
50
+ errorMessage: d,
51
+ label: y,
52
+ onClick: f,
53
+ size: s,
54
+ startIcon: u,
55
+ state: e,
56
+ type: w = "button",
57
+ variant: n = "primary",
58
+ children: a,
59
+ ...C
55
60
  }) => {
56
- const i = {
61
+ const l = {
57
62
  error: {
58
63
  primary: "bg-button-danger border-button-danger text-text-primary hover:bg-button-danger--hover hover:text-text-primary",
59
64
  secondary: "bg-button-danger border-button-danger text-text-primary hover:bg-button-danger--hover hover:text-text-primary",
@@ -66,18 +71,39 @@ const N = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], w = f
66
71
  outline: "bg-button-outline-bg--disabled border-button-outline-border--disabled text-button-outline-text--disabled pointer-events-none",
67
72
  ghost: "bg-transparent text-button-ghost-text--disabled pointer-events-none"
68
73
  }
69
- }, v = u(_({ variant: e, state: t, size: a }), t === "error" && i.error[e], t === "loading" && i.loading[e], g);
70
- return /* @__PURE__ */ s("div", { className: u("flex flex-col justify-items-center", a), children: [
71
- /* @__PURE__ */ s("button", { "aria-disabled": r, className: v, "data-state": t, "data-testid": c || `spectral-button-${e}`, disabled: r, ref: l, type: x, ...m, children: [
72
- d && /* @__PURE__ */ o("span", { className: "flex pr-1", "aria-hidden": !0, "data-testid": "spectral-button-start-icon", children: d }),
73
- t === "loading" && /* @__PURE__ */ o(w, { className: "ml-2 animate-spin", size: 16 }),
74
- p,
75
- n && t !== "loading" && /* @__PURE__ */ o("span", { className: "flex pl-2", "aria-hidden": !0, "data-testid": "spectral-button-end-icon", children: n })
76
- ] }),
77
- t === "error" && b && /* @__PURE__ */ o(h, { message: b, dataTestId: "spectral-button-error-message", id: "button-error" })
74
+ }, N = i(A({ variant: n, state: e, size: s }), e === "error" && l.error[n], e === "loading" && l.loading[n], v), t = m && V(a) && D.count(a) === 1, c = t ? void 0 : a ?? y;
75
+ if (!t && !c)
76
+ throw new Error("Button requires either `label` or `children`");
77
+ const _ = (g) => {
78
+ o && (g.preventDefault(), g.stopPropagation());
79
+ }, j = t ? z : "button";
80
+ return /* @__PURE__ */ p("div", { className: i("flex flex-col justify-items-center", s), children: [
81
+ /* @__PURE__ */ r(
82
+ j,
83
+ {
84
+ "aria-disabled": o,
85
+ className: i(N, t && o && "pointer-events-none opacity-50"),
86
+ "data-state": e,
87
+ "data-testid": h || `spectral-button-${n}`,
88
+ disabled: t ? void 0 : o,
89
+ onClickCapture: t ? _ : void 0,
90
+ onClick: f,
91
+ ref: x,
92
+ tabIndex: t && o ? -1 : void 0,
93
+ type: t ? void 0 : w,
94
+ ...C,
95
+ children: t ? a : /* @__PURE__ */ p(k, { children: [
96
+ u && /* @__PURE__ */ r("span", { className: "flex pr-1", "aria-hidden": !0, "data-testid": "spectral-button-start-icon", children: u }),
97
+ e === "loading" && /* @__PURE__ */ r(q, { className: "ml-2 animate-spin", size: 16 }),
98
+ c,
99
+ b && e !== "loading" && /* @__PURE__ */ r("span", { className: "flex pl-2", "aria-hidden": !0, "data-testid": "spectral-button-end-icon", children: b })
100
+ ] })
101
+ }
102
+ ),
103
+ e === "error" && d && /* @__PURE__ */ r(B, { message: d, dataTestId: "spectral-button-error-message", id: "button-error" })
78
104
  ] });
79
105
  };
80
- j.displayName = "Button";
106
+ F.displayName = "Button";
81
107
  export {
82
- j as Button
108
+ F as Button
83
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spear-ai/spectral",
3
- "version": "1.4.47",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "repository": {