@spear-ai/spectral 1.4.17 → 1.4.19

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.
@@ -1,18 +1,18 @@
1
1
  import "../styles/main.css";
2
- import { jsx as s } from "react/jsx-runtime";
2
+ import { jsx as n } from "react/jsx-runtime";
3
3
  import { Slot as a } from "../primitives/slot.js";
4
4
  import { cn as r } from "../utils/twUtils.js";
5
- import { c } from "../index-D29mdTf5.js";
5
+ import { c as l } from "../index-D29mdTf5.js";
6
6
  import "react";
7
- const l = c(
7
+ const c = l(
8
8
  `inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius,0.375rem)] text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none
9
9
  [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-accent focus-visible:outline-offset-2 focus-visible:outline-2 focus-visible:outline-accent
10
- aria-invalid:ring-destructive/20 aria-invalid:border-destructive bg-level-one text-text-primary hover:bg-level-two cursor-pointer active:text-accent`,
10
+ aria-invalid:ring-destructive/20 aria-invalid:border-destructive bg-level-one text-text-primary hover:bg-level-two cursor-pointer active:text-text-inverted active:bg-accent`,
11
11
  {
12
12
  variants: {
13
13
  variant: {
14
14
  default: "",
15
- outline: "border border-level-three active:text-accent active:border-accent"
15
+ outline: "border border-level-three"
16
16
  },
17
17
  size: {
18
18
  md: "h-9 px-4 py-2 has-[>svg]:px-3",
@@ -33,10 +33,10 @@ const l = c(
33
33
  variant: t,
34
34
  size: e,
35
35
  asChild: o = !1,
36
- ...n
37
- }) => /* @__PURE__ */ s(o ? a : "button", { "data-slot": "button-group-item", "data-variant": t, "data-size": e, className: r(l({ variant: t, size: e, className: i })), ...n });
36
+ ...s
37
+ }) => /* @__PURE__ */ n(o ? a : "button", { "data-slot": "button-group-item", "data-variant": t, "data-size": e, className: r(c({ variant: t, size: e, className: i })), ...s });
38
38
  u.displayName = "ButtonGroupButton";
39
39
  export {
40
40
  u as ButtonGroupButton,
41
- l as buttonVariants
41
+ c as buttonVariants
42
42
  };
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import { ComponentProps } from 'react';
4
4
  export declare const InputGroup: ({ className, ...props }: ComponentProps<"div">) => import("react/jsx-runtime").JSX.Element;
5
5
  export declare const inputGroupAddonVariants: (props?: ({
6
- align?: "block-end" | "block-start" | "inline-end" | "inline-start" | null | undefined;
6
+ align?: "inline-end" | "inline-start" | "block-end" | "block-start" | null | undefined;
7
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
8
  export declare const InputGroupAddon: ({ className, align, ...props }: ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) => import("react/jsx-runtime").JSX.Element;
9
9
  export declare const inputGroupButtonVariants: (props?: ({
package/dist/Toggle.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { ToggleBase } from './ToggleBase';
2
2
  import { VariantProps } from 'class-variance-authority';
3
- import { ComponentProps } from 'react';
4
- export type ToggleProps = ComponentProps<typeof ToggleBase> & VariantProps<typeof toggleVariants>;
3
+ import { ComponentProps, CSSProperties } from 'react';
4
+ export type ActiveColor = string;
5
+ export declare function getActiveColorStyle(activeColor: ActiveColor | undefined, activeTextColor?: ActiveColor): CSSProperties | undefined;
6
+ export type ToggleProps = ComponentProps<typeof ToggleBase> & VariantProps<typeof toggleVariants> & {
7
+ activeColor?: ActiveColor;
8
+ activeTextColor?: ActiveColor;
9
+ };
5
10
  export declare const toggleVariants: (props?: ({
6
11
  variant?: "default" | "outline" | null | undefined;
7
12
  size?: "default" | "sm" | "lg" | null | undefined;
package/dist/Toggle.js CHANGED
@@ -1,17 +1,33 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsx as s } from "react/jsx-runtime";
4
- import { ToggleBase as n } from "./Toggle/ToggleBase.js";
5
- import { cn as d } from "./utils/twUtils.js";
6
- import { c as l } from "./index-D29mdTf5.js";
7
- import { forwardRef as v } from "react";
8
- const b = l(
3
+ import { jsx as c } from "react/jsx-runtime";
4
+ import { ToggleBase as v } from "./Toggle/ToggleBase.js";
5
+ import { cn as b } from "./utils/twUtils.js";
6
+ import { c as u } from "./index-D29mdTf5.js";
7
+ import { forwardRef as h } from "react";
8
+ const f = /^(#|rgb|hsl|oklch|oklab|lab|lch|color|var\(|transparent|currentcolor)/i, p = /^(success|warning|danger|primary|neutral|secondary)-\d+$/;
9
+ function r(e) {
10
+ return f.test(e) ? e : p.test(e) ? `var(--horizon-color-${e})` : `var(--color-${e})`;
11
+ }
12
+ function m(e, t) {
13
+ if (!(!e && !t))
14
+ return {
15
+ ...e && {
16
+ "--color-toggle-bg--active": r(e),
17
+ "--color-toggle-border--active": r(e)
18
+ },
19
+ ...t && {
20
+ "--color-toggle-text--active": r(t)
21
+ }
22
+ };
23
+ }
24
+ const x = u(
9
25
  `
10
- bg-toggle-bg inline-flex items-center justify-center gap-2 border rounded-md text-sm shadow-sm font-medium w-fit data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed
11
- hover:cursor-pointer data-[state=on]:text-toggle-text--active text-toggle-text hover:bg-toggle-bg--hover hover:border-toggle-border--hover data-[state=on]:bg-toggle-bg--active data-[state=on]:border-toggle-border--active
12
- data-[state=on]:border-toggle-border--active hover:text-toggle-text--hover data-[state=on]:bg-toggle-bg--active data-[state=on]:text-toggle-text--active aria-pressed:bg-toggle-bg--active
13
- aria-pressed:text-toggle-text--active aria-pressed:border-toggle-border--active active:bg-selected-primary focus:outline-none outline-none transition-[colors] [&_svg]:pointer-events-none
14
- [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-danger-200/20 dark:aria-invalid:ring-danger-200/40 aria-invalid:border-danger-200 whitespace-nowrap
26
+ bg-toggle-bg inline-flex items-center justify-center gap-2 border rounded-md text-sm shadow-sm font-medium w-fit text-toggle-text whitespace-nowrap outline-none transition-[colors]
27
+ [&_svg]:pointer-events-none [&_svg]:shrink-0 active:bg-toggle-bg--active hover:cursor-pointer hover:bg-toggle-bg--hover hover:border-toggle-border--hover hover:text-toggle-text--hover
28
+ data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed data-[state=on]:bg-toggle-bg--active data-[state=on]:text-toggle-text--active
29
+ data-[state=on]:border-toggle-border--active focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] focus:outline-none aria-invalid:ring-danger-200/20
30
+ aria-invalid:border-danger-200 aria-pressed:bg-toggle-bg--active aria-pressed:border-toggle-border--active aria-pressed:text-toggle-text--active
15
31
  `,
16
32
  {
17
33
  variants: {
@@ -35,8 +51,9 @@ const b = l(
35
51
  layout: "default"
36
52
  }
37
53
  }
38
- ), m = v(({ className: e, variant: t, size: o, layout: r, disabled: a, ...i }, g) => /* @__PURE__ */ s(n, { ref: g, disabled: a, "data-slot": "toggle", "data-testid": "spectral-toggle", className: d(b({ variant: t, size: o, layout: r }), e), ...i }));
54
+ ), A = h(({ className: e, variant: t, size: o, layout: a, disabled: i, activeColor: g, activeTextColor: n, style: s, ...l }, d) => /* @__PURE__ */ c(v, { ref: d, disabled: i, "data-slot": "toggle", "data-testid": "spectral-toggle", className: b(x({ variant: t, size: o, layout: a }), e), style: { ...m(g, n), ...s }, ...l }));
39
55
  export {
40
- m as Toggle,
41
- b as toggleVariants
56
+ A as Toggle,
57
+ m as getActiveColorStyle,
58
+ x as toggleVariants
42
59
  };
@@ -1,15 +1,15 @@
1
- import { ToggleGroupBase } from './ToggleGroupBase';
2
- import { toggleVariants } from '../Toggle/Toggle';
1
+ import { ToggleGroupBase, ToggleGroupItemBase } from './ToggleGroupBase';
2
+ import { toggleVariants, ActiveColor } from '../Toggle/Toggle';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
  import { ComponentProps } from 'react';
5
- export type ToggleGroupProps = ComponentProps<typeof ToggleGroupBase> & VariantProps<typeof toggleVariants>;
6
- export declare const ToggleGroup: ({ className, variant, size, layout, children, ...props }: ToggleGroupProps) => import("react/jsx-runtime").JSX.Element;
7
- export declare const ToggleGroupItem: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "pressed" | "defaultPressed" | "onPressedChange"> & import('./ToggleGroupBase').ItemRenderProps & {
8
- pressed?: boolean;
9
- defaultPressed?: boolean;
10
- } & import('react').RefAttributes<HTMLButtonElement> & VariantProps<(props?: ({
11
- variant?: "default" | "outline" | null | undefined;
12
- size?: "default" | "sm" | "lg" | null | undefined;
13
- layout?: "default" | "expanded" | null | undefined;
14
- } & import('class-variance-authority/types').ClassProp) | undefined) => string>, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
5
+ export type ToggleGroupItemProps = ComponentProps<typeof ToggleGroupItemBase> & VariantProps<typeof toggleVariants> & {
6
+ activeColor?: ActiveColor;
7
+ activeTextColor?: ActiveColor;
8
+ };
9
+ export type ToggleGroupProps = ComponentProps<typeof ToggleGroupBase> & VariantProps<typeof toggleVariants> & {
10
+ activeColor?: ActiveColor;
11
+ activeTextColor?: ActiveColor;
12
+ };
13
+ export declare const ToggleGroup: ({ className, variant, size, layout, activeColor, activeTextColor, children, ...props }: ToggleGroupProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const ToggleGroupItem: import('react').ForwardRefExoticComponent<Omit<ToggleGroupItemProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
15
15
  //# sourceMappingURL=ToggleGroup.d.ts.map
@@ -1,56 +1,58 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsx as u } from "react/jsx-runtime";
4
- import { ToggleGroupItemBase as p, ToggleGroupBase as m } from "./ToggleGroup/ToggleGroupBase.js";
5
- import { toggleVariants as f } from "./Toggle.js";
6
- import { cn as g } from "./utils/twUtils.js";
7
- import { createContext as c, forwardRef as v, useContext as b } from "react";
8
- const n = c({
3
+ import { jsx as s } from "react/jsx-runtime";
4
+ import { ToggleGroupItemBase as C, ToggleGroupBase as T } from "./ToggleGroup/ToggleGroupBase.js";
5
+ import { getActiveColorStyle as z, toggleVariants as G } from "./Toggle.js";
6
+ import { cn as c } from "./utils/twUtils.js";
7
+ import { createContext as w, forwardRef as h, useContext as A } from "react";
8
+ const m = w({
9
9
  size: "default",
10
10
  variant: "default",
11
11
  layout: "default"
12
- }), w = ({ className: d, variant: e, size: o, layout: a, children: l, ...r }) => /* @__PURE__ */ u(
13
- m,
12
+ }), j = ({ className: r, variant: o, size: e, layout: a, activeColor: l, activeTextColor: d, children: n, ...i }) => /* @__PURE__ */ s(
13
+ T,
14
14
  {
15
15
  "data-slot": "toggle-group",
16
16
  "data-testid": "spectral-toggle-group",
17
- "data-variant": e,
18
- "data-size": o,
17
+ "data-variant": o,
18
+ "data-size": e,
19
19
  "data-layout": a,
20
- className: g(
20
+ className: c(
21
21
  "group/toggle-group [&[data-variant='outline']]:bg-toggle-group-bg flex h-fit w-fit [&[data-layout='expanded']]:w-full items-center rounded-md [&_button:first-of-type]:rounded-l-md [&_button:last-of-type]:rounded-r-md [&[data-variant='outline']]:gap-0.25",
22
- d
22
+ r
23
23
  ),
24
- ...r,
25
- children: /* @__PURE__ */ u(n.Provider, { value: { variant: e, size: o, layout: a }, children: l })
24
+ ...i,
25
+ children: /* @__PURE__ */ s(m.Provider, { value: { variant: o, size: e, layout: a, activeColor: l, activeTextColor: d }, children: n })
26
26
  }
27
- ), h = v(({ className: d, children: e, variant: o, size: a, value: l, layout: r, ...i }, s) => {
28
- const t = b(n);
29
- return /* @__PURE__ */ u(
30
- p,
27
+ ), I = h(({ className: r, children: o, variant: e, size: a, value: l, layout: d, activeColor: n, activeTextColor: i, style: v, ...f }, y) => {
28
+ const t = A(m), g = t.variant ?? e, u = t.size ?? a, p = t.layout ?? d, x = n ?? t.activeColor, b = i ?? t.activeTextColor;
29
+ return /* @__PURE__ */ s(
30
+ C,
31
31
  {
32
- ref: s,
32
+ ref: y,
33
33
  "data-slot": "toggle-group-item",
34
34
  "data-testid": "spectral-toggle-group-item",
35
- "data-variant": t.variant || o,
36
- "data-size": t.size || a,
37
- "data-layout": t.layout || r,
35
+ "data-variant": g,
36
+ "data-size": u,
37
+ "data-layout": p,
38
38
  value: l,
39
- className: g(
40
- f({
41
- variant: t.variant || o,
42
- size: t.size || a,
43
- layout: t.layout || r
39
+ className: c(
40
+ G({
41
+ variant: g,
42
+ size: u,
43
+ layout: p
44
44
  }),
45
45
  "group data-[variant=outline]:border-togglegroup-border rounded-none shadow-none focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0",
46
- d
46
+ r
47
47
  ),
48
- ...i,
49
- children: e
48
+ style: { ...z(x, b), ...v },
49
+ ...f,
50
+ children: o
50
51
  }
51
52
  );
52
53
  });
54
+ I.displayName = "ToggleGroupItem";
53
55
  export {
54
- w as ToggleGroup,
55
- h as ToggleGroupItem
56
+ j as ToggleGroup,
57
+ I as ToggleGroupItem
56
58
  };