@blenx-dev/core 0.1.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.
Files changed (172) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/LICENSE +21 -0
  3. package/package.json +49 -0
  4. package/src/DataTable/data-table-column-toggle.tsx +73 -0
  5. package/src/DataTable/data-table-empty.tsx +27 -0
  6. package/src/DataTable/data-table-error.tsx +25 -0
  7. package/src/DataTable/data-table-infinite-loader.tsx +73 -0
  8. package/src/DataTable/data-table-loading.tsx +67 -0
  9. package/src/DataTable/data-table-pagination.tsx +80 -0
  10. package/src/DataTable/data-table-toolbar.tsx +62 -0
  11. package/src/DataTable/data-table.css.ts +420 -0
  12. package/src/DataTable/data-table.tsx +507 -0
  13. package/src/DataTable/index.ts +24 -0
  14. package/src/DataTable/types.ts +169 -0
  15. package/src/DataTable/use-infinite-scroll.ts +67 -0
  16. package/src/components/Accordion/accordion.css.ts +84 -0
  17. package/src/components/Accordion/accordion.tsx +87 -0
  18. package/src/components/Accordion/index.ts +8 -0
  19. package/src/components/Alert/alert.css.ts +29 -0
  20. package/src/components/Alert/alert.tsx +40 -0
  21. package/src/components/Alert/index.ts +1 -0
  22. package/src/components/AlertDialog/alert-dialog.css.ts +62 -0
  23. package/src/components/AlertDialog/alert-dialog.tsx +199 -0
  24. package/src/components/AlertDialog/index.ts +1 -0
  25. package/src/components/AspectRatio/aspect-ratio.css.ts +7 -0
  26. package/src/components/AspectRatio/aspect-ratio.tsx +20 -0
  27. package/src/components/AspectRatio/index.ts +1 -0
  28. package/src/components/Autocomplete/autocomplete.css.ts +167 -0
  29. package/src/components/Autocomplete/autocomplete.tsx +226 -0
  30. package/src/components/Autocomplete/index.ts +1 -0
  31. package/src/components/Avatar/avatar.css.ts +65 -0
  32. package/src/components/Avatar/avatar.tsx +44 -0
  33. package/src/components/Avatar/index.ts +1 -0
  34. package/src/components/Badge/badge.css.ts +180 -0
  35. package/src/components/Badge/badge.tsx +47 -0
  36. package/src/components/Badge/index.ts +1 -0
  37. package/src/components/Box/box.css.ts +5 -0
  38. package/src/components/Box/box.tsx +21 -0
  39. package/src/components/Box/index.ts +1 -0
  40. package/src/components/Breadcrumbs/breadcrumbs.css.ts +72 -0
  41. package/src/components/Breadcrumbs/breadcrumbs.tsx +79 -0
  42. package/src/components/Breadcrumbs/index.ts +9 -0
  43. package/src/components/Button/button.css.ts +200 -0
  44. package/src/components/Button/button.tsx +55 -0
  45. package/src/components/Button/index.ts +1 -0
  46. package/src/components/Calendar/calendar.css.ts +187 -0
  47. package/src/components/Calendar/calendar.tsx +143 -0
  48. package/src/components/Calendar/index.ts +1 -0
  49. package/src/components/Card/card.tsx +32 -0
  50. package/src/components/Card/index.ts +1 -0
  51. package/src/components/Checkbox/checkbox.css.ts +76 -0
  52. package/src/components/Checkbox/checkbox.tsx +94 -0
  53. package/src/components/Checkbox/index.ts +1 -0
  54. package/src/components/CloseButton/close-button.css.ts +11 -0
  55. package/src/components/CloseButton/close-button.tsx +15 -0
  56. package/src/components/CloseButton/index.ts +2 -0
  57. package/src/components/ColorPicker/color-picker.tsx +123 -0
  58. package/src/components/ColorPicker/index.ts +1 -0
  59. package/src/components/ColorSwatch/color-swatch.tsx +21 -0
  60. package/src/components/ColorSwatch/index.ts +1 -0
  61. package/src/components/Combobox/combobox.css.ts +333 -0
  62. package/src/components/Combobox/combobox.tsx +350 -0
  63. package/src/components/Combobox/index.ts +1 -0
  64. package/src/components/Command/command.css.ts +130 -0
  65. package/src/components/Command/command.tsx +413 -0
  66. package/src/components/Command/index.ts +7 -0
  67. package/src/components/Container/container.css.ts +41 -0
  68. package/src/components/Container/container.tsx +25 -0
  69. package/src/components/Container/index.ts +1 -0
  70. package/src/components/CopyButton/copy-button.css.ts +11 -0
  71. package/src/components/CopyButton/copy-button.tsx +45 -0
  72. package/src/components/CopyButton/index.ts +2 -0
  73. package/src/components/DatePicker/date-picker.tsx +75 -0
  74. package/src/components/DatePicker/index.ts +1 -0
  75. package/src/components/Dialog/dialog.css.ts +57 -0
  76. package/src/components/Dialog/dialog.tsx +181 -0
  77. package/src/components/Dialog/index.ts +1 -0
  78. package/src/components/Drawer/drawer.css.ts +404 -0
  79. package/src/components/Drawer/drawer.tsx +573 -0
  80. package/src/components/Drawer/index.ts +1 -0
  81. package/src/components/Field/field.css.ts +35 -0
  82. package/src/components/Field/field.tsx +101 -0
  83. package/src/components/Field/index.ts +1 -0
  84. package/src/components/Grid/grid.css.ts +12 -0
  85. package/src/components/Grid/grid.tsx +32 -0
  86. package/src/components/Grid/index.ts +1 -0
  87. package/src/components/Icon/icon.css.ts +10 -0
  88. package/src/components/Icon/icon.tsx +15 -0
  89. package/src/components/Icon/index.ts +1 -0
  90. package/src/components/IconButton/icon-button.css.ts +6 -0
  91. package/src/components/IconButton/icon-button.tsx +11 -0
  92. package/src/components/IconButton/index.ts +2 -0
  93. package/src/components/Input/index.ts +1 -0
  94. package/src/components/Input/input.css.ts +72 -0
  95. package/src/components/Input/input.tsx +50 -0
  96. package/src/components/InputGroup/index.ts +1 -0
  97. package/src/components/InputGroup/input-group.css.ts +156 -0
  98. package/src/components/InputGroup/input-group.tsx +133 -0
  99. package/src/components/Menu/index.ts +1 -0
  100. package/src/components/Menu/menu.css.ts +121 -0
  101. package/src/components/Menu/menu.tsx +115 -0
  102. package/src/components/OTPField/index.ts +1 -0
  103. package/src/components/OTPField/otp-field.css.ts +54 -0
  104. package/src/components/OTPField/otp-field.tsx +46 -0
  105. package/src/components/Popover/index.ts +1 -0
  106. package/src/components/Popover/popover.css.ts +81 -0
  107. package/src/components/Popover/popover.tsx +113 -0
  108. package/src/components/Progress/index.ts +7 -0
  109. package/src/components/Progress/progress.css.ts +37 -0
  110. package/src/components/Progress/progress.tsx +62 -0
  111. package/src/components/Radio/index.ts +1 -0
  112. package/src/components/Radio/radio.css.ts +72 -0
  113. package/src/components/Radio/radio.tsx +49 -0
  114. package/src/components/ScrollArea/index.ts +1 -0
  115. package/src/components/ScrollArea/scroll-area.css.ts +79 -0
  116. package/src/components/ScrollArea/scroll-area.tsx +96 -0
  117. package/src/components/SegmentedControl/index.ts +1 -0
  118. package/src/components/SegmentedControl/segmented-control.tsx +42 -0
  119. package/src/components/Select/index.ts +1 -0
  120. package/src/components/Select/select.css.ts +182 -0
  121. package/src/components/Select/select.tsx +165 -0
  122. package/src/components/Separator/index.ts +1 -0
  123. package/src/components/Separator/separator.css.ts +59 -0
  124. package/src/components/Separator/separator.tsx +34 -0
  125. package/src/components/Sheet/index.ts +1 -0
  126. package/src/components/Sheet/sheet.css.ts +184 -0
  127. package/src/components/Sheet/sheet.tsx +215 -0
  128. package/src/components/Slider/index.ts +1 -0
  129. package/src/components/Slider/slider.css.ts +81 -0
  130. package/src/components/Slider/slider.tsx +100 -0
  131. package/src/components/Spinner/index.ts +1 -0
  132. package/src/components/Spinner/spinner.css.ts +17 -0
  133. package/src/components/Spinner/spinner.tsx +15 -0
  134. package/src/components/Splitter/index.ts +1 -0
  135. package/src/components/Splitter/splitter.css.ts +69 -0
  136. package/src/components/Splitter/splitter.tsx +521 -0
  137. package/src/components/Stack/index.ts +1 -0
  138. package/src/components/Stack/stack.css.ts +42 -0
  139. package/src/components/Stack/stack.tsx +32 -0
  140. package/src/components/Surface/index.ts +1 -0
  141. package/src/components/Surface/surface.css.ts +40 -0
  142. package/src/components/Surface/surface.tsx +19 -0
  143. package/src/components/Switch/index.ts +1 -0
  144. package/src/components/Switch/switch.css.ts +46 -0
  145. package/src/components/Switch/switch.tsx +25 -0
  146. package/src/components/Table/index.ts +2 -0
  147. package/src/components/Table/table.css.ts +71 -0
  148. package/src/components/Table/table.tsx +117 -0
  149. package/src/components/Tabs/index.ts +1 -0
  150. package/src/components/Tabs/tabs.css.ts +250 -0
  151. package/src/components/Tabs/tabs.tsx +119 -0
  152. package/src/components/Text/index.ts +2 -0
  153. package/src/components/Text/text.css.ts +118 -0
  154. package/src/components/Text/text.tsx +66 -0
  155. package/src/components/Textarea/index.ts +1 -0
  156. package/src/components/Textarea/textarea.css.ts +66 -0
  157. package/src/components/Textarea/textarea.tsx +48 -0
  158. package/src/components/Toggle/index.ts +1 -0
  159. package/src/components/Toggle/toggle.css.ts +91 -0
  160. package/src/components/Toggle/toggle.tsx +44 -0
  161. package/src/components/ToggleGroup/index.ts +1 -0
  162. package/src/components/ToggleGroup/toggle-group.css.ts +77 -0
  163. package/src/components/ToggleGroup/toggle-group.tsx +131 -0
  164. package/src/components/index.ts +54 -0
  165. package/src/index.ts +3 -0
  166. package/src/utils/drawer-styles.css.ts +85 -0
  167. package/src/utils/heights.ts +16 -0
  168. package/src/utils/sprinkles.css.ts +197 -0
  169. package/src/utils/sprinkles.tokens.ts +74 -0
  170. package/src/utils/types.ts +10 -0
  171. package/src/utils/ve-style.utils.ts +51 -0
  172. package/tsconfig.json +10 -0
@@ -0,0 +1,46 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
3
+
4
+ export const root = style({
5
+ width: tokenVars.spacing.xxl,
6
+ height: tokenVars.spacing.lg,
7
+ display: "inline-flex",
8
+ alignItems: "center",
9
+ padding: tokenVars.spacing.xxs,
10
+ borderRadius: tokenVars.borderRadius.full,
11
+ backgroundColor: semanticVars.border.default,
12
+ cursor: "pointer",
13
+ transitionProperty: "background-color",
14
+ transitionDuration: "150ms",
15
+ selectors: {
16
+ "&:focus-visible": {
17
+ outlineWidth: 2,
18
+ outlineStyle: "solid",
19
+ outlineColor: semanticVars.border.strong,
20
+ },
21
+ },
22
+ });
23
+
24
+ export const rootChecked = style({
25
+ backgroundColor: semanticVars.interactive.primary.default,
26
+ });
27
+
28
+ export const rootDisabled = style({
29
+ cursor: "not-allowed",
30
+ opacity: 0.35,
31
+ });
32
+
33
+ export const thumb = style({
34
+ width: tokenVars.spacing.lg,
35
+ height: tokenVars.spacing.lg,
36
+ borderRadius: tokenVars.borderRadius.full,
37
+ backgroundColor: semanticVars.interactive.primary.default,
38
+ transitionProperty: "transform, background-color",
39
+ transitionDuration: "150ms",
40
+ transform: "translateX(0)",
41
+ });
42
+
43
+ export const thumbChecked = style({
44
+ backgroundColor: semanticVars.surface.default,
45
+ transform: `translateX(${tokenVars.spacing.lg})`,
46
+ });
@@ -0,0 +1,25 @@
1
+ import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
2
+ import clsx from "clsx";
3
+ import { root, rootChecked, rootDisabled, thumb, thumbChecked } from "./switch.css";
4
+
5
+ type Props = Omit<SwitchPrimitive.Root.Props, "style" | "className"> & {
6
+ style?: React.CSSProperties;
7
+ className?: string;
8
+ };
9
+
10
+ export function Switch({ className, style, ...props }: Props) {
11
+ return (
12
+ <SwitchPrimitive.Root
13
+ {...props}
14
+ render={(renderProps, { checked, disabled }) => (
15
+ <span
16
+ {...renderProps}
17
+ className={clsx(root, checked && rootChecked, disabled && rootDisabled, className)}
18
+ style={style}
19
+ >
20
+ <SwitchPrimitive.Thumb className={clsx(thumb, checked && thumbChecked)} />
21
+ </span>
22
+ )}
23
+ />
24
+ );
25
+ }
@@ -0,0 +1,2 @@
1
+ export type { Column, TableProps } from "./table";
2
+ export { Table } from "./table";
@@ -0,0 +1,71 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
3
+
4
+ export const root = style({
5
+ width: "100%",
6
+ borderCollapse: "collapse",
7
+ color: semanticVars.text.secondary,
8
+ boxSizing: "border-box",
9
+ });
10
+
11
+ export const head = style({
12
+ backgroundColor: semanticVars.background.subtle,
13
+ });
14
+
15
+ export const header = style({
16
+ paddingTop: tokenVars.spacing.sm,
17
+ paddingBottom: tokenVars.spacing.sm,
18
+ paddingLeft: tokenVars.spacing.md,
19
+ paddingRight: tokenVars.spacing.md,
20
+ fontSize: tokenVars.fontSize.md,
21
+ fontWeight: 600,
22
+ color: semanticVars.text.secondary,
23
+ textAlign: "left",
24
+ textTransform: "uppercase",
25
+ letterSpacing: "0.05em",
26
+ borderBottomWidth: 1,
27
+ borderBottomStyle: "solid",
28
+ borderBottomColor: semanticVars.border.default,
29
+ whiteSpace: "nowrap",
30
+ userSelect: "none",
31
+ });
32
+
33
+ export const row = style({
34
+ transition: "background-color 0.15s ease",
35
+ selectors: {
36
+ "&:hover": {
37
+ backgroundColor: semanticVars.background.subtle,
38
+ },
39
+ },
40
+ });
41
+
42
+ export const cell = style({
43
+ paddingTop: tokenVars.spacing.sm,
44
+ paddingBottom: tokenVars.spacing.sm,
45
+ paddingLeft: tokenVars.spacing.md,
46
+ paddingRight: tokenVars.spacing.md,
47
+ fontSize: tokenVars.fontSize.md,
48
+ borderBottomWidth: 1,
49
+ borderBottomStyle: "solid",
50
+ borderBottomColor: semanticVars.border.subtle,
51
+ whiteSpace: "nowrap",
52
+ overflow: "hidden",
53
+ textOverflow: "ellipsis",
54
+ });
55
+
56
+ export const wrapper = style({
57
+ borderWidth: 1,
58
+ borderStyle: "solid",
59
+ borderColor: semanticVars.border.default,
60
+ borderRadius: tokenVars.borderRadius.default,
61
+ maxWidth: "100%",
62
+ overflowX: "auto",
63
+ });
64
+
65
+ export const alignLeft = style({ textAlign: "left" });
66
+ export const alignCenter = style({ textAlign: "center" });
67
+ export const alignRight = style({ textAlign: "right" });
68
+
69
+ export const colorSecondary = style({
70
+ color: semanticVars.text.secondary,
71
+ });
@@ -0,0 +1,117 @@
1
+ import clsx from "clsx";
2
+ import type { ReactNode } from "react";
3
+ import {
4
+ root,
5
+ head,
6
+ header,
7
+ cell,
8
+ wrapper,
9
+ alignLeft,
10
+ alignCenter,
11
+ alignRight,
12
+ colorSecondary,
13
+ } from "./table.css";
14
+ import * as tableCss from "./table.css";
15
+ import { Box } from "../Box";
16
+
17
+ export interface Column<TData> {
18
+ key: keyof TData;
19
+ header: ReactNode;
20
+ cell?: (row: TData) => ReactNode;
21
+ width?: string;
22
+ align?: "left" | "center" | "right";
23
+ cellProps?: Record<string, unknown>;
24
+ }
25
+
26
+ export interface TableProps<TData> {
27
+ columnData: Column<TData>[];
28
+ rowData: TData[];
29
+ rowKey?: keyof TData & string;
30
+ getRowProps?: (
31
+ row: TData,
32
+ index: number,
33
+ ) => {
34
+ onMouseEnter?: () => void;
35
+ onMouseLeave?: () => void;
36
+ style?: React.CSSProperties;
37
+ [key: string]: unknown;
38
+ };
39
+ style?: React.CSSProperties;
40
+ className?: string;
41
+ color?: "secondary";
42
+ }
43
+
44
+ const cellAlignMap = {
45
+ left: alignLeft,
46
+ center: alignCenter,
47
+ right: alignRight,
48
+ } as const;
49
+
50
+ function getCellValue<TData>(col: Column<TData>, row: TData): React.ReactNode {
51
+ if (col?.cell) {
52
+ return col.cell(row);
53
+ }
54
+ return row[col.key] as React.ReactNode;
55
+ }
56
+
57
+ export function Table<TData>({
58
+ columnData,
59
+ rowData,
60
+ rowKey,
61
+ getRowProps,
62
+ style,
63
+ className,
64
+ color,
65
+ }: TableProps<TData>) {
66
+ return (
67
+ <Box className={clsx(wrapper, color && colorSecondary, className)} style={style}>
68
+ <table className={clsx(root, color && colorSecondary)}>
69
+ <thead className={head}>
70
+ <tr>
71
+ {columnData.map((col) => (
72
+ <th
73
+ key={col.key.toString()}
74
+ style={col.width ? { width: col.width } : undefined}
75
+ className={clsx(header, col.align && cellAlignMap[col.align])}
76
+ >
77
+ {col.header}
78
+ </th>
79
+ ))}
80
+ </tr>
81
+ </thead>
82
+ <tbody>
83
+ {rowData.map((dataRow, index) => {
84
+ const key = rowKey ? (dataRow[rowKey] as string) : index.toString();
85
+ const rowProps = getRowProps?.(dataRow, index);
86
+ return (
87
+ <tr
88
+ key={key}
89
+ {...rowProps}
90
+ className={clsx(
91
+ tableCss.row,
92
+ (rowProps as Record<string, unknown> | undefined)?.className as
93
+ | string
94
+ | undefined,
95
+ )}
96
+ >
97
+ {columnData.map((col) => (
98
+ <td
99
+ key={col.key.toString()}
100
+ {...col.cellProps}
101
+ className={clsx(
102
+ cell,
103
+ col.align && cellAlignMap[col.align],
104
+ (col.cellProps?.className as string | undefined) || undefined,
105
+ )}
106
+ >
107
+ {getCellValue(col, dataRow)}
108
+ </td>
109
+ ))}
110
+ </tr>
111
+ );
112
+ })}
113
+ </tbody>
114
+ </table>
115
+ </Box>
116
+ );
117
+ }
@@ -0,0 +1 @@
1
+ export * from "./tabs";
@@ -0,0 +1,250 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
3
+
4
+ export const root = style({
5
+ display: "flex",
6
+ flexDirection: "column",
7
+ gap: tokenVars.spacing.md,
8
+ width: "100%",
9
+ border: "none",
10
+ backgroundColor: "transparent",
11
+ padding: 0,
12
+ borderRadius: 0,
13
+ outline: "none",
14
+ });
15
+
16
+ export const rootVertical = style({
17
+ flexDirection: "row",
18
+ alignItems: "flex-start",
19
+ gap: tokenVars.spacing.lg,
20
+ });
21
+
22
+ export const list = style({
23
+ position: "relative",
24
+ display: "flex",
25
+ overflow: "hidden",
26
+ border: "none",
27
+ outline: "none",
28
+ backgroundColor: "transparent",
29
+ padding: 0,
30
+ borderRadius: 0,
31
+ });
32
+
33
+ export const listDefault = style({
34
+ flexDirection: "row",
35
+ alignItems: "stretch",
36
+ gap: 0,
37
+ padding: 0,
38
+ backgroundColor: "transparent",
39
+ borderBottomWidth: 1,
40
+ borderBottomStyle: "solid",
41
+ borderBottomColor: semanticVars.border.subtle,
42
+ borderRadius: 0,
43
+ });
44
+
45
+ export const listUnderline = style({
46
+ display: "flex",
47
+ alignItems: "stretch",
48
+ gap: tokenVars.spacing.lg,
49
+ borderBottomWidth: 1,
50
+ borderBottomStyle: "solid",
51
+ borderBottomColor: semanticVars.border.subtle,
52
+ padding: 0,
53
+ });
54
+
55
+ export const listUnderlineVertical = style({
56
+ flexDirection: "column",
57
+ alignSelf: "auto",
58
+ alignItems: "stretch",
59
+ gap: 0,
60
+ padding: 0,
61
+ paddingRight: tokenVars.spacing.sm,
62
+ backgroundColor: "transparent",
63
+ borderRightWidth: 1,
64
+ borderRightStyle: "solid",
65
+ borderRightColor: semanticVars.border.subtle,
66
+ borderRadius: 0,
67
+ });
68
+
69
+ export const listVertical = style({
70
+ flexDirection: "column",
71
+ alignItems: "stretch",
72
+ minWidth: 220,
73
+ borderRightWidth: 1,
74
+ borderRightStyle: "solid",
75
+ borderRightColor: semanticVars.border.subtle,
76
+ });
77
+
78
+ export const tabActiveVertical = style({
79
+ color: semanticVars.text.primary,
80
+ fontWeight: tokenVars.fontWeight.semibold,
81
+ backgroundColor: semanticVars.background.subtle,
82
+ borderRightWidth: 2,
83
+ borderRightStyle: "solid",
84
+ borderRightColor: semanticVars.interactive.secondary.default,
85
+ });
86
+
87
+ export const tabUnderlineActive = style({
88
+ color: semanticVars.text.primary,
89
+ fontWeight: tokenVars.fontWeight.semibold,
90
+ borderBottomWidth: 2,
91
+ borderBottomStyle: "solid",
92
+ borderBottomColor: semanticVars.text.primary,
93
+ });
94
+
95
+ export const listGhost = style({
96
+ display: "flex",
97
+ gap: tokenVars.spacing.sm,
98
+ });
99
+
100
+ export const tabGhost = style({
101
+ padding: `${tokenVars.spacing.sm} ${tokenVars.spacing.md}`,
102
+ borderRadius: tokenVars.borderRadius.md,
103
+ color: semanticVars.text.secondary,
104
+ selectors: {
105
+ "&:hover": {
106
+ backgroundColor: semanticVars.background.subtle,
107
+ },
108
+ },
109
+ });
110
+
111
+ export const tabGhostActive = style({
112
+ backgroundColor: semanticVars.background.subtle,
113
+ color: semanticVars.text.primary,
114
+ fontWeight: tokenVars.fontWeight.semibold,
115
+ });
116
+
117
+ export const listSegmented = style({
118
+ display: "flex",
119
+ gap: tokenVars.spacing.xxs,
120
+ padding: tokenVars.spacing.xxs,
121
+ backgroundColor: semanticVars.background.subtle,
122
+ borderWidth: 1,
123
+ borderStyle: "solid",
124
+ borderColor: semanticVars.border.subtle,
125
+ borderRadius: tokenVars.borderRadius.lg,
126
+ });
127
+
128
+ export const tabSegmented = style({
129
+ padding: `${tokenVars.spacing.sm} ${tokenVars.spacing.md}`,
130
+ borderRadius: tokenVars.borderRadius.md,
131
+ color: semanticVars.text.secondary,
132
+ selectors: {
133
+ "&:hover": {
134
+ backgroundColor: semanticVars.surface.default,
135
+ },
136
+ },
137
+ });
138
+
139
+ export const tabSegmentedActive = style({
140
+ backgroundColor: semanticVars.surface.default,
141
+ color: semanticVars.interactive.primaryFg,
142
+ fontWeight: tokenVars.fontWeight.semibold,
143
+ });
144
+
145
+ export const tab = style({
146
+ position: "relative",
147
+ zIndex: 1,
148
+ display: "inline-flex",
149
+ alignItems: "center",
150
+ justifyContent: "center",
151
+ gap: tokenVars.spacing.xs,
152
+ minHeight: 36,
153
+ backgroundColor: "transparent",
154
+ cursor: "pointer",
155
+ appearance: "none",
156
+ outline: "none",
157
+ borderWidth: 0,
158
+ border: "none",
159
+ textDecoration: "none",
160
+ whiteSpace: "nowrap",
161
+ userSelect: "none",
162
+ font: "inherit",
163
+ fontFamily: tokenVars.font.body,
164
+ WebkitTapHighlightColor: "transparent",
165
+ transition: `color ${tokenVars.duration.normal} ${tokenVars.easing.standard}, background-color ${tokenVars.duration.normal} ${tokenVars.easing.standard}, box-shadow ${tokenVars.duration.normal} ${tokenVars.easing.standard}`,
166
+ });
167
+
168
+ export const tabDefault = style({
169
+ position: "relative",
170
+ padding: `${tokenVars.spacing.sm} ${tokenVars.spacing.md}`,
171
+ borderRadius: 0,
172
+ color: semanticVars.text.secondary,
173
+ fontSize: tokenVars.fontSize.sm,
174
+ fontWeight: tokenVars.fontWeight.medium,
175
+ lineHeight: 1.2,
176
+ minHeight: 40,
177
+ backgroundColor: "transparent",
178
+ selectors: {
179
+ "&:hover": {
180
+ color: semanticVars.text.primary,
181
+ backgroundColor: semanticVars.background.subtle,
182
+ },
183
+ "&:focus-visible": {
184
+ boxShadow: `inset 0 -2px 0 ${semanticVars.interactive.secondary}`,
185
+ },
186
+ },
187
+ });
188
+
189
+ export const tabVertical = style({
190
+ width: "100%",
191
+ justifyContent: "flex-start",
192
+ });
193
+
194
+ export const tabActive = style({
195
+ color: semanticVars.text.primary,
196
+ fontWeight: tokenVars.fontWeight.semibold,
197
+ });
198
+
199
+ export const tabDisabled = style({
200
+ opacity: 0.45,
201
+ cursor: "not-allowed",
202
+ });
203
+
204
+ export const tabActiveDefault = style({
205
+ color: semanticVars.text.primary,
206
+ fontWeight: tokenVars.fontWeight.semibold,
207
+ backgroundColor: "transparent",
208
+ borderBottomWidth: 2,
209
+ borderBottomStyle: "solid",
210
+ borderBottomColor: semanticVars.interactive.secondary.default,
211
+ });
212
+
213
+ export const tabUnderline = style({
214
+ padding: `${tokenVars.spacing.sm} 0`,
215
+ borderRadius: 0,
216
+ color: semanticVars.text.secondary,
217
+ fontSize: tokenVars.fontSize.sm,
218
+ fontWeight: tokenVars.fontWeight.medium,
219
+ backgroundColor: "transparent",
220
+ selectors: {
221
+ "&:hover": {
222
+ color: semanticVars.text.primary,
223
+ },
224
+ },
225
+ });
226
+
227
+ export const indicator = style({
228
+ position: "absolute",
229
+ pointerEvents: "none",
230
+ });
231
+
232
+ export const indicatorDefault = style({
233
+ display: "none",
234
+ });
235
+
236
+ export const indicatorUnderline = style({
237
+ zIndex: 0,
238
+ borderRadius: tokenVars.borderRadius.full,
239
+ backgroundColor: semanticVars.interactive.secondary.default,
240
+ });
241
+
242
+ export const panel = style({
243
+ minWidth: 0,
244
+ paddingTop: tokenVars.spacing.lg,
245
+ outline: "none",
246
+ });
247
+
248
+ export const panelVertical = style({
249
+ flex: 1,
250
+ });
@@ -0,0 +1,119 @@
1
+ import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
2
+ import clsx from "clsx";
3
+ import * as React from "react";
4
+ import {
5
+ root,
6
+ rootVertical,
7
+ list,
8
+ listUnderline,
9
+ listGhost,
10
+ listSegmented,
11
+ tab,
12
+ tabUnderline,
13
+ tabGhost,
14
+ tabSegmented,
15
+ tabVertical,
16
+ tabUnderlineActive,
17
+ tabGhostActive,
18
+ tabSegmentedActive,
19
+ tabDisabled,
20
+ panel,
21
+ panelVertical,
22
+ } from "./tabs.css";
23
+
24
+ type TabsVariant = "underline" | "ghost" | "segmented";
25
+
26
+ type TabsRootProps = TabsPrimitive.Root.Props & {
27
+ variant?: TabsVariant;
28
+ };
29
+
30
+ type TabsListProps = TabsPrimitive.List.Props;
31
+
32
+ type TabsTabProps = TabsPrimitive.Tab.Props;
33
+
34
+ type TabsPanelProps = TabsPrimitive.Panel.Props;
35
+
36
+ type TabsContextValue = {
37
+ variant: TabsVariant;
38
+ };
39
+
40
+ const DEFAULT_VARIANT: TabsVariant = "underline";
41
+
42
+ const TabsContext = React.createContext<TabsContextValue | null>(null);
43
+
44
+ function useTabsContext(): TabsContextValue {
45
+ return React.useContext(TabsContext) ?? { variant: DEFAULT_VARIANT };
46
+ }
47
+
48
+ export function Tabs({ children, variant = DEFAULT_VARIANT, ...props }: TabsRootProps) {
49
+ const contextValue = React.useMemo(() => ({ variant }), [variant]);
50
+
51
+ return (
52
+ <TabsContext.Provider value={contextValue}>
53
+ <TabsPrimitive.Root
54
+ className={(state) => clsx(root, state.orientation === "vertical" && rootVertical)}
55
+ {...props}
56
+ >
57
+ {children}
58
+ </TabsPrimitive.Root>
59
+ </TabsContext.Provider>
60
+ );
61
+ }
62
+
63
+ export function TabsList({ className, ...props }: TabsListProps) {
64
+ const { variant } = useTabsContext();
65
+
66
+ return (
67
+ <TabsPrimitive.List
68
+ className={clsx(
69
+ list,
70
+ variant === "underline" && listUnderline,
71
+ variant === "ghost" && listGhost,
72
+ variant === "segmented" && listSegmented,
73
+ className,
74
+ )}
75
+ {...props}
76
+ />
77
+ );
78
+ }
79
+
80
+ export function TabsTab({ className, ...props }: TabsTabProps) {
81
+ const { variant } = useTabsContext();
82
+
83
+ return (
84
+ <TabsPrimitive.Tab
85
+ className={(state) =>
86
+ clsx(
87
+ tab,
88
+ variant === "underline" && tabUnderline,
89
+ variant === "ghost" && tabGhost,
90
+ variant === "segmented" && tabSegmented,
91
+ state.orientation === "vertical" && tabVertical,
92
+ state.active && variant === "underline" && tabUnderlineActive,
93
+ state.active && variant === "ghost" && tabGhostActive,
94
+ state.active && variant === "segmented" && tabSegmentedActive,
95
+ state.disabled && tabDisabled,
96
+ className,
97
+ )
98
+ }
99
+ {...props}
100
+ />
101
+ );
102
+ }
103
+
104
+ export function TabsIndicator() {
105
+ return null;
106
+ }
107
+
108
+ function TabsPanel({ className, ...props }: TabsPanelProps) {
109
+ return (
110
+ <TabsPrimitive.Panel
111
+ className={(state) =>
112
+ clsx(panel, state.orientation === "vertical" && panelVertical, className)
113
+ }
114
+ {...props}
115
+ />
116
+ );
117
+ }
118
+
119
+ export { TabsPanel };
@@ -0,0 +1,2 @@
1
+ export { Text } from "./text";
2
+ export type { TextProps } from "./text";