gooee 0.51.1 → 1.0.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 (269) hide show
  1. package/README.md +10 -3
  2. package/package.json +6 -2
  3. package/scripts/add.js +181 -42
  4. package/src/base.css +3 -1
  5. package/src/components/Accordion/Accordion.module.css +7 -5
  6. package/src/components/Accordion/Accordion.tsx +13 -11
  7. package/src/components/Accordion/Accordion.vue +16 -15
  8. package/src/components/Accordion/AccordionItem.vue +8 -7
  9. package/src/components/Alert/Alert.module.css +9 -7
  10. package/src/components/Alert/Alert.tsx +25 -16
  11. package/src/components/Alert/Alert.vue +31 -27
  12. package/src/components/AlertDialog/AlertDialog.module.css +2 -0
  13. package/src/components/AlertDialog/AlertDialog.tsx +8 -7
  14. package/src/components/AlertDialog/AlertDialog.vue +25 -23
  15. package/src/components/AnimatedNumber/AnimatedNumber.module.css +5 -3
  16. package/src/components/AnimatedNumber/AnimatedNumber.tsx +6 -6
  17. package/src/components/AnimatedNumber/AnimatedNumber.vue +5 -5
  18. package/src/components/AspectRatio/AspectRatio.module.css +2 -0
  19. package/src/components/AspectRatio/AspectRatio.tsx +3 -3
  20. package/src/components/AspectRatio/AspectRatio.vue +5 -8
  21. package/src/components/Avatar/Avatar.module.css +10 -8
  22. package/src/components/Avatar/Avatar.tsx +4 -3
  23. package/src/components/Avatar/Avatar.vue +17 -19
  24. package/src/components/Avatar/index.ts +0 -2
  25. package/src/components/AvatarGroup/AvatarGroup.module.css +11 -9
  26. package/src/components/AvatarGroup/AvatarGroup.tsx +4 -4
  27. package/src/components/AvatarGroup/AvatarGroup.vue +13 -16
  28. package/src/components/Badge/Badge.module.css +6 -4
  29. package/src/components/Badge/Badge.tsx +3 -3
  30. package/src/components/Badge/Badge.vue +15 -14
  31. package/src/components/Breadcrumb/Breadcrumb.module.css +5 -3
  32. package/src/components/Breadcrumb/Breadcrumb.tsx +20 -12
  33. package/src/components/Breadcrumb/Breadcrumb.vue +33 -25
  34. package/src/components/Button/Button.module.css +16 -14
  35. package/src/components/Button/Button.tsx +6 -4
  36. package/src/components/Button/Button.vue +42 -33
  37. package/src/components/ButtonGroup/ButtonGroup.module.css +2 -0
  38. package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
  39. package/src/components/ButtonGroup/ButtonGroup.vue +9 -12
  40. package/src/components/Card/Card.module.css +6 -4
  41. package/src/components/Card/Card.tsx +6 -6
  42. package/src/components/Card/Card.vue +18 -21
  43. package/src/components/Center/Center.module.css +2 -0
  44. package/src/components/Center/Center.tsx +1 -1
  45. package/src/components/Center/Center.vue +18 -15
  46. package/src/components/Checkbox/Checkbox.module.css +10 -8
  47. package/src/components/Checkbox/Checkbox.tsx +7 -5
  48. package/src/components/Checkbox/Checkbox.vue +29 -31
  49. package/src/components/CheckboxGroup/CheckboxGroup.module.css +3 -1
  50. package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -4
  51. package/src/components/CheckboxGroup/CheckboxGroup.vue +33 -30
  52. package/src/components/Cluster/Cluster.module.css +2 -0
  53. package/src/components/Cluster/Cluster.tsx +1 -1
  54. package/src/components/Cluster/Cluster.vue +21 -17
  55. package/src/components/CodeBlock/CodeBlock.module.css +12 -10
  56. package/src/components/CodeBlock/CodeBlock.tsx +18 -10
  57. package/src/components/CodeBlock/CodeBlock.vue +30 -27
  58. package/src/components/CodeBlock/highlight.ts +1 -1
  59. package/src/components/Collapsible/Collapsible.module.css +7 -5
  60. package/src/components/Collapsible/Collapsible.tsx +7 -6
  61. package/src/components/Collapsible/Collapsible.vue +30 -26
  62. package/src/components/Container/Container.module.css +2 -0
  63. package/src/components/Container/Container.tsx +1 -1
  64. package/src/components/Container/Container.vue +13 -12
  65. package/src/components/CopyButton/CopyButton.module.css +20 -18
  66. package/src/components/CopyButton/CopyButton.tsx +21 -14
  67. package/src/components/CopyButton/CopyButton.vue +41 -31
  68. package/src/components/Dial/Dial.module.css +26 -11
  69. package/src/components/Dial/Dial.tsx +18 -18
  70. package/src/components/Dial/Dial.vue +57 -60
  71. package/src/components/Dialog/Dialog.module.css +4 -2
  72. package/src/components/Dialog/Dialog.tsx +22 -13
  73. package/src/components/Dialog/Dialog.vue +34 -30
  74. package/src/components/Divider/Divider.module.css +5 -3
  75. package/src/components/Divider/Divider.tsx +6 -4
  76. package/src/components/Divider/Divider.vue +13 -16
  77. package/src/components/DropdownMenu/DropdownMenu.module.css +8 -6
  78. package/src/components/DropdownMenu/DropdownMenu.tsx +11 -8
  79. package/src/components/DropdownMenu/DropdownMenu.vue +24 -27
  80. package/src/components/EmptyState/EmptyState.module.css +6 -4
  81. package/src/components/EmptyState/EmptyState.tsx +6 -6
  82. package/src/components/EmptyState/EmptyState.vue +14 -17
  83. package/src/components/Fab/Fab.module.css +19 -17
  84. package/src/components/Fab/Fab.tsx +11 -9
  85. package/src/components/Fab/Fab.vue +29 -26
  86. package/src/components/Fieldset/Fieldset.module.css +2 -0
  87. package/src/components/Fieldset/Fieldset.tsx +4 -3
  88. package/src/components/Fieldset/Fieldset.vue +4 -4
  89. package/src/components/FormField/FormField.module.css +5 -3
  90. package/src/components/FormField/FormField.tsx +7 -7
  91. package/src/components/FormField/FormField.vue +4 -4
  92. package/src/components/Grid/Grid.module.css +2 -0
  93. package/src/components/Grid/Grid.tsx +1 -1
  94. package/src/components/Grid/Grid.vue +25 -22
  95. package/src/components/HoldToConfirm/HoldToConfirm.module.css +13 -11
  96. package/src/components/HoldToConfirm/HoldToConfirm.tsx +11 -9
  97. package/src/components/HoldToConfirm/HoldToConfirm.vue +37 -32
  98. package/src/components/IconButton/IconButton.module.css +7 -5
  99. package/src/components/IconButton/IconButton.tsx +2 -1
  100. package/src/components/IconButton/IconButton.vue +15 -14
  101. package/src/components/Input/Input.module.css +12 -10
  102. package/src/components/Input/Input.tsx +9 -7
  103. package/src/components/Input/Input.vue +45 -35
  104. package/src/components/InputGroup/InputGroup.module.css +8 -6
  105. package/src/components/InputGroup/InputGroup.tsx +5 -4
  106. package/src/components/InputGroup/InputGroup.vue +41 -36
  107. package/src/components/Kbd/Kbd.module.css +9 -7
  108. package/src/components/Kbd/Kbd.tsx +1 -1
  109. package/src/components/Kbd/Kbd.vue +1 -1
  110. package/src/components/Link/Link.module.css +4 -2
  111. package/src/components/Link/Link.tsx +4 -3
  112. package/src/components/Link/Link.vue +13 -16
  113. package/src/components/LivePill/LivePill.module.css +39 -37
  114. package/src/components/LivePill/LivePill.tsx +11 -10
  115. package/src/components/LivePill/LivePill.vue +38 -40
  116. package/src/components/Meter/Meter.module.css +5 -3
  117. package/src/components/Meter/Meter.tsx +9 -8
  118. package/src/components/Meter/Meter.vue +52 -43
  119. package/src/components/MorphButton/MorphButton.module.css +11 -9
  120. package/src/components/MorphButton/MorphButton.tsx +20 -10
  121. package/src/components/MorphButton/MorphButton.vue +29 -25
  122. package/src/components/NumberInput/NumberInput.module.css +7 -5
  123. package/src/components/NumberInput/NumberInput.tsx +11 -8
  124. package/src/components/NumberInput/NumberInput.vue +69 -57
  125. package/src/components/Pagination/Pagination.module.css +147 -5
  126. package/src/components/Pagination/Pagination.tsx +216 -41
  127. package/src/components/Pagination/Pagination.vue +201 -36
  128. package/src/components/Pagination/labels.ts +38 -0
  129. package/src/components/PasswordInput/PasswordInput.module.css +10 -8
  130. package/src/components/PasswordInput/PasswordInput.tsx +15 -7
  131. package/src/components/PasswordInput/PasswordInput.vue +20 -16
  132. package/src/components/PasswordInput/index.ts +1 -1
  133. package/src/components/PickerWheel/DateWheel.vue +20 -12
  134. package/src/components/PickerWheel/PickerWheel.module.css +15 -6
  135. package/src/components/PickerWheel/PickerWheel.tsx +70 -44
  136. package/src/components/PickerWheel/PickerWheel.vue +39 -38
  137. package/src/components/PickerWheel/TimeWheel.vue +23 -21
  138. package/src/components/PickerWheel/WheelColumn.vue +7 -5
  139. package/src/components/Popover/Popover.module.css +5 -3
  140. package/src/components/Popover/Popover.tsx +17 -8
  141. package/src/components/Popover/Popover.vue +26 -25
  142. package/src/components/ProgressBar/ProgressBar.module.css +4 -2
  143. package/src/components/ProgressBar/ProgressBar.tsx +6 -5
  144. package/src/components/ProgressBar/ProgressBar.vue +28 -25
  145. package/src/components/Prose/Prose.module.css +5 -3
  146. package/src/components/Prose/Prose.tsx +1 -1
  147. package/src/components/Prose/Prose.vue +5 -8
  148. package/src/components/Radio/Radio.module.css +10 -8
  149. package/src/components/Radio/Radio.tsx +10 -8
  150. package/src/components/Radio/Radio.vue +8 -8
  151. package/src/components/Radio/RadioGroup.vue +33 -35
  152. package/src/components/Radio/radioContext.ts +12 -0
  153. package/src/components/Retime/Retime.vue +25 -22
  154. package/src/components/RulerScrubber/RulerScrubber.module.css +11 -2
  155. package/src/components/RulerScrubber/RulerScrubber.tsx +19 -18
  156. package/src/components/RulerScrubber/RulerScrubber.vue +50 -54
  157. package/src/components/ScrollArea/ScrollArea.module.css +17 -15
  158. package/src/components/ScrollArea/ScrollArea.tsx +5 -4
  159. package/src/components/ScrollArea/ScrollArea.vue +15 -17
  160. package/src/components/SearchInput/SearchInput.module.css +6 -4
  161. package/src/components/SearchInput/SearchInput.tsx +15 -8
  162. package/src/components/SearchInput/SearchInput.vue +20 -17
  163. package/src/components/SearchInput/index.ts +1 -1
  164. package/src/components/SegmentedControl/SegmentedControl.module.css +7 -5
  165. package/src/components/SegmentedControl/SegmentedControl.tsx +9 -5
  166. package/src/components/SegmentedControl/SegmentedControl.vue +25 -29
  167. package/src/components/Select/Select.module.css +19 -17
  168. package/src/components/Select/Select.tsx +30 -17
  169. package/src/components/Select/Select.vue +62 -57
  170. package/src/components/Sheet/Sheet.module.css +6 -4
  171. package/src/components/Sheet/Sheet.tsx +39 -29
  172. package/src/components/Sheet/Sheet.vue +46 -40
  173. package/src/components/Skeleton/Skeleton.module.css +4 -2
  174. package/src/components/Skeleton/Skeleton.tsx +3 -2
  175. package/src/components/Skeleton/Skeleton.vue +16 -18
  176. package/src/components/Slider/Slider.module.css +14 -12
  177. package/src/components/Slider/Slider.tsx +20 -9
  178. package/src/components/Slider/Slider.vue +47 -37
  179. package/src/components/Spinner/Spinner.module.css +2 -0
  180. package/src/components/Spinner/Spinner.tsx +3 -3
  181. package/src/components/Spinner/Spinner.vue +9 -12
  182. package/src/components/Split/Split.module.css +2 -0
  183. package/src/components/Split/Split.tsx +3 -3
  184. package/src/components/Split/Split.vue +19 -17
  185. package/src/components/SplitFlap/SplitFlap.module.css +9 -7
  186. package/src/components/SplitFlap/SplitFlap.tsx +2 -2
  187. package/src/components/SplitFlap/SplitFlap.vue +24 -21
  188. package/src/components/Stack/Stack.module.css +2 -0
  189. package/src/components/Stack/Stack.tsx +1 -1
  190. package/src/components/Stack/Stack.vue +13 -12
  191. package/src/components/SwipeDeck/SwipeDeck.module.css +13 -11
  192. package/src/components/SwipeDeck/SwipeDeck.tsx +23 -28
  193. package/src/components/SwipeDeck/SwipeDeck.vue +32 -38
  194. package/src/components/Switch/Switch.module.css +10 -8
  195. package/src/components/Switch/Switch.tsx +6 -5
  196. package/src/components/Switch/Switch.vue +22 -24
  197. package/src/components/Table/Table.module.css +24 -22
  198. package/src/components/Table/Table.tsx +27 -30
  199. package/src/components/Table/Table.vue +93 -79
  200. package/src/components/TableOfContents/TableOfContents.module.css +9 -7
  201. package/src/components/TableOfContents/TableOfContents.tsx +8 -8
  202. package/src/components/TableOfContents/TableOfContents.vue +20 -23
  203. package/src/components/Tabs/Tab.vue +3 -0
  204. package/src/components/Tabs/TabList.vue +2 -2
  205. package/src/components/Tabs/TabPanel.vue +2 -0
  206. package/src/components/Tabs/Tabs.module.css +4 -2
  207. package/src/components/Tabs/Tabs.tsx +10 -5
  208. package/src/components/Tabs/Tabs.vue +1 -1
  209. package/src/components/Tag/Tag.module.css +12 -10
  210. package/src/components/Tag/Tag.tsx +13 -15
  211. package/src/components/Tag/Tag.vue +12 -14
  212. package/src/components/Textarea/Textarea.module.css +8 -6
  213. package/src/components/Textarea/Textarea.tsx +4 -3
  214. package/src/components/Textarea/Textarea.vue +32 -34
  215. package/src/components/ThemeToggle/ThemeToggle.module.css +2 -0
  216. package/src/components/ThemeToggle/ThemeToggle.tsx +7 -7
  217. package/src/components/ThemeToggle/ThemeToggle.vue +24 -22
  218. package/src/components/Toast/Toast.module.css +17 -15
  219. package/src/components/Toast/Toast.tsx +51 -34
  220. package/src/components/Toast/Toast.vue +35 -24
  221. package/src/components/Toast/ToastItem.vue +17 -16
  222. package/src/components/Toggle/Toggle.module.css +11 -9
  223. package/src/components/Toggle/Toggle.tsx +3 -2
  224. package/src/components/Toggle/Toggle.vue +13 -15
  225. package/src/components/Tooltip/Tooltip.module.css +5 -3
  226. package/src/components/Tooltip/Tooltip.tsx +1 -0
  227. package/src/components/Tooltip/Tooltip.vue +13 -18
  228. package/src/components/VisuallyHidden/VisuallyHidden.module.css +2 -0
  229. package/src/components/VisuallyHidden/VisuallyHidden.tsx +1 -1
  230. package/src/components/VisuallyHidden/VisuallyHidden.vue +5 -8
  231. package/src/{internal → icons}/icons.module.css +4 -2
  232. package/src/{internal → icons}/icons.tsx +15 -16
  233. package/src/internal/FieldMessage.module.css +5 -3
  234. package/src/internal/FieldMessage.tsx +2 -2
  235. package/src/internal/FieldMessage.vue +2 -2
  236. package/src/internal/Roll.module.css +5 -3
  237. package/src/internal/feel.ts +12 -10
  238. package/src/internal/fling.ts +3 -3
  239. package/src/internal/liquid.ts +12 -10
  240. package/src/internal/liquidMatter.ts +1 -1
  241. package/src/internal/liquidMore.ts +7 -7
  242. package/src/internal/motion/checkbox.ts +4 -4
  243. package/src/internal/motion/fling.ts +19 -9
  244. package/src/internal/motion/holdToConfirm.ts +3 -3
  245. package/src/internal/motion/index.ts +8 -6
  246. package/src/internal/motion/liquid.ts +16 -4
  247. package/src/internal/motion/liquidMatter.ts +8 -6
  248. package/src/internal/motion/liquidMore.ts +44 -25
  249. package/src/internal/motion/livePill.ts +1 -1
  250. package/src/internal/motion/numberInput.ts +2 -2
  251. package/src/internal/motion/pickerWheel.ts +7 -4
  252. package/src/internal/motion/ruler.ts +1 -1
  253. package/src/internal/motion/scrollArea.ts +3 -3
  254. package/src/internal/motion/scrollFrame.ts +9 -7
  255. package/src/internal/motion/scrubber.ts +39 -20
  256. package/src/internal/motion/slider.ts +38 -4
  257. package/src/internal/motion/softPress.ts +10 -9
  258. package/src/internal/motion/splitFlap.ts +4 -4
  259. package/src/internal/motion/swipeDeck.ts +38 -7
  260. package/src/internal/motion/table.ts +3 -6
  261. package/src/internal/motion/themeIcon.ts +1 -1
  262. package/src/internal/motion/themeReveal.ts +1 -1
  263. package/src/internal/motion/toast.ts +3 -3
  264. package/src/internal/motion.ts +7 -8
  265. package/src/internal/scrollFrame.ts +3 -3
  266. package/src/internal/useScrub.ts +1 -15
  267. package/src/internal/vue/useScrub.ts +2 -6
  268. package/src/tokens.css +81 -421
  269. package/src/{internal/vueIcons.ts → icons/vue.ts} +5 -5
@@ -1,18 +1,21 @@
1
1
  'use client'
2
2
 
3
3
  import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react'
4
- import { CheckCircleIcon, ErrorIcon, InfoIcon, XIcon } from '../../internal/icons'
4
+ import { CheckCircleIcon, ErrorIcon, InfoIcon, XIcon } from '../../icons/icons'
5
5
  import { motionMs } from '../../internal/motion'
6
- import { createToastBud, createToastSwipe, toastId, toastLayout, toastSay, toastStack, toastTimer, watchToastHeight, type ToastLeaving, type ToastOrigin, type ToastVariant } from '../../internal/motion/toast'
6
+ import { createToastBud, createToastSwipe, toastId, toastLayout, toastSay, toastStack, toastTimer, watchToastHeight, type ToastLeaving, type ToastOrigin, type ToastTone } from '../../internal/motion/toast'
7
7
  import { Spinner } from '../Spinner'
8
8
  import styles from './Toast.module.css'
9
9
 
10
- export type { ToastVariant }
10
+ export type { ToastTone }
11
11
 
12
12
  export type ToastOptions = {
13
13
  title: string
14
14
  description?: string
15
- variant?: ToastVariant
15
+ /** Sets the icon and colour. Danger is announced at once. */
16
+ tone?: ToastTone
17
+ /** Shows a spinner and keeps the toast until you update it with loading: false. */
18
+ loading?: boolean
16
19
  /** Milliseconds before it leaves. Infinity keeps it until dismissed. */
17
20
  duration?: number
18
21
  action?: { label: string; onClick: () => void }
@@ -36,18 +39,26 @@ export function useToast(): Api {
36
39
  return c
37
40
  }
38
41
 
42
+ export type ToastLabels = {
43
+ /** Name of each close button. The toast title is added after it. */
44
+ dismiss: string
45
+ }
46
+
47
+ const defaultLabels: ToastLabels = { dismiss: 'Dismiss' }
48
+
39
49
  export type ToastProviderProps = {
40
50
  /** Your app. Anything inside can call useToast. */
41
51
  children: ReactNode
42
- /** How many toasts stay visible in the stack. */
43
- visible?: number
52
+ /** Most toasts shown in the stack at once. */
53
+ max?: number
44
54
  /** Name of the notification region for screen readers. */
45
55
  label?: string
46
- /** Screen reader name for each close button. The toast title is added after it. */
47
- dismissLabel?: string
56
+ /** Screen reader text, so you can translate it. Missing keys use the English defaults. */
57
+ labels?: Partial<ToastLabels>
48
58
  }
49
59
 
50
- export function ToastProvider({ children, visible = 3, label = 'Notifications', dismissLabel = 'Dismiss' }: ToastProviderProps) {
60
+ export function ToastProvider({ children, max = 3, label = 'Notifications', labels: labelsProp }: ToastProviderProps) {
61
+ const labels = { ...defaultLabels, ...labelsProp }
51
62
  const [items, setItems] = useState<Item[]>([])
52
63
  const [heights, setHeights] = useState<Record<number, number>>({})
53
64
  const [expanded, setExpanded] = useState(false)
@@ -62,9 +73,9 @@ export function ToastProvider({ children, visible = 3, label = 'Notifications',
62
73
  return () => pending.forEach((t) => window.clearTimeout(t))
63
74
  }, [])
64
75
 
65
- const say = (opts: Partial<ToastOptions>, variant?: ToastVariant) => {
76
+ const say = (opts: Partial<ToastOptions>, tone?: ToastTone) => {
66
77
  const fresh = (prev: string) => toastSay(prev, opts)
67
- if (variant === 'error') setUrgent(fresh)
78
+ if (tone === 'danger') setUrgent(fresh)
68
79
  else setAnnounce(fresh)
69
80
  }
70
81
 
@@ -82,28 +93,29 @@ export function ToastProvider({ children, visible = 3, label = 'Notifications',
82
93
  () => ({
83
94
  toast: (opts) => {
84
95
  const id = toastId()
85
- setItems((list) => [...list, { duration: 5000, variant: 'default', ...opts, id, leaving: false }])
86
- say(opts, opts.variant)
96
+ setItems((list) => [...list, { duration: 5000, tone: 'neutral', ...opts, id, leaving: false }])
97
+ say(opts, opts.tone)
87
98
  return id
88
99
  },
89
100
  update: (id, opts) => {
90
101
  setItems((list) => list.map((t) => (t.id === id ? { ...t, ...opts } : t)))
91
- if (opts.title) say(opts, opts.variant ?? itemsRef.current.find((t) => t.id === id)?.variant)
102
+ if (opts.title) say(opts, opts.tone ?? itemsRef.current.find((t) => t.id === id)?.tone)
92
103
  },
93
104
  dismiss: (id) => remove(id),
94
105
  }),
95
106
  [remove],
96
107
  )
97
108
 
98
- const { layout, frontHeight, height } = toastLayout(items, heights, expanded, visible)
109
+ const { layout, frontHeight, height } = toastLayout(items, heights, expanded, max)
99
110
 
100
111
  return (
101
- <ToastCtx.Provider value={api}>
112
+ <ToastCtx value={api}>
102
113
  {children}
103
114
  <div className={styles.srOnly} role="status" aria-live="polite" aria-atomic="true">{announce}</div>
104
115
  <div className={styles.srOnly} role="alert" aria-atomic="true">{urgent}</div>
105
116
  <section
106
117
  className={styles.viewport}
118
+ data-slot="toast-viewport"
107
119
  // Toasts are not part of an open dialog, but tapping one should not close it.
108
120
  data-gooee-layer-ignore=""
109
121
  aria-label={label}
@@ -113,7 +125,7 @@ export function ToastProvider({ children, visible = 3, label = 'Notifications',
113
125
  onFocus={() => setExpanded(true)}
114
126
  onBlur={(e) => !e.currentTarget.contains(e.relatedTarget) && setExpanded(false)}
115
127
  >
116
- <ol className={styles.list}>
128
+ <ol className={styles.list} data-slot="toast-list">
117
129
  {layout.map(({ t, index, y }) => (
118
130
  <ToastItem
119
131
  key={t.id}
@@ -121,15 +133,15 @@ export function ToastProvider({ children, visible = 3, label = 'Notifications',
121
133
  index={index}
122
134
  y={y}
123
135
  expanded={expanded}
124
- hidden={index >= visible}
136
+ hidden={index >= max}
125
137
  onHeight={(h) => setHeights((m) => (m[t.id] === h ? m : { ...m, [t.id]: h }))}
126
138
  onDismiss={(dir) => remove(t.id, dir)}
127
- dismissLabel={dismissLabel}
139
+ labels={labels}
128
140
  />
129
141
  ))}
130
142
  </ol>
131
143
  </section>
132
- </ToastCtx.Provider>
144
+ </ToastCtx>
133
145
  )
134
146
  }
135
147
 
@@ -141,18 +153,17 @@ type ItemProps = {
141
153
  hidden: boolean
142
154
  onHeight: (h: number) => void
143
155
  onDismiss: (dir: Item['leaving']) => void
144
- dismissLabel: string
156
+ labels: ToastLabels
145
157
  }
146
158
 
147
- const icons: Record<ToastVariant, ReactNode> = {
148
- default: null,
159
+ const icons: Record<ToastTone, ReactNode> = {
160
+ neutral: null,
149
161
  success: <CheckCircleIcon />,
150
- error: <ErrorIcon />,
162
+ danger: <ErrorIcon />,
151
163
  info: <InfoIcon />,
152
- loading: <Spinner size="sm" label={null} />,
153
164
  }
154
165
 
155
- function ToastItem({ item, index, y, expanded, hidden, onHeight, onDismiss, dismissLabel }: ItemProps) {
166
+ function ToastItem({ item, index, y, expanded, hidden, onHeight, onDismiss, labels }: ItemProps) {
156
167
  const ref = useRef<HTMLLIElement>(null)
157
168
  const [dragging, setDragging] = useState(false)
158
169
  const [hover, setHover] = useState(false)
@@ -188,11 +199,11 @@ function ToastItem({ item, index, y, expanded, hidden, onHeight, onDismiss, dism
188
199
  const remaining = useRef(item.duration ?? 5000)
189
200
  useEffect(() => {
190
201
  remaining.current = item.duration ?? 5000
191
- }, [item.duration, item.variant])
202
+ }, [item.duration, item.tone, item.loading])
192
203
  useEffect(() => {
193
- if (paused || !Number.isFinite(remaining.current) || item.variant === 'loading') return
204
+ if (paused || !Number.isFinite(remaining.current) || item.loading) return
194
205
  return toastTimer(remaining, () => onDismiss('down'))
195
- }, [paused, item.variant, item.duration])
206
+ }, [paused, item.tone, item.loading, item.duration])
196
207
 
197
208
  const { y: stackedY, scale } = toastStack(index, y, expanded)
198
209
 
@@ -200,6 +211,7 @@ function ToastItem({ item, index, y, expanded, hidden, onHeight, onDismiss, dism
200
211
  <li
201
212
  ref={ref}
202
213
  className={styles.toast}
214
+ data-slot="toast"
203
215
  data-leaving={item.leaving || undefined}
204
216
  data-dragging={dragging || undefined}
205
217
  data-hidden={hidden || undefined}
@@ -218,15 +230,20 @@ function ToastItem({ item, index, y, expanded, hidden, onHeight, onDismiss, dism
218
230
  onPointerUp={swipe.up}
219
231
  onPointerCancel={swipe.up}
220
232
  >
221
- {icons[item.variant ?? 'default'] && <span className={styles.icon} data-variant={item.variant}>{icons[item.variant ?? 'default']}</span>}
222
- <div className={styles.text}>
223
- <p className={styles.title}>{item.title}</p>
224
- {item.description && <p className={styles.description}>{item.description}</p>}
233
+ {(item.loading || icons[item.tone ?? 'neutral']) && (
234
+ <span className={styles.icon} data-slot="toast-icon" data-tone={item.loading ? undefined : item.tone}>
235
+ {item.loading ? <Spinner size="sm" label={null} /> : icons[item.tone ?? 'neutral']}
236
+ </span>
237
+ )}
238
+ <div className={styles.text} data-slot="toast-content">
239
+ <p className={styles.title} data-slot="toast-title">{item.title}</p>
240
+ {item.description && <p className={styles.description} data-slot="toast-description">{item.description}</p>}
225
241
  </div>
226
242
  {item.action && (
227
243
  <button
228
244
  type="button"
229
245
  className={styles.action}
246
+ data-slot="toast-action"
230
247
  onClick={() => {
231
248
  item.action?.onClick()
232
249
  onDismiss('down')
@@ -235,7 +252,7 @@ function ToastItem({ item, index, y, expanded, hidden, onHeight, onDismiss, dism
235
252
  {item.action.label}
236
253
  </button>
237
254
  )}
238
- <button type="button" className={styles.close} aria-label={`${dismissLabel}: ${item.title}`} onClick={() => onDismiss('down')}>
255
+ <button type="button" className={styles.close} data-slot="toast-close" aria-label={`${labels.dismiss}: ${item.title}`} onClick={() => onDismiss('down')}>
239
256
  <XIcon />
240
257
  </button>
241
258
  </li>
@@ -1,13 +1,21 @@
1
1
  <script lang="ts">
2
2
  import { inject, type InjectionKey } from 'vue'
3
- import type { ToastLeaving, ToastOrigin, ToastVariant } from '../../internal/motion/toast'
3
+ import type { ToastLeaving, ToastOrigin, ToastTone } from '../../internal/motion/toast'
4
4
 
5
- export type { ToastVariant }
5
+ export type { ToastTone }
6
+
7
+ export type ToastLabels = {
8
+ /** Name of each close button. The toast title is added after it. */
9
+ dismiss: string
10
+ }
6
11
 
7
12
  export type ToastOptions = {
8
13
  title: string
9
14
  description?: string
10
- variant?: ToastVariant
15
+ /** Sets the icon and colour. Danger is announced at once. */
16
+ tone?: ToastTone
17
+ /** Shows a spinner and keeps the toast until you update it with loading: false. */
18
+ loading?: boolean
11
19
  /** Milliseconds before it leaves. Infinity keeps it until dismissed. */
12
20
  duration?: number
13
21
  action?: { label: string; onClick: () => void }
@@ -44,17 +52,19 @@ import styles from './Toast.module.css'
44
52
  // The Vue ToastProvider: the same look (Toast.module.css), stack, bud and throw as the React one.
45
53
  // Wrap your app in it; anything inside can call useToast().
46
54
 
47
- const props = withDefaults(
48
- defineProps<{
49
- /** How many toasts stay visible in the stack. */
50
- visible?: number
51
- /** Name of the notification region for screen readers. */
52
- label?: string
53
- /** Screen reader name for each close button. The toast title is added after it. */
54
- dismissLabel?: string
55
- }>(),
56
- { visible: 3, label: 'Notifications', dismissLabel: 'Dismiss' },
57
- )
55
+ const {
56
+ max = 3,
57
+ label = 'Notifications',
58
+ labels,
59
+ } = defineProps<{
60
+ /** Most toasts shown in the stack at once. */
61
+ max?: number
62
+ /** Name of the notification region for screen readers. */
63
+ label?: string
64
+ /** Screen reader text, so you can translate it. Missing keys use the English defaults. */
65
+ labels?: Partial<ToastLabels>
66
+ }>()
67
+ const text = computed(() => ({ dismiss: 'Dismiss', ...labels }))
58
68
 
59
69
  const items = shallowRef<ToastItemData[]>([])
60
70
  const heights = shallowRef<Record<number, number>>({})
@@ -64,8 +74,8 @@ const urgent = ref('')
64
74
  const timers = new Set<number>()
65
75
  onBeforeUnmount(() => timers.forEach((t) => window.clearTimeout(t)))
66
76
 
67
- const say = (opts: Partial<ToastOptions>, variant?: ToastVariant) => {
68
- if (variant === 'error') urgent.value = toastSay(urgent.value, opts)
77
+ const say = (opts: Partial<ToastOptions>, tone?: ToastTone) => {
78
+ if (tone === 'danger') urgent.value = toastSay(urgent.value, opts)
69
79
  else announce.value = toastSay(announce.value, opts)
70
80
  }
71
81
 
@@ -83,19 +93,19 @@ const remove = (id: number, dir: ToastLeaving = 'down') => {
83
93
  provide(toastKey, {
84
94
  toast: (opts) => {
85
95
  const id = toastId()
86
- items.value = [...items.value, { duration: 5000, variant: 'default', ...opts, id, leaving: false }]
87
- say(opts, opts.variant)
96
+ items.value = [...items.value, { duration: 5000, tone: 'neutral', ...opts, id, leaving: false }]
97
+ say(opts, opts.tone)
88
98
  return id
89
99
  },
90
100
  update: (id, opts) => {
91
- const variant = items.value.find((t) => t.id === id)?.variant
101
+ const tone = items.value.find((t) => t.id === id)?.tone
92
102
  items.value = items.value.map((t) => (t.id === id ? { ...t, ...opts } : t))
93
- if (opts.title) say(opts, opts.variant ?? variant)
103
+ if (opts.title) say(opts, opts.tone ?? tone)
94
104
  },
95
105
  dismiss: (id) => remove(id),
96
106
  })
97
107
 
98
- const stack = computed(() => toastLayout(items.value, heights.value, expanded.value, props.visible))
108
+ const stack = computed(() => toastLayout(items.value, heights.value, expanded.value, max))
99
109
  const setHeight = (id: number, h: number) => {
100
110
  if (heights.value[id] !== h) heights.value = { ...heights.value, [id]: h }
101
111
  }
@@ -111,6 +121,7 @@ const onFocusOut = (e: FocusEvent) => !(e.currentTarget as HTMLElement).contains
111
121
  <!-- Toasts are not part of an open dialog, but tapping one should not close it. -->
112
122
  <section
113
123
  :class="styles.viewport"
124
+ data-slot="toast-viewport"
114
125
  data-gooee-layer-ignore=""
115
126
  :aria-label="label"
116
127
  :style="{ height: `${stack.height}px`, '--front-h': `${stack.frontHeight}px` }"
@@ -119,7 +130,7 @@ const onFocusOut = (e: FocusEvent) => !(e.currentTarget as HTMLElement).contains
119
130
  @focusin="expanded = true"
120
131
  @focusout="onFocusOut"
121
132
  >
122
- <ol :class="styles.list">
133
+ <ol :class="styles.list" data-slot="toast-list">
123
134
  <ToastItem
124
135
  v-for="{ t, index, y } in stack.layout"
125
136
  :key="t.id"
@@ -127,8 +138,8 @@ const onFocusOut = (e: FocusEvent) => !(e.currentTarget as HTMLElement).contains
127
138
  :index="index"
128
139
  :y="y"
129
140
  :expanded="expanded"
130
- :hidden="index >= props.visible"
131
- :dismiss-label="dismissLabel"
141
+ :hidden="index >= max"
142
+ :labels="text"
132
143
  @height="(h: number) => setHeight(t.id, h)"
133
144
  @dismiss="(dir: ToastLeaving) => remove(t.id, dir)"
134
145
  />
@@ -1,14 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
3
3
  import { createToastBud, createToastSwipe, toastStack, toastTimer, watchToastHeight, type ToastLeaving } from '../../internal/motion/toast'
4
- import { CheckCircleIcon, ErrorIcon, InfoIcon, XIcon } from '../../internal/vueIcons'
4
+ import { CheckCircleIcon, ErrorIcon, InfoIcon, XIcon } from '../../icons/vue'
5
5
  import Spinner from '../Spinner/Spinner.vue'
6
- import type { ToastItemData } from './Toast.vue'
6
+ import type { ToastItemData, ToastLabels } from './Toast.vue'
7
7
  import styles from './Toast.module.css'
8
8
 
9
9
  // One toast of the Vue ToastProvider (Toast.vue).
10
10
 
11
- const props = defineProps<{ item: ToastItemData; index: number; y: number; expanded: boolean; hidden: boolean; dismissLabel: string }>()
11
+ const props = defineProps<{ item: ToastItemData; index: number; y: number; expanded: boolean; hidden: boolean; labels: ToastLabels }>()
12
12
  const emit = defineEmits<{ height: [h: number]; dismiss: [dir: ToastLeaving] }>()
13
13
 
14
14
  const el = ref<HTMLElement | null>(null)
@@ -49,11 +49,11 @@ watch(
49
49
  // It leaves on its own, but waits while hovered, focused, held or hidden.
50
50
  const paused = computed(() => props.expanded || hover.value || dragging.value || props.item.leaving !== false)
51
51
  const remaining = { current: props.item.duration ?? 5000 }
52
- watch([() => props.item.duration, () => props.item.variant], () => (remaining.current = props.item.duration ?? 5000))
52
+ watch([() => props.item.duration, () => props.item.tone, () => props.item.loading], () => (remaining.current = props.item.duration ?? 5000))
53
53
  watch(
54
- [paused, () => props.item.variant, () => props.item.duration],
54
+ [paused, () => props.item.tone, () => props.item.loading, () => props.item.duration],
55
55
  (_, __, onCleanup) => {
56
- if (paused.value || !Number.isFinite(remaining.current) || props.item.variant === 'loading' || typeof window === 'undefined') return
56
+ if (paused.value || !Number.isFinite(remaining.current) || props.item.loading || typeof window === 'undefined') return
57
57
  onCleanup(toastTimer(remaining, () => dismiss('down')))
58
58
  },
59
59
  { immediate: true },
@@ -76,6 +76,7 @@ const onAction = () => {
76
76
  <li
77
77
  ref="el"
78
78
  :class="styles.toast"
79
+ data-slot="toast"
79
80
  :data-leaving="item.leaving || undefined"
80
81
  :data-dragging="dragging || undefined"
81
82
  :data-hidden="hidden || undefined"
@@ -90,18 +91,18 @@ const onAction = () => {
90
91
  @pointerup="swipe.up"
91
92
  @pointercancel="swipe.up"
92
93
  >
93
- <span v-if="item.variant && item.variant !== 'default'" :class="styles.icon" :data-variant="item.variant">
94
- <CheckCircleIcon v-if="item.variant === 'success'" />
95
- <ErrorIcon v-else-if="item.variant === 'error'" />
96
- <InfoIcon v-else-if="item.variant === 'info'" />
97
- <Spinner v-else size="sm" :label="null" />
94
+ <span v-if="item.loading || (item.tone && item.tone !== 'neutral')" :class="styles.icon" data-slot="toast-icon" :data-tone="item.loading ? undefined : item.tone">
95
+ <Spinner v-if="item.loading" size="sm" :label="null" />
96
+ <CheckCircleIcon v-else-if="item.tone === 'success'" />
97
+ <ErrorIcon v-else-if="item.tone === 'danger'" />
98
+ <InfoIcon v-else />
98
99
  </span>
99
- <div :class="styles.text">
100
- <p :class="styles.title">{{ item.title }}</p>
101
- <p v-if="item.description" :class="styles.description">{{ item.description }}</p>
100
+ <div :class="styles.text" data-slot="toast-content">
101
+ <p :class="styles.title" data-slot="toast-title">{{ item.title }}</p>
102
+ <p v-if="item.description" :class="styles.description" data-slot="toast-description">{{ item.description }}</p>
102
103
  </div>
103
- <button v-if="item.action" type="button" :class="styles.action" @click="onAction">{{ item.action.label }}</button>
104
- <button type="button" :class="styles.close" :aria-label="`${dismissLabel}: ${item.title}`" @click="dismiss('down')">
104
+ <button v-if="item.action" type="button" :class="styles.action" data-slot="toast-action" @click="onAction">{{ item.action.label }}</button>
105
+ <button type="button" :class="styles.close" data-slot="toast-close" :aria-label="`${labels.dismiss}: ${item.title}`" @click="dismiss('down')">
105
106
  <XIcon />
106
107
  </button>
107
108
  </li>
@@ -1,3 +1,4 @@
1
+ @layer gooee.components {
1
2
  .root {
2
3
  --h: var(--gooee-control-h-md);
3
4
  position: relative;
@@ -20,11 +21,11 @@
20
21
  user-select: none;
21
22
  -webkit-tap-highlight-color: transparent;
22
23
  transition:
23
- background-color var(--gooee-motion-fast) var(--gooee-ease-out),
24
- border-color var(--gooee-motion-fast) var(--gooee-ease-out),
25
- color var(--gooee-motion-fast) var(--gooee-ease-out),
26
- box-shadow var(--gooee-motion-fast) var(--gooee-ease-out),
27
- transform var(--gooee-motion-slow) var(--gooee-ease-spring);
24
+ background-color var(--gooee-motion-fast) var(--gooee-ease-morph),
25
+ border-color var(--gooee-motion-fast) var(--gooee-ease-morph),
26
+ color var(--gooee-motion-fast) var(--gooee-ease-morph),
27
+ box-shadow var(--gooee-motion-fast) var(--gooee-ease-morph),
28
+ transform var(--gooee-motion-slow) var(--gooee-ease-morph);
28
29
  }
29
30
 
30
31
  /* Invisible hit area, as in Button, so the small size still gets a 44px target. */
@@ -58,8 +59,8 @@
58
59
  .iconOnly.sm .icon { font-size: var(--gooee-icon-md); }
59
60
 
60
61
  @media (hover: hover) {
61
- .root:hover:not(:disabled):not([data-on]) { background: var(--gooee-color-surface-hover); }
62
- .root[data-on]:hover:not(:disabled) { background: var(--gooee-color-accent-hover); }
62
+ .root:hover:not(:disabled):not([data-state="on"]) { background: var(--gooee-color-surface-hover); }
63
+ .root[data-state="on"]:hover:not(:disabled) { background: var(--gooee-color-accent-hover); }
63
64
  }
64
65
 
65
66
  .root:focus-visible {
@@ -77,11 +78,11 @@
77
78
  .iconOnly:active:not(:disabled)::after { inset: -9%; }
78
79
 
79
80
  /* A solid fill, so the pressed state never rests on a faint shade. */
80
- .root[data-on] {
81
+ .root[data-state="on"] {
81
82
  border-color: var(--gooee-color-accent);
82
83
  background: var(--gooee-color-accent);
83
84
  color: var(--gooee-color-accent-fg);
84
- animation: pop var(--gooee-motion-slow) var(--gooee-ease-spring);
85
+ animation: pop var(--gooee-motion-slow) var(--gooee-ease-morph);
85
86
  }
86
87
 
87
88
  .root:disabled {
@@ -92,3 +93,4 @@
92
93
  @keyframes pop {
93
94
  50% { transform: scale(calc(2 - var(--gooee-press-scale))); }
94
95
  }
96
+ }
@@ -37,13 +37,14 @@ export function Toggle({
37
37
  type={type}
38
38
  aria-pressed={pressed}
39
39
  className={cx(styles.root, styles[size], !children && styles.iconOnly, className)}
40
- data-on={pressed || undefined}
40
+ data-slot="toggle"
41
+ data-state={pressed ? 'on' : 'off'}
41
42
  onClick={(e: MouseEvent<HTMLButtonElement>) => {
42
43
  onClick?.(e)
43
44
  if (!e.defaultPrevented) setPressed(!pressed)
44
45
  }}
45
46
  >
46
- {icon && <span className={styles.icon}>{icon}</span>}
47
+ {icon && <span className={styles.icon} data-slot="toggle-icon">{icon}</span>}
47
48
  {children}
48
49
  </button>
49
50
  )
@@ -6,22 +6,19 @@ import styles from './Toggle.module.css'
6
6
  // other attributes and listeners go to the button.
7
7
  defineOptions({ inheritAttrs: false })
8
8
 
9
- const props = withDefaults(
10
- defineProps<{
11
- /** Starting pressed state when there is no v-model. */
12
- defaultPressed?: boolean
13
- /** Height and text size, the same as Button. */
14
- size?: 'sm' | 'md' | 'lg'
15
- type?: 'button' | 'submit' | 'reset'
16
- }>(),
17
- { defaultPressed: false, size: 'md', type: 'button' },
18
- )
19
- /** Pressed state. Use v-model:pressed, or leave it out and the toggle keeps its own state. */
20
- const model = defineModel<boolean | undefined>('pressed', { type: Boolean, default: undefined })
9
+ const { defaultPressed = false, size = 'md', type = 'button' } = defineProps<{
10
+ /** Starting pressed state when there is no v-model. */
11
+ defaultPressed?: boolean
12
+ /** Height and text size, the same as Button. */
13
+ size?: 'sm' | 'md' | 'lg'
14
+ type?: 'button' | 'submit' | 'reset'
15
+ }>()
16
+ /** Pressed state. Use v-model, or leave it out and the toggle keeps its own state. */
17
+ const model = defineModel<boolean | undefined>({ type: Boolean, default: undefined })
21
18
  const slots = useSlots() as { default?: () => unknown; icon?: () => unknown }
22
19
  const attrs = useAttrs()
23
20
 
24
- const own = ref(props.defaultPressed)
21
+ const own = ref(defaultPressed)
25
22
  const pressed = computed(() => model.value ?? own.value)
26
23
  const rest = computed(() => {
27
24
  const { onClick: _onClick, ...others } = attrs
@@ -43,10 +40,11 @@ const onClick = (e: MouseEvent) => {
43
40
  :type="type"
44
41
  :aria-pressed="pressed"
45
42
  :class="[styles.root, styles[size], !slots.default && styles.iconOnly]"
46
- :data-on="pressed || undefined"
43
+ data-slot="toggle"
44
+ :data-state="pressed ? 'on' : 'off'"
47
45
  @click="onClick"
48
46
  >
49
- <span v-if="slots.icon" :class="styles.icon"><slot name="icon" /></span>
47
+ <span v-if="slots.icon" :class="styles.icon" data-slot="toggle-icon"><slot name="icon" /></span>
50
48
  <slot />
51
49
  </button>
52
50
  </template>
@@ -1,8 +1,9 @@
1
+ @layer gooee.components {
1
2
  .tip {
2
3
  --dx: 0px;
3
4
  --dy: var(--gooee-shift-sm);
4
5
  z-index: var(--gooee-z-tooltip);
5
- max-width: var(--gooee-tooltip-w);
6
+ max-width: var(--gooee-tooltip-w, 260px);
6
7
  padding: var(--gooee-space-2) var(--gooee-space-4);
7
8
  border-radius: var(--gooee-radius-sm);
8
9
  background: var(--gooee-color-inverse);
@@ -10,7 +11,7 @@
10
11
  font-size: var(--gooee-text-sm);
11
12
  line-height: var(--gooee-leading-snug);
12
13
  box-shadow: var(--gooee-shadow-2);
13
- animation: tipIn var(--gooee-motion-base) var(--gooee-ease-out);
14
+ animation: tipIn var(--gooee-motion-base) var(--gooee-ease-morph);
14
15
  }
15
16
 
16
17
  .tip[data-side="bottom"] { --dy: calc(var(--gooee-shift-sm) * -1); }
@@ -18,7 +19,7 @@
18
19
  .tip[data-side="right"] { --dy: 0px; --dx: calc(var(--gooee-shift-sm) * -1); }
19
20
 
20
21
  .tip[data-state="closed"] {
21
- animation: tipOut var(--gooee-motion-fast) var(--gooee-ease-in) forwards;
22
+ animation: tipOut var(--gooee-motion-fast) var(--gooee-ease-morph) forwards;
22
23
  }
23
24
 
24
25
  /* The morph (internal/liquid.ts) grows the tip out of its target instead; the fade stands down. */
@@ -32,3 +33,4 @@
32
33
  @keyframes tipOut {
33
34
  to { opacity: 0; transform: scale(var(--gooee-pop-scale)); }
34
35
  }
36
+ }
@@ -108,6 +108,7 @@ export function Tooltip({ content, side = 'top', children, delay }: TooltipProps
108
108
  id={id}
109
109
  role="tooltip"
110
110
  className={styles.tip}
111
+ data-slot="tooltip-content"
111
112
  data-state={state}
112
113
  data-side={floating.side}
113
114
  style={floating.style}
@@ -2,7 +2,7 @@
2
2
  import { onBeforeUnmount, ref, shallowRef, useId, watch, type VNode } from 'vue'
3
3
  import type { Side } from '../../internal/motion/floating'
4
4
  import { dismissable } from '../../internal/motion/layers'
5
- import { createLiquid } from '../../internal/motion/liquid'
5
+ import { createMorph } from '../../internal/motion/liquid'
6
6
  import { createTipTimer, tipEdge } from '../../internal/motion/tooltip'
7
7
  import { useFloating } from '../../internal/vue/useFloating'
8
8
  import { usePresence } from '../../internal/vue/usePresence'
@@ -12,17 +12,14 @@ import styles from './Tooltip.module.css'
12
12
  // The Vue Tooltip: the same look (Tooltip.module.css), timing and growth as the React one.
13
13
  // The default slot is the trigger: one focusable element, such as a Button.
14
14
 
15
- const props = withDefaults(
16
- defineProps<{
17
- /** Short text shown on hover and focus. It also describes the trigger to screen readers. The content slot replaces it. */
18
- content?: string
19
- /** Preferred side of the trigger. It flips when there is no room. */
20
- side?: Side
21
- /** Delay before showing on hover. Defaults to the tooltip delay token. */
22
- delay?: number
23
- }>(),
24
- { side: 'top' },
25
- )
15
+ const { side = 'top', delay } = defineProps<{
16
+ /** Short text shown on hover and focus. It also describes the trigger to screen readers. The content slot replaces it. */
17
+ content?: string
18
+ /** Preferred side of the trigger. It flips when there is no room. */
19
+ side?: Side
20
+ /** Delay before showing on hover. Defaults to the tooltip delay token. */
21
+ delay?: number
22
+ }>()
26
23
  const slots = defineSlots<{ default?: () => VNode[]; content?: () => unknown }>()
27
24
 
28
25
  const id = useId()
@@ -31,19 +28,16 @@ const anchor = shallowRef<HTMLElement | null>(null)
31
28
  const setAnchor = elementRef(anchor)
32
29
  const tip = ref<HTMLElement | null>(null)
33
30
  const { mounted, state } = usePresence(open, 'morph-out')
34
- const { style, side: placed, ready } = useFloating(anchor, tip, mounted, () => ({ side: props.side, offset: 8 }))
31
+ const { style, side: placed, ready } = useFloating(anchor, tip, mounted, () => ({ side, offset: 8 }))
35
32
  // Vue sets a bare number as no length at all, so the place gets its unit here.
36
33
  // The tip grows out of the edge of the target it points to, a sliver as wide as the target, and folds back into it.
37
- const liquid = createLiquid(
38
- () => tip.value,
39
- () => tipEdge(anchor.value, placed.value),
40
- )
34
+ const liquid = createMorph(() => tip.value, { origin: () => tipEdge(anchor.value, placed.value) })
41
35
  watch([state, () => mounted.value && ready.value], ([s, on]) => on && liquid.play(s), { flush: 'post' })
42
36
 
43
37
  // When it shows and hides (motion/tooltip.ts).
44
38
  const timer = createTipTimer(
45
39
  (v) => (open.value = v),
46
- () => props.delay,
40
+ () => delay,
47
41
  )
48
42
 
49
43
  // Esc hides it without moving focus (WCAG 1.4.13), and only it, not a dialog behind it.
@@ -83,6 +77,7 @@ const trigger = () => {
83
77
  ref="tip"
84
78
  role="tooltip"
85
79
  :class="styles.tip"
80
+ data-slot="tooltip-content"
86
81
  :data-state="state"
87
82
  :data-side="placed"
88
83
  :style="style"
@@ -1,3 +1,4 @@
1
+ @layer gooee.components {
1
2
  /* Clip, not display: none, so screen readers still read it */
2
3
  .root,
3
4
  .focusable:not(:focus-within) {
@@ -11,3 +12,4 @@
11
12
  clip-path: inset(50%);
12
13
  white-space: nowrap;
13
14
  }
15
+ }
@@ -8,5 +8,5 @@ export type VisuallyHiddenProps = ComponentPropsWithRef<'span'> & {
8
8
  }
9
9
 
10
10
  export function VisuallyHidden({ focusable = false, className, ...rest }: VisuallyHiddenProps) {
11
- return <span className={cx(focusable ? styles.focusable : styles.root, className)} {...rest} />
11
+ return <span className={cx(focusable ? styles.focusable : styles.root, className)} data-slot="visually-hidden" {...rest} />
12
12
  }