@nuxt/ui 3.0.0-alpha.9 → 3.0.0-beta.2

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 (289) hide show
  1. package/.nuxt/ui/accordion.ts +2 -2
  2. package/.nuxt/ui/alert.ts +122 -95
  3. package/.nuxt/ui/avatar-group.ts +14 -2
  4. package/.nuxt/ui/avatar.ts +16 -4
  5. package/.nuxt/ui/badge.ts +139 -93
  6. package/.nuxt/ui/breadcrumb.ts +5 -5
  7. package/.nuxt/ui/button-group.ts +13 -0
  8. package/.nuxt/ui/button.ts +167 -136
  9. package/.nuxt/ui/calendar.ts +103 -0
  10. package/.nuxt/ui/card.ts +27 -1
  11. package/.nuxt/ui/carousel.ts +7 -5
  12. package/.nuxt/ui/checkbox.ts +45 -27
  13. package/.nuxt/ui/chip.ts +44 -15
  14. package/.nuxt/ui/color-picker.ts +47 -0
  15. package/.nuxt/ui/command-palette.ts +28 -18
  16. package/.nuxt/ui/container.ts +1 -1
  17. package/.nuxt/ui/context-menu.ts +64 -46
  18. package/.nuxt/ui/drawer.ts +83 -15
  19. package/.nuxt/ui/dropdown-menu.ts +65 -47
  20. package/.nuxt/ui/form-field.ts +15 -7
  21. package/.nuxt/ui/index.ts +5 -1
  22. package/.nuxt/ui/input-menu.ts +150 -116
  23. package/.nuxt/ui/input-number.ts +102 -71
  24. package/.nuxt/ui/input.ts +111 -76
  25. package/.nuxt/ui/kbd.ts +18 -6
  26. package/.nuxt/ui/link.ts +3 -3
  27. package/.nuxt/ui/modal.ts +8 -7
  28. package/.nuxt/ui/navigation-menu.ts +244 -131
  29. package/.nuxt/ui/pin-input.ts +77 -51
  30. package/.nuxt/ui/popover.ts +2 -2
  31. package/.nuxt/ui/progress.ts +111 -72
  32. package/.nuxt/ui/radio-group.ts +45 -22
  33. package/.nuxt/ui/select-menu.ts +122 -86
  34. package/.nuxt/ui/select.ts +120 -84
  35. package/.nuxt/ui/separator.ts +60 -31
  36. package/.nuxt/ui/skeleton.ts +1 -1
  37. package/.nuxt/ui/slideover.ts +17 -9
  38. package/.nuxt/ui/slider.ts +61 -38
  39. package/.nuxt/ui/stepper.ts +202 -0
  40. package/.nuxt/ui/switch.ts +40 -22
  41. package/.nuxt/ui/table.ts +48 -31
  42. package/.nuxt/ui/tabs.ts +100 -72
  43. package/.nuxt/ui/textarea.ts +111 -76
  44. package/.nuxt/ui/toast.ts +53 -33
  45. package/.nuxt/ui/toaster.ts +31 -15
  46. package/.nuxt/ui/tooltip.ts +2 -2
  47. package/.nuxt/ui/tree.ts +154 -0
  48. package/.nuxt/ui.css +92 -0
  49. package/README.md +19 -8
  50. package/cli/commands/make/component.mjs +12 -0
  51. package/cli/package.json +2 -2
  52. package/cli/templates.mjs +27 -22
  53. package/dist/module.cjs +9 -171
  54. package/dist/module.d.cts +5 -15
  55. package/dist/module.d.mts +5 -15
  56. package/dist/module.d.ts +5 -15
  57. package/dist/module.json +2 -2
  58. package/dist/module.mjs +12 -168
  59. package/dist/runtime/components/Accordion.vue +8 -39
  60. package/dist/runtime/components/Alert.vue +22 -21
  61. package/dist/runtime/components/App.vue +9 -15
  62. package/dist/runtime/components/Avatar.vue +33 -21
  63. package/dist/runtime/components/AvatarGroup.vue +5 -7
  64. package/dist/runtime/components/Badge.vue +10 -8
  65. package/dist/runtime/components/Breadcrumb.vue +5 -31
  66. package/dist/runtime/components/Button.vue +5 -8
  67. package/dist/runtime/components/ButtonGroup.vue +5 -7
  68. package/dist/runtime/components/Calendar.vue +194 -0
  69. package/dist/runtime/components/Card.vue +10 -9
  70. package/dist/runtime/components/Carousel.vue +15 -10
  71. package/dist/runtime/components/Checkbox.vue +32 -38
  72. package/dist/runtime/components/Chip.vue +6 -8
  73. package/dist/runtime/components/Collapsible.vue +10 -11
  74. package/dist/runtime/components/ColorPicker.vue +297 -0
  75. package/dist/runtime/components/CommandPalette.vue +111 -97
  76. package/dist/runtime/components/Container.vue +4 -7
  77. package/dist/runtime/components/ContextMenu.vue +16 -69
  78. package/dist/runtime/components/ContextMenuContent.vue +12 -10
  79. package/dist/runtime/components/Drawer.vue +23 -12
  80. package/dist/runtime/components/DropdownMenu.vue +18 -59
  81. package/dist/runtime/components/DropdownMenuContent.vue +12 -10
  82. package/dist/runtime/components/Form.vue +65 -34
  83. package/dist/runtime/components/FormField.vue +22 -13
  84. package/dist/runtime/components/Icon.vue +1 -1
  85. package/dist/runtime/components/Input.vue +15 -7
  86. package/dist/runtime/components/InputMenu.vue +95 -104
  87. package/dist/runtime/components/InputNumber.vue +14 -9
  88. package/dist/runtime/components/Kbd.vue +5 -6
  89. package/dist/runtime/components/Link.vue +5 -8
  90. package/dist/runtime/components/LinkBase.vue +1 -1
  91. package/dist/runtime/components/Modal.vue +51 -38
  92. package/dist/runtime/components/NavigationMenu.vue +129 -114
  93. package/dist/runtime/components/OverlayProvider.vue +29 -0
  94. package/dist/runtime/components/Pagination.vue +6 -9
  95. package/dist/runtime/components/PinInput.vue +10 -11
  96. package/dist/runtime/components/Popover.vue +16 -18
  97. package/dist/runtime/components/Progress.vue +28 -12
  98. package/dist/runtime/components/RadioGroup.vue +9 -12
  99. package/dist/runtime/components/Select.vue +60 -34
  100. package/dist/runtime/components/SelectMenu.vue +160 -165
  101. package/dist/runtime/components/Separator.vue +6 -5
  102. package/dist/runtime/components/Skeleton.vue +4 -7
  103. package/dist/runtime/components/Slideover.vue +51 -37
  104. package/dist/runtime/components/Slider.vue +8 -7
  105. package/dist/runtime/components/Stepper.vue +170 -0
  106. package/dist/runtime/components/Switch.vue +19 -23
  107. package/dist/runtime/components/Table.vue +146 -31
  108. package/dist/runtime/components/Tabs.vue +12 -31
  109. package/dist/runtime/components/Textarea.vue +17 -8
  110. package/dist/runtime/components/Toast.vue +36 -25
  111. package/dist/runtime/components/Toaster.vue +10 -11
  112. package/dist/runtime/components/Tooltip.vue +9 -12
  113. package/dist/runtime/components/Tree.vue +196 -0
  114. package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
  115. package/dist/runtime/composables/defineShortcuts.js +2 -2
  116. package/dist/runtime/composables/useFormField.d.ts +7 -3
  117. package/dist/runtime/composables/useFormField.js +18 -8
  118. package/dist/runtime/composables/useLocale.js +1 -1
  119. package/dist/runtime/composables/useOverlay.d.ts +30 -0
  120. package/dist/runtime/composables/useOverlay.js +71 -0
  121. package/dist/runtime/composables/useToast.d.ts +4 -3
  122. package/dist/runtime/composables/useToast.js +20 -6
  123. package/dist/runtime/index.css +1 -1
  124. package/dist/runtime/keyframes.css +1 -1
  125. package/dist/runtime/locale/ar.js +9 -1
  126. package/dist/runtime/locale/az.js +54 -0
  127. package/dist/runtime/locale/bn.js +54 -0
  128. package/dist/runtime/locale/cs.js +9 -1
  129. package/dist/runtime/locale/da.d.ts +2 -0
  130. package/dist/runtime/locale/da.js +54 -0
  131. package/dist/runtime/locale/de.js +11 -3
  132. package/dist/runtime/locale/el.d.ts +2 -0
  133. package/dist/runtime/locale/el.js +54 -0
  134. package/dist/runtime/locale/en.js +9 -1
  135. package/dist/runtime/locale/es.js +9 -1
  136. package/dist/runtime/locale/et.d.ts +2 -0
  137. package/dist/runtime/locale/et.js +54 -0
  138. package/dist/runtime/locale/fa_ir.js +9 -1
  139. package/dist/runtime/locale/fi.d.ts +2 -0
  140. package/dist/runtime/locale/fi.js +54 -0
  141. package/dist/runtime/locale/fr.js +9 -1
  142. package/dist/runtime/locale/he.d.ts +2 -0
  143. package/dist/runtime/locale/he.js +53 -0
  144. package/dist/runtime/locale/hi.d.ts +2 -0
  145. package/dist/runtime/locale/hi.js +54 -0
  146. package/dist/runtime/locale/hu.d.ts +2 -0
  147. package/dist/runtime/locale/hu.js +54 -0
  148. package/dist/runtime/locale/id.d.ts +2 -0
  149. package/dist/runtime/locale/id.js +54 -0
  150. package/dist/runtime/locale/index.d.ts +25 -3
  151. package/dist/runtime/locale/index.js +25 -3
  152. package/dist/runtime/locale/it.js +9 -1
  153. package/dist/runtime/locale/ja.d.ts +2 -0
  154. package/dist/runtime/locale/ja.js +54 -0
  155. package/dist/runtime/locale/km.d.ts +2 -0
  156. package/dist/runtime/locale/km.js +54 -0
  157. package/dist/runtime/locale/ko.d.ts +2 -0
  158. package/dist/runtime/locale/ko.js +54 -0
  159. package/dist/runtime/locale/nb_no.d.ts +2 -0
  160. package/dist/runtime/locale/nb_no.js +54 -0
  161. package/dist/runtime/locale/nl.d.ts +2 -0
  162. package/dist/runtime/locale/nl.js +54 -0
  163. package/dist/runtime/locale/pl.js +9 -1
  164. package/dist/runtime/locale/pt.d.ts +2 -0
  165. package/dist/runtime/locale/pt.js +54 -0
  166. package/dist/runtime/locale/pt_br.d.ts +2 -0
  167. package/dist/runtime/locale/pt_br.js +54 -0
  168. package/dist/runtime/locale/ru.js +9 -1
  169. package/dist/runtime/locale/sk.d.ts +2 -0
  170. package/dist/runtime/locale/sk.js +54 -0
  171. package/dist/runtime/locale/sv.d.ts +2 -0
  172. package/dist/runtime/locale/sv.js +54 -0
  173. package/dist/runtime/locale/th.d.ts +2 -0
  174. package/dist/runtime/locale/th.js +54 -0
  175. package/dist/runtime/locale/tr.d.ts +2 -0
  176. package/dist/runtime/locale/tr.js +54 -0
  177. package/dist/runtime/locale/uk.d.ts +2 -0
  178. package/dist/runtime/locale/uk.js +54 -0
  179. package/dist/runtime/locale/vi.d.ts +2 -0
  180. package/dist/runtime/locale/vi.js +54 -0
  181. package/dist/runtime/locale/zh_cn.d.ts +2 -0
  182. package/dist/runtime/locale/{zh_hans.js → zh_cn.js} +10 -2
  183. package/dist/runtime/locale/zh_tw.d.ts +2 -0
  184. package/dist/runtime/locale/{zh_hant.js → zh_tw.js} +16 -8
  185. package/dist/runtime/plugins/colors.js +8 -5
  186. package/dist/runtime/types/form.d.ts +24 -15
  187. package/dist/runtime/types/form.js +2 -2
  188. package/dist/runtime/types/index.d.ts +5 -0
  189. package/dist/runtime/types/index.js +5 -0
  190. package/dist/runtime/types/locale.d.ts +8 -0
  191. package/dist/runtime/types/utils.d.ts +7 -3
  192. package/dist/runtime/utils/form.d.ts +4 -4
  193. package/dist/runtime/utils/form.js +6 -8
  194. package/dist/runtime/utils/index.d.ts +1 -1
  195. package/dist/runtime/utils/index.js +15 -2
  196. package/dist/runtime/utils/tv.d.ts +1 -0
  197. package/dist/runtime/utils/tv.js +4 -0
  198. package/dist/runtime/vue/components/Icon.vue +2 -2
  199. package/dist/runtime/vue/components/Link.vue +87 -23
  200. package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
  201. package/dist/runtime/vue/composables/useAppConfig.js +2 -0
  202. package/dist/runtime/vue/plugins/head.d.ts +1 -1
  203. package/dist/runtime/vue/plugins/head.js +3 -3
  204. package/dist/runtime/vue/stubs.d.ts +19 -0
  205. package/dist/runtime/vue/stubs.js +37 -0
  206. package/dist/shared/{ui.d52SSCwA.mjs → ui.DSPu6Y8j.mjs} +905 -401
  207. package/dist/shared/{ui.BPnAe4QS.cjs → ui.DfK2RX6G.cjs} +908 -401
  208. package/dist/unplugin.cjs +62 -26
  209. package/dist/unplugin.d.cts +13 -1
  210. package/dist/unplugin.d.mts +13 -1
  211. package/dist/unplugin.d.ts +13 -1
  212. package/dist/unplugin.mjs +61 -25
  213. package/dist/vite.cjs +3 -2
  214. package/dist/vite.d.cts +2 -0
  215. package/dist/vite.d.mts +2 -0
  216. package/dist/vite.d.ts +2 -0
  217. package/dist/vite.mjs +3 -2
  218. package/package.json +103 -67
  219. package/dist/chunks/component-meta.cjs +0 -77249
  220. package/dist/chunks/component-meta.mjs +0 -77247
  221. package/dist/client/devtools/200.html +0 -1
  222. package/dist/client/devtools/404.html +0 -1
  223. package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKK58UfivUw4aw-SK92LTmKP0.woff2 +0 -0
  224. package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKy58UfivUw-9uYm8d48E4.woff2 +0 -0
  225. package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu0-K6z9mXg-VNw7NHvqnp.woff2 +0 -0
  226. package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu6-K6z9mXgjU0-EkYdMs3MAX.woff2 +0 -0
  227. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-7DW3w-R7n06NbhGy.woff +0 -0
  228. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDG3w-leGNfkTmsj.woff +0 -0
  229. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDW3w-ciElMF03ku.woff +0 -0
  230. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JCm3w-sB722Uoa0f.woff +0 -0
  231. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JDW3w-PBDI1JDjwV.woff +0 -0
  232. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8gCm3w-0q1hqVn09O.woff +0 -0
  233. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9XCm3w-ByvzuLy2fa.woff +0 -0
  234. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9uCm3w-5TKCIs6EEw.woff +0 -0
  235. package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat_XDW3w-r2swRDGfn2.woff +0 -0
  236. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAC5thTQ-ldB60l5U8r.woff +0 -0
  237. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpthTQ-wbFKGFDrgo.woff +0 -0
  238. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpxhTQ-LLUBv5jskj.woff +0 -0
  239. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwARZthTQ-F71RdTRbNg.woff +0 -0
  240. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwA_JxhTQ-6nh65gZkc0.woff +0 -0
  241. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAfJthTQ-aMoWEJLmTt.woff +0 -0
  242. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAkJxhTQ-WMBvmLOgKm.woff +0 -0
  243. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAop1hTQ-utGC2hnWq2.woff +0 -0
  244. package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAopxhTQ-YpyTieVa5B.woff +0 -0
  245. package/dist/client/devtools/_nuxt/BDC8ywlR.js +0 -1
  246. package/dist/client/devtools/_nuxt/BT004Uxp.js +0 -53
  247. package/dist/client/devtools/_nuxt/C1H2Soz3.js +0 -1
  248. package/dist/client/devtools/_nuxt/builds/latest.json +0 -1
  249. package/dist/client/devtools/_nuxt/builds/meta/f98c13ea-d751-4b37-8ce3-94e99708745f.json +0 -1
  250. package/dist/client/devtools/_nuxt/entry.Bx6WJjrx.css +0 -1
  251. package/dist/client/devtools/_nuxt/error-404.Cq4qshcf.css +0 -1
  252. package/dist/client/devtools/_nuxt/error-500.ax1aM34m.css +0 -1
  253. package/dist/client/devtools/favicon.svg +0 -1
  254. package/dist/client/devtools/index.html +0 -1
  255. package/dist/devtools/runtime/DevtoolsRenderer.vue +0 -53
  256. package/dist/devtools/runtime/examples/AvatarGroupExample.vue +0 -7
  257. package/dist/devtools/runtime/examples/ButtonGroupExample.vue +0 -8
  258. package/dist/devtools/runtime/examples/CardExample.vue +0 -13
  259. package/dist/devtools/runtime/examples/CarouselExample.vue +0 -13
  260. package/dist/devtools/runtime/examples/ChipExample.vue +0 -5
  261. package/dist/devtools/runtime/examples/CollapsibleExample.vue +0 -8
  262. package/dist/devtools/runtime/examples/CommandPaletteExample.vue +0 -29
  263. package/dist/devtools/runtime/examples/ContainerExample.vue +0 -5
  264. package/dist/devtools/runtime/examples/ContextMenuExample.vue +0 -5
  265. package/dist/devtools/runtime/examples/DrawerExample.vue +0 -8
  266. package/dist/devtools/runtime/examples/DropdownMenuExample.vue +0 -5
  267. package/dist/devtools/runtime/examples/FormExample.vue +0 -30
  268. package/dist/devtools/runtime/examples/FormFieldExample.vue +0 -5
  269. package/dist/devtools/runtime/examples/LinkExample.vue +0 -5
  270. package/dist/devtools/runtime/examples/ModalExample.vue +0 -8
  271. package/dist/devtools/runtime/examples/PopoverExample.vue +0 -8
  272. package/dist/devtools/runtime/examples/SkeletonExample.vue +0 -3
  273. package/dist/devtools/runtime/examples/SlideoverExample.vue +0 -8
  274. package/dist/devtools/runtime/examples/ToasterExample.vue +0 -11
  275. package/dist/devtools/runtime/examples/TooltipExample.vue +0 -5
  276. package/dist/runtime/components/ModalProvider.vue +0 -12
  277. package/dist/runtime/components/SlideoverProvider.vue +0 -12
  278. package/dist/runtime/composables/extendDevtoolsMeta.d.ts +0 -7
  279. package/dist/runtime/composables/extendDevtoolsMeta.js +0 -2
  280. package/dist/runtime/composables/useModal.d.ts +0 -17
  281. package/dist/runtime/composables/useModal.js +0 -46
  282. package/dist/runtime/composables/useSlideover.d.ts +0 -17
  283. package/dist/runtime/composables/useSlideover.js +0 -46
  284. package/dist/runtime/plugins/modal.d.ts +0 -2
  285. package/dist/runtime/plugins/modal.js +0 -10
  286. package/dist/runtime/plugins/slideover.d.ts +0 -2
  287. package/dist/runtime/plugins/slideover.js +0 -10
  288. /package/dist/runtime/locale/{zh_hans.d.ts → az.d.ts} +0 -0
  289. /package/dist/runtime/locale/{zh_hant.d.ts → bn.d.ts} +0 -0
@@ -1,44 +1,77 @@
1
1
  <!-- eslint-disable vue/block-tag-newline -->
2
2
  <script lang="ts">
3
3
  import type { Ref } from 'vue'
4
- import { tv, type VariantProps } from 'tailwind-variants'
4
+ import type { VariantProps } from 'tailwind-variants'
5
5
  import type { AppConfig } from '@nuxt/schema'
6
+ import type { RowData } from '@tanstack/table-core'
6
7
  import type {
7
- Row,
8
+ CellContext,
8
9
  ColumnDef,
10
+ ColumnFiltersOptions,
9
11
  ColumnFiltersState,
12
+ ColumnOrderState,
13
+ ColumnPinningOptions,
10
14
  ColumnPinningState,
11
- RowSelectionState,
12
- SortingState,
15
+ ColumnSizingInfoState,
16
+ ColumnSizingOptions,
17
+ ColumnSizingState,
18
+ CoreOptions,
19
+ ExpandedOptions,
13
20
  ExpandedState,
14
- VisibilityState,
21
+ FacetedOptions,
15
22
  GlobalFilterOptions,
16
- ColumnFiltersOptions,
17
- ColumnPinningOptions,
18
- VisibilityOptions,
19
- ExpandedOptions,
20
- SortingOptions,
23
+ GroupingOptions,
24
+ GroupingState,
25
+ HeaderContext,
26
+ PaginationOptions,
27
+ PaginationState,
28
+ Row,
29
+ RowPinningOptions,
30
+ RowPinningState,
21
31
  RowSelectionOptions,
32
+ RowSelectionState,
33
+ SortingOptions,
34
+ SortingState,
22
35
  Updater,
23
- CellContext,
24
- HeaderContext
36
+ VisibilityOptions,
37
+ VisibilityState
25
38
  } from '@tanstack/vue-table'
26
39
  import _appConfig from '#build/app.config'
27
40
  import theme from '#build/ui/table'
41
+ import { tv } from '../utils/tv'
28
42
 
29
- const appConfig = _appConfig as AppConfig & { ui: { table: Partial<typeof theme> } }
43
+ declare module '@tanstack/table-core' {
44
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
+ interface ColumnMeta<TData extends RowData, TValue> {
46
+ class?: {
47
+ th?: string
48
+ td?: string
49
+ }
50
+ }
51
+ }
30
52
 
31
- const table = tv({ extend: tv(theme), ...(appConfig.ui?.table || {}) })
53
+ const appConfigTable = _appConfig as AppConfig & { ui: { table: Partial<typeof theme> } }
54
+
55
+ const table = tv({ extend: tv(theme), ...(appConfigTable.ui?.table || {}) })
32
56
 
33
57
  type TableVariants = VariantProps<typeof table>
34
58
 
35
- export type TableColumn<T> = ColumnDef<T>
59
+ export type TableRow<T> = Row<T>
60
+ export type TableData = RowData
61
+ export type TableColumn<T extends TableData, D = unknown> = ColumnDef<T, D>
36
62
 
37
- export interface TableData {
38
- [key: string]: any
63
+ export interface TableOptions<T extends TableData> extends Omit<CoreOptions<T>, 'data' | 'columns' | 'getCoreRowModel' | 'state' | 'onStateChange' | 'renderFallbackValue'> {
64
+ state?: CoreOptions<T>['state']
65
+ onStateChange?: CoreOptions<T>['onStateChange']
66
+ renderFallbackValue?: CoreOptions<T>['renderFallbackValue']
39
67
  }
40
68
 
41
- export interface TableProps<T> {
69
+ export interface TableProps<T extends TableData> extends TableOptions<T> {
70
+ /**
71
+ * The element or component this component should render as.
72
+ * @defaultValue 'div'
73
+ */
74
+ as?: any
42
75
  data?: T[]
43
76
  columns?: TableColumn<T>[]
44
77
  caption?: string
@@ -66,6 +99,11 @@ export interface TableProps<T> {
66
99
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-pinning)
67
100
  */
68
101
  columnPinningOptions?: Omit<ColumnPinningOptions, 'onColumnPinningChange'>
102
+ /**
103
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#table-options)
104
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
105
+ */
106
+ columnSizingOptions?: Omit<ColumnSizingOptions, 'onColumnSizingChange' | 'onColumnSizingInfoChange'>
69
107
  /**
70
108
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#table-options)
71
109
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
@@ -76,6 +114,11 @@ export interface TableProps<T> {
76
114
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
77
115
  */
78
116
  sortingOptions?: Omit<SortingOptions<T>, 'getSortedRowModel' | 'onSortingChange'>
117
+ /**
118
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#table-options)
119
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
120
+ */
121
+ groupingOptions?: Omit<GroupingOptions, 'onGroupingChange'>
79
122
  /**
80
123
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#table-options)
81
124
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
@@ -86,6 +129,22 @@ export interface TableProps<T> {
86
129
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
87
130
  */
88
131
  rowSelectionOptions?: Omit<RowSelectionOptions<T>, 'onRowSelectionChange'>
132
+ /**
133
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#table-options)
134
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
135
+ */
136
+ rowPinningOptions?: Omit<RowPinningOptions<T>, 'onRowPinningChange'>
137
+ /**
138
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#table-options)
139
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
140
+ */
141
+ paginationOptions?: Omit<PaginationOptions, 'onPaginationChange'>
142
+ /**
143
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#table-options)
144
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
145
+ */
146
+ facetedOptions?: FacetedOptions<T>
147
+ onSelect?: (row: TableRow<T>, e?: Event) => void
89
148
  class?: any
90
149
  ui?: Partial<typeof table.slots>
91
150
  }
@@ -103,21 +162,17 @@ export type TableSlots<T> = {
103
162
 
104
163
  <script setup lang="ts" generic="T extends TableData">
105
164
  import { computed } from 'vue'
106
- import {
107
- FlexRender,
108
- getCoreRowModel,
109
- getFilteredRowModel,
110
- getSortedRowModel,
111
- getExpandedRowModel,
112
- useVueTable
113
- } from '@tanstack/vue-table'
165
+ import { Primitive } from 'reka-ui'
114
166
  import { upperFirst } from 'scule'
167
+ import { FlexRender, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getExpandedRowModel, useVueTable } from '@tanstack/vue-table'
168
+ import { reactiveOmit } from '@vueuse/core'
115
169
  import { useLocale } from '../composables/useLocale'
116
170
 
117
171
  const props = defineProps<TableProps<T>>()
118
172
  defineSlots<TableSlots<T>>()
119
173
 
120
174
  const { t } = useLocale()
175
+
121
176
  const data = computed(() => props.data ?? [])
122
177
  const columns = computed<TableColumn<T>[]>(() => props.columns ?? Object.keys(data.value[0] ?? {}).map((accessorKey: string) => ({ accessorKey, header: upperFirst(accessorKey) })))
123
178
 
@@ -130,13 +185,20 @@ const ui = computed(() => table({
130
185
 
131
186
  const globalFilterState = defineModel<string>('globalFilter', { default: undefined })
132
187
  const columnFiltersState = defineModel<ColumnFiltersState>('columnFilters', { default: [] })
188
+ const columnOrderState = defineModel<ColumnOrderState>('columnOrder', { default: [] })
133
189
  const columnVisibilityState = defineModel<VisibilityState>('columnVisibility', { default: {} })
134
190
  const columnPinningState = defineModel<ColumnPinningState>('columnPinning', { default: {} })
191
+ const columnSizingState = defineModel<ColumnSizingState>('columnSizing', { default: {} })
192
+ const columnSizingInfoState = defineModel<ColumnSizingInfoState>('columnSizingInfo', { default: {} })
135
193
  const rowSelectionState = defineModel<RowSelectionState>('rowSelection', { default: {} })
194
+ const rowPinningState = defineModel<RowPinningState>('rowPinning', { default: {} })
136
195
  const sortingState = defineModel<SortingState>('sorting', { default: [] })
196
+ const groupingState = defineModel<GroupingState>('grouping', { default: [] })
137
197
  const expandedState = defineModel<ExpandedState>('expanded', { default: {} })
198
+ const paginationState = defineModel<PaginationState>('pagination', { default: {} })
138
199
 
139
200
  const tableApi = useVueTable({
201
+ ...reactiveOmit(props, 'as', 'data', 'columns', 'caption', 'sticky', 'loading', 'loadingColor', 'loadingAnimation', 'class', 'ui'),
140
202
  data,
141
203
  columns: columns.value,
142
204
  getCoreRowModel: getCoreRowModel(),
@@ -145,18 +207,29 @@ const tableApi = useVueTable({
145
207
  ...(props.columnFiltersOptions || {}),
146
208
  getFilteredRowModel: getFilteredRowModel(),
147
209
  onColumnFiltersChange: updaterOrValue => valueUpdater(updaterOrValue, columnFiltersState),
210
+ onColumnOrderChange: updaterOrValue => valueUpdater(updaterOrValue, columnOrderState),
148
211
  ...(props.visibilityOptions || {}),
149
212
  onColumnVisibilityChange: updaterOrValue => valueUpdater(updaterOrValue, columnVisibilityState),
150
213
  ...(props.columnPinningOptions || {}),
151
214
  onColumnPinningChange: updaterOrValue => valueUpdater(updaterOrValue, columnPinningState),
215
+ ...(props.columnSizingOptions || {}),
216
+ onColumnSizingChange: updaterOrValue => valueUpdater(updaterOrValue, columnSizingState),
217
+ onColumnSizingInfoChange: updaterOrValue => valueUpdater(updaterOrValue, columnSizingInfoState),
152
218
  ...(props.rowSelectionOptions || {}),
153
219
  onRowSelectionChange: updaterOrValue => valueUpdater(updaterOrValue, rowSelectionState),
220
+ ...(props.rowPinningOptions || {}),
221
+ onRowPinningChange: updaterOrValue => valueUpdater(updaterOrValue, rowPinningState),
154
222
  ...(props.sortingOptions || {}),
155
223
  getSortedRowModel: getSortedRowModel(),
156
224
  onSortingChange: updaterOrValue => valueUpdater(updaterOrValue, sortingState),
225
+ ...(props.groupingOptions || {}),
226
+ onGroupingChange: updaterOrValue => valueUpdater(updaterOrValue, groupingState),
157
227
  ...(props.expandedOptions || {}),
158
228
  getExpandedRowModel: getExpandedRowModel(),
159
229
  onExpandedChange: updaterOrValue => valueUpdater(updaterOrValue, expandedState),
230
+ ...(props.paginationOptions || {}),
231
+ onPaginationChange: updaterOrValue => valueUpdater(updaterOrValue, paginationState),
232
+ ...(props.facetedOptions || {}),
160
233
  state: {
161
234
  get globalFilter() {
162
235
  return globalFilterState.value
@@ -164,6 +237,9 @@ const tableApi = useVueTable({
164
237
  get columnFilters() {
165
238
  return columnFiltersState.value
166
239
  },
240
+ get columnOrder() {
241
+ return columnOrderState.value
242
+ },
167
243
  get columnVisibility() {
168
244
  return columnVisibilityState.value
169
245
  },
@@ -178,6 +254,21 @@ const tableApi = useVueTable({
178
254
  },
179
255
  get sorting() {
180
256
  return sortingState.value
257
+ },
258
+ get grouping() {
259
+ return groupingState.value
260
+ },
261
+ get rowPinning() {
262
+ return rowPinningState.value
263
+ },
264
+ get columnSizing() {
265
+ return columnSizingState.value
266
+ },
267
+ get columnSizingInfo() {
268
+ return columnSizingInfoState.value
269
+ },
270
+ get pagination() {
271
+ return paginationState.value
181
272
  }
182
273
  }
183
274
  })
@@ -186,13 +277,29 @@ function valueUpdater<T extends Updater<any>>(updaterOrValue: T, ref: Ref) {
186
277
  ref.value = typeof updaterOrValue === 'function' ? updaterOrValue(ref.value) : updaterOrValue
187
278
  }
188
279
 
280
+ function handleRowSelect(row: TableRow<T>, e: Event) {
281
+ if (!props.onSelect) {
282
+ return
283
+ }
284
+ const target = e.target as HTMLElement
285
+ const isInteractive = target.closest('button')
286
+ if (isInteractive) {
287
+ return
288
+ }
289
+
290
+ e.preventDefault()
291
+ e.stopPropagation()
292
+
293
+ props.onSelect(row, e)
294
+ }
295
+
189
296
  defineExpose({
190
297
  tableApi
191
298
  })
192
299
  </script>
193
300
 
194
301
  <template>
195
- <div :class="ui.root({ class: [props.class, props.ui?.root] })">
302
+ <Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
196
303
  <table :class="ui.base({ class: [props.ui?.base] })">
197
304
  <caption v-if="caption" :class="ui.caption({ class: [props.ui?.caption] })">
198
305
  <slot name="caption">
@@ -206,7 +313,7 @@ defineExpose({
206
313
  v-for="header in headerGroup.headers"
207
314
  :key="header.id"
208
315
  :data-pinned="header.column.getIsPinned()"
209
- :class="ui.th({ class: [props.ui?.th], pinned: !!header.column.getIsPinned() })"
316
+ :class="ui.th({ class: [props.ui?.th, header.column.columnDef.meta?.class?.th], pinned: !!header.column.getIsPinned() })"
210
317
  >
211
318
  <slot :name="`${header.id}-header`" v-bind="header.getContext()">
212
319
  <FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.header" :props="header.getContext()" />
@@ -218,12 +325,20 @@ defineExpose({
218
325
  <tbody :class="ui.tbody({ class: [props.ui?.tbody] })">
219
326
  <template v-if="tableApi.getRowModel().rows?.length">
220
327
  <template v-for="row in tableApi.getRowModel().rows" :key="row.id">
221
- <tr :data-selected="row.getIsSelected()" :data-expanded="row.getIsExpanded()" :class="ui.tr({ class: [props.ui?.tr] })">
328
+ <tr
329
+ :data-selected="row.getIsSelected()"
330
+ :data-selectable="!!props.onSelect"
331
+ :data-expanded="row.getIsExpanded()"
332
+ :role="props.onSelect ? 'button' : undefined"
333
+ :tabindex="props.onSelect ? 0 : undefined"
334
+ :class="ui.tr({ class: [props.ui?.tr] })"
335
+ @click="handleRowSelect(row, $event)"
336
+ >
222
337
  <td
223
338
  v-for="cell in row.getVisibleCells()"
224
339
  :key="cell.id"
225
340
  :data-pinned="cell.column.getIsPinned()"
226
- :class="ui.td({ class: [props.ui?.td], pinned: !!cell.column.getIsPinned() })"
341
+ :class="ui.td({ class: [props.ui?.td, cell.column.columnDef.meta?.class?.td], pinned: !!cell.column.getIsPinned() })"
227
342
  >
228
343
  <slot :name="`${cell.column.id}-cell`" v-bind="cell.getContext()">
229
344
  <FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
@@ -247,5 +362,5 @@ defineExpose({
247
362
  </tr>
248
363
  </tbody>
249
364
  </table>
250
- </div>
365
+ </Primitive>
251
366
  </template>
@@ -1,16 +1,16 @@
1
1
  <script lang="ts">
2
- import { tv, type VariantProps } from 'tailwind-variants'
3
- import type { TabsRootProps, TabsRootEmits, TabsContentProps } from 'radix-vue'
2
+ import type { VariantProps } from 'tailwind-variants'
3
+ import type { TabsRootProps, TabsRootEmits } from 'reka-ui'
4
4
  import type { AppConfig } from '@nuxt/schema'
5
5
  import _appConfig from '#build/app.config'
6
6
  import theme from '#build/ui/tabs'
7
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
7
+ import { tv } from '../utils/tv'
8
8
  import type { AvatarProps } from '../types'
9
9
  import type { DynamicSlots, PartialString } from '../types/utils'
10
10
 
11
- const appConfig = _appConfig as AppConfig & { ui: { tabs: Partial<typeof theme> } }
11
+ const appConfigTabs = _appConfig as AppConfig & { ui: { tabs: Partial<typeof theme> } }
12
12
 
13
- const tabs = tv({ extend: tv(theme), ...(appConfig.ui?.tabs || {}) })
13
+ const tabs = tv({ extend: tv(theme), ...(appConfigTabs.ui?.tabs || {}) })
14
14
 
15
15
  export interface TabsItem {
16
16
  label?: string
@@ -25,7 +25,7 @@ export interface TabsItem {
25
25
 
26
26
  type TabsVariants = VariantProps<typeof tabs>
27
27
 
28
- export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode'> {
28
+ export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
29
29
  /**
30
30
  * The element or component this component should render as.
31
31
  * @defaultValue 'div'
@@ -44,7 +44,7 @@ export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defa
44
44
  * The content of the tabs, can be disabled to prevent rendering the content.
45
45
  * @defaultValue true
46
46
  */
47
- content?: boolean | Omit<TabsContentProps, 'as' | 'asChild' | 'value'>
47
+ content?: boolean
48
48
  /**
49
49
  * The key used to get the label from the item.
50
50
  * @defaultValue 'label'
@@ -64,30 +64,11 @@ export type TabsSlots<T extends { slot?: string }> = {
64
64
  trailing: SlotProps<T>
65
65
  content: SlotProps<T>
66
66
  } & DynamicSlots<T, SlotProps<T>>
67
-
68
- extendDevtoolsMeta({
69
- defaultProps: {
70
- items: [{
71
- label: 'Tab1',
72
- avatar: { src: 'https://avatars.githubusercontent.com/u/739984?v=4' },
73
- content: 'This is the content shown for Tab1'
74
- }, {
75
- label: 'Tab2',
76
- icon: 'i-lucide-user',
77
- content: 'And, this is the content for Tab2'
78
- }, {
79
- label: 'Tab3',
80
- icon: 'i-lucide-bell',
81
- content: 'Finally, this is the content for Tab3'
82
- }]
83
- }
84
- })
85
67
  </script>
86
68
 
87
69
  <script setup lang="ts" generic="T extends TabsItem">
88
- import { computed, toRef } from 'vue'
89
- import { defu } from 'defu'
90
- import { TabsRoot, TabsList, TabsIndicator, TabsTrigger, TabsContent, useForwardPropsEmits } from 'radix-vue'
70
+ import { computed } from 'vue'
71
+ import { TabsRoot, TabsList, TabsIndicator, TabsTrigger, TabsContent, useForwardPropsEmits } from 'reka-ui'
91
72
  import { reactivePick } from '@vueuse/core'
92
73
  import { get } from '../utils'
93
74
  import UIcon from './Icon.vue'
@@ -97,13 +78,13 @@ const props = withDefaults(defineProps<TabsProps<T>>(), {
97
78
  content: true,
98
79
  defaultValue: '0',
99
80
  orientation: 'horizontal',
81
+ unmountOnHide: true,
100
82
  labelKey: 'label'
101
83
  })
102
84
  const emits = defineEmits<TabsEmits>()
103
85
  const slots = defineSlots<TabsSlots<T>>()
104
86
 
105
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultValue', 'orientation', 'activationMode', 'modelValue'), emits)
106
- const contentProps = toRef(() => defu(props.content || {}, { forceMount: true }) as TabsContentProps)
87
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emits)
107
88
 
108
89
  const ui = computed(() => tabs({
109
90
  color: props.color,
@@ -133,7 +114,7 @@ const ui = computed(() => tabs({
133
114
  </TabsList>
134
115
 
135
116
  <template v-if="!!content">
136
- <TabsContent v-for="(item, index) of items" :key="index" v-bind="contentProps" :value="item.value || String(index)" :class="ui.content({ class: props.ui?.content })">
117
+ <TabsContent v-for="(item, index) of items" :key="index" :value="item.value || String(index)" :class="ui.content({ class: props.ui?.content })">
137
118
  <slot :name="item.slot || 'content'" :item="item" :index="index">
138
119
  {{ item.content }}
139
120
  </slot>
@@ -1,16 +1,23 @@
1
1
  <script lang="ts">
2
- import { tv, type VariantProps } from 'tailwind-variants'
2
+ import type { VariantProps } from 'tailwind-variants'
3
3
  import type { AppConfig } from '@nuxt/schema'
4
4
  import _appConfig from '#build/app.config'
5
5
  import theme from '#build/ui/textarea'
6
+ import { tv } from '../utils/tv'
7
+ import type { PartialString } from '../types/utils'
6
8
 
7
- const appConfig = _appConfig as AppConfig & { ui: { textarea: Partial<typeof theme> } }
9
+ const appConfigTextarea = _appConfig as AppConfig & { ui: { textarea: Partial<typeof theme> } }
8
10
 
9
- const textarea = tv({ extend: tv(theme), ...(appConfig.ui?.textarea || {}) })
11
+ const textarea = tv({ extend: tv(theme), ...(appConfigTextarea.ui?.textarea || {}) })
10
12
 
11
13
  type TextareaVariants = VariantProps<typeof textarea>
12
14
 
13
15
  export interface TextareaProps {
16
+ /**
17
+ * The element or component this component should render as.
18
+ * @defaultValue 'div'
19
+ */
20
+ as?: any
14
21
  id?: string
15
22
  name?: string
16
23
  /** The placeholder text when the textarea is empty. */
@@ -28,7 +35,7 @@ export interface TextareaProps {
28
35
  autoresize?: boolean
29
36
  /** Highlight the ring color like a focus state. */
30
37
  highlight?: boolean
31
- ui?: Partial<typeof textarea.slots>
38
+ ui?: PartialString<typeof textarea.slots>
32
39
  }
33
40
 
34
41
  export interface TextareaEmits {
@@ -44,6 +51,7 @@ export interface TextareaSlots {
44
51
 
45
52
  <script setup lang="ts">
46
53
  import { ref, computed, onMounted, nextTick, watch } from 'vue'
54
+ import { Primitive } from 'reka-ui'
47
55
  import { useFormField } from '../composables/useFormField'
48
56
  import { looseToNumber } from '../utils'
49
57
 
@@ -59,7 +67,7 @@ const emits = defineEmits<TextareaEmits>()
59
67
 
60
68
  const [modelValue, modelModifiers] = defineModel<string | number>()
61
69
 
62
- const { emitFormBlur, emitFormInput, emitFormChange, size, color, id, name, highlight, disabled } = useFormField<TextareaProps>(props)
70
+ const { emitFormFocus, emitFormBlur, emitFormInput, emitFormChange, size, color, id, name, highlight, disabled, ariaAttrs } = useFormField<TextareaProps>(props, { deferInputValidation: true })
63
71
 
64
72
  const ui = computed(() => textarea({
65
73
  color: color.value,
@@ -167,7 +175,7 @@ onMounted(() => {
167
175
  </script>
168
176
 
169
177
  <template>
170
- <div :class="ui.root({ class: [props.class, props.ui?.root] })">
178
+ <Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
171
179
  <textarea
172
180
  :id="id"
173
181
  ref="textareaRef"
@@ -178,12 +186,13 @@ onMounted(() => {
178
186
  :class="ui.base({ class: props.ui?.base })"
179
187
  :disabled="disabled"
180
188
  :required="required"
181
- v-bind="$attrs"
189
+ v-bind="{ ...$attrs, ...ariaAttrs }"
182
190
  @input="onInput"
183
191
  @blur="onBlur"
184
192
  @change="onChange"
193
+ @focus="emitFormFocus"
185
194
  />
186
195
 
187
196
  <slot />
188
- </div>
197
+ </Primitive>
189
198
  </template>
@@ -1,15 +1,16 @@
1
1
  <script lang="ts">
2
- import { tv, type VariantProps } from 'tailwind-variants'
3
- import type { ToastRootProps, ToastRootEmits } from 'radix-vue'
2
+ import type { VariantProps } from 'tailwind-variants'
3
+ import type { ToastRootProps, ToastRootEmits } from 'reka-ui'
4
4
  import type { AppConfig } from '@nuxt/schema'
5
5
  import _appConfig from '#build/app.config'
6
6
  import theme from '#build/ui/toast'
7
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
7
+ import { tv } from '../utils/tv'
8
8
  import type { AvatarProps, ButtonProps } from '../types'
9
+ import type { StringOrVNode } from '../types/utils'
9
10
 
10
- const appConfig = _appConfig as AppConfig & { ui: { toast: Partial<typeof theme> } }
11
+ const appConfigToast = _appConfig as AppConfig & { ui: { toast: Partial<typeof theme> } }
11
12
 
12
- const toast = tv({ extend: tv(theme), ...(appConfig.ui?.toast || {}) })
13
+ const toast = tv({ extend: tv(theme), ...(appConfigToast.ui?.toast || {}) })
13
14
 
14
15
  type ToastVariants = VariantProps<typeof toast>
15
16
 
@@ -19,15 +20,16 @@ export interface ToastProps extends Pick<ToastRootProps, 'defaultOpen' | 'open'
19
20
  * @defaultValue 'li'
20
21
  */
21
22
  as?: any
22
- title?: string
23
- description?: string
23
+ title?: StringOrVNode
24
+ description?: StringOrVNode
24
25
  icon?: string
25
26
  avatar?: AvatarProps
26
27
  color?: ToastVariants['color']
28
+ orientation?: ToastVariants['orientation']
27
29
  /**
28
30
  * Display a list of actions:
29
- * - under the title and description if multiline
30
- * - next to the close button if not multiline
31
+ * - under the title and description when orientation is `vertical`
32
+ * - next to the close button when orientation is `horizontal`
31
33
  * `{ size: 'xs' }`{lang="ts-type"}
32
34
  */
33
35
  actions?: ButtonProps[]
@@ -36,7 +38,7 @@ export interface ToastProps extends Pick<ToastRootProps, 'defaultOpen' | 'open'
36
38
  * `{ size: 'md', color: 'neutral', variant: 'link' }`{lang="ts-type"}
37
39
  * @defaultValue true
38
40
  */
39
- close?: ButtonProps | boolean
41
+ close?: boolean | Partial<ButtonProps>
40
42
  /**
41
43
  * The icon displayed in the close button.
42
44
  * @defaultValue appConfig.ui.icons.close
@@ -55,13 +57,11 @@ export interface ToastSlots {
55
57
  actions(props?: {}): any
56
58
  close(props: { ui: any }): any
57
59
  }
58
-
59
- extendDevtoolsMeta<ToastProps>({ ignore: true })
60
60
  </script>
61
61
 
62
62
  <script setup lang="ts">
63
63
  import { ref, computed, onMounted } from 'vue'
64
- import { ToastRoot, ToastTitle, ToastDescription, ToastAction, ToastClose, useForwardPropsEmits } from 'radix-vue'
64
+ import { ToastRoot, ToastTitle, ToastDescription, ToastAction, ToastClose, useForwardPropsEmits } from 'reka-ui'
65
65
  import { reactivePick } from '@vueuse/core'
66
66
  import { useAppConfig } from '#imports'
67
67
  import { useLocale } from '../composables/useLocale'
@@ -70,19 +70,21 @@ import UAvatar from './Avatar.vue'
70
70
  import UButton from './Button.vue'
71
71
 
72
72
  const props = withDefaults(defineProps<ToastProps>(), {
73
- close: true
73
+ close: true,
74
+ orientation: 'vertical'
74
75
  })
75
76
  const emits = defineEmits<ToastEmits>()
76
77
  const slots = defineSlots<ToastSlots>()
77
78
 
78
- const appConfig = useAppConfig()
79
79
  const { t } = useLocale()
80
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultOpen', 'open', 'duration', 'type'), emits)
80
+ const appConfig = useAppConfig()
81
81
 
82
- const multiline = computed(() => !!props.title && !!props.description)
82
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultOpen', 'open', 'duration', 'type'), emits)
83
83
 
84
84
  const ui = computed(() => toast({
85
- color: props.color
85
+ color: props.color,
86
+ orientation: props.orientation,
87
+ title: !!props.title || !!slots.title
86
88
  }))
87
89
 
88
90
  const el = ref()
@@ -108,7 +110,8 @@ defineExpose({
108
110
  ref="el"
109
111
  v-slot="{ remaining, duration }"
110
112
  v-bind="rootProps"
111
- :class="ui.root({ class: [props.class, props.ui?.root], multiline })"
113
+ :data-orientation="orientation"
114
+ :class="ui.root({ class: [props.class, props.ui?.root] })"
112
115
  :style="{ '--height': height }"
113
116
  >
114
117
  <slot name="leading">
@@ -119,16 +122,24 @@ defineExpose({
119
122
  <div :class="ui.wrapper({ class: props.ui?.wrapper })">
120
123
  <ToastTitle v-if="title || !!slots.title" :class="ui.title({ class: props.ui?.title })">
121
124
  <slot name="title">
122
- {{ title }}
125
+ <component :is="title()" v-if="typeof title === 'function'" />
126
+ <component :is="title" v-else-if="typeof title === 'object'" />
127
+ <template v-else>
128
+ {{ title }}
129
+ </template>
123
130
  </slot>
124
131
  </ToastTitle>
125
132
  <ToastDescription v-if="description || !!slots.description" :class="ui.description({ class: props.ui?.description })">
126
133
  <slot name="description">
127
- {{ description }}
134
+ <component :is="description()" v-if="typeof description === 'function'" />
135
+ <component :is="description" v-else-if="typeof description === 'object'" />
136
+ <template v-else>
137
+ {{ description }}
138
+ </template>
128
139
  </slot>
129
140
  </ToastDescription>
130
141
 
131
- <div v-if="multiline && actions?.length" :class="ui.actions({ class: props.ui?.actions, multiline: true })">
142
+ <div v-if="orientation === 'vertical' && actions?.length" :class="ui.actions({ class: props.ui?.actions })">
132
143
  <slot name="actions">
133
144
  <ToastAction v-for="(action, index) in actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
134
145
  <UButton size="xs" :color="color" v-bind="action" />
@@ -137,8 +148,8 @@ defineExpose({
137
148
  </div>
138
149
  </div>
139
150
 
140
- <div v-if="(!multiline && actions?.length) || close !== null" :class="ui.actions({ class: props.ui?.actions, multiline: false })">
141
- <template v-if="!multiline">
151
+ <div v-if="(orientation === 'horizontal' && actions?.length) || close" :class="ui.actions({ class: props.ui?.actions, orientation: 'horizontal' })">
152
+ <template v-if="orientation === 'horizontal' && actions?.length">
142
153
  <slot name="actions">
143
154
  <ToastAction v-for="(action, index) in actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
144
155
  <UButton size="xs" :color="color" v-bind="action" />
@@ -155,7 +166,7 @@ defineExpose({
155
166
  color="neutral"
156
167
  variant="link"
157
168
  :aria-label="t('toast.close')"
158
- v-bind="typeof close === 'object' ? close : undefined"
169
+ v-bind="(typeof close === 'object' ? close as Partial<ButtonProps> : {})"
159
170
  :class="ui.close({ class: props.ui?.close })"
160
171
  @click.stop
161
172
  />