raft-ui 0.0.4 → 0.0.6

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 (114) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -1
  3. package/dist/button-CJqMhTPQ.mjs +621 -0
  4. package/dist/index-CpGciYPW.d.mts +267 -0
  5. package/dist/index.d.mts +90 -254
  6. package/dist/index.mjs +121 -628
  7. package/dist/wip.d.mts +133 -15
  8. package/dist/wip.mjs +289 -16
  9. package/package.json +5 -9
  10. package/src/components/alert-dialog/alert-dialog.tsx +215 -0
  11. package/src/components/alert-dialog/index.ts +30 -0
  12. package/src/components/avatar/avatar.tsx +3 -3
  13. package/src/components/avatar/index.ts +2 -2
  14. package/src/components/badge/badge.tsx +2 -2
  15. package/src/components/badge/index.ts +2 -2
  16. package/src/components/banner/banner.tsx +2 -2
  17. package/src/components/banner/index.ts +2 -2
  18. package/src/components/bottom-sheet/bottom-sheet.tsx +3 -3
  19. package/src/components/bottom-sheet/index.ts +2 -2
  20. package/src/components/button/button.tsx +7 -5
  21. package/src/components/button/index.ts +2 -2
  22. package/src/components/checkbox/checkbox-indicator.tsx +2 -2
  23. package/src/components/checkbox/checkbox.tsx +4 -4
  24. package/src/components/checkbox/index.ts +2 -2
  25. package/src/components/combobox/combobox.tsx +4 -4
  26. package/src/components/combobox/index.ts +1 -1
  27. package/src/components/context-menu/context-menu.tsx +4 -4
  28. package/src/components/context-menu/index.ts +2 -2
  29. package/src/components/conversation-preview-card/conversation-preview-card.tsx +2 -2
  30. package/src/components/conversation-preview-card/index.ts +2 -2
  31. package/src/components/description-list/description-list.tsx +2 -2
  32. package/src/components/description-list/index.ts +2 -2
  33. package/src/components/dialog/dialog.tsx +152 -0
  34. package/src/components/dialog/index.ts +26 -0
  35. package/src/components/dropdown-menu/dropdown-menu.tsx +7 -7
  36. package/src/components/dropdown-menu/index.ts +2 -2
  37. package/src/components/empty-state/empty-state.tsx +2 -2
  38. package/src/components/empty-state/index.ts +2 -2
  39. package/src/components/field/field.tsx +4 -4
  40. package/src/components/field/index.ts +2 -2
  41. package/src/components/inline-code/index.ts +2 -2
  42. package/src/components/inline-code/inline-code.tsx +9 -7
  43. package/src/components/input/index.ts +2 -2
  44. package/src/components/input/input.tsx +4 -4
  45. package/src/components/input-group/index.ts +2 -2
  46. package/src/components/input-group/input-group.tsx +5 -5
  47. package/src/components/kbd/index.ts +2 -2
  48. package/src/components/kbd/kbd.tsx +2 -2
  49. package/src/components/label/index.ts +2 -7
  50. package/src/components/label/label.tsx +2 -2
  51. package/src/components/lightbox/index.ts +2 -2
  52. package/src/components/lightbox/lightbox.tsx +3 -3
  53. package/src/components/list-item/index.ts +2 -2
  54. package/src/components/list-item/list-item.tsx +2 -2
  55. package/src/components/media-list-item/index.ts +2 -2
  56. package/src/components/media-list-item/media-list-item.tsx +4 -4
  57. package/src/components/notification-center/index.ts +2 -2
  58. package/src/components/notification-center/notification-center.tsx +5 -5
  59. package/src/components/panel-header/index.ts +2 -2
  60. package/src/components/panel-header/panel-header.tsx +2 -2
  61. package/src/components/popover/index.ts +2 -2
  62. package/src/components/popover/popover.tsx +3 -3
  63. package/src/components/preview-shell/index.ts +2 -2
  64. package/src/components/preview-shell/preview-shell.tsx +2 -2
  65. package/src/components/quoted-message-card/index.ts +2 -2
  66. package/src/components/quoted-message-card/quoted-message-card.tsx +3 -3
  67. package/src/components/radio-group/index.ts +2 -6
  68. package/src/components/radio-group/radio-group.tsx +4 -4
  69. package/src/components/section-header/index.ts +2 -2
  70. package/src/components/section-header/section-header.tsx +2 -2
  71. package/src/components/section-label/index.ts +2 -2
  72. package/src/components/section-label/section-label.tsx +2 -2
  73. package/src/components/segmented-control/index.ts +2 -2
  74. package/src/components/segmented-control/segmented-control.tsx +3 -3
  75. package/src/components/select/index.ts +2 -2
  76. package/src/components/select/select.tsx +4 -4
  77. package/src/components/separator/index.ts +2 -0
  78. package/src/components/separator/separator.tsx +40 -0
  79. package/src/components/spinner/index.ts +2 -2
  80. package/src/components/spinner/spinner.tsx +3 -3
  81. package/src/components/status/index.ts +2 -2
  82. package/src/components/status/status.tsx +2 -2
  83. package/src/components/tabs/index.ts +2 -2
  84. package/src/components/tabs/tabs.tsx +43 -9
  85. package/src/components/text/index.ts +2 -2
  86. package/src/components/text/text.tsx +2 -1
  87. package/src/components/textarea/index.ts +2 -2
  88. package/src/components/textarea/textarea.tsx +3 -3
  89. package/src/components/toggle-group/index.ts +2 -7
  90. package/src/components/toggle-group/toggle-group.tsx +3 -3
  91. package/src/components/tooltip/index.ts +2 -8
  92. package/src/components/tooltip/tooltip.tsx +42 -16
  93. package/src/index.ts +60 -57
  94. package/src/legacy/AvatarListRow.tsx +1 -1
  95. package/src/legacy/Checkbox.tsx +1 -1
  96. package/src/legacy/ConversationPreviewCard.tsx +1 -1
  97. package/src/legacy/DismissBackdrop.tsx +1 -1
  98. package/src/legacy/ExperimentalBadge.tsx +1 -1
  99. package/src/legacy/NotificationCenter.tsx +2 -2
  100. package/src/legacy/PanelHeader.tsx +1 -1
  101. package/src/legacy/QuotedMessageCard.tsx +1 -1
  102. package/src/legacy/ReorderablePanelTabs.tsx +6 -1
  103. package/src/legacy/SectionHeader.tsx +1 -1
  104. package/src/legacy/Spinner.tsx +1 -1
  105. package/src/legacy/SurfaceListItem.tsx +1 -1
  106. package/src/legacy/selection-popover.tsx +2 -2
  107. package/src/legacy/server-switcher-menu.tsx +2 -2
  108. package/src/lib/theme/theme-provider.tsx +1 -1
  109. package/src/lib/theme/use-theme.ts +1 -1
  110. package/src/styles.css +5 -6
  111. package/src/wip.ts +82 -24
  112. package/dist/styled-props-B3SNekJg.d.mts +0 -16
  113. package/dist/use-theme-Y_h1DKll.mjs +0 -34
  114. package/src/fonts/brutal.css +0 -2
@@ -0,0 +1,40 @@
1
+ import { Separator as BaseSeparator } from "@base-ui/react/separator";
2
+ import { tv } from "../../lib/tv";
3
+ import type { StyledProps } from "../../lib/styled-props";
4
+ import { useThemeFamily } from "../../lib/theme/use-theme";
5
+
6
+ const separator = tv({
7
+ base: [
8
+ "shrink-0",
9
+ "data-[orientation=horizontal]:w-full",
10
+ "data-[orientation=vertical]:self-stretch",
11
+ ],
12
+ variants: {
13
+ theme: {
14
+ brutal: [
15
+ "data-[orientation=horizontal]:h-0 data-[orientation=horizontal]:border-t-2 data-[orientation=horizontal]:border-black",
16
+ "data-[orientation=vertical]:w-0 data-[orientation=vertical]:border-l-2 data-[orientation=vertical]:border-black",
17
+ ],
18
+ elegant: [
19
+ "bg-line-muted",
20
+ "data-[orientation=horizontal]:h-px",
21
+ "data-[orientation=vertical]:w-px",
22
+ ],
23
+ },
24
+ },
25
+ });
26
+
27
+ export type SeparatorProps = StyledProps<BaseSeparator.Props>;
28
+
29
+ export function Separator({ className, orientation = "horizontal", ...props }: SeparatorProps) {
30
+ const theme = useThemeFamily();
31
+
32
+ return (
33
+ <BaseSeparator
34
+ data-slot="separator"
35
+ orientation={orientation}
36
+ className={separator({ theme, className })}
37
+ {...props}
38
+ />
39
+ );
40
+ }
@@ -1,2 +1,2 @@
1
- export { Spinner } from "./spinner.tsx";
2
- export type { SpinnerProps } from "./spinner.tsx";
1
+ export { Spinner } from "./spinner";
2
+ export type { SpinnerProps } from "./spinner";
@@ -1,8 +1,8 @@
1
1
  import { mergeProps } from "@base-ui/react/merge-props";
2
2
  import { useRender } from "@base-ui/react/use-render";
3
- import { tv, type VariantProps } from "../../lib/tv.ts";
4
- import { useThemeFamily } from "../../lib/theme/use-theme.ts";
5
- import type { WithoutChildren } from "../../lib/without-children.ts";
3
+ import { tv, type VariantProps } from "../../lib/tv";
4
+ import { useThemeFamily } from "../../lib/theme/use-theme";
5
+ import type { WithoutChildren } from "../../lib/without-children";
6
6
 
7
7
  const BRAILLE_SPINNER_STYLE = `
8
8
  @keyframes raft-braille-spinner {
@@ -1,2 +1,2 @@
1
- export { Status } from "./status.tsx";
2
- export type { StatusProps } from "./status.tsx";
1
+ export { Status } from "./status";
2
+ export type { StatusProps } from "./status";
@@ -1,7 +1,7 @@
1
1
  import { mergeProps } from "@base-ui/react/merge-props";
2
2
  import { useRender } from "@base-ui/react/use-render";
3
- import { tv, type VariantProps } from "../../lib/tv.ts";
4
- import { useThemeFamily } from "../../lib/theme/use-theme.ts";
3
+ import { tv, type VariantProps } from "../../lib/tv";
4
+ import { useThemeFamily } from "../../lib/theme/use-theme";
5
5
 
6
6
  const STATUS_STYLE = `
7
7
  @keyframes raft-status-pulse-background {
@@ -9,7 +9,7 @@ export {
9
9
  SortableTabsList,
10
10
  SortableTabsTab,
11
11
  useOrderedTabs,
12
- } from "./tabs.tsx";
12
+ } from "./tabs";
13
13
  export type {
14
14
  OrderedTabItem,
15
15
  SortableTabsListProps,
@@ -21,4 +21,4 @@ export type {
21
21
  TabsPanelProps,
22
22
  TabsProps,
23
23
  TabsTabProps,
24
- } from "./tabs.tsx";
24
+ } from "./tabs";
@@ -16,6 +16,7 @@ import {
16
16
  useSensor,
17
17
  useSensors,
18
18
  type DragEndEvent,
19
+ type DragStartEvent,
19
20
  } from "@dnd-kit/core";
20
21
  import {
21
22
  arrayMove,
@@ -23,9 +24,9 @@ import {
23
24
  SortableContext,
24
25
  useSortable,
25
26
  } from "@dnd-kit/sortable";
26
- import { tv, type VariantProps } from "../../lib/tv.ts";
27
- import type { StyledProps } from "../../lib/styled-props.ts";
28
- import { useThemeFamily } from "../../lib/theme/use-theme.ts";
27
+ import { tv, type VariantProps } from "../../lib/tv";
28
+ import type { StyledProps } from "../../lib/styled-props";
29
+ import { useThemeFamily } from "../../lib/theme/use-theme";
29
30
 
30
31
  const tabs = tv({
31
32
  slots: {
@@ -46,6 +47,7 @@ const tabs = tv({
46
47
  brutal: {
47
48
  list: [
48
49
  "flex w-max max-w-full overflow-x-auto border-2 border-line-strong bg-layer-panel",
50
+ "data-[sorting=true]:[overflow-x:hidden]",
49
51
  "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
50
52
  ],
51
53
  background: "hidden",
@@ -79,6 +81,8 @@ const tabs = tv({
79
81
  "group/tabs-list relative flex h-12 w-max max-w-full items-center gap-6 px-4",
80
82
  "overflow-x-auto overflow-y-hidden overscroll-contain whitespace-nowrap",
81
83
  "border-b border-line-muted",
84
+ "data-[sorting=true]:[overflow-x:hidden]",
85
+ "data-[sorting=true]:[&_[data-slot=tabs-indicator]]:opacity-0 data-[sorting=true]:[&_[data-slot=tabs-indicator]]:transition-none",
82
86
  "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
83
87
  ],
84
88
  background: ["pointer-events-none absolute inset-x-0 top-0 z-0 h-px bg-line-muted"],
@@ -112,6 +116,8 @@ const tabs = tv({
112
116
  "group/tabs-list relative isolate flex h-auto w-max max-w-full items-center gap-1",
113
117
  "overflow-x-auto overflow-y-visible overscroll-contain whitespace-nowrap",
114
118
  "p-px",
119
+ "data-[sorting=true]:[overflow-x:hidden]",
120
+ "data-[sorting=true]:[&_[data-slot=tabs-indicator]]:opacity-0 data-[sorting=true]:[&_[data-slot=tabs-indicator]]:transition-none",
115
121
  "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
116
122
  ],
117
123
  background: ["pointer-events-none absolute inset-0 z-0 rounded-[7px] bg-layer-muted"],
@@ -123,6 +129,11 @@ const tabs = tv({
123
129
  "data-[active]:text-[oklch(38%_.006_285)]",
124
130
  "data-[active]:hover:text-[oklch(38%_.006_285)]",
125
131
  "data-[active]:[&_[data-slot=tabs-label]]:text-[0.8125rem]",
132
+ "data-[reorderable=true]:data-[active]:bg-layer-panel",
133
+ "data-[reorderable=true]:data-[active]:shadow-[0_0_0_1px_oklch(0%_0_0/.1),0_1px_1px_-1px_oklch(0%_0_0/.04),0_1px_2px_oklch(0%_0_0/.03)]",
134
+ "group-has-[>[data-slot=tabs-background]]/tabs-list:data-[reorderable=true]:data-[active]:shadow-[0_0_0_1px_oklch(0%_0_0/.045),0_1px_1px_-1px_oklch(0%_0_0/.025),0_1px_2px_oklch(0%_0_0/.02)]",
135
+ "data-[dragging-active=true]:bg-layer-panel",
136
+ "data-[dragging-active=true]:shadow-[0_0_0_1px_oklch(0%_0_0/.1),0_1px_1px_-1px_oklch(0%_0_0/.04),0_1px_2px_oklch(0%_0_0/.03)]",
126
137
  "[&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0 [&_svg]:[stroke-width:1.5]",
127
138
  "[&_svg]:text-foreground-placeholder [&_svg]:transition-colors [&_svg]:duration-150 [&_svg]:ease-out",
128
139
  "hover:[&_svg]:text-[oklch(42%_.006_285)]",
@@ -145,6 +156,7 @@ const tabs = tv({
145
156
 
146
157
  type TabsReorderContextValue = {
147
158
  enabled: boolean;
159
+ activeId?: string | undefined;
148
160
  };
149
161
 
150
162
  const TabsReorderContext = createContext<TabsReorderContextValue>({ enabled: false });
@@ -152,7 +164,6 @@ const TabsValueContext = createContext<string | undefined>(undefined);
152
164
  type TabsListVariant = "default" | "underline";
153
165
 
154
166
  const TabsListVariantContext = createContext<TabsListVariant>("default");
155
- const REORDER_ENABLED_CONTEXT = { enabled: true } as const satisfies TabsReorderContextValue;
156
167
 
157
168
  export type TabsProps<T extends string = string> = StyledProps<
158
169
  Omit<BaseTabs.Root.Props, "defaultValue" | "onValueChange" | "value">
@@ -199,6 +210,7 @@ export type TabsListProps = StyledProps<BaseTabs.List.Props> & {
199
210
 
200
211
  export function TabsList({ className, children, variant = "default", ...props }: TabsListProps) {
201
212
  const theme = useThemeFamily();
213
+ const reorder = use(TabsReorderContext);
202
214
  const resolvedVariant = theme === "elegant" ? variant : "underline";
203
215
  const { list } = tabs({ theme, variant: resolvedVariant });
204
216
 
@@ -211,7 +223,7 @@ export function TabsList({ className, children, variant = "default", ...props }:
211
223
  {...props}
212
224
  >
213
225
  {children}
214
- {theme === "elegant" ? <TabsIndicator /> : null}
226
+ {theme === "elegant" && !reorder.enabled ? <TabsIndicator /> : null}
215
227
  </BaseTabs.List>
216
228
  </TabsListVariantContext.Provider>
217
229
  );
@@ -229,13 +241,25 @@ export function SortableTabsList<T extends string = string>({
229
241
  variant = "default",
230
242
  ...props
231
243
  }: SortableTabsListProps<T>) {
244
+ const [activeId, setActiveId] = useState<string | undefined>(undefined);
232
245
  const sensors = useSensors(
233
246
  useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
234
247
  useSensor(TouchSensor, { activationConstraint: { delay: 350, tolerance: 8 } }),
235
248
  );
236
249
  const tabIds = useMemo(() => value.map(String), [value]);
250
+ const reorderContext = useMemo(
251
+ () => ({ enabled: true, activeId }) as const satisfies TabsReorderContextValue,
252
+ [activeId],
253
+ );
254
+ const handleDragStart = useCallback(({ active }: DragStartEvent) => {
255
+ setActiveId(String(active.id));
256
+ }, []);
257
+ const handleDragCancel = useCallback(() => {
258
+ setActiveId(undefined);
259
+ }, []);
237
260
  const handleDragEnd = useCallback(
238
261
  ({ active, over }: DragEndEvent) => {
262
+ setActiveId(undefined);
239
263
  if (!over || active.id === over.id) return;
240
264
  const oldIndex = tabIds.indexOf(String(active.id));
241
265
  const newIndex = tabIds.indexOf(String(over.id));
@@ -246,10 +270,17 @@ export function SortableTabsList<T extends string = string>({
246
270
  );
247
271
 
248
272
  return (
249
- <DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
273
+ <DndContext
274
+ autoScroll={false}
275
+ sensors={sensors}
276
+ collisionDetection={closestCenter}
277
+ onDragStart={handleDragStart}
278
+ onDragCancel={handleDragCancel}
279
+ onDragEnd={handleDragEnd}
280
+ >
250
281
  <SortableContext items={tabIds} strategy={horizontalListSortingStrategy}>
251
- <TabsReorderContext.Provider value={REORDER_ENABLED_CONTEXT}>
252
- <TabsList variant={variant} {...props}>
282
+ <TabsReorderContext.Provider value={reorderContext}>
283
+ <TabsList variant={variant} {...props} data-sorting={activeId ? "true" : undefined}>
253
284
  {children}
254
285
  </TabsList>
255
286
  </TabsReorderContext.Provider>
@@ -273,10 +304,12 @@ export function SortableTabsTab<T extends string = string>({
273
304
  ...props
274
305
  }: SortableTabsTabProps<T>) {
275
306
  const reorder = use(TabsReorderContext);
307
+ const activeValue = use(TabsValueContext);
276
308
  const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
277
309
  id: value,
278
310
  disabled: !reorder.enabled,
279
311
  });
312
+ const isDraggingActive = isDragging && activeValue === String(value);
280
313
 
281
314
  if (!reorder.enabled) {
282
315
  return <TabsTabButton value={value} {...props} />;
@@ -295,10 +328,11 @@ export function SortableTabsTab<T extends string = string>({
295
328
  <TabsTabButton
296
329
  value={value}
297
330
  sortableRef={setNodeRef}
331
+ {...props}
332
+ data-dragging-active={isDraggingActive ? "true" : undefined}
298
333
  data-dragging-source={isDragging ? "true" : undefined}
299
334
  data-reorderable="true"
300
335
  style={style}
301
- {...props}
302
336
  {...sortableAttributes}
303
337
  {...listeners}
304
338
  />
@@ -1,2 +1,2 @@
1
- export { Text, TextHeading, TextMono, TextSans } from "./text.tsx";
2
- export type { TextHeadingProps, TextMonoProps, TextSansProps } from "./text.tsx";
1
+ export { Text, TextHeading, TextMono, TextSans } from "./text";
2
+ export type { TextHeadingProps, TextMonoProps, TextSansProps } from "./text";
@@ -1,12 +1,13 @@
1
1
  import { mergeProps } from "@base-ui/react/merge-props";
2
2
  import { useRender } from "@base-ui/react/use-render";
3
- import { tv, type VariantProps } from "../../lib/tv.ts";
3
+ import { tv, type VariantProps } from "../../lib/tv";
4
4
 
5
5
  const textColorVariants = {
6
6
  default: ["text-foreground-strong"],
7
7
  primary: ["text-primary-700"],
8
8
  information: ["text-info-dark"],
9
9
  muted: ["text-foreground-muted"],
10
+ placeholder: ["text-foreground-placeholder"],
10
11
  accent: ["text-accent-700"],
11
12
  success: ["text-success-base"],
12
13
  warning: ["text-warning-base"],
@@ -1,2 +1,2 @@
1
- export { Textarea, TextareaCounter, TextareaGroup } from "./textarea.tsx";
2
- export type { TextareaCounterProps, TextareaGroupProps, TextareaProps } from "./textarea.tsx";
1
+ export { Textarea, TextareaCounter, TextareaGroup } from "./textarea";
2
+ export type { TextareaCounterProps, TextareaGroupProps, TextareaProps } from "./textarea";
@@ -1,7 +1,7 @@
1
1
  import type { ComponentPropsWithRef } from "react";
2
- import { tv } from "../../lib/tv.ts";
3
- import { useThemeFamily } from "../../lib/theme/use-theme.ts";
4
- import type { WithoutChildren } from "../../lib/without-children.ts";
2
+ import { tv } from "../../lib/tv";
3
+ import { useThemeFamily } from "../../lib/theme/use-theme";
4
+ import type { WithoutChildren } from "../../lib/without-children";
5
5
 
6
6
  const textarea = tv({
7
7
  slots: {
@@ -1,12 +1,7 @@
1
- export {
2
- ToggleGroup,
3
- ToggleGroupCount,
4
- ToggleGroupItem,
5
- ToggleGroupLabel,
6
- } from "./toggle-group.tsx";
1
+ export { ToggleGroup, ToggleGroupCount, ToggleGroupItem, ToggleGroupLabel } from "./toggle-group";
7
2
  export type {
8
3
  ToggleGroupCountProps,
9
4
  ToggleGroupItemProps,
10
5
  ToggleGroupLabelProps,
11
6
  ToggleGroupProps,
12
- } from "./toggle-group.tsx";
7
+ } from "./toggle-group";
@@ -1,9 +1,9 @@
1
1
  import type { ComponentPropsWithRef } from "react";
2
2
  import { Toggle as BaseToggle } from "@base-ui/react/toggle";
3
3
  import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
4
- import { tv, type VariantProps } from "../../lib/tv.ts";
5
- import type { StyledProps } from "../../lib/styled-props.ts";
6
- import { useThemeFamily } from "../../lib/theme/use-theme.ts";
4
+ import { tv, type VariantProps } from "../../lib/tv";
5
+ import type { StyledProps } from "../../lib/styled-props";
6
+ import { useThemeFamily } from "../../lib/theme/use-theme";
7
7
 
8
8
  const toggleGroup = tv({
9
9
  slots: {
@@ -1,14 +1,8 @@
1
- export {
2
- Tooltip,
3
- TooltipContent,
4
- TooltipPortal,
5
- TooltipProvider,
6
- TooltipTrigger,
7
- } from "./tooltip.tsx";
1
+ export { Tooltip, TooltipContent, TooltipPortal, TooltipProvider, TooltipTrigger } from "./tooltip";
8
2
  export type {
9
3
  TooltipContentProps,
10
4
  TooltipPortalProps,
11
5
  TooltipProps,
12
6
  TooltipProviderProps,
13
7
  TooltipTriggerProps,
14
- } from "./tooltip.tsx";
8
+ } from "./tooltip";
@@ -1,16 +1,16 @@
1
1
  import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
2
2
  import type { ComponentProps } from "react";
3
- import { tv } from "../../lib/tv.ts";
4
- import type { StyledProps } from "../../lib/styled-props.ts";
5
- import { useThemeFamily } from "../../lib/theme/use-theme.ts";
3
+ import { tv, type VariantProps } from "../../lib/tv";
4
+ import type { StyledProps } from "../../lib/styled-props";
5
+ import { useThemeFamily } from "../../lib/theme/use-theme";
6
6
 
7
7
  const tooltip = tv({
8
8
  slots: {
9
9
  trigger: ["select-none"],
10
10
  positioner: ["isolate z-50 outline-none"],
11
11
  content: [
12
- "relative inline-flex max-w-xs items-center gap-1.5 px-2.5 py-1.5",
13
- "text-xs leading-4 whitespace-normal",
12
+ "relative inline-flex max-w-xs items-center gap-1.5 px-3 py-2",
13
+ "text-[13px] leading-[18px] whitespace-normal",
14
14
  "origin-[var(--transform-origin)] outline-none",
15
15
  "transition-[opacity,transform] duration-100",
16
16
  "data-[starting-style]:scale-95 data-[starting-style]:opacity-0",
@@ -46,16 +46,31 @@ const tooltip = tv({
46
46
  elegant: {
47
47
  content: [
48
48
  "rounded-md bg-layer-popover",
49
- "font-sans text-xs font-medium tracking-[-0.005em] text-foreground-strong",
49
+ "font-sans text-[13px] font-medium tracking-[-0.005em] text-foreground-strong",
50
50
  "shadow-[0_0_0_1px_oklch(0.21_0.006_285_/_0.10),0_1px_1px_oklch(0.21_0.006_285_/_0.04),0_1px_4px_-3px_oklch(0.21_0.006_285_/_0.10)]",
51
51
  "[&_[data-slot=kbd]]:bg-foreground-muted/10 [&_[data-slot=kbd]]:text-foreground-muted [&_[data-slot=kbd]]:ring-0",
52
52
  ],
53
53
  arrow: [],
54
54
  },
55
55
  },
56
+ variant: {
57
+ default: {},
58
+ inverse: {
59
+ content: [
60
+ "bg-foreground-strong text-foreground-inverse",
61
+ "!shadow-[0_12px_24px_0_oklch(0.21_0.006_285_/_0.045),0_1px_2px_0_oklch(0.21_0.006_285_/_0.035)]",
62
+ "[&_[data-slot=kbd]]:bg-white/10 [&_[data-slot=kbd]]:text-foreground-inverse [&_[data-slot=kbd]]:ring-0",
63
+ ],
64
+ },
65
+ },
66
+ },
67
+ defaultVariants: {
68
+ variant: "default",
56
69
  },
57
70
  });
58
71
 
72
+ type TooltipStyleProps = VariantProps<typeof tooltip>;
73
+
59
74
  export type TooltipProviderProps = BaseTooltip.Provider.Props;
60
75
 
61
76
  export function TooltipProvider({ delay = 0, ...props }: TooltipProviderProps) {
@@ -88,25 +103,35 @@ export function TooltipPortal(props: TooltipPortalProps) {
88
103
  return <BaseTooltip.Portal data-slot="tooltip-portal" {...props} />;
89
104
  }
90
105
 
91
- type TooltipArrowProps = StyledProps<BaseTooltip.Arrow.Props>;
106
+ type TooltipArrowProps = StyledProps<BaseTooltip.Arrow.Props> & Pick<TooltipStyleProps, "variant">;
92
107
 
93
- function TooltipArrow({ className, ...props }: TooltipArrowProps) {
108
+ function TooltipArrow({ className, variant, ...props }: TooltipArrowProps) {
94
109
  const theme = useThemeFamily();
95
- const { arrow } = tooltip({ theme });
110
+ const { arrow } = tooltip({ theme, variant });
96
111
  return (
97
112
  <BaseTooltip.Arrow data-slot="tooltip-arrow" className={arrow({ className })} {...props}>
98
- <TooltipArrowSvg />
113
+ <TooltipArrowSvg variant={variant} />
99
114
  </BaseTooltip.Arrow>
100
115
  );
101
116
  }
102
117
 
103
- function TooltipArrowSvg(props: ComponentProps<"svg">) {
118
+ function TooltipArrowSvg({
119
+ variant,
120
+ ...props
121
+ }: ComponentProps<"svg"> & Pick<TooltipStyleProps, "variant">) {
122
+ const isInverse = variant === "inverse";
123
+
104
124
  return (
105
125
  <svg width="12" height="6" viewBox="0 0 12 6" fill="none" {...props}>
106
- <path d="M1 0H11L6 5.25Z" className="fill-layer-popover" />
126
+ <path
127
+ d="M1 0H11L6 5.25Z"
128
+ className={isInverse ? "fill-foreground-strong" : "fill-layer-popover"}
129
+ />
107
130
  <path
108
131
  d="M1 0.5L6 5.25L11 0.5"
109
- className="stroke-[oklch(0.21_0.006_285_/_0.10)]"
132
+ className={
133
+ isInverse ? "stroke-[oklch(0_0_0_/_0.18)]" : "stroke-[oklch(0.21_0.006_285_/_0.10)]"
134
+ }
110
135
  strokeLinecap="round"
111
136
  strokeLinejoin="round"
112
137
  vectorEffect="non-scaling-stroke"
@@ -132,7 +157,7 @@ export type TooltipContentProps = StyledProps<BaseTooltip.Popup.Props> &
132
157
  | "sticky"
133
158
  > & {
134
159
  portalProps?: TooltipPortalProps;
135
- };
160
+ } & Pick<TooltipStyleProps, "variant">;
136
161
 
137
162
  export function TooltipContent({
138
163
  align = "center",
@@ -148,12 +173,13 @@ export function TooltipContent({
148
173
  sideOffset = 6,
149
174
  sticky,
150
175
  portalProps,
176
+ variant,
151
177
  className,
152
178
  children,
153
179
  ...props
154
180
  }: TooltipContentProps) {
155
181
  const theme = useThemeFamily();
156
- const { positioner, content } = tooltip({ theme });
182
+ const { positioner, content } = tooltip({ theme, variant });
157
183
 
158
184
  return (
159
185
  <BaseTooltip.Portal {...portalProps}>
@@ -178,7 +204,7 @@ export function TooltipContent({
178
204
  {...props}
179
205
  >
180
206
  {children}
181
- <TooltipArrow />
207
+ <TooltipArrow variant={variant} />
182
208
  </BaseTooltip.Popup>
183
209
  </BaseTooltip.Positioner>
184
210
  </BaseTooltip.Portal>