@brightlocal/ui-components 3.4.0 → 3.5.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/AI_USAGE.md +22 -3
- package/README.md +177 -109
- package/component-meta.json +1061 -102
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +13 -2
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +4 -3
- package/dist/banner.cjs +1 -1
- package/dist/banner.d.ts +47 -11
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +156 -79
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +40 -5
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +59 -52
- package/dist/blocks/input-list.d.ts +1 -0
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +12 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +64 -63
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +47 -43
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +12 -0
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +115 -97
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -10
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +281 -296
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +430 -343
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -2
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +212 -207
- package/dist/count-indicator.cjs +1 -0
- package/dist/count-indicator.d.ts +85 -0
- package/dist/count-indicator.d.ts.map +1 -0
- package/dist/count-indicator.js +72 -0
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +101 -11
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +593 -523
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +26 -3
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +62 -47
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +8 -4
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +37 -38
- package/dist/file-upload.cjs +1 -0
- package/dist/file-upload.d.ts +546 -0
- package/dist/file-upload.d.ts.map +1 -0
- package/dist/file-upload.js +1103 -0
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +7 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +52 -52
- package/dist/hooks/use-file-dropzone.cjs +1 -0
- package/dist/hooks/use-file-dropzone.d.ts +75 -0
- package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
- package/dist/hooks/use-file-dropzone.js +133 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +29 -16
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +153 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +676 -640
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +30 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -115
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +37 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +131 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +6 -6
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.d.ts +27 -1
- package/dist/lib/empty-canvas.d.ts.map +1 -1
- package/dist/lib/empty-canvas.js +27 -23
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +19 -2
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +14 -9
- package/dist/lib/field-aria.cjs +1 -1
- package/dist/lib/field-aria.d.ts +4 -4
- package/dist/lib/field-aria.d.ts.map +1 -1
- package/dist/lib/field-aria.js +7 -5
- package/dist/lib/media-viewer-content.cjs +1 -1
- package/dist/lib/media-viewer-content.js +1 -1
- package/dist/lib/table-internal.cjs +1 -1
- package/dist/lib/table-internal.d.ts +19 -0
- package/dist/lib/table-internal.d.ts.map +1 -1
- package/dist/lib/table-internal.js +22 -7
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +13 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +103 -82
- package/dist/logo-mark.cjs +1 -1
- package/dist/logo-mark.d.ts +18 -2
- package/dist/logo-mark.d.ts.map +1 -1
- package/dist/logo-mark.js +159 -79
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.d.ts +50 -7
- package/dist/media-empty.d.ts.map +1 -1
- package/dist/media-empty.js +14 -13
- package/dist/media-viewer.cjs +1 -1
- package/dist/media-viewer.js +6 -6
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +92 -101
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +17 -17
- package/dist/relative-date.d.ts +6 -0
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/resizable.d.ts +1 -1
- package/dist/result-count.cjs +1 -1
- package/dist/result-count.d.ts +13 -16
- package/dist/result-count.d.ts.map +1 -1
- package/dist/result-count.js +24 -33
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +22 -3
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +152 -125
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +67 -76
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +77 -76
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +39 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +127 -76
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +34 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +115 -19
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +137 -131
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +6 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +14 -13
- package/package.json +3 -4
- package/src/blocks/empty-state.tsx +108 -48
- package/src/blocks/input-list.tsx +1 -0
- package/src/blocks/sidebar.tsx +39 -16
- package/src/components/alert-dialog.tsx +18 -2
- package/src/components/banner.tsx +247 -68
- package/src/components/button.tsx +27 -10
- package/src/components/card.tsx +89 -7
- package/src/components/chart.tsx +47 -67
- package/src/components/combobox.tsx +221 -12
- package/src/components/command.tsx +83 -37
- package/src/components/count-indicator.tsx +188 -0
- package/src/components/data-table.tsx +506 -159
- package/src/components/dialog.tsx +74 -5
- package/src/components/drawer.tsx +52 -32
- package/src/components/file-upload.tsx +2574 -0
- package/src/components/global-layout.tsx +18 -5
- package/src/components/hover-card.tsx +395 -65
- package/src/components/input-chip.tsx +67 -2
- package/src/components/input-group.tsx +89 -6
- package/src/components/list.tsx +40 -3
- package/src/components/logo-mark.tsx +109 -25
- package/src/components/media-empty.tsx +62 -7
- package/src/components/multi-select-filter.tsx +9 -16
- package/src/components/pagination.tsx +15 -2
- package/src/components/relative-date.tsx +6 -0
- package/src/components/result-count.tsx +27 -54
- package/src/components/sheet.tsx +86 -8
- package/src/components/single-select-filter.tsx +9 -16
- package/src/components/table.tsx +16 -1
- package/src/components/tabs.tsx +223 -41
- package/src/components/textarea.tsx +271 -4
- package/src/components/tooltip.tsx +29 -2
- package/src/components/typography-text.tsx +7 -2
- package/src/hooks/use-file-dropzone.ts +325 -0
- package/src/index.ts +3 -0
- package/src/lib/empty-canvas.tsx +47 -20
- package/src/lib/empty-chip.tsx +38 -3
- package/src/lib/field-aria.tsx +11 -6
- package/src/lib/table-internal.ts +38 -0
package/src/components/tabs.tsx
CHANGED
|
@@ -29,24 +29,79 @@ const TabsContext = React.createContext<TabsContextValue>({
|
|
|
29
29
|
variant: "default",
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Horizontal alignment of triggers inside the tab list.
|
|
34
|
+
* - `"start"` — triggers sit at the left edge (default for underline)
|
|
35
|
+
* - `"center"` — triggers are centred; falls back to start on overflow
|
|
36
|
+
* (default for pill)
|
|
37
|
+
*
|
|
38
|
+
* @deprecated No consumer uses this — the variant-aware defaults cover every
|
|
39
|
+
* real case. Will be removed in a future major. Use `className="justify-center"`
|
|
40
|
+
* if you need to override.
|
|
41
|
+
*/
|
|
42
|
+
type TabsListAlign = "start" | "center";
|
|
43
|
+
|
|
44
|
+
const tabsListVariants = cva(
|
|
45
|
+
[
|
|
46
|
+
"inline-flex max-w-full items-center",
|
|
47
|
+
// A row wider than its container scrolls sideways instead of widening
|
|
48
|
+
// the page (six tabs on a phone). Only an overflowing list becomes a
|
|
49
|
+
// scroll container (data-overflowing), because a scroll container clips
|
|
50
|
+
// the focus ring of a list that fits. The scrollbar stays hidden; touch,
|
|
51
|
+
// trackpad and arrow keys scroll the row. overscroll-x-contain is scoped
|
|
52
|
+
// to the list, so the page keeps its back/forward swipe gestures.
|
|
53
|
+
"overscroll-x-contain [scrollbar-width:none]",
|
|
54
|
+
"data-overflowing:overflow-x-auto data-overflowing:overflow-y-hidden",
|
|
55
|
+
],
|
|
56
|
+
{
|
|
57
|
+
variants: {
|
|
58
|
+
variant: {
|
|
59
|
+
default: "h-9 w-fit bg-muted rounded-lg p-1",
|
|
60
|
+
// The bottom rule is an inset shadow, not a border: a scrolling list
|
|
61
|
+
// clips at its padding box, so a border would cut the active
|
|
62
|
+
// underline in half.
|
|
63
|
+
underline:
|
|
64
|
+
"w-full gap-1 rounded-none shadow-[inset_0_-1px_0_var(--border)]",
|
|
65
|
+
},
|
|
66
|
+
align: {
|
|
67
|
+
start: "justify-start",
|
|
68
|
+
center: "justify-center-safe",
|
|
69
|
+
},
|
|
70
|
+
fullWidth: {
|
|
71
|
+
// Triggers share the row equally (basis-0 + grow) and wrap long labels
|
|
72
|
+
// inside their cell instead of overflowing or truncating.
|
|
73
|
+
true: [
|
|
74
|
+
"flex w-full items-stretch",
|
|
75
|
+
// wrap-anywhere breaks a single long word too, so it never spills
|
|
76
|
+
// into the next trigger.
|
|
77
|
+
"*:min-w-0 *:flex-1 *:basis-0 *:whitespace-normal *:wrap-anywhere *:text-center",
|
|
78
|
+
],
|
|
79
|
+
false: "",
|
|
80
|
+
},
|
|
37
81
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
82
|
+
compoundVariants: [
|
|
83
|
+
// The pill row grows with wrapped labels instead of clipping at 36px.
|
|
84
|
+
// py-0.5 keeps a one-line row at h-9: stretched triggers (30px tall)
|
|
85
|
+
// fit the 32px content box instead of pushing the row to 38px.
|
|
86
|
+
{
|
|
87
|
+
variant: "default",
|
|
88
|
+
fullWidth: true,
|
|
89
|
+
className: "h-auto min-h-9 py-0.5",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
defaultVariants: {
|
|
93
|
+
variant: "default",
|
|
94
|
+
fullWidth: false,
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
);
|
|
43
98
|
|
|
44
99
|
const tabsTriggerVariants = cva(
|
|
45
100
|
[
|
|
46
101
|
"inline-flex items-center justify-center gap-2",
|
|
47
102
|
"text-label whitespace-nowrap",
|
|
48
103
|
"cursor-pointer",
|
|
49
|
-
"
|
|
104
|
+
"outline-none",
|
|
50
105
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
51
106
|
],
|
|
52
107
|
{
|
|
@@ -64,13 +119,15 @@ const tabsTriggerVariants = cva(
|
|
|
64
119
|
"dark:data-[state=active]:border-white/15 dark:data-[state=active]:bg-white/5",
|
|
65
120
|
],
|
|
66
121
|
underline: [
|
|
67
|
-
"
|
|
122
|
+
"px-3 py-1.5",
|
|
68
123
|
"rounded-none border-b-2 border-transparent bg-transparent",
|
|
69
124
|
"first:rounded-l-none last:rounded-r-none",
|
|
70
125
|
"text-muted-foreground hover:bg-transparent hover:text-foreground",
|
|
71
126
|
"data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-foreground",
|
|
72
127
|
"transition-[color,border-color,box-shadow] duration-fast ease-out",
|
|
73
128
|
"focus-visible:rounded-md focus-visible:shadow-default",
|
|
129
|
+
"[&:focus:not(:focus-visible)]:shadow-none",
|
|
130
|
+
"[&[data-pointer-focus]:focus-visible]:shadow-none [&[data-pointer-focus]:focus-visible]:rounded-none",
|
|
74
131
|
],
|
|
75
132
|
},
|
|
76
133
|
},
|
|
@@ -100,9 +157,18 @@ interface TabsProps<T extends string = string> extends Omit<
|
|
|
100
157
|
* @default "default"
|
|
101
158
|
*/
|
|
102
159
|
variant?: TabsVariant;
|
|
103
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* Only mount a panel when its tab is first activated; once visited it stays
|
|
162
|
+
* mounted (hidden while inactive) unless `unmountOnExit` is also set.
|
|
163
|
+
* @default false
|
|
164
|
+
*/
|
|
104
165
|
lazyMount?: boolean;
|
|
105
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Unmount a panel's content when its tab becomes inactive. Off by default:
|
|
168
|
+
* inactive panels stay mounted and hidden, so form edits, scroll position
|
|
169
|
+
* and other local state survive a tab switch.
|
|
170
|
+
* @default false
|
|
171
|
+
*/
|
|
106
172
|
unmountOnExit?: boolean;
|
|
107
173
|
/** The controlled value of the active tab */
|
|
108
174
|
value?: T;
|
|
@@ -136,20 +202,20 @@ function TabsInner<T extends string = string>(
|
|
|
136
202
|
() => new Set(activeValue != null ? [activeValue] : [])
|
|
137
203
|
);
|
|
138
204
|
|
|
205
|
+
// Record the active tab as visited however it became active: a trigger
|
|
206
|
+
// click or a parent changing the controlled `value`. Updating state during
|
|
207
|
+
// render (guarded, so it settles in one pass) keeps the panel from being
|
|
208
|
+
// dropped when it is left.
|
|
209
|
+
if (lazyMount && activeValue != null && !visitedTabs.has(activeValue)) {
|
|
210
|
+
setVisitedTabs(new Set(visitedTabs).add(activeValue));
|
|
211
|
+
}
|
|
212
|
+
|
|
139
213
|
const handleValueChange = React.useCallback(
|
|
140
214
|
(newValue: string) => {
|
|
141
215
|
setInternalValue(newValue as T);
|
|
142
|
-
if (lazyMount) {
|
|
143
|
-
setVisitedTabs((prev) => {
|
|
144
|
-
if (prev.has(newValue)) return prev;
|
|
145
|
-
const next = new Set(prev);
|
|
146
|
-
next.add(newValue);
|
|
147
|
-
return next;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
216
|
onValueChange?.(newValue as T);
|
|
151
217
|
},
|
|
152
|
-
[
|
|
218
|
+
[onValueChange]
|
|
153
219
|
);
|
|
154
220
|
|
|
155
221
|
const contextValue = React.useMemo(
|
|
@@ -167,7 +233,11 @@ function TabsInner<T extends string = string>(
|
|
|
167
233
|
<TabsContext.Provider value={contextValue}>
|
|
168
234
|
<TabsPrimitive.Root
|
|
169
235
|
ref={ref}
|
|
170
|
-
className={cn(
|
|
236
|
+
className={cn(
|
|
237
|
+
"flex max-w-full min-w-0 flex-col",
|
|
238
|
+
variant === "underline" ? "gap-6" : "gap-2",
|
|
239
|
+
className
|
|
240
|
+
)}
|
|
171
241
|
data-hook={dataHook}
|
|
172
242
|
data-slot="tabs"
|
|
173
243
|
data-tracking-el={trackingEl}
|
|
@@ -192,6 +262,44 @@ const Tabs = React.forwardRef(TabsInner) as <T extends string = string>(
|
|
|
192
262
|
|
|
193
263
|
(Tabs as React.FC).displayName = "Tabs";
|
|
194
264
|
|
|
265
|
+
/**
|
|
266
|
+
* True while an element's children are wider than the element itself.
|
|
267
|
+
* Re-measures when the element or any child resizes, and when children are
|
|
268
|
+
* added or removed.
|
|
269
|
+
*/
|
|
270
|
+
function useHorizontalOverflow(element: HTMLElement | null) {
|
|
271
|
+
const [overflowing, setOverflowing] = React.useState(false);
|
|
272
|
+
|
|
273
|
+
React.useLayoutEffect(() => {
|
|
274
|
+
if (!element || typeof ResizeObserver === "undefined") return;
|
|
275
|
+
|
|
276
|
+
const measure = () =>
|
|
277
|
+
setOverflowing(element.scrollWidth > element.clientWidth + 1);
|
|
278
|
+
|
|
279
|
+
const resize = new ResizeObserver(measure);
|
|
280
|
+
const observeAll = () => {
|
|
281
|
+
resize.disconnect();
|
|
282
|
+
resize.observe(element);
|
|
283
|
+
for (const child of Array.from(element.children)) resize.observe(child);
|
|
284
|
+
};
|
|
285
|
+
const mutation = new MutationObserver(() => {
|
|
286
|
+
observeAll();
|
|
287
|
+
measure();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
observeAll();
|
|
291
|
+
mutation.observe(element, { childList: true });
|
|
292
|
+
measure();
|
|
293
|
+
|
|
294
|
+
return () => {
|
|
295
|
+
resize.disconnect();
|
|
296
|
+
mutation.disconnect();
|
|
297
|
+
};
|
|
298
|
+
}, [element]);
|
|
299
|
+
|
|
300
|
+
return overflowing;
|
|
301
|
+
}
|
|
302
|
+
|
|
195
303
|
/**
|
|
196
304
|
* Props for the TabsList component
|
|
197
305
|
*/
|
|
@@ -204,26 +312,72 @@ interface TabsListProps extends React.ComponentProps<
|
|
|
204
312
|
trackingEl?: string;
|
|
205
313
|
/** Tracking label for analytics context */
|
|
206
314
|
trackingLabel?: string;
|
|
315
|
+
/**
|
|
316
|
+
* Horizontal alignment of triggers inside the list.
|
|
317
|
+
* Defaults to `"start"` for the underline variant and `"center"` for the
|
|
318
|
+
* pill variant.
|
|
319
|
+
*
|
|
320
|
+
* @deprecated No consumer uses this — the variant-aware defaults cover every
|
|
321
|
+
* real case. Will be removed in a future major. Use `className` if you need
|
|
322
|
+
* to override alignment.
|
|
323
|
+
*/
|
|
324
|
+
align?: TabsListAlign;
|
|
325
|
+
/**
|
|
326
|
+
* Stretch the list to its container and give every trigger an equal share
|
|
327
|
+
* of the width. Long labels wrap inside their trigger; they never truncate.
|
|
328
|
+
* @default false
|
|
329
|
+
*/
|
|
330
|
+
fullWidth?: boolean;
|
|
207
331
|
}
|
|
208
332
|
|
|
209
333
|
const TabsList = React.forwardRef<
|
|
210
334
|
React.ComponentRef<typeof TabsPrimitive.List>,
|
|
211
335
|
TabsListProps
|
|
212
|
-
>(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
336
|
+
>(
|
|
337
|
+
(
|
|
338
|
+
{
|
|
339
|
+
className,
|
|
340
|
+
dataHook,
|
|
341
|
+
trackingEl,
|
|
342
|
+
trackingLabel,
|
|
343
|
+
align: alignProp,
|
|
344
|
+
fullWidth = false,
|
|
345
|
+
...props
|
|
346
|
+
},
|
|
347
|
+
ref
|
|
348
|
+
) => {
|
|
349
|
+
const { variant } = React.useContext(TabsContext);
|
|
350
|
+
const resolvedAlign =
|
|
351
|
+
alignProp ?? (variant === "underline" ? "start" : "center");
|
|
352
|
+
const [list, setList] = React.useState<HTMLDivElement | null>(null);
|
|
353
|
+
const overflowing = useHorizontalOverflow(list);
|
|
354
|
+
|
|
355
|
+
const setRefs = React.useCallback(
|
|
356
|
+
(node: HTMLDivElement | null) => {
|
|
357
|
+
setList(node);
|
|
358
|
+
if (typeof ref === "function") ref(node);
|
|
359
|
+
else if (ref) ref.current = node;
|
|
360
|
+
},
|
|
361
|
+
[ref]
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<TabsPrimitive.List
|
|
366
|
+
ref={setRefs}
|
|
367
|
+
className={cn(
|
|
368
|
+
tabsListVariants({ variant, align: resolvedAlign, fullWidth }),
|
|
369
|
+
className
|
|
370
|
+
)}
|
|
371
|
+
data-hook={dataHook}
|
|
372
|
+
data-overflowing={overflowing ? "" : undefined}
|
|
373
|
+
data-slot="tabs-list"
|
|
374
|
+
data-tracking-el={trackingEl}
|
|
375
|
+
data-tracking-label={trackingLabel}
|
|
376
|
+
{...props}
|
|
377
|
+
/>
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
);
|
|
227
381
|
|
|
228
382
|
TabsList.displayName = "TabsList";
|
|
229
383
|
|
|
@@ -252,12 +406,30 @@ function TabsTriggerInner<T extends string = string>(
|
|
|
252
406
|
dataHook,
|
|
253
407
|
trackingEl,
|
|
254
408
|
trackingLabel,
|
|
409
|
+
onPointerDown: onPointerDownProp,
|
|
410
|
+
onBlur: onBlurProp,
|
|
255
411
|
...props
|
|
256
412
|
}: TabsTriggerProps<T>,
|
|
257
413
|
ref: React.ForwardedRef<React.ComponentRef<typeof TabsPrimitive.Trigger>>
|
|
258
414
|
) {
|
|
259
415
|
const { variant } = React.useContext(TabsContext);
|
|
260
416
|
|
|
417
|
+
const handlePointerDown = React.useCallback(
|
|
418
|
+
(e: React.PointerEvent<HTMLButtonElement>) => {
|
|
419
|
+
e.currentTarget.setAttribute("data-pointer-focus", "");
|
|
420
|
+
onPointerDownProp?.(e);
|
|
421
|
+
},
|
|
422
|
+
[onPointerDownProp]
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
const handleBlur = React.useCallback(
|
|
426
|
+
(e: React.FocusEvent<HTMLButtonElement>) => {
|
|
427
|
+
e.currentTarget.removeAttribute("data-pointer-focus");
|
|
428
|
+
onBlurProp?.(e);
|
|
429
|
+
},
|
|
430
|
+
[onBlurProp]
|
|
431
|
+
);
|
|
432
|
+
|
|
261
433
|
return (
|
|
262
434
|
<TabsPrimitive.Trigger
|
|
263
435
|
ref={ref}
|
|
@@ -266,6 +438,8 @@ function TabsTriggerInner<T extends string = string>(
|
|
|
266
438
|
data-slot="tabs-trigger"
|
|
267
439
|
data-tracking-el={trackingEl}
|
|
268
440
|
data-tracking-label={trackingLabel}
|
|
441
|
+
onBlur={handleBlur}
|
|
442
|
+
onPointerDown={handlePointerDown}
|
|
269
443
|
{...props}
|
|
270
444
|
/>
|
|
271
445
|
);
|
|
@@ -315,7 +489,7 @@ function TabsContentInner<T extends string = string>(
|
|
|
315
489
|
|
|
316
490
|
const isActive = value === activeValue;
|
|
317
491
|
|
|
318
|
-
if (lazyMount && !visitedTabs.has(value)) {
|
|
492
|
+
if (lazyMount && !isActive && !visitedTabs.has(value)) {
|
|
319
493
|
return null;
|
|
320
494
|
}
|
|
321
495
|
|
|
@@ -326,11 +500,18 @@ function TabsContentInner<T extends string = string>(
|
|
|
326
500
|
return (
|
|
327
501
|
<TabsPrimitive.Content
|
|
328
502
|
ref={ref}
|
|
329
|
-
className={cn(
|
|
503
|
+
className={cn(
|
|
504
|
+
"flex-1 outline-none data-[state=inactive]:hidden",
|
|
505
|
+
className
|
|
506
|
+
)}
|
|
330
507
|
data-hook={dataHook}
|
|
331
508
|
data-slot="tabs-content"
|
|
332
509
|
data-tracking-el={trackingEl}
|
|
333
510
|
data-tracking-label={trackingLabel}
|
|
511
|
+
// Radix unmounts inactive content unless forceMount. Keep it mounted
|
|
512
|
+
// (unless unmountOnExit); the class above hides it with display: none,
|
|
513
|
+
// which also takes it out of the accessibility tree and the tab order.
|
|
514
|
+
forceMount={unmountOnExit ? undefined : true}
|
|
334
515
|
value={value}
|
|
335
516
|
{...props}
|
|
336
517
|
/>
|
|
@@ -351,6 +532,7 @@ export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
|
351
532
|
export type {
|
|
352
533
|
TabsProps,
|
|
353
534
|
TabsListProps,
|
|
535
|
+
TabsListAlign,
|
|
354
536
|
TabsTriggerProps,
|
|
355
537
|
TabsContentProps,
|
|
356
538
|
TabsVariant,
|