@vllnt/ui 0.4.0-canary.sha1893a9d → 0.4.0-canary.sha227ddb3
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/CHANGELOG.md +14 -0
- package/README.md +28 -1
- package/dist/components/atoms/avatar/avatar.js +129 -24
- package/dist/components/atoms/breadcrumb/breadcrumb.js +89 -37
- package/dist/components/atoms/kbd/kbd.js +41 -11
- package/dist/components/atoms/progress-bar/progress-bar.js +161 -29
- package/dist/components/atoms/pull-quote/pull-quote.js +77 -0
- package/dist/components/atoms/scrim/scrim.js +32 -0
- package/dist/components/atoms/sheet/sheet.js +3 -2
- package/dist/components/atoms/tabs/tabs.js +34 -11
- package/dist/components/atoms/tag-group/tag-group.js +10 -5
- package/dist/components/atoms/tags-input/tags-input.js +1 -1
- package/dist/components/atoms/timeline/timeline.js +15 -3
- package/dist/components/index.js +38 -2
- package/dist/components/molecules/approval-request/approval-request.js +168 -0
- package/dist/components/molecules/cookie-consent/cookie-consent.js +188 -80
- package/dist/components/molecules/progress-tracker/progress-tracker.js +7 -16
- package/dist/components/organisms/access-matrix/access-matrix.js +271 -0
- package/dist/components/organisms/code-block/code-block.js +145 -81
- package/dist/components/organisms/cta-band/cta-band.js +79 -0
- package/dist/components/organisms/order-summary/order-summary.js +172 -0
- package/dist/components/organisms/settings-list/settings-list.js +125 -0
- package/dist/components/organisms/share-dialog-people/share-dialog-people.js +412 -0
- package/dist/index.d.ts +912 -61
- package/dist/tailwind-preset.js +16 -0
- package/package.json +4 -3
- package/styles.css +21 -2
- package/themes/default.css +21 -2
- package/themes/products.css +146 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Product themes stylesheet** - `@vllnt/ui/themes/products.css` ships the
|
|
12
|
+
Maia and PaaS themes as `html[data-theme="maia"]` and
|
|
13
|
+
`html[data-theme="paas"]`, each with a `.dark` block. It is generated from
|
|
14
|
+
`packages/design/tokens.json`. Load Figtree (Maia) and JetBrains Mono
|
|
15
|
+
(Maia, PaaS) in your app; the package does not ship the fonts.
|
|
16
|
+
- **Status and diff colors** - CSS variables `--success`, `--warning`,
|
|
17
|
+
`--info`, their `-foreground` pairs, `--diff-added` and `--diff-removed` in
|
|
18
|
+
`themes/default.css` and `styles.css`, and matching Tailwind colors
|
|
19
|
+
(`success`, `warning`, `info`, `diff.added`, `diff.removed`) in the preset.
|
|
20
|
+
- **Label type step** - `--font-size-label`, `--line-height-label` and
|
|
21
|
+
`--font-weight-label`.
|
|
22
|
+
|
|
9
23
|
## [0.4.0] - 2026-10-31
|
|
10
24
|
|
|
11
25
|
### Added
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vllnt/ui
|
|
2
2
|
|
|
3
|
-
React component library —
|
|
3
|
+
React component library — 321 components built on Radix UI primitives, Tailwind CSS, and CVA.
|
|
4
4
|
|
|
5
5
|
See [CHANGELOG.md](./CHANGELOG.md) for release history.
|
|
6
6
|
|
|
@@ -142,6 +142,7 @@ export function Example() {
|
|
|
142
142
|
| `@vllnt/ui/styles.css` | Full styles (Tailwind base + theme variables + utilities) |
|
|
143
143
|
| `@vllnt/ui/themes/default.css` | Theme CSS variables only (no Tailwind base) |
|
|
144
144
|
| `@vllnt/ui/themes/presets.css` | Built-in color presets (applied via `data-theme`) |
|
|
145
|
+
| `@vllnt/ui/themes/products.css` | Product themes `maia` and `paas` (generated; applied via `data-theme`) |
|
|
145
146
|
|
|
146
147
|
## Theming
|
|
147
148
|
|
|
@@ -191,6 +192,32 @@ at runtime with `<ThemeSwitcher />` (or `setThemePreset` / `useThemePreset`),
|
|
|
191
192
|
which set `data-theme` on the document root. Render `<ThemePresetProvider />`
|
|
192
193
|
once near the root to restore the saved preset before paint.
|
|
193
194
|
|
|
195
|
+
### Product themes
|
|
196
|
+
|
|
197
|
+
`@vllnt/ui/themes/products.css` adds two full product themes, generated from
|
|
198
|
+
`packages/design/tokens.json`. Import it after `styles.css`, set
|
|
199
|
+
`data-theme="maia"` or `data-theme="paas"` on `<html>`, and keep using the
|
|
200
|
+
`dark` class for dark mode:
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<html data-theme="maia" class="dark">
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- `maia`: pink primary, Figtree and JetBrains Mono, tighter type scale and radius.
|
|
207
|
+
Its Label step is capitals in the design: add `uppercase` where you use it.
|
|
208
|
+
- `paas`: core neutrals and status tones in JetBrains Mono. Dark is the design
|
|
209
|
+
default; light works too.
|
|
210
|
+
|
|
211
|
+
The package does not ship fonts. Core puts Inter (sans) and JetBrains Mono
|
|
212
|
+
(mono) first, then the system stacks. Load Inter, JetBrains Mono (core, Maia and
|
|
213
|
+
PaaS) and Figtree (Maia) in your app, for example with `next/font` or a font
|
|
214
|
+
`<link>`; without them each stack falls back to the system font stack
|
|
215
|
+
(`system-ui` for core sans and Maia, `ui-monospace` for core mono and PaaS).
|
|
216
|
+
|
|
217
|
+
Both define `success`, `warning`, `info`, `diff-added` and `diff-removed` roles
|
|
218
|
+
(the core theme defines them as well). Web `--radius` carries the theme's
|
|
219
|
+
`md` step only; the other radius steps ship in the `@vllnt/ui-core` outputs.
|
|
220
|
+
|
|
194
221
|
To design and export your own theme, use the visual editor at
|
|
195
222
|
[`/themes`](https://ui.vllnt.com/themes) — it exports a CSS block, a
|
|
196
223
|
`npx shadcn add` command, or design tokens.
|
|
@@ -1,51 +1,156 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, use } from "react";
|
|
3
4
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
4
6
|
import { cn } from "../../../lib/utils.js";
|
|
7
|
+
const avatarSizeVariants = cva("relative flex shrink-0", {
|
|
8
|
+
defaultVariants: {
|
|
9
|
+
size: "md"
|
|
10
|
+
},
|
|
11
|
+
variants: {
|
|
12
|
+
size: {
|
|
13
|
+
lg: "size-12 text-lg",
|
|
14
|
+
md: "size-10",
|
|
15
|
+
sm: "size-8 text-sm",
|
|
16
|
+
xl: "size-16 text-2xl",
|
|
17
|
+
xs: "size-6 text-xs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const avatarShapeVariants = cva("", {
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
shape: "circle"
|
|
24
|
+
},
|
|
25
|
+
variants: {
|
|
26
|
+
shape: {
|
|
27
|
+
circle: "rounded-full",
|
|
28
|
+
square: "rounded-md"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const avatarPresenceVariants = cva(
|
|
33
|
+
"absolute bottom-0 right-0 flex items-center justify-center rounded-full ring-2 ring-background",
|
|
34
|
+
{
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
size: "md"
|
|
37
|
+
},
|
|
38
|
+
variants: {
|
|
39
|
+
presence: {
|
|
40
|
+
away: "border-2 border-warning bg-background",
|
|
41
|
+
busy: "bg-destructive",
|
|
42
|
+
online: "bg-success"
|
|
43
|
+
},
|
|
44
|
+
size: {
|
|
45
|
+
lg: "size-3.5",
|
|
46
|
+
md: "size-3",
|
|
47
|
+
sm: "size-2.5",
|
|
48
|
+
xl: "size-4",
|
|
49
|
+
xs: "size-2"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
const DEFAULT_PRESENCE_LABELS = {
|
|
55
|
+
away: "Away",
|
|
56
|
+
busy: "Busy",
|
|
57
|
+
online: "Online"
|
|
58
|
+
};
|
|
59
|
+
const AvatarShapeContext = createContext("circle");
|
|
60
|
+
const AvatarPresenceMarker = ({
|
|
61
|
+
label,
|
|
62
|
+
presence,
|
|
63
|
+
size
|
|
64
|
+
}) => /* @__PURE__ */ jsxs(
|
|
65
|
+
"span",
|
|
66
|
+
{
|
|
67
|
+
className: avatarPresenceVariants({ presence, size }),
|
|
68
|
+
"data-presence": presence,
|
|
69
|
+
children: [
|
|
70
|
+
presence === "busy" ? /* @__PURE__ */ jsx(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
className: "h-0.5 w-1/2 rounded-full bg-background"
|
|
75
|
+
}
|
|
76
|
+
) : null,
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label })
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
5
81
|
const Avatar = ({
|
|
82
|
+
children,
|
|
6
83
|
className,
|
|
84
|
+
presence,
|
|
85
|
+
presenceLabels,
|
|
7
86
|
ref,
|
|
87
|
+
shape = "circle",
|
|
88
|
+
size = "md",
|
|
8
89
|
...props
|
|
9
|
-
}) => /* @__PURE__ */ jsx(
|
|
90
|
+
}) => /* @__PURE__ */ jsx(AvatarShapeContext, { value: shape, children: /* @__PURE__ */ jsxs(
|
|
10
91
|
AvatarPrimitive.Root,
|
|
11
92
|
{
|
|
12
93
|
className: cn(
|
|
13
|
-
|
|
94
|
+
avatarSizeVariants({ size }),
|
|
95
|
+
avatarShapeVariants({ shape }),
|
|
96
|
+
presence === void 0 && "overflow-hidden",
|
|
14
97
|
className
|
|
15
98
|
),
|
|
16
99
|
ref,
|
|
17
|
-
...props
|
|
100
|
+
...props,
|
|
101
|
+
children: [
|
|
102
|
+
children,
|
|
103
|
+
presence === void 0 ? null : /* @__PURE__ */ jsx(
|
|
104
|
+
AvatarPresenceMarker,
|
|
105
|
+
{
|
|
106
|
+
label: presenceLabels?.[presence] ?? DEFAULT_PRESENCE_LABELS[presence],
|
|
107
|
+
presence,
|
|
108
|
+
size
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
]
|
|
18
112
|
}
|
|
19
|
-
);
|
|
113
|
+
) });
|
|
20
114
|
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
21
115
|
const AvatarImage = ({
|
|
22
116
|
className,
|
|
23
117
|
ref,
|
|
24
118
|
...props
|
|
25
|
-
}) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
119
|
+
}) => {
|
|
120
|
+
const shape = use(AvatarShapeContext);
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
AvatarPrimitive.Image,
|
|
123
|
+
{
|
|
124
|
+
className: cn(
|
|
125
|
+
"aspect-square h-full w-full",
|
|
126
|
+
avatarShapeVariants({ shape }),
|
|
127
|
+
className
|
|
128
|
+
),
|
|
129
|
+
ref,
|
|
130
|
+
...props
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
};
|
|
33
134
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
34
135
|
const AvatarFallback = ({
|
|
35
136
|
className,
|
|
36
137
|
ref,
|
|
37
138
|
...props
|
|
38
|
-
}) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
className
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
139
|
+
}) => {
|
|
140
|
+
const shape = use(AvatarShapeContext);
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
AvatarPrimitive.Fallback,
|
|
143
|
+
{
|
|
144
|
+
className: cn(
|
|
145
|
+
"flex h-full w-full items-center justify-center bg-muted",
|
|
146
|
+
avatarShapeVariants({ shape }),
|
|
147
|
+
className
|
|
148
|
+
),
|
|
149
|
+
ref,
|
|
150
|
+
...props
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
};
|
|
49
154
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
50
155
|
export {
|
|
51
156
|
Avatar,
|
|
@@ -1,68 +1,120 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
2
3
|
import Link from "next/link";
|
|
3
4
|
import { cn } from "../../../lib/utils.js";
|
|
5
|
+
const DEFAULT_LABELS = {
|
|
6
|
+
more: "More",
|
|
7
|
+
region: "Breadcrumb"
|
|
8
|
+
};
|
|
9
|
+
const COLLAPSE_THRESHOLD = 3;
|
|
4
10
|
const SEPARATOR_CHARS = {
|
|
5
11
|
arrow: "\u2192",
|
|
6
12
|
chevron: "\u203A",
|
|
7
13
|
slash: "/"
|
|
8
14
|
};
|
|
15
|
+
const crumbVariants = cva("flex items-center gap-1", {
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
tone: "muted"
|
|
18
|
+
},
|
|
19
|
+
variants: {
|
|
20
|
+
tone: {
|
|
21
|
+
current: "font-medium text-foreground",
|
|
22
|
+
muted: "text-muted-foreground"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
9
26
|
function SeparatorIcon({ type }) {
|
|
10
27
|
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: SEPARATOR_CHARS[type] ?? "\u203A" });
|
|
11
28
|
}
|
|
12
|
-
function
|
|
29
|
+
function CrumbBody({ item }) {
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
item.icon ? /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: item.icon }) : null,
|
|
32
|
+
/* @__PURE__ */ jsx("span", { className: cn(typeof item.label === "string" && "truncate"), children: item.label })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
function Crumb({
|
|
36
|
+
isCurrent,
|
|
37
|
+
item,
|
|
38
|
+
linkComponent: LinkComponent,
|
|
39
|
+
variant
|
|
40
|
+
}) {
|
|
41
|
+
if (isCurrent) {
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
"aria-current": "page",
|
|
46
|
+
className: crumbVariants({
|
|
47
|
+
tone: variant === "default" ? "current" : "muted"
|
|
48
|
+
}),
|
|
49
|
+
children: /* @__PURE__ */ jsx(CrumbBody, { item })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (item.href) {
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
LinkComponent,
|
|
56
|
+
{
|
|
57
|
+
className: cn(
|
|
58
|
+
crumbVariants({ tone: "muted" }),
|
|
59
|
+
"transition-colors hover:text-foreground motion-reduce:transition-none"
|
|
60
|
+
),
|
|
61
|
+
href: item.href,
|
|
62
|
+
children: /* @__PURE__ */ jsx(CrumbBody, { item })
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ jsx("span", { className: crumbVariants({ tone: "muted" }), children: /* @__PURE__ */ jsx(CrumbBody, { item }) });
|
|
67
|
+
}
|
|
68
|
+
function getVisibleEntries(items, overflow) {
|
|
69
|
+
const entries = items.map((item, index) => ({ index, item }));
|
|
70
|
+
if (overflow === "collapsed" && entries.length > COLLAPSE_THRESHOLD) {
|
|
71
|
+
return [...entries.slice(0, 1), null, ...entries.slice(-2)];
|
|
72
|
+
}
|
|
73
|
+
return entries;
|
|
74
|
+
}
|
|
75
|
+
const Breadcrumb = ({
|
|
13
76
|
className,
|
|
14
77
|
items,
|
|
78
|
+
labels,
|
|
79
|
+
linkComponent = Link,
|
|
80
|
+
overflow = "none",
|
|
81
|
+
ref,
|
|
15
82
|
separator = "chevron",
|
|
16
83
|
variant = "default"
|
|
17
|
-
}) {
|
|
84
|
+
}) => {
|
|
85
|
+
const lastIndex = items.length - 1;
|
|
18
86
|
return /* @__PURE__ */ jsx(
|
|
19
87
|
"nav",
|
|
20
88
|
{
|
|
21
|
-
"aria-label":
|
|
89
|
+
"aria-label": labels?.region ?? DEFAULT_LABELS.region,
|
|
22
90
|
className: cn("flex items-center space-x-1 text-sm", className),
|
|
23
|
-
|
|
24
|
-
|
|
91
|
+
ref,
|
|
92
|
+
children: /* @__PURE__ */ jsx("ol", { className: "flex items-center space-x-1", children: getVisibleEntries(items, overflow).map((entry, position) => /* @__PURE__ */ jsxs(
|
|
93
|
+
"li",
|
|
25
94
|
{
|
|
26
95
|
className: "flex items-center",
|
|
27
96
|
children: [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
97
|
+
position > 0 && /* @__PURE__ */ jsx("span", { className: "mx-2", children: /* @__PURE__ */ jsx(SeparatorIcon, { type: separator }) }),
|
|
98
|
+
entry ? /* @__PURE__ */ jsx(
|
|
99
|
+
Crumb,
|
|
31
100
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
37
|
-
"span",
|
|
38
|
-
{
|
|
39
|
-
className: cn(
|
|
40
|
-
// Truncate plain string labels; custom React elements handle their own overflow
|
|
41
|
-
typeof item.label === "string" && "truncate",
|
|
42
|
-
variant === "minimal" ? "text-muted-foreground" : "text-foreground"
|
|
43
|
-
),
|
|
44
|
-
children: item.label
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
]
|
|
101
|
+
isCurrent: entry.index === lastIndex,
|
|
102
|
+
item: entry.item,
|
|
103
|
+
linkComponent,
|
|
104
|
+
variant
|
|
48
105
|
}
|
|
49
|
-
) : /* @__PURE__ */ jsxs("span", { className: "
|
|
50
|
-
|
|
51
|
-
/* @__PURE__ */ jsx(
|
|
52
|
-
"span",
|
|
53
|
-
{
|
|
54
|
-
className: cn(typeof item.label === "string" && "truncate"),
|
|
55
|
-
children: item.label
|
|
56
|
-
}
|
|
57
|
-
)
|
|
106
|
+
) : /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
107
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2026" }),
|
|
108
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: labels?.more ?? DEFAULT_LABELS.more })
|
|
58
109
|
] })
|
|
59
110
|
]
|
|
60
111
|
},
|
|
61
|
-
`${typeof item.label === "string" ? item.label : "breadcrumb"}-${index.toString()}`
|
|
62
|
-
))
|
|
112
|
+
entry ? `${typeof entry.item.label === "string" ? entry.item.label : "breadcrumb"}-${entry.index.toString()}` : "breadcrumb-more"
|
|
113
|
+
)) })
|
|
63
114
|
}
|
|
64
115
|
);
|
|
65
|
-
}
|
|
116
|
+
};
|
|
117
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
66
118
|
export {
|
|
67
119
|
Breadcrumb
|
|
68
120
|
};
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import {
|
|
4
4
|
useSyncExternalStore
|
|
5
5
|
} from "react";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
|
+
import { Command } from "lucide-react";
|
|
7
8
|
import { cn } from "../../../lib/utils.js";
|
|
8
9
|
const kbdVariants = cva(
|
|
9
|
-
"inline-flex select-none items-center justify-center
|
|
10
|
+
"inline-flex select-none items-center justify-center font-mono font-medium text-foreground [&>svg]:h-3 [&>svg]:w-3",
|
|
10
11
|
{
|
|
11
12
|
defaultVariants: {
|
|
12
|
-
size: "md"
|
|
13
|
+
size: "md",
|
|
14
|
+
variant: "default"
|
|
13
15
|
},
|
|
14
16
|
variants: {
|
|
15
17
|
size: {
|
|
16
18
|
lg: "h-7 min-w-[1.75rem] px-2 text-sm",
|
|
17
19
|
md: "h-5 min-w-[1.25rem] px-1.5 text-xs",
|
|
18
20
|
sm: "h-4 min-w-[1rem] px-1 text-[10px]"
|
|
21
|
+
},
|
|
22
|
+
variant: {
|
|
23
|
+
bracket: "gap-0.5",
|
|
24
|
+
default: "rounded border border-border bg-muted shadow-[0_1px_0_0_oklch(var(--border))]"
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
);
|
|
23
29
|
const MAC_PLATFORM_PATTERN = /mac|iphone|ipad|ipod/i;
|
|
30
|
+
const COMMAND_GLYPH = "\u2318";
|
|
31
|
+
const COMMAND_NAME = "Command";
|
|
24
32
|
const MODIFIER_LABELS = {
|
|
25
33
|
alt: { mac: "\u2325", other: "Alt" },
|
|
26
34
|
ctrl: { mac: "\u2303", other: "Ctrl" },
|
|
@@ -71,41 +79,63 @@ function formatToken(token, mac) {
|
|
|
71
79
|
if (special !== void 0) return special;
|
|
72
80
|
return token.length === 1 ? token.toUpperCase() : token;
|
|
73
81
|
}
|
|
82
|
+
function describeLabel(label) {
|
|
83
|
+
return label === COMMAND_GLYPH ? COMMAND_NAME : label;
|
|
84
|
+
}
|
|
85
|
+
function renderLabel(label) {
|
|
86
|
+
if (label !== COMMAND_GLYPH) return label;
|
|
87
|
+
return /* @__PURE__ */ jsx(Command, { "aria-label": COMMAND_NAME, role: "img" });
|
|
88
|
+
}
|
|
89
|
+
function withBrackets(content, variant) {
|
|
90
|
+
if (variant !== "bracket") return content;
|
|
91
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "[" }),
|
|
93
|
+
content,
|
|
94
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "]" })
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
74
97
|
const Kbd = ({
|
|
75
98
|
children,
|
|
76
99
|
className,
|
|
100
|
+
platform = "auto",
|
|
77
101
|
ref,
|
|
78
102
|
shortcut,
|
|
79
103
|
size,
|
|
104
|
+
variant,
|
|
80
105
|
...rest
|
|
81
106
|
}) => {
|
|
82
|
-
const
|
|
107
|
+
const detectedMac = useIsMac();
|
|
108
|
+
const isMac = platform === "auto" ? detectedMac : platform === "mac";
|
|
109
|
+
const keyClassName = cn(kbdVariants({ size, variant }), className);
|
|
83
110
|
if (children !== void 0) {
|
|
84
|
-
return /* @__PURE__ */ jsx("kbd", { className:
|
|
111
|
+
return /* @__PURE__ */ jsx("kbd", { className: keyClassName, ref, ...rest, children: withBrackets(children, variant) });
|
|
85
112
|
}
|
|
86
113
|
if (shortcut) {
|
|
87
114
|
const tokens = shortcut.split(SHORTCUT_SEPARATOR).map((token) => token.trim()).filter(Boolean);
|
|
88
|
-
const
|
|
115
|
+
const keys = tokens.map((token) => ({
|
|
116
|
+
label: formatToken(token, isMac),
|
|
117
|
+
token
|
|
118
|
+
}));
|
|
89
119
|
return /* @__PURE__ */ jsx(
|
|
90
120
|
"span",
|
|
91
121
|
{
|
|
92
|
-
"aria-label":
|
|
122
|
+
"aria-label": keys.map(({ label }) => describeLabel(label)).join(" + "),
|
|
93
123
|
className: "inline-flex items-center gap-1",
|
|
94
124
|
role: "img",
|
|
95
|
-
children:
|
|
125
|
+
children: keys.map(({ label, token }, index) => /* @__PURE__ */ jsx(
|
|
96
126
|
"kbd",
|
|
97
127
|
{
|
|
98
|
-
className:
|
|
128
|
+
className: keyClassName,
|
|
99
129
|
ref: index === 0 ? ref : void 0,
|
|
100
130
|
...index === 0 ? rest : {},
|
|
101
|
-
children:
|
|
131
|
+
children: withBrackets(renderLabel(label), variant)
|
|
102
132
|
},
|
|
103
133
|
`${token}-${index.toString()}`
|
|
104
134
|
))
|
|
105
135
|
}
|
|
106
136
|
);
|
|
107
137
|
}
|
|
108
|
-
return /* @__PURE__ */ jsx("kbd", { className:
|
|
138
|
+
return /* @__PURE__ */ jsx("kbd", { className: keyClassName, ref, ...rest });
|
|
109
139
|
};
|
|
110
140
|
Kbd.displayName = "Kbd";
|
|
111
141
|
export {
|