@djangocfg/ui-core 2.1.634 → 2.1.636
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/package.json +9 -8
- package/src/components/data/badge/index.tsx +10 -1
- package/src/components/data/table/index.tsx +12 -2
- package/src/components/forms/button/index.tsx +18 -4
- package/src/components/forms/control-size.ts +10 -10
- package/src/components/index.ts +2 -1
- package/src/components/navigation/context-menu/index.tsx +7 -7
- package/src/components/navigation/dropdown-menu/index.tsx +7 -7
- package/src/components/navigation/menubar/index.tsx +7 -7
- package/src/components/navigation/sidebar/sidebar.tsx +14 -23
- package/src/components/overlay/popover/index.tsx +1 -1
- package/src/components/overlay/side-panel/index.tsx +28 -4
- package/src/components/overlay/tooltip/index.tsx +56 -6
- package/src/components/select/select.tsx +4 -4
- package/src/components/specialized/copy/index.tsx +3 -0
- package/src/hooks/media/index.ts +1 -0
- package/src/hooks/media/useCanHover.ts +14 -0
- package/src/styles/css/base.css +80 -0
- package/src/styles/css/presets/notion.css +175 -0
- package/src/styles/css/theme/dark.css +23 -23
- package/src/styles/css/theme/light.css +54 -59
- package/src/styles/css/utilities/touch-safe.css +17 -3
- package/src/styles/presets/presets.ts +1 -0
- package/src/styles/presets/types.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.636",
|
|
4
4
|
"description": "Pure React UI component library without Next.js dependencies - for Electron, Vite, CRA apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-components",
|
|
@@ -119,7 +119,8 @@
|
|
|
119
119
|
"./styles/presets/windows": "./src/styles/css/presets/windows.css",
|
|
120
120
|
"./styles/presets/soft": "./src/styles/css/presets/soft.css",
|
|
121
121
|
"./styles/presets/dense": "./src/styles/css/presets/dense.css",
|
|
122
|
-
"./styles/presets/high-contrast": "./src/styles/css/presets/high-contrast.css"
|
|
122
|
+
"./styles/presets/high-contrast": "./src/styles/css/presets/high-contrast.css",
|
|
123
|
+
"./styles/presets/notion": "./src/styles/css/presets/notion.css"
|
|
123
124
|
},
|
|
124
125
|
"files": [
|
|
125
126
|
"dist",
|
|
@@ -138,8 +139,8 @@
|
|
|
138
139
|
"check:docs": "node scripts/check-docs.mjs"
|
|
139
140
|
},
|
|
140
141
|
"peerDependencies": {
|
|
141
|
-
"@djangocfg/api": "^2.1.
|
|
142
|
-
"@djangocfg/i18n": "^2.1.
|
|
142
|
+
"@djangocfg/api": "^2.1.636",
|
|
143
|
+
"@djangocfg/i18n": "^2.1.636",
|
|
143
144
|
"consola": "^3.4.2",
|
|
144
145
|
"lucide-react": "^1.68.0",
|
|
145
146
|
"moment": "^2.30.1",
|
|
@@ -214,10 +215,10 @@
|
|
|
214
215
|
"vaul": "1.1.2"
|
|
215
216
|
},
|
|
216
217
|
"devDependencies": {
|
|
217
|
-
"@djangocfg/api": "^2.1.
|
|
218
|
-
"@djangocfg/eslint-config": "^2.1.
|
|
219
|
-
"@djangocfg/i18n": "^2.1.
|
|
220
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
218
|
+
"@djangocfg/api": "^2.1.636",
|
|
219
|
+
"@djangocfg/eslint-config": "^2.1.636",
|
|
220
|
+
"@djangocfg/i18n": "^2.1.636",
|
|
221
|
+
"@djangocfg/typescript-config": "^2.1.636",
|
|
221
222
|
"@storybook/react-vite": "^10.6.5",
|
|
222
223
|
"@types/node": "^24.13.3",
|
|
223
224
|
"@types/react": "19.3.0",
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { cn } from '../../../lib/utils';
|
|
5
5
|
|
|
6
6
|
const badgeVariants = cva(
|
|
7
|
-
"inline-flex items-center rounded-
|
|
7
|
+
"inline-flex items-center rounded-(--badge-radius) border px-(--badge-px) py-(--badge-py) text-(length:--badge-font-size) font-(weight:--badge-weight) transition-colors focus:outline-none focus:ring-1 focus:ring-ring",
|
|
8
8
|
{
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|
|
@@ -15,6 +15,15 @@ const badgeVariants = cva(
|
|
|
15
15
|
destructive:
|
|
16
16
|
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
|
17
17
|
outline: "text-foreground",
|
|
18
|
+
gray: "border-transparent bg-(--tag-gray-bg) text-(--tag-gray-fg)",
|
|
19
|
+
brown: "border-transparent bg-(--tag-brown-bg) text-(--tag-brown-fg)",
|
|
20
|
+
orange: "border-transparent bg-(--tag-orange-bg) text-(--tag-orange-fg)",
|
|
21
|
+
yellow: "border-transparent bg-(--tag-yellow-bg) text-(--tag-yellow-fg)",
|
|
22
|
+
green: "border-transparent bg-(--tag-green-bg) text-(--tag-green-fg)",
|
|
23
|
+
blue: "border-transparent bg-(--tag-blue-bg) text-(--tag-blue-fg)",
|
|
24
|
+
purple: "border-transparent bg-(--tag-purple-bg) text-(--tag-purple-fg)",
|
|
25
|
+
pink: "border-transparent bg-(--tag-pink-bg) text-(--tag-pink-fg)",
|
|
26
|
+
red: "border-transparent bg-(--tag-red-bg) text-(--tag-red-fg)",
|
|
18
27
|
},
|
|
19
28
|
},
|
|
20
29
|
defaultVariants: {
|
|
@@ -14,15 +14,25 @@ const Table = React.forwardRef<
|
|
|
14
14
|
* double border and a radius that doesn't match the parent's.
|
|
15
15
|
*/
|
|
16
16
|
frame?: boolean
|
|
17
|
+
/**
|
|
18
|
+
* A database grid, as in Notion: no header band, hairline column dividers, 36px rows,
|
|
19
|
+
* regular-weight column labels. Pair with `frame={false}` on a page-level table.
|
|
20
|
+
*/
|
|
21
|
+
grid?: boolean
|
|
17
22
|
}
|
|
18
|
-
>(({ className, containerClassName, frame = true, ...props }, ref) => {
|
|
23
|
+
>(({ className, containerClassName, frame = true, grid = false, ...props }, ref) => {
|
|
19
24
|
// Scroll container. Cap its height via `containerClassName`
|
|
20
25
|
// (e.g. "max-h-80") to get a scrollable body with a sticky header.
|
|
21
26
|
const scroll = (
|
|
22
27
|
<div className={cn("w-full overflow-auto", containerClassName)}>
|
|
23
28
|
<table
|
|
24
29
|
ref={ref}
|
|
25
|
-
className={cn(
|
|
30
|
+
className={cn(
|
|
31
|
+
"w-full caption-bottom text-sm",
|
|
32
|
+
grid &&
|
|
33
|
+
"[&_thead]:bg-transparent [&_th]:h-8 [&_th]:border-r [&_th]:border-divider [&_th]:font-normal [&_td]:h-9 [&_td]:border-r [&_td]:border-divider [&_td]:py-0 [&_th:last-child]:border-r-0 [&_td:last-child]:border-r-0",
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
26
36
|
{...props}
|
|
27
37
|
/>
|
|
28
38
|
</div>
|
|
@@ -8,10 +8,11 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
8
8
|
|
|
9
9
|
import { cn } from '../../../lib/utils';
|
|
10
10
|
import { Link } from '../../navigation/link';
|
|
11
|
+
import { TooltipHint, type TooltipProp } from '../../overlay/tooltip';
|
|
11
12
|
import { buttonSizeClass, CONTROL_SIZE } from '../control-size';
|
|
12
13
|
|
|
13
14
|
const buttonVariants = cva(
|
|
14
|
-
"inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius)] text-sm font-
|
|
15
|
+
"inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius)] text-sm font-(weight:--button-weight) transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
15
16
|
{
|
|
16
17
|
variants: {
|
|
17
18
|
variant: {
|
|
@@ -40,7 +41,7 @@ const buttonVariants = cva(
|
|
|
40
41
|
xs: cn(buttonSizeClass('xs'), "rounded-[var(--radius-sm)]"),
|
|
41
42
|
lg: cn(buttonSizeClass('lg'), "rounded-[var(--radius)]"),
|
|
42
43
|
huge: cn(buttonSizeClass('huge'), "rounded-[var(--radius)]"),
|
|
43
|
-
icon: cn(CONTROL_SIZE.default.height, "w-
|
|
44
|
+
icon: cn(CONTROL_SIZE.default.height, "w-(--control-h-default)"),
|
|
44
45
|
},
|
|
45
46
|
// Most variants ship a baked-in `shadow`/`shadow-sm` for a lifted look.
|
|
46
47
|
// `elevated={false}` flattens that (e.g. controls grouped inside a card —
|
|
@@ -65,6 +66,11 @@ export interface ButtonProps
|
|
|
65
66
|
VariantProps<typeof buttonVariants> {
|
|
66
67
|
asChild?: boolean
|
|
67
68
|
loading?: boolean
|
|
69
|
+
/**
|
|
70
|
+
* The control's hover hint: a text, or `{ content, hotkey?, side?, delay?, hoverable? }` (`TooltipConfig`). Replaces the `Tooltip` / `TooltipTrigger` / `TooltipContent` wrapper.
|
|
71
|
+
* Drawn only where the device can hover (`useCanHover`), so a phone gets none; a disabled button is wrapped in a span so it can still be hovered.
|
|
72
|
+
*/
|
|
73
|
+
tooltip?: TooltipProp
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
// Filter out SVG icons from children when loading
|
|
@@ -83,7 +89,7 @@ function filterIcons(children: React.ReactNode): React.ReactNode {
|
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
86
|
-
({ className, variant, size, elevated, asChild = false, loading = false, onClick, children, disabled, ...props }, ref) => {
|
|
92
|
+
({ className, variant, size, elevated, asChild = false, loading = false, onClick, children, disabled, tooltip, ...props }, ref) => {
|
|
87
93
|
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
88
94
|
if (!loading) {
|
|
89
95
|
onClick?.(e);
|
|
@@ -94,6 +100,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
94
100
|
// Don't render loading spinner with asChild to avoid "Children.only" error
|
|
95
101
|
if (asChild) {
|
|
96
102
|
return (
|
|
103
|
+
<TooltipHint tooltip={tooltip}>
|
|
97
104
|
<Slot
|
|
98
105
|
className={cn(buttonVariants({ variant, size, elevated, className }))}
|
|
99
106
|
ref={ref}
|
|
@@ -102,10 +109,12 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
102
109
|
>
|
|
103
110
|
{children}
|
|
104
111
|
</Slot>
|
|
112
|
+
</TooltipHint>
|
|
105
113
|
)
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
return (
|
|
117
|
+
<TooltipHint tooltip={tooltip} disabled={disabled || loading}>
|
|
109
118
|
<button
|
|
110
119
|
className={cn(buttonVariants({ variant, size, elevated, className }))}
|
|
111
120
|
ref={ref}
|
|
@@ -116,6 +125,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
116
125
|
{loading && <Loader2 className="size-4 animate-spin" />}
|
|
117
126
|
{loading ? filterIcons(children) : children}
|
|
118
127
|
</button>
|
|
128
|
+
</TooltipHint>
|
|
119
129
|
)
|
|
120
130
|
}
|
|
121
131
|
)
|
|
@@ -150,11 +160,13 @@ export interface ButtonLinkProps
|
|
|
150
160
|
disabled?: boolean
|
|
151
161
|
/** Inert + dimmed + spinner (e.g. while an action resolves). */
|
|
152
162
|
loading?: boolean
|
|
163
|
+
/** The hover hint (see `ButtonProps.tooltip`). */
|
|
164
|
+
tooltip?: TooltipProp
|
|
153
165
|
}
|
|
154
166
|
|
|
155
167
|
const ButtonLink = React.forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
|
156
168
|
(
|
|
157
|
-
{ className, variant, size, elevated, href, replace, scroll, prefetch, disabled = false, loading = false, onClick, children, ...props },
|
|
169
|
+
{ className, variant, size, elevated, href, replace, scroll, prefetch, disabled = false, loading = false, onClick, children, tooltip, ...props },
|
|
158
170
|
ref,
|
|
159
171
|
) => {
|
|
160
172
|
// `<a>` can't be natively disabled — emulate it (aria + tab-order + no
|
|
@@ -169,6 +181,7 @@ const ButtonLink = React.forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
|
|
169
181
|
}
|
|
170
182
|
|
|
171
183
|
return (
|
|
184
|
+
<TooltipHint tooltip={tooltip}>
|
|
172
185
|
<Link
|
|
173
186
|
href={href}
|
|
174
187
|
replace={replace}
|
|
@@ -187,6 +200,7 @@ const ButtonLink = React.forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
|
|
187
200
|
{loading && <Loader2 className="size-4 animate-spin" />}
|
|
188
201
|
{loading ? filterIcons(children) : children}
|
|
189
202
|
</Link>
|
|
203
|
+
</TooltipHint>
|
|
190
204
|
)
|
|
191
205
|
}
|
|
192
206
|
)
|
|
@@ -22,32 +22,32 @@ import { cn } from '../../lib/utils';
|
|
|
22
22
|
*/
|
|
23
23
|
export const CONTROL_SIZE = {
|
|
24
24
|
xs: {
|
|
25
|
-
height: 'h-
|
|
26
|
-
minHeight: 'min-h-
|
|
25
|
+
height: 'h-(--control-h-xs)',
|
|
26
|
+
minHeight: 'min-h-(--control-h-xs)',
|
|
27
27
|
button: 'px-2 py-1 text-xs',
|
|
28
28
|
field: 'px-2 py-0.5 text-xs',
|
|
29
29
|
},
|
|
30
30
|
sm: {
|
|
31
|
-
height: 'h-
|
|
32
|
-
minHeight: 'min-h-
|
|
31
|
+
height: 'h-(--control-h-sm)',
|
|
32
|
+
minHeight: 'min-h-(--control-h-sm)',
|
|
33
33
|
button: 'px-3 text-sm',
|
|
34
34
|
field: 'px-2.5 py-1 text-sm',
|
|
35
35
|
},
|
|
36
36
|
default: {
|
|
37
|
-
height: 'h-
|
|
38
|
-
minHeight: 'min-h-
|
|
37
|
+
height: 'h-(--control-h-default)',
|
|
38
|
+
minHeight: 'min-h-(--control-h-default)',
|
|
39
39
|
button: 'px-4 py-2',
|
|
40
40
|
field: 'px-3 py-1 text-base md:text-sm',
|
|
41
41
|
},
|
|
42
42
|
lg: {
|
|
43
|
-
height: 'h-
|
|
44
|
-
minHeight: 'min-h-
|
|
43
|
+
height: 'h-(--control-h-lg)',
|
|
44
|
+
minHeight: 'min-h-(--control-h-lg)',
|
|
45
45
|
button: 'px-8',
|
|
46
46
|
field: 'px-4 py-2 text-base',
|
|
47
47
|
},
|
|
48
48
|
huge: {
|
|
49
|
-
height: 'h-
|
|
50
|
-
minHeight: 'min-h-
|
|
49
|
+
height: 'h-(--control-h-huge)',
|
|
50
|
+
minHeight: 'min-h-(--control-h-huge)',
|
|
51
51
|
button: 'px-10 text-lg',
|
|
52
52
|
},
|
|
53
53
|
} as const;
|
package/src/components/index.ts
CHANGED
|
@@ -105,7 +105,8 @@ export { ResponsiveSheet, ResponsiveSheetContent, ResponsiveSheetHeader, Respons
|
|
|
105
105
|
export { SidePanel, SidePanelContent, SidePanelHeader, SidePanelTitle, SidePanelDescription, SidePanelBody, SidePanelFooter, SidePanelClose } from './overlay/side-panel';
|
|
106
106
|
export type { SidePanelProps, SidePanelContentProps, SidePanelCloseProps } from './overlay/side-panel';
|
|
107
107
|
export { HoverCard, HoverCardContent, HoverCardTrigger } from './overlay/hover-card';
|
|
108
|
-
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './overlay/tooltip';
|
|
108
|
+
export { Tooltip, TooltipContent, TooltipHint, TooltipProvider, TooltipTrigger } from './overlay/tooltip';
|
|
109
|
+
export type { TooltipConfig, TooltipProp } from './overlay/tooltip';
|
|
109
110
|
|
|
110
111
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
111
112
|
// Navigation
|
|
@@ -28,7 +28,7 @@ const ContextMenuSubTrigger = React.forwardRef<
|
|
|
28
28
|
<ContextMenuPrimitive.SubTrigger
|
|
29
29
|
ref={ref}
|
|
30
30
|
className={cn(
|
|
31
|
-
"flex cursor-default select-none items-center rounded-[var(--radius-sm)] px-
|
|
31
|
+
"flex cursor-default select-none items-center rounded-[var(--radius-sm)] px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
32
32
|
inset && "pl-8",
|
|
33
33
|
className
|
|
34
34
|
)}
|
|
@@ -47,7 +47,7 @@ const ContextMenuSubContent = React.forwardRef<
|
|
|
47
47
|
<ContextMenuPrimitive.SubContent
|
|
48
48
|
ref={ref}
|
|
49
49
|
className={cn(
|
|
50
|
-
"z-[1400] min-w-32 overflow-hidden rounded-[var(--radius-popover)] border bg-popover p-
|
|
50
|
+
"z-[1400] min-w-32 overflow-hidden rounded-[var(--radius-popover)] border bg-popover p-(--menu-padding) text-popover-foreground shadow-(--popup-shadow) data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:duration-75 data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-98 motion-reduce:data-[state=open]:animate-none",
|
|
51
51
|
className
|
|
52
52
|
)}
|
|
53
53
|
{...props}
|
|
@@ -63,7 +63,7 @@ const ContextMenuContent = React.forwardRef<
|
|
|
63
63
|
<ContextMenuPrimitive.Content
|
|
64
64
|
ref={ref}
|
|
65
65
|
className={cn(
|
|
66
|
-
"z-[1400] max-h-(--radix-context-menu-content-available-height) min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-[var(--radius-popover)] border bg-popover p-
|
|
66
|
+
"z-[1400] max-h-(--radix-context-menu-content-available-height) min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-[var(--radius-popover)] border bg-popover p-(--menu-padding) text-popover-foreground shadow-(--popup-shadow) data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:duration-75 data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-98 motion-reduce:data-[state=open]:animate-none",
|
|
67
67
|
className
|
|
68
68
|
)}
|
|
69
69
|
{...props}
|
|
@@ -85,7 +85,7 @@ const ContextMenuItem = React.forwardRef<
|
|
|
85
85
|
ref={ref}
|
|
86
86
|
data-variant={variant}
|
|
87
87
|
className={cn(
|
|
88
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] px-
|
|
88
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
89
89
|
"[&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",
|
|
90
90
|
"data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive [&[data-variant=destructive]_svg]:text-destructive",
|
|
91
91
|
inset && "pl-8",
|
|
@@ -103,7 +103,7 @@ const ContextMenuCheckboxItem = React.forwardRef<
|
|
|
103
103
|
<ContextMenuPrimitive.CheckboxItem
|
|
104
104
|
ref={ref}
|
|
105
105
|
className={cn(
|
|
106
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] py-
|
|
106
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] py-(--menu-item-py) pl-8 pr-2 text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
107
107
|
"[&_svg]:size-4 [&_svg]:shrink-0",
|
|
108
108
|
className
|
|
109
109
|
)}
|
|
@@ -128,7 +128,7 @@ const ContextMenuRadioItem = React.forwardRef<
|
|
|
128
128
|
<ContextMenuPrimitive.RadioItem
|
|
129
129
|
ref={ref}
|
|
130
130
|
className={cn(
|
|
131
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] py-
|
|
131
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] py-(--menu-item-py) pl-8 pr-2 text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
132
132
|
"[&_svg]:size-4 [&_svg]:shrink-0",
|
|
133
133
|
className
|
|
134
134
|
)}
|
|
@@ -153,7 +153,7 @@ const ContextMenuLabel = React.forwardRef<
|
|
|
153
153
|
<ContextMenuPrimitive.Label
|
|
154
154
|
ref={ref}
|
|
155
155
|
className={cn(
|
|
156
|
-
"px-
|
|
156
|
+
"px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-label-font-size) font-(weight:--menu-label-weight) text-(color:--menu-label-color) text-foreground",
|
|
157
157
|
inset && "pl-8",
|
|
158
158
|
className
|
|
159
159
|
)}
|
|
@@ -46,7 +46,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
46
46
|
<DropdownMenuPrimitive.SubTrigger
|
|
47
47
|
ref={ref}
|
|
48
48
|
className={cn(
|
|
49
|
-
"flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] px-
|
|
49
|
+
"flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-font-size) outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
50
50
|
inset && "pl-8",
|
|
51
51
|
className
|
|
52
52
|
)}
|
|
@@ -71,7 +71,7 @@ const DropdownMenuSubContent = React.forwardRef<
|
|
|
71
71
|
// and clip. `min()` of the space Radix measured to the viewport edge and a
|
|
72
72
|
// comfortable ceiling — a menu that spans the WHOLE screen reads as a page,
|
|
73
73
|
// not a menu, so we stop well short of the viewport even when it would fit.
|
|
74
|
-
"z-[1400] max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] min-w-32 overflow-y-auto overflow-x-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-
|
|
74
|
+
"z-[1400] max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] min-w-32 overflow-y-auto overflow-x-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-(--menu-padding) text-popover-foreground shadow-(--popup-shadow) data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
75
75
|
className
|
|
76
76
|
)}
|
|
77
77
|
{...props}
|
|
@@ -106,7 +106,7 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
106
106
|
// render behind it (reported: language list clipped under the dialog).
|
|
107
107
|
// So the layer order is: sheet(200) < shell(1000/1001) < dialog(1300) <
|
|
108
108
|
// popover(1400). A popover always belongs on top of its opener.
|
|
109
|
-
"z-[1400] max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] min-w-32 overflow-y-auto overflow-x-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-
|
|
109
|
+
"z-[1400] max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] min-w-32 overflow-y-auto overflow-x-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-(--menu-padding) text-popover-foreground shadow-(--popup-shadow)",
|
|
110
110
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
111
111
|
className
|
|
112
112
|
)}
|
|
@@ -127,7 +127,7 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
127
127
|
}
|
|
128
128
|
>(({ className, inset, href, variant = "default", children, ...props }, ref) => {
|
|
129
129
|
const classes = cn(
|
|
130
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] px-
|
|
130
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-[var(--radius-sm)] px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-font-size) outline-none transition-colors focus:bg-foreground/[0.07] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
131
131
|
"data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive",
|
|
132
132
|
inset && "pl-8",
|
|
133
133
|
className
|
|
@@ -163,7 +163,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
|
|
163
163
|
<DropdownMenuPrimitive.CheckboxItem
|
|
164
164
|
ref={ref}
|
|
165
165
|
className={cn(
|
|
166
|
-
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-
|
|
166
|
+
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-(--menu-item-py) pl-8 pr-2 text-(length:--menu-font-size) outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
167
167
|
className
|
|
168
168
|
)}
|
|
169
169
|
checked={checked}
|
|
@@ -187,7 +187,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
|
|
187
187
|
<DropdownMenuPrimitive.RadioItem
|
|
188
188
|
ref={ref}
|
|
189
189
|
className={cn(
|
|
190
|
-
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-
|
|
190
|
+
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-(--menu-item-py) pl-8 pr-2 text-(length:--menu-font-size) outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
191
191
|
className
|
|
192
192
|
)}
|
|
193
193
|
{...props}
|
|
@@ -211,7 +211,7 @@ const DropdownMenuLabel = React.forwardRef<
|
|
|
211
211
|
<DropdownMenuPrimitive.Label
|
|
212
212
|
ref={ref}
|
|
213
213
|
className={cn(
|
|
214
|
-
"px-
|
|
214
|
+
"px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-label-font-size) font-(weight:--menu-label-weight) text-(color:--menu-label-color)",
|
|
215
215
|
inset && "pl-8",
|
|
216
216
|
className
|
|
217
217
|
)}
|
|
@@ -76,7 +76,7 @@ const MenubarSubTrigger = React.forwardRef<
|
|
|
76
76
|
<MenubarPrimitive.SubTrigger
|
|
77
77
|
ref={ref}
|
|
78
78
|
className={cn(
|
|
79
|
-
"flex cursor-default select-none items-center rounded-[var(--radius-sm)] px-
|
|
79
|
+
"flex cursor-default select-none items-center rounded-[var(--radius-sm)] px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
80
80
|
inset && "pl-8",
|
|
81
81
|
className
|
|
82
82
|
)}
|
|
@@ -95,7 +95,7 @@ const MenubarSubContent = React.forwardRef<
|
|
|
95
95
|
<MenubarPrimitive.SubContent
|
|
96
96
|
ref={ref}
|
|
97
97
|
className={cn(
|
|
98
|
-
"z-[1400] min-w-32 overflow-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-
|
|
98
|
+
"z-[1400] min-w-32 overflow-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-(--menu-padding) text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
99
99
|
className
|
|
100
100
|
)}
|
|
101
101
|
{...props}
|
|
@@ -118,7 +118,7 @@ const MenubarContent = React.forwardRef<
|
|
|
118
118
|
alignOffset={alignOffset}
|
|
119
119
|
sideOffset={sideOffset}
|
|
120
120
|
className={cn(
|
|
121
|
-
"z-[1400] min-w-48 overflow-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-
|
|
121
|
+
"z-[1400] min-w-48 overflow-hidden rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-(--menu-padding) text-popover-foreground shadow-(--popup-shadow) data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
122
122
|
className
|
|
123
123
|
)}
|
|
124
124
|
{...props}
|
|
@@ -139,7 +139,7 @@ const MenubarItem = React.forwardRef<
|
|
|
139
139
|
}
|
|
140
140
|
>(({ className, inset, href, variant = "default", children, ...props }, ref) => {
|
|
141
141
|
const classes = cn(
|
|
142
|
-
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] px-
|
|
142
|
+
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
143
143
|
"data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive",
|
|
144
144
|
inset && "pl-8",
|
|
145
145
|
className
|
|
@@ -175,7 +175,7 @@ const MenubarCheckboxItem = React.forwardRef<
|
|
|
175
175
|
<MenubarPrimitive.CheckboxItem
|
|
176
176
|
ref={ref}
|
|
177
177
|
className={cn(
|
|
178
|
-
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-
|
|
178
|
+
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-(--menu-item-py) pl-8 pr-2 text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
179
179
|
className
|
|
180
180
|
)}
|
|
181
181
|
checked={checked}
|
|
@@ -198,7 +198,7 @@ const MenubarRadioItem = React.forwardRef<
|
|
|
198
198
|
<MenubarPrimitive.RadioItem
|
|
199
199
|
ref={ref}
|
|
200
200
|
className={cn(
|
|
201
|
-
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-
|
|
201
|
+
"relative flex cursor-default select-none items-center rounded-[var(--radius-sm)] py-(--menu-item-py) pl-8 pr-2 text-(length:--menu-font-size) outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
202
202
|
className
|
|
203
203
|
)}
|
|
204
204
|
{...props}
|
|
@@ -222,7 +222,7 @@ const MenubarLabel = React.forwardRef<
|
|
|
222
222
|
<MenubarPrimitive.Label
|
|
223
223
|
ref={ref}
|
|
224
224
|
className={cn(
|
|
225
|
-
"px-
|
|
225
|
+
"px-(--menu-item-px) py-(--menu-item-py) text-(length:--menu-label-font-size) font-(weight:--menu-label-weight) text-(color:--menu-label-color)",
|
|
226
226
|
inset && "pl-8",
|
|
227
227
|
className
|
|
228
228
|
)}
|
|
@@ -6,7 +6,6 @@ import * as React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { cn } from '../../../lib';
|
|
8
8
|
import { useIsMobile } from '../../../hooks/media';
|
|
9
|
-
import { useShortcutModLabel } from '../../../hooks/device';
|
|
10
9
|
import { Slot } from '@radix-ui/react-slot';
|
|
11
10
|
|
|
12
11
|
import { Button } from '../../forms/button';
|
|
@@ -308,10 +307,8 @@ const SidebarTrigger = React.forwardRef<
|
|
|
308
307
|
React.ElementRef<typeof Button>,
|
|
309
308
|
React.ComponentProps<typeof Button>
|
|
310
309
|
>(({ className, onClick, ...props }, ref) => {
|
|
311
|
-
const { toggleSidebar, openMobile } = useSidebar()
|
|
312
|
-
const mod = useShortcutModLabel()
|
|
310
|
+
const { toggleSidebar, openMobile, open: isOpenDesktop } = useSidebar()
|
|
313
311
|
const isMobile = useIsMobile()
|
|
314
|
-
const desktopHint = `Toggle sidebar (${mod}+B)`
|
|
315
312
|
|
|
316
313
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
317
314
|
onClick?.(event)
|
|
@@ -338,25 +335,19 @@ const SidebarTrigger = React.forwardRef<
|
|
|
338
335
|
}
|
|
339
336
|
|
|
340
337
|
return (
|
|
341
|
-
<
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
</Button>
|
|
355
|
-
</TooltipTrigger>
|
|
356
|
-
<TooltipContent side="right" align="center" sideOffset={8} className="max-w-[16rem]">
|
|
357
|
-
{desktopHint}
|
|
358
|
-
</TooltipContent>
|
|
359
|
-
</Tooltip>
|
|
338
|
+
<Button
|
|
339
|
+
ref={ref}
|
|
340
|
+
data-sidebar="trigger"
|
|
341
|
+
variant="ghost"
|
|
342
|
+
size="icon"
|
|
343
|
+
className={buttonClass}
|
|
344
|
+
tooltip={{ content: openMobile || isOpenDesktop ? "Close sidebar" : "Open sidebar", hotkey: `mod+${SIDEBAR_KEYBOARD_SHORTCUT}`, side: "right", sideOffset: 8 }}
|
|
345
|
+
onClick={handleClick}
|
|
346
|
+
{...props}
|
|
347
|
+
>
|
|
348
|
+
<PanelLeft className="h-4 w-4" />
|
|
349
|
+
<span className="sr-only">Toggle sidebar</span>
|
|
350
|
+
</Button>
|
|
360
351
|
)
|
|
361
352
|
})
|
|
362
353
|
SidebarTrigger.displayName = "SidebarTrigger"
|
|
@@ -57,7 +57,7 @@ const PopoverContent = React.forwardRef<
|
|
|
57
57
|
// (in the class list below) caps the whole panel to.
|
|
58
58
|
collisionPadding={collisionPadding}
|
|
59
59
|
className={cn(
|
|
60
|
-
"popover-panel z-[1400] w-72 rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-4 text-popover-foreground shadow-
|
|
60
|
+
"popover-panel z-[1400] w-72 rounded-[var(--radius-popover)] border bg-popover backdrop-blur-xl p-4 text-popover-foreground shadow-(--popup-shadow) outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
61
61
|
className
|
|
62
62
|
)}
|
|
63
63
|
{...props}
|
|
@@ -33,6 +33,17 @@ import { cn } from '../../../lib/utils';
|
|
|
33
33
|
|
|
34
34
|
// ─── Root ─────────────────────────────────────────────────────────────────────
|
|
35
35
|
|
|
36
|
+
// A menu, popover or listbox opened from inside the panel is portalled to <body>, so it is "outside" the panel in the DOM. While one is
|
|
37
|
+
// open, a press or Esc belongs to that layer (it closes itself); the panel must not also go. Without this, closing a "..." menu by
|
|
38
|
+
// clicking away or pressing Esc took the whole panel with it. A closing layer keeps `data-state="closed"` for its exit animation.
|
|
39
|
+
const NESTED_LAYER =
|
|
40
|
+
'[data-slot="popover-content"],[role="menu"],[role="listbox"],[data-radix-popper-content-wrapper]';
|
|
41
|
+
function nestedLayerOpen(): boolean {
|
|
42
|
+
return Array.from(document.querySelectorAll(NESTED_LAYER)).some(
|
|
43
|
+
(el) => el.getAttribute('data-state') !== 'closed' && !el.closest('[data-state="closed"]'),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
export interface SidePanelProps {
|
|
37
48
|
open: boolean;
|
|
38
49
|
onOpenChange: (open: boolean) => void;
|
|
@@ -56,6 +67,15 @@ export interface SidePanelProps {
|
|
|
56
67
|
* must not dismiss the thing they are reading from.
|
|
57
68
|
*/
|
|
58
69
|
closeOnOutsideClick?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Dim the page behind the panel. Default ``false`` (the page stays legible and live).
|
|
72
|
+
*
|
|
73
|
+
* For a panel that covers content the reader is not meant to work in while it is open (a chat that
|
|
74
|
+
* slides over the page because the window has no room for a column): the dimming says the page is
|
|
75
|
+
* behind it. It is a plain layer, not a modal: no focus trap, no scroll lock; a press on it closes
|
|
76
|
+
* the panel through ``closeOnOutsideClick``.
|
|
77
|
+
*/
|
|
78
|
+
backdrop?: boolean;
|
|
59
79
|
}
|
|
60
80
|
|
|
61
81
|
const SidePanel: React.FC<SidePanelProps> & {
|
|
@@ -66,7 +86,7 @@ const SidePanel: React.FC<SidePanelProps> & {
|
|
|
66
86
|
Body: typeof SidePanelBody;
|
|
67
87
|
Footer: typeof SidePanelFooter;
|
|
68
88
|
Close: typeof SidePanelClose;
|
|
69
|
-
} = ({ open, onOpenChange, children, side = 'right', closeOnEsc = true, closeOnOutsideClick = true }) => {
|
|
89
|
+
} = ({ open, onOpenChange, children, side = 'right', closeOnEsc = true, closeOnOutsideClick = true, backdrop = false }) => {
|
|
70
90
|
// The panel element, so the outside-click listener can ask "was this click
|
|
71
91
|
// inside?" — there is no backdrop to catch it for us.
|
|
72
92
|
const contentRef = React.useRef<HTMLDivElement | null>(null);
|
|
@@ -77,7 +97,8 @@ const SidePanel: React.FC<SidePanelProps> & {
|
|
|
77
97
|
React.useEffect(() => {
|
|
78
98
|
if (!open || !closeOnEsc) return;
|
|
79
99
|
const handler = (e: KeyboardEvent) => {
|
|
80
|
-
|
|
100
|
+
// Radix layers handle Esc first (capture phase) and mark it handled.
|
|
101
|
+
if (e.key === 'Escape' && !e.defaultPrevented && !nestedLayerOpen()) onOpenChange(false);
|
|
81
102
|
};
|
|
82
103
|
window.addEventListener('keydown', handler);
|
|
83
104
|
return () => window.removeEventListener('keydown', handler);
|
|
@@ -99,6 +120,7 @@ const SidePanel: React.FC<SidePanelProps> & {
|
|
|
99
120
|
|
|
100
121
|
const handler = (event: PointerEvent) => {
|
|
101
122
|
if (!armed) return;
|
|
123
|
+
if (nestedLayerOpen()) return;
|
|
102
124
|
const target = event.target as Node | null;
|
|
103
125
|
if (!target || contentRef.current?.contains(target)) return;
|
|
104
126
|
// A click inside any overlay the panel itself opened — a Select's
|
|
@@ -121,7 +143,7 @@ const SidePanel: React.FC<SidePanelProps> & {
|
|
|
121
143
|
};
|
|
122
144
|
}, [open, closeOnOutsideClick, onOpenChange]);
|
|
123
145
|
|
|
124
|
-
const contextValue = React.useMemo(() => ({ side, contentRef }), [side]);
|
|
146
|
+
const contextValue = React.useMemo(() => ({ side, contentRef, backdrop }), [side, backdrop]);
|
|
125
147
|
|
|
126
148
|
return (
|
|
127
149
|
<DrawerPrimitive.Root
|
|
@@ -152,6 +174,7 @@ SidePanel.displayName = 'SidePanel';
|
|
|
152
174
|
const SidePanelSideContext = React.createContext<{
|
|
153
175
|
side: 'right' | 'left';
|
|
154
176
|
contentRef?: React.MutableRefObject<HTMLDivElement | null>;
|
|
177
|
+
backdrop?: boolean;
|
|
155
178
|
}>({ side: 'right' });
|
|
156
179
|
|
|
157
180
|
// ─── Content ──────────────────────────────────────────────────────────────────
|
|
@@ -167,7 +190,7 @@ const SidePanelContent = React.forwardRef<
|
|
|
167
190
|
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
168
191
|
SidePanelContentProps
|
|
169
192
|
>(({ className, children, width = '440px', style, ...props }, ref) => {
|
|
170
|
-
const { side, contentRef } = React.useContext(SidePanelSideContext);
|
|
193
|
+
const { side, contentRef, backdrop } = React.useContext(SidePanelSideContext);
|
|
171
194
|
// Both refs always compose: the caller's, and the panel's own, which the
|
|
172
195
|
// outside-click listener measures against.
|
|
173
196
|
const composedRef = useComposedRefs(ref, contentRef ?? null);
|
|
@@ -176,6 +199,7 @@ const SidePanelContent = React.forwardRef<
|
|
|
176
199
|
|
|
177
200
|
return (
|
|
178
201
|
<DrawerPrimitive.Portal>
|
|
202
|
+
{backdrop ? <div aria-hidden="true" data-slot="side-panel-backdrop" className="fixed inset-0 z-499 bg-overlay animate-in fade-in-0" /> : null}
|
|
179
203
|
<DrawerPrimitive.Content
|
|
180
204
|
ref={composedRef}
|
|
181
205
|
aria-describedby={undefined}
|