@nuxt/ui 4.11.1 → 4.11.3

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 (106) hide show
  1. package/README.md +3 -3
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +2 -2
  4. package/dist/runtime/components/Accordion.d.vue.ts +1 -1
  5. package/dist/runtime/components/Accordion.vue.d.ts +1 -1
  6. package/dist/runtime/components/App.vue +2 -1
  7. package/dist/runtime/components/AuthForm.d.vue.ts +4 -0
  8. package/dist/runtime/components/AuthForm.vue.d.ts +4 -0
  9. package/dist/runtime/components/Breadcrumb.d.vue.ts +1 -1
  10. package/dist/runtime/components/Breadcrumb.vue.d.ts +1 -1
  11. package/dist/runtime/components/Carousel.d.vue.ts +1 -1
  12. package/dist/runtime/components/Carousel.vue.d.ts +1 -1
  13. package/dist/runtime/components/ChatPrompt.vue +1 -1
  14. package/dist/runtime/components/CheckboxGroup.d.vue.ts +1 -1
  15. package/dist/runtime/components/CheckboxGroup.vue.d.ts +1 -1
  16. package/dist/runtime/components/CommandPalette.d.vue.ts +1 -1
  17. package/dist/runtime/components/CommandPalette.vue.d.ts +1 -1
  18. package/dist/runtime/components/ContextMenu.d.vue.ts +1 -1
  19. package/dist/runtime/components/ContextMenu.vue.d.ts +1 -1
  20. package/dist/runtime/components/DashboardNavbar.vue +1 -1
  21. package/dist/runtime/components/DashboardSearch.vue +3 -3
  22. package/dist/runtime/components/DashboardSidebar.vue +3 -3
  23. package/dist/runtime/components/DropdownMenu.d.vue.ts +1 -1
  24. package/dist/runtime/components/DropdownMenu.vue.d.ts +1 -1
  25. package/dist/runtime/components/EditorToolbar.vue +6 -5
  26. package/dist/runtime/components/FooterColumns.d.vue.ts +1 -1
  27. package/dist/runtime/components/FooterColumns.vue.d.ts +1 -1
  28. package/dist/runtime/components/Form.d.vue.ts +2 -0
  29. package/dist/runtime/components/Form.vue +57 -30
  30. package/dist/runtime/components/Form.vue.d.ts +2 -0
  31. package/dist/runtime/components/Header.vue +3 -3
  32. package/dist/runtime/components/Input.vue +5 -5
  33. package/dist/runtime/components/InputDate.vue +12 -6
  34. package/dist/runtime/components/InputMenu.d.vue.ts +1 -1
  35. package/dist/runtime/components/InputMenu.vue +18 -7
  36. package/dist/runtime/components/InputMenu.vue.d.ts +1 -1
  37. package/dist/runtime/components/InputTime.vue +12 -6
  38. package/dist/runtime/components/LinkBase.vue +3 -1
  39. package/dist/runtime/components/Listbox.d.vue.ts +1 -1
  40. package/dist/runtime/components/Listbox.vue.d.ts +1 -1
  41. package/dist/runtime/components/NavigationMenu.d.vue.ts +1 -1
  42. package/dist/runtime/components/NavigationMenu.vue.d.ts +1 -1
  43. package/dist/runtime/components/PageAnchors.d.vue.ts +1 -1
  44. package/dist/runtime/components/PageAnchors.vue.d.ts +1 -1
  45. package/dist/runtime/components/PageLinks.d.vue.ts +1 -1
  46. package/dist/runtime/components/PageLinks.vue.d.ts +1 -1
  47. package/dist/runtime/components/PinInput.d.vue.ts +5 -3
  48. package/dist/runtime/components/PinInput.vue +15 -7
  49. package/dist/runtime/components/PinInput.vue.d.ts +5 -3
  50. package/dist/runtime/components/ProgressGroup.d.vue.ts +1 -1
  51. package/dist/runtime/components/ProgressGroup.vue.d.ts +1 -1
  52. package/dist/runtime/components/RadioGroup.d.vue.ts +1 -1
  53. package/dist/runtime/components/RadioGroup.vue.d.ts +1 -1
  54. package/dist/runtime/components/Select.d.vue.ts +1 -1
  55. package/dist/runtime/components/Select.vue +7 -1
  56. package/dist/runtime/components/Select.vue.d.ts +1 -1
  57. package/dist/runtime/components/SelectMenu.d.vue.ts +1 -1
  58. package/dist/runtime/components/SelectMenu.vue +22 -3
  59. package/dist/runtime/components/SelectMenu.vue.d.ts +1 -1
  60. package/dist/runtime/components/Splitter.d.vue.ts +1 -1
  61. package/dist/runtime/components/Splitter.vue.d.ts +1 -1
  62. package/dist/runtime/components/Stepper.d.vue.ts +1 -1
  63. package/dist/runtime/components/Stepper.vue.d.ts +1 -1
  64. package/dist/runtime/components/Table.vue +24 -2
  65. package/dist/runtime/components/Tabs.d.vue.ts +1 -1
  66. package/dist/runtime/components/Tabs.vue.d.ts +1 -1
  67. package/dist/runtime/components/Textarea.vue +5 -5
  68. package/dist/runtime/components/Timeline.d.vue.ts +1 -1
  69. package/dist/runtime/components/Timeline.vue.d.ts +1 -1
  70. package/dist/runtime/components/Toaster.vue +1 -1
  71. package/dist/runtime/components/Tree.d.vue.ts +1 -1
  72. package/dist/runtime/components/Tree.vue +1 -1
  73. package/dist/runtime/components/Tree.vue.d.ts +1 -1
  74. package/dist/runtime/components/content/ContentNavigation.d.vue.ts +1 -1
  75. package/dist/runtime/components/content/ContentNavigation.vue.d.ts +1 -1
  76. package/dist/runtime/components/content/ContentSearch.vue +3 -3
  77. package/dist/runtime/components/content/ContentSurround.d.vue.ts +1 -1
  78. package/dist/runtime/components/content/ContentSurround.vue.d.ts +1 -1
  79. package/dist/runtime/components/content/ContentToc.d.vue.ts +1 -1
  80. package/dist/runtime/components/content/ContentToc.vue.d.ts +1 -1
  81. package/dist/runtime/composables/useFilter.js +7 -1
  82. package/dist/runtime/composables/useFormField.d.ts +1 -1
  83. package/dist/runtime/composables/useFormField.js +8 -4
  84. package/dist/runtime/composables/useForwardProps.js +2 -2
  85. package/dist/runtime/composables/useOverlay.d.ts +2 -2
  86. package/dist/runtime/composables/useOverlay.js +5 -5
  87. package/dist/runtime/composables/useResizable.js +1 -1
  88. package/dist/runtime/index.css +1 -1
  89. package/dist/runtime/types/form.d.ts +3 -0
  90. package/dist/runtime/utils/form.js +3 -20
  91. package/dist/runtime/utils/index.js +22 -18
  92. package/dist/runtime/utils/virtualizer.d.ts +1 -1
  93. package/dist/runtime/utils/virtualizer.js +9 -11
  94. package/dist/runtime/vue/overrides/inertia/LinkBase.vue +3 -1
  95. package/dist/shared/{ui.DCJ9twx8.mjs → ui.CNAeRcb0.mjs} +45 -13
  96. package/dist/unplugin.d.mts +2 -1
  97. package/dist/unplugin.mjs +22 -10
  98. package/dist/vite.mjs +1 -1
  99. package/package.json +57 -60
  100. package/cli/commands/make/component.mjs +0 -86
  101. package/cli/commands/make/index.mjs +0 -14
  102. package/cli/commands/make/locale.mjs +0 -93
  103. package/cli/index.mjs +0 -15
  104. package/cli/package.json +0 -13
  105. package/cli/templates.mjs +0 -256
  106. package/cli/utils.mjs +0 -50
@@ -1,93 +0,0 @@
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 or en_gb.',
15
- required: true
16
- },
17
- name: {
18
- description: 'Locale name in its own language. Defaults to the CLDR name for the code.'
19
- },
20
- dir: {
21
- description: 'Locale direction. Defaults to the CLDR direction for the code.'
22
- }
23
- },
24
- async setup({ args }) {
25
- const path = resolve('.')
26
- const localePath = resolve(path, `src/runtime/locale`)
27
-
28
- const originLocaleFilePath = resolve(localePath, 'en.ts')
29
- const newLocaleFilePath = resolve(localePath, `${args.code}.ts`)
30
-
31
- // Validate locale code
32
- if (existsSync(newLocaleFilePath)) {
33
- consola.error(`🚨 ${args.code} already exists!`)
34
- process.exit(1)
35
- }
36
-
37
- if (!args.code.match(/^[a-z]{2,3}(?:_(?:[a-z]{2}|\d{3}))?$/)) {
38
- consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en, en_gb or es_419`)
39
- process.exit(1)
40
- }
41
-
42
- const code = normalizeLocale(args.code)
43
- const language = code.split('-')[0]
44
-
45
- // `Intl.DisplayNames` echoes the input back when the code is unknown to CLDR
46
- if (new Intl.DisplayNames(['en'], { type: 'language' }).of(language) === language) {
47
- consola.error(`🚨 ${language} is not a known ISO 639 language code!\nFor example, the code for Tajik is tg, not tj.`)
48
- process.exit(1)
49
- }
50
-
51
- const region = code.split('-')[1]
52
- if (region && new Intl.DisplayNames(['en'], { type: 'region' }).of(region) === region) {
53
- consola.error(`🚨 ${region} is not a known region code!\nExample: en_gb or pt_br`)
54
- process.exit(1)
55
- }
56
-
57
- let name = args.name
58
- if (!name) {
59
- const cldrName = new Intl.DisplayNames([code], { type: 'language', languageDisplay: 'standard' }).of(code)
60
- name = cldrName.charAt(0).toLocaleUpperCase(code) + cldrName.slice(1)
61
- consola.info(`🌍 Using CLDR name for ${code}: ${name}`)
62
- }
63
-
64
- let dir = args.dir
65
- if (!dir) {
66
- const intlLocale = new Intl.Locale(code)
67
- dir = (intlLocale.getTextInfo?.() ?? intlLocale.textInfo)?.direction ?? 'ltr'
68
- if (dir === 'rtl') {
69
- consola.info(`🌍 Using CLDR direction for ${code}: ${dir}`)
70
- }
71
- }
72
-
73
- if (!['ltr', 'rtl'].includes(dir)) {
74
- consola.error(`🚨 Direction ${dir} not supported!`)
75
- process.exit(1)
76
- }
77
-
78
- // Create new locale export
79
- const localeExportFile = resolve(localePath, `index.ts`)
80
- await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`)
81
- await sortFile(localeExportFile)
82
-
83
- // Create new locale file
84
- await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
85
- const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
86
- const rewrittenLocaleFile = localeFile
87
- .replace(/name: '(.*)',/, `name: '${name}',`)
88
- .replace(/code: '(.*)',/, `code: '${code}',${dir !== 'ltr' ? `\n dir: '${dir}',` : ''}`)
89
- await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
90
-
91
- consola.success(`🪄 Generated ${newLocaleFilePath}`)
92
- }
93
- })
package/cli/index.mjs DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- import { defineCommand, runMain } from 'citty'
3
- import make from './commands/make/index.mjs'
4
-
5
- const main = defineCommand({
6
- meta: {
7
- name: 'nuxt-ui',
8
- description: 'Nuxt UI CLI'
9
- },
10
- subCommands: {
11
- make
12
- }
13
- })
14
-
15
- runMain(main)
package/cli/package.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "name": "@nuxt/ui-cli",
3
- "type": "module",
4
- "exports": {
5
- ".": "./index.mjs"
6
- },
7
- "dependencies": {
8
- "citty": "^0.2.2",
9
- "consola": "^3.4.2",
10
- "pathe": "^2.0.3",
11
- "scule": "^1.3.0"
12
- }
13
- }
package/cli/templates.mjs DELETED
@@ -1,256 +0,0 @@
1
- import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
2
-
3
- const playground = ({ name }) => {
4
- const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
5
- const kebabName = kebabCase(name)
6
-
7
- return {
8
- filename: `playgrounds/nuxt/app/pages/components/${kebabName}.vue`,
9
- contents: `
10
- <template>
11
- <div>
12
- <U${upperName} />
13
- </div>
14
- </template>
15
- `
16
- }
17
- }
18
-
19
- const component = ({ name, primitive, prose, content }) => {
20
- const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
21
- const camelName = camelCase(name)
22
- const kebabName = kebabCase(name)
23
- const nested = prose || content
24
- const dirPrefix = prose ? 'prose/' : (content ? 'content/' : '')
25
- const importPrefix = nested ? '../..' : '..'
26
- const componentKey = prose ? `prose.${camelName}` : camelName
27
- const componentConfigArgs = prose
28
- ? `typeof theme, AppConfig, '${camelName}', 'ui.prose'`
29
- : `typeof theme, AppConfig, '${camelName}'`
30
- const appConfigLookup = prose
31
- ? `appConfig.ui?.prose?.${camelName}`
32
- : `appConfig.ui?.${camelName}`
33
-
34
- return {
35
- filename: `src/runtime/components/${dirPrefix}${upperName}.vue`,
36
- contents: primitive
37
- ? `
38
- <script lang="ts">
39
- import type { VNode } from 'vue'
40
- import type { AppConfig } from '@nuxt/schema'
41
- import theme from '#build/ui/${dirPrefix}${kebabName}'
42
- import type { ComponentConfig } from '${importPrefix}/types/tv'
43
-
44
- type ${upperName} = ComponentConfig<${componentConfigArgs}>
45
-
46
- export interface ${upperName}Props {
47
- /**
48
- * The element or component this component should render as.
49
- * @defaultValue 'div'
50
- */
51
- as?: any
52
- class?: any
53
- ui?: ${upperName}['slots']
54
- }
55
-
56
- export interface ${upperName}Slots {
57
- default?(props?: {}): VNode[]
58
- }
59
- </script>
60
-
61
- <script setup lang="ts">
62
- import { computed } from 'vue'
63
- import { Primitive } from 'reka-ui'
64
- import { useAppConfig } from '#imports'
65
- import { useComponentProps } from '${importPrefix}/composables/useComponentProps'
66
- import { tv } from '${importPrefix}/utils/tv'
67
-
68
- const _props = defineProps<${upperName}Props>()
69
- defineSlots<${upperName}Slots>()
70
-
71
- const props = useComponentProps('${componentKey}', _props)
72
-
73
- const appConfig = useAppConfig() as ${upperName}['AppConfig']
74
-
75
- // eslint-disable-next-line vue/no-dupe-keys
76
- const ui = computed(() => tv({ extend: theme, ...(${appConfigLookup} || {}) })())
77
- </script>
78
-
79
- <template>
80
- <Primitive :as="props.as" data-slot="root" :class="ui.root({ class: [props.ui?.root, props.class] })">
81
- <slot />
82
- </Primitive>
83
- </template>
84
- `
85
- : `
86
- <script lang="ts">
87
- import type { ${upperName}RootProps, ${upperName}RootEmits } from 'reka-ui'
88
- import type { VNode } from 'vue'
89
- import type { AppConfig } from '@nuxt/schema'
90
- import theme from '#build/ui/${dirPrefix}${kebabName}'
91
- import type { ComponentConfig } from '${importPrefix}/types/tv'
92
-
93
- type ${upperName} = ComponentConfig<${componentConfigArgs}>
94
-
95
- // TODO: narrow with \`Pick<${upperName}RootProps, '...' | '...'>\` to expose only the props you need.
96
- export interface ${upperName}Props extends ${upperName}RootProps {
97
- class?: any
98
- ui?: ${upperName}['slots']
99
- }
100
-
101
- export interface ${upperName}Emits extends ${upperName}RootEmits {}
102
-
103
- export interface ${upperName}Slots {
104
- default?(props?: {}): VNode[]
105
- }
106
- </script>
107
-
108
- <script setup lang="ts">
109
- import { computed } from 'vue'
110
- import { ${upperName}Root } from 'reka-ui'
111
- import { reactivePick } from '@vueuse/core'
112
- import { useAppConfig } from '#imports'
113
- import { useComponentProps } from '${importPrefix}/composables/useComponentProps'
114
- import { useForwardProps } from '${importPrefix}/composables/useForwardProps'
115
- import { tv } from '${importPrefix}/utils/tv'
116
-
117
- const _props = defineProps<${upperName}Props>()
118
- const emits = defineEmits<${upperName}Emits>()
119
- defineSlots<${upperName}Slots>()
120
-
121
- const props = useComponentProps('${componentKey}', _props)
122
-
123
- const appConfig = useAppConfig() as ${upperName}['AppConfig']
124
-
125
- // TODO: list the same keys as in \`${upperName}Props\` Pick.
126
- const rootProps = useForwardProps(reactivePick(props, 'as'), emits)
127
-
128
- // eslint-disable-next-line vue/no-dupe-keys
129
- const ui = computed(() => tv({ extend: theme, ...(${appConfigLookup} || {}) })())
130
- </script>
131
-
132
- <template>
133
- <${upperName}Root v-bind="rootProps" data-slot="root" :class="ui.root({ class: [props.ui?.root, props.class] })">
134
- <slot />
135
- </${upperName}Root>
136
- </template>
137
- `
138
- }
139
- }
140
-
141
- const theme = ({ name, prose, content }) => {
142
- const kebabName = kebabCase(name)
143
-
144
- return {
145
- filename: `src/theme/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}.ts`,
146
- contents: prose
147
- ? `
148
- export default {
149
- base: ''
150
- }
151
- `
152
- : `
153
- export default {
154
- slots: {
155
- root: ''
156
- }
157
- }
158
- `
159
- }
160
- }
161
-
162
- const test = ({ name, prose, content }) => {
163
- const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
164
-
165
- return {
166
- filename: `test/components/${content ? 'content/' : ''}${upperName}.spec.ts`,
167
- contents: prose
168
- ? undefined
169
- : `
170
- import { describe, it, expect } from 'vitest'
171
- import { axe } from 'vitest-axe'
172
- import { mountSuspended } from '@nuxt/test-utils/runtime'
173
- import ${upperName} from '../../${content ? '../' : ''}src/runtime/components/${content ? 'content/' : ''}${upperName}.vue'
174
- import { renderEach } from '../${content ? '../' : ''}component-render'
175
-
176
- describe('${upperName}', () => {
177
- const props = {}
178
-
179
- renderEach(${upperName}, [
180
- // Props
181
- ['with as', { props: { as: 'section' } }],
182
- ['with class', { props: { class: '' } }],
183
- ['with ui', { props: { ui: {} } }],
184
- // Slots
185
- ['with default slot', { props, slots: { default: () => 'Default slot' } }]
186
- ])
187
-
188
- it('passes accessibility tests', async () => {
189
- const wrapper = await mountSuspended(${upperName}, {
190
- props
191
- })
192
-
193
- expect(await axe(wrapper.element)).toHaveNoViolations()
194
- })
195
- })
196
- `
197
- }
198
- }
199
-
200
- const docs = ({ name, primitive }) => {
201
- const kebabName = kebabCase(name)
202
- const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
203
-
204
- return {
205
- filename: `docs/content/docs/2.components/${kebabName}.md`,
206
- contents: `---
207
- title: ${upperName}
208
- description: ''
209
- links:${primitive
210
- ? ''
211
- : `
212
- - label: ${upperName}
213
- icon: i-custom-reka-ui
214
- to: https://reka-ui.com/docs/components/${kebabName}`}
215
- - label: GitHub
216
- icon: i-simple-icons-github
217
- to: https://github.com/nuxt/ui/blob/v4/src/runtime/components/${upperName}.vue
218
- navigation.badge: Soon
219
- ---
220
-
221
- ## Usage
222
-
223
- ## Examples
224
-
225
- ## API
226
-
227
- ### Props
228
-
229
- :component-props
230
-
231
- ### Slots
232
-
233
- :component-slots
234
-
235
- ### Emits
236
-
237
- :component-emits
238
-
239
- ## Theme
240
-
241
- :component-theme
242
-
243
- ## Changelog
244
-
245
- :component-changelog
246
- `
247
- }
248
- }
249
-
250
- export default {
251
- playground,
252
- component,
253
- theme,
254
- test,
255
- docs
256
- }
package/cli/utils.mjs DELETED
@@ -1,50 +0,0 @@
1
- import { promises as fsp } from 'node:fs'
2
-
3
- export async function sortFile(path) {
4
- const file = await fsp.readFile(path, 'utf-8')
5
-
6
- const lines = file.trim().split('\n').sort()
7
-
8
- await fsp.writeFile(path, lines.join('\n') + '\n')
9
- }
10
-
11
- export async function appendFile(path, contents) {
12
- const file = await fsp.readFile(path, 'utf-8')
13
-
14
- if (!file.includes(contents)) {
15
- await fsp.writeFile(path, file.trim() + '\n' + contents + '\n')
16
- }
17
- }
18
-
19
- /**
20
- * Insert a `key?: Partial<ComponentTypes.XProps>` entry into the `ThemeDefaults`
21
- * interface in `src/runtime/composables/useComponentProps.ts`, keeping entries
22
- * sorted alphabetically and avoiding duplicates.
23
- */
24
- export async function appendThemeDefault(path, key, propsType) {
25
- const file = await fsp.readFile(path, 'utf-8')
26
- const entry = ` ${key}?: Partial<ComponentTypes.${propsType}>`
27
-
28
- const match = file.match(/(export interface ThemeDefaults \{\n)([\s\S]*?)(\n\})/)
29
- if (!match) return
30
-
31
- const [, header, body, footer] = match
32
- if (body.split('\n').includes(entry)) return
33
-
34
- const sorted = [...body.split('\n'), entry].sort().join('\n')
35
- await fsp.writeFile(path, file.replace(match[0], header + sorted + footer))
36
- }
37
-
38
- export function normalizeLocale(locale) {
39
- if (!locale) {
40
- return ''
41
- }
42
-
43
- if (locale.includes('_')) {
44
- return locale.split('_')
45
- .map((part, index) => index === 0 ? part.toLowerCase() : part.toUpperCase())
46
- .join('-')
47
- }
48
-
49
- return locale.toLowerCase()
50
- }