Compare commits

...

231 Commits

Author SHA1 Message Date
Benjamin Canac
49498d53a2 Merge branch 'v3' into feat/update-playground-form 2024-11-12 14:18:35 +01:00
Romain Hamel
17170bb998 playground(form): update examples (#2613) 2024-11-12 13:57:04 +01:00
renovate[bot]
fa5a3752c9 chore(deps): update tailwindcss to v4.0.0-alpha.33 (v3) (#2493)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-12 13:56:31 +01:00
Romain Hamel
8b975de35e feat(playground): update form examples 2024-11-12 13:44:09 +01:00
Benjamin Canac
fc9711223b chore(github): update issue templates 2024-11-12 13:11:42 +01:00
Alex
8a8b1ee2e1 feat(locale): provide code (#2611) 2024-11-12 12:57:40 +01:00
Benjamin Canac
30218f1b5b feat(NavigationMenu): control items open & defaultOpen on vertical
Resolves #2608
2024-11-12 11:12:19 +01:00
Romain Hamel
3584a3328b fix(Form): match error-pattern on input validation (#2606) 2024-11-11 22:50:22 +01:00
renovate[bot]
6d3dbdbee5 chore(deps): update all non-major dependencies (v3) (#2598)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-11 21:07:54 +01:00
renovate[bot]
c614a0aafc chore(deps): lock file maintenance (v3) (#2596)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-11 19:26:57 +01:00
Sandro Circi
df7a61a97a fix(useLocale): missing import in various components (#2603) 2024-11-11 19:24:33 +01:00
Romain Hamel
143612ec73 feat(FormField): add error-pattern prop (#2601) 2024-11-11 18:35:27 +01:00
Benjamin Canac
18931acdb3 fix(InputMenu/SelectMenu): init filter with labelKey 2024-11-11 00:28:43 +01:00
Benjamin Canac
bbc6bf2455 docs(input-menu/select-menu): add countries picker examples 2024-11-11 00:08:16 +01:00
Benjamin Canac
ff1e0798d3 feat(SelectMenu): use UInput in search to handle props like icon
Resolves #2021
2024-11-10 23:22:44 +01:00
Benjamin Canac
b0be26d67f fix(Toaster): teleport to body
Resolves #2404
2024-11-10 19:21:50 +01:00
Benjamin Canac
36ea3e4045 chore(scripts): remove 2024-11-10 18:36:52 +01:00
Adam Kasper
4889d30b44 feat(locale): add support for Czech translation (#2593) 2024-11-10 18:17:32 +01:00
Benjamin Canac
944a7e0f07 Revert "fix(module): resolve #build/app.config import for vue and nuxt"
This reverts commit d6943e39c0.
2024-11-10 17:25:33 +01:00
Benjamin Canac
d6943e39c0 fix(module): resolve #build/app.config import for vue and nuxt
Resolves #2560
2024-11-10 16:45:46 +01:00
Benjamin Canac
ddb46905e7 fix(App): missing vue imports 2024-11-10 16:44:09 +01:00
renovate[bot]
0e74dbebce chore(deps): update all non-major dependencies (v3) (#2579)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-10 14:45:10 +01:00
Benjamin Canac
9e2cc5b125 fix(Modal/Slideover): prevent esc with prevent-close prop
Resolves #2501
2024-11-10 10:19:47 +01:00
Benjamin Canac
ea97759c2c feat(Popover): add prevent-close prop
Resolves #2245
2024-11-10 10:18:08 +01:00
Dewdew
95a0bbc581 fix(Link): missing relative import (#2588)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-10 10:05:17 +01:00
Benjamin Canac
ecd63ad8d6 test: update vue snapshots 2024-11-10 09:42:11 +01:00
Benjamin Canac
47f58f52ef fix(ContextMenu/DropdownMenu): relative imports with prefix 2024-11-10 09:39:37 +01:00
Benjamin Canac
446f9c1085 feat(Table): add caption prop 2024-11-09 23:55:26 +01:00
Benjamin Canac
7e8a1dd496 chore(readme): update 2024-11-09 22:06:55 +01:00
Benjamin Canac
89ee31b7ae chore(readme): update 2024-11-09 22:03:56 +01:00
Benjamin Canac
95be76940c docs(getting-started): use ::steps and mention css files 2024-11-09 22:03:49 +01:00
Benjamin Canac
761afaf40d docs(deps): update @nuxt/ui-pro 2024-11-09 21:50:20 +01:00
Sandro Circi
d167c9b807 fix(locale): Italian translation (#2584) 2024-11-09 16:15:43 +01:00
Alex
824ba56291 feat(cli): add locale command (#2586) 2024-11-09 16:14:29 +01:00
Sandro Circi
4fbbb25f68 feat(locale): add support for Italian (#2583) 2024-11-09 13:50:03 +01:00
Muhammad Mahmoud
602a667343 feat(locale): add support for Arabic (#2582) 2024-11-09 13:49:50 +01:00
BlackWhite
febda5c2b6 feat(locale): translate chinese (#2580) 2024-11-09 10:40:42 +01:00
Malik-Jouda
20379f51cc docs(nuxt.config): cannot use import.meta outside a module (#2578) 2024-11-09 10:06:56 +01:00
renovate[bot]
1ec56f3326 chore(deps): update all non-major dependencies (v3) (#2572)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-08 18:03:14 +01:00
Alex
1f44d58b64 docs(i18n): auto generated lang support (#2574)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-08 17:48:42 +01:00
Benjamin Canac
5392f988b8 docs(app): fetch files lazy on client 2024-11-08 17:35:42 +01:00
Alex
26362408b1 feat(module): support i18n in components (#2553)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-08 17:22:57 +01:00
renovate[bot]
1e7638bd03 chore(deps): update all non-major dependencies (v3) (#2563)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-08 16:55:39 +01:00
Romain Hamel
afe40033b0 fix(module): skip devtools renderer page injection if router integration is disabled (#2571) 2024-11-08 16:27:25 +01:00
Benjamin Canac
503f701c7e fix(InputMenu/SelectMenu): multiple not working with generic boolean casting
Resolves #2541
2024-11-08 10:59:13 +01:00
Benjamin Canac
d9822db6e8 chore(InputMenu/Select/SelectMenu): consistent types 2024-11-08 10:27:05 +01:00
Benjamin Canac
0ceafe1d54 fix(InputMenu/SelectMenu): look in items only with value-attribute
Resolves #2464
2024-11-08 10:26:44 +01:00
Benjamin Canac
f943f88fcc fix(InputMenu/SelectMenu): use isEqual from ohash 2024-11-08 10:19:02 +01:00
Benjamin Canac
e831813aa3 chore(git): ignore vue playground files 2024-11-07 22:35:50 +01:00
Benjamin Canac
37a359701f fix(module): remove fast-deep-equal in favor of custom isEqual 2024-11-07 21:56:56 +01:00
Benjamin Canac
557e0c92a4 docs(deps): revert @nuxt/content to 3.0.0-alpha.5 2024-11-07 21:54:42 +01:00
Benjamin Canac
7f6db45f1e feat(css): add --ui-bg-muted / --ui-border-muted variables
Those are used in Nuxt UI Pro
2024-11-07 21:43:49 +01:00
Benjamin Canac
a64a7104c5 docs(app): update links 2024-11-07 17:46:44 +01:00
Benjamin Canac
40fc8f3718 docs(app): remove icons from breadcrumb 2024-11-07 16:33:19 +01:00
Benjamin Canac
8059d540e3 docs(app): improve links 2024-11-07 16:25:01 +01:00
Benjamin Canac
42fce998e4 docs: remove markdown from descriptions 2024-11-07 15:21:38 +01:00
Benjamin Canac
70fcc68ee2 chore(release): v3.0.0-alpha.8 2024-11-07 14:58:47 +01:00
Benjamin Canac
230cda129b docs(getting-started): update 2024-11-07 14:56:31 +01:00
Benjamin Canac
1c01db4d20 docs(avatar): update 2024-11-07 14:56:00 +01:00
Benjamin Canac
c9adf333be feat(Avatar): infer width / height on <img> based on size prop 2024-11-07 14:49:39 +01:00
Benjamin Canac
ffb551ab54 test: add silent: true in vue config 2024-11-07 13:08:12 +01:00
Benjamin Canac
f1a14dd87c feat(Avatar): use NuxtImg component when available
Resolves nuxt/ui#2078
2024-11-07 13:01:52 +01:00
renovate[bot]
0454124b3c chore(deps): update dependency @iconify-json/lucide to ^1.2.12 (v3) (#2556)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-07 12:43:35 +01:00
Benjamin Canac
0bfe2b60b3 fix(module): add fast-deep-equal in optimizeDeps 2024-11-07 12:19:41 +01:00
Benjamin Canac
5ec756d263 playground(deps): add @iconify-json/lucide 2024-11-07 11:52:59 +01:00
renovate[bot]
d6a434469d chore(deps): update all non-major dependencies (v3) (#2529)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-07 11:23:49 +01:00
renovate[bot]
ebbd605ff3 chore(deps): update nuxt framework to ^3.14.159 (v3) (#2547)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-06 19:15:22 +01:00
Benjamin Canac
860e6ed801 chore(module): pass resolver to templates 2024-11-06 16:13:42 +01:00
Benjamin Canac
12ae20df20 fix(module): define #build/app.config
Resolves nuxt/ui#2532
2024-11-06 15:46:05 +01:00
Benjamin Canac
64ad4b6892 fix(NavigationMenu): enforce data-orientation 2024-11-06 15:45:18 +01:00
Benjamin Canac
3c443c631c playground(tooltip): use buttons 2024-11-06 14:57:12 +01:00
Benjamin Canac
104b926c2e docs(deps): update @nuxt/ui-pro 2024-11-06 14:57:03 +01:00
Benjamin Canac
60c574cd01 docs(app): update banner icon 2024-11-06 14:41:41 +01:00
Alex
f821e6681b fix(Table): types in undeclared slots (#2544)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-06 14:27:22 +01:00
Alex
a6c1a6c587 feat(theme)!: migrate from heroicons to lucide (#2540)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-06 12:59:19 +01:00
renovate[bot]
e3092b6b40 chore(deps): update dependency sirv to v3 (v3) (#2538)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-05 22:25:36 +01:00
renovate[bot]
5f99f284ec chore(deps): update dependency nuxt to ^3.14.0 (v3) (#2537)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-05 22:25:04 +01:00
Romain Hamel
701c75a2a8 feat(module): devtools integration (#2196)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-05 22:17:56 +01:00
Benjamin Canac
7fc6b387b3 docs(getting-started): add Vue section 2024-11-05 21:47:12 +01:00
Alex
f66c96e277 feat(DropdownMenu/ContextMenu): handle color field in items (#2510)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-05 21:21:01 +01:00
Malik-Jouda
2d52834529 feat(Badge): handle icon and avatar props (#2497)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-11-05 19:34:40 +01:00
Benjamin Canac
a97c511279 fix(utils): improve escapeRegExp function 2024-11-05 18:03:10 +01:00
Benjamin Canac
50cc034796 chore(deps): dedupe 2024-11-05 15:11:27 +01:00
Benjamin Canac
9f87ea5729 docs(installation): improve callouts 2024-11-05 15:10:13 +01:00
renovate[bot]
eedf287654 chore(deps): update nuxt framework to ^3.14.0 (v3) (#2528)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-04 20:58:02 +01:00
renovate[bot]
28e35da59e chore(deps): update dependency @nuxthub/core to ^0.8.5 (v3) (#2527)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-04 19:39:34 +01:00
renovate[bot]
41eac7ff82 chore(deps): lock file maintenance (v3) (#2520)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-04 14:20:08 +01:00
renovate[bot]
7dd2fd05fc chore(deps): update all non-major dependencies (v3) (#2509)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-04 10:29:03 +01:00
Benjamin Canac
845f85a072 fix(useKbd): hydration issue
Related to #2494
2024-11-02 14:29:33 +01:00
Benjamin Canac
120eb920a8 chore(unplugin): improve ui types 2024-11-02 12:50:49 +01:00
Benjamin Canac
1a93d13a16 fix(components): missing relative imports
Resolves nuxt/ui#2515
2024-11-02 12:50:25 +01:00
Benjamin Canac
5a9511fa04 docs(nuxt.config): add typescript lang 2024-10-31 15:44:10 +01:00
Alexander
332c6c08d7 feat(Kbd): special keys for macOS and other systems (#2494)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-31 15:14:15 +01:00
Alexander
f26f6c8168 feat(InputMenu/Select/SelectMenu): arrow prop implementation (#2503)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-31 15:09:24 +01:00
renovate[bot]
c85ba43040 chore(deps): update all non-major dependencies (v3) (#2495)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-31 14:30:53 +01:00
Benjamin Canac
50918a8128 docs: update to @nuxt/content@next (#2379)
Co-authored-by: Farnabaz <farnabaz@gmail.com>
2024-10-31 14:16:26 +01:00
Benjamin Canac
8669553ea4 fix(Chip): proxy attrs to slot
Resolves nuxt/ui#2484
2024-10-31 12:17:51 +01:00
Benjamin Canac
b416a194df test(NavigationMenu): update vue snapshots 2024-10-31 11:58:25 +01:00
Benjamin Canac
d73c4ddd41 test(ButtonGroup): update vue snapshots 2024-10-31 11:52:33 +01:00
Benjamin Canac
7289eb21e2 chore(deps): remove vue-tsc resolutions 2024-10-31 11:32:12 +01:00
Benjamin Canac
b5ca0d96f1 feat(NavigationMenu): add item-content slot 2024-10-31 11:27:52 +01:00
Benjamin Canac
d980115408 fix(ButtonGroup): merge class with theme
Resolves nuxt/ui#2498
2024-10-31 11:27:19 +01:00
Alexander
ef561e7cba feat(Table): customize header and cell through slots (#2457)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-30 15:21:48 +01:00
renovate[bot]
45171e206e chore(deps): lock file maintenance (v3) (#2474)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-30 12:08:17 +01:00
renovate[bot]
ce427f7543 chore(deps): update all non-major dependencies (v3) (#2454)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-30 12:01:08 +01:00
Benjamin Canac
309e52faa7 fix(InputMenu/SelectMenu): fast-deep-equal import
Resolves nuxt/ui#2488
2024-10-29 22:15:24 +01:00
Yasser Lahbibi
fc2015bb0e fix(NavigationMenu): improve generic types (#2482)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-29 19:21:35 +01:00
Fabian B.
03dd1eba7e fix(Carousel): add missing aria-label on dots (#2489) 2024-10-29 18:31:13 +01:00
Benjamin Canac
77d18d8ab7 fix(templates): type error in app config
Resolves nuxt/ui#2481
2024-10-28 22:43:11 +01:00
Malik-Jouda
94c49186e1 feat(components): improve RTL support (#2433)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-28 21:37:01 +01:00
Rihan
e82a82d812 docs(use-toast): add App component warning (#2480) 2024-10-28 21:31:53 +01:00
Yasser Lahbibi
db8111d783 fix(InputMenu/Select/SelectMenu): improve types (#2471) 2024-10-28 18:08:24 +01:00
Sandro Circi
1402436c2b fix(NavigationMenu): add missing min-w-0 to make truncate work (#2476) 2024-10-28 17:13:30 +01:00
Sandro Circi
75410fba97 docs(table): fix examples width (#2478) 2024-10-28 16:55:11 +01:00
Benjamin Canac
0a17663d13 chore(cli): update templates 2024-10-28 16:43:43 +01:00
Benjamin Canac
e592da2fcb fix(Tabs): same behaviour between pill and link variants
Resolves #2338
2024-10-28 10:48:53 +01:00
Benjamin Canac
2514abeb5b chore(github): put back docs typecheck 2024-10-25 17:28:19 +02:00
Daniel Roe
d4a943e631 feat(module): add support for vue using unplugin (#2416)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-25 17:15:26 +02:00
Sébastien Chopin
50c6bf0092 chore(deps): update @nuxthub/core (#2459) 2024-10-25 00:00:19 +02:00
renovate[bot]
9cdde9edb2 chore(deps): update tailwindcss to v4.0.0-alpha.30 (v3) (#2458)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-24 23:47:21 +02:00
Benjamin Canac
3f48fdae8d test(Table): import from #components to resolve components 2024-10-24 16:27:39 +02:00
Malik-Jouda
058c49add2 playground(popover): update text (#2452)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-24 15:06:55 +02:00
Benjamin Canac
5d4a8ff713 docs(nuxt.config): lint 2024-10-24 14:50:45 +02:00
Benjamin Canac
2af0346654 docs(getting-started): improve faq 2024-10-24 14:35:46 +02:00
Benjamin Canac
f55194e6f0 docs(nuxt.config): clean 2024-10-23 23:49:51 +02:00
Benjamin Canac
eb47a7099d chore(deps): update eslint / @nuxt/eslint-config 2024-10-23 21:35:11 +02:00
Benjamin Canac
68f0269046 chore(release): v3.0.0-alpha.7 2024-10-23 21:27:57 +02:00
Benjamin Canac
47d9955ed9 chore(renovate): ignore resolutions 2024-10-23 21:22:21 +02:00
renovate[bot]
6386a4d99a chore(deps): update all non-major dependencies (v3) (#2418)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-23 21:17:55 +02:00
Benjamin Canac
7687ac16fd docs(table): update 2024-10-23 17:51:28 +02:00
Benjamin Canac
90a775bab9 docs(table): update 2024-10-23 17:49:17 +02:00
renovate[bot]
efeb3f9cfa chore(deps): update tailwindcss to v4.0.0-alpha.29 (v3) (#2440)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-23 17:44:59 +02:00
Benjamin Canac
b54950e3ed feat(Table): implement component (#2364) 2024-10-23 17:32:30 +02:00
Sandro Circi
34bddd45be feat(NavigationMenu): handle children on vertical orientation (#2384)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-22 22:52:38 +02:00
Benjamin Canac
69d7b57825 docs(error): update loading indicator color 2024-10-22 12:57:36 +02:00
Benjamin Canac
92873e05ba docs(app): update error 2024-10-22 12:51:42 +02:00
Benjamin Canac
7870288367 docs(app): improve meta 2024-10-22 12:51:32 +02:00
Benjamin Canac
9d3d5db376 docs(deps): update @nuxt/ui-pro 2024-10-22 12:51:18 +02:00
renovate[bot]
090fe16cff chore(deps): update devdependency @nuxt/test-utils to ^3.14.4 (v3) (#2423)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-21 18:21:44 +02:00
renovate[bot]
44ebb35953 chore(deps): lock file maintenance (v3) (#2428)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-21 18:15:17 +02:00
Benjamin Canac
5000a4e0d5 playground(select-menu): add missing placeholder 2024-10-19 18:27:07 +02:00
rizkyyy
5385944359 feat(Form): add superstruct validation (#2363)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
Co-authored-by: Romain Hamel <rom.hml@gmail.com>
2024-10-19 14:07:22 +02:00
Tomy Kho
7802aacf3f fix(InputMenu): emit focus event (#2386)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-18 16:09:04 +02:00
Benjamin Canac
f59844bb61 fix(Input/InputMenu/Select/SelectMenu): uniformize placeholder color 2024-10-18 15:48:08 +02:00
Benjamin Canac
9359603a0a docs(input): add examples 2024-10-18 15:42:27 +02:00
Benjamin Canac
d407c42be7 docs(deps): update @nuxt/ui-pro 2024-10-18 15:17:53 +02:00
renovate[bot]
8a06981df2 chore(deps): update tailwindcss to v4.0.0-alpha.28 (v3) (#2412)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-18 15:17:33 +02:00
Benjamin Canac
a68016ec5d fix(Slideover): set max height on top / bottom positions
Resolves nuxt/ui#2388
2024-10-17 22:44:56 +02:00
Benjamin Canac
973023a04e chore(css): move keyframes into separate file 2024-10-17 22:32:26 +02:00
renovate[bot]
f6789a156c chore(deps): update all non-major dependencies (v3) (#2395)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-17 22:15:17 +02:00
Benjamin Canac
61b232377b fix(AvatarGroup): wrong ring on big sizes 2024-10-17 22:14:29 +02:00
Benjamin Canac
eb1b30db40 playground(app): improve responsive navigation 2024-10-17 22:06:34 +02:00
Benjamin Canac
b975235c8b feat(ContextMenu/DropdownMenu): handle loading field in items 2024-10-17 22:03:32 +02:00
Benjamin Canac
81a59969f6 chore(ContextMenu/DropdownMenu): prevent useless extends 2024-10-17 21:47:23 +02:00
Benjamin Canac
dc8cd1e664 docs(components): ignore props in ComponentProps 2024-10-17 21:46:53 +02:00
Benjamin Canac
c63920d05b docs(context-menu/dropdown-menu): improve items properties 2024-10-17 21:25:50 +02:00
Benjamin Canac
37171b9327 chore(components): prevent useless extends on items 2024-10-17 21:25:17 +02:00
Benjamin Canac
49abad243c feat(CommandPalette): handle loading field in items 2024-10-17 21:13:11 +02:00
Benjamin Canac
c1294f6505 chore(components): prioritize icon over avatar in items 2024-10-17 21:06:10 +02:00
Benjamin Canac
53a3796d1b feat(Input/InputMenu/Select/SelectMenu): handle avatar prop 2024-10-17 18:21:12 +02:00
Benjamin Canac
df2013ca92 fix(Button): invalid hover on link variant 2024-10-17 17:41:30 +02:00
Benjamin Canac
0666884b6f docs: use nuxt.png in avatars 2024-10-17 17:10:39 +02:00
Benjamin Canac
a54c3e49fe feat(Button): handle avatar prop 2024-10-17 17:09:59 +02:00
Benjamin Canac
716ed10068 test: consistent avatar urls 2024-10-17 16:33:50 +02:00
Benjamin Canac
e137577a72 docs: consistent avatar urls 2024-10-17 16:31:51 +02:00
Benjamin Canac
0f9349f920 playground: consistent avatar urls 2024-10-17 16:31:41 +02:00
Benjamin Canac
e6143e8600 docs(deps): add wrangler as devDependencies 2024-10-15 18:34:03 +02:00
renovate[bot]
b9380c15ab chore(deps): update tailwindcss to v4.0.0-alpha.27 (v3) (#2263)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-15 18:03:07 +02:00
renovate[bot]
0b7f171268 chore(deps): update all non-major dependencies (v3) (#2382)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-15 17:29:53 +02:00
Benjamin Canac
490fb1377b docs(deps): use @nuxt/ui-pro preview release 2024-10-15 17:14:56 +02:00
Benjamin Canac
8ef6e712ac feat(ContextMenu/DropdownMenu): handle checkbox items type
Resolves #2144
2024-10-15 17:14:56 +02:00
Benjamin Canac
0759e29c22 docs(installation): add Continuous Releases section 2024-10-15 17:03:44 +02:00
Benjamin Canac
5385f84e0a chore(github): split docs typecheck 2024-10-15 16:33:17 +02:00
Benjamin Canac
46bd1cb002 docs(carousel): use useTemplateRef 2024-10-15 15:21:53 +02:00
Benjamin Canac
8258cd3829 docs(form): use useTemplateRef 2024-10-15 15:21:42 +02:00
Benjamin Canac
16b48efa96 docs(ThemePicker): remove select event 2024-10-15 15:13:43 +02:00
Benjamin Canac
b39c4d127e fix(components)!: rename select to onSelect on items 2024-10-15 15:13:43 +02:00
renovate[bot]
6af276ef38 chore(deps): update devdependency @release-it/conventional-changelog to v9 (v3) (#2368)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 18:31:37 +02:00
renovate[bot]
67fe33f820 chore(deps): update all non-major dependencies (v3) (#2352)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 17:55:59 +02:00
renovate[bot]
9e8b9dcc62 chore(deps): lock file maintenance (v3) (#2376)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-14 17:23:43 +02:00
Benjamin Canac
e9affb6f5b docs(command-palette): update 2024-10-14 14:48:14 +02:00
Benjamin Canac
6e9f6a8ef4 docs(accordion): add alert about multiple and v-model
Resolves #2372
2024-10-14 14:47:40 +02:00
Sandro Circi
dcce571cda fix(module): stop using tailwind's shorthand arbitrary variable syntax (#2366)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-14 10:42:26 +02:00
Benjamin Canac
ea07dffdd5 chore(github): update issue templates 2024-10-12 19:13:51 +02:00
Benjamin Canac
acfc6cef2d feat(Accordion/Breadcrumb/CommandPalette/ContextMenu/DropdownMenu/NavigationMenu/Tabs): add labelKey prop 2024-10-11 18:30:21 +02:00
Benjamin Canac
f6f9823b15 feat(InputMenu/RadioGroup/Select/SelectMenu): handle labelKey and use get to support dot notation 2024-10-11 15:31:47 +02:00
Benjamin Canac
296ae456c9 chore(components): move utils imports before components 2024-10-11 14:15:44 +02:00
Benjamin Canac
f6631ff7bc fix(Checkbox): indeterminate prop not working 2024-10-11 14:13:46 +02:00
Benjamin Canac
bcfa4b74a9 fix(Drawer/Modal/Slideover): no need for z-index since its isolated
Resolves nuxt/ui#2347
2024-10-11 00:08:17 +02:00
Benjamin Canac
1a7af6d182 test(SelectMenu): update snapshots 2024-10-11 00:07:39 +02:00
Benjamin Canac
558871a46a docs(Header): fix logo focus 2024-10-10 21:11:23 +02:00
Benjamin Canac
c8c17490ab docs(roadmap): fix height 2024-10-10 21:07:50 +02:00
Benjamin Canac
9e03da41b3 fix(css): font-sans already applied on <html> 2024-10-10 17:13:46 +02:00
Benjamin Canac
a2bad2eee2 fix(css): make @theme default 2024-10-10 17:13:05 +02:00
Benjamin Canac
7c21ddefa8 fix(InputMenu/SelectMenu): escape regexp before search 2024-10-10 16:12:22 +02:00
Benjamin Canac
0f9ac8733e fix(InputMenu/SelectMenu): improve displayed value
Resolves nuxt/ui#2353
2024-10-10 16:01:44 +02:00
Benjamin Canac
365bc0fc9a docs(select/select-menu): apply width class on examples
Resolves #2297
2024-10-10 15:34:33 +02:00
Benjamin Canac
c34a805e5f docs: improve hard-coded rounded 2024-10-09 18:24:50 +02:00
Benjamin Canac
b4ffcedd2e docs(deps): update @nuxt/ui-pro 2024-10-09 17:05:35 +02:00
Benjamin Canac
55179ce71c chore(release): v3.0.0-alpha.6 2024-10-09 16:29:01 +02:00
Benjamin Canac
e6d91c94d1 docs(deps): use @nuxt/ui-pro compact url 2024-10-09 16:17:41 +02:00
Benjamin Canac
9026cf2594 chore(release-it): update 2024-10-09 16:00:30 +02:00
renovate[bot]
818ec3893c chore(deps): update all non-major dependencies (v3) (#2344)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-09 15:51:09 +02:00
Benjamin Canac
31b701d9df chore(github): pkg.pr.new compact publish 2024-10-09 15:19:01 +02:00
Benjamin Canac
bee04adf4c fix(Carousel): move embla plugins to dependencies 2024-10-09 15:10:22 +02:00
Sandro Circi
057e86cfda feat(module): implement --ui-radius CSS variable (#2341)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-09 14:28:29 +02:00
Benjamin Canac
68ee3f11ca feat(Carousel): implement component (#2288) 2024-10-08 17:12:43 +02:00
renovate[bot]
69a6e11c52 chore(deps): update all non-major dependencies (v3) (#2335)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-08 12:16:57 +02:00
Benjamin Canac
53a4696ed3 docs(installation): improve theme.colors section 2024-10-08 12:05:17 +02:00
Benjamin Canac
7c4ffa56ec chore(module): improve tsdoc 2024-10-08 11:58:23 +02:00
Benjamin Canac
1fc21af918 docs(installation): add warning about shamefully-hoist
TypeScript warning is no longer needed since 6e7a400d4e
2024-10-08 00:51:28 +02:00
renovate[bot]
ede20f89c4 chore(deps): update all non-major dependencies (v3) (#2331)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-07 23:47:22 +02:00
Fabian Hiller
0955c07edd feat(Form): add Standard Schema support (#2303)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-10-07 23:25:52 +02:00
renovate[bot]
aa8fa5be3a chore(deps): update all non-major dependencies (v3) (#2329)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-07 23:20:48 +02:00
renovate[bot]
cf490c3b77 chore(deps): update pnpm to v9.12.1 (v3) (#2328)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-07 15:50:04 +02:00
renovate[bot]
220f659c4c chore(deps): update devdependency @nuxt/test-utils to ^3.14.3 (v3) (#2326)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-07 15:43:17 +02:00
Benjamin Canac
f2e8762b48 docs(deps): use @nuxt/ui-pro@v2 2024-10-07 15:25:07 +02:00
renovate[bot]
c2e879feac chore(deps): update all non-major dependencies (v3) (#2311)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-07 15:18:57 +02:00
Benjamin Canac
3a7c5c2601 fix(Alert): default variant to solid for consistency 2024-10-07 14:57:46 +02:00
Benjamin Canac
9368c6a639 refactor(module)!: implement design system with CSS variables (#2298) 2024-10-07 14:48:02 +02:00
Benjamin Canac
3cf5535b2f fix(Button): center text with block prop
Resolves nuxt/ui#2317
2024-10-07 14:23:24 +02:00
renovate[bot]
cb0081e0a7 chore(deps): update all non-major dependencies (v3) (#2290)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-05 23:14:35 +02:00
Benjamin Canac
6e7a400d4e chore(deps): add typescript in peerDependencies 2024-10-05 14:38:52 +02:00
Benjamin Canac
fde75087d0 chore(github): add publish step with pkg-pr-new 2024-10-05 14:05:15 +02:00
Benjamin Canac
7c3ed81309 docs(pages): use title instead of navigation.title in og image 2024-10-02 19:09:07 +02:00
Benjamin Canac
cb44980440 docs(pages): add z-index on toc to go over code examples 2024-10-02 18:51:46 +02:00
Benjamin Canac
6c7c2f02f3 fix(Accordion): use text-left break-words instead of truncate on label 2024-10-02 18:51:32 +02:00
Benjamin Canac
a1ebf8da9a docs(Header): fix badge truncate 2024-10-02 18:47:21 +02:00
Benjamin Canac
ed77b69f5d chore(module): lint 2024-10-02 16:46:11 +02:00
Benjamin Canac
dd42e652d1 docs(deps): update @nuxt/ui-pro 2024-10-02 16:18:29 +02:00
Benjamin Canac
b82af02839 feat(module): set disableTransition option on @nuxtjs/color-mode 2024-10-02 16:18:10 +02:00
613 changed files with 44884 additions and 13548 deletions

74
.github/ISSUE_TEMPLATE/bug-v3.yml vendored Normal file
View File

@@ -0,0 +1,74 @@
name: "🐛 Bug report (v3)"
description: Report a bug to help us improve the module (v3 only).
labels: ["triage", "bug", "v3"]
body:
- type: markdown
attributes:
value: |
> [!IMPORTANT]
> As Nuxt UI v3 is currently in alpha, we recommend thorough testing before using it in production environments. We're actively working on stabilization and welcome feedback from early adopters to improve the library.
- type: markdown
attributes:
value: |
Before reporting a bug, please make sure that you have read through our [v3 documentation](https://ui3.nuxt.dev/) and existing [issues](https://github.com/nuxt/ui/issues?q=is%3Aissue%20is%3Aopen%20sort%3Aupdated-desc%20label%3Av3).
- type: textarea
id: env
attributes:
label: Environment
description: You can use `npx nuxi info` to fill this section
placeholder: |
- Operating System: `Darwin`
- Node Version: `v18.16.0`
- Nuxt Version: `3.7.3`
- CLI Version: `3.8.4`
- Nitro Version: `2.6.3`
- Package Manager: `pnpm@8.7.4`
- Builder: `-`
- User Config: `-`
- Runtime Modules: `-`
- Build Modules: `-`
validations:
required: true
- type: dropdown
id: package
attributes:
label: Is this bug related to Nuxt or Vue?
options:
- Nuxt
- Vue
validations:
required: true
- type: input
id: version
attributes:
label: Version
placeholder: v3.0.0-alpha.x
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Reproduction
description: Please provide a reproduction link. A minimal [reproduction is required](https://antfu.me/posts/why-reproductions-are-required) unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "needs reproduction" label. If no reproduction is provided we might close it.
placeholder: https://github.com/my/reproduction
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description.
validations:
required: true
- type: textarea
id: additonal
attributes:
label: Additional context
description: If applicable, add any other context or screenshots here.
- type: textarea
id: logs
attributes:
label: Logs
description: |
Optional if provided reproduction. Please try not to insert an image but copy paste the log text.
render: shell-script

View File

@@ -6,6 +6,15 @@ body:
attributes:
value: |
Before requesting a feature, please make sure that you have read through our [documentation](https://ui.nuxt.com) and existing [issues](https://github.com/nuxt/ui/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
- type: dropdown
id: version
attributes:
label: For what version of Nuxt UI are you suggesting this?
options:
- v2.x
- v3.0.0-alpha.x
validations:
required: true
- type: textarea
id: description
attributes:

View File

@@ -6,6 +6,15 @@ body:
attributes:
value: |
Before asking a question, please make sure that you have read through our [documentation](https://ui.nuxt.com) and existing [issues](https://github.com/nuxt/ui/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
- type: dropdown
id: version
attributes:
label: For what version of Nuxt UI are you asking this question?
options:
- v2.x
- v3.0.0-alpha.x
validations:
required: true
- type: textarea
id: description
attributes:

View File

@@ -43,6 +43,9 @@ jobs:
- name: Prepare
run: pnpm run dev:prepare
- name: Devtools prepare
run: pnpm run devtools:prepare
- name: Lint
run: pnpm run lint
@@ -52,5 +55,11 @@ jobs:
- name: Test
run: pnpm run test
- name: Test (vue)
run: pnpm run test:vue
- name: Build
run: pnpm run build
- name: Publish
run: pnpx pkg-pr-new publish --compact --no-template --pnpm

8
.gitignore vendored
View File

@@ -1,3 +1,6 @@
.component-meta/
component-meta.*
# Nuxt dev/build outputs
.output
.data
@@ -22,3 +25,8 @@ logs
.env
.env.*
!.env.example
playground-vue/auto-imports.d.ts
playground-vue/components.d.ts
playground-vue/tsconfig.app.tsbuildinfo
playground-vue/tsconfig.node.tsbuildinfo

View File

@@ -3,6 +3,14 @@
"commitMessage": "chore(release): v${version}",
"tagName": "v${version}"
},
"github": {
"release": true,
"releaseName": "v${version}",
"web": true
},
"hooks": {
"before:init": ["pnpm lint", "pnpm typecheck"]
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": {

View File

@@ -1,5 +1,107 @@
# Changelog
## [3.0.0-alpha.8](https://github.com/nuxt/ui/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-11-07)
### ⚠ BREAKING CHANGES
* **theme:** migrate from `heroicons` to `lucide` (#2540)
### Features
* **Avatar:** infer `width` / `height` on `<img>` based on `size` prop ([c9adf33](https://github.com/nuxt/ui/commit/c9adf333be3e489b91fd044189809c28c62e7951))
* **Avatar:** use `NuxtImg` component when available ([f1a14dd](https://github.com/nuxt/ui/commit/f1a14dd87c3e250a7eaa6729f68201201a476f9f)), closes [nuxt/ui#2078](https://github.com/nuxt/ui/issues/2078)
* **Badge:** handle `icon` and `avatar` props ([#2497](https://github.com/nuxt/ui/issues/2497)) ([2d52834](https://github.com/nuxt/ui/commit/2d52834529e00a43b1a9b3015d073500b4208981))
* **components:** improve RTL support ([#2433](https://github.com/nuxt/ui/issues/2433)) ([94c4918](https://github.com/nuxt/ui/commit/94c49186e16d84d77a637bbdfe00e7cb880204fe))
* **DropdownMenu/ContextMenu:** handle `color` field in items ([#2510](https://github.com/nuxt/ui/issues/2510)) ([f66c96e](https://github.com/nuxt/ui/commit/f66c96e277970f80c905a8936c73b1d37479a940))
* **InputMenu/Select/SelectMenu:** `arrow` prop implementation ([#2503](https://github.com/nuxt/ui/issues/2503)) ([f26f6c8](https://github.com/nuxt/ui/commit/f26f6c8168ad5e44e47ab770cee10035257841a2))
* **Kbd:** special keys for macOS and other systems ([#2494](https://github.com/nuxt/ui/issues/2494)) ([332c6c0](https://github.com/nuxt/ui/commit/332c6c08d73ebdbffc18e1f196962eaa76e7a8dc))
* **module:** add support for `vue` using `unplugin` ([#2416](https://github.com/nuxt/ui/issues/2416)) ([d4a943e](https://github.com/nuxt/ui/commit/d4a943e631b5e16dc7863395f1dd906087228e1c))
* **module:** devtools integration ([#2196](https://github.com/nuxt/ui/issues/2196)) ([701c75a](https://github.com/nuxt/ui/commit/701c75a2a88a29be2fce193f75e1484799a5539c))
* **NavigationMenu:** add `item-content` slot ([b5ca0d9](https://github.com/nuxt/ui/commit/b5ca0d96f1de049dde698e57a340fc8ee54dd2e7))
* **Table:** customize `header` and `cell` through slots ([#2457](https://github.com/nuxt/ui/issues/2457)) ([ef561e7](https://github.com/nuxt/ui/commit/ef561e7cba172b61f296d4ff11815ec31902fb4a))
* **theme:** migrate from `heroicons` to `lucide` ([#2540](https://github.com/nuxt/ui/issues/2540)) ([a6c1a6c](https://github.com/nuxt/ui/commit/a6c1a6c587ca35439852ce93cd4edc5041c6a9bf))
### Bug Fixes
* **ButtonGroup:** merge class with theme ([d980115](https://github.com/nuxt/ui/commit/d9801154088ec7a20901b805f5d21e485e481d98)), closes [nuxt/ui#2498](https://github.com/nuxt/ui/issues/2498)
* **Carousel:** add missing `aria-label` on dots ([#2489](https://github.com/nuxt/ui/issues/2489)) ([03dd1eb](https://github.com/nuxt/ui/commit/03dd1eba7ece4c48393960dc6c725be3a1eec776))
* **Chip:** proxy attrs to slot ([8669553](https://github.com/nuxt/ui/commit/8669553ea415cc969b2066a78830d03e8dfc811b)), closes [nuxt/ui#2484](https://github.com/nuxt/ui/issues/2484)
* **components:** missing relative imports ([1a93d13](https://github.com/nuxt/ui/commit/1a93d13a1609d8b90783f20b330738cd7456503e)), closes [nuxt/ui#2515](https://github.com/nuxt/ui/issues/2515)
* **InputMenu/Select/SelectMenu:** improve types ([#2471](https://github.com/nuxt/ui/issues/2471)) ([db8111d](https://github.com/nuxt/ui/commit/db8111d7835d030ced79899e826ff1eb74cf1cf4))
* **InputMenu/SelectMenu:** `fast-deep-equal` import ([309e52f](https://github.com/nuxt/ui/commit/309e52faa76fc0a135dbc0d9543380ffd9066bda)), closes [nuxt/ui#2488](https://github.com/nuxt/ui/issues/2488)
* **module:** add `fast-deep-equal` in `optimizeDeps` ([0bfe2b6](https://github.com/nuxt/ui/commit/0bfe2b60b3eb06ec30c80505f10380bab4f7ad4c))
* **module:** define `[#build](https://github.com/nuxt/ui/issues/build)/app.config` ([12ae20d](https://github.com/nuxt/ui/commit/12ae20df20db18d233a185c59ede7dcaeca93071)), closes [nuxt/ui#2532](https://github.com/nuxt/ui/issues/2532)
* **NavigationMenu:** add missing `min-w-0` to make truncate work ([#2476](https://github.com/nuxt/ui/issues/2476)) ([1402436](https://github.com/nuxt/ui/commit/1402436c2b0262edada04273b60c3b2914df2895))
* **NavigationMenu:** enforce `data-orientation` ([64ad4b6](https://github.com/nuxt/ui/commit/64ad4b6892d827df921550bf7ae31048d8d6cc50))
* **NavigationMenu:** improve generic types ([#2482](https://github.com/nuxt/ui/issues/2482)) ([fc2015b](https://github.com/nuxt/ui/commit/fc2015bb0e9ccb017a91ba1ee839cd84cf740cf3))
* **Table:** types in undeclared slots ([#2544](https://github.com/nuxt/ui/issues/2544)) ([f821e66](https://github.com/nuxt/ui/commit/f821e6681bfc5d1515fe7158fe3fda639a897ac8))
* **Tabs:** same behaviour between `pill` and `link` variants ([e592da2](https://github.com/nuxt/ui/commit/e592da2fcb9deb5ad5f2ffb442ff07d86923bab6)), closes [#2338](https://github.com/nuxt/ui/issues/2338)
* **templates:** type error in app config ([77d18d8](https://github.com/nuxt/ui/commit/77d18d8ab7bf28aee316a443d52b852dfc5fd1ca)), closes [nuxt/ui#2481](https://github.com/nuxt/ui/issues/2481)
* **useKbd:** hydration issue ([845f85a](https://github.com/nuxt/ui/commit/845f85a072598f47c7afe10c4e5ebcc480450113)), closes [#2494](https://github.com/nuxt/ui/issues/2494)
* **utils:** improve `escapeRegExp` function ([a97c511](https://github.com/nuxt/ui/commit/a97c511279d32747b487ab5de32677e36a884e53))
## [3.0.0-alpha.7](https://github.com/nuxt/ui/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-10-23)
### ⚠ BREAKING CHANGES
* **components:** rename `select` to `onSelect` on items
### Features
* **Accordion/Breadcrumb/CommandPalette/ContextMenu/DropdownMenu/NavigationMenu/Tabs:** add `labelKey` prop ([acfc6ce](https://github.com/nuxt/ui/commit/acfc6cef2db88774749d38a98416fdd85922d513))
* **Button:** handle `avatar` prop ([a54c3e4](https://github.com/nuxt/ui/commit/a54c3e49fe782e329f9245e496c336143e3e4b23))
* **CommandPalette:** handle `loading` field in items ([49abad2](https://github.com/nuxt/ui/commit/49abad243cee97b99753e2500c4bdaa0efe5eb75))
* **ContextMenu/DropdownMenu:** handle `checkbox` items type ([8ef6e71](https://github.com/nuxt/ui/commit/8ef6e712acbb2fc026eb35cefa8e29fc0b59d70f)), closes [#2144](https://github.com/nuxt/ui/issues/2144)
* **ContextMenu/DropdownMenu:** handle `loading` field in items ([b975235](https://github.com/nuxt/ui/commit/b975235c8b8e693a32efd3fd5381eed88fa3db4d))
* **Form:** add `superstruct` validation ([#2363](https://github.com/nuxt/ui/issues/2363)) ([5385944](https://github.com/nuxt/ui/commit/53859443593b584f7cd44106021e80f441e9ca06))
* **Input/InputMenu/Select/SelectMenu:** handle `avatar` prop ([53a3796](https://github.com/nuxt/ui/commit/53a3796d1b08717a589028f99fc01084df661708))
* **InputMenu/RadioGroup/Select/SelectMenu:** handle `labelKey` and use `get` to support dot notation ([f6f9823](https://github.com/nuxt/ui/commit/f6f9823b15d84362d093703cb15ecba64c73c2c2))
* **NavigationMenu:** handle children on `vertical` orientation ([#2384](https://github.com/nuxt/ui/issues/2384)) ([34bddd4](https://github.com/nuxt/ui/commit/34bddd45be2ba1d51ddb9b6b40860f2414f63180))
* **Table:** implement component ([#2364](https://github.com/nuxt/ui/issues/2364)) ([b54950e](https://github.com/nuxt/ui/commit/b54950e3ed77a466eb048788757a76018638eafa))
### Bug Fixes
* **AvatarGroup:** wrong ring on big sizes ([61b2323](https://github.com/nuxt/ui/commit/61b232377b4b1fb41de30fd33e690a36b36ba575))
* **Button:** invalid hover on `link` variant ([df2013c](https://github.com/nuxt/ui/commit/df2013ca92a49b5947e2fbc2641fd92860c32042))
* **Checkbox:** `indeterminate` prop not working ([f6631ff](https://github.com/nuxt/ui/commit/f6631ff7bc607e140e9db2c7335c409a811820e4))
* **components:** rename `select` to `onSelect` on items ([b39c4d1](https://github.com/nuxt/ui/commit/b39c4d127e0ddf7607e868ecc83930ca49436bad))
* **css:** `font-sans` already applied on <html> ([9e03da4](https://github.com/nuxt/ui/commit/9e03da41b3537236864ae2a533c47e99a6270b77))
* **css:** make `[@theme](https://github.com/theme)` default ([a2bad2e](https://github.com/nuxt/ui/commit/a2bad2eee2d2a9255152692898078d26e9ecad98))
* **Drawer/Modal/Slideover:** no need for `z-index` since its isolated ([bcfa4b7](https://github.com/nuxt/ui/commit/bcfa4b74a9713be764ecb6db93d60d1360e52f07)), closes [nuxt/ui#2347](https://github.com/nuxt/ui/issues/2347)
* **Input/InputMenu/Select/SelectMenu:** uniformize placeholder color ([f59844b](https://github.com/nuxt/ui/commit/f59844bb617f50ef78ae5abe250b0744d7341a2f))
* **InputMenu/SelectMenu:** escape regexp before search ([7c21dde](https://github.com/nuxt/ui/commit/7c21ddefa87bf3d9999c0e790b48c004c078304d))
* **InputMenu/SelectMenu:** improve displayed value ([0f9ac87](https://github.com/nuxt/ui/commit/0f9ac8733e402d1f22a3eb6c1e24a8d5607b3572)), closes [nuxt/ui#2353](https://github.com/nuxt/ui/issues/2353)
* **InputMenu:** emit `focus` event ([#2386](https://github.com/nuxt/ui/issues/2386)) ([7802aac](https://github.com/nuxt/ui/commit/7802aacf3f5be572dd64c3288196432a41f06b0e))
* **module:** stop using tailwind's shorthand arbitrary variable syntax ([#2366](https://github.com/nuxt/ui/issues/2366)) ([dcce571](https://github.com/nuxt/ui/commit/dcce571cdab08de8408c8ba6b236b051eec3a603))
* **Slideover:** set max height on `top` / `bottom` positions ([a68016e](https://github.com/nuxt/ui/commit/a68016ec5d6859e892c90333d35fd7db09fdcf10)), closes [nuxt/ui#2388](https://github.com/nuxt/ui/issues/2388)
## [3.0.0-alpha.6](https://github.com/nuxt/ui/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-10-09)
### ⚠ BREAKING CHANGES
* **module:** implement design system with CSS variables (#2298)
### Features
* **Carousel:** implement component ([#2288](https://github.com/nuxt/ui/issues/2288)) ([68ee3f1](https://github.com/nuxt/ui/commit/68ee3f11ca01b19cf890ef8105ffb87ef9bb3188))
* **Form:** add Standard Schema support ([#2303](https://github.com/nuxt/ui/issues/2303)) ([0955c07](https://github.com/nuxt/ui/commit/0955c07edd8ea5b5c39b770804b8e4c6f86d94b0))
* **module:** implement `--ui-radius` CSS variable ([#2341](https://github.com/nuxt/ui/issues/2341)) ([057e86c](https://github.com/nuxt/ui/commit/057e86cfda1ef5c7a370c99ef409d22e48772ca7))
* **module:** set `disableTransition` option on `@nuxtjs/color-mode` ([b82af02](https://github.com/nuxt/ui/commit/b82af02839b7d75344d9431fabdc42f0ac0681e1))
### Bug Fixes
* **Accordion:** use `text-left break-words` instead of `truncate` on label ([6c7c2f0](https://github.com/nuxt/ui/commit/6c7c2f02f395747a0c68a499630f502e3f02ded3))
* **Alert:** default variant to `solid` for consistency ([3a7c5c2](https://github.com/nuxt/ui/commit/3a7c5c26011bfcffcdf6ac3451adb2af1453b9db))
* **Button:** center text with `block` prop ([3cf5535](https://github.com/nuxt/ui/commit/3cf5535b2faa28b557ca55d694abdfa7d7ad0efc)), closes [nuxt/ui#2317](https://github.com/nuxt/ui/issues/2317)
* **Carousel:** move embla plugins to `dependencies` ([bee04ad](https://github.com/nuxt/ui/commit/bee04adf4cc4fd6d69e93ad94500f5ef604405e7))
### Code Refactoring
* **module:** implement design system with CSS variables ([#2298](https://github.com/nuxt/ui/issues/2298)) ([9368c6a](https://github.com/nuxt/ui/commit/9368c6a63955a2e6c2f4f900a9b91c61bb2e5a72))
## [3.0.0-alpha.5](https://github.com/nuxt/ui/compare/v3.0.0-alpha.4...v3.0.0-alpha.5) (2024-10-02)

View File

@@ -1,6 +1,6 @@
[![nuxt-ui.png](https://repository-images.githubusercontent.com/428329515/43fec891-9030-4601-8233-5d45ba5c6013)](https://ui.nuxt.com)
# Nuxt UI v3
# Nuxt UI
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
@@ -9,9 +9,14 @@
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.
## Installation
> [!NOTE]
> You are on the `v3` development branch, check out the [dev branch](https://github.com/nuxt/ui) for Nuxt UI v2.
1. Install the Nuxt UI v3 alpha package:
## Documentation
Visit https://ui3.nuxt.dev to explore the documentation.
## Installation
```bash [pnpm]
pnpm add @nuxt/ui@next
@@ -29,10 +34,9 @@ npm install @nuxt/ui@next
bun add @nuxt/ui@next
```
> [!WARNING]
> Make sure you have `typescript` installed in your dev dependencies.
### Nuxt
2. Register the Nuxt UI module in your `nuxt.config.ts`:
1. Add the Nuxt UI module in your `nuxt.config.ts`:
```ts [nuxt.config.ts]
export default defineNuxtConfig({
@@ -40,16 +44,54 @@ export default defineNuxtConfig({
})
```
3. Import Tailwind and Nuxt UI in your `app.vue` or in your [CSS](https://nuxt.com/docs/getting-started/styling#the-css-property):
2. Import Tailwind CSS and Nuxt UI in your CSS:
```css [main.css]
```css [assets/css/main.css]
@import "tailwindcss";
@import "@nuxt/ui";
```
## Documentation
Learn more in the [installation guide](https://ui3.nuxt.dev/getting-started/installation/nuxt).
Visit https://ui3.nuxt.dev to explore the documentation.
### Vue
1. Add the Nuxt UI Vite plugin in your `vite.config.ts`:
```ts [vite.config.ts]
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui()
]
})
```
2. Use the Nuxt UI Vue plugin in your `main.ts`:
```ts [main.ts]
import { createApp } from 'vue'
import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue'
const app = createApp(App)
app.use(ui)
app.mount('#app')
```
3. Import Tailwind CSS and Nuxt UI in your CSS:
```css [assets/main.css]
@import "tailwindcss";
@import "@nuxt/ui";
```
Learn more in the [installation guide](https://ui3.nuxt.dev/getting-started/installation/vue).
## Credits

View File

@@ -1,12 +1,24 @@
import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
entries: [
// Include devtools runtime files
{ input: './src/devtools/runtime', builder: 'mkdist', outDir: 'dist/devtools/runtime' },
// Vue support
'./src/unplugin',
'./src/vite'
],
rollup: {
emitCJS: true
},
replace: {
'process.env.DEV': 'false'
'process.env.DEV': 'false',
'process.env.NUXT_UI_DEVTOOLS_LOCAL': 'false'
},
hooks: {
'mkdist:entry:options'(ctx, entry, options) {
options.addRelativeDeclarationExtensions = false
}
}
},
externals: ['#build/ui', 'vite']
})

View File

@@ -3,13 +3,13 @@ import { resolve } from 'pathe'
import { defineCommand } from 'citty'
import { consola } from 'consola'
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
import { appendFile, sortFile } from '../utils.mjs'
import templates from '../templates.mjs'
import { appendFile, sortFile } from '../../utils.mjs'
import templates from '../../templates.mjs'
export default defineCommand({
meta: {
name: 'init',
description: 'Init a new component.'
name: 'component',
description: 'Make a new component.'
},
args: {
name: {

View File

@@ -0,0 +1,14 @@
import { defineCommand } from 'citty'
import component from './component.mjs'
import locale from './locale.mjs'
export default defineCommand({
meta: {
name: 'make',
description: 'Commands to create new Nuxt UI entities.'
},
subCommands: {
component,
locale
}
})

View File

@@ -0,0 +1,53 @@
import { existsSync, promises as fsp } from 'node:fs'
import { resolve } from 'pathe'
import { consola } from 'consola'
import { appendFile, sortFile, normalizeLocale } from '../../utils.mjs'
import { defineCommand } from 'citty'
export default defineCommand({
meta: {
name: 'locale',
description: 'Make a new locale.'
},
args: {
code: {
description: 'Locale code to create. For example: en.',
required: true
},
name: {
description: 'Locale name to create. For example: English.',
required: true
}
},
async setup({ args }) {
const path = resolve('.')
const localePath = resolve(path, `src/runtime/locale`)
const originLocaleFilePath = resolve(localePath, 'en.ts')
const newLocaleFilePath = resolve(localePath, `${args.code}.ts`)
// Validate locale code
if (existsSync(newLocaleFilePath)) {
consola.error(`🚨 ${args.code} already exists!`)
process.exit(1)
}
if (!args.code.match(/^[a-z]{2}(?:_[a-z]{2,4})?$/)) {
consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`)
process.exit(1)
}
// Create new locale export
const localeExportFile = resolve(localePath, `index.ts`)
await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`)
await sortFile(localeExportFile)
// Create new locale file
await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
const rewrittenLocaleFile = localeFile.replace(/defineLocale\('(.*)'/, `defineLocale('${args.name}', '${normalizeLocale(args.code)}'`)
await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
consola.success(`🪄 Generated ${newLocaleFilePath}`)
}
})

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { defineCommand, runMain } from 'citty'
import init from './commands/init.mjs'
import make from './commands/make/index.mjs'
const main = defineCommand({
meta: {
@@ -8,7 +8,7 @@ const main = defineCommand({
description: 'Nuxt UI CLI'
},
subCommands: {
init
make
}
})

View File

@@ -42,7 +42,7 @@ const ${camelName} = tv({ extend: tv(theme), ...(appConfig.${key}?.${prose ? 'pr
export interface ${upperName}Props {
/**
* The element or component this component should render as.
* @defaultValue \`div\`
* @defaultValue 'div'
*/
as?: any
class?: any

View File

@@ -15,3 +15,17 @@ export async function appendFile(path, contents) {
await fsp.writeFile(path, file.trim() + '\n' + contents + '\n')
}
}
export function normalizeLocale(locale) {
if (!locale) {
return ''
}
if (locale.includes('_')) {
return locale.split('_')
.map((part, index) => index === 0 ? part.toLowerCase() : part.toUpperCase())
.join('-')
}
return locale.toLowerCase()
}

View File

@@ -0,0 +1,8 @@
export default defineAppConfig({
ui: {
colors: {
primary: 'green',
neutral: 'zinc'
}
}
})

222
devtools/app/app.vue Normal file
View File

@@ -0,0 +1,222 @@
<script setup lang="ts">
import type { Component } from '../../src/devtools/meta'
import { watchDebounced } from '@vueuse/core'
// Disable devtools in component renderer iframe
// @ts-expect-error - Nuxt Devtools internal value
window.__NUXT_DEVTOOLS_DISABLE__ = true
const component = useState<Component | undefined>('__ui-devtools-component')
const state = useState<Record<string, any>>('__ui-devtools-state', () => ({}))
const { data: components, status, error } = useAsyncData<Array<Component>>('__ui-devtools-components', async () => {
const componentMeta = await $fetch<Record<string, Component>>('/api/component-meta')
if (!component.value || !componentMeta[component.value.slug]) {
component.value = componentMeta['button']
}
state.value.props = Object.values(componentMeta).reduce((acc, comp) => {
const componentDefaultProps = comp.meta?.props.reduce((acc, prop) => {
if (prop.default) acc[prop.name] = prop.default
return acc
}, {} as Record<string, any>)
acc[comp.slug] = {
...comp.defaultVariants, // Default values from the theme template
...componentDefaultProps, // Default values from vue props
...componentMeta[comp.slug]?.meta?.devtools?.defaultProps // Default values from devtools extended meta
}
return acc
}, {} as Record<string, any>)
return Object.values(componentMeta)
})
const componentProps = computed(() => {
if (!component.value) return
return state.value.props[component.value?.slug]
})
const componentPropsMeta = computed(() => {
return component.value?.meta?.props.filter(prop => prop.name !== 'ui').sort((a, b) => a.name.localeCompare(b.name))
})
function updateRenderer() {
if (!component.value) return
const event: Event & { data?: any } = new Event('nuxt-ui-devtools:update-renderer')
event.data = {
props: state.value.props?.[component.value.slug], slots: state.value.slots?.[component.value?.slug]
}
window.dispatchEvent(event)
}
watchDebounced(state, updateRenderer, { deep: true, debounce: 200, maxWait: 500 })
onMounted(() => window.addEventListener('nuxt-ui-devtools:component-loaded', onComponentLoaded))
onUnmounted(() => window.removeEventListener('nuxt-ui-devtools:component-loaded', onComponentLoaded))
function onComponentLoaded() {
if (!component.value) return
updateRenderer()
}
const tabs = computed(() => {
if (!component.value) return
return [
{ label: 'Props', slot: 'props', icon: 'i-lucide-settings', disabled: !component.value.meta?.props?.length }
]
})
function openDocs() {
if (!component.value) return
window.parent.open(`https://ui3.nuxt.dev/components/${component.value.slug}`)
}
const colorMode = useColorMode()
const isDark = computed({
get() {
return colorMode.value === 'dark'
},
set(value) {
colorMode.preference = value ? 'dark' : 'light'
const event: Event & { isDark?: boolean } = new Event('nuxt-ui-devtools:set-color-mode')
event.isDark = value
window.dispatchEvent(event)
}
})
</script>
<template>
<UApp class="flex justify-center items-center h-screen w-full relative font-sans">
<div v-if="status === 'pending' || error || !component || !components?.length">
<div v-if="error" class="flex flex-col justify-center items-center h-screen w-screen text-center text-[var(--ui-color-error-500)]">
<UILogo class="h-8" />
<UIcon name="i-lucide-circle-alert" size="20" class="mt-2" />
<p>
{{ (error.data as any)?.error ?? 'Unexpected error' }}
</p>
</div>
</div>
<template v-else>
<div
class="top-0 h-[49px] border-b border-[var(--ui-border)] flex justify-center"
>
<span />
<UInputMenu
v-model="component"
variant="none"
:items="components"
placeholder="Search component..."
class="top-0 translate-y-0 w-full mx-2"
icon="i-lucide-search"
/>
<div class="absolute top-[49px] bottom-0 inset-x-0 grid xl:grid-cols-8 grid-cols-4 bg-[var(--ui-bg)]">
<div class="col-span-1 border-r border-[var(--ui-border)] hidden xl:block overflow-y-auto">
<UNavigationMenu
:items="components.map((c) => ({ ...c, active: c.slug === component?.slug, onSelect: () => component = c }))"
orientation="vertical"
:ui="{ link: 'before:rounded-none' }"
/>
</div>
<div class="xl:col-span-5 col-span-2 relative">
<ComponentPreview :component="component" :props="componentProps" class="h-full" />
<div class="flex gap-2 absolute top-1 right-2">
<UButton
:icon="isDark ? 'i-lucide-moon' : 'i-lucide-sun'"
variant="ghost"
color="neutral"
@click="isDark = !isDark"
/>
<UButton
v-if="component"
variant="ghost"
color="neutral"
icon="i-lucide-external-link"
@click="openDocs()"
>
Open docs
</UButton>
</div>
</div>
<div class="border-l border-[var(--ui-border)] flex flex-col col-span-2 overflow-y-auto">
<UTabs color="neutral" variant="link" :items="tabs" class="relative" :ui="{ list: 'sticky top-0 bg-[var(--ui-bg)] z-50' }">
<template #props>
<div v-for="prop in componentPropsMeta" :key="'prop-' + prop.name" class="px-3 py-5 border-b border-[var(--ui-border)]">
<ComponentPropInput
v-model="componentProps[prop.name]"
:meta="prop"
:ignore="component.meta?.devtools?.ignoreProps?.includes(prop.name)"
/>
</div>
</template>
</UTabs>
</div>
</div>
</div>
</template>
</UApp>
</template>
<style>
@import 'tailwindcss';
@import '@nuxt/ui';
@theme {
--font-family-sans: 'DM Sans', sans-serif;
--color-primary-50: var(--ui-color-primary-50);
--color-primary-100: var(--ui-color-primary-100);
--color-primary-200: var(--ui-color-primary-200);
--color-primary-300: var(--ui-color-primary-300);
--color-primary-400: var(--ui-color-primary-400);
--color-primary-500: var(--ui-color-primary-500);
--color-primary-600: var(--ui-color-primary-600);
--color-primary-700: var(--ui-color-primary-700);
--color-primary-800: var(--ui-color-primary-800);
--color-primary-900: var(--ui-color-primary-900);
--color-primary-950: var(--ui-color-primary-950);
--color-neutral-50: var(--ui-color-neutral-50);
--color-neutral-100: var(--ui-color-neutral-100);
--color-neutral-200: var(--ui-color-neutral-200);
--color-neutral-300: var(--ui-color-neutral-300);
--color-neutral-400: var(--ui-color-neutral-400);
--color-neutral-500: var(--ui-color-neutral-500);
--color-neutral-600: var(--ui-color-neutral-600);
--color-neutral-700: var(--ui-color-neutral-700);
--color-neutral-800: var(--ui-color-neutral-800);
--color-neutral-900: var(--ui-color-neutral-900);
--color-neutral-950: var(--ui-color-neutral-950);
}
:root {
--ui-border: var(--ui-color-neutral-200);
--ui-bg: white;
}
.dark {
--ui-border: var(--ui-color-neutral-800);
--ui-bg: var(--ui-color-neutral-900);
}
.shiki
.shiki span {
background-color: transparent !important;
}
html.dark .shiki,
html.dark .shiki span {
color: var(--shiki-dark) !important;
background-color: transparent !important;
/* Optional, if you also want font styles */
font-style: var(--shiki-dark-font-style) !important;
font-weight: var(--shiki-dark-font-weight) !important;
text-decoration: var(--shiki-dark-text-decoration) !important;
}
</style>

View File

@@ -0,0 +1,43 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
const collapsed = ref(true)
const wrapper = ref<HTMLElement | null>(null)
const content = ref<HTMLElement | null>(null)
const overflow = computed(() => {
if (!content.value || !wrapper.value) return false
return content.value.scrollHeight > 48 * 4
})
onMounted(() => {
if (wrapper.value) {
wrapper.value.style.transition = 'max-height 0.3s ease' // Set transition for max-height
}
})
</script>
<template>
<div class="border rounded-[var(--ui-radius)] border-[var(--ui-border)]">
<div
ref="wrapper"
:class="['overflow-hidden', collapsed && overflow ? 'max-h-48' : 'max-h-none']"
>
<div ref="content">
<slot />
</div>
</div>
<UButton
v-if="overflow"
class="bg-[var(--ui-bg)] group w-full flex justify-center my-1 border-t border-[var(--ui-border)] rounded-t-none"
variant="link"
color="neutral"
trailing-icon="i-lucide-chevron-down"
:data-state="collapsed ? 'closed' : 'open'"
:ui="{ trailingIcon: 'transition group-data-[state=open]:rotate-180' }"
@click="collapsed = !collapsed"
>
{{ collapsed ? 'Expand' : 'Collapse' }}
</UButton>
</div>
</template>

View File

@@ -0,0 +1,151 @@
<script setup lang="ts">
import type { Component } from '../../../src/devtools/meta'
import { useClipboard } from '@vueuse/core'
import { kebabCase } from 'scule'
import { escapeString } from 'knitwork'
const props = defineProps<{ component?: Component, props?: object, themeSlots?: Record<string, any> }>()
const { data: componentExample } = useAsyncData('__ui_devtools_component-source', async () => {
const example = props.component?.meta?.devtools?.example
if (!example) return false
return await $fetch<{ source: string }>(`/api/component-example`, { params: { component: example } })
}, { watch: [() => props.component?.slug] })
function genPropValue(value: any): string {
if (typeof value === 'string') {
return `'${escapeString(value).replace(/'/g, '&apos;').replace(/"/g, '&quot;')}'`
}
if (Array.isArray(value)) {
return `[ ${value.map(item => `${genPropValue(item)}`).join(',')} ]`
}
if (typeof value === 'object' && value !== null) {
const entries = Object.entries(value).map(([key, val]) => `${key}: ${genPropValue(val)}`)
return `{ ${entries.join(`,`)} }`
}
return value
}
const code = computed(() => {
if (!props.component) return
const propsTemplate = Object.entries(props.props ?? {})?.map(([key, value]: [string, any]) => {
const defaultValue: any = props.component?.meta?.props.find(prop => prop.name === key)?.default
if (defaultValue === value) return
if (value === true) return kebabCase(key)
if (value === false && defaultValue === true) return `:${kebabCase(key)}="false"`
if (!value) return
if (props.component?.defaultVariants?.[key] === value) return
if (typeof value === 'string') return `${kebabCase(key)}=${genPropValue(value)}`
return `:${kebabCase(key)}="${genPropValue(value)}"`
}).filter(Boolean).join('\n')
const slotsTemplate = props.themeSlots
? genPropValue(Object.keys(props.themeSlots).filter(key => key !== 'base').reduce((acc, key) => {
acc[key] = genPropValue(props.themeSlots?.[key])
return acc
}, {} as Record<string, string>))
: undefined
const extraTemplate = [
propsTemplate,
props.themeSlots?.base ? `class="${genPropValue(props.themeSlots.base)}"` : null,
slotsTemplate && slotsTemplate !== '{}' ? `:ui="${slotsTemplate}"` : null
].filter(Boolean).join(' ')
if (componentExample.value) {
const componentRegexp = new RegExp(`<${props.component.label}(\\s|\\r|>)`)
return componentExample.value?.source
.replace(/import .* from ['"]#.*['"];?\n+/, '')
.replace(componentRegexp, `<${props.component.label} ${extraTemplate}$1`)
.replace('v-bind="$attrs"', '')
}
return `<${props.component.label} ${extraTemplate} />`
})
const { $prettier } = useNuxtApp()
const { data: formattedCode } = useAsyncData('__ui-devtools-component-formatted-code', async () => {
if (!code.value) return
return await $prettier.format(code.value, {
semi: false,
singleQuote: true,
printWidth: 80
})
}, { watch: [code] })
const { codeToHtml } = useShiki()
const { data: highlightedCode } = useAsyncData('__ui-devtools-component-highlighted-code', async () => {
return formattedCode.value
? codeToHtml(formattedCode.value, 'vue')
: undefined
}, { watch: [formattedCode] })
const { copy, copied } = useClipboard()
const rendererVisible = ref(true)
const renderer = ref()
const rendererReady = ref(false)
function onRendererReady() {
rendererReady.value = true
setTimeout(() => rendererVisible.value = !!renderer.value.contentWindow.document.getElementById('ui-devtools-renderer'), 500)
}
watch(() => props.component, () => rendererReady.value = false)
const previewUrl = computed(() => {
if (!props.component) return
const baseUrl = `/__nuxt_ui__/components/${props.component.slug}`
const params = new URLSearchParams()
if (props.component?.meta?.devtools?.example !== undefined) {
params.append('example', props.component.meta.devtools.example)
}
const queryString = params.toString()
return queryString ? `${baseUrl}?${queryString}` : baseUrl
})
</script>
<template>
<div class="flex flex-col bg-grid">
<iframe
v-if="component"
v-show="rendererReady && rendererVisible"
ref="renderer"
class="grow w-full"
:src="previewUrl"
@load="onRendererReady"
/>
<div v-if="!rendererVisible" class="grow w-full flex justify-center items-center px-8">
<UAlert color="error" variant="subtle" title="Component preview not found" icon="i-lucide-circle-alert">
<template #description>
<p>Ensure your <code>app.vue</code> file includes a <code>&lt;NuxtPage /&gt;</code> component, as the component preview is mounted as a page. </p>
</template>
</UAlert>
</div>
<div v-if="highlightedCode && formattedCode" v-show="rendererReady" class="relative w-full p-3">
<!-- eslint-disable vue/no-v-html -->
<pre class="p-4 min-h-40 max-h-72 text-sm overflow-y-auto rounded-[calc(var(--ui-radius)*1.5)] border border-[var(--ui-border)] bg-neutral-50 dark:bg-neutral-800" v-html="highlightedCode" />
<UButton
color="neutral"
variant="link"
:icon="copied ? 'i-lucide-clipboard-check' : 'i-lucide-clipboard'"
class="absolute top-6 right-6"
@click="copy(formattedCode)"
/>
</div>
</div>
</template>
<style scoped>
.bg-grid {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' transform='scale(3)'%3E%3Crect width='100%25' height='100%25' fill='%23fff'/%3E%3Cpath fill='none' stroke='hsla(0, 0%25, 98%25, 1)' stroke-width='.2' d='M10 0v20ZM0 10h20Z'/%3E%3C/svg%3E");
background-size: 40px 40px;
}
.dark .bg-grid {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' transform='scale(3)'%3E%3Crect width='100%25' height='100%25' fill='hsl(0, 0%25, 8.5%25)'/%3E%3Cpath fill='none' stroke='hsl(0, 0%25, 11.0%25)' stroke-width='.2' d='M10 0v20ZM0 10h20Z'/%3E%3C/svg%3E");
background-size: 40px 40px;
}
</style>

View File

@@ -0,0 +1,39 @@
<script setup lang="ts">
import type { PropertyMeta } from 'vue-component-meta'
const props = defineProps<{ meta: Partial<PropertyMeta>, ignore?: boolean }>()
const modelValue = defineModel<any>()
const matchedInput = shallowRef()
const parsedSchema = shallowRef()
const { resolveInputSchema } = usePropSchema()
watchEffect(() => {
if (!props.meta?.schema) return
const result = resolveInputSchema(props.meta.schema)
parsedSchema.value = result?.schema
matchedInput.value = result?.input
})
const description = computed(() => {
return props.meta.description?.replace(/`([^`]+)`/g, '<code class="font-medium bg-[var(--ui-bg-elevated)] px-1 py-0.5 rounded-[var(--ui-radius)]">$1</code>')
})
</script>
<template>
<UFormField :name="meta?.name" class="" :ui="{ wrapper: 'mb-2' }" :class="{ 'opacity-70 cursor-not-allowed': !matchedInput || ignore }">
<template #label>
<p v-if="meta?.name" class="font-mono font-bold px-1.5 py-0.5 border border-[var(--ui-border-accented)] border-dashed rounded-[var(--ui-radius)] bg-[var(--ui-bg-elevated)]">
{{ meta?.name }}
</p>
</template>
<template #description>
<!-- eslint-disable vue/no-v-html -->
<p v-if="meta.description" class="text-neutral-600 dark:text-neutral-400 mt-1" v-html="description" />
</template>
<component :is="matchedInput.component" v-if="!ignore && matchedInput" v-model="modelValue" :schema="parsedSchema" />
</UFormField>
</template>

View File

@@ -0,0 +1,10 @@
<template>
<svg
width="1020"
height="200"
viewBox="0 0 1020 200"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="w-auto h-6 shrink-0 text-[var(--ui-text)]"
><path d="M377 200C379.16 200 381 198.209 381 196V103C381 103 386 112 395 127L434 194C435.785 197.74 439.744 200 443 200H470V50H443C441.202 50 439 51.4941 439 54V148L421 116L385 55C383.248 51.8912 379.479 50 376 50H350V200H377Z" fill="currentColor" /><path d="M726 92H739C742.314 92 745 89.3137 745 86V60H773V92H800V116H773V159C773 169.5 778.057 174 787 174H800V200H783C759.948 200 745 185.071 745 160V116H726V92Z" fill="currentColor" /><path d="M591 92V154C591 168.004 585.742 179.809 578 188C570.258 196.191 559.566 200 545 200C530.434 200 518.742 196.191 511 188C503.389 179.809 498 168.004 498 154V92H514C517.412 92 520.769 92.622 523 95C525.231 97.2459 526 98.5652 526 102V154C526 162.059 526.457 167.037 530 171C533.543 174.831 537.914 176 545 176C552.217 176 555.457 174.831 559 171C562.543 167.037 563 162.059 563 154V102C563 98.5652 563.769 96.378 566 94C567.96 91.9107 570.028 91.9599 573 92C573.411 92.0055 574.586 92 575 92H591Z" fill="currentColor" /><path d="M676 144L710 92H684C680.723 92 677.812 93.1758 676 96L660 120L645 97C643.188 94.1758 639.277 92 636 92H611L645 143L608 200H634C637.25 200 640.182 196.787 642 194L660 167L679 195C680.818 197.787 683.75 200 687 200H713L676 144Z" fill="currentColor" /><path d="M168 200H279C282.542 200 285.932 198.756 289 197C292.068 195.244 295.23 193.041 297 190C298.77 186.959 300.002 183.51 300 179.999C299.998 176.488 298.773 173.04 297 170.001L222 41C220.23 37.96 218.067 35.7552 215 34C211.933 32.2448 207.542 31 204 31C200.458 31 197.067 32.2448 194 34C190.933 35.7552 188.77 37.96 187 41L168 74L130 9.99764C128.228 6.95784 126.068 3.75491 123 2C119.932 0.245087 116.542 0 113 0C109.458 0 106.068 0.245087 103 2C99.9323 3.75491 96.7717 6.95784 95 9.99764L2 170.001C0.226979 173.04 0.00154312 176.488 1.90993e-06 179.999C-0.0015393 183.51 0.229648 186.959 2 190C3.77035 193.04 6.93245 195.244 10 197C13.0675 198.756 16.4578 200 20 200H90C117.737 200 137.925 187.558 152 164L186 105L204 74L259 168H186L168 200ZM89 168H40L113 42L150 105L125.491 147.725C116.144 163.01 105.488 168 89 168Z" fill="var(--ui-color-primary-500)" /><path d="M958 60.0001H938C933.524 60.0001 929.926 59.9395 927 63C924.074 65.8905 925 67.5792 925 72V141C925 151.372 923.648 156.899 919 162C914.352 166.931 908.468 169 899 169C889.705 169 882.648 166.931 878 162C873.352 156.899 873 151.372 873 141V72.0001C873 67.5793 872.926 65.8906 870 63.0001C867.074 59.9396 863.476 60.0001 859 60.0001H840V141C840 159.023 845.016 173.458 855 184C865.156 194.542 879.893 200 899 200C918.107 200 932.844 194.542 943 184C953.156 173.458 958 159.023 958 141V60.0001Z" fill="var(--ui-color-primary-500)" /><path fill-rule="evenodd" clip-rule="evenodd" d="M1000 60.0233L1020 60V77L1020 128V156.007L1020 181L1020 189.004C1020 192.938 1019.98 194.429 1017 197.001C1014.02 199.725 1009.56 200 1005 200H986.001V181.006L986 130.012V70.0215C986 66.1576 986.016 64.5494 989 62.023C991.819 59.6358 995.437 60.0233 1000 60.0233Z" fill="var(--ui-color-primary-500)" /></svg>
</template>

View File

@@ -0,0 +1,76 @@
<script lang="ts">
import { z } from 'zod'
export const arrayInputSchema = z.object({
kind: z.literal('array'),
schema: z.array(z.any({}))
.or(z.record(z.number(), z.any({})).transform(t => Object.values(t)))
.transform((t) => {
return t.filter(s => s !== 'undefined')
}).pipe(z.array(z.any()).max(1))
})
export type ArrayInputSchema = z.infer<typeof arrayInputSchema>
</script>
<script setup lang="ts">
const props = defineProps<{
schema: ArrayInputSchema
}>()
const modelValue = defineModel<Array<any>>({})
const itemSchema = computed(() => {
return props.schema?.schema[0]
})
function removeArrayItem(index: number) {
if (!modelValue.value) return
modelValue.value.splice(index, 1)
}
function addArrayItem() {
if (!modelValue.value) {
modelValue.value = [{}]
} else {
modelValue.value.push({})
}
}
</script>
<template>
<div>
<div v-for="value, index in modelValue" :key="index" class="relative">
<ComponentPropInput
:model-value="value"
:meta="{ schema: itemSchema }"
/>
<UPopover>
<UButton variant="ghost" color="neutral" icon="i-lucide-ellipsis-vertical" class="absolute top-4 right-1" />
<template #content>
<UButton
variant="ghost"
color="error"
icon="i-lucide-trash"
block
@click="removeArrayItem(index)"
>
Remove
</UButton>
</template>
</UPopover>
</div>
<UButton
icon="i-lucide-plus"
color="neutral"
variant="ghost"
block
class="justify-center mt-4"
@click="addArrayItem()"
>
Add value
</UButton>
</div>
</template>

View File

@@ -0,0 +1,20 @@
<script lang="ts">
import { z } from 'zod'
export const booleanInputSchema = z.literal('boolean').or(z.object({
kind: z.literal('enum'),
type: z.string().refine((type) => {
return type.split('|').some(t => t.trim() === 'boolean')
})
}))
export type BooleanInputSchema = z.infer<typeof booleanInputSchema>
</script>
<script setup lang="ts">
defineProps<{ schema: BooleanInputSchema }>()
</script>
<template>
<USwitch />
</template>

View File

@@ -0,0 +1,15 @@
<script lang="ts">
import { z } from 'zod'
export const numberInputSchema = z.literal('number')
export type NumberInputSchema = z.infer<typeof numberInputSchema>
</script>
<script setup lang="ts">
defineProps<{ schema: NumberInputSchema }>()
const modelValue = defineModel<number>()
</script>
<template>
<UInput v-model.number="modelValue" type="number" />
</template>

View File

@@ -0,0 +1,38 @@
<script lang="ts">
import { z } from 'zod'
export const objectInputSchema = z.object({
kind: z.literal('object'),
schema: z.record(z.string(), z.any())
})
export type ObjectInputSchema = z.infer<typeof objectInputSchema>
</script>
<script setup lang="ts">
const props = defineProps<{
schema: ObjectInputSchema
}>()
const modelValue = defineModel<Record<string, any>>({})
const attributesSchemas = computed(() => {
return Object.values(props.schema.schema)
})
</script>
<template>
<CollapseContainer>
<ComponentPropInput
v-for="attributeSchema in attributesSchemas"
:key="attributeSchema.name"
class="border-b last:border-b-0 border-[var(--ui-border)] p-4"
:model-value="modelValue?.[attributeSchema.name]"
:meta="attributeSchema"
@update:model-value="(value: any) => {
if (!modelValue) modelValue ||= {}
else modelValue[attributeSchema.name] = value
}"
/>
</CollapseContainer>
</template>

View File

@@ -0,0 +1,60 @@
<script lang="ts">
import { z } from 'zod'
export const stringEnumInputSchema = z.object({
kind: z.literal('enum'),
schema: z.array(z.string())
.or(z.record(z.any(), z.string()).transform<string[]>(t => Object.values(t)))
.transform<string[]>(t => t.filter(s => s.trim().match(/^["'`]/)).map(s => s.trim().replaceAll(/["'`]/g, '')))
.pipe(z.array(z.string()).min(1))
})
export type StringEnumInputSchema = z.infer<typeof stringEnumInputSchema>
</script>
<script setup lang="ts">
const props = defineProps<{
schema: StringEnumInputSchema
}>()
const sizes = ['xs', 'sm', 'md', 'lg', 'xl']
function parseSize(size: string) {
const sizePattern = sizes.join('|')
const regex = new RegExp(`^(\\d*)(${sizePattern})$`, 'i')
const match = size.match(regex)
if (!match) return null
const number = match[1] ? Number.parseInt(match[1], 10) : 1 // Default to 1 if no number is present
const suffix = match[2] ?? ''
return { number, suffix }
}
const options = computed(() => {
return [...props.schema.schema].sort((a, b) => {
const sizeA = parseSize(a)
const sizeB = parseSize(b)
if (!sizeA || !sizeB) return a.localeCompare(b)
const suffixAIndex = sizes.indexOf(sizeA.suffix)
const suffixBIndex = sizes.indexOf(sizeB.suffix)
if (suffixAIndex !== -1 && suffixBIndex !== -1) {
if (suffixAIndex !== suffixBIndex) {
return suffixAIndex - suffixBIndex
}
} else if (suffixAIndex === -1 || suffixBIndex === -1) {
if (sizeA.suffix !== sizeB.suffix) {
return sizeA.suffix.localeCompare(sizeB.suffix)
}
}
return sizeA.number - sizeB.number
})
})
</script>
<template>
<USelectMenu :items="options" class="min-w-[167px]" />
</template>

View File

@@ -0,0 +1,15 @@
<script lang="ts">
import { z } from 'zod'
export const stringInputSchema = z.literal('string').or(z.string().transform(t => t.split('|').find(s => s.trim() === 'string')).pipe(z.string()))
export type StringInputSchema = z.infer<typeof stringInputSchema>
</script>
<script setup lang="ts">
defineProps<{ schema: StringInputSchema }>()
</script>
<template>
<UInput />
</template>

View File

@@ -0,0 +1,44 @@
import type { PropertyMeta } from 'vue-component-meta'
import BooleanInput, { booleanInputSchema } from '../components/inputs/BooleanInput.vue'
import StringInput, { stringInputSchema } from '../components/inputs/StringInput.vue'
import NumberInput, { numberInputSchema } from '../components/inputs/NumberInput.vue'
import StringEnumInput, { stringEnumInputSchema } from '../components/inputs/StringEnumInput.vue'
import ObjectInput, { objectInputSchema } from '../components/inputs/ObjectInput.vue'
import ArrayInput, { arrayInputSchema } from '../components/inputs/ArrayInput.vue'
// List of available inputs.
const availableInputs = [
{ id: 'string', schema: stringInputSchema, component: StringInput },
{ id: 'number', schema: numberInputSchema, component: NumberInput },
{ id: 'boolean', schema: booleanInputSchema, component: BooleanInput },
{ id: 'stringEnum', schema: stringEnumInputSchema, component: StringEnumInput },
{ id: 'object', schema: objectInputSchema, component: ObjectInput },
{ id: 'array', schema: arrayInputSchema, component: ArrayInput }
]
export function usePropSchema() {
function resolveInputSchema(schema: PropertyMeta['schema']): { schema: PropertyMeta['schema'], input: any } | undefined {
// Return the first input in the list of available inputs that matches the schema.
for (const input of availableInputs) {
const result = input.schema.safeParse(schema)
if (result.success) {
// Returns the output from zod to get the transformed output.
// It only includes attributes defined in the zod schema.
return { schema: result.data as PropertyMeta['schema'], input }
}
}
if (typeof schema === 'string') return
// If the schema is a complex enum or array return the first nested schema that matches an input.
if (schema.kind === 'enum' && schema.schema) {
const enumSchemas = typeof schema.schema === 'object' ? Object.values(schema.schema) : schema.schema
for (const enumSchema of enumSchemas) {
const result = resolveInputSchema(enumSchema)
if (result) return result
}
}
}
return { resolveInputSchema }
}

View File

@@ -0,0 +1,34 @@
import { createHighlighterCore } from 'shiki/core'
import type { BuiltinLanguage, HighlighterCore } from 'shiki'
import loadWasm from 'shiki/wasm'
import MaterialThemeLighter from 'shiki/themes/material-theme-lighter.mjs'
import MaterialThemePalenight from 'shiki/themes/material-theme-palenight.mjs'
import VueLang from 'shiki/langs/vue.mjs'
import MarkdownLang from 'shiki/langs/markdown.mjs'
export const highlighter = shallowRef<HighlighterCore>()
// A custom composable for syntax highlighting with Shiki since `@nuxt/mdc` relies on
// a server endpoint to highlight code.
export function useShiki() {
async function codeToHtml(code: string, lang: BuiltinLanguage | 'text' = 'text') {
if (!highlighter.value) {
highlighter.value = await createHighlighterCore({
themes: [MaterialThemeLighter, MaterialThemePalenight],
langs: [VueLang, MarkdownLang],
loadWasm
})
}
return highlighter.value.codeToHtml(code, {
lang,
themes: {
dark: 'material-theme-palenight',
default: 'material-theme-lighter',
light: 'material-theme-lighter'
}
})
}
return { codeToHtml }
}

View File

@@ -0,0 +1,54 @@
import type { Options } from 'prettier'
import PrettierWorker from '@/workers/prettier.js?worker&inline'
export interface SimplePrettier {
format: (source: string, options?: Options) => Promise<string>
}
function createPrettierWorkerApi(worker: Worker): SimplePrettier {
let counter = 0
const handlers: any = {}
worker.addEventListener('message', (event) => {
const { uid, message, error } = event.data
if (!handlers[uid]) {
return
}
const [resolve, reject] = handlers[uid]
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete handlers[uid]
if (error) {
reject(error)
} else {
resolve(message)
}
})
function postMessage<T>(message: any) {
const uid = ++counter
return new Promise<T>((resolve, reject) => {
handlers[uid] = [resolve, reject]
worker.postMessage({ uid, message })
})
}
return {
format(source: string, options?: Options) {
return postMessage({ type: 'format', source, options })
}
}
}
export default defineNuxtPlugin(async () => {
const worker = new PrettierWorker()
const prettier = createPrettierWorkerApi(worker)
return {
provide: {
prettier
}
}
})

View File

@@ -0,0 +1,36 @@
/* eslint-disable no-undef */
self.onmessage = async function (event) {
self.postMessage({
uid: event.data.uid,
message: await handleMessage(event.data.message)
})
}
function handleMessage(message) {
switch (message.type) {
case 'format':
return handleFormatMessage(message)
}
}
async function handleFormatMessage(message) {
if (!globalThis.prettier) {
await Promise.all([
import('https://unpkg.com/prettier@3.3.3/standalone.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/html.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/postcss.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/babel.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/estree.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/typescript.js')
])
}
const { options, source } = message
const formatted = await prettier.format(source, {
parser: 'vue',
plugins: prettierPlugins,
...options
})
return formatted
}

38
devtools/nuxt.config.ts Normal file
View File

@@ -0,0 +1,38 @@
import { resolve } from 'node:path'
export default defineNuxtConfig({
modules: ['../src/module', '@nuxt/test-utils/module'],
ssr: false,
devtools: { enabled: false },
app: {
baseURL: '/__nuxt_ui__/devtools'
},
future: {
compatibilityVersion: 4
},
compatibilityDate: '2024-04-03',
nitro: {
hooks: {
'prerender:routes': function (routes) {
routes.clear()
}
},
output: {
publicDir: resolve(__dirname, '../dist/client/devtools')
}
},
vite: {
server: {
hmr: {
clientPort: process.env.PORT ? +process.env.PORT : undefined
}
}
}
})

19
devtools/package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "@nuxt/ui-devtools",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"test": "vitest"
},
"dependencies": {
"@nuxt/ui": "latest",
"knitwork": "^1.1.0",
"nuxt": "^3.14.159",
"prettier": "^3.3.3",
"zod": "^3.23.8"
}
}

View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" class="w-auto h-6 shrink-0" viewBox="840 60 180 140"><path d="M958 60.0001H938C933.524 60.0001 929.926 59.9395 927 63C924.074 65.8905 925 67.5792 925 72V141C925 151.372 923.648 156.899 919 162C914.352 166.931 908.468 169 899 169C889.705 169 882.648 166.931 878 162C873.352 156.899 873 151.372 873 141V72.0001C873 67.5793 872.926 65.8906 870 63.0001C867.074 59.9396 863.476 60.0001 859 60.0001H840V141C840 159.023 845.016 173.458 855 184C865.156 194.542 879.893 200 899 200C918.107 200 932.844 194.542 943 184C953.156 173.458 958 159.023 958 141V60.0001Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M1000 60.0233L1020 60V77L1020 128V156.007L1020 181L1020 189.004C1020 192.938 1019.98 194.429 1017 197.001C1014.02 199.725 1009.56 200 1005 200H986.001V181.006L986 130.012V70.0215C986 66.1576 986.016 64.5494 989 62.023C991.819 59.6358 995.437 60.0233 1000 60.0233Z" fill="currentColor"></path> <style> path { fill: #00000080; } @media (prefers-color-scheme: dark) { path { fill: #ffffff80; } } </style> </svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,24 @@
// @vitest-environment node
import { it, expect, describe } from 'vitest'
import { usePropSchema } from '../../app/composables/usePropSchema'
import { stringSchema, optionalStringSchema, booleanSchema, numberSchema, optionalNumberSchema, optionalBooleanSchema, objectSchema, arraySchema, arrayOptionalSchema, stringEnumSchema } from '../fixtures/schemas'
describe('usePropSchema', () => {
const { resolveInputSchema } = usePropSchema()
it.each([
['string', { schema: stringSchema, inputId: 'string' }],
['optional string', { schema: optionalStringSchema, inputId: 'string' }],
['number', { schema: numberSchema, inputId: 'number' }],
['optional number', { schema: optionalNumberSchema, inputId: 'number' }],
['boolean', { schema: booleanSchema, inputId: 'boolean' }],
['string enum', { schema: stringEnumSchema, inputId: 'stringEnum' }],
['object', { schema: objectSchema, inputId: 'object' }],
['optional boolean', { schema: optionalBooleanSchema, inputId: 'boolean' }],
['array', { schema: arraySchema, inputId: 'array' }],
['optional array', { schema: arrayOptionalSchema, inputId: 'array' }]
])('resolveInputSchema should resolve %s schema', async (_: string, options) => {
const result = resolveInputSchema(options.schema as any)
expect(result?.input.id).toBe(options.inputId)
})
})

133
devtools/test/fixtures/schemas.ts vendored Normal file
View File

@@ -0,0 +1,133 @@
export const stringSchema = 'string' as const
export const optionalStringSchema = {
kind: 'enum',
type: 'string | undefined',
schema: {
0: 'undefined',
1: 'string'
}
}
export const numberSchema = 'number' as const
export const optionalNumberSchema = {
kind: 'enum',
type: 'number | undefined',
schema: {
0: 'undefined',
1: 'number'
}
}
export const booleanSchema = 'boolean' as const
export const optionalBooleanSchema = {
kind: 'enum',
type: 'boolean | undefined',
schema: {
0: 'undefined',
1: 'boolean'
}
}
export const objectSchema = {
kind: 'object',
type: 'AccordionItem',
schema: {
label: {
name: 'label',
global: false,
description: '',
tags: [],
required: false,
type: 'string | undefined',
schema: {
kind: 'enum',
type: 'string | undefined',
schema: {
0: 'undefined',
1: 'string'
}
}
}
}
}
export const arraySchema = {
kind: 'array',
type: 'AccordionItem[]',
schema: [
{
kind: 'object',
type: 'AccordionItem',
schema: {
label: {
name: 'label',
global: false,
description: '',
tags: [],
required: false,
type: 'string | undefined',
schema: {
kind: 'enum',
type: 'string | undefined',
schema: {
0: 'undefined',
1: 'string'
}
}
}
}
}
]
}
export const arrayOptionalSchema = {
kind: 'enum',
type: 'AccordionItem[] | undefined',
schema: {
0: 'undefined',
1: {
kind: 'array',
type: 'AccordionItem[]',
schema: [
{
kind: 'object',
type: 'AccordionItem',
schema: {
label: {
name: 'label',
global: false,
description: '',
tags: [],
required: false,
type: 'string | undefined',
schema: {
kind: 'enum',
type: 'string | undefined',
schema: {
0: 'undefined',
1: 'string'
}
}
}
}
}
]
}
}
}
export const stringEnumSchema = {
kind: 'enum',
type: '"true" | "false" | "page" | "step" | "location" | "date" | "time" | undefined',
schema: {
0: 'undefined',
1: '"true"',
2: '"false"',
3: '"page"',
4: '"step"',
5: '"location"',
6: '"date"',
7: '"time"'
}
}

View File

@@ -0,0 +1,7 @@
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({
test: {
environment: 'nuxt'
}
})

4
devtools/tsconfig.json Normal file
View File

@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}

View File

@@ -4,10 +4,13 @@ export default defineAppConfig({
expand: true,
duration: 5000
},
theme: {
radius: 0.25
},
ui: {
colors: {
primary: 'green',
gray: 'slate'
neutral: 'slate'
}
}
})

View File

@@ -1,16 +1,16 @@
<script setup lang="ts">
import { withoutTrailingSlash } from 'ufo'
import colors from 'tailwindcss/colors'
// import { debounce } from 'perfect-debounce'
// import type { ContentSearchFile } from '@nuxt/ui-pro'
const route = useRoute()
const appConfig = useAppConfig()
// const colorMode = useColorMode()
const runtimeConfig = useRuntimeConfig()
const { integrity, api } = runtimeConfig.public.content
const colorMode = useColorMode()
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation(), { default: () => [] })
const { data: files } = await useLazyFetch<any[]>(`${api.baseURL}/search${integrity ? '-' + integrity : ''}`, { default: () => [] })
const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('content'))
const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('content'), {
server: false
})
const searchTerm = ref('')
@@ -22,45 +22,47 @@ const searchTerm = ref('')
// useTrackEvent('Search', { props: { query: `${query} - ${searchTerm.value?.commandPaletteRef.results.length} results` } })
// }, 500))
const links = computed(() => {
return [{
label: 'Docs',
icon: 'i-heroicons-book-open',
to: '/getting-started',
active: route.path.startsWith('/getting-started') || route.path.startsWith('/components')
}, ...(navigation.value.find(item => item._path === '/pro')
? [{
label: 'Pro',
icon: 'i-heroicons-square-3-stack-3d',
to: '/pro',
active: route.path.startsWith('/pro/getting-started') || route.path.startsWith('/pro/components') || route.path.startsWith('/pro/prose')
}, {
label: 'Pricing',
icon: 'i-heroicons-credit-card',
to: '/pro/pricing'
}, {
label: 'Templates',
icon: 'i-heroicons-computer-desktop',
to: '/pro/templates'
}]
: []), {
label: 'Releases',
icon: 'i-heroicons-rocket-launch',
to: '/releases'
}].filter(Boolean)
})
const links = computed(() => [{
label: 'Docs',
icon: 'i-lucide-square-play',
to: '/getting-started',
active: route.path.startsWith('/getting-started')
}, {
label: 'Components',
icon: 'i-lucide-square-code',
to: '/components',
active: route.path.startsWith('/components')
}, {
label: 'Roadmap',
icon: 'i-lucide-map',
to: '/roadmap'
}, {
label: 'Figma',
icon: 'i-lucide-figma',
to: 'https://www.figma.com/community/file/1288455405058138934',
target: '_blank'
}, {
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases',
target: '_blank'
}].filter(Boolean))
// const color = computed(() => colorMode.value === 'dark' ? '#18181b' : 'white')
const color = computed(() => colorMode.value === 'dark' ? (colors as any)[appConfig.ui.colors.neutral][900] : 'white')
const radius = computed(() => `:root { --ui-radius: ${appConfig.theme.radius}rem; }`)
useHead({
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
// { key: 'theme-color', name: 'theme-color', content: color }
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ key: 'theme-color', name: 'theme-color', content: color }
],
link: [
{ rel: 'icon', type: 'image/svg+xml', href: '/icon.svg' },
{ rel: 'canonical', href: `https://ui.nuxt.com${withoutTrailingSlash(route.path)}` }
],
style: [
{ innerHTML: radius, id: 'nuxt-ui-radius', tagPriority: -2 }
],
htmlAttrs: {
lang: 'en'
}
@@ -71,7 +73,24 @@ useServerSeoMeta({
twitterCard: 'summary_large_image'
})
provide('navigation', navigation)
const updatedNavigation = computed(() => navigation.value?.map(item => ({
...item,
children: item.children?.map((child: typeof item) => ({
...child,
...(child.path === '/getting-started/installation' && {
title: 'Installation',
active: route.path.startsWith('/getting-started/installation'),
children: []
}),
...(child.path === '/getting-started/i18n' && {
title: 'I18n',
active: route.path.startsWith('/getting-started/i18n'),
children: []
})
})) || []
})))
provide('navigation', updatedNavigation)
</script>
<template>
@@ -105,6 +124,8 @@ provide('navigation', navigation)
@source "../content/**/*.md";
@theme {
--container-8xl: 90rem;
--font-family-sans: 'Public Sans', sans-serif;
--color-green-50: #EFFDF5;
@@ -121,6 +142,6 @@ provide('navigation', navigation)
}
:root {
--container-width: 90rem;
--ui-container: var(--container-8xl);
}
</style>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,5 +1,5 @@
<template>
<UBanner icon="i-heroicons-wrench-screwdriver" :actions="[{ label: 'Go to Nuxt UI v2', to: 'https://ui.nuxt.com', trailingIcon: 'i-heroicons-arrow-right-20-solid', class: 'rounded-full' }]" :close="false">
<UBanner icon="i-lucide-construction" :actions="[{ label: 'Go to Nuxt UI v2', to: 'https://ui.nuxt.com', trailingIcon: 'i-lucide-arrow-right' }]" :close="false">
<template #title>
You're looking at the documentation for <span class="font-semibold">Nuxt UI v3</span>!
</template>

View File

@@ -23,15 +23,15 @@ const route = useRoute()
<UFooter>
<template #left>
<NuxtLink v-if="route.path.startsWith('/pro')" to="https://ui.nuxt.com/pro/purchase" target="_blank" class="text-sm text-gray-500 dark:text-gray-400">
Purchase <span class="text-gray-900 dark:text-white">Nuxt UI Pro</span>
<NuxtLink v-if="route.path.startsWith('/pro')" to="https://ui.nuxt.com/pro/purchase" target="_blank" class="text-sm text-[var(--ui-text-muted)]">
Purchase <span class="text-[var(--ui-text-highlighted)]">Nuxt UI Pro</span>
</NuxtLink>
<NuxtLink v-else to="https://github.com/nuxt/ui" target="_blank" class="text-sm text-gray-500 dark:text-gray-400">
Published under <span class="text-gray-900 dark:text-white">MIT License</span>
<NuxtLink v-else to="https://github.com/nuxt/ui" target="_blank" class="text-sm text-[var(--ui-text-muted)]">
Published under <span class="text-[var(--ui-text-highlighted)]">MIT License</span>
</NuxtLink>
</template>
<!-- <UNavigationMenu :items="items" variant="link" color="gray" /> -->
<!-- <UNavigationMenu :items="items" variant="link" color="neutral" /> -->
<template #right>
<UButton
@@ -39,7 +39,7 @@ const route = useRoute()
icon="i-simple-icons-nuxtdotjs"
to="https://nuxt.com"
target="_blank"
color="gray"
color="neutral"
variant="ghost"
/>
<UButton
@@ -47,7 +47,7 @@ const route = useRoute()
icon="i-simple-icons-discord"
to="https://chat.nuxt.dev"
target="_blank"
color="gray"
color="neutral"
variant="ghost"
/>
<UButton
@@ -55,7 +55,7 @@ const route = useRoute()
icon="i-simple-icons-x"
to="https://x.com/nuxt_js"
target="_blank"
color="gray"
color="neutral"
variant="ghost"
/>
<UButton
@@ -63,7 +63,7 @@ const route = useRoute()
icon="i-simple-icons-github"
to="https://github.com/nuxt/ui"
target="_blank"
color="gray"
color="neutral"
variant="ghost"
/>
</template>

View File

@@ -1,55 +1,61 @@
<script setup lang="ts">
import type { NavItem } from '@nuxt/content'
import type { ContentNavigationItem } from '@nuxt/content'
import type { NavigationMenuItem } from '@nuxt/ui'
defineProps<{
const props = defineProps<{
links: NavigationMenuItem[]
}>()
const config = useRuntimeConfig().public
const navigation = inject<Ref<NavItem[]>>('navigation')
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
// const items = computed(() => props.links.map(({ icon, ...link }) => link))
const items = computed(() => props.links.map(({ icon, ...link }) => link))
defineShortcuts({
meta_g: () => {
window.open('https://github.com/nuxt/ui/tree/v3', '_blank')
}
})
</script>
<template>
<UHeader :ui="{ left: 'min-w-0' }">
<template #left>
<NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-gray-900 dark:text-white min-w-0" aria-label="Nuxt UI">
<NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-[var(--ui-text-highlighted)] min-w-0 focus-visible:outline-[var(--ui-primary)]" aria-label="Nuxt UI">
<Logo class="w-auto h-6 shrink-0" />
<UBadge :label="`v${config.version}`" variant="subtle" size="sm" class="-mb-[2px] rounded font-semibold truncate" />
<UBadge :label="`v${config.version}`" variant="subtle" size="sm" class="-mb-[2px] rounded-[var(--ui-radius)] font-semibold inline-block truncate" />
</NuxtLink>
</template>
<!-- <UNavigationMenu :items="items" variant="link" /> -->
<UNavigationMenu :items="items" variant="link" />
<template #right>
<ColorPicker />
<ThemePicker />
<UTooltip text="Search" :kbds="['meta', 'K']">
<UContentSearchButton />
</UTooltip>
<ColorModeButton />
<UButton
color="gray"
variant="ghost"
to="https://github.com/nuxt/ui/tree/v3"
target="_blank"
icon="i-simple-icons-github"
aria-label="GitHub"
/>
<UTooltip text="Open on GitHub" :kbds="['meta', 'G']">
<UButton
color="neutral"
variant="ghost"
to="https://github.com/nuxt/ui/tree/v3"
target="_blank"
icon="i-simple-icons-github"
aria-label="GitHub"
/>
</UTooltip>
</template>
<template #content>
<!-- <UNavigationMenu orientation="vertical" :items="items" class="-ml-2.5" />
<UNavigationMenu orientation="vertical" :items="links" class="-ml-2.5" />
<USeparator type="dashed" class="my-4" /> -->
<USeparator type="dashed" class="my-4" />
<UContentNavigation :navigation="navigation" />
<UContentNavigation :navigation="navigation" highlight />
</template>
</UHeader>
</template>

View File

@@ -4,8 +4,8 @@
<path d="M726 92H739C742.314 92 745 89.3137 745 86V60H773V92H800V116H773V159C773 169.5 778.057 174 787 174H800V200H783C759.948 200 745 185.071 745 160V116H726V92Z" fill="currentColor" />
<path d="M591 92V154C591 168.004 585.742 179.809 578 188C570.258 196.191 559.566 200 545 200C530.434 200 518.742 196.191 511 188C503.389 179.809 498 168.004 498 154V92H514C517.412 92 520.769 92.622 523 95C525.231 97.2459 526 98.5652 526 102V154C526 162.059 526.457 167.037 530 171C533.543 174.831 537.914 176 545 176C552.217 176 555.457 174.831 559 171C562.543 167.037 563 162.059 563 154V102C563 98.5652 563.769 96.378 566 94C567.96 91.9107 570.028 91.9599 573 92C573.411 92.0055 574.586 92 575 92H591Z" fill="currentColor" />
<path d="M676 144L710 92H684C680.723 92 677.812 93.1758 676 96L660 120L645 97C643.188 94.1758 639.277 92 636 92H611L645 143L608 200H634C637.25 200 640.182 196.787 642 194L660 167L679 195C680.818 197.787 683.75 200 687 200H713L676 144Z" fill="currentColor" />
<path d="M168 200H279C282.542 200 285.932 198.756 289 197C292.068 195.244 295.23 193.041 297 190C298.77 186.959 300.002 183.51 300 179.999C299.998 176.488 298.773 173.04 297 170.001L222 41C220.23 37.96 218.067 35.7552 215 34C211.933 32.2448 207.542 31 204 31C200.458 31 197.067 32.2448 194 34C190.933 35.7552 188.77 37.96 187 41L168 74L130 9.99764C128.228 6.95784 126.068 3.75491 123 2C119.932 0.245087 116.542 0 113 0C109.458 0 106.068 0.245087 103 2C99.9323 3.75491 96.7717 6.95784 95 9.99764L2 170.001C0.226979 173.04 0.00154312 176.488 1.90993e-06 179.999C-0.0015393 183.51 0.229648 186.959 2 190C3.77035 193.04 6.93245 195.244 10 197C13.0675 198.756 16.4578 200 20 200H90C117.737 200 137.925 187.558 152 164L186 105L204 74L259 168H186L168 200ZM89 168H40L113 42L150 105L125.491 147.725C116.144 163.01 105.488 168 89 168Z" fill="var(--color-primary-DEFAULT)" />
<path d="M958 60.0001H938C933.524 60.0001 929.926 59.9395 927 63C924.074 65.8905 925 67.5792 925 72V141C925 151.372 923.648 156.899 919 162C914.352 166.931 908.468 169 899 169C889.705 169 882.648 166.931 878 162C873.352 156.899 873 151.372 873 141V72.0001C873 67.5793 872.926 65.8906 870 63.0001C867.074 59.9396 863.476 60.0001 859 60.0001H840V141C840 159.023 845.016 173.458 855 184C865.156 194.542 879.893 200 899 200C918.107 200 932.844 194.542 943 184C953.156 173.458 958 159.023 958 141V60.0001Z" fill="var(--color-primary-DEFAULT)" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M1000 60.0233L1020 60V77L1020 128V156.007L1020 181L1020 189.004C1020 192.938 1019.98 194.429 1017 197.001C1014.02 199.725 1009.56 200 1005 200H986.001V181.006L986 130.012V70.0215C986 66.1576 986.016 64.5494 989 62.023C991.819 59.6358 995.437 60.0233 1000 60.0233Z" fill="var(--color-primary-DEFAULT)" />
<path d="M168 200H279C282.542 200 285.932 198.756 289 197C292.068 195.244 295.23 193.041 297 190C298.77 186.959 300.002 183.51 300 179.999C299.998 176.488 298.773 173.04 297 170.001L222 41C220.23 37.96 218.067 35.7552 215 34C211.933 32.2448 207.542 31 204 31C200.458 31 197.067 32.2448 194 34C190.933 35.7552 188.77 37.96 187 41L168 74L130 9.99764C128.228 6.95784 126.068 3.75491 123 2C119.932 0.245087 116.542 0 113 0C109.458 0 106.068 0.245087 103 2C99.9323 3.75491 96.7717 6.95784 95 9.99764L2 170.001C0.226979 173.04 0.00154312 176.488 1.90993e-06 179.999C-0.0015393 183.51 0.229648 186.959 2 190C3.77035 193.04 6.93245 195.244 10 197C13.0675 198.756 16.4578 200 20 200H90C117.737 200 137.925 187.558 152 164L186 105L204 74L259 168H186L168 200ZM89 168H40L113 42L150 105L125.491 147.725C116.144 163.01 105.488 168 89 168Z" fill="var(--ui-primary)" />
<path d="M958 60.0001H938C933.524 60.0001 929.926 59.9395 927 63C924.074 65.8905 925 67.5792 925 72V141C925 151.372 923.648 156.899 919 162C914.352 166.931 908.468 169 899 169C889.705 169 882.648 166.931 878 162C873.352 156.899 873 151.372 873 141V72.0001C873 67.5793 872.926 65.8906 870 63.0001C867.074 59.9396 863.476 60.0001 859 60.0001H840V141C840 159.023 845.016 173.458 855 184C865.156 194.542 879.893 200 899 200C918.107 200 932.844 194.542 943 184C953.156 173.458 958 159.023 958 141V60.0001Z" fill="var(--ui-primary)" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M1000 60.0233L1020 60V77L1020 128V156.007L1020 181L1020 189.004C1020 192.938 1019.98 194.429 1017 197.001C1014.02 199.725 1009.56 200 1005 200H986.001V181.006L986 130.012V70.0215C986 66.1576 986.016 64.5494 989 62.023C991.819 59.6358 995.437 60.0233 1000 60.0233Z" fill="var(--ui-primary)" />
</svg>
</template>

View File

@@ -1,38 +0,0 @@
<template>
<ClientOnly v-if="!colorMode?.forced">
<UButton
:icon="isDark ? appConfig.ui.icons.dark : appConfig.ui.icons.light"
color="gray"
variant="ghost"
v-bind="{
...$attrs
}"
:aria-label="`Switch to ${isDark ? 'light' : 'dark'} mode`"
@click="isDark = !isDark"
/>
<template #fallback>
<div class="w-8 h-8" />
</template>
</ClientOnly>
</template>
<script setup lang="ts">
defineOptions({
inheritAttrs: false
})
const colorMode = useColorMode()
const appConfig = useAppConfig()
// Computed
const isDark = computed({
get() {
return colorMode.value === 'dark'
},
set() {
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
}
})
</script>

View File

@@ -1,62 +0,0 @@
<template>
<UPopover mode="hover" :ui="{ content: 'p-2' }">
<template #default="{ open }">
<UButton
icon="i-heroicons-swatch-20-solid"
color="gray"
:variant="open ? 'soft' : 'ghost'"
square
aria-label="Color picker"
:ui="{ leadingIcon: 'text-primary-500 dark:text-primary-400' }"
/>
</template>
<template #content>
<fieldset class="grid grid-cols-5 gap-px">
<legend class="text-[11px] font-bold mb-1">
Primary
</legend>
<ColorPickerPill v-for="color in primaryColors" :key="color" :color="color" :selected="primary" @select="primary = color" />
</fieldset>
<USeparator class="my-2" type="dashed" />
<fieldset class="grid grid-cols-5 gap-px">
<legend class="text-[11px] font-bold mb-1">
Gray
</legend>
<ColorPickerPill v-for="color in grayColors" :key="color" :color="color" :selected="gray" @select="gray = color" />
</fieldset>
</template>
</UPopover>
</template>
<script setup lang="ts">
const appConfig = useAppConfig()
// Computed
const primaryColors = ['red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']
const primary = computed({
get() {
return appConfig.ui.colors.primary
},
set(option) {
appConfig.ui.colors.primary = option
window.localStorage.setItem('nuxt-ui-primary', appConfig.ui.colors.primary)
}
})
const grayColors = ['slate', 'cool', 'zinc', 'neutral', 'stone']
const gray = computed({
get() {
return appConfig.ui.colors.gray
},
set(option) {
appConfig.ui.colors.gray = option
window.localStorage.setItem('nuxt-ui-gray', appConfig.ui.colors.gray)
}
})
</script>

View File

@@ -1,24 +0,0 @@
<template>
<UTooltip :text="color" class="capitalize" :portal="false">
<UButton
color="gray"
square
:variant="color === selected ? 'soft' : 'ghost'"
@click.stop.prevent="$emit('select')"
>
<span
class="inline-block w-3 h-3 rounded-full"
:class="`bg-[--color-light] dark:bg-[--color-dark]`"
:style="{
'--color-light': `var(--color-${color}-500)`,
'--color-dark': `var(--color-${color}-400)`
}"
/>
</UButton>
</UTooltip>
</template>
<script setup lang="ts">
defineProps<{ color: string, selected: string }>()
defineEmits(['select'])
</script>

View File

@@ -32,6 +32,10 @@ const props = defineProps<{
* @defaultValue false
*/
collapse?: boolean
/**
* A list of line numbers to highlight in the code block
*/
highlights?: number[]
}>()
const route = useRoute()
@@ -39,6 +43,7 @@ const { $prettier } = useNuxtApp()
const camelName = camelCase(props.slug ?? route.params.slug?.[route.params.slug.length - 1] ?? '')
const name = `U${upperFirst(camelName)}`
const component = defineAsyncComponent(() => import(`#ui/components/${upperFirst(camelName)}.vue`))
const componentProps = reactive({ ...(props.props || {}) })
const componentEvents = reactive({
@@ -86,7 +91,7 @@ const options = computed(() => {
value: variant,
label: variant,
chip: key.toLowerCase().endsWith('color') ? { color: variant } : undefined
})).filter(variant => key.toLowerCase().endsWith('color') ? !['error'].includes(variant.value) : true)
}))
return {
name: key,
@@ -105,7 +110,7 @@ const code = computed(() => {
`
}
code += `\`\`\`vue`
code += `\`\`\`vue${props.highlights?.length ? ` {${props.highlights.join('-')}}` : ''}`
if (props.external?.length) {
code += `
@@ -201,7 +206,8 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
formatted = await $prettier.format(code.value, {
trailingComma: 'none',
semi: false,
singleQuote: true
singleQuote: true,
printWidth: 100
})
} catch {
formatted = code.value
@@ -214,15 +220,15 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
<template>
<div class="my-5">
<div>
<div v-if="options.length" class="flex items-center gap-2.5 border border-gray-200 dark:border-gray-700 border-b-0 relative rounded-t-md px-4 py-2.5 overflow-x-auto">
<div v-if="options.length" class="flex items-center gap-2.5 border border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)] border-b-0 relative rounded-t-[calc(var(--ui-radius)*1.5)] px-4 py-2.5 overflow-x-auto">
<template v-for="option in options" :key="option.name">
<UFormField
:label="option.label"
size="sm"
class="inline-flex ring ring-gray-300 dark:ring-gray-700 rounded"
class="inline-flex ring ring-[var(--ui-border-accented)] rounded-[var(--ui-radius)]"
:ui="{
wrapper: 'bg-gray-50 dark:bg-gray-800/50 rounded-l flex border-r border-gray-300 dark:border-gray-700',
label: 'text-gray-500 dark:text-gray-400 px-2 py-1.5',
wrapper: 'bg-[var(--ui-bg-elevated)]/50 rounded-l-[var(--ui-radius)] flex border-r border-[var(--ui-border-accented)]',
label: 'text-[var(--ui-text-muted)] px-2 py-1.5',
container: 'mt-0'
}"
>
@@ -231,9 +237,9 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
:model-value="getComponentProp(option.name)"
:items="option.items"
value-key="value"
color="gray"
color="neutral"
variant="soft"
class="rounded rounded-l-none min-w-12"
class="rounded-[var(--ui-radius)] rounded-l-none min-w-12"
:search-input="false"
:class="[option.name.toLowerCase().endsWith('color') && 'pl-6']"
:ui="{ itemLeadingChip: 'size-2' }"
@@ -254,21 +260,21 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
v-else
:type="option.type?.includes('number') ? 'number' : 'text'"
:model-value="getComponentProp(option.name)"
color="gray"
color="neutral"
variant="soft"
:ui="{ base: 'rounded rounded-l-none min-w-12' }"
:ui="{ base: 'rounded-[var(--ui-radius)] rounded-l-none min-w-12' }"
@update:model-value="setComponentProp(option.name, $event)"
/>
</UFormField>
</template>
</div>
<div class="flex justify-center border border-b-0 border-gray-200 dark:border-gray-700 relative p-4 z-[1]" :class="[!options.length && 'rounded-t-md', props.class]">
<component :is="name" v-bind="{ ...componentProps, ...componentEvents }">
<div v-if="component" class="flex justify-center border border-b-0 border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)] relative p-4 z-[1]" :class="[!options.length && 'rounded-t-[calc(var(--ui-radius)*1.5)]', props.class]">
<component :is="component" v-bind="{ ...componentProps, ...componentEvents }">
<template v-for="slot in Object.keys(slots || {})" :key="slot" #[slot]>
<ContentSlot :name="slot" unwrap="p">
<MDCSlot :name="slot" unwrap="p">
{{ slots?.[slot] }}
</ContentSlot>
</MDCSlot>
</template>
</component>
</div>

View File

@@ -24,9 +24,9 @@ const meta = await fetchComponentMeta(name as any)
<ProseTbody>
<ProseTr v-for="event in (meta?.meta?.events || [])" :key="event.name">
<ProseTd>
<ProseCodeInline>
<ProseCode>
{{ event.name }}
</ProseCodeInline>
</ProseCode>
</ProseTd>
<ProseTd>
<HighlightInlineType v-if="event.type" :type="event.type" />

View File

@@ -22,13 +22,11 @@ const props = withDefaults(defineProps<{
* @defaultValue true
*/
preview?: boolean
/**
* Whether to show the source code
* @defaultValue true
*/
source?: boolean
/**
* A list of variable props to link to the component.
*/
@@ -40,6 +38,10 @@ const props = withDefaults(defineProps<{
default: any
multiple?: boolean
}>
/**
* A list of line numbers to highlight in the code block
*/
highlights?: number[]
}>(), {
preview: true,
source: true
@@ -65,7 +67,7 @@ const code = computed(() => {
`
}
code += `\`\`\`vue${props.preview ? '' : ` [${data.pascalName}.vue]`}
code += `\`\`\`vue ${props.preview ? '' : ` [${data.pascalName}.vue]`}${props.highlights?.length ? `{${props.highlights.join('-')}}` : ''}
${data?.code ?? ''}
\`\`\``
@@ -87,7 +89,8 @@ const { data: ast } = await useAsyncData(`component-example-${camelName}`, async
formatted = await $prettier.format(code.value, {
trailingComma: 'none',
semi: false,
singleQuote: true
singleQuote: true,
printWidth: 100
})
} catch {
formatted = code.value
@@ -113,9 +116,9 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
<template>
<div class="my-5">
<div v-if="preview">
<div class="border border-gray-200 dark:border-gray-700 relative z-[1]" :class="[{ 'border-b-0 rounded-t-md': props.source, 'rounded-md': !props.source }]">
<div v-if="props.options?.length || !!slots.options" class="flex gap-4 p-4 border-b border-gray-200 dark:border-gray-700">
<template v-if="preview">
<div class="border border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)] relative z-[1]" :class="[{ 'border-b-0 rounded-t-[calc(var(--ui-radius)*1.5)]': props.source, 'rounded-[calc(var(--ui-radius)*1.5)]': !props.source }]">
<div v-if="props.options?.length || !!slots.options" class="flex gap-4 p-4 border-b border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)]">
<slot name="options" />
<UFormField
@@ -124,10 +127,10 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
:label="option.label"
:name="option.name"
size="sm"
class="inline-flex ring ring-gray-300 dark:ring-gray-700 rounded"
class="inline-flex ring ring-[var(--ui-border-accented)] rounded-[var(--ui-radius)]"
:ui="{
wrapper: 'bg-gray-50 dark:bg-gray-800/50 rounded-l flex border-r border-gray-300 dark:border-gray-700',
label: 'text-gray-500 dark:text-gray-400 px-2 py-1.5',
wrapper: 'bg-[var(--ui-bg-elevated)]/50 rounded-l-[var(--ui-radius)] flex border-r border-[var(--ui-border-accented)]',
label: 'text-[var(--ui-text-muted)] px-2 py-1.5',
container: 'mt-0'
}"
>
@@ -137,9 +140,9 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
:items="option.items"
:search-input="false"
:value-key="option.name.toLowerCase().endsWith('color') ? 'value' : undefined"
color="gray"
color="neutral"
variant="soft"
class="rounded rounded-l-none min-w-12"
class="rounded-[var(--ui-radius)] rounded-l-none min-w-12"
:multiple="option.multiple"
:class="[option.name.toLowerCase().endsWith('color') && 'pl-6']"
:ui="{ itemLeadingChip: 'size-2' }"
@@ -158,9 +161,9 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
<UInput
v-else
:model-value="get(optionsValues, option.name)"
color="gray"
color="neutral"
variant="soft"
:ui="{ base: 'rounded rounded-l-none min-w-12' }"
:ui="{ base: 'rounded-[var(--ui-radius)] rounded-l-none min-w-12' }"
@update:model-value="set(optionsValues, option.name, $event)"
/>
</UFormField>
@@ -170,7 +173,7 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
<component :is="camelName" v-bind="{ ...componentProps, ...optionsValues }" />
</div>
</div>
</div>
</template>
<MDCRenderer v-if="ast && props.source" :body="ast.body" :data="ast.data" class="[&_pre]:!rounded-t-none [&_div.my-5]:!mt-0" />
</div>

View File

@@ -3,9 +3,29 @@ import { upperFirst, camelCase } from 'scule'
import type { ComponentMeta } from 'vue-component-meta'
import * as theme from '#build/ui'
const props = defineProps<{
const props = withDefaults(defineProps<{
ignore?: string[]
}>()
}>(), {
ignore: () => [
'activeClass',
'inactiveClass',
'exactActiveClass',
'ariaCurrentValue',
'href',
'rel',
'noRel',
'prefetch',
'prefetchOn',
'noPrefetch',
'prefetchedClass',
'replace',
'exact',
'exactQuery',
'exactHash',
'external',
'onClick'
]
})
const route = useRoute()
@@ -67,9 +87,9 @@ const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
<ProseTbody>
<ProseTr v-for="prop in metaProps" :key="prop.name">
<ProseTd>
<ProseCodeInline>
<ProseCode>
{{ prop.name }}
</ProseCodeInline>
</ProseCode>
</ProseTd>
<ProseTd>
<HighlightInlineType v-if="prop.default" :type="prop.default" />
@@ -77,8 +97,9 @@ const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
<ProseTd>
<HighlightInlineType v-if="prop.type" :type="prop.type" />
<MDC v-if="prop.description" :value="prop.description" class="text-gray-600 dark:text-gray-300 mt-1" />
<MDC v-if="prop.description" :value="prop.description" class="text-[var(--ui-text-toned)] mt-1" />
<ComponentPropsLinks v-if="prop.tags?.length" :prop="prop" />
<ComponentPropsSchema v-if="prop.schema" :prop="prop" :ignore="ignore" />
</ProseTd>
</ProseTr>

View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
import type { PropertyMeta } from 'vue-component-meta'
const props = defineProps<{
prop: PropertyMeta
}>()
const links = computed(() => props.prop.tags?.filter((tag: any) => tag.name === 'link'))
</script>
<template>
<ProseUl v-if="links?.length">
<ProseLi v-for="link in links" :key="link.name">
<MDC :value="link.text ?? ''" class="my-1" />
</ProseLi>
</ProseUl>
</template>

View File

@@ -40,7 +40,7 @@ const schemaProps = computed(() => {
<ProseLi v-for="schemaProp in schemaProps" :key="schemaProp.name">
<HighlightInlineType :type="`${schemaProp.name}${schemaProp.required === false ? '?' : ''}: ${schemaProp.type}`" />
<MDC v-if="schemaProp.description" :value="schemaProp.description" class="text-gray-500 dark:text-gray-400 my-1" />
<MDC v-if="schemaProp.description" :value="schemaProp.description" class="text-[var(--ui-text-muted)] my-1" />
</ProseLi>
</ProseUl>
</Collapsible>

View File

@@ -24,14 +24,14 @@ const meta = await fetchComponentMeta(name as any)
<ProseTbody>
<ProseTr v-for="slot in (meta?.meta?.slots || [])" :key="slot.name">
<ProseTd>
<ProseCodeInline>
<ProseCode>
{{ slot.name }}
</ProseCodeInline>
</ProseCode>
</ProseTd>
<ProseTd>
<HighlightInlineType v-if="slot.type" :type="slot.type" />
<MDC v-if="slot.description" :value="slot.description" class="text-gray-600 dark:text-gray-300 mt-1" />
<MDC v-if="slot.description" :value="slot.description" class="text-[var(--ui-text-toned)] mt-1" />
</ProseTd>
</ProseTr>
</ProseTbody>

View File

@@ -13,7 +13,7 @@ function stripCompoundVariants(component?: any) {
if (component?.compoundVariants) {
component.compoundVariants = component.compoundVariants.filter((compoundVariant: any) => {
if (compoundVariant.color) {
if (!['primary', 'gray'].includes(compoundVariant.color)) {
if (!['primary', 'neutral'].includes(compoundVariant.color)) {
strippedCompoundVariants.value = true
return false
@@ -21,7 +21,15 @@ function stripCompoundVariants(component?: any) {
}
if (compoundVariant.highlightColor) {
if (!['primary', 'gray'].includes(compoundVariant.highlightColor)) {
if (!['primary', 'neutral'].includes(compoundVariant.highlightColor)) {
strippedCompoundVariants.value = true
return false
}
}
if (compoundVariant.loadingColor) {
if (!['primary', 'neutral'].includes(compoundVariant.loadingColor)) {
strippedCompoundVariants.value = true
return false
@@ -53,11 +61,11 @@ export default defineAppConfig(${json5.stringify(component.value, null, 2).repla
::
${strippedCompoundVariants.value
? `
? `
::callout{icon="i-simple-icons-github" to="https://github.com/nuxt/ui/blob/v3/src/theme/${name}.ts"}
Some colors in \`compoundVariants\` are omitted for readability. Check out the source code on GitHub.
::`
: ''}
: ''}
`
return parseMarkdown(md)

View File

@@ -6,10 +6,10 @@ const { data: ast } = await useAsyncData(`icons-theme`, async () => {
const md = `
\`\`\`ts [app.config.ts]
export default defineAppConfig(${json5.stringify({
ui: {
icons
}
}, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
ui: {
icons
}
}, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
\`\`\`\
`

View File

@@ -1,6 +1,6 @@
<template>
<div class="relative overflow-hidden rounded border border-dashed border-gray-400 dark:border-gray-500 opacity-75 px-4 flex items-center justify-center">
<svg class="absolute inset-0 h-full w-full stroke-gray-900/10 dark:stroke-white/10" fill="none">
<div class="relative overflow-hidden rounded-[var(--ui-radius)] border border-dashed border-[var(--ui-border-accented)] opacity-75 px-4 flex items-center justify-center">
<svg class="absolute inset-0 h-full w-full stroke-[var(--ui-border-inverted)]/10" fill="none">
<defs>
<pattern
id="pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e"

View File

@@ -0,0 +1,34 @@
<script setup lang="ts">
import * as locales from '@nuxt/ui/locale'
const props = withDefaults(defineProps<{
default?: string
}>(), {
default: 'en'
})
const getLocaleKeys = () => Object.keys(locales) as Array<keyof typeof locales>
const localesList = getLocaleKeys().map(locale => [locale, locales[locale].name])
</script>
<!-- eslint-disable vue/singleline-html-element-content-newline -->
<template>
<div>
<ProseUl>
<ProseLi v-for="[key, label] in localesList" :key="key">
<ProseCode>{{ key }}</ProseCode> - {{ label }}
<template v-if="key === props.default">
(default)
</template>
</ProseLi>
</ProseUl>
<Note to="https://github.com/nuxt/ui/tree/v3/src/runtime/locale" target="_blank">
If you need additional languages, you can contribute by creating a PR to add a new locale in <ProseCode>src/runtime/locale/</ProseCode>.
</Note>
<Tip>
You can use the <ProseCode>nuxt-ui</ProseCode> CLI to create a new locale:
<ProsePre language="bash">nuxt-ui make locale --code "en" --name "English"</ProsePre>
</Tip>
</div>
</template>

View File

@@ -2,15 +2,15 @@
const items = [
{
label: 'Icons',
icon: 'i-heroicons-face-smile'
icon: 'i-lucide-smile'
},
{
label: 'Colors',
icon: 'i-heroicons-swatch'
icon: 'i-lucide-swatch-book'
},
{
label: 'Components',
icon: 'i-heroicons-cube-transparent'
icon: 'i-lucide-box'
}
]
</script>

View File

@@ -2,15 +2,15 @@
const items = [
{
label: 'Icons',
icon: 'i-heroicons-face-smile'
icon: 'i-lucide-smile'
},
{
label: 'Colors',
icon: 'i-heroicons-swatch'
icon: 'i-lucide-swatch-book'
},
{
label: 'Components',
icon: 'i-heroicons-cube-transparent'
icon: 'i-lucide-box'
}
]
</script>
@@ -18,7 +18,7 @@ const items = [
<template>
<UAccordion :items="items">
<template #content="{ item }">
<p class="pb-3.5 text-sm text-gray-500 dark:text-gray-400">
<p class="pb-3.5 text-sm text-[var(--ui-text-muted)]">
This is the {{ item.label }} panel.
</p>
</template>

View File

@@ -2,18 +2,18 @@
const items = [
{
label: 'Icons',
icon: 'i-heroicons-face-smile',
icon: 'i-lucide-smile',
content: 'You have nothing to do, @nuxt/icon will handle it automatically.'
},
{
label: 'Colors',
icon: 'i-heroicons-swatch',
icon: 'i-lucide-swatch-book',
slot: 'colors',
content: 'Choose a primary and a gray color from your Tailwind CSS theme.'
content: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
},
{
label: 'Components',
icon: 'i-heroicons-cube-transparent',
icon: 'i-lucide-box',
content: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
}
]
@@ -22,7 +22,7 @@ const items = [
<template>
<UAccordion :items="items">
<template #colors="{ item }">
<p class="text-sm pb-3.5 text-primary-500 dark:text-primary-400">
<p class="text-sm pb-3.5 text-[var(--ui-primary)]">
{{ item.content }}
</p>
</template>

View File

@@ -2,17 +2,17 @@
const items = [
{
label: 'Icons',
icon: 'i-heroicons-face-smile',
icon: 'i-lucide-smile',
content: 'You have nothing to do, @nuxt/icon will handle it automatically.'
},
{
label: 'Colors',
icon: 'i-heroicons-swatch',
content: 'Choose a primary and a gray color from your Tailwind CSS theme.'
icon: 'i-lucide-swatch-book',
content: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
},
{
label: 'Components',
icon: 'i-heroicons-cube-transparent',
icon: 'i-lucide-box',
content: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
}
]

View File

@@ -1,22 +1,22 @@
<template>
<UAvatarGroup>
<UChip inset color="green">
<UChip inset color="success">
<UAvatar
src="https://avatars.githubusercontent.com/u/739984?v=4"
src="https://github.com/benjamincanac.png"
alt="Benjamin Canac"
/>
</UChip>
<UChip inset color="amber">
<UChip inset color="warning">
<UAvatar
src="https://avatars.githubusercontent.com/u/25613751?v=4"
src="https://github.com/romhml.png"
alt="Romain Hamel"
/>
</UChip>
<UChip inset color="red">
<UChip inset color="error">
<UAvatar
src="https://avatars.githubusercontent.com/u/19751938?v=4"
src="https://github.com/noook.png"
alt="Neil Richter"
/>
</UChip>

View File

@@ -3,11 +3,11 @@
<ULink
to="https://github.com/benjamincanac"
target="_blank"
class="hover:ring-primary-500 dark:hover:ring-primary-400 transition"
class="hover:ring-[var(--ui-primary)] transition"
raw
>
<UAvatar
src="https://avatars.githubusercontent.com/u/739984?v=4"
src="https://github.com/benjamincanac.png"
alt="Benjamin Canac"
/>
</ULink>
@@ -15,11 +15,11 @@
<ULink
to="https://github.com/romhml"
target="_blank"
class="hover:ring-primary-500 dark:hover:ring-primary-400 transition"
class="hover:ring-[var(--ui-primary)] transition"
raw
>
<UAvatar
src="https://avatars.githubusercontent.com/u/25613751?v=4"
src="https://github.com/romhml.png"
alt="Romain Hamel"
/>
</ULink>
@@ -27,11 +27,11 @@
<ULink
to="https://github.com/noook"
target="_blank"
class="hover:ring-primary-500 dark:hover:ring-primary-400 transition"
class="hover:ring-[var(--ui-primary)] transition"
raw
>
<UAvatar
src="https://avatars.githubusercontent.com/u/19751938?v=4"
src="https://github.com/noook.png"
alt="Neil Richter"
/>
</ULink>

View File

@@ -2,21 +2,21 @@
<UAvatarGroup>
<UTooltip text="benjamincanac">
<UAvatar
src="https://avatars.githubusercontent.com/u/739984?v=4"
src="https://github.com/benjamincanac.png"
alt="Benjamin Canac"
/>
</UTooltip>
<UTooltip text="romhml">
<UAvatar
src="https://avatars.githubusercontent.com/u/25613751?v=4"
src="https://github.com/romhml.png"
alt="Romain Hamel"
/>
</UTooltip>
<UTooltip text="noook">
<UAvatar
src="https://avatars.githubusercontent.com/u/19751938?v=4"
src="https://github.com/noook.png"
alt="Neil Richter"
/>
</UTooltip>

View File

@@ -1,7 +1,7 @@
<template>
<UChip inset>
<UAvatar
src="https://avatars.githubusercontent.com/u/739984?v=4"
src="https://github.com/benjamincanac.png"
alt="Benjamin Canac"
/>
</UChip>

View File

@@ -1,7 +1,7 @@
<template>
<UTooltip text="Benjamin Canac">
<UAvatar
src="https://avatars.githubusercontent.com/u/739984?v=4"
src="https://github.com/benjamincanac.png"
alt="Benjamin Canac"
/>
</UTooltip>

View File

@@ -4,7 +4,7 @@ const items = [{
to: '/'
}, {
slot: 'dropdown',
icon: 'i-heroicons-ellipsis-horizontal',
icon: 'i-lucide-ellipsis',
children: [{
label: 'Documentation'
}, {
@@ -25,7 +25,7 @@ const items = [{
<UBreadcrumb :items="items">
<template #dropdown="{ item }">
<UDropdownMenu :items="item.children">
<UButton :icon="item.icon" color="gray" variant="link" class="p-0.5" />
<UButton :icon="item.icon" color="neutral" variant="link" class="p-0.5" />
</UDropdownMenu>
</template>
</UBreadcrumb>

View File

@@ -14,7 +14,7 @@ const items = [{
<template>
<UBreadcrumb :items="items">
<template #separator>
<span class="mx-2 text-gray-500 dark:text-gray-400">/</span>
<span class="mx-2 text-[var(--ui-text-muted)]">/</span>
</template>
</UBreadcrumb>
</template>

View File

@@ -1,32 +1,32 @@
<script setup lang="ts">
const items = [{
label: 'Team',
icon: 'i-heroicons-users'
icon: 'i-lucide-users'
}, {
label: 'Invite users',
icon: 'i-heroicons-user-plus',
icon: 'i-lucide-user-plus',
children: [{
label: 'Invite by email',
icon: 'i-heroicons-paper-airplane'
icon: 'i-lucide-send-horizontal'
}, {
label: 'Invite by link',
icon: 'i-heroicons-link'
icon: 'i-lucide-link'
}]
}, {
label: 'New team',
icon: 'i-heroicons-plus'
icon: 'i-lucide-plus'
}]
</script>
<template>
<UButtonGroup>
<UButton color="gray" variant="subtle" label="Settings" />
<UButton color="neutral" variant="subtle" label="Settings" />
<UDropdownMenu :items="items">
<UButton
color="gray"
color="neutral"
variant="outline"
icon="i-heroicons-chevron-down-20-solid"
icon="i-lucide-chevron-down"
/>
</UDropdownMenu>
</UButtonGroup>

View File

@@ -1,12 +1,12 @@
<template>
<UButtonGroup>
<UInput color="gray" variant="outline" placeholder="Enter token" />
<UInput color="neutral" variant="outline" placeholder="Enter token" />
<UTooltip text="Copy to clipboard">
<UButton
color="gray"
color="neutral"
variant="subtle"
icon="i-heroicons-clipboard-document"
icon="i-lucide-clipboard"
/>
</UTooltip>
</UButtonGroup>

View File

@@ -0,0 +1,16 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel v-slot="{ item }" arrows :items="items" class="w-full max-w-xs mx-auto">
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,29 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/320?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/320?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/320?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
auto-height
arrows
dots
:items="items"
:ui="{
container: 'transition-[height]',
controls: 'absolute -top-8 inset-x-12',
dots: '-top-7',
dot: 'w-6 h-1'
}"
class="w-full max-w-xs mx-auto"
>
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,24 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/468/468?random=1',
'https://picsum.photos/468/468?random=2',
'https://picsum.photos/468/468?random=3',
'https://picsum.photos/468/468?random=4',
'https://picsum.photos/468/468?random=5',
'https://picsum.photos/468/468?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
loop
dots
arrows
auto-scroll
:items="items"
:ui="{ item: 'basis-1/3' }"
>
<img :src="item" width="234" height="234" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,24 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/468/468?random=1',
'https://picsum.photos/468/468?random=2',
'https://picsum.photos/468/468?random=3',
'https://picsum.photos/468/468?random=4',
'https://picsum.photos/468/468?random=5',
'https://picsum.photos/468/468?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
loop
arrows
dots
:autoplay="{ delay: 2000 }"
:items="items"
:ui="{ item: 'basis-1/3' }"
>
<img :src="item" width="234" height="234" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,25 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/528/528?random=1',
'https://picsum.photos/528/528?random=2',
'https://picsum.photos/528/528?random=3',
'https://picsum.photos/528/528?random=4',
'https://picsum.photos/528/528?random=5',
'https://picsum.photos/528/528?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
class-names
arrows
:items="items"
:ui="{
item: 'basis-[70%] transition-opacity [&:not(.is-snapped)]:opacity-10'
}"
class="mx-auto max-w-sm"
>
<img :src="item" width="264" height="264" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,16 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel v-slot="{ item }" dots :items="items" class="w-full max-w-xs mx-auto">
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,16 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel v-slot="{ item }" dots :items="items" :ui="{ item: 'basis-1/3' }">
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,23 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
fade
arrows
dots
:items="items"
class="w-full max-w-xs mx-auto"
>
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,16 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel v-slot="{ item }" :items="items" class="w-full max-w-xs mx-auto">
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,16 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/468/468?random=1',
'https://picsum.photos/468/468?random=2',
'https://picsum.photos/468/468?random=3',
'https://picsum.photos/468/468?random=4',
'https://picsum.photos/468/468?random=5',
'https://picsum.photos/468/468?random=6'
]
</script>
<template>
<UCarousel v-slot="{ item }" :items="items" :ui="{ item: 'basis-1/3' }">
<img :src="item" width="234" height="234" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,22 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
orientation="vertical"
:items="items"
class="w-full max-w-xs mx-auto"
:ui="{ container: 'h-[336px]' }"
>
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,23 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
arrows
:prev="{ color: 'primary' }"
:next="{ variant: 'solid' }"
:items="items"
class="w-full max-w-xs mx-auto"
>
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,28 @@
<script setup lang="ts">
defineProps<{
prevIcon?: string
nextIcon?: string
}>()
const items = [
'https://picsum.photos/640/640?random=1',
'https://picsum.photos/640/640?random=2',
'https://picsum.photos/640/640?random=3',
'https://picsum.photos/640/640?random=4',
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
arrows
:prev-icon="prevIcon"
:next-icon="nextIcon"
:items="items"
class="w-full max-w-xs mx-auto"
>
<img :src="item" width="320" height="320" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -0,0 +1,22 @@
<script setup lang="ts">
const items = [
'https://picsum.photos/468/468?random=1',
'https://picsum.photos/468/468?random=2',
'https://picsum.photos/468/468?random=3',
'https://picsum.photos/468/468?random=4',
'https://picsum.photos/468/468?random=5',
'https://picsum.photos/468/468?random=6'
]
</script>
<template>
<UCarousel
v-slot="{ item }"
loop
wheel-gestures
:items="items"
:ui="{ item: 'basis-1/3' }"
>
<img :src="item" width="234" height="234" class="rounded-lg">
</UCarousel>
</template>

View File

@@ -2,7 +2,7 @@
const statuses = ['online', 'away', 'busy', 'offline']
const status = ref(statuses[0])
const color = computed(() => status.value ? { online: 'green', away: 'amber', busy: 'red', offline: 'gray' }[status.value] as any : 'online')
const color = computed(() => status.value ? { online: 'success', away: 'warning', busy: 'error', offline: 'neutral' }[status.value] as any : 'online')
const show = computed(() => status.value !== 'offline')
@@ -18,6 +18,6 @@ onMounted(() => {
<template>
<UChip :color="color" :show="show" inset>
<UAvatar src="https://avatars.githubusercontent.com/u/739984?v=4" />
<UAvatar src="https://github.com/benjamincanac.png" />
</UChip>
</template>

View File

@@ -1,11 +1,11 @@
<template>
<UCollapsible class="w-48">
<UCollapsible class="flex flex-col gap-2 w-48">
<UButton
class="group"
label="Open"
color="gray"
color="neutral"
variant="subtle"
trailing-icon="i-heroicons-chevron-down-20-solid"
trailing-icon="i-lucide-chevron-down"
:ui="{
trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200'
}"

View File

@@ -7,12 +7,12 @@ defineShortcuts({
</script>
<template>
<UCollapsible v-model:open="open" class="w-48">
<UCollapsible v-model:open="open" class="flex flex-col gap-2 w-48">
<UButton
label="Open"
color="gray"
color="neutral"
variant="subtle"
trailing-icon="i-heroicons-chevron-down-20-solid"
trailing-icon="i-lucide-chevron-down"
block
/>

View File

@@ -1,40 +1,68 @@
<script setup lang="ts">
const groups = [{
id: 'settings',
items: [{
label: 'Profile',
icon: 'i-heroicons-user',
kbds: ['meta', 'P']
}, {
label: 'Billing',
icon: 'i-heroicons-credit-card',
kbds: ['meta', 'B'],
slot: 'billing'
}, {
label: 'Notifications',
icon: 'i-heroicons-bell'
}, {
label: 'Security',
icon: 'i-heroicons-lock-closed'
}]
items: [
{
label: 'Profile',
icon: 'i-lucide-user',
kbds: ['meta', 'P']
},
{
label: 'Billing',
icon: 'i-lucide-credit-card',
kbds: ['meta', 'B'],
slot: 'billing'
},
{
label: 'Notifications',
icon: 'i-lucide-bell'
},
{
label: 'Security',
icon: 'i-lucide-lock'
}
]
}, {
id: 'users',
label: 'Users',
slot: 'users',
items: [
{ id: 1, label: 'Durward Reynolds' },
{ id: 2, label: 'Kenton Towne' },
{ id: 3, label: 'Therese Wunsch' },
{ id: 4, label: 'Benedict Kessler' },
{ id: 5, label: 'Katelyn Rohan' }
{
label: 'Benjamin Canac',
suffix: 'benjamincanac'
},
{
label: 'Sylvain Marroufin',
suffix: 'smarroufin'
},
{
label: 'Sébastien Chopin',
suffix: 'atinux'
},
{
label: 'Romain Hamel',
suffix: 'romhml'
},
{
label: 'Haytham A. Salama',
suffix: 'Haythamasalama'
},
{
label: 'Daniel Roe',
suffix: 'danielroe'
},
{
label: 'Neil Richter',
suffix: 'noook'
}
]
}]
</script>
<template>
<UCommandPalette :groups="groups" class="flex-1 h-80">
<template #users-leading="{ index }">
<UAvatar :src="`https://i.pravatar.cc/120?img=${index}`" size="2xs" />
<template #users-leading="{ item }">
<UAvatar :src="`https://github.com/${item.suffix}.png`" size="2xs" />
</template>
<template #billing-label="{ item }">

View File

@@ -1,24 +0,0 @@
<script setup lang="ts">
const users = [
{ id: 1, label: 'Durward Reynolds' },
{ id: 2, label: 'Kenton Towne' },
{ id: 3, label: 'Therese Wunsch' },
{ id: 4, label: 'Benedict Kessler' },
{ id: 5, label: 'Katelyn Rohan' }
]
const selected = ref(users[0])
function onSelect(item: any) {
console.log(item)
}
</script>
<template>
<UCommandPalette
v-model="selected"
:groups="[{ id: 'users', items: users }]"
class="flex-1"
@update:model-value="onSelect"
/>
</template>

View File

@@ -1,25 +0,0 @@
<script setup lang="ts">
const users = [
{ id: 1, label: 'Durward Reynolds' },
{ id: 2, label: 'Kenton Towne' },
{ id: 3, label: 'Therese Wunsch' },
{ id: 4, label: 'Benedict Kessler' },
{ id: 5, label: 'Katelyn Rohan' }
]
const selected = ref([users[0], users[1]])
function onSelect(items: any) {
console.log(items)
}
</script>
<template>
<UCommandPalette
v-model="selected"
multiple
:groups="[{ id: 'users', items: users }]"
class="flex-1"
@update:model-value="onSelect"
/>
</template>

View File

@@ -2,11 +2,55 @@
const open = ref(false)
const users = [
{ id: 1, label: 'Durward Reynolds' },
{ id: 2, label: 'Kenton Towne' },
{ id: 3, label: 'Therese Wunsch' },
{ id: 4, label: 'Benedict Kessler' },
{ id: 5, label: 'Katelyn Rohan' }
{
label: 'Benjamin Canac',
suffix: 'benjamincanac',
avatar: {
src: 'https://github.com/benjamincanac.png'
}
},
{
label: 'Sylvain Marroufin',
suffix: 'smarroufin',
avatar: {
src: 'https://github.com/smarroufin.png'
}
},
{
label: 'Sébastien Chopin',
suffix: 'atinux',
avatar: {
src: 'https://github.com/atinux.png'
}
},
{
label: 'Romain Hamel',
suffix: 'romhml',
avatar: {
src: 'https://github.com/romhml.png'
}
},
{
label: 'Haytham A. Salama',
suffix: 'Haythamasalama',
avatar: {
src: 'https://github.com/Haythamasalama.png'
}
},
{
label: 'Daniel Roe',
suffix: 'danielroe',
avatar: {
src: 'https://github.com/danielroe.png'
}
},
{
label: 'Neil Richter',
suffix: 'noook',
avatar: {
src: 'https://github.com/noook.png'
}
}
]
</script>
@@ -14,17 +58,13 @@ const users = [
<UModal v-model:open="open">
<UButton
label="Search users..."
color="gray"
color="neutral"
variant="subtle"
icon="i-heroicons-magnifying-glass"
icon="i-lucide-search"
/>
<template #content>
<UCommandPalette
close
:groups="[{ id: 'users', items: users }]"
@update:open="open = $event"
/>
<UCommandPalette close :groups="[{ id: 'users', items: users }]" @update:open="open = $event" />
</template>
</UModal>
</template>

View File

@@ -1,29 +1,36 @@
<script setup lang="ts">
const items = [{
id: '/',
label: 'Introduction',
level: 1
}, {
id: '/getting-started#whats-new-in-v3',
label: 'What\'s new in v3?',
level: 2
}, {
id: '/getting-started#radix-vue-3',
label: 'Radix Vue',
level: 3
}, {
id: '/getting-started#tailwind-css-v4',
label: 'Tailwind CSS v4',
level: 3
}, {
id: '/getting-started#tailwind-variants',
label: 'Tailwind Variants',
level: 3
}, {
id: '/getting-started/installation',
label: 'Installation',
level: 1
}]
const items = [
{
id: '/',
label: 'Introduction',
level: 1
},
{
id: '/getting-started#whats-new-in-v3',
label: 'What\'s new in v3?',
level: 2
},
{
id: '/getting-started#radix-vue-3',
label: 'Radix Vue',
level: 3
},
{
id: '/getting-started#tailwind-css-v4',
label: 'Tailwind CSS v4',
level: 3
},
{
id: '/getting-started#tailwind-variants',
label: 'Tailwind Variants',
level: 3
},
{
id: '/getting-started/installation',
label: 'Installation',
level: 1
}
]
function postFilter(searchTerm: string, items: any[]) {
// Filter only first level items if no searchTerm

View File

@@ -1,13 +1,82 @@
<script setup lang="ts">
const users = [
{ id: 1, label: 'Durward Reynolds' },
{ id: 2, label: 'Kenton Towne' },
{ id: 3, label: 'Therese Wunsch' },
{ id: 4, label: 'Benedict Kessler' },
{ id: 5, label: 'Katelyn Rohan' }
{
label: 'Benjamin Canac',
suffix: 'benjamincanac',
to: 'https://github.com/benjamincanac',
target: '_blank',
avatar: {
src: 'https://github.com/benjamincanac.png',
alt: 'benjamincanac'
}
},
{
label: 'Sylvain Marroufin',
suffix: 'smarroufin',
to: 'https://github.com/smarroufin',
target: '_blank',
avatar: {
src: 'https://github.com/smarroufin.png',
alt: 'smarroufin'
}
},
{
label: 'Sébastien Chopin',
suffix: 'atinux',
to: 'https://github.com/atinux',
target: '_blank',
avatar: {
src: 'https://github.com/atinux.png',
alt: 'atinux'
}
},
{
label: 'Romain Hamel',
suffix: 'romhml',
to: 'https://github.com/romhml',
target: '_blank',
avatar: {
src: 'https://github.com/romhml.png',
alt: 'romhml'
}
},
{
label: 'Haytham A. Salama',
suffix: 'Haythamasalama',
to: 'https://github.com/Haythamasalama',
target: '_blank',
avatar: {
src: 'https://github.com/Haythamasalama.png',
alt: 'Haythamasalama'
}
},
{
label: 'Daniel Roe',
suffix: 'danielroe',
to: 'https://github.com/danielroe',
target: '_blank',
avatar: {
src: 'https://github.com/danielroe.png',
alt: 'danielroe'
}
},
{
label: 'Neil Richter',
suffix: 'noook',
to: 'https://github.com/noook',
target: '_blank',
avatar: {
src: 'https://github.com/noook.png',
alt: 'noook'
}
}
]
const searchTerm = ref('Th')
const searchTerm = ref('')
function onSelect() {
searchTerm.value = ''
}
</script>
<template>
@@ -15,5 +84,6 @@ const searchTerm = ref('Th')
v-model:search-term="searchTerm"
:groups="[{ id: 'users', items: users }]"
class="flex-1"
@update:model-value="onSelect"
/>
</template>

View File

@@ -0,0 +1,155 @@
<script setup lang="ts">
const router = useRouter()
const groups = ref([
{
id: 'users',
label: 'Users',
items: [
{
label: 'Benjamin Canac',
suffix: 'benjamincanac',
to: 'https://github.com/benjamincanac',
target: '_blank',
avatar: {
src: 'https://github.com/benjamincanac.png',
alt: 'benjamincanac'
}
},
{
label: 'Sylvain Marroufin',
suffix: 'smarroufin',
to: 'https://github.com/smarroufin',
target: '_blank',
avatar: {
src: 'https://github.com/smarroufin.png',
alt: 'smarroufin'
}
},
{
label: 'Sébastien Chopin',
suffix: 'atinux',
to: 'https://github.com/atinux',
target: '_blank',
avatar: {
src: 'https://github.com/atinux.png',
alt: 'atinux'
}
},
{
label: 'Romain Hamel',
suffix: 'romhml',
to: 'https://github.com/romhml',
target: '_blank',
avatar: {
src: 'https://github.com/romhml.png',
alt: 'romhml'
}
},
{
label: 'Haytham A. Salama',
suffix: 'Haythamasalama',
to: 'https://github.com/Haythamasalama',
target: '_blank',
avatar: {
src: 'https://github.com/Haythamasalama.png',
alt: 'Haythamasalama'
}
},
{
label: 'Daniel Roe',
suffix: 'danielroe',
to: 'https://github.com/danielroe',
target: '_blank',
avatar: {
src: 'https://github.com/danielroe.png',
alt: 'danielroe'
}
},
{
label: 'Neil Richter',
suffix: 'noook',
to: 'https://github.com/noook',
target: '_blank',
avatar: {
src: 'https://github.com/noook.png',
alt: 'noook'
}
}
]
},
{
id: 'actions',
items: [
{
label: 'Add new file',
suffix: 'Create a new file in the current directory or workspace.',
icon: 'i-lucide-file-plus',
kbds: [
'meta',
'N'
],
onSelect() {
console.log('Add new file')
}
},
{
label: 'Add new folder',
suffix: 'Create a new folder in the current directory or workspace.',
icon: 'i-lucide-folder-plus',
kbds: [
'meta',
'F'
],
onSelect() {
console.log('Add new folder')
}
},
{
label: 'Add hashtag',
suffix: 'Add a hashtag to the current item.',
icon: 'i-lucide-hash',
kbds: [
'meta',
'H'
],
onSelect() {
console.log('Add hashtag')
}
},
{
label: 'Add label',
suffix: 'Add a label to the current item.',
icon: 'i-lucide-tag',
kbds: [
'meta',
'L'
],
onSelect() {
console.log('Add label')
}
}
]
}
])
function onSelect(item: any) {
if (item.onSelect) {
item.onSelect()
} else if (item.to) {
if (typeof item.to === 'string' && (item.target === '_blank' || item.to.startsWith('http'))) {
window.open(item.to, item.target || '_blank')
} else {
router.push(item.to)
}
}
}
</script>
<template>
<UCommandPalette
:groups="groups"
class="flex-1 h-80"
@update:model-value="onSelect"
/>
</template>

View File

@@ -0,0 +1,40 @@
<script setup lang="ts">
const showSidebar = ref(true)
const showToolbar = ref(false)
const items = computed(() => [{
label: 'View',
type: 'label' as const
}, {
type: 'separator' as const
}, {
label: 'Show Sidebar',
type: 'checkbox' as const,
checked: showSidebar.value,
onUpdateChecked(checked: boolean) {
showSidebar.value = checked
},
onSelect(e: Event) {
e.preventDefault()
}
}, {
label: 'Show Toolbar',
type: 'checkbox' as const,
checked: showToolbar.value,
onUpdateChecked(checked: boolean) {
showToolbar.value = checked
}
}, {
label: 'Collapse Pinned Tabs',
type: 'checkbox' as const,
disabled: true
}])
</script>
<template>
<UContextMenu :items="items" class="w-48">
<div class="flex items-center justify-center rounded-md border border-dashed border-[var(--ui-border-accented)] text-sm aspect-video w-72">
Right click here
</div>
</UContextMenu>
</template>

View File

@@ -0,0 +1,33 @@
<script setup lang="ts">
const items = [
[
{
label: 'View',
icon: 'i-lucide-eye'
},
{
label: 'Copy',
icon: 'i-lucide-copy'
},
{
label: 'Edit',
icon: 'i-lucide-pencil'
}
],
[
{
label: 'Delete',
color: 'error' as const,
icon: 'i-lucide-trash'
}
]
]
</script>
<template>
<UContextMenu :items="items" class="w-48">
<div class="flex items-center justify-center rounded-md border border-dashed border-[var(--ui-border-accented)] text-sm aspect-video w-72">
Right click here
</div>
</UContextMenu>
</template>

View File

@@ -13,7 +13,7 @@ const items = [{
<template>
<UContextMenu :items="items" class="w-48">
<div class="flex items-center justify-center rounded-md border border-dashed border-gray-300 dark:border-gray-700 text-sm aspect-video w-72">
<div class="flex items-center justify-center rounded-md border border-dashed border-[var(--ui-border-accented)] text-sm aspect-video w-72">
Right click here
</div>
@@ -22,7 +22,7 @@ const items = [{
</template>
<template #refresh-trailing>
<UIcon v-if="loading" name="i-heroicons-arrow-path-20-solid" class="shrink-0 size-5 text-primary-500 dark:text-primary-400 animate-spin" />
<UIcon v-if="loading" name="i-lucide-refresh-ccw" class="shrink-0 size-5 text-[var(--ui-primary)] animate-spin" />
</template>
</UContextMenu>
</template>

View File

@@ -18,12 +18,12 @@ const groups = computed(() => [{
</script>
<template>
<UDrawer>
<UDrawer :handle="false">
<UButton
label="Search users..."
color="gray"
color="neutral"
variant="subtle"
icon="i-heroicons-magnifying-glass"
icon="i-lucide-search"
/>
<template #content>
@@ -32,7 +32,7 @@ const groups = computed(() => [{
:loading="status === 'pending'"
:groups="groups"
placeholder="Search users..."
class="h-96 border-t border-gray-200 dark:border-gray-800"
class="h-80"
/>
</template>
</UDrawer>

Some files were not shown because too many files have changed in this diff Show More