mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-15 12:39:35 +01:00
Compare commits
171 Commits
v3.0.0-alp
...
v3.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21d8c352a9 | ||
|
|
5deadc7096 | ||
|
|
fa9f0a7e2a | ||
|
|
143c015bbd | ||
|
|
d75f47419d | ||
|
|
7b148daf1f | ||
|
|
30e0c7fddd | ||
|
|
14fb21be00 | ||
|
|
25091bad48 | ||
|
|
b75ed29068 | ||
|
|
b2fa65734b | ||
|
|
d3a079a644 | ||
|
|
8c6a8c283f | ||
|
|
2fc36c878c | ||
|
|
992be91823 | ||
|
|
bd2f077fe8 | ||
|
|
7329900ae5 | ||
|
|
8d85498ee1 | ||
|
|
5c292cf620 | ||
|
|
c0837059a9 | ||
|
|
f5ea2411dc | ||
|
|
1fbbfe8df0 | ||
|
|
0daac5bafb | ||
|
|
756f791a1a | ||
|
|
8ed434c105 | ||
|
|
190a2c9799 | ||
|
|
e55c0e2594 | ||
|
|
4312ca4702 | ||
|
|
2289742656 | ||
|
|
601f4b2cd2 | ||
|
|
cd080541a0 | ||
|
|
5722e0802d | ||
|
|
8d0026558a | ||
|
|
e5119a9ca4 | ||
|
|
976dd2a386 | ||
|
|
1d95eb7246 | ||
|
|
7cc26d098d | ||
|
|
9241ba1230 | ||
|
|
3396d5cebe | ||
|
|
937585cb3f | ||
|
|
9c00f7c7b7 | ||
|
|
73e25ed235 | ||
|
|
75c5e87724 | ||
|
|
95aa6f68b3 | ||
|
|
f516d7b36d | ||
|
|
300ccc4885 | ||
|
|
e48b416e3b | ||
|
|
17170bb998 | ||
|
|
fa5a3752c9 | ||
|
|
fc9711223b | ||
|
|
8a8b1ee2e1 | ||
|
|
30218f1b5b | ||
|
|
3584a3328b | ||
|
|
6d3dbdbee5 | ||
|
|
c614a0aafc | ||
|
|
df7a61a97a | ||
|
|
143612ec73 | ||
|
|
18931acdb3 | ||
|
|
bbc6bf2455 | ||
|
|
ff1e0798d3 | ||
|
|
b0be26d67f | ||
|
|
36ea3e4045 | ||
|
|
4889d30b44 | ||
|
|
944a7e0f07 | ||
|
|
d6943e39c0 | ||
|
|
ddb46905e7 | ||
|
|
0e74dbebce | ||
|
|
9e2cc5b125 | ||
|
|
ea97759c2c | ||
|
|
95a0bbc581 | ||
|
|
ecd63ad8d6 | ||
|
|
47f58f52ef | ||
|
|
446f9c1085 | ||
|
|
7e8a1dd496 | ||
|
|
89ee31b7ae | ||
|
|
95be76940c | ||
|
|
761afaf40d | ||
|
|
d167c9b807 | ||
|
|
824ba56291 | ||
|
|
4fbbb25f68 | ||
|
|
602a667343 | ||
|
|
febda5c2b6 | ||
|
|
20379f51cc | ||
|
|
1ec56f3326 | ||
|
|
1f44d58b64 | ||
|
|
5392f988b8 | ||
|
|
26362408b1 | ||
|
|
1e7638bd03 | ||
|
|
afe40033b0 | ||
|
|
503f701c7e | ||
|
|
d9822db6e8 | ||
|
|
0ceafe1d54 | ||
|
|
f943f88fcc | ||
|
|
e831813aa3 | ||
|
|
37a359701f | ||
|
|
557e0c92a4 | ||
|
|
7f6db45f1e | ||
|
|
a64a7104c5 | ||
|
|
40fc8f3718 | ||
|
|
8059d540e3 | ||
|
|
42fce998e4 | ||
|
|
70fcc68ee2 | ||
|
|
230cda129b | ||
|
|
1c01db4d20 | ||
|
|
c9adf333be | ||
|
|
ffb551ab54 | ||
|
|
f1a14dd87c | ||
|
|
0454124b3c | ||
|
|
0bfe2b60b3 | ||
|
|
5ec756d263 | ||
|
|
d6a434469d | ||
|
|
ebbd605ff3 | ||
|
|
860e6ed801 | ||
|
|
12ae20df20 | ||
|
|
64ad4b6892 | ||
|
|
3c443c631c | ||
|
|
104b926c2e | ||
|
|
60c574cd01 | ||
|
|
f821e6681b | ||
|
|
a6c1a6c587 | ||
|
|
e3092b6b40 | ||
|
|
5f99f284ec | ||
|
|
701c75a2a8 | ||
|
|
7fc6b387b3 | ||
|
|
f66c96e277 | ||
|
|
2d52834529 | ||
|
|
a97c511279 | ||
|
|
50cc034796 | ||
|
|
9f87ea5729 | ||
|
|
eedf287654 | ||
|
|
28e35da59e | ||
|
|
41eac7ff82 | ||
|
|
7dd2fd05fc | ||
|
|
845f85a072 | ||
|
|
120eb920a8 | ||
|
|
1a93d13a16 | ||
|
|
5a9511fa04 | ||
|
|
332c6c08d7 | ||
|
|
f26f6c8168 | ||
|
|
c85ba43040 | ||
|
|
50918a8128 | ||
|
|
8669553ea4 | ||
|
|
b416a194df | ||
|
|
d73c4ddd41 | ||
|
|
7289eb21e2 | ||
|
|
b5ca0d96f1 | ||
|
|
d980115408 | ||
|
|
ef561e7cba | ||
|
|
45171e206e | ||
|
|
ce427f7543 | ||
|
|
309e52faa7 | ||
|
|
fc2015bb0e | ||
|
|
03dd1eba7e | ||
|
|
77d18d8ab7 | ||
|
|
94c49186e1 | ||
|
|
e82a82d812 | ||
|
|
db8111d783 | ||
|
|
1402436c2b | ||
|
|
75410fba97 | ||
|
|
0a17663d13 | ||
|
|
e592da2fcb | ||
|
|
2514abeb5b | ||
|
|
d4a943e631 | ||
|
|
50c6bf0092 | ||
|
|
9cdde9edb2 | ||
|
|
3f48fdae8d | ||
|
|
058c49add2 | ||
|
|
5d4a8ff713 | ||
|
|
2af0346654 | ||
|
|
f55194e6f0 | ||
|
|
eb47a7099d |
15
.github/ISSUE_TEMPLATE/bug-v3.yml
vendored
15
.github/ISSUE_TEMPLATE/bug-v3.yml
vendored
@@ -5,8 +5,8 @@ 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.
|
||||
> [!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: |
|
||||
@@ -29,11 +29,20 @@ body:
|
||||
- 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.5
|
||||
placeholder: v3.0.0-alpha.x
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -12,7 +12,7 @@ body:
|
||||
label: For what version of Nuxt UI are you suggesting this?
|
||||
options:
|
||||
- v2.x
|
||||
- v3-alpha
|
||||
- v3.0.0-alpha.x
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/question.yml
vendored
2
.github/ISSUE_TEMPLATE/question.yml
vendored
@@ -12,7 +12,7 @@ body:
|
||||
label: For what version of Nuxt UI are you asking this question?
|
||||
options:
|
||||
- v2.x
|
||||
- v3-alpha
|
||||
- v3.0.0-alpha.x
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
||||
13
.github/workflows/ci-v3.yml
vendored
13
.github/workflows/ci-v3.yml
vendored
@@ -43,21 +43,26 @@ jobs:
|
||||
- name: Prepare
|
||||
run: pnpm run dev:prepare
|
||||
|
||||
- name: Devtools prepare
|
||||
run: pnpm run devtools:prepare
|
||||
|
||||
- name: Lint
|
||||
run: pnpm run lint
|
||||
|
||||
- name: Typecheck
|
||||
run: pnpm run typecheck
|
||||
|
||||
- name: Docs typecheck
|
||||
run: pnpm run docs:typecheck
|
||||
continue-on-error: true
|
||||
|
||||
- name: Test
|
||||
run: pnpm run test
|
||||
|
||||
- name: Test (vue)
|
||||
run: pnpm run test:vue
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Build vue fixture
|
||||
run: pnpm run test:vue:build
|
||||
|
||||
- name: Publish
|
||||
run: pnpx pkg-pr-new publish --compact --no-template --pnpm
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -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
|
||||
|
||||
102
CHANGELOG.md
102
CHANGELOG.md
@@ -1,5 +1,107 @@
|
||||
# Changelog
|
||||
|
||||
## [3.0.0-alpha.9](https://github.com/nuxt/ui/compare/v3.0.0-alpha.8...v3.0.0-alpha.9) (2024-11-19)
|
||||
|
||||
### Features
|
||||
|
||||
* **cli:** add locale command ([#2586](https://github.com/nuxt/ui/issues/2586)) ([824ba56](https://github.com/nuxt/ui/commit/824ba5629183bc4cd59321213558770db211f6e5))
|
||||
* **css:** add `--ui-bg-muted` / `--ui-border-muted` variables ([7f6db45](https://github.com/nuxt/ui/commit/7f6db45f1e15ef39cda9b732cb601c552f29570a))
|
||||
* **Form:** apply transformations ([#2550](https://github.com/nuxt/ui/issues/2550)) ([75c5e87](https://github.com/nuxt/ui/commit/75c5e87724e7abdf0a6751d7a1dbbafb947f373f))
|
||||
* **FormField:** add `error-pattern` prop ([#2601](https://github.com/nuxt/ui/issues/2601)) ([143612e](https://github.com/nuxt/ui/commit/143612ec737d1c7571398601c3222f2eed37996e))
|
||||
* **InputMenu/SelectMenu:** add `create-item` prop ([#2472](https://github.com/nuxt/ui/issues/2472)) ([f516d7b](https://github.com/nuxt/ui/commit/f516d7b36da51565f4ab05a4c9cfe5e5b4015124))
|
||||
* **InputNumber:** implement component ([#2577](https://github.com/nuxt/ui/issues/2577)) ([bd2f077](https://github.com/nuxt/ui/commit/bd2f077fe8e645d5fce8b1eb5a6eb1068b3e8f7c))
|
||||
* **Link:** allow partial query match for its active state ([#2664](https://github.com/nuxt/ui/issues/2664)) ([7329900](https://github.com/nuxt/ui/commit/7329900ae549430b88567a09cbb585d3cf0a6d32))
|
||||
* **locale:** add Persian language ([#2682](https://github.com/nuxt/ui/issues/2682)) ([14fb21b](https://github.com/nuxt/ui/commit/14fb21be0034ffc0ba5d213734c00f12e0d6bea8))
|
||||
* **locale:** add Polish language ([#2678](https://github.com/nuxt/ui/issues/2678)) ([2fc36c8](https://github.com/nuxt/ui/commit/2fc36c878c67967ec91e4f6999575bad45521d44))
|
||||
* **locale:** add support for Arabic ([#2582](https://github.com/nuxt/ui/issues/2582)) ([602a667](https://github.com/nuxt/ui/commit/602a667343be22b72383ab3cf42f36ec9e135082))
|
||||
* **locale:** add support for Czech translation ([#2593](https://github.com/nuxt/ui/issues/2593)) ([4889d30](https://github.com/nuxt/ui/commit/4889d30b448296de42e146dc5771738837c31f8c))
|
||||
* **locale:** add support for Italian ([#2583](https://github.com/nuxt/ui/issues/2583)) ([4fbbb25](https://github.com/nuxt/ui/commit/4fbbb25f68b0b5ee76e50f2da776a74d54acc041))
|
||||
* **locale:** provide `code` ([#2611](https://github.com/nuxt/ui/issues/2611)) ([8a8b1ee](https://github.com/nuxt/ui/commit/8a8b1ee2e1628bc5439ef109d3c68b69bf631f81))
|
||||
* **locale:** provide `dir` on `defineLocale` ([#2620](https://github.com/nuxt/ui/issues/2620)) ([937585c](https://github.com/nuxt/ui/commit/937585cb3f8bc902d60a4b5904711598204aee2d))
|
||||
* **locale:** translate chinese ([#2580](https://github.com/nuxt/ui/issues/2580)) ([febda5c](https://github.com/nuxt/ui/commit/febda5c2b67374d1358a66694543b77037d239c6))
|
||||
* **locale:** translate Spanish ([#2644](https://github.com/nuxt/ui/issues/2644)) ([8ed434c](https://github.com/nuxt/ui/commit/8ed434c105b75ae02aa7493a235cebb64d518d09))
|
||||
* **locale:** typing `dir` ([#2643](https://github.com/nuxt/ui/issues/2643)) ([e55c0e2](https://github.com/nuxt/ui/commit/e55c0e25947e7bcef931b26dafaad120f488a627))
|
||||
* **module:** support i18n in components ([#2553](https://github.com/nuxt/ui/issues/2553)) ([2636240](https://github.com/nuxt/ui/commit/26362408b161108487b889ff001bec9166059c79))
|
||||
* **NavigationMenu:** control items `open` & `defaultOpen` on vertical ([30218f1](https://github.com/nuxt/ui/commit/30218f1b5b0a56207fd4db224ffa0401ac194a04)), closes [#2608](https://github.com/nuxt/ui/issues/2608)
|
||||
* **PinInput:** implement component ([#2570](https://github.com/nuxt/ui/issues/2570)) ([95aa6f6](https://github.com/nuxt/ui/commit/95aa6f68b316d02c28d1124d9a826bca55cde81f))
|
||||
* **Popover:** add `prevent-close` prop ([ea97759](https://github.com/nuxt/ui/commit/ea97759c2c219bdf5c48b652b47d293ddf513a00)), closes [#2245](https://github.com/nuxt/ui/issues/2245)
|
||||
* **SelectMenu:** use `UInput` in search to handle props like icon ([ff1e079](https://github.com/nuxt/ui/commit/ff1e0798d384d40ad82a95fe5faa16acb080efe3)), closes [#2021](https://github.com/nuxt/ui/issues/2021)
|
||||
* **Table:** add `caption` prop ([446f9c1](https://github.com/nuxt/ui/commit/446f9c1085e96187afdc5c1d7ce3450f8df1a2e1))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **App:** missing `vue` imports ([ddb4690](https://github.com/nuxt/ui/commit/ddb46905e7e3480ab578bcd8a478f25dff60081a))
|
||||
* **App:** remove `dir` prop ([#2630](https://github.com/nuxt/ui/issues/2630)) ([7cc26d0](https://github.com/nuxt/ui/commit/7cc26d098dff70923bcd9d414d675018951b1967))
|
||||
* **Breadcrumb/Carousel/Pagination:** handle icons in RTL mode ([#2633](https://github.com/nuxt/ui/issues/2633)) ([e5119a9](https://github.com/nuxt/ui/commit/e5119a9ca4e217ef769904323c16bd8c0cbc02d9))
|
||||
* **Breadcrumb:** render as `nav` ([756f791](https://github.com/nuxt/ui/commit/756f791a1a8dd3a4a88c212b4e4f775584decb55)), closes [#2649](https://github.com/nuxt/ui/issues/2649)
|
||||
* **Button:** improve neutral solid variant hover ([8d85498](https://github.com/nuxt/ui/commit/8d85498ee197ec0b26cdd7c4b08f84fec45ddd8f))
|
||||
* **Carousel:** use `dir` from locale ([#2647](https://github.com/nuxt/ui/issues/2647)) ([1fbbfe8](https://github.com/nuxt/ui/commit/1fbbfe8df06b3b8b294615ac328d582c5230aa8b))
|
||||
* **ContextMenu/DropdownMenu:** relative imports with prefix ([47f58f5](https://github.com/nuxt/ui/commit/47f58f52ef2d03176a184a3ca2154f5cea655edb))
|
||||
* **css:** `--font-family-sans` renamed to `--font-sans` ([#2680](https://github.com/nuxt/ui/issues/2680)) ([b2fa657](https://github.com/nuxt/ui/commit/b2fa65734bb59186520c985f7c73fc34a0cb8b37))
|
||||
* **css:** remove useless spacing override ([8d00265](https://github.com/nuxt/ui/commit/8d0026558a21efbbca08e9939844f7479a0d6cce))
|
||||
* **FormField:** missing conditions to apply container classes ([#2631](https://github.com/nuxt/ui/issues/2631)) ([9241ba1](https://github.com/nuxt/ui/commit/9241ba1230b0fde41595634362d83c92c66b7699))
|
||||
* **Form:** match `error-pattern` on input validation ([#2606](https://github.com/nuxt/ui/issues/2606)) ([3584a33](https://github.com/nuxt/ui/commit/3584a3328b8588f024557c9908242bc374853419))
|
||||
* **InputMenu/SelectMenu:** init `filter` with `labelKey` ([18931ac](https://github.com/nuxt/ui/commit/18931acdb316bc72a3e5ed6d20985688ad5c8d99))
|
||||
* **InputMenu/SelectMenu:** look in `items` only with `value-attribute` ([0ceafe1](https://github.com/nuxt/ui/commit/0ceafe1d54000f3eb49562b00c188d82fa23c4ee)), closes [#2464](https://github.com/nuxt/ui/issues/2464)
|
||||
* **InputMenu/SelectMenu:** multiple not working with generic boolean casting ([503f701](https://github.com/nuxt/ui/commit/503f701c7ecdfe27e9057e5ddebfc7e03889d61b)), closes [#2541](https://github.com/nuxt/ui/issues/2541)
|
||||
* **InputMenu/SelectMenu:** use `isEqual` from `ohash` ([f943f88](https://github.com/nuxt/ui/commit/f943f88fcc9f4678d8f7bd224799e289a0c57dd8))
|
||||
* **Link:** missing relative import ([#2588](https://github.com/nuxt/ui/issues/2588)) ([95a0bbc](https://github.com/nuxt/ui/commit/95a0bbc581a40677f620eed3170f9a423976214b))
|
||||
* **locale:** Improve German translation ([#2676](https://github.com/nuxt/ui/issues/2676)) ([992be91](https://github.com/nuxt/ui/commit/992be91823fe1877254ccd092c71c77dd3ff42f7))
|
||||
* **locale:** it translation ([#2623](https://github.com/nuxt/ui/issues/2623)) ([73e25ed](https://github.com/nuxt/ui/commit/73e25ed23562f755ea4c66e6c5fb06dd18caac1e))
|
||||
* **locale:** Italian translation ([#2584](https://github.com/nuxt/ui/issues/2584)) ([d167c9b](https://github.com/nuxt/ui/commit/d167c9b807a82fdf0fd280ce8417a66f86d7ed72))
|
||||
* **Modal/Slideover:** prevent `esc` with `prevent-close` prop ([9e2cc5b](https://github.com/nuxt/ui/commit/9e2cc5b12567472044726924a3896b4b0e7993a1)), closes [#2501](https://github.com/nuxt/ui/issues/2501)
|
||||
* **module:** remove `fast-deep-equal` in favor of custom `isEqual` ([37a3597](https://github.com/nuxt/ui/commit/37a359701f4b2ce4a9b0727b64c0e3eea6be00b4))
|
||||
* **module:** skip devtools renderer page injection if router integration is disabled ([#2571](https://github.com/nuxt/ui/issues/2571)) ([afe4003](https://github.com/nuxt/ui/commit/afe40033b088d8aedb73fa8387a0284ef78444e4))
|
||||
* **PinInput:** missing `useFormField` import ([601f4b2](https://github.com/nuxt/ui/commit/601f4b2cd2027817b935e02a0b4584dc3dce655f))
|
||||
* **Textarea:** `autoresize` does not work when initializing `modelValue` ([#2681](https://github.com/nuxt/ui/issues/2681)) ([d3a079a](https://github.com/nuxt/ui/commit/d3a079a644db3dfe2f4e9567973550d74b3ba905))
|
||||
* **Toaster:** teleport to `body` ([b0be26d](https://github.com/nuxt/ui/commit/b0be26d67feab467ac5862edd82e52df03a5091c)), closes [#2404](https://github.com/nuxt/ui/issues/2404)
|
||||
* **Toast:** unreachable behind overlays ([#2650](https://github.com/nuxt/ui/issues/2650)) ([0daac5b](https://github.com/nuxt/ui/commit/0daac5bafb756c3a2dfaf2bf166c30c0eb476e08))
|
||||
* **useLocale:** missing import in various components ([#2603](https://github.com/nuxt/ui/issues/2603)) ([df7a61a](https://github.com/nuxt/ui/commit/df7a61a97a14b3d7943baee6a74686134dfdb10b))
|
||||
|
||||
### Reverts
|
||||
|
||||
* Revert "docs(ComponentCode/ComponentExample): use relative imports" ([5deadc7](https://github.com/nuxt/ui/commit/5deadc709640bbfd3ec14c1c9363deb55e765d6a))
|
||||
|
||||
## [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
|
||||
|
||||
64
README.md
64
README.md
@@ -1,6 +1,6 @@
|
||||
[](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,18 +44,54 @@ export default defineNuxtConfig({
|
||||
})
|
||||
```
|
||||
|
||||
3. Import Tailwind CSS and Nuxt UI in your `app.vue` or [CSS](https://nuxt.com/docs/getting-started/styling#the-css-property):
|
||||
2. Import Tailwind CSS and Nuxt UI in your CSS:
|
||||
|
||||
```vue [app.vue]
|
||||
<style>
|
||||
```css [assets/css/main.css]
|
||||
@import "tailwindcss";
|
||||
@import "@nuxt/ui";
|
||||
</style>
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
@@ -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']
|
||||
})
|
||||
|
||||
@@ -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: {
|
||||
14
cli/commands/make/index.mjs
Normal file
14
cli/commands/make/index.mjs
Normal 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
|
||||
}
|
||||
})
|
||||
64
cli/commands/make/locale.mjs
Normal file
64
cli/commands/make/locale.mjs
Normal file
@@ -0,0 +1,64 @@
|
||||
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
|
||||
},
|
||||
dir: {
|
||||
description: 'Locale direction. For example: rtl.',
|
||||
default: 'ltr'
|
||||
}
|
||||
},
|
||||
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 (!['ltr', 'rtl'].includes(args.dir)) {
|
||||
consola.error(`🚨 Direction ${args.dir} not supported!`)
|
||||
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(/name: '(.*)',/, `name: '${args.name}',`)
|
||||
.replace(/code: '(.*)',/, `code: '${normalizeLocale(args.code)}',${(args.dir && args.dir !== 'ltr') ? `\n dir: '${args.dir}',` : ''}`)
|
||||
await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
|
||||
|
||||
consola.success(`🪄 Generated ${newLocaleFilePath}`)
|
||||
}
|
||||
})
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -163,9 +163,54 @@ describe('${upperName}', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const doc = ({ name, pro }) => {
|
||||
const kebabName = kebabCase(name)
|
||||
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
|
||||
|
||||
return {
|
||||
filename: `docs/content/${pro ? 'pro' : '3.components'}/${kebabName}.md`,
|
||||
contents: `---
|
||||
description:
|
||||
links: ${pro
|
||||
? ''
|
||||
: `
|
||||
- label: ${upperName}
|
||||
icon: i-custom-radix-vue
|
||||
to: https://www.radix-vue.com/components/${kebabName}.html`}
|
||||
- label: GitHub
|
||||
icon: i-simple-icons-github
|
||||
to: https://github.com/nuxt/${pro ? 'ui-pro' : 'ui'}/tree/v3/src/runtime/components/${upperName}.vue
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
## Examples
|
||||
|
||||
## API
|
||||
|
||||
### Props
|
||||
|
||||
:component-props
|
||||
|
||||
### Slots
|
||||
|
||||
:component-slots
|
||||
|
||||
### Emits
|
||||
|
||||
:component-emits
|
||||
|
||||
## Theme
|
||||
|
||||
:component-theme
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
playground,
|
||||
component,
|
||||
theme,
|
||||
test
|
||||
test,
|
||||
doc
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
8
devtools/app/app.config.ts
Normal file
8
devtools/app/app.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export default defineAppConfig({
|
||||
ui: {
|
||||
colors: {
|
||||
primary: 'green',
|
||||
neutral: 'zinc'
|
||||
}
|
||||
}
|
||||
})
|
||||
222
devtools/app/app.vue
Normal file
222
devtools/app/app.vue
Normal 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-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>
|
||||
43
devtools/app/components/CollapseContainer.vue
Normal file
43
devtools/app/components/CollapseContainer.vue
Normal 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>
|
||||
151
devtools/app/components/ComponentPreview.vue
Normal file
151
devtools/app/components/ComponentPreview.vue
Normal 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, ''').replace(/"/g, '"')}'`
|
||||
}
|
||||
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><NuxtPage /></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>
|
||||
39
devtools/app/components/ComponentPropInput.vue
Normal file
39
devtools/app/components/ComponentPropInput.vue
Normal 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>
|
||||
10
devtools/app/components/UILogo.vue
Normal file
10
devtools/app/components/UILogo.vue
Normal 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>
|
||||
76
devtools/app/components/inputs/ArrayInput.vue
Normal file
76
devtools/app/components/inputs/ArrayInput.vue
Normal 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>
|
||||
20
devtools/app/components/inputs/BooleanInput.vue
Normal file
20
devtools/app/components/inputs/BooleanInput.vue
Normal 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>
|
||||
15
devtools/app/components/inputs/NumberInput.vue
Normal file
15
devtools/app/components/inputs/NumberInput.vue
Normal 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>
|
||||
38
devtools/app/components/inputs/ObjectInput.vue
Normal file
38
devtools/app/components/inputs/ObjectInput.vue
Normal 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>
|
||||
60
devtools/app/components/inputs/StringEnumInput.vue
Normal file
60
devtools/app/components/inputs/StringEnumInput.vue
Normal 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>
|
||||
15
devtools/app/components/inputs/StringInput.vue
Normal file
15
devtools/app/components/inputs/StringInput.vue
Normal 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>
|
||||
44
devtools/app/composables/usePropSchema.ts
Normal file
44
devtools/app/composables/usePropSchema.ts
Normal 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 }
|
||||
}
|
||||
34
devtools/app/composables/useShiki.ts
Normal file
34
devtools/app/composables/useShiki.ts
Normal 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 }
|
||||
}
|
||||
54
devtools/app/plugins/prettier.client.ts
Normal file
54
devtools/app/plugins/prettier.client.ts
Normal 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
|
||||
}
|
||||
}
|
||||
})
|
||||
36
devtools/app/workers/prettier.js
Normal file
36
devtools/app/workers/prettier.js
Normal 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
38
devtools/nuxt.config.ts
Normal 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
19
devtools/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
1
devtools/public/favicon.svg
Normal file
1
devtools/public/favicon.svg
Normal 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 |
24
devtools/test/composables/usePropSchema.test.ts
Normal file
24
devtools/test/composables/usePropSchema.test.ts
Normal 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
133
devtools/test/fixtures/schemas.ts
vendored
Normal 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"'
|
||||
}
|
||||
}
|
||||
7
devtools/test/vitest.config.ts
Normal file
7
devtools/test/vitest.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineVitestConfig } from '@nuxt/test-utils/config'
|
||||
|
||||
export default defineVitestConfig({
|
||||
test: {
|
||||
environment: 'nuxt'
|
||||
}
|
||||
})
|
||||
4
devtools/tsconfig.json
Normal file
4
devtools/tsconfig.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json"
|
||||
}
|
||||
@@ -2,16 +2,15 @@
|
||||
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 { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation(), { default: () => [] })
|
||||
const { data: files } = await useLazyFetch<ContentSearchFile[]>(`${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('')
|
||||
|
||||
@@ -23,33 +22,31 @@ 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' ? (colors as any)[appConfig.ui.colors.neutral][900] : 'white')
|
||||
const radius = computed(() => `:root { --ui-radius: ${appConfig.theme.radius}rem; }`)
|
||||
@@ -76,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>
|
||||
@@ -110,7 +124,9 @@ provide('navigation', navigation)
|
||||
@source "../content/**/*.md";
|
||||
|
||||
@theme {
|
||||
--font-family-sans: 'Public Sans', sans-serif;
|
||||
--container-8xl: 90rem;
|
||||
|
||||
--font-sans: 'Public Sans', sans-serif;
|
||||
|
||||
--color-green-50: #EFFDF5;
|
||||
--color-green-100: #D9FBE8;
|
||||
@@ -126,6 +142,6 @@ provide('navigation', navigation)
|
||||
}
|
||||
|
||||
:root {
|
||||
--ui-container-width: 90rem;
|
||||
--ui-container: var(--container-8xl);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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' }]" :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>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<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: () => {
|
||||
@@ -29,7 +29,7 @@ defineShortcuts({
|
||||
</NuxtLink>
|
||||
</template>
|
||||
|
||||
<!-- <UNavigationMenu :items="items" variant="link" /> -->
|
||||
<UNavigationMenu :items="items" variant="link" />
|
||||
|
||||
<template #right>
|
||||
<ThemePicker />
|
||||
@@ -51,11 +51,11 @@ defineShortcuts({
|
||||
</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>
|
||||
|
||||
@@ -43,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({
|
||||
@@ -163,7 +164,7 @@ const code = computed(() => {
|
||||
continue
|
||||
}
|
||||
|
||||
code += ` ${prop?.type.includes('number') ? ':' : ''}${name}="${value}"`
|
||||
code += ` ${typeof value === 'number' ? ':' : ''}${name}="${value}"`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +220,7 @@ 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-[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">
|
||||
<div v-if="options.length" class="flex items-center gap-2.5 border border-[var(--ui-border-muted)] 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"
|
||||
@@ -268,12 +269,12 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div 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="name" v-bind="{ ...componentProps, ...componentEvents }">
|
||||
<div v-if="component" class="flex justify-center border border-b-0 border-[var(--ui-border-muted)] 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>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -117,8 +117,8 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
|
||||
<template>
|
||||
<div class="my-5">
|
||||
<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)]">
|
||||
<div class="border border-[var(--ui-border-muted)] 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-border-muted)]">
|
||||
<slot name="options" />
|
||||
|
||||
<UFormField
|
||||
|
||||
@@ -87,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" />
|
||||
|
||||
@@ -24,9 +24,9 @@ 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" />
|
||||
|
||||
64
docs/app/components/content/SupportedLanguages.vue
Normal file
64
docs/app/components/content/SupportedLanguages.vue
Normal file
@@ -0,0 +1,64 @@
|
||||
<script setup lang="ts">
|
||||
import * as locales from '@nuxt/ui/locale'
|
||||
import type { Locale } from '@nuxt/ui'
|
||||
|
||||
type LocaleKey = keyof typeof locales
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
default?: string
|
||||
}>(), {
|
||||
default: 'en'
|
||||
})
|
||||
|
||||
const getLocaleKeys = Object.keys(locales) as LocaleKey[]
|
||||
const localesList = getLocaleKeys.map<[LocaleKey, Locale]>(locale => [locale, locales[locale]])
|
||||
</script>
|
||||
|
||||
<!-- eslint-disable vue/singleline-html-element-content-newline -->
|
||||
<template>
|
||||
<div>
|
||||
<ProseP>
|
||||
By default, the <ProseCode>{{ props.default }}</ProseCode> locale is used.
|
||||
</ProseP>
|
||||
<ProseTable>
|
||||
<ProseThead>
|
||||
<ProseTr>
|
||||
<ProseTh>
|
||||
Language
|
||||
</ProseTh>
|
||||
<ProseTh>
|
||||
Code
|
||||
</ProseTh>
|
||||
<ProseTh>
|
||||
Direction
|
||||
</ProseTh>
|
||||
</ProseTr>
|
||||
</ProseThead>
|
||||
<ProseTbody>
|
||||
<ProseTr v-for="[key, locale] in localesList" :key="key">
|
||||
<ProseTd>
|
||||
{{ locale.name }}
|
||||
</ProseTd>
|
||||
<ProseTd>
|
||||
<ProseCode>
|
||||
{{ locale.code }}
|
||||
</ProseCode>
|
||||
</ProseTd>
|
||||
<ProseTd>
|
||||
<ProseCode>
|
||||
{{ locale.dir }}
|
||||
</ProseCode>
|
||||
</ProseTd>
|
||||
</ProseTr>
|
||||
</ProseTbody>
|
||||
</ProseTable>
|
||||
<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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 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.'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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',
|
||||
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.'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ const items = [{
|
||||
to: '/'
|
||||
}, {
|
||||
slot: 'dropdown',
|
||||
icon: 'i-heroicons-ellipsis-horizontal',
|
||||
icon: 'i-lucide-ellipsis',
|
||||
children: [{
|
||||
label: 'Documentation'
|
||||
}, {
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<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>
|
||||
|
||||
@@ -26,7 +26,7 @@ const items = [{
|
||||
<UButton
|
||||
color="neutral"
|
||||
variant="outline"
|
||||
icon="i-heroicons-chevron-down-20-solid"
|
||||
icon="i-lucide-chevron-down"
|
||||
/>
|
||||
</UDropdownMenu>
|
||||
</UButtonGroup>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<UButton
|
||||
color="neutral"
|
||||
variant="subtle"
|
||||
icon="i-heroicons-clipboard-document"
|
||||
icon="i-lucide-clipboard"
|
||||
/>
|
||||
</UTooltip>
|
||||
</UButtonGroup>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
label="Open"
|
||||
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'
|
||||
}"
|
||||
|
||||
@@ -12,7 +12,7 @@ defineShortcuts({
|
||||
label="Open"
|
||||
color="neutral"
|
||||
variant="subtle"
|
||||
trailing-icon="i-heroicons-chevron-down-20-solid"
|
||||
trailing-icon="i-lucide-chevron-down"
|
||||
block
|
||||
/>
|
||||
|
||||
|
||||
@@ -4,22 +4,22 @@ const groups = [{
|
||||
items: [
|
||||
{
|
||||
label: 'Profile',
|
||||
icon: 'i-heroicons-user',
|
||||
icon: 'i-lucide-user',
|
||||
kbds: ['meta', 'P']
|
||||
},
|
||||
{
|
||||
label: 'Billing',
|
||||
icon: 'i-heroicons-credit-card',
|
||||
icon: 'i-lucide-credit-card',
|
||||
kbds: ['meta', 'B'],
|
||||
slot: 'billing'
|
||||
},
|
||||
{
|
||||
label: 'Notifications',
|
||||
icon: 'i-heroicons-bell'
|
||||
icon: 'i-lucide-bell'
|
||||
},
|
||||
{
|
||||
label: 'Security',
|
||||
icon: 'i-heroicons-lock-closed'
|
||||
icon: 'i-lucide-lock'
|
||||
}
|
||||
]
|
||||
}, {
|
||||
|
||||
@@ -60,7 +60,7 @@ const users = [
|
||||
label="Search users..."
|
||||
color="neutral"
|
||||
variant="subtle"
|
||||
icon="i-heroicons-magnifying-glass"
|
||||
icon="i-lucide-search"
|
||||
/>
|
||||
|
||||
<template #content>
|
||||
|
||||
@@ -84,7 +84,7 @@ const groups = ref([
|
||||
{
|
||||
label: 'Add new file',
|
||||
suffix: 'Create a new file in the current directory or workspace.',
|
||||
icon: 'i-heroicons-document-plus',
|
||||
icon: 'i-lucide-file-plus',
|
||||
kbds: [
|
||||
'meta',
|
||||
'N'
|
||||
@@ -96,7 +96,7 @@ const groups = ref([
|
||||
{
|
||||
label: 'Add new folder',
|
||||
suffix: 'Create a new folder in the current directory or workspace.',
|
||||
icon: 'i-heroicons-folder-plus',
|
||||
icon: 'i-lucide-folder-plus',
|
||||
kbds: [
|
||||
'meta',
|
||||
'F'
|
||||
@@ -108,7 +108,7 @@ const groups = ref([
|
||||
{
|
||||
label: 'Add hashtag',
|
||||
suffix: 'Add a hashtag to the current item.',
|
||||
icon: 'i-heroicons-hashtag',
|
||||
icon: 'i-lucide-hash',
|
||||
kbds: [
|
||||
'meta',
|
||||
'H'
|
||||
@@ -120,7 +120,7 @@ const groups = ref([
|
||||
{
|
||||
label: 'Add label',
|
||||
suffix: 'Add a label to the current item.',
|
||||
icon: 'i-heroicons-tag',
|
||||
icon: 'i-lucide-tag',
|
||||
kbds: [
|
||||
'meta',
|
||||
'L'
|
||||
|
||||
@@ -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>
|
||||
@@ -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-[var(--ui-primary)] 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>
|
||||
|
||||
@@ -23,7 +23,7 @@ const groups = computed(() => [{
|
||||
label="Search users..."
|
||||
color="neutral"
|
||||
variant="subtle"
|
||||
icon="i-heroicons-magnifying-glass"
|
||||
icon="i-lucide-search"
|
||||
/>
|
||||
|
||||
<template #content>
|
||||
|
||||
@@ -4,7 +4,7 @@ const open = ref(false)
|
||||
|
||||
<template>
|
||||
<UDrawer v-model:open="open" title="Drawer with footer" description="This is useful when you want a form in a Drawer." :ui="{ container: 'max-w-xl mx-auto' }">
|
||||
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-heroicons-chevron-up-20-solid" />
|
||||
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
|
||||
|
||||
<template #body>
|
||||
<Placeholder class="h-48" />
|
||||
|
||||
@@ -8,7 +8,7 @@ defineShortcuts({
|
||||
|
||||
<template>
|
||||
<UDrawer v-model:open="open">
|
||||
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-heroicons-chevron-up-20-solid" />
|
||||
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
|
||||
|
||||
<template #content>
|
||||
<Placeholder class="h-48 m-4" />
|
||||
|
||||
@@ -5,13 +5,13 @@ const showDownloads = ref(false)
|
||||
|
||||
const items = computed(() => [{
|
||||
label: 'Interface',
|
||||
icon: 'i-heroicons-window',
|
||||
icon: 'i-lucide-app-window',
|
||||
type: 'label' as const
|
||||
}, {
|
||||
type: 'separator' as const
|
||||
}, {
|
||||
label: 'Show Bookmarks',
|
||||
icon: 'i-heroicons-bookmark',
|
||||
icon: 'i-lucide-bookmark',
|
||||
type: 'checkbox' as const,
|
||||
checked: showBookmarks.value,
|
||||
onUpdateChecked(checked: boolean) {
|
||||
@@ -22,7 +22,7 @@ const items = computed(() => [{
|
||||
}
|
||||
}, {
|
||||
label: 'Show History',
|
||||
icon: 'i-heroicons-clock',
|
||||
icon: 'i-lucide-clock',
|
||||
type: 'checkbox' as const,
|
||||
checked: showHistory.value,
|
||||
onUpdateChecked(checked: boolean) {
|
||||
@@ -30,7 +30,7 @@ const items = computed(() => [{
|
||||
}
|
||||
}, {
|
||||
label: 'Show Downloads',
|
||||
icon: 'i-heroicons-arrow-down-on-square',
|
||||
icon: 'i-lucide-download',
|
||||
type: 'checkbox' as const,
|
||||
checked: showDownloads.value,
|
||||
onUpdateChecked(checked: boolean) {
|
||||
@@ -41,6 +41,6 @@ const items = computed(() => [{
|
||||
|
||||
<template>
|
||||
<UDropdownMenu :items="items" :content="{ align: 'start' }" class="w-48">
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-heroicons-bars-3" />
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<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>
|
||||
<UDropdownMenu :items="items" class="w-48">
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
|
||||
|
||||
<template #profile-trailing>
|
||||
<UIcon name="i-lucide-badge-check" class="shrink-0 size-5 text-[var(--ui-primary)]" />
|
||||
</template>
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
@@ -1,23 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
const items = [{
|
||||
label: 'Profile',
|
||||
icon: 'i-heroicons-user',
|
||||
icon: 'i-lucide-user',
|
||||
slot: 'profile'
|
||||
}, {
|
||||
label: 'Billing',
|
||||
icon: 'i-heroicons-credit-card'
|
||||
icon: 'i-lucide-credit-card'
|
||||
}, {
|
||||
label: 'Settings',
|
||||
icon: 'i-heroicons-cog'
|
||||
icon: 'i-lucide-cog'
|
||||
}]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDropdownMenu :items="items" class="w-48">
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-heroicons-bars-3" />
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
|
||||
|
||||
<template #profile-trailing>
|
||||
<UIcon name="i-heroicons-check-badge" class="shrink-0 size-5 text-[var(--ui-primary)]" />
|
||||
<UIcon name="i-lucide-badge-check" class="shrink-0 size-5 text-[var(--ui-primary)]" />
|
||||
</template>
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
|
||||
@@ -7,18 +7,18 @@ defineShortcuts({
|
||||
|
||||
const items = [{
|
||||
label: 'Profile',
|
||||
icon: 'i-heroicons-user'
|
||||
icon: 'i-lucide-user'
|
||||
}, {
|
||||
label: 'Billing',
|
||||
icon: 'i-heroicons-credit-card'
|
||||
icon: 'i-lucide-credit-card'
|
||||
}, {
|
||||
label: 'Settings',
|
||||
icon: 'i-heroicons-cog'
|
||||
icon: 'i-lucide-cog'
|
||||
}]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDropdownMenu v-model:open="open" :items="items" class="w-48">
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-heroicons-bars-3" />
|
||||
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { FormSubmitEvent } from '@nuxt/ui'
|
||||
|
||||
const schema = z.object({
|
||||
input: z.string().min(10),
|
||||
inputNumber: z.number().min(10),
|
||||
inputMenu: z.any().refine(option => option?.value === 'option-2', {
|
||||
message: 'Select Option 2'
|
||||
}),
|
||||
@@ -29,10 +30,11 @@ const schema = z.object({
|
||||
radioGroup: z.string().refine(value => value === 'option-2', {
|
||||
message: 'Select Option 2'
|
||||
}),
|
||||
slider: z.number().max(20, { message: 'Must be less than 20' })
|
||||
slider: z.number().max(20, { message: 'Must be less than 20' }),
|
||||
pin: z.string().regex(/^\d$/).array().length(5)
|
||||
})
|
||||
|
||||
type Schema = z.output<typeof schema>
|
||||
type Schema = z.input<typeof schema>
|
||||
|
||||
const state = reactive<Partial<Schema>>({})
|
||||
|
||||
@@ -52,10 +54,10 @@ async function onSubmit(event: FormSubmitEvent<any>) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UForm ref="form" :state="state" :schema="schema" @submit="onSubmit">
|
||||
<UForm ref="form" :state="state" :schema="schema" class="w-full" @submit="onSubmit">
|
||||
<div class="grid grid-cols-3 gap-4">
|
||||
<UFormField label="Input" name="input">
|
||||
<UInput v-model="state.input" placeholder="john@lennon.com" class="w-40" />
|
||||
<UInput v-model="state.input" placeholder="john@lennon.com" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
@@ -73,42 +75,48 @@ async function onSubmit(event: FormSubmitEvent<any>) {
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="select" label="Select">
|
||||
<USelect v-model="state.select" :items="items" />
|
||||
<USelect v-model="state.select" :items="items" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="selectMenu" label="Select Menu">
|
||||
<USelectMenu v-model="state.selectMenu" :items="items" />
|
||||
<USelectMenu v-model="state.selectMenu" :items="items" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="selectMenuMultiple" label="Select Menu (Multiple)">
|
||||
<USelectMenu v-model="state.selectMenuMultiple" multiple :items="items" />
|
||||
<USelectMenu v-model="state.selectMenuMultiple" multiple :items="items" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="inputMenu" label="Input Menu">
|
||||
<UInputMenu v-model="state.inputMenu" :items="items" />
|
||||
<UInputMenu v-model="state.inputMenu" :items="items" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="inputMenuMultiple" label="Input Menu (Multiple)">
|
||||
<UInputMenu v-model="state.inputMenuMultiple" multiple :items="items" />
|
||||
<UInputMenu v-model="state.inputMenuMultiple" multiple :items="items" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<span />
|
||||
<UFormField name="inputNumber" label="Input Number">
|
||||
<UInputNumber v-model="state.inputNumber" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField label="Textarea" name="textarea">
|
||||
<UTextarea v-model="state.textarea" />
|
||||
<UTextarea v-model="state.textarea" class="w-full" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="radioGroup">
|
||||
<URadioGroup v-model="state.radioGroup" legend="Radio group" :items="items" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField name="pin" label="Pin Input" :error-pattern="/(pin)\..*/">
|
||||
<UPinInput v-model="state.pin" />
|
||||
</UFormField>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 mt-8">
|
||||
<UButton color="neutral" type="submit">
|
||||
<UButton type="submit">
|
||||
Submit
|
||||
</UButton>
|
||||
|
||||
<UButton color="neutral" variant="outline" @click="form?.clear()">
|
||||
<UButton variant="outline" @click="form?.clear()">
|
||||
Clear
|
||||
</UButton>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<script setup lang="ts">
|
||||
const { data: countries, status, execute } = await useLazyFetch<{
|
||||
name: string
|
||||
code: string
|
||||
emoji: string
|
||||
}[]>('/api/countries.json', {
|
||||
immediate: false
|
||||
})
|
||||
|
||||
function onOpen() {
|
||||
if (!countries.value?.length) {
|
||||
execute()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInputMenu
|
||||
:items="countries || []"
|
||||
:loading="status === 'pending'"
|
||||
label-key="name"
|
||||
:search-input="{ icon: 'i-lucide-search' }"
|
||||
placeholder="Select country"
|
||||
class="w-48"
|
||||
@update:open="onOpen"
|
||||
>
|
||||
<template #leading="{ modelValue, ui }">
|
||||
<span v-if="modelValue" class="size-5 text-center">
|
||||
{{ modelValue?.emoji }}
|
||||
</span>
|
||||
<UIcon v-else name="i-lucide-earth" :class="ui.leadingIcon()" />
|
||||
</template>
|
||||
<template #item-leading="{ item }">
|
||||
<span class="size-5 text-center">
|
||||
{{ item.emoji }}
|
||||
</span>
|
||||
</template>
|
||||
</UInputMenu>
|
||||
</template>
|
||||
@@ -15,7 +15,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
||||
<UInputMenu
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
icon="i-heroicons-user"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
>
|
||||
<template #leading="{ modelValue, ui }">
|
||||
|
||||
@@ -21,7 +21,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
:filter="false"
|
||||
icon="i-heroicons-user"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
>
|
||||
<template #leading="{ modelValue, ui }">
|
||||
|
||||
@@ -16,8 +16,8 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
||||
<UInputMenu
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
:filter="['name', 'email']"
|
||||
icon="i-heroicons-user"
|
||||
:filter="['label', 'email']"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
class="w-80"
|
||||
>
|
||||
|
||||
@@ -3,22 +3,22 @@ const items = ref([
|
||||
{
|
||||
label: 'Backlog',
|
||||
value: 'backlog',
|
||||
icon: 'i-heroicons-question-mark-circle'
|
||||
icon: 'i-lucide-circle-help'
|
||||
},
|
||||
{
|
||||
label: 'Todo',
|
||||
value: 'todo',
|
||||
icon: 'i-heroicons-plus-circle'
|
||||
icon: 'i-lucide-circle-plus'
|
||||
},
|
||||
{
|
||||
label: 'In Progress',
|
||||
value: 'in_progress',
|
||||
icon: 'i-heroicons-arrow-up-circle'
|
||||
icon: 'i-lucide-circle-arrow-up'
|
||||
},
|
||||
{
|
||||
label: 'Done',
|
||||
value: 'done',
|
||||
icon: 'i-heroicons-check-circle'
|
||||
icon: 'i-lucide-circle-check'
|
||||
}
|
||||
])
|
||||
const value = ref(items.value[0])
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
const value = ref(1500)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInputNumber
|
||||
v-model="value"
|
||||
:format-options="{
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
currencyDisplay: 'code',
|
||||
currencySign: 'accounting'
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
const value = ref(5)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInputNumber
|
||||
v-model="value"
|
||||
:format-options="{
|
||||
signDisplay: 'exceptZero',
|
||||
minimumFractionDigits: 1
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
const retries = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UFormField label="Retries" help="Specify number of attempts" required>
|
||||
<UInputNumber v-model="retries" placeholder="Enter retries" />
|
||||
</UFormField>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
const value = ref(0.05)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInputNumber
|
||||
v-model="value"
|
||||
:step="0.01"
|
||||
:format-options="{
|
||||
style: 'percent'
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
const value = ref(5)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInputNumber v-model="value">
|
||||
<template #decrement>
|
||||
<UButton size="xs" icon="i-lucide-minus" />
|
||||
</template>
|
||||
|
||||
<template #increment>
|
||||
<UButton size="xs" icon="i-lucide-plus" />
|
||||
</template>
|
||||
</UInputNumber>
|
||||
</template>
|
||||
@@ -6,14 +6,14 @@ const value = ref('Click to clear')
|
||||
<UInput
|
||||
v-model="value"
|
||||
placeholder="Type something..."
|
||||
:ui="{ trailing: 'pr-0.5' }"
|
||||
:ui="{ trailing: 'pe-1' }"
|
||||
>
|
||||
<template v-if="value?.length" #trailing>
|
||||
<UButton
|
||||
color="neutral"
|
||||
variant="link"
|
||||
size="sm"
|
||||
icon="i-heroicons-x-circle"
|
||||
icon="i-lucide-circle-x"
|
||||
aria-label="Clear input"
|
||||
@click="value = ''"
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
const value = ref('npx nuxi module add ui')
|
||||
const copied = ref(false)
|
||||
|
||||
function copy() {
|
||||
navigator.clipboard.writeText(value.value)
|
||||
copied.value = true
|
||||
|
||||
setTimeout(() => {
|
||||
copied.value = false
|
||||
}, 2000)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInput
|
||||
v-model="value"
|
||||
:ui="{ trailing: 'pr-0.5' }"
|
||||
>
|
||||
<template v-if="value?.length" #trailing>
|
||||
<UTooltip text="Copy to clipboard" :content="{ side: 'right' }">
|
||||
<UButton
|
||||
:color="copied ? 'success' : 'neutral'"
|
||||
variant="link"
|
||||
size="sm"
|
||||
:icon="copied ? 'i-lucide-copy-check' : 'i-lucide-copy'"
|
||||
aria-label="Copy to clipboard"
|
||||
@click="copy"
|
||||
/>
|
||||
</UTooltip>
|
||||
</template>
|
||||
</UInput>
|
||||
</template>
|
||||
@@ -4,6 +4,6 @@ const email = ref('')
|
||||
|
||||
<template>
|
||||
<UFormField label="Email" help="We won't share your email." required>
|
||||
<UInput v-model="email" placeholder="Enter your email" icon="i-heroicons-at-symbol" />
|
||||
<UInput v-model="email" placeholder="Enter your email" icon="i-lucide-at-sign" />
|
||||
</UFormField>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
const input = useTemplateRef('input')
|
||||
|
||||
defineShortcuts({
|
||||
'/': () => {
|
||||
input.value?.inputRef?.focus()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UInput
|
||||
ref="input"
|
||||
icon="i-lucide-search"
|
||||
placeholder="Search..."
|
||||
>
|
||||
<template #trailing>
|
||||
<UKbd value="/" />
|
||||
</template>
|
||||
</UInput>
|
||||
</template>
|
||||
@@ -40,7 +40,7 @@ const text = computed(() => {
|
||||
placeholder="Password"
|
||||
:color="color"
|
||||
:type="show ? 'text' : 'password'"
|
||||
:ui="{ trailing: 'pr-0.5' }"
|
||||
:ui="{ trailing: 'pe-1' }"
|
||||
:aria-invalid="score < 4"
|
||||
aria-describedby="password-strength"
|
||||
class="w-full"
|
||||
@@ -50,7 +50,7 @@ const text = computed(() => {
|
||||
color="neutral"
|
||||
variant="link"
|
||||
size="sm"
|
||||
:icon="show ? 'i-heroicons-eye-slash' : 'i-heroicons-eye'"
|
||||
:icon="show ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
||||
aria-label="show ? 'Hide password' : 'Show password'"
|
||||
:aria-pressed="show"
|
||||
aria-controls="password"
|
||||
@@ -79,7 +79,7 @@ const text = computed(() => {
|
||||
class="flex items-center gap-0.5"
|
||||
:class="req.met ? 'text-[var(--ui-success)]' : 'text-[var(--ui-text-muted)]'"
|
||||
>
|
||||
<UIcon :name="req.met ? 'i-heroicons-check-circle' : 'i-heroicons-x-circle'" class="size-4 shrink-0" />
|
||||
<UIcon :name="req.met ? 'i-lucide-circle-check' : 'i-lucide-circle-x'" class="size-4 shrink-0" />
|
||||
|
||||
<span class="text-xs font-light">
|
||||
{{ req.text }}
|
||||
|
||||
@@ -8,14 +8,14 @@ const password = ref('password')
|
||||
v-model="password"
|
||||
placeholder="Password"
|
||||
:type="show ? 'text' : 'password'"
|
||||
:ui="{ trailing: 'pr-0.5' }"
|
||||
:ui="{ trailing: 'pe-1' }"
|
||||
>
|
||||
<template #trailing>
|
||||
<UButton
|
||||
color="neutral"
|
||||
variant="link"
|
||||
size="sm"
|
||||
:icon="show ? 'i-heroicons-eye-slash' : 'i-heroicons-eye'"
|
||||
:icon="show ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
||||
aria-label="show ? 'Hide password' : 'Show password'"
|
||||
:aria-pressed="show"
|
||||
aria-controls="password"
|
||||
|
||||
@@ -23,7 +23,7 @@ const groups = computed(() => [{
|
||||
label="Search users..."
|
||||
color="neutral"
|
||||
variant="subtle"
|
||||
icon="i-heroicons-magnifying-glass"
|
||||
icon="i-lucide-search"
|
||||
/>
|
||||
|
||||
<template #content>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
const items = [
|
||||
{
|
||||
label: 'Docs',
|
||||
icon: 'i-lucide-book-open',
|
||||
slot: 'docs',
|
||||
children: [
|
||||
{
|
||||
label: 'Icons',
|
||||
description: 'You have nothing to do, @nuxt/icon will handle it automatically.'
|
||||
},
|
||||
{
|
||||
label: 'Colors',
|
||||
description: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
|
||||
},
|
||||
{
|
||||
label: 'Theme',
|
||||
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Components',
|
||||
icon: 'i-lucide-box',
|
||||
slot: 'components',
|
||||
children: [
|
||||
{
|
||||
label: 'Link',
|
||||
description: 'Use NuxtLink with superpowers.'
|
||||
},
|
||||
{
|
||||
label: 'Modal',
|
||||
description: 'Display a modal within your application.'
|
||||
},
|
||||
{
|
||||
label: 'NavigationMenu',
|
||||
description: 'Display a list of links.'
|
||||
},
|
||||
{
|
||||
label: 'Pagination',
|
||||
description: 'Display a list of pages.'
|
||||
},
|
||||
{
|
||||
label: 'Popover',
|
||||
description: 'Display a non-modal dialog that floats around a trigger element.'
|
||||
},
|
||||
{
|
||||
label: 'Progress',
|
||||
description: 'Show a horizontal bar to indicate task progression.'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'GitHub'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UNavigationMenu
|
||||
:items="items"
|
||||
class="justify-center"
|
||||
:ui="{
|
||||
viewport: 'sm:w-[var(--radix-navigation-menu-viewport-width)]',
|
||||
childList: 'sm:w-96',
|
||||
childLinkDescription: 'text-balance line-clamp-2'
|
||||
}"
|
||||
>
|
||||
<template #docs-content="{ item }">
|
||||
<ul class="grid gap-2 p-4 lg:w-[500px] lg:grid-cols-[minmax(0,.75fr)_minmax(0,1fr)]">
|
||||
<li class="row-span-3">
|
||||
<Placeholder class="size-full min-h-48" />
|
||||
</li>
|
||||
|
||||
<li v-for="child in item.children" :key="child.label">
|
||||
<ULink class="text-sm text-left rounded-md p-3 transition-colors hover:bg-[var(--ui-bg-elevated)]/50">
|
||||
<p class="font-medium text-[var(--ui-text-highlighted)]">
|
||||
{{ child.label }}
|
||||
</p>
|
||||
<p class="text-[var(--ui-text-muted)] line-clamp-2">
|
||||
{{ child.description }}
|
||||
</p>
|
||||
</ULink>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</UNavigationMenu>
|
||||
</template>
|
||||
@@ -2,17 +2,17 @@
|
||||
const items = [
|
||||
{
|
||||
label: 'Guide',
|
||||
icon: 'i-heroicons-book-open'
|
||||
icon: 'i-lucide-book-open'
|
||||
|
||||
},
|
||||
{
|
||||
label: 'Composables',
|
||||
icon: 'i-heroicons-circle-stack'
|
||||
icon: 'i-lucide-database'
|
||||
|
||||
},
|
||||
{
|
||||
label: 'Components',
|
||||
icon: 'i-heroicons-cube-transparent',
|
||||
icon: 'i-lucide-box',
|
||||
slot: 'components'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,93 +2,93 @@
|
||||
const items = [
|
||||
{
|
||||
label: 'Guide',
|
||||
icon: 'i-heroicons-book-open',
|
||||
icon: 'i-lucide-book-open',
|
||||
children: [
|
||||
{
|
||||
label: 'Introduction',
|
||||
description: 'Fully styled and customizable components for Nuxt.',
|
||||
icon: 'i-heroicons-home'
|
||||
icon: 'i-lucide-house'
|
||||
},
|
||||
{
|
||||
label: 'Installation',
|
||||
description: 'Learn how to install and configure Nuxt UI in your application.',
|
||||
icon: 'i-heroicons-cloud-arrow-down'
|
||||
icon: 'i-lucide-cloud-download'
|
||||
},
|
||||
{
|
||||
label: 'Icons',
|
||||
icon: 'i-heroicons-face-smile',
|
||||
icon: 'i-lucide-smile',
|
||||
description: 'You have nothing to do, @nuxt/icon will handle it automatically.'
|
||||
},
|
||||
{
|
||||
label: 'Colors',
|
||||
icon: 'i-heroicons-swatch',
|
||||
icon: 'i-lucide-swatch-book',
|
||||
description: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
|
||||
},
|
||||
{
|
||||
label: 'Theme',
|
||||
icon: 'i-heroicons-cog',
|
||||
icon: 'i-lucide-cog',
|
||||
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Composables',
|
||||
icon: 'i-heroicons-circle-stack',
|
||||
icon: 'i-lucide-database',
|
||||
children: [
|
||||
{
|
||||
label: 'defineShortcuts',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Define shortcuts for your application.'
|
||||
},
|
||||
{
|
||||
label: 'useModal',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a modal within your application.'
|
||||
},
|
||||
{
|
||||
label: 'useSlideover',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a slideover within your application.'
|
||||
},
|
||||
{
|
||||
label: 'useToast',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a toast within your application.'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Components',
|
||||
icon: 'i-heroicons-cube-transparent',
|
||||
icon: 'i-lucide-box',
|
||||
children: [
|
||||
{
|
||||
label: 'Link',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Use NuxtLink with superpowers.'
|
||||
},
|
||||
{
|
||||
label: 'Modal',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a modal within your application.'
|
||||
},
|
||||
{
|
||||
label: 'NavigationMenu',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a list of links.'
|
||||
},
|
||||
{
|
||||
label: 'Pagination',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a list of pages.'
|
||||
},
|
||||
{
|
||||
label: 'Popover',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Display a non-modal dialog that floats around a trigger element.'
|
||||
},
|
||||
{
|
||||
label: 'Progress',
|
||||
icon: 'i-heroicons-document-text',
|
||||
icon: 'i-lucide-file-text',
|
||||
description: 'Show a horizontal bar to indicate task progression.'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -28,7 +28,7 @@ const label = ref([])
|
||||
<template>
|
||||
<UPopover :content="{ side: 'right', align: 'start' }">
|
||||
<UButton
|
||||
icon="i-heroicons-tag"
|
||||
icon="i-lucide-tag"
|
||||
label="Select labels"
|
||||
color="neutral"
|
||||
variant="subtle"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
const { data: countries, status, execute } = await useLazyFetch<{
|
||||
name: string
|
||||
code: string
|
||||
emoji: string
|
||||
}[]>('/api/countries.json', {
|
||||
immediate: false,
|
||||
default: () => []
|
||||
})
|
||||
|
||||
function onOpen() {
|
||||
if (!countries.value?.length) {
|
||||
execute()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<USelectMenu
|
||||
:items="countries"
|
||||
:loading="status === 'pending'"
|
||||
label-key="name"
|
||||
:search-input="{ icon: 'i-lucide-search' }"
|
||||
placeholder="Select country"
|
||||
class="w-48"
|
||||
@update:open="onOpen"
|
||||
>
|
||||
<template #leading="{ modelValue, ui }">
|
||||
<span v-if="modelValue" class="size-5 text-center">
|
||||
{{ modelValue?.emoji }}
|
||||
</span>
|
||||
<UIcon v-else name="i-lucide-earth" :class="ui.leadingIcon()" />
|
||||
</template>
|
||||
<template #item-leading="{ item }">
|
||||
<span class="size-5 text-center">
|
||||
{{ item.emoji }}
|
||||
</span>
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</template>
|
||||
@@ -15,7 +15,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
||||
<USelectMenu
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
icon="i-heroicons-user"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
class="w-48"
|
||||
>
|
||||
|
||||
@@ -21,7 +21,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
:filter="false"
|
||||
icon="i-heroicons-user"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
class="w-48"
|
||||
>
|
||||
|
||||
@@ -16,8 +16,8 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
||||
<USelectMenu
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
:filter="['name', 'email']"
|
||||
icon="i-heroicons-user"
|
||||
:filter="['label', 'email']"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
class="w-80"
|
||||
>
|
||||
|
||||
@@ -3,22 +3,22 @@ const items = ref([
|
||||
{
|
||||
label: 'Backlog',
|
||||
value: 'backlog',
|
||||
icon: 'i-heroicons-question-mark-circle'
|
||||
icon: 'i-lucide-circle-help'
|
||||
},
|
||||
{
|
||||
label: 'Todo',
|
||||
value: 'todo',
|
||||
icon: 'i-heroicons-plus-circle'
|
||||
icon: 'i-lucide-circle-plus'
|
||||
},
|
||||
{
|
||||
label: 'In Progress',
|
||||
value: 'in_progress',
|
||||
icon: 'i-heroicons-arrow-up-circle'
|
||||
icon: 'i-lucide-circle-arrow-up'
|
||||
},
|
||||
{
|
||||
label: 'Done',
|
||||
value: 'done',
|
||||
icon: 'i-heroicons-check-circle'
|
||||
icon: 'i-lucide-circle-check'
|
||||
}
|
||||
])
|
||||
const value = ref(items.value[0])
|
||||
|
||||
@@ -19,7 +19,7 @@ function getUserAvatar(value: string) {
|
||||
<USelect
|
||||
:items="users || []"
|
||||
:loading="status === 'pending'"
|
||||
icon="i-heroicons-user"
|
||||
icon="i-lucide-user"
|
||||
placeholder="Select user"
|
||||
class="w-48"
|
||||
>
|
||||
|
||||
@@ -3,22 +3,22 @@ const items = ref([
|
||||
{
|
||||
label: 'Backlog',
|
||||
value: 'backlog',
|
||||
icon: 'i-heroicons-question-mark-circle'
|
||||
icon: 'i-lucide-circle-help'
|
||||
},
|
||||
{
|
||||
label: 'Todo',
|
||||
value: 'todo',
|
||||
icon: 'i-heroicons-plus-circle'
|
||||
icon: 'i-lucide-circle-plus'
|
||||
},
|
||||
{
|
||||
label: 'In Progress',
|
||||
value: 'in_progress',
|
||||
icon: 'i-heroicons-arrow-up-circle'
|
||||
icon: 'i-lucide-circle-arrow-up'
|
||||
},
|
||||
{
|
||||
label: 'Done',
|
||||
value: 'done',
|
||||
icon: 'i-heroicons-check-circle'
|
||||
icon: 'i-lucide-circle-check'
|
||||
}
|
||||
])
|
||||
const value = ref(items.value[0]?.value)
|
||||
|
||||
@@ -99,7 +99,7 @@ const columnFilters = ref([{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col flex-1">
|
||||
<div class="flex flex-col flex-1 w-full">
|
||||
<div class="flex px-4 py-3.5 border-b border-[var(--ui-border-accented)]">
|
||||
<UInput
|
||||
:model-value="(table?.tableApi?.getColumn('email')?.getFilterValue() as string)"
|
||||
|
||||
@@ -90,7 +90,7 @@ function getHeader(column: Column<Payment>, label: string, position: 'left' | 'r
|
||||
color: 'neutral',
|
||||
variant: 'ghost',
|
||||
label,
|
||||
icon: isPinned ? 'i-heroicons-star-20-solid' : 'i-heroicons-star',
|
||||
icon: isPinned ? 'i-lucide-pin-off' : 'i-lucide-pin',
|
||||
class: '-mx-2.5',
|
||||
onClick() {
|
||||
column.pin(isPinned === position ? false : position)
|
||||
|
||||
@@ -82,7 +82,7 @@ const columns: TableColumn<Payment>[] = [{
|
||||
color: 'neutral',
|
||||
variant: 'ghost',
|
||||
label: 'Email',
|
||||
icon: isSorted ? (isSorted === 'asc' ? 'i-heroicons-bars-arrow-up-20-solid' : 'i-heroicons-bars-arrow-down-20-solid') : 'i-heroicons-arrows-up-down-20-solid',
|
||||
icon: isSorted ? (isSorted === 'asc' ? 'i-lucide-arrow-up-narrow-wide' : 'i-lucide-arrow-down-wide-narrow') : 'i-lucide-arrow-up-down',
|
||||
class: '-mx-2.5',
|
||||
onClick: () => column.toggleSorting(column.getIsSorted() === 'asc')
|
||||
})
|
||||
|
||||
@@ -103,7 +103,7 @@ function getHeader(column: Column<Payment>, label: string) {
|
||||
items: [{
|
||||
label: 'Asc',
|
||||
type: 'checkbox',
|
||||
icon: 'i-heroicons-bars-arrow-up-20-solid',
|
||||
icon: 'i-lucide-arrow-up-narrow-wide',
|
||||
checked: isSorted === 'asc',
|
||||
onSelect: () => {
|
||||
if (isSorted === 'asc') {
|
||||
@@ -114,7 +114,7 @@ function getHeader(column: Column<Payment>, label: string) {
|
||||
}
|
||||
}, {
|
||||
label: 'Desc',
|
||||
icon: 'i-heroicons-bars-arrow-down-20-solid',
|
||||
icon: 'i-lucide-arrow-down-wide-narrow',
|
||||
type: 'checkbox',
|
||||
checked: isSorted === 'desc',
|
||||
onSelect: () => {
|
||||
@@ -129,7 +129,7 @@ function getHeader(column: Column<Payment>, label: string) {
|
||||
color: 'neutral',
|
||||
variant: 'ghost',
|
||||
label,
|
||||
icon: isSorted ? (isSorted === 'asc' ? 'i-heroicons-bars-arrow-up-20-solid' : 'i-heroicons-bars-arrow-down-20-solid') : 'i-heroicons-arrows-up-down-20-solid',
|
||||
icon: isSorted ? (isSorted === 'asc' ? 'i-lucide-arrow-up-narrow-wide' : 'i-lucide-arrow-down-wide-narrow') : 'i-lucide-arrow-up-down',
|
||||
class: '-mx-2.5 data-[state=open]:bg-[var(--ui-bg-elevated)]'
|
||||
}))
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user