@jcsoftdev/ui 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/forms/input/input.js +5 -2
- package/dist/navigation/tabs/tabs.d.ts +2 -2
- package/dist/navigation/tabs/tabs.js +24 -1
- package/dist/overlays/dialog/dialog.d.ts +5 -0
- package/dist/overlays/dialog/dialog.js +18 -6
- package/dist/shell/topbar/topbar.js +2 -2
- package/package.json +2 -2
- package/src/forms/input/input.tsx +6 -1
- package/src/navigation/tabs/tabs.tsx +33 -1
- package/src/overlays/dialog/dialog.tsx +31 -13
- package/src/shell/topbar/topbar.tsx +2 -2
- package/styles/base.css +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.1 (2026-11-19)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- **Dialog keeps its actions and its close button in view.** `DialogHeader` and `DialogFooter` no longer shrink away (`shrink-0`) and `DialogBody` scrolls on its own (`min-h-0 flex-1 overflow-y-auto overscroll-contain`), so a long form keeps the title and the actions reachable. The footer pads for the bottom safe-area inset. The close button now sits in a zero-height sticky anchor, so it stays visible when content placed straight into `DialogContent` scrolls (it used to be absolutely positioned inside the scrolling element and scrolled away). It keeps its tab order, its `aria-label`, its `close` class part and its size, but it is now wrapped in a `div`, so a `[role=dialog] > button` selector no longer reaches it. Both rely on `DialogContent` staying a flex column (the default): a `grid` or `block` override, a `gap` or padding on it moves the anchor. Header and footer stay pinned when they are direct children of `DialogContent`, or of a wrapper such as a `<form>` that is itself `flex min-h-0 flex-col`. Content placed straight into `DialogContent` still scrolls as before.
|
|
8
|
+
- **Tabs: no stray focus ring after a click.** A tab focused by a click no longer shows the ring a previous keyboard focus carried over (`data-pointer-focus`, silenced in `@jcsoftdev/ui-tokens` `base.css` and cleared on the next key press or blur). Keyboard focus keeps its ring. A click on the tab strip's empty space no longer moves focus to the first tab or selects it.
|
|
9
|
+
- **Read-only inputs no longer look editable.** `Input` with `readOnly` drops its border and uses the sunken surface with secondary ink and a default cursor, on the bare input and on the wrapper that holds start or end adornments.
|
|
10
|
+
- **Topbar buttons reach 44px under touch.** The menu button and the search button use `min-h-(--touch-target)` (and `min-w-(--touch-target)` in the collapsed search), so they follow `data-density="touch"` and `data-density="auto"` on coarse pointers like the other controls.
|
|
11
|
+
|
|
3
12
|
## 0.10.0 (2026-11-15)
|
|
4
13
|
|
|
5
14
|
### Intent-aware components and accessibility
|
|
@@ -23,6 +23,8 @@ const CHROME = "rounded-input border-control bg-surface-control";
|
|
|
23
23
|
const TEXT = "min-w-0 text-control text-ink placeholder:text-ink-3";
|
|
24
24
|
const RING = "focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1";
|
|
25
25
|
const INVALID = "aria-[invalid=true]:border-danger";
|
|
26
|
+
const READ_ONLY = "[&[readonly]]:cursor-default [&[readonly]]:border-transparent [&[readonly]]:bg-surface-sunken [&[readonly]]:text-ink-2";
|
|
27
|
+
const READ_ONLY_WRAPPER = "has-[input[readonly]]:border-transparent has-[input[readonly]]:bg-surface-sunken has-[input[readonly]]:text-ink-2";
|
|
26
28
|
function Input({
|
|
27
29
|
size = "md",
|
|
28
30
|
variant = "default",
|
|
@@ -45,7 +47,7 @@ function Input({
|
|
|
45
47
|
bare ? [
|
|
46
48
|
height[size],
|
|
47
49
|
"bg-transparent outline-none focus-visible:outline-2 focus-visible:outline-accent-ink"
|
|
48
|
-
] : [CHROME, RING, INVALID, inputSizeClasses[size]],
|
|
50
|
+
] : [CHROME, RING, INVALID, READ_ONLY, inputSizeClasses[size]],
|
|
49
51
|
classNames?.input,
|
|
50
52
|
className
|
|
51
53
|
),
|
|
@@ -64,7 +66,8 @@ function Input({
|
|
|
64
66
|
bare ? "has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-accent-ink" : [
|
|
65
67
|
CHROME,
|
|
66
68
|
paddingX[size],
|
|
67
|
-
"focus-within:border-transparent focus-within:outline-2 focus-within:outline-accent-ink focus-within:-outline-offset-1 has-[input[aria-invalid=true]]:border-danger"
|
|
69
|
+
"focus-within:border-transparent focus-within:outline-2 focus-within:outline-accent-ink focus-within:-outline-offset-1 has-[input[aria-invalid=true]]:border-danger",
|
|
70
|
+
READ_ONLY_WRAPPER
|
|
68
71
|
],
|
|
69
72
|
"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50",
|
|
70
73
|
classNames?.root,
|
|
@@ -22,13 +22,13 @@ export interface TabsListProps extends ComponentPropsWithRef<"div"> {
|
|
|
22
22
|
/** Wraps arrow navigation around the ends. Defaults to `true`. */
|
|
23
23
|
loop?: boolean | undefined;
|
|
24
24
|
}
|
|
25
|
-
export declare function TabsList({ className, loop, ref, onFocus, ...props }: TabsListProps): import("react").JSX.Element;
|
|
25
|
+
export declare function TabsList({ className, loop, ref, onFocus, onMouseDown, ...props }: TabsListProps): import("react").JSX.Element;
|
|
26
26
|
export interface TabsTriggerProps extends Omit<ComponentPropsWithRef<"button">, "value">, IntentProps {
|
|
27
27
|
value: string;
|
|
28
28
|
/** Optional record count shown after the label. */
|
|
29
29
|
count?: number;
|
|
30
30
|
}
|
|
31
|
-
export declare function TabsTrigger({ className, count, children, value, disabled, onMouseDown, onKeyDown, onFocus, intent, intentKey, ref, ...props }: TabsTriggerProps): import("react").JSX.Element;
|
|
31
|
+
export declare function TabsTrigger({ className, count, children, value, disabled, onMouseDown, onKeyDown, onFocus, onBlur, intent, intentKey, ref, ...props }: TabsTriggerProps): import("react").JSX.Element;
|
|
32
32
|
export interface TabsContentProps extends Omit<ComponentPropsWithRef<"div">, "value">, IntentProps {
|
|
33
33
|
value: string;
|
|
34
34
|
/** Keeps the panel mounted (hidden) while inactive. */
|
|
@@ -12,6 +12,12 @@ import {
|
|
|
12
12
|
useRovingFocus
|
|
13
13
|
} from "../../utils/roving-focus.js";
|
|
14
14
|
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
15
|
+
const markPointerFocus = (element) => {
|
|
16
|
+
if (element) element.dataset.pointerFocus = "";
|
|
17
|
+
};
|
|
18
|
+
const clearPointerFocus = (element) => {
|
|
19
|
+
delete element.dataset.pointerFocus;
|
|
20
|
+
};
|
|
15
21
|
const TabsContext = createContext(null);
|
|
16
22
|
const TabsListContext = createContext(null);
|
|
17
23
|
function useTabsContext(part) {
|
|
@@ -47,7 +53,14 @@ function Tabs({
|
|
|
47
53
|
}
|
|
48
54
|
) });
|
|
49
55
|
}
|
|
50
|
-
function TabsList({
|
|
56
|
+
function TabsList({
|
|
57
|
+
className,
|
|
58
|
+
loop = true,
|
|
59
|
+
ref,
|
|
60
|
+
onFocus,
|
|
61
|
+
onMouseDown,
|
|
62
|
+
...props
|
|
63
|
+
}) {
|
|
51
64
|
const context = useTabsContext("TabsList");
|
|
52
65
|
const roving = useRovingFocus({
|
|
53
66
|
orientation: context.orientation,
|
|
@@ -66,6 +79,9 @@ function TabsList({ className, loop = true, ref, onFocus, ...props }) {
|
|
|
66
79
|
...props,
|
|
67
80
|
ref: composedRef,
|
|
68
81
|
onFocus: composeHandlers(onFocus, rovingOnFocus),
|
|
82
|
+
onMouseDown: composeHandlers(onMouseDown, (event) => {
|
|
83
|
+
if (event.target === event.currentTarget) event.preventDefault();
|
|
84
|
+
}),
|
|
69
85
|
className: cn(
|
|
70
86
|
"@container/tabs flex max-w-full gap-0.5 overflow-x-auto overscroll-x-contain border-b-divider px-2",
|
|
71
87
|
className
|
|
@@ -82,6 +98,7 @@ function TabsTrigger({
|
|
|
82
98
|
onMouseDown,
|
|
83
99
|
onKeyDown,
|
|
84
100
|
onFocus,
|
|
101
|
+
onBlur,
|
|
85
102
|
intent,
|
|
86
103
|
intentKey,
|
|
87
104
|
ref,
|
|
@@ -98,6 +115,7 @@ function TabsTrigger({
|
|
|
98
115
|
const item = getItemProps(value, {
|
|
99
116
|
disabled,
|
|
100
117
|
onKeyDown: composeHandlers(onKeyDown, (event) => {
|
|
118
|
+
clearPointerFocus(event.currentTarget);
|
|
101
119
|
if (disabled || event.target !== event.currentTarget) return;
|
|
102
120
|
if (event.key === " " || event.key === "Enter") context.setValue(value);
|
|
103
121
|
}),
|
|
@@ -121,8 +139,13 @@ function TabsTrigger({
|
|
|
121
139
|
...props,
|
|
122
140
|
...item,
|
|
123
141
|
ref: composedRef,
|
|
142
|
+
onBlur: composeHandlers(
|
|
143
|
+
onBlur,
|
|
144
|
+
(event) => clearPointerFocus(event.currentTarget)
|
|
145
|
+
),
|
|
124
146
|
onMouseDown: composeHandlers(onMouseDown, (event) => {
|
|
125
147
|
if (!disabled && event.button === 0 && !event.ctrlKey) {
|
|
148
|
+
markPointerFocus(event.currentTarget);
|
|
126
149
|
event.currentTarget.focus();
|
|
127
150
|
context.setValue(value);
|
|
128
151
|
} else {
|
|
@@ -33,6 +33,11 @@ export interface DialogContentProps extends DialogPrimitive.DialogContentProps,
|
|
|
33
33
|
/** Portal target. Defaults to `document.body`; pass an element to keep a scoped `data-style`. */
|
|
34
34
|
container?: HTMLElement | null;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Keep it a flex column (the default): the sticky close anchor and the pinned `DialogHeader` and
|
|
38
|
+
* `DialogFooter` rely on it. A wrapper between them and this element, such as a `<form>`, needs
|
|
39
|
+
* `flex min-h-0 flex-col` too.
|
|
40
|
+
*/
|
|
36
41
|
export declare function DialogContent({ className, classNames, width, material, blocking, closeLabel, container, children, onEscapeKeyDown, onPointerDownOutside, onInteractOutside, onCloseAutoFocus, intent, intentKey, ref, ...props }: DialogContentProps): import("react").JSX.Element;
|
|
37
42
|
/** Title above description at every width; pass `flex-row items-center` in `className` for a side-by-side layout. */
|
|
38
43
|
export declare function DialogHeader({ className, ...props }: ComponentPropsWithRef<"div">): import("react").JSX.Element;
|
|
@@ -87,18 +87,21 @@ function DialogContent({
|
|
|
87
87
|
ref: composedRef,
|
|
88
88
|
children: [
|
|
89
89
|
children,
|
|
90
|
-
!blocking &&
|
|
90
|
+
!blocking && // Zero-height sticky anchor: content that scrolls inside the dialog (anything not wrapped
|
|
91
|
+
// in `DialogBody`) cannot carry the close button away. `order-first` is visual only; the
|
|
92
|
+
// button stays last in the DOM and in the tab order.
|
|
93
|
+
/* @__PURE__ */ jsx("div", { className: "pointer-events-none sticky top-0 z-10 order-first h-0 shrink-0", children: /* @__PURE__ */ jsx(
|
|
91
94
|
DialogPrimitive.Close,
|
|
92
95
|
{
|
|
93
96
|
"aria-label": closeLabel ?? strings.close,
|
|
94
97
|
className: cn(
|
|
95
98
|
// A 30px square (44px under touch) centred where the 24px button was, so the glyph stays put.
|
|
96
|
-
"absolute top-[calc(0.5625rem-0.4375rem*var(--touch))] right-[calc(0.5625rem-0.4375rem*var(--touch))] flex size-control-sm items-center justify-center rounded-event text-ink-3 hover:text-ink",
|
|
99
|
+
"pointer-events-auto absolute top-[calc(0.5625rem-0.4375rem*var(--touch))] right-[calc(0.5625rem-0.4375rem*var(--touch))] flex size-control-sm items-center justify-center rounded-event text-ink-3 hover:text-ink",
|
|
97
100
|
classNames?.close
|
|
98
101
|
),
|
|
99
102
|
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "size-4" })
|
|
100
103
|
}
|
|
101
|
-
)
|
|
104
|
+
) })
|
|
102
105
|
]
|
|
103
106
|
}
|
|
104
107
|
)
|
|
@@ -108,7 +111,7 @@ function DialogHeader({ className, ...props }) {
|
|
|
108
111
|
return /* @__PURE__ */ jsx(
|
|
109
112
|
"div",
|
|
110
113
|
{
|
|
111
|
-
className: cn("flex flex-col gap-1 border-b-divider py-3.5 pr-10 pl-4.5", className),
|
|
114
|
+
className: cn("flex shrink-0 flex-col gap-1 border-b-divider py-3.5 pr-10 pl-4.5", className),
|
|
112
115
|
...props
|
|
113
116
|
}
|
|
114
117
|
);
|
|
@@ -132,14 +135,23 @@ function DialogDescription({
|
|
|
132
135
|
return /* @__PURE__ */ jsx(DialogPrimitive.Description, { className: cn("m-0 text-ink-2", className), ...props });
|
|
133
136
|
}
|
|
134
137
|
function DialogBody({ className, ...props }) {
|
|
135
|
-
return /* @__PURE__ */ jsx(
|
|
138
|
+
return /* @__PURE__ */ jsx(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: cn(
|
|
142
|
+
"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain p-4.5",
|
|
143
|
+
className
|
|
144
|
+
),
|
|
145
|
+
...props
|
|
146
|
+
}
|
|
147
|
+
);
|
|
136
148
|
}
|
|
137
149
|
function DialogFooter({ className, ...props }) {
|
|
138
150
|
return /* @__PURE__ */ jsx(
|
|
139
151
|
"div",
|
|
140
152
|
{
|
|
141
153
|
className: cn(
|
|
142
|
-
"flex flex-wrap items-center gap-2 border-t-divider px-4.5 py-3",
|
|
154
|
+
"flex shrink-0 flex-wrap items-center gap-2 border-t-divider px-4.5 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",
|
|
143
155
|
"@max-sm/dialog:flex-col-reverse @max-sm/dialog:items-stretch @max-sm/dialog:[&>*]:w-full",
|
|
144
156
|
className
|
|
145
157
|
),
|
|
@@ -68,7 +68,7 @@ function Topbar({
|
|
|
68
68
|
"aria-label": menuLabel,
|
|
69
69
|
onClick: onOpenMenu,
|
|
70
70
|
className: cn(
|
|
71
|
-
"hidden size-8.5 shrink-0 items-center justify-center rounded-control text-ink-2 hover:bg-surface-2 hover:text-ink @max-[900px]/app:inline-flex",
|
|
71
|
+
"hidden size-8.5 min-h-(--touch-target) min-w-(--touch-target) shrink-0 items-center justify-center rounded-control text-ink-2 hover:bg-surface-2 hover:text-ink @max-[900px]/app:inline-flex",
|
|
72
72
|
classNames?.menuButton
|
|
73
73
|
),
|
|
74
74
|
children: /* @__PURE__ */ jsx(Menu, { className: "size-5", "aria-hidden": "true" })
|
|
@@ -116,7 +116,7 @@ function Topbar({
|
|
|
116
116
|
"aria-label": searchLabel ?? searchPlaceholder,
|
|
117
117
|
onClick: onSearch,
|
|
118
118
|
className: cn(
|
|
119
|
-
"ml-auto flex h-8.5 w-[min(320px,38cqw)] shrink-0 items-center gap-2 rounded-input border-control bg-surface-control pr-2 pl-2.5 text-ink-3 text-meta @max-[700px]/topbar:w-8.5 @max-[700px]/topbar:justify-center @max-[700px]/topbar:px-0",
|
|
119
|
+
"ml-auto flex h-8.5 min-h-(--touch-target) w-[min(320px,38cqw)] shrink-0 items-center gap-2 rounded-input border-control bg-surface-control pr-2 pl-2.5 text-ink-3 text-meta @max-[700px]/topbar:w-8.5 @max-[700px]/topbar:min-w-(--touch-target) @max-[700px]/topbar:justify-center @max-[700px]/topbar:px-0",
|
|
120
120
|
classNames?.search
|
|
121
121
|
),
|
|
122
122
|
children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcsoftdev/ui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Token-driven React component library: React 19, Tailwind v4.",
|
|
5
5
|
"author": "jcsoftdev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"typescript": "^5.5.4",
|
|
103
103
|
"vite": "7.3.6",
|
|
104
104
|
"vitest": "4.1.11",
|
|
105
|
-
"@jcsoftdev/ui-tokens": "^0.10.
|
|
105
|
+
"@jcsoftdev/ui-tokens": "^0.10.1"
|
|
106
106
|
},
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"access": "public"
|
|
@@ -34,6 +34,10 @@ const TEXT = "min-w-0 text-control text-ink placeholder:text-ink-3";
|
|
|
34
34
|
const RING =
|
|
35
35
|
"focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1";
|
|
36
36
|
const INVALID = "aria-[invalid=true]:border-danger";
|
|
37
|
+
const READ_ONLY =
|
|
38
|
+
"[&[readonly]]:cursor-default [&[readonly]]:border-transparent [&[readonly]]:bg-surface-sunken [&[readonly]]:text-ink-2";
|
|
39
|
+
const READ_ONLY_WRAPPER =
|
|
40
|
+
"has-[input[readonly]]:border-transparent has-[input[readonly]]:bg-surface-sunken has-[input[readonly]]:text-ink-2";
|
|
37
41
|
|
|
38
42
|
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size">, IntentProps {
|
|
39
43
|
/**
|
|
@@ -80,7 +84,7 @@ export function Input({
|
|
|
80
84
|
height[size],
|
|
81
85
|
"bg-transparent outline-none focus-visible:outline-2 focus-visible:outline-accent-ink",
|
|
82
86
|
]
|
|
83
|
-
: [CHROME, RING, INVALID, inputSizeClasses[size]],
|
|
87
|
+
: [CHROME, RING, INVALID, READ_ONLY, inputSizeClasses[size]],
|
|
84
88
|
classNames?.input,
|
|
85
89
|
className,
|
|
86
90
|
)}
|
|
@@ -102,6 +106,7 @@ export function Input({
|
|
|
102
106
|
CHROME,
|
|
103
107
|
paddingX[size],
|
|
104
108
|
"focus-within:border-transparent focus-within:outline-2 focus-within:outline-accent-ink focus-within:-outline-offset-1 has-[input[aria-invalid=true]]:border-danger",
|
|
109
|
+
READ_ONLY_WRAPPER,
|
|
105
110
|
],
|
|
106
111
|
"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50",
|
|
107
112
|
classNames?.root,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
type ComponentPropsWithRef,
|
|
5
5
|
createContext,
|
|
6
|
+
type FocusEvent,
|
|
6
7
|
type KeyboardEvent,
|
|
7
8
|
type MouseEvent,
|
|
8
9
|
useContext,
|
|
@@ -18,6 +19,19 @@ import {
|
|
|
18
19
|
} from "../../utils/roving-focus.js";
|
|
19
20
|
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* A click focuses a tab by script, and a script focus inherits `:focus-visible` when
|
|
24
|
+
* the previous focus came from the keyboard, which would frame something that was only clicked.
|
|
25
|
+
* `data-pointer-focus` (silenced in `base.css`) marks that focus; the next key press or blur
|
|
26
|
+
* clears it so the ring stays for keyboard users.
|
|
27
|
+
*/
|
|
28
|
+
const markPointerFocus = (element: HTMLElement | null) => {
|
|
29
|
+
if (element) element.dataset.pointerFocus = "";
|
|
30
|
+
};
|
|
31
|
+
const clearPointerFocus = (element: HTMLElement) => {
|
|
32
|
+
delete element.dataset.pointerFocus;
|
|
33
|
+
};
|
|
34
|
+
|
|
21
35
|
type TabsActivationMode = "automatic" | "manual";
|
|
22
36
|
type GetItemProps = ReturnType<typeof useRovingFocus>["getItemProps"];
|
|
23
37
|
|
|
@@ -93,7 +107,14 @@ export interface TabsListProps extends ComponentPropsWithRef<"div"> {
|
|
|
93
107
|
loop?: boolean | undefined;
|
|
94
108
|
}
|
|
95
109
|
|
|
96
|
-
export function TabsList({
|
|
110
|
+
export function TabsList({
|
|
111
|
+
className,
|
|
112
|
+
loop = true,
|
|
113
|
+
ref,
|
|
114
|
+
onFocus,
|
|
115
|
+
onMouseDown,
|
|
116
|
+
...props
|
|
117
|
+
}: TabsListProps) {
|
|
97
118
|
const context = useTabsContext("TabsList");
|
|
98
119
|
const roving = useRovingFocus({
|
|
99
120
|
orientation: context.orientation,
|
|
@@ -113,6 +134,11 @@ export function TabsList({ className, loop = true, ref, onFocus, ...props }: Tab
|
|
|
113
134
|
{...props}
|
|
114
135
|
ref={composedRef}
|
|
115
136
|
onFocus={composeHandlers(onFocus, rovingOnFocus)}
|
|
137
|
+
onMouseDown={composeHandlers(onMouseDown, (event: MouseEvent<HTMLDivElement>) => {
|
|
138
|
+
// A click on the strip's own padding would focus the strip, and the roving focus would
|
|
139
|
+
// then move to (and select) the first tab. Focus stays where it was instead.
|
|
140
|
+
if (event.target === event.currentTarget) event.preventDefault();
|
|
141
|
+
})}
|
|
116
142
|
className={cn(
|
|
117
143
|
"@container/tabs flex max-w-full gap-0.5 overflow-x-auto overscroll-x-contain border-b-divider px-2",
|
|
118
144
|
className,
|
|
@@ -139,6 +165,7 @@ export function TabsTrigger({
|
|
|
139
165
|
onMouseDown,
|
|
140
166
|
onKeyDown,
|
|
141
167
|
onFocus,
|
|
168
|
+
onBlur,
|
|
142
169
|
intent,
|
|
143
170
|
intentKey,
|
|
144
171
|
ref,
|
|
@@ -156,6 +183,7 @@ export function TabsTrigger({
|
|
|
156
183
|
const item = getItemProps<HTMLButtonElement>(value, {
|
|
157
184
|
disabled,
|
|
158
185
|
onKeyDown: composeHandlers(onKeyDown, (event: KeyboardEvent<HTMLButtonElement>) => {
|
|
186
|
+
clearPointerFocus(event.currentTarget);
|
|
159
187
|
if (disabled || event.target !== event.currentTarget) return;
|
|
160
188
|
if (event.key === " " || event.key === "Enter") context.setValue(value);
|
|
161
189
|
}),
|
|
@@ -179,8 +207,12 @@ export function TabsTrigger({
|
|
|
179
207
|
{...props}
|
|
180
208
|
{...item}
|
|
181
209
|
ref={composedRef}
|
|
210
|
+
onBlur={composeHandlers(onBlur, (event: FocusEvent<HTMLButtonElement>) =>
|
|
211
|
+
clearPointerFocus(event.currentTarget),
|
|
212
|
+
)}
|
|
182
213
|
onMouseDown={composeHandlers(onMouseDown, (event: MouseEvent<HTMLButtonElement>) => {
|
|
183
214
|
if (!disabled && event.button === 0 && !event.ctrlKey) {
|
|
215
|
+
markPointerFocus(event.currentTarget);
|
|
184
216
|
event.currentTarget.focus();
|
|
185
217
|
context.setValue(value);
|
|
186
218
|
} else {
|
|
@@ -64,6 +64,11 @@ export interface DialogContentProps extends DialogPrimitive.DialogContentProps,
|
|
|
64
64
|
container?: HTMLElement | null;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Keep it a flex column (the default): the sticky close anchor and the pinned `DialogHeader` and
|
|
69
|
+
* `DialogFooter` rely on it. A wrapper between them and this element, such as a `<form>`, needs
|
|
70
|
+
* `flex min-h-0 flex-col` too.
|
|
71
|
+
*/
|
|
67
72
|
export function DialogContent({
|
|
68
73
|
className,
|
|
69
74
|
classNames,
|
|
@@ -124,16 +129,21 @@ export function DialogContent({
|
|
|
124
129
|
>
|
|
125
130
|
{children}
|
|
126
131
|
{!blocking && (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
// Zero-height sticky anchor: content that scrolls inside the dialog (anything not wrapped
|
|
133
|
+
// in `DialogBody`) cannot carry the close button away. `order-first` is visual only; the
|
|
134
|
+
// button stays last in the DOM and in the tab order.
|
|
135
|
+
<div className="pointer-events-none sticky top-0 z-10 order-first h-0 shrink-0">
|
|
136
|
+
<DialogPrimitive.Close
|
|
137
|
+
aria-label={closeLabel ?? strings.close}
|
|
138
|
+
className={cn(
|
|
139
|
+
// A 30px square (44px under touch) centred where the 24px button was, so the glyph stays put.
|
|
140
|
+
"pointer-events-auto absolute top-[calc(0.5625rem-0.4375rem*var(--touch))] right-[calc(0.5625rem-0.4375rem*var(--touch))] flex size-control-sm items-center justify-center rounded-event text-ink-3 hover:text-ink",
|
|
141
|
+
classNames?.close,
|
|
142
|
+
)}
|
|
143
|
+
>
|
|
144
|
+
<X aria-hidden="true" className="size-4" />
|
|
145
|
+
</DialogPrimitive.Close>
|
|
146
|
+
</div>
|
|
137
147
|
)}
|
|
138
148
|
</DialogPrimitive.Content>
|
|
139
149
|
</DialogPrimitive.Portal>
|
|
@@ -144,7 +154,7 @@ export function DialogContent({
|
|
|
144
154
|
export function DialogHeader({ className, ...props }: ComponentPropsWithRef<"div">) {
|
|
145
155
|
return (
|
|
146
156
|
<div
|
|
147
|
-
className={cn("flex flex-col gap-1 border-b-divider py-3.5 pr-10 pl-4.5", className)}
|
|
157
|
+
className={cn("flex shrink-0 flex-col gap-1 border-b-divider py-3.5 pr-10 pl-4.5", className)}
|
|
148
158
|
{...props}
|
|
149
159
|
/>
|
|
150
160
|
);
|
|
@@ -170,14 +180,22 @@ export function DialogDescription({
|
|
|
170
180
|
}
|
|
171
181
|
|
|
172
182
|
export function DialogBody({ className, ...props }: ComponentPropsWithRef<"div">) {
|
|
173
|
-
return
|
|
183
|
+
return (
|
|
184
|
+
<div
|
|
185
|
+
className={cn(
|
|
186
|
+
"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain p-4.5",
|
|
187
|
+
className,
|
|
188
|
+
)}
|
|
189
|
+
{...props}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
174
192
|
}
|
|
175
193
|
|
|
176
194
|
export function DialogFooter({ className, ...props }: ComponentPropsWithRef<"div">) {
|
|
177
195
|
return (
|
|
178
196
|
<div
|
|
179
197
|
className={cn(
|
|
180
|
-
"flex flex-wrap items-center gap-2 border-t-divider px-4.5 py-3",
|
|
198
|
+
"flex shrink-0 flex-wrap items-center gap-2 border-t-divider px-4.5 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",
|
|
181
199
|
"@max-sm/dialog:flex-col-reverse @max-sm/dialog:items-stretch @max-sm/dialog:[&>*]:w-full",
|
|
182
200
|
className,
|
|
183
201
|
)}
|
|
@@ -120,7 +120,7 @@ export function Topbar({
|
|
|
120
120
|
aria-label={menuLabel}
|
|
121
121
|
onClick={onOpenMenu}
|
|
122
122
|
className={cn(
|
|
123
|
-
"hidden size-8.5 shrink-0 items-center justify-center rounded-control text-ink-2 hover:bg-surface-2 hover:text-ink @max-[900px]/app:inline-flex",
|
|
123
|
+
"hidden size-8.5 min-h-(--touch-target) min-w-(--touch-target) shrink-0 items-center justify-center rounded-control text-ink-2 hover:bg-surface-2 hover:text-ink @max-[900px]/app:inline-flex",
|
|
124
124
|
classNames?.menuButton,
|
|
125
125
|
)}
|
|
126
126
|
>
|
|
@@ -169,7 +169,7 @@ export function Topbar({
|
|
|
169
169
|
aria-label={searchLabel ?? searchPlaceholder}
|
|
170
170
|
onClick={onSearch}
|
|
171
171
|
className={cn(
|
|
172
|
-
"ml-auto flex h-8.5 w-[min(320px,38cqw)] shrink-0 items-center gap-2 rounded-input border-control bg-surface-control pr-2 pl-2.5 text-ink-3 text-meta @max-[700px]/topbar:w-8.5 @max-[700px]/topbar:justify-center @max-[700px]/topbar:px-0",
|
|
172
|
+
"ml-auto flex h-8.5 min-h-(--touch-target) w-[min(320px,38cqw)] shrink-0 items-center gap-2 rounded-input border-control bg-surface-control pr-2 pl-2.5 text-ink-3 text-meta @max-[700px]/topbar:w-8.5 @max-[700px]/topbar:min-w-(--touch-target) @max-[700px]/topbar:justify-center @max-[700px]/topbar:px-0",
|
|
173
173
|
classNames?.search,
|
|
174
174
|
)}
|
|
175
175
|
>
|
package/styles/base.css
CHANGED
|
@@ -33,6 +33,11 @@ body {
|
|
|
33
33
|
outline-offset: var(--focus-ring-offset, 2px);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/* Tabs flags a clicked tab; intent outlines stay. */
|
|
37
|
+
[data-pointer-focus]:focus-visible:not([data-intent-highlight], [data-intent-changed]) {
|
|
38
|
+
outline-color: transparent;
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
@keyframes intent-highlight {
|
|
37
42
|
from {
|
|
38
43
|
background-color: var(--intent-highlight-tint, var(--accent-soft));
|