@brightlocal/ui-components 2.25.0 → 2.26.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/README.md +1 -1
- package/component-meta.json +239 -13
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +23 -9
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +95 -87
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +17 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +8 -1
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +6 -5
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +65 -91
- package/package.json +3 -6
- package/src/components/alert.tsx +68 -33
- package/src/components/data-table.tsx +25 -2
- package/src/components/link.tsx +57 -66
- package/dist/browser-entry.d.ts +0 -19
- package/dist/browser-entry.d.ts.map +0 -1
- package/src/browser-entry.ts +0 -99
- package/src/browser-tokens.css +0 -1
package/dist/link.js
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as s, jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import * as h from "react";
|
|
3
|
-
import { ExternalLink as
|
|
4
|
-
import { Slot as
|
|
5
|
-
import { cva as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"ease-out",
|
|
23
|
-
"focus-visible:shadow-default"
|
|
24
|
-
], L = y(
|
|
25
|
-
// `gap-2` (spacing/2) keeps the icon–text gap consistent across all variants.
|
|
26
|
-
["inline-flex", "items-center", "gap-2", "cursor-pointer", "outline-none"],
|
|
3
|
+
import { ExternalLink as b } from "@brightlocal/icons";
|
|
4
|
+
import { Slot as y, Slottable as S } from "@radix-ui/react-slot";
|
|
5
|
+
import { cva as L } from "class-variance-authority";
|
|
6
|
+
import { ButtonVariants as j } from "@brightlocal/ui-components/button";
|
|
7
|
+
import { cn as i } from "@brightlocal/ui-components/lib/utils";
|
|
8
|
+
const w = /* @__PURE__ */ new Set([
|
|
9
|
+
"aria-disabled:opacity-50",
|
|
10
|
+
"aria-invalid:ring-destructive/20",
|
|
11
|
+
"dark:aria-invalid:ring-destructive/40",
|
|
12
|
+
"aria-invalid:border-destructive",
|
|
13
|
+
"data-[state=open]:bg-accent"
|
|
14
|
+
]), e = (n) => i(
|
|
15
|
+
j({ variant: n, size: "default" }).split(/\s+/).filter((t) => t && !w.has(t)).join(" "),
|
|
16
|
+
"no-underline"
|
|
17
|
+
), V = L(
|
|
18
|
+
// No shared base: the button-styled variants carry the Button base classes,
|
|
19
|
+
// and a base here would be silently overridden by them in tailwind-merge
|
|
20
|
+
// (last wins). Each variant is self-contained.
|
|
21
|
+
"",
|
|
27
22
|
{
|
|
28
23
|
variants: {
|
|
29
24
|
variant: {
|
|
30
25
|
// Inline text link (default) — the original Link styling.
|
|
26
|
+
// `gap-2` (spacing/2) matches the Button icon–text gap.
|
|
31
27
|
inline: [
|
|
28
|
+
"inline-flex",
|
|
29
|
+
"items-center",
|
|
30
|
+
"gap-2",
|
|
31
|
+
"cursor-pointer",
|
|
32
|
+
"outline-none",
|
|
32
33
|
"rounded-sm",
|
|
33
34
|
// Color tokens (light mode: #2563EB, dark mode: #3B82F6)
|
|
34
35
|
"text-link",
|
|
@@ -47,86 +48,59 @@ const e = [
|
|
|
47
48
|
// Focus state
|
|
48
49
|
"focus-visible:shadow-default"
|
|
49
50
|
],
|
|
51
|
+
// Button-styled, brand CTA (matches Button `primary`).
|
|
52
|
+
primary: e("primary"),
|
|
50
53
|
// Button-styled, filled (maps to Button `secondary`).
|
|
51
|
-
filled:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// and keeps that border on focus (focus is the shared shadow ring only).
|
|
59
|
-
outline: [
|
|
60
|
-
...e,
|
|
61
|
-
"border",
|
|
62
|
-
"border-input",
|
|
63
|
-
"border-solid",
|
|
64
|
-
"bg-background",
|
|
65
|
-
"text-foreground",
|
|
66
|
-
"hover:bg-accent",
|
|
67
|
-
"hover:text-accent-foreground",
|
|
68
|
-
"dark:bg-input/30",
|
|
69
|
-
"dark:border-input",
|
|
70
|
-
"dark:hover:bg-input/50",
|
|
71
|
-
"dark:hover:border-input"
|
|
72
|
-
],
|
|
73
|
-
// Button-styled, transparent (maps to Button `ghost`).
|
|
74
|
-
ghost: [
|
|
75
|
-
...e,
|
|
76
|
-
"bg-transparent",
|
|
77
|
-
"text-foreground",
|
|
78
|
-
"hover:bg-accent"
|
|
79
|
-
],
|
|
54
|
+
filled: e("secondary"),
|
|
55
|
+
// Button-styled, bordered (matches Button `outline`). Button's outline
|
|
56
|
+
// declares no text color (buttons default sensibly; anchors inherit
|
|
57
|
+
// ambient/link colors), so links must pin `text-foreground` explicitly.
|
|
58
|
+
outline: i(e("outline"), "text-foreground"),
|
|
59
|
+
// Button-styled, transparent (matches Button `ghost`).
|
|
60
|
+
ghost: e("ghost"),
|
|
80
61
|
// Icon-only, circular. Mirrors `ghost` in a fixed 36px square
|
|
81
|
-
// footprint
|
|
82
|
-
// Requires an `aria-label` since there is no text content.
|
|
83
|
-
icon:
|
|
84
|
-
...e,
|
|
85
|
-
"w-9",
|
|
86
|
-
"px-0",
|
|
87
|
-
"bg-transparent",
|
|
88
|
-
"text-foreground",
|
|
89
|
-
"hover:bg-accent"
|
|
90
|
-
]
|
|
62
|
+
// footprint — the same `size-9 p-0` Button applies to icon-only
|
|
63
|
+
// buttons. Requires an `aria-label` since there is no text content.
|
|
64
|
+
icon: i(e("ghost"), "size-9 p-0")
|
|
91
65
|
}
|
|
92
66
|
},
|
|
93
67
|
defaultVariants: {
|
|
94
68
|
variant: "inline"
|
|
95
69
|
}
|
|
96
70
|
}
|
|
97
|
-
),
|
|
71
|
+
), z = h.forwardRef(
|
|
98
72
|
({
|
|
99
|
-
className:
|
|
73
|
+
className: n,
|
|
100
74
|
variant: t = "inline",
|
|
101
|
-
dataHook:
|
|
102
|
-
trackingEl:
|
|
103
|
-
trackingLabel:
|
|
104
|
-
asChild:
|
|
75
|
+
dataHook: c,
|
|
76
|
+
trackingEl: u,
|
|
77
|
+
trackingLabel: f,
|
|
78
|
+
asChild: k = !1,
|
|
105
79
|
external: r = !1,
|
|
106
|
-
showExternalIcon:
|
|
107
|
-
children:
|
|
108
|
-
...
|
|
109
|
-
},
|
|
110
|
-
const
|
|
111
|
-
ref:
|
|
112
|
-
className:
|
|
113
|
-
"data-hook":
|
|
80
|
+
showExternalIcon: m = !0,
|
|
81
|
+
children: a,
|
|
82
|
+
...p
|
|
83
|
+
}, v) => {
|
|
84
|
+
const x = r ? { target: "_blank", rel: "noopener noreferrer" } : {}, g = t === "inline" ? "link-default" : `link-${t}`, o = {
|
|
85
|
+
ref: v,
|
|
86
|
+
className: i(V({ variant: t }), n),
|
|
87
|
+
"data-hook": c,
|
|
114
88
|
"data-slot": "link",
|
|
115
|
-
"data-tracking-el":
|
|
116
|
-
"data-tracking-label":
|
|
117
|
-
...
|
|
118
|
-
...
|
|
119
|
-
},
|
|
120
|
-
return
|
|
121
|
-
/* @__PURE__ */ d(
|
|
122
|
-
|
|
123
|
-
] }) : /* @__PURE__ */
|
|
124
|
-
|
|
125
|
-
|
|
89
|
+
"data-tracking-el": u || g,
|
|
90
|
+
"data-tracking-label": f,
|
|
91
|
+
...x,
|
|
92
|
+
...p
|
|
93
|
+
}, l = r && m && /* @__PURE__ */ d(b, { "aria-hidden": "true", "data-slot": "external-icon" });
|
|
94
|
+
return k ? /* @__PURE__ */ s(y, { ...o, children: [
|
|
95
|
+
/* @__PURE__ */ d(S, { children: a }),
|
|
96
|
+
l
|
|
97
|
+
] }) : /* @__PURE__ */ s("a", { ...o, children: [
|
|
98
|
+
a,
|
|
99
|
+
l
|
|
126
100
|
] });
|
|
127
101
|
}
|
|
128
102
|
);
|
|
129
|
-
|
|
103
|
+
z.displayName = "Link";
|
|
130
104
|
export {
|
|
131
|
-
|
|
105
|
+
z as Link
|
|
132
106
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -192,8 +192,8 @@
|
|
|
192
192
|
"sonner": "^2.0.7",
|
|
193
193
|
"tailwind-merge": "^3.4.0",
|
|
194
194
|
"vaul": "^1.1.2",
|
|
195
|
-
"@brightlocal/
|
|
196
|
-
"@brightlocal/
|
|
195
|
+
"@brightlocal/icons": "2.3.1",
|
|
196
|
+
"@brightlocal/illustrations": "0.6.0"
|
|
197
197
|
},
|
|
198
198
|
"size-limit": [
|
|
199
199
|
{
|
|
@@ -218,7 +218,6 @@
|
|
|
218
218
|
"typecheck": "tsc --noEmit",
|
|
219
219
|
"clean": "rm -rf dist",
|
|
220
220
|
"build": "pnpm run clean && vite build",
|
|
221
|
-
"build:browser": "vite build --config vite.config.browser.ts && cp -R ../tokens/src/fonts dist-browser/fonts && node scripts/audit-browser-demos.mjs",
|
|
222
221
|
"size": "size-limit",
|
|
223
222
|
"analyze": "vite-bundle-visualizer",
|
|
224
223
|
"deprecations:list": "node scripts/deprecations-list.mjs",
|
|
@@ -229,8 +228,6 @@
|
|
|
229
228
|
"token-drift:check": "node scripts/token-drift.mjs --check",
|
|
230
229
|
"token-drift:update-baseline": "node scripts/token-drift.mjs --update-baseline",
|
|
231
230
|
"token-drift:report": "node scripts/token-report.mjs",
|
|
232
|
-
"audit-demos": "node scripts/audit-browser-demos.mjs",
|
|
233
|
-
"audit-demos:check": "node scripts/audit-browser-demos.mjs --check",
|
|
234
231
|
"build:changelog": "node scripts/generate-changelog.js",
|
|
235
232
|
"rel:patch": "node scripts/changeset-create.mjs patch",
|
|
236
233
|
"rel:minor": "node scripts/changeset-create.mjs minor",
|
package/src/components/alert.tsx
CHANGED
|
@@ -63,15 +63,7 @@ const AlertDescription = React.forwardRef<
|
|
|
63
63
|
));
|
|
64
64
|
AlertDescription.displayName = "AlertDescription";
|
|
65
65
|
|
|
66
|
-
interface
|
|
67
|
-
/**
|
|
68
|
-
* Optional title for the alert
|
|
69
|
-
*/
|
|
70
|
-
title?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Description text for the alert (REQUIRED)
|
|
73
|
-
*/
|
|
74
|
-
description: React.ReactNode;
|
|
66
|
+
interface AlertContentBaseProps {
|
|
75
67
|
/**
|
|
76
68
|
* Additional CSS classes
|
|
77
69
|
*/
|
|
@@ -94,6 +86,33 @@ interface AlertContentProps {
|
|
|
94
86
|
trackingLabel?: string;
|
|
95
87
|
}
|
|
96
88
|
|
|
89
|
+
/**
|
|
90
|
+
* At least one of `title` or `description` must be provided.
|
|
91
|
+
*/
|
|
92
|
+
type AlertContentProps = AlertContentBaseProps &
|
|
93
|
+
(
|
|
94
|
+
| {
|
|
95
|
+
/**
|
|
96
|
+
* Title for the alert
|
|
97
|
+
*/
|
|
98
|
+
title: string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional description text for the alert
|
|
101
|
+
*/
|
|
102
|
+
description?: React.ReactNode;
|
|
103
|
+
}
|
|
104
|
+
| {
|
|
105
|
+
/**
|
|
106
|
+
* Optional title for the alert
|
|
107
|
+
*/
|
|
108
|
+
title?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Description text for the alert
|
|
111
|
+
*/
|
|
112
|
+
description: React.ReactNode;
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
97
116
|
function AlertSuccess({
|
|
98
117
|
title,
|
|
99
118
|
description,
|
|
@@ -105,18 +124,22 @@ function AlertSuccess({
|
|
|
105
124
|
}: AlertContentProps) {
|
|
106
125
|
return (
|
|
107
126
|
<Alert
|
|
108
|
-
className={className}
|
|
127
|
+
className={cn("items-center", className)}
|
|
109
128
|
data-hook={dataHook}
|
|
110
129
|
data-tracking-el={trackingEl}
|
|
111
130
|
data-tracking-label={trackingLabel}
|
|
112
131
|
variant="success"
|
|
113
132
|
>
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
<div className="flex min-w-0 flex-1 items-start gap-3">
|
|
134
|
+
<CircleCheck className="text-success-foreground shrink-0 translate-y-0.5" />
|
|
135
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
136
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
137
|
+
{description != null && (
|
|
138
|
+
<AlertDescription>{description}</AlertDescription>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
118
141
|
</div>
|
|
119
|
-
{action && <div className="self-center">{action}</div>}
|
|
142
|
+
{action && <div className="shrink-0 self-center">{action}</div>}
|
|
120
143
|
</Alert>
|
|
121
144
|
);
|
|
122
145
|
}
|
|
@@ -132,18 +155,22 @@ function AlertInfo({
|
|
|
132
155
|
}: AlertContentProps) {
|
|
133
156
|
return (
|
|
134
157
|
<Alert
|
|
135
|
-
className={className}
|
|
158
|
+
className={cn("items-center", className)}
|
|
136
159
|
data-hook={dataHook}
|
|
137
160
|
data-tracking-el={trackingEl}
|
|
138
161
|
data-tracking-label={trackingLabel}
|
|
139
162
|
variant="info"
|
|
140
163
|
>
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
164
|
+
<div className="flex min-w-0 flex-1 items-start gap-3">
|
|
165
|
+
<Info className="text-info-foreground shrink-0 translate-y-0.5" />
|
|
166
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
167
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
168
|
+
{description != null && (
|
|
169
|
+
<AlertDescription>{description}</AlertDescription>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
145
172
|
</div>
|
|
146
|
-
{action && <div className="self-center">{action}</div>}
|
|
173
|
+
{action && <div className="shrink-0 self-center">{action}</div>}
|
|
147
174
|
</Alert>
|
|
148
175
|
);
|
|
149
176
|
}
|
|
@@ -159,18 +186,22 @@ function AlertDestructive({
|
|
|
159
186
|
}: AlertContentProps) {
|
|
160
187
|
return (
|
|
161
188
|
<Alert
|
|
162
|
-
className={className}
|
|
189
|
+
className={cn("items-center", className)}
|
|
163
190
|
data-hook={dataHook}
|
|
164
191
|
data-tracking-el={trackingEl}
|
|
165
192
|
data-tracking-label={trackingLabel}
|
|
166
193
|
variant="destructive"
|
|
167
194
|
>
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
195
|
+
<div className="flex min-w-0 flex-1 items-start gap-3">
|
|
196
|
+
<CircleX className="text-destructive-foreground shrink-0 translate-y-0.5" />
|
|
197
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
198
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
199
|
+
{description != null && (
|
|
200
|
+
<AlertDescription>{description}</AlertDescription>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
172
203
|
</div>
|
|
173
|
-
{action && <div className="self-center">{action}</div>}
|
|
204
|
+
{action && <div className="shrink-0 self-center">{action}</div>}
|
|
174
205
|
</Alert>
|
|
175
206
|
);
|
|
176
207
|
}
|
|
@@ -186,18 +217,22 @@ function AlertWarning({
|
|
|
186
217
|
}: AlertContentProps) {
|
|
187
218
|
return (
|
|
188
219
|
<Alert
|
|
189
|
-
className={className}
|
|
220
|
+
className={cn("items-center", className)}
|
|
190
221
|
data-hook={dataHook}
|
|
191
222
|
data-tracking-el={trackingEl}
|
|
192
223
|
data-tracking-label={trackingLabel}
|
|
193
224
|
variant="warning"
|
|
194
225
|
>
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
226
|
+
<div className="flex min-w-0 flex-1 items-start gap-3">
|
|
227
|
+
<TriangleAlert className="text-warning-foreground shrink-0 translate-y-0.5" />
|
|
228
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
229
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
230
|
+
{description != null && (
|
|
231
|
+
<AlertDescription>{description}</AlertDescription>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
199
234
|
</div>
|
|
200
|
-
{action && <div className="self-center">{action}</div>}
|
|
235
|
+
{action && <div className="shrink-0 self-center">{action}</div>}
|
|
201
236
|
</Alert>
|
|
202
237
|
);
|
|
203
238
|
}
|
|
@@ -162,7 +162,16 @@ export interface UseDataTableOptions<TData> {
|
|
|
162
162
|
|
|
163
163
|
// ---------- Common features ----------
|
|
164
164
|
|
|
165
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Enable column sorting. Set to `false` to disable sorting for every
|
|
167
|
+
* column — `column.getCanSort()` returns `false`, so
|
|
168
|
+
* `DataTableColumnHeader` renders plain titles with no sort buttons and
|
|
169
|
+
* no `aria-sort`. TanStack ANDs this flag with each column def's own
|
|
170
|
+
* `enableSorting`: per-column `false` opts a column out under the
|
|
171
|
+
* default, but per-column `true` cannot re-enable sorting when this
|
|
172
|
+
* table-level flag is `false`.
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
166
175
|
enableSorting?: boolean;
|
|
167
176
|
/** Enable global text search across rows (substring match). @default false */
|
|
168
177
|
enableGlobalFiltering?: boolean;
|
|
@@ -247,6 +256,13 @@ export interface UseDataTableOptions<TData> {
|
|
|
247
256
|
* consumers to pass into `DataTable`, `DataTablePagination`,
|
|
248
257
|
* `DataTableSearch`, etc.
|
|
249
258
|
*
|
|
259
|
+
* Sorting is resolved per column: TanStack ANDs the table-level
|
|
260
|
+
* `enableSorting` flag (default `true`) with each column def's own
|
|
261
|
+
* `enableSorting`. Three cases — all columns sortable (default, configure
|
|
262
|
+
* nothing), whole table unsortable (`enableSorting: false` on the hook), or
|
|
263
|
+
* mixed (keep the table-level default and set `enableSorting: false` on the
|
|
264
|
+
* individual column defs that must not sort).
|
|
265
|
+
*
|
|
250
266
|
* @example
|
|
251
267
|
* const table = useDataTable({
|
|
252
268
|
* columns,
|
|
@@ -334,6 +350,10 @@ export function useDataTable<TData>(
|
|
|
334
350
|
...(pageCount != null && { pageCount }),
|
|
335
351
|
}),
|
|
336
352
|
|
|
353
|
+
// Always forward the flag — TanStack defaults `enableSorting` to true,
|
|
354
|
+
// so omitting it would leave `column.getCanSort()` returning true even
|
|
355
|
+
// when the consumer disabled sorting table-wide.
|
|
356
|
+
enableSorting,
|
|
337
357
|
...(enableSorting && {
|
|
338
358
|
...(!manualSorting && {
|
|
339
359
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -351,8 +371,11 @@ export function useDataTable<TData>(
|
|
|
351
371
|
globalFilterFn: "includesString",
|
|
352
372
|
}),
|
|
353
373
|
|
|
374
|
+
// Always forward — TanStack defaults `enableRowSelection` to true, so
|
|
375
|
+
// omitting it would leave `row.getCanSelect()` returning true and
|
|
376
|
+
// `DataTableSelectRowCheckbox` enabled on tables without selection.
|
|
377
|
+
enableRowSelection,
|
|
354
378
|
...(enableRowSelection && {
|
|
355
|
-
enableRowSelection: true,
|
|
356
379
|
onRowSelectionChange: setRowSelectionState,
|
|
357
380
|
}),
|
|
358
381
|
|
package/src/components/link.tsx
CHANGED
|
@@ -3,38 +3,55 @@ import { ExternalLink } from "@brightlocal/icons";
|
|
|
3
3
|
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
ButtonVariants,
|
|
8
|
+
type ButtonVariant,
|
|
9
|
+
} from "@brightlocal/ui-components/button";
|
|
6
10
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
11
|
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
// Button state classes that must NOT apply to links. Unlike `:disabled`
|
|
13
|
+
// (inert on anchors), these selectors DO match anchors and would introduce
|
|
14
|
+
// styling hooks Link never had: `aria-disabled` dimming (a link would look
|
|
15
|
+
// disabled while staying clickable), `aria-invalid` destructive rings, and
|
|
16
|
+
// the persistent open-trigger highlight when a ghost/icon link is used as a
|
|
17
|
+
// Radix overlay trigger via asChild.
|
|
18
|
+
const buttonOnlyStateClasses = new Set([
|
|
19
|
+
"aria-disabled:opacity-50",
|
|
20
|
+
"aria-invalid:ring-destructive/20",
|
|
21
|
+
"dark:aria-invalid:ring-destructive/40",
|
|
22
|
+
"aria-invalid:border-destructive",
|
|
23
|
+
"data-[state=open]:bg-accent",
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
// Button-styled variants delegate to the Button component's own CVA so the
|
|
27
|
+
// treatments stay visually identical across both components and never drift.
|
|
28
|
+
// Anchors carry a browser-default underline that buttons never have, hence
|
|
29
|
+
// the `no-underline`.
|
|
30
|
+
const buttonStyledLink = (variant: ButtonVariant) =>
|
|
31
|
+
cn(
|
|
32
|
+
ButtonVariants({ variant, size: "default" })
|
|
33
|
+
.split(/\s+/)
|
|
34
|
+
.filter((cls) => cls && !buttonOnlyStateClasses.has(cls))
|
|
35
|
+
.join(" "),
|
|
36
|
+
"no-underline"
|
|
37
|
+
);
|
|
29
38
|
|
|
30
39
|
const linkVariants = cva(
|
|
31
|
-
//
|
|
32
|
-
|
|
40
|
+
// No shared base: the button-styled variants carry the Button base classes,
|
|
41
|
+
// and a base here would be silently overridden by them in tailwind-merge
|
|
42
|
+
// (last wins). Each variant is self-contained.
|
|
43
|
+
"",
|
|
33
44
|
{
|
|
34
45
|
variants: {
|
|
35
46
|
variant: {
|
|
36
47
|
// Inline text link (default) — the original Link styling.
|
|
48
|
+
// `gap-2` (spacing/2) matches the Button icon–text gap.
|
|
37
49
|
inline: [
|
|
50
|
+
"inline-flex",
|
|
51
|
+
"items-center",
|
|
52
|
+
"gap-2",
|
|
53
|
+
"cursor-pointer",
|
|
54
|
+
"outline-none",
|
|
38
55
|
"rounded-sm",
|
|
39
56
|
// Color tokens (light mode: #2563EB, dark mode: #3B82F6)
|
|
40
57
|
"text-link",
|
|
@@ -53,47 +70,20 @@ const linkVariants = cva(
|
|
|
53
70
|
// Focus state
|
|
54
71
|
"focus-visible:shadow-default",
|
|
55
72
|
],
|
|
73
|
+
// Button-styled, brand CTA (matches Button `primary`).
|
|
74
|
+
primary: buttonStyledLink("primary"),
|
|
56
75
|
// Button-styled, filled (maps to Button `secondary`).
|
|
57
|
-
filled:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// and keeps that border on focus (focus is the shared shadow ring only).
|
|
65
|
-
outline: [
|
|
66
|
-
...buttonStyledBase,
|
|
67
|
-
"border",
|
|
68
|
-
"border-input",
|
|
69
|
-
"border-solid",
|
|
70
|
-
"bg-background",
|
|
71
|
-
"text-foreground",
|
|
72
|
-
"hover:bg-accent",
|
|
73
|
-
"hover:text-accent-foreground",
|
|
74
|
-
"dark:bg-input/30",
|
|
75
|
-
"dark:border-input",
|
|
76
|
-
"dark:hover:bg-input/50",
|
|
77
|
-
"dark:hover:border-input",
|
|
78
|
-
],
|
|
79
|
-
// Button-styled, transparent (maps to Button `ghost`).
|
|
80
|
-
ghost: [
|
|
81
|
-
...buttonStyledBase,
|
|
82
|
-
"bg-transparent",
|
|
83
|
-
"text-foreground",
|
|
84
|
-
"hover:bg-accent",
|
|
85
|
-
],
|
|
76
|
+
filled: buttonStyledLink("secondary"),
|
|
77
|
+
// Button-styled, bordered (matches Button `outline`). Button's outline
|
|
78
|
+
// declares no text color (buttons default sensibly; anchors inherit
|
|
79
|
+
// ambient/link colors), so links must pin `text-foreground` explicitly.
|
|
80
|
+
outline: cn(buttonStyledLink("outline"), "text-foreground"),
|
|
81
|
+
// Button-styled, transparent (matches Button `ghost`).
|
|
82
|
+
ghost: buttonStyledLink("ghost"),
|
|
86
83
|
// Icon-only, circular. Mirrors `ghost` in a fixed 36px square
|
|
87
|
-
// footprint
|
|
88
|
-
// Requires an `aria-label` since there is no text content.
|
|
89
|
-
icon:
|
|
90
|
-
...buttonStyledBase,
|
|
91
|
-
"w-9",
|
|
92
|
-
"px-0",
|
|
93
|
-
"bg-transparent",
|
|
94
|
-
"text-foreground",
|
|
95
|
-
"hover:bg-accent",
|
|
96
|
-
],
|
|
84
|
+
// footprint — the same `size-9 p-0` Button applies to icon-only
|
|
85
|
+
// buttons. Requires an `aria-label` since there is no text content.
|
|
86
|
+
icon: cn(buttonStyledLink("ghost"), "size-9 p-0"),
|
|
97
87
|
},
|
|
98
88
|
},
|
|
99
89
|
defaultVariants: {
|
|
@@ -113,10 +103,11 @@ export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
|
113
103
|
*/
|
|
114
104
|
dataHook: string;
|
|
115
105
|
/**
|
|
116
|
-
* Visual style variant. `inline` renders a standard text link; `
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
106
|
+
* Visual style variant. `inline` renders a standard text link; `primary`
|
|
107
|
+
* renders the brand CTA treatment (matches `Button variant="primary"`);
|
|
108
|
+
* `filled`, `outline` and `ghost` render button-styled treatments for
|
|
109
|
+
* inline actions and high-priority navigation; `icon` renders a circular
|
|
110
|
+
* icon-only link (provide an `aria-label` since there is no text content).
|
|
120
111
|
* @default "inline"
|
|
121
112
|
*/
|
|
122
113
|
variant?: LinkVariant;
|
package/dist/browser-entry.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as ReactDOM from "react-dom";
|
|
3
|
-
export * from './index';
|
|
4
|
-
export { React, ReactDOM };
|
|
5
|
-
export declare const h: typeof React.createElement;
|
|
6
|
-
export declare const useState: typeof React.useState;
|
|
7
|
-
export declare const useEffect: typeof React.useEffect;
|
|
8
|
-
export declare const useMemo: typeof React.useMemo;
|
|
9
|
-
export declare const useCallback: typeof React.useCallback;
|
|
10
|
-
export declare const useRef: typeof React.useRef;
|
|
11
|
-
export declare const useContext: typeof React.useContext;
|
|
12
|
-
export declare const useReducer: typeof React.useReducer;
|
|
13
|
-
export declare const useLayoutEffect: typeof React.useLayoutEffect;
|
|
14
|
-
export declare const Fragment: React.ExoticComponent<React.FragmentProps>;
|
|
15
|
-
export declare const version: string;
|
|
16
|
-
export declare const buildTime: string;
|
|
17
|
-
export declare function mount(name: string, container: HTMLElement, props?: Record<string, unknown>): () => void;
|
|
18
|
-
export declare function render(element: React.ReactNode, container: HTMLElement): () => void;
|
|
19
|
-
//# sourceMappingURL=browser-entry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-entry.d.ts","sourceRoot":"","sources":["../src/browser-entry.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAKtC,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAE3B,eAAO,MAAM,CAAC,4BAAsB,CAAC;AACrC,eAAO,MAAM,QAAQ,uBAAiB,CAAC;AACvC,eAAO,MAAM,SAAS,wBAAkB,CAAC;AACzC,eAAO,MAAM,OAAO,sBAAgB,CAAC;AACrC,eAAO,MAAM,WAAW,0BAAoB,CAAC;AAC7C,eAAO,MAAM,MAAM,qBAAe,CAAC;AACnC,eAAO,MAAM,UAAU,yBAAmB,CAAC;AAC3C,eAAO,MAAM,UAAU,yBAAmB,CAAC;AAC3C,eAAO,MAAM,eAAe,8BAAwB,CAAC;AACrD,eAAO,MAAM,QAAQ,4CAAiB,CAAC;AAOvC,eAAO,MAAM,OAAO,QAC+C,CAAC;AACpE,eAAO,MAAM,SAAS,QAC0C,CAAC;AAmBjE,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,WAAW,EACtB,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,MAAM,IAAI,CA0BZ;AAED,wBAAgB,MAAM,CACpB,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,SAAS,EAAE,WAAW,GACrB,MAAM,IAAI,CAaZ"}
|