@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.
- package/dist/components/ui/ActionLink.d.ts +9 -3
- package/dist/components/ui/ActionLink.js +19 -7
- package/dist/components/ui/Button.js +28 -39
- package/dist/components/ui/buttonStyles.d.ts +5 -0
- package/dist/components/ui/buttonStyles.js +23 -0
- package/dist/core.css +1 -0
- package/dist/styles.css +1 -0
- package/package.json +1 -1
|
@@ -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
|
-
/**
|
|
9
|
-
|
|
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 {
|
|
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
|
|
5
|
-
let o = {
|
|
6
|
-
...
|
|
7
|
-
|
|
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
|
|
21
|
+
return c ? c(p) : /* @__PURE__ */ a("a", { ...p });
|
|
10
22
|
}
|
|
11
23
|
//#endregion
|
|
12
|
-
export {
|
|
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
|
|
5
|
-
import { Loader2 as
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
23
|
+
}, d = {
|
|
35
24
|
sm: "hidden sm:inline",
|
|
36
25
|
md: "hidden md:inline",
|
|
37
26
|
lg: "hidden lg:inline"
|
|
38
|
-
},
|
|
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
|
|
59
|
-
let
|
|
60
|
-
return /* @__PURE__ */
|
|
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:
|
|
63
|
-
"data-control-size":
|
|
64
|
-
"data-variant":
|
|
65
|
-
"data-size":
|
|
66
|
-
"data-pressed":
|
|
67
|
-
"data-hide-label":
|
|
68
|
-
disabled:
|
|
69
|
-
className: e((!
|
|
70
|
-
...
|
|
71
|
-
"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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
className:
|
|
77
|
-
children:
|
|
78
|
-
}) :
|
|
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 {
|
|
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(
|