@nuxt/ui 3.0.0-alpha.8 → 3.0.0-alpha.9

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 (121) hide show
  1. package/.nuxt/ui/button.ts +1 -1
  2. package/.nuxt/ui/card.ts +1 -1
  3. package/.nuxt/ui/carousel.ts +2 -2
  4. package/.nuxt/ui/container.ts +1 -1
  5. package/.nuxt/ui/index.ts +2 -0
  6. package/.nuxt/ui/input-menu.ts +3 -3
  7. package/.nuxt/ui/input-number.ts +204 -0
  8. package/.nuxt/ui/input.ts +2 -2
  9. package/.nuxt/ui/navigation-menu.ts +1 -1
  10. package/.nuxt/ui/pin-input.ts +145 -0
  11. package/.nuxt/ui/select-menu.ts +8 -13
  12. package/.nuxt/ui/select.ts +2 -2
  13. package/.nuxt/ui/table.ts +1 -0
  14. package/.nuxt/ui/tabs.ts +1 -1
  15. package/.nuxt/ui/textarea.ts +2 -2
  16. package/.nuxt/ui/toaster.ts +1 -1
  17. package/.nuxt/ui/tooltip.ts +1 -1
  18. package/README.md +52 -12
  19. package/cli/commands/{init.mjs → make/component.mjs} +4 -4
  20. package/cli/commands/make/index.mjs +14 -0
  21. package/cli/commands/make/locale.mjs +64 -0
  22. package/cli/index.mjs +2 -2
  23. package/cli/templates.mjs +46 -1
  24. package/cli/utils.mjs +14 -0
  25. package/dist/chunks/component-meta.cjs +7320 -3335
  26. package/dist/chunks/component-meta.mjs +7320 -3335
  27. package/dist/client/devtools/200.html +1 -1
  28. package/dist/client/devtools/404.html +1 -1
  29. package/dist/client/devtools/_nuxt/{hKiujHsR.js → BDC8ywlR.js} +1 -1
  30. package/dist/client/devtools/_nuxt/{DM3_wAgz.js → BT004Uxp.js} +22 -31
  31. package/dist/client/devtools/_nuxt/{Bj9hdafK.js → C1H2Soz3.js} +1 -1
  32. package/dist/client/devtools/_nuxt/builds/latest.json +1 -1
  33. package/dist/client/devtools/_nuxt/builds/meta/f98c13ea-d751-4b37-8ce3-94e99708745f.json +1 -0
  34. package/dist/client/devtools/_nuxt/entry.Bx6WJjrx.css +1 -0
  35. package/dist/client/devtools/_nuxt/error-404.Cq4qshcf.css +1 -0
  36. package/dist/client/devtools/_nuxt/error-500.ax1aM34m.css +1 -0
  37. package/dist/client/devtools/index.html +1 -1
  38. package/dist/module.cjs +13 -12
  39. package/dist/module.json +1 -1
  40. package/dist/module.mjs +13 -12
  41. package/dist/runtime/components/Alert.vue +4 -1
  42. package/dist/runtime/components/App.vue +11 -5
  43. package/dist/runtime/components/Breadcrumb.vue +8 -3
  44. package/dist/runtime/components/Carousel.vue +11 -7
  45. package/dist/runtime/components/CommandPalette.vue +5 -3
  46. package/dist/runtime/components/ContextMenuContent.vue +2 -0
  47. package/dist/runtime/components/DropdownMenuContent.vue +2 -0
  48. package/dist/runtime/components/Form.vue +18 -20
  49. package/dist/runtime/components/FormField.vue +7 -3
  50. package/dist/runtime/components/InputMenu.vue +97 -21
  51. package/dist/runtime/components/InputNumber.vue +192 -0
  52. package/dist/runtime/components/Link.vue +19 -5
  53. package/dist/runtime/components/Modal.vue +12 -3
  54. package/dist/runtime/components/NavigationMenu.vue +4 -2
  55. package/dist/runtime/components/Pagination.vue +12 -5
  56. package/dist/runtime/components/PinInput.vue +96 -0
  57. package/dist/runtime/components/Popover.vue +17 -1
  58. package/dist/runtime/components/Select.vue +1 -1
  59. package/dist/runtime/components/SelectMenu.vue +106 -30
  60. package/dist/runtime/components/Slideover.vue +12 -3
  61. package/dist/runtime/components/Table.vue +11 -1
  62. package/dist/runtime/components/Textarea.vue +1 -1
  63. package/dist/runtime/components/Toast.vue +4 -1
  64. package/dist/runtime/components/Toaster.vue +22 -14
  65. package/dist/runtime/composables/defineLocale.d.ts +9 -0
  66. package/dist/runtime/composables/defineLocale.js +4 -0
  67. package/dist/runtime/composables/useFormField.d.ts +4 -1
  68. package/dist/runtime/composables/useFormField.js +1 -1
  69. package/dist/runtime/composables/useLocale.d.ts +4 -0
  70. package/dist/runtime/composables/useLocale.js +10 -0
  71. package/dist/runtime/index.css +1 -1
  72. package/dist/runtime/locale/ar.d.ts +2 -0
  73. package/dist/runtime/locale/ar.js +47 -0
  74. package/dist/runtime/locale/cs.d.ts +2 -0
  75. package/dist/runtime/locale/cs.js +46 -0
  76. package/dist/runtime/locale/de.d.ts +2 -0
  77. package/dist/runtime/locale/de.js +46 -0
  78. package/dist/runtime/locale/en.d.ts +2 -0
  79. package/dist/runtime/locale/en.js +46 -0
  80. package/dist/runtime/locale/es.d.ts +2 -0
  81. package/dist/runtime/locale/es.js +46 -0
  82. package/dist/runtime/locale/fa_ir.d.ts +2 -0
  83. package/dist/runtime/locale/fa_ir.js +47 -0
  84. package/dist/runtime/locale/fr.d.ts +2 -0
  85. package/dist/runtime/locale/fr.js +46 -0
  86. package/dist/runtime/locale/index.d.ts +12 -0
  87. package/dist/runtime/locale/index.js +12 -0
  88. package/dist/runtime/locale/it.d.ts +2 -0
  89. package/dist/runtime/locale/it.js +46 -0
  90. package/dist/runtime/locale/pl.d.ts +2 -0
  91. package/dist/runtime/locale/pl.js +46 -0
  92. package/dist/runtime/locale/ru.d.ts +2 -0
  93. package/dist/runtime/locale/ru.js +46 -0
  94. package/dist/runtime/locale/zh_hans.d.ts +2 -0
  95. package/dist/runtime/locale/zh_hans.js +46 -0
  96. package/dist/runtime/locale/zh_hant.d.ts +2 -0
  97. package/dist/runtime/locale/zh_hant.js +46 -0
  98. package/dist/runtime/types/form.d.ts +7 -2
  99. package/dist/runtime/types/index.d.ts +3 -0
  100. package/dist/runtime/types/index.js +3 -0
  101. package/dist/runtime/types/locale.d.ts +48 -0
  102. package/dist/runtime/types/locale.js +0 -0
  103. package/dist/runtime/utils/form.d.ts +5 -9
  104. package/dist/runtime/utils/form.js +115 -50
  105. package/dist/runtime/utils/link.d.ts +1 -1
  106. package/dist/runtime/utils/locale.d.ts +15 -0
  107. package/dist/runtime/utils/locale.js +25 -0
  108. package/dist/shared/{ui.BU7wzH0D.cjs → ui.BPnAe4QS.cjs} +194 -36
  109. package/dist/shared/{ui.BufKhDiD.mjs → ui.d52SSCwA.mjs} +194 -36
  110. package/dist/unplugin.cjs +1 -1
  111. package/dist/unplugin.d.cts +5 -3
  112. package/dist/unplugin.d.mts +5 -3
  113. package/dist/unplugin.d.ts +5 -3
  114. package/dist/unplugin.mjs +1 -1
  115. package/dist/vite.cjs +1 -1
  116. package/dist/vite.mjs +1 -1
  117. package/package.json +33 -26
  118. package/dist/client/devtools/_nuxt/builds/meta/e6b425f7-b919-4014-915b-0ea07c316790.json +0 -1
  119. package/dist/client/devtools/_nuxt/entry.DaJP-ZMB.css +0 -24
  120. package/dist/client/devtools/_nuxt/error-404.B0Nmv3fV.css +0 -1
  121. package/dist/client/devtools/_nuxt/error-500.C8fgTxVz.css +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![nuxt-ui.png](https://repository-images.githubusercontent.com/428329515/43fec891-9030-4601-8233-5d45ba5c6013)](https://ui.nuxt.com)
2
2
 
3
- # Nuxt UI v3
3
+ # Nuxt UI
4
4
 
5
5
  [![npm version][npm-version-src]][npm-version-href]
6
6
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
@@ -9,9 +9,14 @@
9
9
 
10
10
  We're thrilled to introduce Nuxt UI v3, a significant upgrade to our UI library that delivers extensive improvements and robust new capabilities. This major update harnesses the combined strengths of [Radix Vue](https://www.radix-vue.com/), [Tailwind CSS v4](https://tailwindcss.com/blog/tailwindcss-v4-alpha), and [Tailwind Variants](https://www.tailwind-variants.org/) to offer developers an unparalleled set of tools for creating sophisticated, accessible, and highly performant user interfaces.
11
11
 
12
- ## Installation
12
+ > [!NOTE]
13
+ > You are on the `v3` development branch, check out the [dev branch](https://github.com/nuxt/ui) for Nuxt UI v2.
14
+
15
+ ## Documentation
13
16
 
14
- 1. Install the Nuxt UI v3 alpha package:
17
+ Visit https://ui3.nuxt.dev to explore the documentation.
18
+
19
+ ## Installation
15
20
 
16
21
  ```bash [pnpm]
17
22
  pnpm add @nuxt/ui@next
@@ -29,10 +34,9 @@ npm install @nuxt/ui@next
29
34
  bun add @nuxt/ui@next
30
35
  ```
31
36
 
32
- > [!WARNING]
33
- > Make sure you have `typescript` installed in your dev dependencies.
37
+ ### Nuxt
34
38
 
35
- 2. Register the Nuxt UI module in your `nuxt.config.ts`:
39
+ 1. Add the Nuxt UI module in your `nuxt.config.ts`:
36
40
 
37
41
  ```ts [nuxt.config.ts]
38
42
  export default defineNuxtConfig({
@@ -40,18 +44,54 @@ export default defineNuxtConfig({
40
44
  })
41
45
  ```
42
46
 
43
- 3. Import Tailwind CSS and Nuxt UI in your `app.vue` or [CSS](https://nuxt.com/docs/getting-started/styling#the-css-property):
47
+ 2. Import Tailwind CSS and Nuxt UI in your CSS:
44
48
 
45
- ```vue [app.vue]
46
- <style>
49
+ ```css [assets/css/main.css]
47
50
  @import "tailwindcss";
48
51
  @import "@nuxt/ui";
49
- </style>
50
52
  ```
51
53
 
52
- ## Documentation
54
+ Learn more in the [installation guide](https://ui3.nuxt.dev/getting-started/installation/nuxt).
53
55
 
54
- Visit https://ui3.nuxt.dev to explore the documentation.
56
+ ### Vue
57
+
58
+ 1. Add the Nuxt UI Vite plugin in your `vite.config.ts`:
59
+
60
+ ```ts [vite.config.ts]
61
+ import { defineConfig } from 'vite'
62
+ import vue from '@vitejs/plugin-vue'
63
+ import ui from '@nuxt/ui/vite'
64
+
65
+ export default defineConfig({
66
+ plugins: [
67
+ vue(),
68
+ ui()
69
+ ]
70
+ })
71
+ ```
72
+
73
+ 2. Use the Nuxt UI Vue plugin in your `main.ts`:
74
+
75
+ ```ts [main.ts]
76
+ import { createApp } from 'vue'
77
+ import ui from '@nuxt/ui/vue-plugin'
78
+ import App from './App.vue'
79
+
80
+ const app = createApp(App)
81
+
82
+ app.use(ui)
83
+
84
+ app.mount('#app')
85
+ ```
86
+
87
+ 3. Import Tailwind CSS and Nuxt UI in your CSS:
88
+
89
+ ```css [assets/main.css]
90
+ @import "tailwindcss";
91
+ @import "@nuxt/ui";
92
+ ```
93
+
94
+ Learn more in the [installation guide](https://ui3.nuxt.dev/getting-started/installation/vue).
55
95
 
56
96
  ## Credits
57
97
 
@@ -3,13 +3,13 @@ import { resolve } from 'pathe'
3
3
  import { defineCommand } from 'citty'
4
4
  import { consola } from 'consola'
5
5
  import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
6
- import { appendFile, sortFile } from '../utils.mjs'
7
- import templates from '../templates.mjs'
6
+ import { appendFile, sortFile } from '../../utils.mjs'
7
+ import templates from '../../templates.mjs'
8
8
 
9
9
  export default defineCommand({
10
10
  meta: {
11
- name: 'init',
12
- description: 'Init a new component.'
11
+ name: 'component',
12
+ description: 'Make a new component.'
13
13
  },
14
14
  args: {
15
15
  name: {
@@ -0,0 +1,14 @@
1
+ import { defineCommand } from 'citty'
2
+ import component from './component.mjs'
3
+ import locale from './locale.mjs'
4
+
5
+ export default defineCommand({
6
+ meta: {
7
+ name: 'make',
8
+ description: 'Commands to create new Nuxt UI entities.'
9
+ },
10
+ subCommands: {
11
+ component,
12
+ locale
13
+ }
14
+ })
@@ -0,0 +1,64 @@
1
+ import { existsSync, promises as fsp } from 'node:fs'
2
+ import { resolve } from 'pathe'
3
+ import { consola } from 'consola'
4
+ import { appendFile, sortFile, normalizeLocale } from '../../utils.mjs'
5
+ import { defineCommand } from 'citty'
6
+
7
+ export default defineCommand({
8
+ meta: {
9
+ name: 'locale',
10
+ description: 'Make a new locale.'
11
+ },
12
+ args: {
13
+ code: {
14
+ description: 'Locale code to create. For example: en.',
15
+ required: true
16
+ },
17
+ name: {
18
+ description: 'Locale name to create. For example: English.',
19
+ required: true
20
+ },
21
+ dir: {
22
+ description: 'Locale direction. For example: rtl.',
23
+ default: 'ltr'
24
+ }
25
+ },
26
+ async setup({ args }) {
27
+ const path = resolve('.')
28
+ const localePath = resolve(path, `src/runtime/locale`)
29
+
30
+ const originLocaleFilePath = resolve(localePath, 'en.ts')
31
+ const newLocaleFilePath = resolve(localePath, `${args.code}.ts`)
32
+
33
+ // Validate locale code
34
+ if (existsSync(newLocaleFilePath)) {
35
+ consola.error(`🚨 ${args.code} already exists!`)
36
+ process.exit(1)
37
+ }
38
+
39
+ if (!['ltr', 'rtl'].includes(args.dir)) {
40
+ consola.error(`🚨 Direction ${args.dir} not supported!`)
41
+ process.exit(1)
42
+ }
43
+
44
+ if (!args.code.match(/^[a-z]{2}(?:_[a-z]{2,4})?$/)) {
45
+ consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`)
46
+ process.exit(1)
47
+ }
48
+
49
+ // Create new locale export
50
+ const localeExportFile = resolve(localePath, `index.ts`)
51
+ await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`)
52
+ await sortFile(localeExportFile)
53
+
54
+ // Create new locale file
55
+ await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
56
+ const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
57
+ const rewrittenLocaleFile = localeFile
58
+ .replace(/name: '(.*)',/, `name: '${args.name}',`)
59
+ .replace(/code: '(.*)',/, `code: '${normalizeLocale(args.code)}',${(args.dir && args.dir !== 'ltr') ? `\n dir: '${args.dir}',` : ''}`)
60
+ await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
61
+
62
+ consola.success(`🪄 Generated ${newLocaleFilePath}`)
63
+ }
64
+ })
package/cli/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty'
3
- import init from './commands/init.mjs'
3
+ import make from './commands/make/index.mjs'
4
4
 
5
5
  const main = defineCommand({
6
6
  meta: {
@@ -8,7 +8,7 @@ const main = defineCommand({
8
8
  description: 'Nuxt UI CLI'
9
9
  },
10
10
  subCommands: {
11
- init
11
+ make
12
12
  }
13
13
  })
14
14
 
package/cli/templates.mjs CHANGED
@@ -163,9 +163,54 @@ describe('${upperName}', () => {
163
163
  }
164
164
  }
165
165
 
166
+ const doc = ({ name, pro }) => {
167
+ const kebabName = kebabCase(name)
168
+ const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
169
+
170
+ return {
171
+ filename: `docs/content/${pro ? 'pro' : '3.components'}/${kebabName}.md`,
172
+ contents: `---
173
+ description:
174
+ links: ${pro
175
+ ? ''
176
+ : `
177
+ - label: ${upperName}
178
+ icon: i-custom-radix-vue
179
+ to: https://www.radix-vue.com/components/${kebabName}.html`}
180
+ - label: GitHub
181
+ icon: i-simple-icons-github
182
+ to: https://github.com/nuxt/${pro ? 'ui-pro' : 'ui'}/tree/v3/src/runtime/components/${upperName}.vue
183
+ ---
184
+
185
+ ## Usage
186
+
187
+ ## Examples
188
+
189
+ ## API
190
+
191
+ ### Props
192
+
193
+ :component-props
194
+
195
+ ### Slots
196
+
197
+ :component-slots
198
+
199
+ ### Emits
200
+
201
+ :component-emits
202
+
203
+ ## Theme
204
+
205
+ :component-theme
206
+ `
207
+ }
208
+ }
209
+
166
210
  export default {
167
211
  playground,
168
212
  component,
169
213
  theme,
170
- test
214
+ test,
215
+ doc
171
216
  }
package/cli/utils.mjs CHANGED
@@ -15,3 +15,17 @@ export async function appendFile(path, contents) {
15
15
  await fsp.writeFile(path, file.trim() + '\n' + contents + '\n')
16
16
  }
17
17
  }
18
+
19
+ export function normalizeLocale(locale) {
20
+ if (!locale) {
21
+ return ''
22
+ }
23
+
24
+ if (locale.includes('_')) {
25
+ return locale.split('_')
26
+ .map((part, index) => index === 0 ? part.toLowerCase() : part.toUpperCase())
27
+ .join('-')
28
+ }
29
+
30
+ return locale.toLowerCase()
31
+ }