@softure-ai/theme-notion 0.10.3 → 0.11.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +70 -3
  3. package/dist/index.d.ts +5 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +5 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/messages/en.d.ts +17 -0
  8. package/dist/messages/en.d.ts.map +1 -1
  9. package/dist/messages/en.js +17 -0
  10. package/dist/messages/en.js.map +1 -1
  11. package/dist/messages/index.d.ts +17 -0
  12. package/dist/messages/index.d.ts.map +1 -1
  13. package/dist/notion/RouteLoading.d.ts +14 -0
  14. package/dist/notion/RouteLoading.d.ts.map +1 -0
  15. package/dist/notion/RouteLoading.js +11 -0
  16. package/dist/notion/RouteLoading.js.map +1 -0
  17. package/dist/notion/TopLoadingBar.d.ts +15 -0
  18. package/dist/notion/TopLoadingBar.d.ts.map +1 -0
  19. package/dist/notion/TopLoadingBar.js +10 -0
  20. package/dist/notion/TopLoadingBar.js.map +1 -0
  21. package/dist/notion/Upload.d.ts +64 -0
  22. package/dist/notion/Upload.d.ts.map +1 -0
  23. package/dist/notion/Upload.js +114 -0
  24. package/dist/notion/Upload.js.map +1 -0
  25. package/dist/notion/format-file-size.d.ts +3 -0
  26. package/dist/notion/format-file-size.d.ts.map +1 -0
  27. package/dist/notion/format-file-size.js +17 -0
  28. package/dist/notion/format-file-size.js.map +1 -0
  29. package/dist/ui/dialog.js +1 -1
  30. package/dist/ui/dialog.js.map +1 -1
  31. package/dist/ui/progress.d.ts.map +1 -1
  32. package/dist/ui/progress.js +17 -2
  33. package/dist/ui/progress.js.map +1 -1
  34. package/dist/ui/tabs-variants.d.ts +6 -0
  35. package/dist/ui/tabs-variants.d.ts.map +1 -0
  36. package/dist/ui/tabs-variants.js +26 -0
  37. package/dist/ui/tabs-variants.js.map +1 -0
  38. package/dist/ui/tabs.d.ts +3 -7
  39. package/dist/ui/tabs.d.ts.map +1 -1
  40. package/dist/ui/tabs.js +2 -25
  41. package/dist/ui/tabs.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/index.ts +16 -0
  44. package/src/messages/en.ts +17 -0
  45. package/src/notion/RouteLoading.tsx +34 -0
  46. package/src/notion/TopLoadingBar.tsx +28 -0
  47. package/src/notion/Upload.tsx +324 -0
  48. package/src/notion/format-file-size.ts +16 -0
  49. package/src/ui/dialog.tsx +1 -1
  50. package/src/ui/progress.tsx +18 -1
  51. package/src/ui/tabs-variants.ts +29 -0
  52. package/src/ui/tabs.tsx +3 -29
@@ -0,0 +1,324 @@
1
+ "use client";
2
+
3
+ import { CircleAlert, CircleCheck, Clock, File as FileIcon, Pause, Play, RotateCw, Upload as UploadIcon, X, type LucideIcon } from "lucide-react";
4
+ import { useId, useRef, useState, type DragEvent, type ReactNode } from "react";
5
+
6
+ import { en } from "../messages/en.js";
7
+ import { cn } from "../lib/utils.js";
8
+ import { Button } from "../ui/button.js";
9
+ import { Field, FieldDescription, FieldError, FieldLabel } from "../ui/field.js";
10
+ import { Progress } from "../ui/progress.js";
11
+
12
+ import { formatFileSize } from "./format-file-size.js";
13
+ import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
14
+ import type { PaletteColor } from "./palette.js";
15
+ import { Status } from "./Status.js";
16
+
17
+ export type UploadState = "queued" | "uploading" | "paused" | "done" | "failed";
18
+
19
+ /** One file of an upload, as the app or its transport (e.g. `@softure-ai/files`) tracks it. */
20
+ export interface UploadFileItem {
21
+ // Kept on the row as `data-upload`.
22
+ readonly id: string;
23
+ readonly name: string;
24
+ // In bytes.
25
+ readonly size: number;
26
+ readonly state: UploadState;
27
+ // 0–100, drawn while uploading or paused; clamped, and a non-finite value reads as 0.
28
+ readonly progress?: number;
29
+ // Why the upload failed, shown under a failed row.
30
+ readonly error?: string;
31
+ }
32
+
33
+ /** The texts of the upload parts; `{name}` stands for the file's name. Built-in English: `notionMessages.en.upload`. */
34
+ export interface UploadMessages {
35
+ readonly choose: string;
36
+ readonly chooseOne: string;
37
+ readonly drop: string;
38
+ readonly dropOne: string;
39
+ readonly dropping: string;
40
+ readonly retry: string;
41
+ readonly pause: string;
42
+ readonly resume: string;
43
+ readonly remove: string;
44
+ readonly progress: string;
45
+ // Each state's word, e.g. `failed`.
46
+ readonly queued: string;
47
+ readonly uploading: string;
48
+ readonly paused: string;
49
+ readonly done: string;
50
+ readonly failed: string;
51
+ }
52
+
53
+ /** The app's wording for the upload parts; each text left out keeps the built-in English one. */
54
+ export type UploadMessagesOverride = Partial<UploadMessages>;
55
+
56
+ function mergeMessages(override: UploadMessagesOverride | undefined): UploadMessages {
57
+ return { ...en.upload, ...override };
58
+ }
59
+
60
+ function fillName(template: string, name: string): string {
61
+ return template.replaceAll("{name}", name);
62
+ }
63
+
64
+ /** Whether a file matches an `accept` list (".pdf", "video/*", "image/png"), the way the browser's picker reads it. */
65
+ function isAccepted(file: File, accept: string | undefined): boolean {
66
+ if (accept === undefined || accept.trim() === "") return true;
67
+ const name = file.name.toLowerCase();
68
+ const type = file.type.toLowerCase();
69
+ return accept
70
+ .split(",")
71
+ .map((entry) => entry.trim().toLowerCase())
72
+ .filter((entry) => entry !== "")
73
+ .some((entry) => {
74
+ if (entry.startsWith(".")) return name.endsWith(entry);
75
+ if (entry.endsWith("/*")) return type.startsWith(entry.slice(0, -1));
76
+ return type === entry;
77
+ });
78
+ }
79
+
80
+ export interface UploadFieldProps {
81
+ // The field's visible label.
82
+ readonly label: ReactNode;
83
+ readonly description?: ReactNode;
84
+ // A message under the area, e.g. "Choose at least one file"; marks the field invalid.
85
+ readonly error?: ReactNode;
86
+ // Passed to the native file input: file types, several files, the camera on a phone.
87
+ readonly accept?: string;
88
+ readonly multiple?: boolean;
89
+ readonly capture?: "user" | "environment";
90
+ readonly disabled?: boolean;
91
+ // The files picked or dropped (those matching `accept`; only the first without `multiple`).
92
+ readonly onFilesSelected: (files: File[]) => void;
93
+ // Dropped files that do not match `accept`; the picker never offers them.
94
+ readonly onFilesRejected?: (files: File[]) => void;
95
+ readonly messages?: UploadMessagesOverride;
96
+ // The native input's id; generated when left out.
97
+ readonly id?: string;
98
+ readonly className?: string;
99
+ }
100
+
101
+ // A labelled area to add files: a touch-sized button opens the native picker (so a phone offers its files, photos and
102
+ // camera), and on a wide screen files can also be dropped on the area. It holds no files of its own: it hands each pick
103
+ // or drop to `onFilesSelected`, and the app or its transport keeps the list (`UploadList`).
104
+ export function UploadField({
105
+ label,
106
+ description,
107
+ error,
108
+ accept,
109
+ multiple = false,
110
+ capture,
111
+ disabled = false,
112
+ onFilesSelected,
113
+ onFilesRejected,
114
+ messages,
115
+ id,
116
+ className,
117
+ }: UploadFieldProps) {
118
+ const words = mergeMessages(messages);
119
+ const generatedId = useId();
120
+ const inputId = id ?? generatedId;
121
+ const descriptionId = `${inputId}-description`;
122
+ const errorId = `${inputId}-error`;
123
+ const inputRef = useRef<HTMLInputElement>(null);
124
+ const [isDragging, setIsDragging] = useState(false);
125
+ const isInvalid = error !== undefined && error !== null && error !== false;
126
+ const describedBy = [description === undefined ? undefined : descriptionId, isInvalid ? errorId : undefined].filter(Boolean).join(" ") || undefined;
127
+
128
+ const handOver = (files: File[]) => {
129
+ const accepted = files.filter((file) => isAccepted(file, accept));
130
+ const rejected = files.filter((file) => !isAccepted(file, accept));
131
+ const selected = multiple ? accepted : accepted.slice(0, 1);
132
+ if (selected.length > 0) onFilesSelected(selected);
133
+ if (rejected.length > 0) onFilesRejected?.(rejected);
134
+ };
135
+
136
+ const handleDragOver = (event: DragEvent<HTMLDivElement>) => {
137
+ if (disabled) return;
138
+ event.preventDefault();
139
+ event.dataTransfer.dropEffect = "copy";
140
+ setIsDragging(true);
141
+ };
142
+
143
+ const handleDragLeave = (event: DragEvent<HTMLDivElement>) => {
144
+ // Moving onto a child fires a leave on the area too; only leaving the area itself ends the highlight.
145
+ if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget)) return;
146
+ setIsDragging(false);
147
+ };
148
+
149
+ const handleDrop = (event: DragEvent<HTMLDivElement>) => {
150
+ if (disabled) return;
151
+ event.preventDefault();
152
+ setIsDragging(false);
153
+ handOver(Array.from(event.dataTransfer.files));
154
+ };
155
+
156
+ return (
157
+ <Field data-slot="upload-field" data-invalid={isInvalid || undefined} data-disabled={disabled || undefined} className={className}>
158
+ <FieldLabel htmlFor={inputId}>{label}</FieldLabel>
159
+ <div
160
+ data-slot="upload-drop-area"
161
+ data-dragging={isDragging || undefined}
162
+ onDragOver={handleDragOver}
163
+ onDragEnter={handleDragOver}
164
+ onDragLeave={handleDragLeave}
165
+ onDrop={handleDrop}
166
+ className={cn(
167
+ "flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-input p-4 text-center text-sm text-muted-foreground transition-colors duration-120",
168
+ "md:flex-row md:gap-3",
169
+ "data-[dragging=true]:border-primary data-[dragging=true]:bg-blue-bg",
170
+ "group-data-[invalid=true]/field:border-destructive group-data-[disabled=true]/field:opacity-50",
171
+ )}
172
+ >
173
+ <UploadIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className="hidden size-5 shrink-0 md:block" />
174
+ <Button
175
+ type="button"
176
+ variant="outline"
177
+ size="touch"
178
+ className="md:h-7"
179
+ disabled={disabled}
180
+ aria-describedby={describedBy}
181
+ onClick={() => inputRef.current?.click()}
182
+ >
183
+ <UploadIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className="md:hidden" />
184
+ {multiple ? words.choose : words.chooseOne}
185
+ </Button>
186
+ {/* A phone has nothing to drop, so the hint shows on a wide screen only. */}
187
+ <span data-slot="upload-drop-hint" aria-hidden="true" className="hidden md:inline">
188
+ {isDragging ? words.dropping : multiple ? words.drop : words.dropOne}
189
+ </span>
190
+ <input
191
+ ref={inputRef}
192
+ id={inputId}
193
+ type="file"
194
+ accept={accept}
195
+ multiple={multiple}
196
+ capture={capture}
197
+ disabled={disabled}
198
+ tabIndex={-1}
199
+ aria-describedby={describedBy}
200
+ aria-invalid={isInvalid || undefined}
201
+ className="sr-only"
202
+ onChange={(event) => {
203
+ handOver(Array.from(event.currentTarget.files ?? []));
204
+ // Cleared, so picking the same file again after removing it is a change too.
205
+ event.currentTarget.value = "";
206
+ }}
207
+ />
208
+ </div>
209
+ {description === undefined ? null : <FieldDescription id={descriptionId}>{description}</FieldDescription>}
210
+ {isInvalid ? <FieldError id={errorId}>{error}</FieldError> : null}
211
+ </Field>
212
+ );
213
+ }
214
+
215
+ export interface UploadListProps {
216
+ // The list's accessible name, e.g. "Files".
217
+ readonly label: string;
218
+ // `UploadItem` rows.
219
+ readonly children: ReactNode;
220
+ readonly className?: string;
221
+ }
222
+
223
+ // The files of an upload, one `UploadItem` per row.
224
+ export function UploadList({ label, children, className }: UploadListProps) {
225
+ return (
226
+ <ul aria-label={label} data-slot="upload-list" className={cn("flex flex-col gap-1", className)}>
227
+ {children}
228
+ </ul>
229
+ );
230
+ }
231
+
232
+ const STATE_STATUS: Readonly<Record<UploadState, { readonly color: PaletteColor; readonly icon: LucideIcon }>> = {
233
+ queued: { color: "gray", icon: Clock },
234
+ uploading: { color: "blue", icon: UploadIcon },
235
+ paused: { color: "orange", icon: Pause },
236
+ done: { color: "green", icon: CircleCheck },
237
+ failed: { color: "red", icon: CircleAlert },
238
+ };
239
+
240
+ function clampProgress(value: number | undefined): number {
241
+ if (value === undefined || !Number.isFinite(value)) return 0;
242
+ return Math.min(100, Math.max(0, value));
243
+ }
244
+
245
+ export interface UploadItemProps {
246
+ readonly item: UploadFileItem;
247
+ // Each button shows only with its callback: Retry on a failed row, Pause while uploading, Resume when paused.
248
+ readonly onRetry?: (item: UploadFileItem) => void;
249
+ readonly onPause?: (item: UploadFileItem) => void;
250
+ readonly onResume?: (item: UploadFileItem) => void;
251
+ readonly onRemove?: (item: UploadFileItem) => void;
252
+ // Formats the size, e.g. "de" writes "1,5 kB".
253
+ readonly locale?: string;
254
+ readonly messages?: UploadMessagesOverride;
255
+ readonly className?: string;
256
+ }
257
+
258
+ // One file of an upload: its name, size and state word, a progress bar while it uploads or waits paused, the reason and
259
+ // a Retry button when it failed, and a Remove button. The buttons are touch sized on a phone.
260
+ export function UploadItem({ item, onRetry, onPause, onResume, onRemove, locale = "en", messages, className }: UploadItemProps) {
261
+ const words = mergeMessages(messages);
262
+ const errorId = `${useId()}-error`;
263
+ const status = STATE_STATUS[item.state];
264
+ const hasProgress = item.state === "uploading" || item.state === "paused";
265
+ const hasError = item.state === "failed" && item.error !== undefined && item.error !== "";
266
+ return (
267
+ <li
268
+ data-slot="upload-item"
269
+ data-upload={item.id}
270
+ data-state={item.state}
271
+ className={cn("flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5", className)}
272
+ >
273
+ <FileIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
274
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
275
+ <div className="flex min-w-0 flex-wrap items-center gap-x-2">
276
+ <span data-slot="upload-item-name" title={item.name} className="min-w-0 truncate text-sm font-medium">
277
+ {item.name}
278
+ </span>
279
+ <span data-slot="upload-item-size" className="shrink-0 text-small text-muted-foreground tabular-nums">
280
+ {formatFileSize(item.size, locale)}
281
+ </span>
282
+ <Status color={status.color} icon={status.icon} className="shrink-0 text-small">
283
+ {words[item.state]}
284
+ </Status>
285
+ </div>
286
+ {hasProgress ? (
287
+ <Progress
288
+ value={clampProgress(item.progress)}
289
+ aria-label={fillName(words.progress, item.name)}
290
+ indicatorClassName={item.state === "paused" ? "bg-orange" : undefined}
291
+ />
292
+ ) : null}
293
+ {hasError ? (
294
+ <p id={errorId} data-slot="upload-item-error" className="text-small text-destructive">
295
+ {item.error}
296
+ </p>
297
+ ) : null}
298
+ </div>
299
+ <div data-slot="upload-item-actions" className="flex shrink-0 items-center gap-1">
300
+ {item.state === "failed" && onRetry !== undefined ? (
301
+ <Button type="button" variant="outline" size="touch" className="md:h-7" aria-describedby={hasError ? errorId : undefined} onClick={() => onRetry(item)}>
302
+ <RotateCw aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
303
+ {words.retry}
304
+ </Button>
305
+ ) : null}
306
+ {item.state === "uploading" && onPause !== undefined ? (
307
+ <ItemIconButton icon={Pause} label={fillName(words.pause, item.name)} onClick={() => onPause(item)} />
308
+ ) : null}
309
+ {item.state === "paused" && onResume !== undefined ? (
310
+ <ItemIconButton icon={Play} label={fillName(words.resume, item.name)} onClick={() => onResume(item)} />
311
+ ) : null}
312
+ {onRemove === undefined ? null : <ItemIconButton icon={X} label={fillName(words.remove, item.name)} onClick={() => onRemove(item)} />}
313
+ </div>
314
+ </li>
315
+ );
316
+ }
317
+
318
+ function ItemIconButton({ icon: Icon, label, onClick }: { readonly icon: LucideIcon; readonly label: string; readonly onClick: () => void }) {
319
+ return (
320
+ <Button type="button" variant="ghost" size="icon-touch" className="text-muted-foreground md:size-7" aria-label={label} title={label} onClick={onClick}>
321
+ <Icon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
322
+ </Button>
323
+ );
324
+ }
@@ -0,0 +1,16 @@
1
+ // A plain module (no "use client"), so a Server Component can call the formatter (issue #1005).
2
+ const SIZE_UNITS = ["kilobyte", "megabyte", "gigabyte", "terabyte"] as const;
3
+
4
+ /** A file size for people, in decimal steps (1 kB = 1000 bytes), written by the locale: `formatFileSize(1500)` is "1.5 kB". Safe on the server. */
5
+ export function formatFileSize(bytes: number, locale = "en"): string {
6
+ const size = Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
7
+ // Bytes in full ("820 bytes"): the short form of the unit is the bare word "byte" in English.
8
+ if (size < 1000) return new Intl.NumberFormat(locale, { style: "unit", unit: "byte", unitDisplay: "long" }).format(Math.round(size));
9
+ let value = size / 1000;
10
+ let unit = 0;
11
+ while (value >= 1000 && unit < SIZE_UNITS.length - 1) {
12
+ value /= 1000;
13
+ unit += 1;
14
+ }
15
+ return new Intl.NumberFormat(locale, { style: "unit", unit: SIZE_UNITS[unit], unitDisplay: "short", maximumFractionDigits: 1 }).format(value);
16
+ }
package/src/ui/dialog.tsx CHANGED
@@ -131,12 +131,12 @@ function DialogFooter({
131
131
  )}
132
132
  {...props}
133
133
  >
134
- {children}
135
134
  {showCloseButton && (
136
135
  <DialogPrimitive.Close asChild>
137
136
  <Button variant="outline">{closeLabel}</Button>
138
137
  </DialogPrimitive.Close>
139
138
  )}
139
+ {children}
140
140
  </div>
141
141
  )
142
142
  }
@@ -6,6 +6,22 @@ import { Progress as ProgressPrimitive } from "radix-ui"
6
6
 
7
7
  const FILL_CLASS = /(^|\s)bg-/
8
8
 
9
+ // Without a value the fill is a third of the track sliding across it for ever (tw-animate-css's exit slide, which
10
+ // adds to the `translate` that parks it left of the track); with reduced motion it stands still, full and faint.
11
+ const INDETERMINATE_CLASS = [
12
+ "data-[state=indeterminate]:w-1/3",
13
+ "data-[state=indeterminate]:-translate-x-full",
14
+ "data-[state=indeterminate]:animate-out",
15
+ "data-[state=indeterminate]:slide-out-to-right-[400%]",
16
+ "data-[state=indeterminate]:repeat-infinite",
17
+ "data-[state=indeterminate]:duration-1500",
18
+ "data-[state=indeterminate]:ease-in-out",
19
+ "motion-reduce:data-[state=indeterminate]:animate-none",
20
+ "motion-reduce:data-[state=indeterminate]:w-full",
21
+ "motion-reduce:data-[state=indeterminate]:translate-x-0",
22
+ "motion-reduce:data-[state=indeterminate]:opacity-50",
23
+ ].join(" ")
24
+
9
25
  function hasFillClass(className: string | undefined): boolean {
10
26
  return className !== undefined && FILL_CLASS.test(className)
11
27
  }
@@ -33,12 +49,13 @@ function Progress({
33
49
  data-slot="progress-indicator"
34
50
  className={cn(
35
51
  "h-full w-full flex-1 bg-primary transition-all",
52
+ INDETERMINATE_CLASS,
36
53
  // In dark the default fill is the lighter link blue, so it reaches 3:1 against its track; a fill colour of
37
54
  // the caller's own replaces both.
38
55
  !hasFillClass(indicatorClassName) && "dark:bg-link",
39
56
  indicatorClassName
40
57
  )}
41
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
58
+ style={value == null ? undefined : { transform: `translateX(-${100 - value}%)` }}
42
59
  />
43
60
  </ProgressPrimitive.Root>
44
61
  )
@@ -0,0 +1,29 @@
1
+ // The class builder of TabsList, in a plain module so a Server Component can call it (issue #1008).
2
+ import { cva } from "class-variance-authority"
3
+
4
+ export const tabsListVariants = cva(
5
+ "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",
6
+ {
7
+ variants: {
8
+ variant: {
9
+ default: "bg-muted",
10
+ line: "gap-1 bg-transparent",
11
+ },
12
+ size: {
13
+ default: "",
14
+ // The triggers set the height: a fixed one would cap them at 35 px.
15
+ touch: "group-data-[orientation=horizontal]/tabs:h-auto",
16
+ },
17
+ // Keeps to its container's width and scrolls sideways; the line variant keeps room for the active underline.
18
+ scrollable: {
19
+ false: "",
20
+ true: "relative w-full max-w-full min-w-0 justify-start overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:thin] group-data-[orientation=horizontal]/tabs:h-auto data-[variant=line]:pb-1.5 *:flex-none",
21
+ },
22
+ },
23
+ defaultVariants: {
24
+ variant: "line",
25
+ size: "default",
26
+ scrollable: false,
27
+ },
28
+ }
29
+ )
package/src/ui/tabs.tsx CHANGED
@@ -1,8 +1,9 @@
1
1
  "use client"
2
2
 
3
3
  import * as React from "react"
4
- import { cva, type VariantProps } from "class-variance-authority"
4
+ import type { VariantProps } from "class-variance-authority"
5
5
  import { cn } from "../lib/utils.js"
6
+ import { tabsListVariants } from "./tabs-variants.js"
6
7
  import { Tabs as TabsPrimitive } from "radix-ui"
7
8
 
8
9
  type TabsTriggerSize = "default" | "touch"
@@ -29,33 +30,6 @@ function Tabs({
29
30
  )
30
31
  }
31
32
 
32
- const tabsListVariants = cva(
33
- "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",
34
- {
35
- variants: {
36
- variant: {
37
- default: "bg-muted",
38
- line: "gap-1 bg-transparent",
39
- },
40
- size: {
41
- default: "",
42
- // The triggers set the height: a fixed one would cap them at 35 px.
43
- touch: "group-data-[orientation=horizontal]/tabs:h-auto",
44
- },
45
- // Keeps to its container's width and scrolls sideways; the line variant keeps room for the active underline.
46
- scrollable: {
47
- false: "",
48
- true: "relative w-full max-w-full min-w-0 justify-start overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:thin] group-data-[orientation=horizontal]/tabs:h-auto data-[variant=line]:pb-1.5 *:flex-none",
49
- },
50
- },
51
- defaultVariants: {
52
- variant: "line",
53
- size: "default",
54
- scrollable: false,
55
- },
56
- }
57
- )
58
-
59
33
  // Scrolls a scrollable list so its active trigger sits in the middle, now and whenever the active tab changes.
60
34
  function useCentredActiveTrigger(list: React.RefObject<HTMLDivElement | null>, isScrollable: boolean) {
61
35
  React.useEffect(() => {
@@ -145,4 +119,4 @@ function TabsContent({
145
119
  )
146
120
  }
147
121
 
148
- export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
122
+ export { Tabs, TabsList, TabsTrigger, TabsContent }