@adea-ai/ui 0.22.2 → 0.23.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 (92) hide show
  1. package/README.md +6 -3
  2. package/dist/components/account-drawer.d.ts +3 -3
  3. package/dist/components/account-drawer.js +119 -19
  4. package/dist/components/on-screen-controls.d.ts +2 -1
  5. package/dist/components/on-screen-controls.js +158 -46
  6. package/dist/components/scene-settings.d.ts +3 -3
  7. package/dist/components/scene-settings.js +247 -28
  8. package/dist/components/theme-provider.d.ts +27 -5
  9. package/dist/components/theme-provider.js +96 -7
  10. package/dist/components/theme-toggle.d.ts +4 -4
  11. package/dist/components/theme-toggle.js +62 -18
  12. package/dist/components/ui/badge.d.ts +4 -3
  13. package/dist/components/ui/badge.js +31 -30
  14. package/dist/components/ui/button.d.ts +4 -3
  15. package/dist/components/ui/button.js +49 -32
  16. package/dist/components/ui/card.d.ts +3 -3
  17. package/dist/components/ui/card.js +25 -6
  18. package/dist/components/ui/dialog.d.ts +13 -13
  19. package/dist/components/ui/dialog.js +94 -26
  20. package/dist/components/ui/drawer.d.ts +23 -15
  21. package/dist/components/ui/drawer.js +109 -64
  22. package/dist/components/ui/dropdown-menu.d.ts +28 -22
  23. package/dist/components/ui/dropdown-menu.js +165 -36
  24. package/dist/components/ui/empty.d.ts +7 -6
  25. package/dist/components/ui/empty.js +78 -26
  26. package/dist/components/ui/field.d.ts +15 -14
  27. package/dist/components/ui/field.js +177 -55
  28. package/dist/components/ui/input.d.ts +2 -2
  29. package/dist/components/ui/input.js +20 -5
  30. package/dist/components/ui/label.d.ts +2 -2
  31. package/dist/components/ui/label.js +15 -5
  32. package/dist/components/ui/radio-group.d.ts +4 -4
  33. package/dist/components/ui/radio-group.js +36 -9
  34. package/dist/components/ui/separator.d.ts +6 -2
  35. package/dist/components/ui/separator.js +18 -6
  36. package/dist/components/ui/skeleton.d.ts +2 -1
  37. package/dist/components/ui/skeleton.js +15 -4
  38. package/dist/components/ui/spinner.d.ts +4 -3
  39. package/dist/components/ui/spinner.js +15 -5
  40. package/dist/components/ui/switch.d.ts +6 -3
  41. package/dist/components/ui/switch.js +57 -6
  42. package/dist/components/ui/tabs.d.ts +6 -5
  43. package/dist/components/ui/tabs.js +52 -24
  44. package/dist/components/ui/toggle-group.d.ts +10 -8
  45. package/dist/components/ui/toggle-group.js +91 -20
  46. package/dist/components/ui/toggle.d.ts +4 -2
  47. package/dist/components/ui/toggle.js +38 -23
  48. package/dist/components/ui/tooltip.d.ts +13 -6
  49. package/dist/components/ui/tooltip.js +51 -14
  50. package/dist/components/version-dialog.d.ts +2 -2
  51. package/dist/components/version-dialog.js +322 -129
  52. package/dist/components/workspace-brand.d.ts +1 -1
  53. package/dist/components/workspace-brand.js +12 -3
  54. package/dist/components/workspace-logo.d.ts +2 -2
  55. package/dist/components/workspace-logo.js +15 -3
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +20 -19
  58. package/dist/lib/utils.js +7 -4
  59. package/dist/lib/version-notes.js +14 -29
  60. package/package.json +18 -16
  61. package/src/components/account-drawer.tsx +48 -67
  62. package/src/components/on-screen-controls.tsx +55 -62
  63. package/src/components/scene-settings.tsx +97 -100
  64. package/src/components/theme-provider.tsx +122 -22
  65. package/src/components/theme-toggle.tsx +29 -54
  66. package/src/components/ui/badge.tsx +14 -23
  67. package/src/components/ui/button.tsx +9 -11
  68. package/src/components/ui/card.tsx +9 -6
  69. package/src/components/ui/dialog.tsx +58 -55
  70. package/src/components/ui/drawer.tsx +84 -125
  71. package/src/components/ui/dropdown-menu.tsx +130 -153
  72. package/src/components/ui/empty.tsx +29 -26
  73. package/src/components/ui/field.tsx +83 -87
  74. package/src/components/ui/input.tsx +8 -8
  75. package/src/components/ui/label.tsx +6 -7
  76. package/src/components/ui/radio-group.tsx +22 -19
  77. package/src/components/ui/separator.tsx +16 -9
  78. package/src/components/ui/skeleton.tsx +6 -3
  79. package/src/components/ui/spinner.tsx +9 -5
  80. package/src/components/ui/switch.tsx +47 -20
  81. package/src/components/ui/tabs.tsx +31 -30
  82. package/src/components/ui/toggle-group.tsx +65 -54
  83. package/src/components/ui/toggle.tsx +9 -12
  84. package/src/components/ui/tooltip.tsx +41 -36
  85. package/src/components/version-dialog.tsx +144 -144
  86. package/src/components/workspace-brand.tsx +5 -5
  87. package/src/components/workspace-logo.tsx +9 -8
  88. package/src/index.tsx +7 -1
  89. package/src/styles/base.css +637 -0
  90. package/src/styles/globals.css +1 -1
  91. package/tsconfig.json +2 -1
  92. package/components.json +0 -19
@@ -1,23 +1,23 @@
1
- 'use client'
2
-
3
- import { Tabs as TabsPrimitive } from '@base-ui/react/tabs'
1
+ import { Tabs as TabsPrimitive } from '@kobalte/core/tabs'
4
2
  import { cva, type VariantProps } from 'class-variance-authority'
3
+ import { splitProps, type ComponentProps } from 'solid-js'
5
4
 
6
5
  import { cn } from '#lib/utils'
7
6
 
8
- function Tabs({ className, orientation = 'horizontal', ...props }: TabsPrimitive.Root.Props) {
7
+ function Tabs(props: ComponentProps<typeof TabsPrimitive>) {
8
+ const [local, rest] = splitProps(props, ['class', 'orientation'])
9
9
  return (
10
- <TabsPrimitive.Root
10
+ <TabsPrimitive
11
11
  data-slot="tabs"
12
- data-orientation={orientation}
13
- className={cn('group/tabs flex gap-2 data-horizontal:flex-col', className)}
14
- {...props}
12
+ orientation={local.orientation}
13
+ class={cn('group/tabs flex gap-2 data-[orientation=horizontal]:flex-col', local.class)}
14
+ {...rest}
15
15
  />
16
16
  )
17
17
  }
18
18
 
19
19
  const tabsListVariants = cva(
20
- 'group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none',
20
+ 'group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none',
21
21
  {
22
22
  variants: {
23
23
  variant: {
@@ -31,43 +31,44 @@ const tabsListVariants = cva(
31
31
  }
32
32
  )
33
33
 
34
- function TabsList({
35
- className,
36
- variant = 'default',
37
- ...props
38
- }: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
34
+ function TabsList(
35
+ props: ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>
36
+ ) {
37
+ const [local, rest] = splitProps(props, ['class', 'variant'])
39
38
  return (
40
39
  <TabsPrimitive.List
41
40
  data-slot="tabs-list"
42
- data-variant={variant}
43
- className={cn(tabsListVariants({ variant }), className)}
44
- {...props}
41
+ data-variant={local.variant ?? 'default'}
42
+ class={cn(tabsListVariants({ variant: local.variant }), local.class)}
43
+ {...rest}
45
44
  />
46
45
  )
47
46
  }
48
47
 
49
- function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
48
+ function TabsTrigger(props: ComponentProps<typeof TabsPrimitive.Trigger>) {
49
+ const [local, rest] = splitProps(props, ['class'])
50
50
  return (
51
- <TabsPrimitive.Tab
51
+ <TabsPrimitive.Trigger
52
52
  data-slot="tabs-trigger"
53
- className={cn(
54
- "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
55
- 'group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent',
56
- 'data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground',
57
- 'after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100',
58
- className
53
+ class={cn(
54
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-selected:shadow-sm group-data-[variant=line]/tabs-list:data-selected:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
55
+ 'group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-selected:bg-transparent dark:group-data-[variant=line]/tabs-list:data-selected:border-transparent dark:group-data-[variant=line]/tabs-list:data-selected:bg-transparent',
56
+ 'data-selected:bg-background data-selected:text-foreground dark:data-selected:border-input dark:data-selected:bg-input/30 dark:data-selected:text-foreground',
57
+ 'after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-selected:after:opacity-100',
58
+ local.class
59
59
  )}
60
- {...props}
60
+ {...rest}
61
61
  />
62
62
  )
63
63
  }
64
64
 
65
- function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
65
+ function TabsContent(props: ComponentProps<typeof TabsPrimitive.Content>) {
66
+ const [local, rest] = splitProps(props, ['class'])
66
67
  return (
67
- <TabsPrimitive.Panel
68
+ <TabsPrimitive.Content
68
69
  data-slot="tabs-content"
69
- className={cn('flex-1 text-sm outline-none', className)}
70
- {...props}
70
+ class={cn('flex-1 text-sm outline-none', local.class)}
71
+ {...rest}
71
72
  />
72
73
  )
73
74
  }
@@ -1,87 +1,98 @@
1
- 'use client'
2
-
3
- import * as React from 'react'
4
- import { Toggle as TogglePrimitive } from '@base-ui/react/toggle'
5
- import { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group'
1
+ import { ToggleGroup as ToggleGroupPrimitive } from '@kobalte/core/toggle-group'
6
2
  import { type VariantProps } from 'class-variance-authority'
3
+ import { createContext, splitProps, useContext, type ComponentProps } from 'solid-js'
7
4
 
8
5
  import { cn } from '#lib/utils'
9
6
  import { toggleVariants } from '#components/ui/toggle'
10
7
 
11
- const ToggleGroupContext = React.createContext<
12
- VariantProps<typeof toggleVariants> & {
13
- spacing?: number
14
- orientation?: 'horizontal' | 'vertical'
15
- }
16
- >({
8
+ type ToggleGroupContextValue = VariantProps<typeof toggleVariants> & {
9
+ spacing: number
10
+ }
11
+
12
+ const ToggleGroupContext = createContext<ToggleGroupContextValue>({
17
13
  size: 'default',
18
14
  variant: 'default',
19
15
  spacing: 2,
20
- orientation: 'horizontal',
21
16
  })
22
17
 
23
- function ToggleGroup({
24
- className,
25
- variant,
26
- size,
27
- spacing = 2,
28
- orientation = 'horizontal',
29
- children,
30
- ...props
31
- }: ToggleGroupPrimitive.Props &
18
+ type ToggleGroupProps = Omit<
19
+ ComponentProps<typeof ToggleGroupPrimitive>,
20
+ 'multiple' | 'onChange' | 'value'
21
+ > &
32
22
  VariantProps<typeof toggleVariants> & {
33
23
  spacing?: number
34
- orientation?: 'horizontal' | 'vertical'
35
- }) {
24
+ value?: string[]
25
+ onChange?: (value: string[]) => void
26
+ }
27
+
28
+ function ToggleGroup(props: ToggleGroupProps) {
29
+ const [local, rest] = splitProps(props, [
30
+ 'class',
31
+ 'variant',
32
+ 'size',
33
+ 'spacing',
34
+ 'orientation',
35
+ 'children',
36
+ 'value',
37
+ 'onChange',
38
+ ])
39
+
36
40
  return (
37
41
  <ToggleGroupPrimitive
38
42
  data-slot="toggle-group"
39
- data-variant={variant}
40
- data-size={size}
41
- data-spacing={spacing}
42
- data-orientation={orientation}
43
- style={{ '--gap': spacing } as React.CSSProperties}
44
- className={cn(
45
- 'group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch',
46
- className
43
+ data-variant={local.variant ?? 'default'}
44
+ data-size={local.size ?? 'default'}
45
+ data-spacing={local.spacing ?? 2}
46
+ data-orientation={local.orientation ?? 'horizontal'}
47
+ multiple
48
+ value={local.value}
49
+ onChange={local.onChange}
50
+ style={{ '--gap': local.spacing ?? 2 }}
51
+ class={cn(
52
+ 'group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch',
53
+ local.class
47
54
  )}
48
- {...props}
55
+ {...rest}
49
56
  >
50
- <ToggleGroupContext.Provider value={{ variant, size, spacing, orientation }}>
51
- {children}
57
+ <ToggleGroupContext.Provider
58
+ value={{
59
+ variant: local.variant,
60
+ size: local.size,
61
+ spacing: local.spacing ?? 2,
62
+ }}
63
+ >
64
+ {local.children}
52
65
  </ToggleGroupContext.Provider>
53
66
  </ToggleGroupPrimitive>
54
67
  )
55
68
  }
56
69
 
57
- function ToggleGroupItem({
58
- className,
59
- children,
60
- variant = 'default',
61
- size = 'default',
62
- ...props
63
- }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
64
- const context = React.useContext(ToggleGroupContext)
70
+ type ToggleGroupItemProps = ComponentProps<typeof ToggleGroupPrimitive.Item> &
71
+ VariantProps<typeof toggleVariants>
72
+
73
+ function ToggleGroupItem(props: ToggleGroupItemProps) {
74
+ const [local, rest] = splitProps(props, ['class', 'children', 'variant', 'size'])
75
+ const context = useContext(ToggleGroupContext)
65
76
 
66
77
  return (
67
- <TogglePrimitive
78
+ <ToggleGroupPrimitive.Item
68
79
  data-slot="toggle-group-item"
69
- data-variant={context.variant || variant}
70
- data-size={context.size || size}
80
+ data-variant={context.variant ?? local.variant}
81
+ data-size={context.size ?? local.size}
71
82
  data-spacing={context.spacing}
72
- className={cn(
73
- 'shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t',
83
+ class={cn(
84
+ 'shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t',
74
85
  toggleVariants({
75
- variant: context.variant || variant,
76
- size: context.size || size,
86
+ variant: context.variant ?? local.variant,
87
+ size: context.size ?? local.size,
77
88
  }),
78
- className
89
+ local.class
79
90
  )}
80
- {...props}
91
+ {...rest}
81
92
  >
82
- {children}
83
- </TogglePrimitive>
93
+ {local.children}
94
+ </ToggleGroupPrimitive.Item>
84
95
  )
85
96
  }
86
97
 
87
- export { ToggleGroup, ToggleGroupItem }
98
+ export { ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps }
@@ -1,12 +1,11 @@
1
- 'use client'
2
-
3
- import { Toggle as TogglePrimitive } from '@base-ui/react/toggle'
1
+ import { ToggleButton as TogglePrimitive } from '@kobalte/core/toggle-button'
4
2
  import { cva, type VariantProps } from 'class-variance-authority'
3
+ import { splitProps, type ComponentProps } from 'solid-js'
5
4
 
6
5
  import { cn } from '#lib/utils'
7
6
 
8
7
  const toggleVariants = cva(
9
- "group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
10
9
  {
11
10
  variants: {
12
11
  variant: {
@@ -27,17 +26,15 @@ const toggleVariants = cva(
27
26
  }
28
27
  )
29
28
 
30
- function Toggle({
31
- className,
32
- variant = 'default',
33
- size = 'default',
34
- ...props
35
- }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
29
+ type ToggleProps = ComponentProps<typeof TogglePrimitive> & VariantProps<typeof toggleVariants>
30
+
31
+ function Toggle(props: ToggleProps) {
32
+ const [local, rest] = splitProps(props, ['class', 'variant', 'size'])
36
33
  return (
37
34
  <TogglePrimitive
38
35
  data-slot="toggle"
39
- className={cn(toggleVariants({ variant, size, className }))}
40
- {...props}
36
+ class={cn(toggleVariants({ variant: local.variant, size: local.size }), local.class)}
37
+ {...rest}
41
38
  />
42
39
  )
43
40
  }
@@ -1,54 +1,59 @@
1
- 'use client'
2
-
3
- import * as React from 'react'
4
- import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip'
1
+ import { Tooltip as TooltipPrimitive } from '@kobalte/core/tooltip'
2
+ import {
3
+ createContext,
4
+ splitProps,
5
+ useContext,
6
+ type ComponentProps,
7
+ type ParentProps,
8
+ } from 'solid-js'
5
9
 
6
10
  import { cn } from '#lib/utils'
7
11
 
8
12
  const TOOLTIP_DELAY = 200
9
13
 
10
- function TooltipProvider({ delay = TOOLTIP_DELAY, ...props }: TooltipPrimitive.Provider.Props) {
11
- return <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />
14
+ const TooltipDelayContext = createContext<number>(TOOLTIP_DELAY)
15
+
16
+ function TooltipProvider(props: ParentProps<{ delay?: number }>) {
17
+ return (
18
+ <TooltipDelayContext.Provider value={props.delay ?? TOOLTIP_DELAY}>
19
+ {props.children}
20
+ </TooltipDelayContext.Provider>
21
+ )
12
22
  }
13
23
 
14
- function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
15
- return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
24
+ function Tooltip(props: ComponentProps<typeof TooltipPrimitive>) {
25
+ const delay = useContext(TooltipDelayContext)
26
+ return <TooltipPrimitive openDelay={delay} data-slot="tooltip" {...props} />
16
27
  }
17
28
 
18
- function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
29
+ function TooltipTrigger(props: ComponentProps<typeof TooltipPrimitive.Trigger>) {
19
30
  return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
20
31
  }
21
32
 
22
- function TooltipContent({
23
- className,
24
- side = 'top',
25
- sideOffset = 4,
26
- align,
27
- alignOffset,
28
- children,
29
- ...props
30
- }: TooltipPrimitive.Popup.Props &
31
- Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
33
+ type TooltipContentProps = ComponentProps<typeof TooltipPrimitive.Content> & {
34
+ side?: 'top' | 'right' | 'bottom' | 'left'
35
+ sideOffset?: number
36
+ align?: 'start' | 'center' | 'end'
37
+ }
38
+
39
+ function TooltipContent(props: TooltipContentProps) {
40
+ const [local, rest] = splitProps(props, ['class', 'side', 'sideOffset', 'align', 'children'])
41
+ const placement = () => `${local.side ?? 'top'}${local.align ? `-${local.align}` : ''}`
42
+
32
43
  return (
33
44
  <TooltipPrimitive.Portal>
34
- <TooltipPrimitive.Positioner
35
- className="isolate z-[160] outline-none"
36
- align={align}
37
- alignOffset={alignOffset}
38
- side={side}
39
- sideOffset={sideOffset}
45
+ <TooltipPrimitive.Content
46
+ data-slot="tooltip-content"
47
+ placement={placement()}
48
+ gutter={local.sideOffset ?? 4}
49
+ class={cn(
50
+ 'z-[160] max-w-72 rounded-md bg-popover px-2.5 py-1.5 text-sm leading-5 text-popover-foreground shadow-md ring-1 ring-foreground/10 data-closed:animate-out data-closed:fade-out-0 data-expanded:animate-in data-expanded:fade-in-0',
51
+ local.class
52
+ )}
53
+ {...rest}
40
54
  >
41
- <TooltipPrimitive.Popup
42
- data-slot="tooltip-content"
43
- className={cn(
44
- 'max-w-72 rounded-md bg-popover px-2.5 py-1.5 text-sm leading-5 text-popover-foreground shadow-md ring-1 ring-foreground/10',
45
- className
46
- )}
47
- {...props}
48
- >
49
- {children}
50
- </TooltipPrimitive.Popup>
51
- </TooltipPrimitive.Positioner>
55
+ {local.children}
56
+ </TooltipPrimitive.Content>
52
57
  </TooltipPrimitive.Portal>
53
58
  )
54
59
  }