@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
package/dist/module.mjs CHANGED
@@ -1,128 +1,10 @@
1
- import defu, { defu as defu$1 } from 'defu';
2
- import { defineNuxtModule, createResolver, addVitePlugin, addPlugin, addComponentsDir, addImportsDir, extendPages, hasNuxtModule, installModule } from '@nuxt/kit';
3
- import { d as defaultOptions, r as resolveColors, a as getDefaultUiConfig, b as addTemplates, c as buildTemplates } from './shared/ui.d52SSCwA.mjs';
4
- import { addCustomTab } from '@nuxt/devtools-kit';
5
- import sirv from 'sirv';
6
- import 'get-port-please';
7
- import { kebabCase, camelCase } from 'scule';
8
- import fs from 'node:fs';
1
+ import { defu } from 'defu';
2
+ import { defineNuxtModule, createResolver, addVitePlugin, addPlugin, addComponentsDir, addImportsDir, hasNuxtModule, installModule } from '@nuxt/kit';
3
+ import { d as defaultOptions, r as resolveColors, a as getDefaultUiConfig, b as addTemplates } from './shared/ui.DSPu6Y8j.mjs';
9
4
  import '../dist/runtime/utils/index.js';
10
5
  import 'node:url';
11
-
12
- const devtoolsComponentMeta = {};
13
- function extractDevtoolsMeta(code) {
14
- const match = code.match(/extendDevtoolsMeta(?:<.*?>)?\(/);
15
- if (!match)
16
- return null;
17
- const startIndex = code.indexOf(match[0]) + match[0].length;
18
- let openBraceCount = 0;
19
- let closeBraceCount = 0;
20
- let endIndex = startIndex;
21
- for (let i = startIndex; i < code.length; i++) {
22
- if (code[i] === "{")
23
- openBraceCount++;
24
- if (code[i] === "}")
25
- closeBraceCount++;
26
- if (openBraceCount > 0 && openBraceCount === closeBraceCount) {
27
- endIndex = i + 1;
28
- break;
29
- }
30
- }
31
- return code.slice(startIndex, endIndex).trim();
32
- }
33
- function devtoolsMetaPlugin({ resolve, options, templates }) {
34
- return {
35
- name: "ui-devtools-component-meta",
36
- enforce: "pre",
37
- async transform(code, id) {
38
- if (!id.match(/\/runtime\/components\/\w+.vue/))
39
- return;
40
- const fileName = id.split("/")[id.split("/").length - 1];
41
- if (code && fileName) {
42
- const slug = kebabCase(fileName.replace(/\..*/, ""));
43
- const match = extractDevtoolsMeta(code);
44
- if (match) {
45
- const metaObject = new Function(`return ${match}`)();
46
- devtoolsComponentMeta[slug] = { meta: { devtools: { ...metaObject } } };
47
- }
48
- }
49
- return {
50
- code
51
- };
52
- },
53
- configureServer(server) {
54
- server.middlewares.use("/__nuxt_ui__/devtools/api/component-meta", async (_req, res) => {
55
- res.setHeader("Content-Type", "application/json");
56
- try {
57
- const componentMeta = await import('./chunks/component-meta.mjs');
58
- const meta = defu(
59
- Object.entries(componentMeta.default).reduce((acc, [key, value]) => {
60
- if (!key.startsWith("U"))
61
- return acc;
62
- const name = key.substring(1);
63
- const slug = kebabCase(name);
64
- const template = templates?.[camelCase(name)];
65
- if (devtoolsComponentMeta[slug] === void 0) {
66
- const path = resolve(`./runtime/components/${name}.vue`);
67
- const code = fs.readFileSync(path, "utf-8");
68
- const match = extractDevtoolsMeta(code);
69
- if (match) {
70
- const metaObject = new Function(`return ${match}`)();
71
- devtoolsComponentMeta[slug] = { meta: { devtools: { ...metaObject } } };
72
- } else {
73
- devtoolsComponentMeta[slug] = null;
74
- }
75
- }
76
- value.meta.props = value.meta.props.map((prop) => {
77
- let defaultValue = prop.default ? prop.default : prop?.tags?.find((tag) => tag.name === "defaultValue" && !tag.text?.includes("appConfig"))?.text ?? template?.defaultVariants?.[prop.name];
78
- if (typeof defaultValue === "string")
79
- defaultValue = defaultValue?.replaceAll(/["'`]/g, "");
80
- if (defaultValue === "true")
81
- defaultValue = true;
82
- if (defaultValue === "false")
83
- defaultValue = false;
84
- if (!Number.isNaN(Number.parseInt(defaultValue)))
85
- defaultValue = Number.parseInt(defaultValue);
86
- return {
87
- ...prop,
88
- default: defaultValue
89
- };
90
- });
91
- const label = key.replace(/^U/, options.prefix ?? "U");
92
- acc[kebabCase(key.replace(/^U/, ""))] = { ...value, label, slug };
93
- return acc;
94
- }, {}),
95
- devtoolsComponentMeta
96
- );
97
- res.end(JSON.stringify(meta));
98
- } catch (error) {
99
- console.error(`Failed to fetch component meta`, error);
100
- res.statusCode = 500;
101
- res.end(JSON.stringify({ error: "Failed to fetch component meta" }));
102
- }
103
- });
104
- server.middlewares.use("/__nuxt_ui__/devtools/api/component-example", async (req, res) => {
105
- const query = new URL(req.url, "http://localhost").searchParams;
106
- const name = query.get("component");
107
- if (!name) {
108
- res.statusCode = 400;
109
- res.end(JSON.stringify({ error: "Component name is required" }));
110
- return;
111
- }
112
- try {
113
- const path = resolve(`./devtools/runtime/examples/${name}.vue`);
114
- const source = fs.readFileSync(path, "utf-8");
115
- res.setHeader("Content-Type", "application/json");
116
- res.end(JSON.stringify({ component: name, source }));
117
- } catch (error) {
118
- console.error(`Failed to read component source for ${name}:`, error);
119
- res.statusCode = 500;
120
- res.end(JSON.stringify({ error: "Failed to read component source" }));
121
- }
122
- });
123
- }
124
- };
125
- }
6
+ import 'scule';
7
+ import 'tailwindcss/colors';
126
8
 
127
9
  const module = defineNuxtModule({
128
10
  meta: {
@@ -131,7 +13,7 @@ const module = defineNuxtModule({
131
13
  compatibility: {
132
14
  nuxt: ">=3.13.1"
133
15
  },
134
- docs: "https://ui3.nuxt.dev/getting-started/installation"
16
+ docs: "https://ui3.nuxt.dev/getting-started/installation/nuxt"
135
17
  },
136
18
  defaults: defaultOptions,
137
19
  async setup(options, nuxt) {
@@ -140,7 +22,7 @@ const module = defineNuxtModule({
140
22
  options.theme.colors = resolveColors(options.theme.colors);
141
23
  nuxt.options.ui = options;
142
24
  nuxt.options.alias["#ui"] = resolve("./runtime");
143
- nuxt.options.appConfig.ui = defu$1(nuxt.options.appConfig.ui || {}, getDefaultUiConfig(options.theme.colors));
25
+ nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui || {}, getDefaultUiConfig(options.theme.colors));
144
26
  nuxt.options.app.rootAttrs = nuxt.options.app.rootAttrs || {};
145
27
  nuxt.options.app.rootAttrs.class = [nuxt.options.app.rootAttrs.class, "isolate"].filter(Boolean).join(" ");
146
28
  if (nuxt.options.builder === "@nuxt/vite-builder") {
@@ -149,23 +31,21 @@ const module = defineNuxtModule({
149
31
  } else {
150
32
  nuxt.options.postcss.plugins["@tailwindcss/postcss"] = {};
151
33
  }
152
- async function registerModule(name, options2) {
34
+ async function registerModule(name, key, options2) {
153
35
  if (!hasNuxtModule(name)) {
154
36
  await installModule(name, options2);
155
37
  } else {
156
- nuxt.options[name] = defu$1(nuxt.options[name], options2);
38
+ nuxt.options[key] = defu(nuxt.options[key], options2);
157
39
  }
158
40
  }
159
- await registerModule("@nuxt/icon", { cssLayer: "components" });
41
+ await registerModule("@nuxt/icon", "icon", { cssLayer: "components" });
160
42
  if (options.fonts) {
161
- await registerModule("@nuxt/fonts", { experimental: { processCSSVariables: true } });
43
+ await registerModule("@nuxt/fonts", "fonts", { experimental: { processCSSVariables: true } });
162
44
  }
163
45
  if (options.colorMode) {
164
- await registerModule("@nuxtjs/color-mode", { classSuffix: "", disableTransition: true });
46
+ await registerModule("@nuxtjs/color-mode", "colorMode", { classSuffix: "", disableTransition: true });
165
47
  }
166
48
  addPlugin({ src: resolve("./runtime/plugins/colors") });
167
- addPlugin({ src: resolve("./runtime/plugins/modal") });
168
- addPlugin({ src: resolve("./runtime/plugins/slideover") });
169
49
  addComponentsDir({
170
50
  path: resolve("./runtime/components"),
171
51
  prefix: options.prefix,
@@ -173,42 +53,6 @@ const module = defineNuxtModule({
173
53
  });
174
54
  addImportsDir(resolve("./runtime/composables"));
175
55
  addTemplates(options, nuxt, resolve);
176
- if (nuxt.options.dev && nuxt.options.devtools.enabled && options.devtools?.enabled) {
177
- const templates = buildTemplates(options);
178
- nuxt.options.vite = defu$1(nuxt.options?.vite, { plugins: [devtoolsMetaPlugin({ resolve, templates, options })] });
179
- {
180
- nuxt.hook("vite:serverCreated", async (server) => {
181
- server.middlewares.use("/__nuxt_ui__/devtools", sirv(resolve("../dist/client/devtools"), {
182
- single: true,
183
- dev: true
184
- }));
185
- });
186
- }
187
- nuxt.options.routeRules = defu$1(nuxt.options.routeRules, { "/__nuxt_ui__/**": { ssr: false } });
188
- extendPages((pages) => {
189
- if (pages.length) {
190
- pages.unshift({
191
- name: "ui-devtools",
192
- path: "/__nuxt_ui__/components/:slug",
193
- file: resolve("./devtools/runtime/DevtoolsRenderer.vue"),
194
- meta: {
195
- // https://github.com/nuxt/nuxt/pull/29366
196
- // isolate: true
197
- layout: false
198
- }
199
- });
200
- }
201
- });
202
- addCustomTab({
203
- name: "nuxt-ui",
204
- title: "Nuxt UI",
205
- icon: "/__nuxt_ui__/devtools/favicon.svg",
206
- view: {
207
- type: "iframe",
208
- src: "/__nuxt_ui__/devtools"
209
- }
210
- });
211
- }
212
56
  }
213
57
  });
214
58
 
@@ -1,15 +1,14 @@
1
1
  <script lang="ts">
2
- import { tv } from 'tailwind-variants'
3
- import type { AccordionRootProps, AccordionRootEmits } from 'radix-vue'
2
+ import type { AccordionRootProps, AccordionRootEmits } from 'reka-ui'
4
3
  import type { AppConfig } from '@nuxt/schema'
5
4
  import _appConfig from '#build/app.config'
6
5
  import theme from '#build/ui/accordion'
7
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
6
+ import { tv } from '../utils/tv'
8
7
  import type { DynamicSlots } from '../types/utils'
9
8
 
10
- const appConfig = _appConfig as AppConfig & { ui: { accordion: Partial<typeof theme> } }
9
+ const appConfigAccordion = _appConfig as AppConfig & { ui: { accordion: Partial<typeof theme> } }
11
10
 
12
- const accordion = tv({ extend: tv(theme), ...(appConfig.ui?.accordion || {}) })
11
+ const accordion = tv({ extend: tv(theme), ...(appConfigAccordion.ui?.accordion || {}) })
13
12
 
14
13
  export interface AccordionItem {
15
14
  label?: string
@@ -22,7 +21,7 @@ export interface AccordionItem {
22
21
  disabled?: boolean
23
22
  }
24
23
 
25
- export interface AccordionProps<T> extends Pick<AccordionRootProps, 'collapsible' | 'defaultValue' | 'modelValue' | 'type' | 'disabled'> {
24
+ export interface AccordionProps<T> extends Pick<AccordionRootProps, 'collapsible' | 'defaultValue' | 'modelValue' | 'type' | 'disabled' | 'unmountOnHide'> {
26
25
  /**
27
26
  * The element or component this component should render as.
28
27
  * @defaultValue 'div'
@@ -54,42 +53,11 @@ export type AccordionSlots<T extends { slot?: string }> = {
54
53
  content: SlotProps<T>
55
54
  body: SlotProps<T>
56
55
  } & DynamicSlots<T, SlotProps<T>>
57
-
58
- extendDevtoolsMeta({
59
- defaultProps: {
60
- items: [{
61
- label: 'Getting Started',
62
- icon: 'i-lucide-info',
63
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.'
64
- }, {
65
- label: 'Installation',
66
- icon: 'i-lucide-download',
67
- disabled: true,
68
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.'
69
- }, {
70
- label: 'Theming',
71
- icon: 'i-lucide-pipette',
72
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.'
73
- }, {
74
- label: 'Layouts',
75
- icon: 'i-lucide-layout-dashboard',
76
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.'
77
- }, {
78
- label: 'Components',
79
- icon: 'i-lucide-layers-3',
80
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.'
81
- }, {
82
- label: 'Utilities',
83
- icon: 'i-lucide-wrench',
84
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.'
85
- }]
86
- }
87
- })
88
56
  </script>
89
57
 
90
58
  <script setup lang="ts" generic="T extends AccordionItem">
91
59
  import { computed } from 'vue'
92
- import { AccordionRoot, AccordionItem, AccordionHeader, AccordionTrigger, AccordionContent, useForwardPropsEmits } from 'radix-vue'
60
+ import { AccordionRoot, AccordionItem, AccordionHeader, AccordionTrigger, AccordionContent, useForwardPropsEmits } from 'reka-ui'
93
61
  import { reactivePick } from '@vueuse/core'
94
62
  import { useAppConfig } from '#imports'
95
63
  import { get } from '../utils'
@@ -98,13 +66,14 @@ import UIcon from './Icon.vue'
98
66
  const props = withDefaults(defineProps<AccordionProps<T>>(), {
99
67
  type: 'single',
100
68
  collapsible: true,
69
+ unmountOnHide: true,
101
70
  labelKey: 'label'
102
71
  })
103
72
  const emits = defineEmits<AccordionEmits>()
104
73
  const slots = defineSlots<AccordionSlots<T>>()
105
74
 
106
75
  const appConfig = useAppConfig()
107
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'collapsible', 'defaultValue', 'disabled', 'modelValue', 'type'), emits)
76
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'collapsible', 'defaultValue', 'disabled', 'modelValue', 'type', 'unmountOnHide'), emits)
108
77
 
109
78
  const ui = computed(() => accordion({
110
79
  disabled: props.disabled
@@ -1,14 +1,14 @@
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/alert'
6
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
6
+ import { tv } from '../utils/tv'
7
7
  import type { AvatarProps, ButtonProps } from '../types'
8
8
 
9
- const appConfig = _appConfig as AppConfig & { ui: { alert: Partial<typeof theme> } }
9
+ const appConfigAlert = _appConfig as AppConfig & { ui: { alert: Partial<typeof theme> } }
10
10
 
11
- const alert = tv({ extend: tv(theme), ...(appConfig.ui?.alert || {}) })
11
+ const alert = tv({ extend: tv(theme), ...(appConfigAlert.ui?.alert || {}) })
12
12
 
13
13
  type AlertVariants = VariantProps<typeof alert>
14
14
 
@@ -24,20 +24,21 @@ export interface AlertProps {
24
24
  avatar?: AvatarProps
25
25
  color?: AlertVariants['color']
26
26
  variant?: AlertVariants['variant']
27
+ orientation?: AlertVariants['orientation']
27
28
  /**
28
29
  * Display a list of actions:
29
- * - under the title and description if multiline
30
- * - next to the close button if not multiline
30
+ * - under the title and description when orientation is `vertical`
31
+ * - next to the close button when orientation is `horizontal`
31
32
  * `{ size: 'xs' }`{lang="ts-type"}
32
33
  */
33
34
  actions?: ButtonProps[]
34
35
  /**
35
36
  * Display a close button to dismiss the alert.
36
37
  * `{ size: 'md', color: 'neutral', variant: 'link' }`{lang="ts-type"}
37
- * @emits `close`
38
+ * @emits 'update:open'
38
39
  * @defaultValue false
39
40
  */
40
- close?: ButtonProps | boolean
41
+ close?: boolean | Partial<ButtonProps>
41
42
  /**
42
43
  * The icon displayed in the close button.
43
44
  * @defaultValue appConfig.ui.icons.close
@@ -58,36 +59,36 @@ export interface AlertSlots {
58
59
  actions(props?: {}): any
59
60
  close(props: { ui: any }): any
60
61
  }
61
-
62
- extendDevtoolsMeta<AlertProps>({ defaultProps: { title: 'Heads up!' } })
63
62
  </script>
64
63
 
65
64
  <script setup lang="ts">
66
65
  import { computed } from 'vue'
67
- import { Primitive } from 'radix-vue'
66
+ import { Primitive } from 'reka-ui'
68
67
  import { useAppConfig } from '#imports'
69
68
  import { useLocale } from '../composables/useLocale'
70
69
  import UIcon from './Icon.vue'
71
70
  import UAvatar from './Avatar.vue'
72
71
  import UButton from './Button.vue'
73
72
 
74
- const props = defineProps<AlertProps>()
73
+ const props = withDefaults(defineProps<AlertProps>(), {
74
+ orientation: 'vertical'
75
+ })
75
76
  const emits = defineEmits<AlertEmits>()
76
77
  const slots = defineSlots<AlertSlots>()
77
78
 
78
- const appConfig = useAppConfig()
79
79
  const { t } = useLocale()
80
-
81
- const multiline = computed(() => !!props.title && !!props.description)
80
+ const appConfig = useAppConfig()
82
81
 
83
82
  const ui = computed(() => alert({
84
83
  color: props.color,
85
- variant: props.variant
84
+ variant: props.variant,
85
+ orientation: props.orientation,
86
+ title: !!props.title || !!slots.title
86
87
  }))
87
88
  </script>
88
89
 
89
90
  <template>
90
- <Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root], multiline })">
91
+ <Primitive :as="as" :data-orientation="orientation" :class="ui.root({ class: [props.class, props.ui?.root] })">
91
92
  <slot name="leading">
92
93
  <UAvatar v-if="avatar" :size="((props.ui?.avatarSize || ui.avatarSize()) as AvatarProps['size'])" v-bind="avatar" :class="ui.avatar({ class: props.ui?.avatar })" />
93
94
  <UIcon v-else-if="icon" :name="icon" :class="ui.icon({ class: props.ui?.icon })" />
@@ -105,15 +106,15 @@ const ui = computed(() => alert({
105
106
  </slot>
106
107
  </div>
107
108
 
108
- <div v-if="multiline && actions?.length" :class="ui.actions({ class: props.ui?.actions, multiline: true })">
109
+ <div v-if="orientation === 'vertical' && actions?.length" :class="ui.actions({ class: props.ui?.actions })">
109
110
  <slot name="actions">
110
111
  <UButton v-for="(action, index) in actions" :key="index" size="xs" v-bind="action" />
111
112
  </slot>
112
113
  </div>
113
114
  </div>
114
115
 
115
- <div v-if="(!multiline && actions?.length) || close" :class="ui.actions({ class: props.ui?.actions, multiline: false })">
116
- <template v-if="!multiline">
116
+ <div v-if="(orientation === 'horizontal' && actions?.length) || close" :class="ui.actions({ class: props.ui?.actions, orientation: 'horizontal' })">
117
+ <template v-if="orientation === 'horizontal' && actions?.length">
117
118
  <slot name="actions">
118
119
  <UButton v-for="(action, index) in actions" :key="index" size="xs" v-bind="action" />
119
120
  </slot>
@@ -127,7 +128,7 @@ const ui = computed(() => alert({
127
128
  color="neutral"
128
129
  variant="link"
129
130
  :aria-label="t('alert.close')"
130
- v-bind="typeof close === 'object' ? close : undefined"
131
+ v-bind="(typeof close === 'object' ? close as Partial<ButtonProps> : {})"
131
132
  :class="ui.close({ class: props.ui?.close })"
132
133
  @click="emits('update:open', false)"
133
134
  />
@@ -1,11 +1,9 @@
1
1
  <script lang="ts">
2
- import type { ConfigProviderProps, TooltipProviderProps } from 'radix-vue'
2
+ import type { ConfigProviderProps, TooltipProviderProps } from 'reka-ui'
3
3
  import { localeContextInjectionKey } from '../composables/useLocale'
4
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
5
4
  import type { ToasterProps, Locale } from '../types'
6
- import { en } from '../locale'
7
5
 
8
- export interface AppProps extends Omit<ConfigProviderProps, 'useId' | 'dir'> {
6
+ export interface AppProps extends Omit<ConfigProviderProps, 'useId' | 'dir' | 'locale'> {
9
7
  tooltip?: TooltipProviderProps
10
8
  toaster?: ToasterProps | null
11
9
  locale?: Locale
@@ -18,17 +16,14 @@ export interface AppSlots {
18
16
  export default {
19
17
  name: 'App'
20
18
  }
21
-
22
- extendDevtoolsMeta({ ignore: true })
23
19
  </script>
24
20
 
25
21
  <script setup lang="ts">
26
- import { toRef, useId, provide, computed } from 'vue'
27
- import { ConfigProvider, TooltipProvider, useForwardProps } from 'radix-vue'
22
+ import { toRef, useId, provide } from 'vue'
23
+ import { ConfigProvider, TooltipProvider, useForwardProps } from 'reka-ui'
28
24
  import { reactivePick } from '@vueuse/core'
29
25
  import UToaster from './Toaster.vue'
30
- import UModalProvider from './ModalProvider.vue'
31
- import USlideoverProvider from './SlideoverProvider.vue'
26
+ import UOverlayProvider from './OverlayProvider.vue'
32
27
 
33
28
  const props = defineProps<AppProps>()
34
29
  defineSlots<AppSlots>()
@@ -37,20 +32,19 @@ const configProviderProps = useForwardProps(reactivePick(props, 'scrollBody'))
37
32
  const tooltipProps = toRef(() => props.tooltip)
38
33
  const toasterProps = toRef(() => props.toaster)
39
34
 
40
- const locale = computed(() => props.locale || en)
35
+ const locale = toRef(() => props.locale)
41
36
  provide(localeContextInjectionKey, locale)
42
37
  </script>
43
38
 
44
39
  <template>
45
- <ConfigProvider :use-id="() => (useId() as string)" :dir="locale.dir" v-bind="configProviderProps">
40
+ <ConfigProvider :use-id="() => (useId() as string)" :dir="locale?.dir" :locale="locale?.code" v-bind="configProviderProps">
46
41
  <TooltipProvider v-bind="tooltipProps">
47
42
  <UToaster v-if="toaster !== null" v-bind="toasterProps">
48
43
  <slot />
49
44
  </UToaster>
50
45
  <slot v-else />
51
- </TooltipProvider>
52
46
 
53
- <UModalProvider />
54
- <USlideoverProvider />
47
+ <UOverlayProvider />
48
+ </TooltipProvider>
55
49
  </ConfigProvider>
56
50
  </template>
@@ -1,18 +1,17 @@
1
1
  <script lang="ts">
2
- import { tv, type VariantProps } from 'tailwind-variants'
3
- import type { AvatarFallbackProps } from 'radix-vue'
2
+ import type { VariantProps } from 'tailwind-variants'
4
3
  import type { AppConfig } from '@nuxt/schema'
5
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
6
4
  import _appConfig from '#build/app.config'
7
5
  import theme from '#build/ui/avatar'
6
+ import { tv } from '../utils/tv'
8
7
 
9
- const appConfig = _appConfig as AppConfig & { ui: { avatar: Partial<typeof theme> } }
8
+ const appConfigAvatar = _appConfig as AppConfig & { ui: { avatar: Partial<typeof theme> } }
10
9
 
11
- const avatar = tv({ extend: tv(theme), ...(appConfig.ui?.avatar || {}) })
10
+ const avatar = tv({ extend: tv(theme), ...(appConfigAvatar.ui?.avatar || {}) })
12
11
 
13
12
  type AvatarVariants = VariantProps<typeof avatar>
14
13
 
15
- export interface AvatarProps extends Pick<AvatarFallbackProps, 'delayMs'> {
14
+ export interface AvatarProps {
16
15
  /**
17
16
  * The element or component this component should render as.
18
17
  * @defaultValue 'span'
@@ -27,23 +26,22 @@ export interface AvatarProps extends Pick<AvatarFallbackProps, 'delayMs'> {
27
26
  ui?: Partial<typeof avatar.slots>
28
27
  }
29
28
 
30
- extendDevtoolsMeta<AvatarProps>({ defaultProps: { src: 'https://avatars.githubusercontent.com/u/739984?v=4', alt: 'Benjamin Canac' } })
29
+ export interface AvatarSlots {
30
+ default(props?: {}): any
31
+ }
31
32
  </script>
32
33
 
33
34
  <script setup lang="ts">
34
- import { computed } from 'vue'
35
- import { AvatarRoot, AvatarImage, AvatarFallback, useForwardProps } from 'radix-vue'
36
- import { reactivePick } from '@vueuse/core'
35
+ import { ref, computed, watch } from 'vue'
36
+ import { Primitive } from 'reka-ui'
37
+ import ImageComponent from '#build/ui-image-component'
37
38
  import { useAvatarGroup } from '../composables/useAvatarGroup'
38
39
  import UIcon from './Icon.vue'
39
- import ImageComponent from '#build/ui-image-component'
40
40
 
41
41
  defineOptions({ inheritAttrs: false })
42
42
 
43
43
  const props = withDefaults(defineProps<AvatarProps>(), { as: 'span' })
44
44
 
45
- const fallbackProps = useForwardProps(reactivePick(props, 'delayMs'))
46
-
47
45
  const fallback = computed(() => props.text || (props.alt || '').split(' ').map(word => word.charAt(0)).join('').substring(0, 2))
48
46
 
49
47
  const { size } = useAvatarGroup(props)
@@ -64,24 +62,38 @@ const sizePx = computed(() => ({
64
62
  '2xl': 44,
65
63
  '3xl': 48
66
64
  })[props.size || 'md'])
65
+
66
+ const error = ref(false)
67
+
68
+ watch(() => props.src, () => {
69
+ if (error.value) {
70
+ error.value = false
71
+ }
72
+ })
73
+
74
+ function onError() {
75
+ error.value = true
76
+ }
67
77
  </script>
68
78
 
69
79
  <template>
70
- <AvatarRoot :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
71
- <AvatarImage
72
- v-if="src"
73
- :as="ImageComponent"
80
+ <Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
81
+ <component
82
+ :is="ImageComponent"
83
+ v-if="src && !error"
84
+ role="img"
74
85
  :src="src"
75
86
  :alt="alt"
76
87
  :width="sizePx"
77
88
  :height="sizePx"
78
89
  v-bind="$attrs"
79
90
  :class="ui.image({ class: props.ui?.image })"
91
+ @error="onError"
80
92
  />
81
93
 
82
- <AvatarFallback as-child v-bind="fallbackProps">
94
+ <slot v-else>
83
95
  <UIcon v-if="icon" :name="icon" :class="ui.icon({ class: props.ui?.icon })" />
84
- <span v-else :class="ui.fallback({ class: props.ui?.fallback })">{{ fallback }}</span>
85
- </AvatarFallback>
86
- </AvatarRoot>
96
+ <span v-else :class="ui.fallback({ class: props.ui?.fallback })">{{ fallback || '&nbsp;' }}</span>
97
+ </slot>
98
+ </Primitive>
87
99
  </template>
@@ -1,13 +1,13 @@
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/avatar-group'
6
- import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
6
+ import { tv } from '../utils/tv'
7
7
 
8
- const appConfig = _appConfig as AppConfig & { ui: { avatarGroup: Partial<typeof theme> } }
8
+ const appConfigAvatarGroup = _appConfig as AppConfig & { ui: { avatarGroup: Partial<typeof theme> } }
9
9
 
10
- const avatarGroup = tv({ extend: tv(theme), ...(appConfig.ui?.avatarGroup || {}) })
10
+ const avatarGroup = tv({ extend: tv(theme), ...(appConfigAvatarGroup.ui?.avatarGroup || {}) })
11
11
 
12
12
  type AvatarGroupVariants = VariantProps<typeof avatarGroup>
13
13
 
@@ -29,13 +29,11 @@ export interface AvatarGroupProps {
29
29
  export interface AvatarGroupSlots {
30
30
  default(props?: {}): any
31
31
  }
32
-
33
- extendDevtoolsMeta({ example: 'AvatarGroupExample' })
34
32
  </script>
35
33
 
36
34
  <script setup lang="ts">
37
35
  import { computed, provide } from 'vue'
38
- import { Primitive } from 'radix-vue'
36
+ import { Primitive } from 'reka-ui'
39
37
  import { avatarGroupInjectionKey } from '../composables/useAvatarGroup'
40
38
  import UAvatar from './Avatar.vue'
41
39