@vendure-io/ui 2.0.0-beta.8 → 2.0.0-rc.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/LICENSE.md +34 -0
- package/package.json +8 -6
- package/src/components/atoms/alert-dialog.tsx +1 -1
- package/src/components/atoms/alert.tsx +1 -1
- package/src/components/atoms/badge.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/card.tsx +39 -4
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +24 -5
- package/src/components/atoms/command.tsx +16 -5
- package/src/components/atoms/context-menu.tsx +1 -1
- package/src/components/atoms/dialog.tsx +1 -1
- package/src/components/atoms/drawer.tsx +134 -35
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/field.tsx +2 -2
- package/src/components/atoms/input.tsx +1 -1
- package/src/components/atoms/item.tsx +4 -1
- package/src/components/atoms/menubar.tsx +1 -1
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +8 -2
- package/src/components/atoms/progress.tsx +1 -1
- package/src/components/atoms/radio-group.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +1 -2
- package/src/components/atoms/select.tsx +1 -1
- package/src/components/atoms/sheet.tsx +1 -1
- package/src/components/atoms/sidebar.tsx +6 -4
- package/src/components/atoms/slider.tsx +2 -2
- package/src/components/atoms/switch.tsx +1 -1
- package/src/components/atoms/table.tsx +34 -2
- package/src/components/atoms/tabs.tsx +64 -1
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle-group.tsx +1 -1
- package/src/components/atoms/toggle.tsx +5 -2
- package/src/components/molecules/chip.tsx +7 -2
- package/src/components/molecules/code-block/file-type-icons.tsx +123 -0
- package/src/components/molecules/code-block/process-code.ts +60 -0
- package/src/components/molecules/code-block/transform-command.tsx +177 -0
- package/src/components/molecules/code-block.tsx +29 -575
- package/src/components/molecules/combobox-free-text.tsx +23 -2
- package/src/components/molecules/copyable-text.tsx +14 -1
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +12 -13
- package/src/components/molecules/data-table/data-table-types.tsx +50 -2
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -1
- package/src/components/molecules/data-table/data-table.tsx +188 -96
- package/src/components/molecules/date-picker.tsx +3 -1
- package/src/components/molecules/date-range-picker.tsx +3 -1
- package/src/components/molecules/date-time-picker.tsx +3 -1
- package/src/components/molecules/file-dropzone.tsx +15 -5
- package/src/components/molecules/illustrations/empty-database.tsx +8 -5
- package/src/components/molecules/illustrations/error.tsx +19 -17
- package/src/components/molecules/illustrations/expired.tsx +55 -0
- package/src/components/molecules/illustrations/first-run.tsx +3 -1
- package/src/components/molecules/illustrations/no-activity.tsx +35 -14
- package/src/components/molecules/illustrations/no-customers.tsx +66 -0
- package/src/components/molecules/illustrations/no-documents.tsx +4 -3
- package/src/components/molecules/illustrations/no-invoices.tsx +45 -0
- package/src/components/molecules/illustrations/no-notifications.tsx +7 -8
- package/src/components/molecules/illustrations/no-orders.tsx +25 -17
- package/src/components/molecules/illustrations/no-plugins.tsx +21 -31
- package/src/components/molecules/illustrations/no-products.tsx +53 -0
- package/src/components/molecules/illustrations/no-projects.tsx +54 -0
- package/src/components/molecules/illustrations/no-promotions.tsx +49 -0
- package/src/components/molecules/illustrations/no-subscription.tsx +72 -0
- package/src/components/molecules/illustrations/not-found.tsx +17 -15
- package/src/components/molecules/illustrations/offline.tsx +12 -10
- package/src/components/molecules/illustrations/payment-failed.tsx +53 -0
- package/src/components/molecules/illustrations/success.tsx +43 -0
- package/src/components/molecules/inline-code.tsx +26 -0
- package/src/components/molecules/page-header.tsx +7 -3
- package/src/components/molecules/stat-card.tsx +13 -12
- package/src/components/molecules/state-views/empty-state.tsx +12 -1
- package/src/components/molecules/state-views/loading-state.tsx +7 -3
- package/src/lib/highlight.ts +177 -0
- package/src/lib/state-dictionary.ts +18 -5
- package/src/lib/utils.ts +0 -19
|
@@ -89,7 +89,7 @@ function DropdownMenuItem({
|
|
|
89
89
|
data-inset={inset}
|
|
90
90
|
data-variant={variant}
|
|
91
91
|
className={cn(
|
|
92
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
92
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive-subtle-foreground data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive-subtle-foreground data-[variant=destructive]:*:[svg]:text-destructive-subtle-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
93
93
|
className
|
|
94
94
|
)}
|
|
95
95
|
{...props}
|
|
@@ -52,7 +52,7 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const fieldVariants = cva(
|
|
55
|
-
"data-[invalid=true]:text-destructive gap-3 group/field flex w-full",
|
|
55
|
+
"data-[invalid=true]:text-destructive-subtle-foreground gap-3 group/field flex w-full",
|
|
56
56
|
{
|
|
57
57
|
variants: {
|
|
58
58
|
orientation: {
|
|
@@ -216,7 +216,7 @@ function FieldError({
|
|
|
216
216
|
<div
|
|
217
217
|
role="alert"
|
|
218
218
|
data-slot="field-error"
|
|
219
|
-
className={cn("text-destructive text-sm font-normal", className)}
|
|
219
|
+
className={cn("text-destructive-subtle-foreground text-sm font-normal", className)}
|
|
220
220
|
{...props}
|
|
221
221
|
>
|
|
222
222
|
{content}
|
|
@@ -9,7 +9,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
|
9
9
|
type={type}
|
|
10
10
|
data-slot="input"
|
|
11
11
|
className={cn(
|
|
12
|
-
"dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
12
|
+
"dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive file:text-foreground placeholder:text-muted-foreground h-9 w-full min-w-0 rounded-md border bg-transparent px-2.5 py-1 text-base transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 md:text-sm",
|
|
13
13
|
className
|
|
14
14
|
)}
|
|
15
15
|
{...props}
|
|
@@ -6,10 +6,13 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
import { Separator } from "@vendure-io/ui/components/atoms/separator"
|
|
8
8
|
|
|
9
|
+
// No role="list": Item renders any element through its render prop (often a
|
|
10
|
+
// link), so it cannot take role="listitem", and a list without listitem
|
|
11
|
+
// children fails axe aria-required-children. Pass role="list" and wrap items
|
|
12
|
+
// in role="listitem" elements when the group is a real list.
|
|
9
13
|
function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
10
14
|
return (
|
|
11
15
|
<div
|
|
12
|
-
role="list"
|
|
13
16
|
data-slot="item-group"
|
|
14
17
|
className={cn(
|
|
15
18
|
"group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2",
|
|
@@ -98,7 +98,7 @@ function MenubarItem({
|
|
|
98
98
|
data-inset={inset}
|
|
99
99
|
data-variant={variant}
|
|
100
100
|
className={cn(
|
|
101
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive! not-data-[variant=destructive]:focus:**:text-accent-foreground group/menubar-item gap-2 rounded-sm px-2 py-1.5 text-sm data-disabled:opacity-50 data-inset:pl-8 [&_svg:not([class*='size-'])]:size-4",
|
|
101
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive-subtle-foreground data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive-subtle-foreground data-[variant=destructive]:*:[svg]:text-destructive-subtle-foreground! not-data-[variant=destructive]:focus:**:text-accent-foreground group/menubar-item gap-2 rounded-sm px-2 py-1.5 text-sm data-disabled:opacity-50 data-inset:pl-8 [&_svg:not([class*='size-'])]:size-4",
|
|
102
102
|
className
|
|
103
103
|
)}
|
|
104
104
|
{...props}
|
|
@@ -24,7 +24,7 @@ function NativeSelect({
|
|
|
24
24
|
<select
|
|
25
25
|
data-slot="native-select"
|
|
26
26
|
data-size={size}
|
|
27
|
-
className="border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
27
|
+
className="border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive h-9 w-full min-w-0 appearance-none rounded-md border bg-transparent py-1 pr-8 pl-2.5 text-sm transition-[color,box-shadow] outline-none select-none focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:ring-3 data-[size=sm]:h-8"
|
|
28
28
|
{...props}
|
|
29
29
|
/>
|
|
30
30
|
<ChevronDownIcon className="text-muted-foreground pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 select-none" aria-hidden="true" data-slot="native-select-icon" />
|
|
@@ -33,6 +33,9 @@ function NavigationMenuList({
|
|
|
33
33
|
return (
|
|
34
34
|
<NavigationMenuPrimitive.List
|
|
35
35
|
data-slot="navigation-menu-list"
|
|
36
|
+
// Base UI sets aria-orientation, which is not allowed on a list
|
|
37
|
+
// (axe aria-allowed-attr). Arrow-key navigation does not depend on it.
|
|
38
|
+
aria-orientation={undefined}
|
|
36
39
|
className={cn(
|
|
37
40
|
"group flex flex-1 list-none items-center justify-center gap-0",
|
|
38
41
|
className
|
|
@@ -56,7 +59,7 @@ function NavigationMenuItem({
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
const navigationMenuTriggerStyle = cva(
|
|
59
|
-
"bg-
|
|
62
|
+
"bg-transparent hover:bg-muted focus:bg-muted data-open:hover:bg-muted data-open:focus:bg-muted data-open:bg-muted/50 focus-visible:ring-ring data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted rounded-md px-4 py-2 text-sm font-medium transition-all focus-visible:ring-2 disabled:opacity-50 group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center disabled:pointer-events-none outline-none"
|
|
60
63
|
)
|
|
61
64
|
|
|
62
65
|
function NavigationMenuTrigger({
|
|
@@ -121,6 +124,9 @@ function NavigationMenuPositioner({
|
|
|
121
124
|
)
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
// Base UI writes a valueless data-active (with aria-current="page") on the
|
|
128
|
+
// active link, so the variant is data-active:, not data-[active=true]:. The
|
|
129
|
+
// active link gets the tabs line-variant underline.
|
|
124
130
|
function NavigationMenuLink({
|
|
125
131
|
className,
|
|
126
132
|
...props
|
|
@@ -129,7 +135,7 @@ function NavigationMenuLink({
|
|
|
129
135
|
<NavigationMenuPrimitive.Link
|
|
130
136
|
data-slot="navigation-menu-link"
|
|
131
137
|
className={cn(
|
|
132
|
-
"data-
|
|
138
|
+
"data-active:text-foreground data-active:font-medium focus-visible:ring-ring hover:bg-muted focus:bg-muted relative flex items-center gap-1.5 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-2 [&_svg:not([class*='size-'])]:size-4 after:bg-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:opacity-0 after:transition-opacity data-active:after:opacity-100",
|
|
133
139
|
className
|
|
134
140
|
)}
|
|
135
141
|
{...props}
|
|
@@ -29,7 +29,7 @@ function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {
|
|
|
29
29
|
return (
|
|
30
30
|
<ProgressPrimitive.Track
|
|
31
31
|
className={cn(
|
|
32
|
-
"bg-
|
|
32
|
+
"bg-control-border relative flex h-1.5 w-full items-center overflow-x-hidden rounded-full",
|
|
33
33
|
className
|
|
34
34
|
)}
|
|
35
35
|
data-slot="progress-track"
|
|
@@ -20,7 +20,7 @@ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
|
|
|
20
20
|
<RadioPrimitive.Root
|
|
21
21
|
data-slot="radio-group-item"
|
|
22
22
|
className={cn(
|
|
23
|
-
"border-
|
|
23
|
+
"border-control-border dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3",
|
|
24
24
|
className
|
|
25
25
|
)}
|
|
26
26
|
{...props}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import * as React from "react"
|
|
4
3
|
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
|
|
5
4
|
|
|
6
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
@@ -18,7 +17,7 @@ function ScrollArea({
|
|
|
18
17
|
>
|
|
19
18
|
<ScrollAreaPrimitive.Viewport
|
|
20
19
|
data-slot="scroll-area-viewport"
|
|
21
|
-
className="focus-visible:ring-ring
|
|
20
|
+
className="focus-visible:ring-ring size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-2"
|
|
22
21
|
>
|
|
23
22
|
{children}
|
|
24
23
|
</ScrollAreaPrimitive.Viewport>
|
|
@@ -41,7 +41,7 @@ function SelectTrigger({
|
|
|
41
41
|
data-slot="select-trigger"
|
|
42
42
|
data-size={size}
|
|
43
43
|
className={cn(
|
|
44
|
-
"border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
44
|
+
"border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
45
45
|
className
|
|
46
46
|
)}
|
|
47
47
|
{...props}
|
|
@@ -28,7 +28,7 @@ function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
|
|
|
28
28
|
<SheetPrimitive.Backdrop
|
|
29
29
|
data-slot="sheet-overlay"
|
|
30
30
|
className={cn(
|
|
31
|
-
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 z-50 bg-
|
|
31
|
+
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 z-50 bg-scrim motion-reduce:animate-none data-open:duration-(--transition-duration-normal) data-open:ease-(--ease-out) data-closed:duration-(--transition-duration-fast) data-closed:ease-(--ease-in) data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",
|
|
32
32
|
className
|
|
33
33
|
)}
|
|
34
34
|
{...props}
|
|
@@ -317,7 +317,7 @@ function SidebarInset({
|
|
|
317
317
|
props: mergeProps<"main">(
|
|
318
318
|
{
|
|
319
319
|
className: cn(
|
|
320
|
-
"bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:bg-surface md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border/60
|
|
320
|
+
"bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:bg-surface md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border/60",
|
|
321
321
|
className
|
|
322
322
|
),
|
|
323
323
|
},
|
|
@@ -489,14 +489,16 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
|
489
489
|
)
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
+
// Hover and active share the sidebar-accent fill, so the active item also gets
|
|
493
|
+
// a sidebar-primary bar on its leading edge.
|
|
492
494
|
const sidebarMenuButtonVariants = cva(
|
|
493
|
-
"ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-md p-2 text-left text-sm transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&_svg]:size-4 [&_svg]:shrink-0",
|
|
495
|
+
"before:bg-sidebar-primary relative before:absolute before:inset-y-1.5 before:left-0 before:w-0.5 before:rounded-full before:opacity-0 data-active:before:opacity-100 ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-md p-2 text-left text-sm transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&_svg]:size-4 [&>svg:first-child]:size-4.5 [&>svg:first-child]:[stroke-width:2.125] [&_svg]:shrink-0",
|
|
494
496
|
{
|
|
495
497
|
variants: {
|
|
496
498
|
variant: {
|
|
497
499
|
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
498
500
|
outline:
|
|
499
|
-
"bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[
|
|
501
|
+
"bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[0_0_0_1px_var(--sidebar-border)] hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
|
|
500
502
|
},
|
|
501
503
|
size: {
|
|
502
504
|
default: "h-8 text-sm",
|
|
@@ -694,7 +696,7 @@ function SidebarMenuSubButton({
|
|
|
694
696
|
props: mergeProps<"a">(
|
|
695
697
|
{
|
|
696
698
|
className: cn(
|
|
697
|
-
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:ring-2 data-[size=md]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
|
|
699
|
+
"before:bg-sidebar-primary relative before:absolute before:inset-y-1.5 before:left-0 before:w-0.5 before:rounded-full before:opacity-0 data-active:before:opacity-100 text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:ring-2 data-[size=md]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
|
|
698
700
|
className
|
|
699
701
|
),
|
|
700
702
|
},
|
|
@@ -37,7 +37,7 @@ function Slider({
|
|
|
37
37
|
<SliderPrimitive.Control className="relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col">
|
|
38
38
|
<SliderPrimitive.Track
|
|
39
39
|
data-slot="slider-track"
|
|
40
|
-
className="bg-
|
|
40
|
+
className="bg-control-border relative grow overflow-hidden rounded-full select-none data-horizontal:h-1.5 data-horizontal:w-full data-vertical:h-full data-vertical:w-1.5"
|
|
41
41
|
>
|
|
42
42
|
<SliderPrimitive.Indicator
|
|
43
43
|
data-slot="slider-range"
|
|
@@ -48,7 +48,7 @@ function Slider({
|
|
|
48
48
|
<SliderPrimitive.Thumb
|
|
49
49
|
data-slot="slider-thumb"
|
|
50
50
|
key={index}
|
|
51
|
-
className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-
|
|
51
|
+
className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-background transition-[color,box-shadow] select-none hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
52
52
|
/>
|
|
53
53
|
))}
|
|
54
54
|
</SliderPrimitive.Control>
|
|
@@ -16,7 +16,7 @@ function Switch({
|
|
|
16
16
|
data-slot="switch"
|
|
17
17
|
data-size={size}
|
|
18
18
|
className={cn(
|
|
19
|
-
"data-checked:bg-primary data-unchecked:bg-
|
|
19
|
+
"data-checked:bg-primary data-unchecked:bg-control-border focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 aria-invalid:ring-3 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px]",
|
|
20
20
|
className
|
|
21
21
|
)}
|
|
22
22
|
{...props}
|
|
@@ -4,11 +4,40 @@ import * as React from "react"
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
6
|
|
|
7
|
+
// When the table is wider than its container, the container scrolls and must
|
|
8
|
+
// be reachable by keyboard (axe scrollable-region-focusable), so it becomes a
|
|
9
|
+
// tab stop with a focus ring. A table that fits adds no tab stop.
|
|
7
10
|
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
11
|
+
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
12
|
+
const [scrollable, setScrollable] = React.useState(false)
|
|
13
|
+
|
|
14
|
+
// Measure before the first paint, so an overflowing table is a tab stop
|
|
15
|
+
// from the start; the observer then tracks later size changes.
|
|
16
|
+
React.useLayoutEffect(() => {
|
|
17
|
+
const container = containerRef.current
|
|
18
|
+
if (!container) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
const update = () =>
|
|
22
|
+
setScrollable(container.scrollWidth > container.clientWidth)
|
|
23
|
+
update()
|
|
24
|
+
if (typeof ResizeObserver === "undefined") {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
const observer = new ResizeObserver(update)
|
|
28
|
+
observer.observe(container)
|
|
29
|
+
if (container.firstElementChild) {
|
|
30
|
+
observer.observe(container.firstElementChild)
|
|
31
|
+
}
|
|
32
|
+
return () => observer.disconnect()
|
|
33
|
+
}, [])
|
|
34
|
+
|
|
8
35
|
return (
|
|
9
36
|
<div
|
|
37
|
+
ref={containerRef}
|
|
10
38
|
data-slot="table-container"
|
|
11
|
-
|
|
39
|
+
tabIndex={scrollable ? 0 : undefined}
|
|
40
|
+
className="focus-visible:ring-ring relative w-full overflow-x-auto rounded-[inherit] outline-none focus-visible:ring-2"
|
|
12
41
|
>
|
|
13
42
|
<table
|
|
14
43
|
data-slot="table"
|
|
@@ -52,12 +81,15 @@ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
|
52
81
|
)
|
|
53
82
|
}
|
|
54
83
|
|
|
84
|
+
// data-state="selected" is the DataTable (TanStack) row-selection marker, not a
|
|
85
|
+
// Radix attribute, so the selector is live. Selected rows use the accent fill
|
|
86
|
+
// plus a primary bar on the leading edge, so they stay distinct from hover.
|
|
55
87
|
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
56
88
|
return (
|
|
57
89
|
<tr
|
|
58
90
|
data-slot="table-row"
|
|
59
91
|
className={cn(
|
|
60
|
-
"hover:bg-muted/50 data-[state=selected]:bg-
|
|
92
|
+
"hover:bg-muted/50 data-[state=selected]:bg-accent data-[state=selected]:shadow-[inset_2px_0_0_var(--primary)] border-b border-border/50 transition-colors",
|
|
61
93
|
className
|
|
62
94
|
)}
|
|
63
95
|
{...props}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { mergeProps } from "@base-ui/react/merge-props"
|
|
3
4
|
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render"
|
|
4
6
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
7
|
|
|
6
8
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
@@ -82,4 +84,65 @@ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
|
|
82
84
|
)
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
// Link tabs: section navigation where each tab is a route. They look like the
|
|
88
|
+
// line variant, but they are a <nav> of links with aria-current="page", not a
|
|
89
|
+
// tablist. Base UI Tabs would put role="tab" on a link and expect a panel for
|
|
90
|
+
// each tab, and the router already owns which section shows.
|
|
91
|
+
function TabsNav({ className, ...props }: React.ComponentProps<"nav">) {
|
|
92
|
+
return (
|
|
93
|
+
<nav
|
|
94
|
+
data-slot="tabs-nav"
|
|
95
|
+
className={cn(
|
|
96
|
+
// The padding keeps the focus ring and the underline inside the
|
|
97
|
+
// scroll box, which clips everything outside it.
|
|
98
|
+
"text-muted-foreground flex h-9 max-w-full items-center gap-1 overflow-x-auto p-[3px]",
|
|
99
|
+
className
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// `active` sets aria-current="page". The style reads aria-current, so a router
|
|
107
|
+
// link that sets it on the active route (TanStack Router, React Router's
|
|
108
|
+
// NavLink) works through `render` without `active`.
|
|
109
|
+
function TabsLink({
|
|
110
|
+
className,
|
|
111
|
+
active,
|
|
112
|
+
render,
|
|
113
|
+
...props
|
|
114
|
+
}: useRender.ComponentProps<"a"> & { active?: boolean }) {
|
|
115
|
+
return useRender({
|
|
116
|
+
defaultTagName: "a",
|
|
117
|
+
render,
|
|
118
|
+
props: mergeProps<"a">(
|
|
119
|
+
{
|
|
120
|
+
// Leave the attribute to the router link unless `active` is set.
|
|
121
|
+
...(active !== undefined && {
|
|
122
|
+
"aria-current": active ? ("page" as const) : undefined,
|
|
123
|
+
}),
|
|
124
|
+
className: cn(
|
|
125
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-full shrink-0 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-[3px] focus-visible:outline-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
126
|
+
"aria-[current=page]:text-foreground dark:aria-[current=page]:text-foreground",
|
|
127
|
+
// The underline sits on the bottom edge of the nav, like the line variant.
|
|
128
|
+
"after:bg-foreground after:absolute after:inset-x-0 after:bottom-[-4px] after:h-0.5 after:opacity-0 after:transition-opacity aria-[current=page]:after:opacity-100",
|
|
129
|
+
className
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
props
|
|
133
|
+
),
|
|
134
|
+
state: {
|
|
135
|
+
slot: "tabs-link",
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
Tabs,
|
|
142
|
+
TabsList,
|
|
143
|
+
TabsTrigger,
|
|
144
|
+
TabsContent,
|
|
145
|
+
TabsNav,
|
|
146
|
+
TabsLink,
|
|
147
|
+
tabsListVariants,
|
|
148
|
+
}
|
|
@@ -7,7 +7,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
|
7
7
|
<textarea
|
|
8
8
|
data-slot="textarea"
|
|
9
9
|
className={cn(
|
|
10
|
-
"border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
10
|
+
"border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-2.5 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 md:text-sm",
|
|
11
11
|
className
|
|
12
12
|
)}
|
|
13
13
|
{...props}
|
|
@@ -72,7 +72,7 @@ function ToggleGroupItem({
|
|
|
72
72
|
data-size={context.size || size}
|
|
73
73
|
data-spacing={context.spacing}
|
|
74
74
|
className={cn(
|
|
75
|
-
// Base UI's Toggle emits data-pressed, never Radix's data-[state=on] — the pressed style comes from toggleVariants via its aria-pressed
|
|
75
|
+
// Base UI's Toggle emits data-pressed, never Radix's data-[state=on] — the pressed style comes from toggleVariants via its aria-pressed and data-pressed rules
|
|
76
76
|
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
|
77
77
|
toggleVariants({
|
|
78
78
|
variant: context.variant || variant,
|
|
@@ -6,12 +6,15 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
|
|
8
8
|
const toggleVariants = cva(
|
|
9
|
-
|
|
9
|
+
// Pressed uses the solid primary pair, like checked Checkbox, Radio and
|
|
10
|
+
// Switch: bg-muted was the hover shade and nearly vanished on dark overlays.
|
|
11
|
+
// Base UI sets both aria-pressed and data-pressed; both are styled.
|
|
12
|
+
"hover:text-foreground aria-pressed:bg-primary aria-pressed:text-primary-foreground aria-pressed:hover:bg-primary/80 aria-pressed:hover:text-primary-foreground data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/80 data-pressed:hover:text-primary-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive gap-1 rounded-md text-sm font-medium transition-[color,box-shadow] [&_svg:not([class*='size-'])]:size-4 group/toggle hover:bg-muted inline-flex items-center justify-center whitespace-nowrap outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
10
13
|
{
|
|
11
14
|
variants: {
|
|
12
15
|
variant: {
|
|
13
16
|
default: "bg-transparent",
|
|
14
|
-
outline: "border-input hover:bg-muted border bg-transparent",
|
|
17
|
+
outline: "border-input hover:bg-muted aria-pressed:border-primary data-pressed:border-primary border bg-transparent",
|
|
15
18
|
},
|
|
16
19
|
size: {
|
|
17
20
|
default: "h-9 min-w-9 px-2",
|
|
@@ -6,7 +6,9 @@ import type { VariantProps } from 'class-variance-authority';
|
|
|
6
6
|
import { XIcon } from 'lucide-react';
|
|
7
7
|
import type * as React from 'react';
|
|
8
8
|
|
|
9
|
-
interface ChipProps extends React.ComponentProps<'span'
|
|
9
|
+
interface ChipProps extends React.ComponentProps<'span'> {
|
|
10
|
+
/** Badge variants a tag can take. `link` and `ghost` are not tag treatments. */
|
|
11
|
+
variant?: Exclude<VariantProps<typeof badgeVariants>['variant'], 'link' | 'ghost'>;
|
|
10
12
|
/** Leading icon slot. */
|
|
11
13
|
icon?: React.ReactNode;
|
|
12
14
|
/**
|
|
@@ -55,6 +57,9 @@ function Chip({
|
|
|
55
57
|
data-slot="chip"
|
|
56
58
|
variant={variant}
|
|
57
59
|
data-disabled={disabled ? '' : undefined}
|
|
60
|
+
// Marks the dimmed label as an inactive component, which WCAG 1.4.3
|
|
61
|
+
// exempts from the contrast minimum.
|
|
62
|
+
aria-disabled={disabled || undefined}
|
|
58
63
|
className={cn(
|
|
59
64
|
'max-w-full gap-1',
|
|
60
65
|
onRemove && 'pr-1',
|
|
@@ -72,7 +77,7 @@ function Chip({
|
|
|
72
77
|
disabled={disabled}
|
|
73
78
|
aria-label={removeLabel}
|
|
74
79
|
onClick={onRemove}
|
|
75
|
-
className="-mr-0.5 ml-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-current/70 hover:bg-
|
|
80
|
+
className="-mr-0.5 ml-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-current/70 hover:bg-current/10 hover:text-current disabled:pointer-events-none"
|
|
76
81
|
>
|
|
77
82
|
<XIcon className="size-3" />
|
|
78
83
|
</button>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand glyphs for common file extensions, shown next to the filename in the
|
|
3
|
+
* header. Path data is inlined from Simple Icons (CC0) so the package takes no
|
|
4
|
+
* icon dependency; glyphs render monochrome via currentColor and inherit the
|
|
5
|
+
* muted header foreground. Unknown extensions fall back to the generic
|
|
6
|
+
* lucide FileIcon.
|
|
7
|
+
*/
|
|
8
|
+
interface FileTypeIconDef {
|
|
9
|
+
/** Brand name of the glyph */
|
|
10
|
+
title: string;
|
|
11
|
+
/** SVG path data on a 24x24 viewBox */
|
|
12
|
+
path: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const typescriptIcon: FileTypeIconDef = {
|
|
16
|
+
title: 'TypeScript',
|
|
17
|
+
path: 'M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const reactIcon: FileTypeIconDef = {
|
|
21
|
+
title: 'React',
|
|
22
|
+
path: 'M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38-.318-.184-.688-.277-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127.666.382.955 1.835.73 3.704-.054.46-.142.945-.25 1.44-.96-.236-2.006-.417-3.107-.534-.66-.905-1.345-1.727-2.035-2.447 1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28-.686.72-1.37 1.537-2.02 2.442-1.107.117-2.154.298-3.113.538-.112-.49-.195-.964-.254-1.42-.23-1.868.054-3.32.714-3.707.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564-.44-.02-.89-.034-1.345-.034-.46 0-.915.01-1.36.034.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093.406.582.802 1.203 1.183 1.86.372.64.71 1.29 1.018 1.946-.308.655-.646 1.31-1.013 1.95-.38.66-.773 1.288-1.18 1.87-.728.063-1.466.098-2.21.098-.74 0-1.477-.035-2.202-.093-.406-.582-.802-1.204-1.183-1.86-.372-.64-.71-1.29-1.018-1.946.303-.657.646-1.313 1.013-1.954.38-.66.773-1.286 1.18-1.868.728-.064 1.466-.098 2.21-.098zm-3.635.254c-.24.377-.48.763-.704 1.16-.225.39-.435.782-.635 1.174-.265-.656-.49-1.31-.676-1.947.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387-.18.632-.405 1.282-.66 1.933-.2-.39-.41-.783-.64-1.174-.225-.392-.465-.774-.705-1.146zm3.063.675c.484.15.944.317 1.375.498 1.732.74 2.852 1.708 2.852 2.476-.005.768-1.125 1.74-2.857 2.475-.42.18-.88.342-1.355.493-.28-.958-.646-1.956-1.1-2.98.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98-.45 1.017-.812 2.01-1.086 2.964-.484-.15-.944-.318-1.37-.5-1.732-.737-2.852-1.706-2.852-2.474 0-.768 1.12-1.742 2.852-2.476.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948-.64.157-1.316.29-2.016.39.24-.375.48-.762.705-1.158.225-.39.435-.788.636-1.18zm-9.945.02c.2.392.41.783.64 1.175.23.39.465.772.705 1.143-.695-.102-1.365-.23-2.006-.386.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423.23 1.868-.054 3.32-.714 3.708-.147.09-.338.128-.563.128-1.012 0-2.514-.807-4.11-2.28.686-.72 1.37-1.536 2.02-2.44 1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532.66.905 1.345 1.727 2.035 2.446-1.595 1.483-3.092 2.295-4.11 2.295-.22-.005-.406-.05-.553-.132-.666-.38-.955-1.834-.73-3.703.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034.46 0 .915-.01 1.36-.034-.44.572-.895 1.095-1.345 1.565-.455-.47-.91-.993-1.36-1.565z',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const javascriptIcon: FileTypeIconDef = {
|
|
26
|
+
title: 'JavaScript',
|
|
27
|
+
path: 'M0 0h24v24H0V0zm22.034 18.276c-.175-1.095-.888-2.015-3.003-2.873-.736-.345-1.554-.585-1.797-1.14-.091-.33-.105-.51-.046-.705.15-.646.915-.84 1.515-.66.39.12.75.42.976.9 1.034-.676 1.034-.676 1.755-1.125-.27-.42-.404-.601-.586-.78-.63-.705-1.469-1.065-2.834-1.034l-.705.089c-.676.165-1.32.525-1.71 1.005-1.14 1.291-.811 3.541.569 4.471 1.365 1.02 3.361 1.244 3.616 2.205.24 1.17-.87 1.545-1.966 1.41-.811-.18-1.26-.586-1.755-1.336l-1.83 1.051c.21.48.45.689.81 1.109 1.74 1.756 6.09 1.666 6.871-1.004.029-.09.24-.705.074-1.65l.046.067zm-8.983-7.245h-2.248c0 1.938-.009 3.864-.009 5.805 0 1.232.063 2.363-.138 2.711-.33.689-1.18.601-1.566.48-.396-.196-.597-.466-.83-.855-.063-.105-.11-.196-.127-.196l-1.825 1.125c.305.63.75 1.172 1.324 1.517.855.51 2.004.675 3.207.405.783-.226 1.458-.691 1.811-1.411.51-.93.402-2.07.397-3.346.012-2.054 0-4.109 0-6.179l.004-.056z',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const jsonIcon: FileTypeIconDef = {
|
|
31
|
+
title: 'JSON',
|
|
32
|
+
path: 'M12.043 23.968c.479-.004.953-.029 1.426-.094a11.805 11.805 0 003.146-.863 12.404 12.404 0 003.793-2.542 11.977 11.977 0 002.44-3.427 11.794 11.794 0 001.02-3.476c.149-1.16.135-2.346-.045-3.499a11.96 11.96 0 00-.793-2.788 11.197 11.197 0 00-.854-1.617c-1.168-1.837-2.861-3.314-4.81-4.3a12.835 12.835 0 00-2.172-.87h-.005c.119.063.24.132.345.201.12.074.239.146.351.225a8.93 8.93 0 011.559 1.33c1.063 1.145 1.797 2.548 2.218 4.041.284.982.434 1.998.495 3.017.044.743.044 1.491-.047 2.229-.149 1.27-.554 2.51-1.228 3.596a7.475 7.475 0 01-1.903 2.084c-1.244.928-2.877 1.482-4.436 1.114a3.916 3.916 0 01-.748-.258 4.692 4.692 0 01-.779-.45 6.08 6.08 0 01-1.244-1.105 6.507 6.507 0 01-1.049-1.747 7.366 7.366 0 01-.494-2.54c-.03-1.273.225-2.553.854-3.67a6.43 6.43 0 011.663-1.918c.225-.178.464-.333.704-.479l.016-.007a5.121 5.121 0 00-1.441-.12 4.963 4.963 0 00-1.228.24c-.359.12-.704.27-1.019.45a6.146 6.146 0 00-.733.494c-.211.18-.42.36-.615.555-1.123 1.153-1.768 2.682-2.022 4.256-.15.973-.15 1.96-.091 2.95.105 1.395.391 2.787.945 4.062a8.518 8.518 0 001.348 2.173 8.14 8.14 0 003.132 2.23 7.934 7.934 0 002.113.54c.074.015.149.015.209.015zm-2.934-.398a4.102 4.102 0 01-.45-.228 8.5 8.5 0 01-2.038-1.534c-1.094-1.137-1.827-2.566-2.247-4.08a15.184 15.184 0 01-.495-3.172 12.14 12.14 0 01.046-2.082c.135-1.257.495-2.501 1.124-3.58a6.889 6.889 0 011.783-2.053 6.23 6.23 0 011.633-.9 5.363 5.363 0 013.522-.045c.029 0 .029 0 .045.03.015.015.045.015.06.03.045.016.104.045.165.074.239.12.479.271.704.42a6.294 6.294 0 012.097 2.502c.42.914.615 1.934.631 2.938.014 1.079-.18 2.157-.645 3.146a6.42 6.42 0 01-2.638 2.832c.09.03.18.045.271.075.225.044.449.074.688.074 1.468.045 2.892-.66 3.94-1.647.195-.18.375-.375.54-.585.225-.27.435-.54.614-.823.239-.375.435-.75.614-1.154a8.112 8.112 0 00.509-1.664c.196-1.004.211-2.022.149-3.026-.135-2.022-.673-4.045-1.842-5.724a9.054 9.054 0 00-.555-.719 9.868 9.868 0 00-1.063-1.034 8.477 8.477 0 00-1.363-.915 9.927 9.927 0 00-1.692-.598l-.3-.06c-.209-.03-.42-.044-.634-.06a8.453 8.453 0 00-1.015.016c-.704.045-1.412.16-2.112.337C5.799 1.227 2.863 3.566 1.3 6.67A11.834 11.834 0 00.238 9.801a11.81 11.81 0 00-.104 3.775c.12 1.02.374 2.023.778 2.977.227.57.511 1.124.825 1.648 1.094 1.783 2.683 3.236 4.51 4.24.688.39 1.408.69 2.157.944.226.074.45.15.689.21z',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const htmlIcon: FileTypeIconDef = {
|
|
36
|
+
title: 'HTML5',
|
|
37
|
+
path: 'M1.5 0h21l-1.91 21.563L11.977 24l-8.564-2.438L1.5 0zm7.031 9.75l-.232-2.718 10.059.003.23-2.622L5.412 4.41l.698 8.01h9.126l-.326 3.426-2.91.804-2.955-.81-.188-2.11H6.248l.33 4.171L12 19.351l5.379-1.443.744-8.157H8.531z',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const cssIcon: FileTypeIconDef = {
|
|
41
|
+
title: 'CSS',
|
|
42
|
+
path: 'M0 0v20.16A3.84 3.84 0 0 0 3.84 24h16.32A3.84 3.84 0 0 0 24 20.16V3.84A3.84 3.84 0 0 0 20.16 0Zm14.256 13.08c1.56 0 2.28 1.08 2.304 2.64h-1.608c.024-.288-.048-.6-.144-.84-.096-.192-.288-.264-.552-.264-.456 0-.696.264-.696.84-.024.576.288.888.768 1.08.72.288 1.608.744 1.92 1.296q.432.648.432 1.656c0 1.608-.912 2.592-2.496 2.592-1.656 0-2.4-1.032-2.424-2.688h1.68c0 .792.264 1.176.792 1.176.264 0 .456-.072.552-.24.192-.312.24-1.176-.048-1.512-.312-.408-.912-.6-1.32-.816q-.828-.396-1.224-.936c-.24-.36-.36-.888-.36-1.536 0-1.44.936-2.472 2.424-2.448m5.4 0c1.584 0 2.304 1.08 2.328 2.64h-1.608c0-.288-.048-.6-.168-.84-.096-.192-.264-.264-.528-.264-.48 0-.72.264-.72.84s.288.888.792 1.08c.696.288 1.608.744 1.92 1.296.264.432.408.984.408 1.656.024 1.608-.888 2.592-2.472 2.592-1.68 0-2.424-1.056-2.448-2.688h1.68c0 .744.264 1.176.792 1.176.264 0 .456-.072.552-.24.216-.312.264-1.176-.048-1.512-.288-.408-.888-.6-1.32-.816-.552-.264-.96-.576-1.2-.936s-.36-.888-.36-1.536c-.024-1.44.912-2.472 2.4-2.448m-11.031.018c.711-.006 1.419.198 1.839.63.432.432.672 1.128.648 1.992H9.336c.024-.456-.096-.792-.432-.96-.312-.144-.768-.048-.888.24-.12.264-.192.576-.168.864v3.504c0 .744.264 1.128.768 1.128a.65.65 0 0 0 .552-.264c.168-.24.192-.552.168-.84h1.776c.096 1.632-.984 2.712-2.568 2.688-1.536 0-2.496-.864-2.472-2.472v-4.032c0-.816.24-1.44.696-1.848.432-.408 1.146-.624 1.857-.63',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const markdownIcon: FileTypeIconDef = {
|
|
46
|
+
title: 'Markdown',
|
|
47
|
+
path: 'M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const mdxIcon: FileTypeIconDef = {
|
|
51
|
+
title: 'MDX',
|
|
52
|
+
path: 'M.79 7.12h22.42c.436 0 .79.355.79.792v8.176c0 .436-.354.79-.79.79H.79a.79.79 0 0 1-.79-.79V7.912a.79.79 0 0 1 .79-.791V7.12Zm2.507 7.605v-3.122l1.89 1.89L7.12 11.56v3.122h1.055v-5.67l-2.99 2.99L2.24 9.056v5.67h1.055v-.001Zm8.44-1.845-1.474-1.473-.746.746 2.747 2.747 2.745-2.747-.746-.746-1.473 1.473v-4h-1.054v4Zm10.041.987-2.175-2.175 2.22-2.22-.746-.746-2.22 2.22-2.22-2.22-.747.746 2.22 2.22-2.176 2.177.746.746 2.177-2.177 2.176 2.175.745-.746Z',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const yamlIcon: FileTypeIconDef = {
|
|
56
|
+
title: 'YAML',
|
|
57
|
+
path: 'm0 .97 4.111 6.453v4.09h2.638v-4.09L11.053.969H8.214L5.58 5.125 2.965.969Zm12.093.024-4.47 10.544h2.114l.97-2.345h4.775l.804 2.345h2.26L14.255.994Zm1.133 2.225 1.463 3.87h-3.096zm3.06 9.475v10.29H24v-2.199h-5.454v-8.091zm-12.175.002v10.335h2.217v-7.129l2.32 4.792h1.746l2.4-4.96v7.295h2.127V12.696h-2.904L9.44 17.37l-2.455-4.674Z',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const graphqlIcon: FileTypeIconDef = {
|
|
61
|
+
title: 'GraphQL',
|
|
62
|
+
path: 'M12.002 0a2.138 2.138 0 1 0 0 4.277 2.138 2.138 0 1 0 0-4.277zm8.54 4.931a2.138 2.138 0 1 0 0 4.277 2.138 2.138 0 1 0 0-4.277zm0 9.862a2.138 2.138 0 1 0 0 4.277 2.138 2.138 0 1 0 0-4.277zm-8.54 4.931a2.138 2.138 0 1 0 0 4.276 2.138 2.138 0 1 0 0-4.276zm-8.542-4.93a2.138 2.138 0 1 0 0 4.276 2.138 2.138 0 1 0 0-4.277zm0-9.863a2.138 2.138 0 1 0 0 4.277 2.138 2.138 0 1 0 0-4.277zm8.542-3.378L2.953 6.777v10.448l9.049 5.224 9.047-5.224V6.777zm0 1.601 7.66 13.27H4.34zm-1.387.371L3.97 15.037V7.363zm2.774 0 6.646 3.838v7.674zM5.355 17.44h13.293l-6.646 3.836z',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const bashIcon: FileTypeIconDef = {
|
|
66
|
+
title: 'Bash',
|
|
67
|
+
path: 'M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const dockerIcon: FileTypeIconDef = {
|
|
71
|
+
title: 'Docker',
|
|
72
|
+
path: 'M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z',
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const FILE_TYPE_ICONS: Record<string, FileTypeIconDef> = {
|
|
76
|
+
ts: typescriptIcon,
|
|
77
|
+
mts: typescriptIcon,
|
|
78
|
+
cts: typescriptIcon,
|
|
79
|
+
tsx: reactIcon,
|
|
80
|
+
jsx: reactIcon,
|
|
81
|
+
js: javascriptIcon,
|
|
82
|
+
mjs: javascriptIcon,
|
|
83
|
+
cjs: javascriptIcon,
|
|
84
|
+
json: jsonIcon,
|
|
85
|
+
jsonc: jsonIcon,
|
|
86
|
+
html: htmlIcon,
|
|
87
|
+
css: cssIcon,
|
|
88
|
+
md: markdownIcon,
|
|
89
|
+
mdx: mdxIcon,
|
|
90
|
+
yml: yamlIcon,
|
|
91
|
+
yaml: yamlIcon,
|
|
92
|
+
graphql: graphqlIcon,
|
|
93
|
+
gql: graphqlIcon,
|
|
94
|
+
sh: bashIcon,
|
|
95
|
+
bash: bashIcon,
|
|
96
|
+
zsh: bashIcon,
|
|
97
|
+
dockerfile: dockerIcon,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Resolve the brand icon for a filename by its extension. Matching uses the
|
|
102
|
+
* basename, so directory names never interfere. `Dockerfile` matches by full
|
|
103
|
+
* basename since it has no extension. Returns undefined for unknown extensions
|
|
104
|
+
* and dotfiles; the header then falls back to the generic file icon.
|
|
105
|
+
*/
|
|
106
|
+
function matchFileTypeIcon(filename: string): FileTypeIconDef | undefined {
|
|
107
|
+
const basename = filename.split('/').pop()?.toLowerCase() ?? '';
|
|
108
|
+
if (basename === 'dockerfile') return FILE_TYPE_ICONS.dockerfile;
|
|
109
|
+
const dotIndex = basename.lastIndexOf('.');
|
|
110
|
+
if (dotIndex <= 0) return undefined;
|
|
111
|
+
return FILE_TYPE_ICONS[basename.slice(dotIndex + 1)];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function FileTypeIcon({ icon }: { icon: FileTypeIconDef }) {
|
|
115
|
+
return (
|
|
116
|
+
<svg viewBox="0 0 24 24" className="size-3.5 shrink-0 fill-current" aria-hidden="true">
|
|
117
|
+
<path d={icon.path} />
|
|
118
|
+
</svg>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { FileTypeIcon, matchFileTypeIcon };
|
|
123
|
+
export type { FileTypeIconDef };
|