@leonardaustin/ui 0.32.0 → 0.33.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.
@@ -1,14 +1,20 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ import { type ControlSize } from "../../providers/ControlSizeContext";
2
3
  type AnchorProps = ComponentPropsWithRef<"a"> & {
3
4
  href: string;
4
5
  };
5
6
  export interface ActionLinkProps extends AnchorProps {
6
7
  /** Destination for native navigation, including opening in a new tab. */
7
8
  href: string;
8
- /** Inline text link or bordered secondary action. */
9
- appearance?: "inline" | "secondary";
9
+ /**
10
+ * Inline text link, bordered secondary action or accent primary action.
11
+ * `secondary` and `primary` match Button and follow the control size.
12
+ */
13
+ appearance?: "inline" | "secondary" | "primary";
14
+ /** Inherit ControlSizeProvider or opt into a minimum 44px hit area. */
15
+ controlSize?: ControlSize;
10
16
  /** Render a router anchor, forwarding the supplied attributes, children and ref. */
11
17
  renderLink?: (props: AnchorProps) => ReactNode;
12
18
  }
13
- export declare function ActionLink({ appearance, renderLink, className, ...props }: ActionLinkProps): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
19
+ export declare function ActionLink({ appearance, controlSize, renderLink, className, ...props }: ActionLinkProps): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
14
20
  export {};
@@ -1,12 +1,24 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
- import { jsx as t } from "react/jsx-runtime";
2
+ import { useControlSize as t } from "../../providers/ControlSizeContext.js";
3
+ import { buttonBaseStyles as n, sizeStyles as r, variantStyles as i } from "./buttonStyles.js";
4
+ import { jsx as a } from "react/jsx-runtime";
3
5
  //#region src/components/ui/ActionLink.tsx
4
- function n({ appearance: n = "inline", renderLink: r, className: i, ...a }) {
5
- let o = {
6
- ...a,
7
- className: e("focus-visible:outline-accent focus-visible:outline-2 focus-visible:outline-offset-2", n === "secondary" ? "bg-bg-secondary text-text-primary border-border hover:bg-bg-hover inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors duration-[100ms]" : "text-accent-fg underline underline-offset-2", i)
6
+ function o({ appearance: o = "inline", controlSize: s, renderLink: c, className: l, ...u }) {
7
+ let d = t(s), f = o !== "inline", p = {
8
+ ...u,
9
+ ...f && {
10
+ "data-control-size": d,
11
+ "data-variant": o,
12
+ "data-size": "md"
13
+ },
14
+ className: e(f ? [
15
+ "ui-sized-control",
16
+ n,
17
+ i[o],
18
+ r.md
19
+ ] : ["focus-visible:outline-accent focus-visible:outline-2 focus-visible:outline-offset-2", "text-accent-fg underline underline-offset-2"], l)
8
20
  };
9
- return r ? r(o) : /* @__PURE__ */ t("a", { ...o });
21
+ return c ? c(p) : /* @__PURE__ */ a("a", { ...p });
10
22
  }
11
23
  //#endregion
12
- export { n as ActionLink };
24
+ export { o as ActionLink };
@@ -1,41 +1,30 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
2
  import { useControlSize as t } from "../../providers/ControlSizeContext.js";
3
+ import { buttonBaseStyles as n, sizeStyles as r, variantStyles as i } from "./buttonStyles.js";
3
4
  import "react";
4
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
- import { Loader2 as i } from "lucide-react";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ import { Loader2 as s } from "lucide-react";
6
7
  //#region src/components/ui/Button.tsx
7
- var a = {
8
- primary: "bg-accent text-text-on-accent hover:bg-accent-hover active:bg-accent-active",
9
- secondary: "bg-bg-secondary text-text-primary border border-border hover:bg-bg-hover hover:border-border-strong",
10
- danger: "bg-danger-muted text-danger-fg border border-transparent hover:bg-danger/20",
11
- ghost: "text-text-secondary hover:text-text-primary hover:bg-bg-hover",
12
- icon: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover",
13
- link: "text-accent-fg hover:underline underline-offset-2"
14
- }, o = {
15
- xs: "h-6 px-2 text-2xs gap-1",
16
- sm: "h-7 px-2.5 text-xs gap-1.5",
17
- md: "h-8 px-3 text-xs gap-2",
18
- lg: "h-9 px-4 text-sm gap-2"
19
- }, s = {
8
+ var c = {
20
9
  xs: "h-6 w-6",
21
10
  sm: "h-7 w-7",
22
11
  md: "h-8 w-8",
23
12
  lg: "h-9 w-9"
24
- }, c = {
13
+ }, l = {
25
14
  xs: "text-2xs gap-1",
26
15
  sm: "text-xs gap-1.5",
27
16
  md: "text-xs gap-2",
28
17
  lg: "text-sm gap-2"
29
- }, l = {
18
+ }, u = {
30
19
  xs: "h-3 w-3",
31
20
  sm: "h-3.5 w-3.5",
32
21
  md: "h-3.5 w-3.5",
33
22
  lg: "h-4 w-4"
34
- }, u = {
23
+ }, d = {
35
24
  sm: "hidden sm:inline",
36
25
  md: "hidden md:inline",
37
26
  lg: "hidden lg:inline"
38
- }, d = {
27
+ }, f = {
39
28
  sm: {
40
29
  xs: "px-1 sm:px-2",
41
30
  sm: "px-1.5 sm:px-2.5",
@@ -55,29 +44,29 @@ var a = {
55
44
  lg: "px-2.5 lg:px-4"
56
45
  }
57
46
  };
58
- function f({ variant: f = "secondary", size: p = "md", controlSize: m, loading: h, pressed: g, icon: _, hideLabel: v, className: y, children: b, disabled: x, ref: S, ...C }) {
59
- let w = t(m), T = f === "icon", E = f === "link", D = g ?? (C["aria-pressed"] === !0 || C["aria-pressed"] === "true"), O = v === !0 ? "sm" : v === !1 ? void 0 : v;
60
- return /* @__PURE__ */ r("button", {
47
+ function p({ variant: p = "secondary", size: m = "md", controlSize: h, loading: g, pressed: _, icon: v, hideLabel: y, className: b, children: x, disabled: S, ref: C, ...w }) {
48
+ let T = t(h), E = p === "icon", D = p === "link", O = _ ?? (w["aria-pressed"] === !0 || w["aria-pressed"] === "true"), k = y === !0 ? "sm" : y === !1 ? void 0 : y;
49
+ return /* @__PURE__ */ o("button", {
61
50
  type: "button",
62
- ref: S,
63
- "data-control-size": w,
64
- "data-variant": f,
65
- "data-size": p,
66
- "data-pressed": g !== void 0 || C["aria-pressed"] !== void 0 ? String(D) : void 0,
67
- "data-hide-label": O && !T ? "" : void 0,
68
- disabled: x || h,
69
- className: e((!E || w === "comfortable") && "ui-sized-control", "inline-flex items-center justify-center rounded-md font-medium", "font-control", "transition-colors duration-[100ms] ease-out", "cursor-pointer", "disabled:cursor-not-allowed disabled:opacity-40", "focus-visible:outline-accent focus-visible:outline-2 focus-visible:outline-offset-2", a[f], D && (f === "secondary" || f === "ghost" || T) && "text-text-primary", T ? s[p] : E ? c[p] : o[p], O && !T && !E && d[O]?.[p], y),
70
- ...C,
71
- "aria-pressed": g ?? C["aria-pressed"],
51
+ ref: C,
52
+ "data-control-size": T,
53
+ "data-variant": p,
54
+ "data-size": m,
55
+ "data-pressed": _ !== void 0 || w["aria-pressed"] !== void 0 ? String(O) : void 0,
56
+ "data-hide-label": k && !E ? "" : void 0,
57
+ disabled: S || g,
58
+ className: e((!D || T === "comfortable") && "ui-sized-control", n, i[p], O && (p === "secondary" || p === "ghost" || E) && "text-text-primary", E ? c[m] : D ? l[m] : r[m], k && !E && !D && f[k]?.[m], b),
59
+ ...w,
60
+ "aria-pressed": _ ?? w["aria-pressed"],
72
61
  children: [
73
- h && /* @__PURE__ */ n(i, { className: "h-3.5 w-3.5 animate-spin" }),
74
- _ && !h && /* @__PURE__ */ n(_, { className: l[p] }),
75
- b && (O ? /* @__PURE__ */ n("span", {
76
- className: u[O],
77
- children: b
78
- }) : b)
62
+ g && /* @__PURE__ */ a(s, { className: "h-3.5 w-3.5 animate-spin" }),
63
+ v && !g && /* @__PURE__ */ a(v, { className: u[m] }),
64
+ x && (k ? /* @__PURE__ */ a("span", {
65
+ className: d[k],
66
+ children: x
67
+ }) : x)
79
68
  ]
80
69
  });
81
70
  }
82
71
  //#endregion
83
- export { f as Button };
72
+ export { p as Button };
@@ -0,0 +1,5 @@
1
+ import type { ButtonSize, ButtonVariant } from "./Button";
2
+ /** Shared Button class tokens, reused by ActionLink so the two cannot drift. */
3
+ export declare const buttonBaseStyles: string;
4
+ export declare const variantStyles: Record<ButtonVariant, string>;
5
+ export declare const sizeStyles: Record<ButtonSize, string>;
@@ -0,0 +1,23 @@
1
+ //#region src/components/ui/buttonStyles.ts
2
+ var e = [
3
+ "inline-flex items-center justify-center rounded-md font-medium",
4
+ "font-control",
5
+ "transition-colors duration-[100ms] ease-out",
6
+ "cursor-pointer",
7
+ "disabled:cursor-not-allowed disabled:opacity-40",
8
+ "focus-visible:outline-accent focus-visible:outline-2 focus-visible:outline-offset-2"
9
+ ].join(" "), t = {
10
+ primary: "bg-accent text-text-on-accent hover:bg-accent-hover active:bg-accent-active",
11
+ secondary: "bg-bg-secondary text-text-primary border border-border hover:bg-bg-hover hover:border-border-strong",
12
+ danger: "bg-danger-muted text-danger-fg border border-transparent hover:bg-danger/20",
13
+ ghost: "text-text-secondary hover:text-text-primary hover:bg-bg-hover",
14
+ icon: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover",
15
+ link: "text-accent-fg hover:underline underline-offset-2"
16
+ }, n = {
17
+ xs: "h-6 px-2 text-2xs gap-1",
18
+ sm: "h-7 px-2.5 text-xs gap-1.5",
19
+ md: "h-8 px-3 text-xs gap-2",
20
+ lg: "h-9 px-4 text-sm gap-2"
21
+ };
22
+ //#endregion
23
+ export { e as buttonBaseStyles, n as sizeStyles, t as variantStyles };
package/dist/core.css CHANGED
@@ -2163,6 +2163,7 @@ select:disabled + .ui-select-placeholder {
2163
2163
  }
2164
2164
  :is(
2165
2165
  button.ui-sized-control[data-variant],
2166
+ a.ui-sized-control[data-variant],
2166
2167
  input.ui-sized-control:not(.ui-password-input),
2167
2168
  textarea.ui-sized-control
2168
2169
  )[data-control-size="compact"]:not([data-variant="icon"]):not(
package/dist/styles.css CHANGED
@@ -2983,6 +2983,7 @@ select:disabled + .ui-select-placeholder {
2983
2983
  }
2984
2984
  :is(
2985
2985
  button.ui-sized-control[data-variant],
2986
+ a.ui-sized-control[data-variant],
2986
2987
  input.ui-sized-control:not(.ui-password-input),
2987
2988
  textarea.ui-sized-control
2988
2989
  )[data-control-size="compact"]:not([data-variant="icon"]):not(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonardaustin/ui",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "Reusable React component library and application shell for Leonard Austin projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",