Compare commits

..

2 Commits

Author SHA1 Message Date
Benjamin Canac
49498d53a2 Merge branch 'v3' into feat/update-playground-form 2024-11-12 14:18:35 +01:00
Romain Hamel
8b975de35e feat(playground): update form examples 2024-11-12 13:44:09 +01:00
453 changed files with 15113 additions and 39547 deletions

View File

@@ -28,7 +28,7 @@ body:
id: version id: version
attributes: attributes:
label: Version label: Version
placeholder: v2.20.0 placeholder: v2.8.0
validations: validations:
required: true required: true
- type: textarea - type: textarea

View File

@@ -2,6 +2,11 @@ name: "🐛 Bug report (v3)"
description: Report a bug to help us improve the module (v3 only). description: Report a bug to help us improve the module (v3 only).
labels: ["triage", "bug", "v3"] labels: ["triage", "bug", "v3"]
body: body:
- type: markdown
attributes:
value: |
> [!IMPORTANT]
> As Nuxt UI v3 is currently in alpha, we recommend thorough testing before using it in production environments. We're actively working on stabilization and welcome feedback from early adopters to improve the library.
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
@@ -44,7 +49,7 @@ body:
id: reproduction id: reproduction
attributes: attributes:
label: Reproduction label: Reproduction
description: Please provide a reproduction link using the Nuxt template https://codesandbox.io/p/devbox/nuxt-ui3-n3sxks or the Vue template https://codesandbox.io/p/devbox/nuxt-ui3-vue-4h5gqn. A minimal [reproduction is required](https://antfu.me/posts/why-reproductions-are-required) unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "needs reproduction" label. If no reproduction is provided we might close it. description: Please provide a reproduction link. A minimal [reproduction is required](https://antfu.me/posts/why-reproductions-are-required) unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "needs reproduction" label. If no reproduction is provided we might close it.
placeholder: https://github.com/my/reproduction placeholder: https://github.com/my/reproduction
validations: validations:
required: true required: true

View File

@@ -1,20 +0,0 @@
name: "🚀 Feature request (v3)"
description: Suggest an idea or enhancement for the module (v3 only).
labels: ["triage", "enhancement", "v3"]
body:
- type: markdown
attributes:
value: |
Before requesting a feature, please make sure that you have read through our [v3 documentation](https://ui3.nuxt.dev/) and existing [issues](https://github.com/nuxt/ui/issues?q=is%3Aissue%20is%3Aopen%20sort%3Aupdated-desc%20label%3Av3).
- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of what you think would be an helpful addition to the module, including the possible use cases and alternatives you have considered. If you have a working prototype or module that implements it, please include a link.
validations:
required: true
- type: textarea
id: additonal
attributes:
label: Additional context
description: If applicable, add any other context or screenshots here.

View File

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

View File

@@ -1,14 +0,0 @@
name: "💬 Question (v3)"
description: Ask a question about the module (v3 only).
labels: ["question", "v3"]
body:
- type: markdown
attributes:
value: |
Before asking a question, please make sure that you have read through our [v3 documentation](https://ui3.nuxt.dev/) and existing [issues](https://github.com/nuxt/ui/issues?q=is%3Aissue%20is%3Aopen%20sort%3Aupdated-desc%20label%3Av3).
- type: textarea
id: description
attributes:
label: Description
validations:
required: true

View File

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

View File

@@ -1,4 +1,4 @@
name: module name: ci-v3
on: on:
push: push:
@@ -9,7 +9,7 @@ on:
- v3 - v3
jobs: jobs:
build: ci:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
@@ -19,7 +19,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] # macos-latest, windows-latest os: [ubuntu-latest] # macos-latest, windows-latest
node: [22] node: [20]
env: env:
NUXT_GITHUB_TOKEN: ${{ secrets.NUXT_GITHUB_TOKEN }} NUXT_GITHUB_TOKEN: ${{ secrets.NUXT_GITHUB_TOKEN }}
@@ -61,8 +61,5 @@ jobs:
- name: Build - name: Build
run: pnpm run build run: pnpm run build
- name: Build vue fixture
run: pnpm run test:vue:build
- name: Publish - name: Publish
run: pnpx pkg-pr-new publish --compact --no-template --pnpm run: pnpx pkg-pr-new publish --compact --no-template --pnpm

View File

@@ -1,57 +0,0 @@
name: docs
on:
push:
branches:
- v3
pull_request:
branches:
- v3
jobs:
deploy:
runs-on: ${{ matrix.os }}
environment:
name: ${{ github.ref == 'refs/heads/v3' && 'production' || 'preview' }}
url: ${{ steps.deploy.outputs.deployment-url }}
permissions:
contents: read
id-token: write
strategy:
matrix:
os: [ubuntu-latest] # macos-latest, windows-latest
node: [22]
env:
NUXT_GITHUB_TOKEN: ${{ secrets.NUXT_GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Prepare build
run: pnpm run dev:prepare
- name: Build application
run: pnpm run docs:build
- name: Deploy to NuxtHub
uses: nuxt-hub/action@v1
id: deploy
with:
project-key: ui-7eg3
directory: docs/dist

View File

@@ -1,53 +0,0 @@
name: playground
on:
push:
branches:
- v3
jobs:
deploy:
runs-on: ${{ matrix.os }}
environment:
name: ${{ github.ref == 'refs/heads/v3' && 'production' || 'preview' }}
url: ${{ steps.deploy.outputs.deployment-url }}
permissions:
contents: read
id-token: write
strategy:
matrix:
os: [ubuntu-latest] # macos-latest, windows-latest
node: [22]
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Prepare build
run: pnpm run dev:prepare
- name: Build application
run: pnpm run dev:build
env:
NITRO_PRESET: cloudflare-pages
- name: Deploy to NuxtHub
uses: nuxt-hub/action@v1
id: deploy
with:
project-key: ui3-playground-pb9b
directory: playground/dist

View File

@@ -1,173 +1,5 @@
# Changelog # Changelog
## [3.0.0-alpha.11](https://github.com/nuxt/ui/compare/v3.0.0-alpha.10...v3.0.0-alpha.11) (2025-01-13)
### ⚠ BREAKING CHANGES
* **Modal/Popover/Slideover:** rename `prevent-close` to `dismissible` + uniformize docs
### Features
* **Badge:** rework sizes ([d9967f5](https://github.com/nuxt/ui/commit/d9967f5e282d41f4000d5451efed7254b4c1608c))
* **CommandPalette:** add `autofocus` prop ([#2942](https://github.com/nuxt/ui/issues/2942)) ([1b3c919](https://github.com/nuxt/ui/commit/1b3c919222a4002d84dd968f93bcf9d615e412bc))
* **locale:** add Danish language ([#2952](https://github.com/nuxt/ui/issues/2952)) ([e1d385a](https://github.com/nuxt/ui/commit/e1d385a17545f8091c8d2459842fe4c39b8c9399))
* **locale:** add Estonian language ([#3036](https://github.com/nuxt/ui/issues/3036)) ([01bf99e](https://github.com/nuxt/ui/commit/01bf99eec8c2fd0e3dbe1271be152844e401287a))
* **locale:** add Finnish language ([#3013](https://github.com/nuxt/ui/issues/3013)) ([c770ae1](https://github.com/nuxt/ui/commit/c770ae124e626682935475dc6a164aacd1408c01))
* **locale:** add Greek language ([#2975](https://github.com/nuxt/ui/issues/2975)) ([b326a14](https://github.com/nuxt/ui/commit/b326a14fb0e62edc8e55599c16f934f54f95aa42))
* **locale:** add Indonesian language ([#3024](https://github.com/nuxt/ui/issues/3024)) ([a18ad84](https://github.com/nuxt/ui/commit/a18ad84edfe6b3f444d379f24defeecb63e5cdb9))
* **locale:** add Swedish language ([#3012](https://github.com/nuxt/ui/issues/3012)) ([0201a3d](https://github.com/nuxt/ui/commit/0201a3de757db426c877ef2761de8e9d7493983e))
* **locale:** add Thai language ([#2980](https://github.com/nuxt/ui/issues/2980)) ([c8cd06e](https://github.com/nuxt/ui/commit/c8cd06e92dab208271ab7b7f6806793eea1e8969))
* **locale:** add Ukrainian language ([#2908](https://github.com/nuxt/ui/issues/2908)) ([5efae59](https://github.com/nuxt/ui/commit/5efae599b642e65ec8ccaf2361b69abe993a0173))
* **locale:** add Viet language ([#2986](https://github.com/nuxt/ui/issues/2986)) ([ffba108](https://github.com/nuxt/ui/commit/ffba108291f321471650ca9060ea264f41482648))
* **module:** allow `tv` customization through `app.config` ([#2938](https://github.com/nuxt/ui/issues/2938)) ([30ba53e](https://github.com/nuxt/ui/commit/30ba53e20b3b91909c2c8162f35b13b6ad305d13))
### Bug Fixes
* **Accordion/Collapsible/NavigationMenu/Tabs:** define `unmountOnHide` default ([4344e36](https://github.com/nuxt/ui/commit/4344e366647e9618c21fe800b43d2b4ae2611226))
* **Avatar:** bind `$attrs` on `AvatarFallback` ([#2933](https://github.com/nuxt/ui/issues/2933)) ([7f64198](https://github.com/nuxt/ui/commit/7f64198a70104436f39f2f9d8527df0508fd84f6))
* **Badge:** reduce radius on `sm` size ([f97d2e3](https://github.com/nuxt/ui/commit/f97d2e3b88d1ba9be5f7e2916c6502e38ac4d4c1))
* **CommandPalette/SelectMenu:** missing translations ([#3057](https://github.com/nuxt/ui/issues/3057)) ([d5dba0e](https://github.com/nuxt/ui/commit/d5dba0ebc98594906ef1d9428da11d44317b70fc))
* **components:** enable pointer events on menus ([#2881](https://github.com/nuxt/ui/issues/2881)) ([f85b098](https://github.com/nuxt/ui/commit/f85b0985bdd6f51aff41acc6f86dd02db9832b24))
* **defineShortcuts:** handle extract when using `onSelect` or `onClick` ([#2896](https://github.com/nuxt/ui/issues/2896)) ([2e17fb6](https://github.com/nuxt/ui/commit/2e17fb68dee7e7bb27750c816d27b62249a1247b))
* **DropdownMenu/ContextMenu:** correct bindings of `checkbox` items ([#2921](https://github.com/nuxt/ui/issues/2921)) ([4c5a4fb](https://github.com/nuxt/ui/commit/4c5a4fb5265c36a39e551b8ee43b86e9ebd3d064))
* **FormField:** restore `eager-validation` prop behavior ([#3031](https://github.com/nuxt/ui/issues/3031)) ([41dc11c](https://github.com/nuxt/ui/commit/41dc11ceefd8f505fbc5214fe61f12483b0da4a2))
* **InputMenu:** removing `tag` does not change `modelValue` ([#3054](https://github.com/nuxt/ui/issues/3054)) ([5a44394](https://github.com/nuxt/ui/commit/5a443944ae622c8f4a893e0a18a80026ea9c1fe0))
* **locale:** improve Traditional Chinese translation ([#3051](https://github.com/nuxt/ui/issues/3051)) ([5c2c55f](https://github.com/nuxt/ui/commit/5c2c55ff08fbc16c869ad382e5fe5ac9fcc791de))
* **Modal/Popover/Slideover:** rename `prevent-close` to `dismissible` + uniformize docs ([6fb426f](https://github.com/nuxt/ui/commit/6fb426fc17d6d524e7d0503c2c8f3610f60b954d))
* **NavigationMenu:** `arrow` styles after `reka-ui` migration ([9759320](https://github.com/nuxt/ui/commit/97593204384669c479b85932024317a300ce29d8))
* **NavigationMenu:** highlight border on children only with `vertical` orientation ([e931880](https://github.com/nuxt/ui/commit/e93188067172d357a7724f937aeec70a0dabe611))
* **NavigationMenu:** remove `w-full` on root slot ([ef7ecd2](https://github.com/nuxt/ui/commit/ef7ecd242f4550838dbe3a45e33855afff89f506)), closes [#3000](https://github.com/nuxt/ui/issues/3000)
* **NavigationMenu:** unbind link on collapsible trigger with `vertical` orientation ([82d6344](https://github.com/nuxt/ui/commit/82d63446a12445accbca9131a83806994631761b))
* **SelectMenu:** handle `resetSearchTermOnBlur` manually ([#3082](https://github.com/nuxt/ui/issues/3082)) ([c902a40](https://github.com/nuxt/ui/commit/c902a40f7c0ce5ceb4624bbe2bbdfa09c87f7c75))
* **Stepper:** correct item `value` type ([4f05b1a](https://github.com/nuxt/ui/commit/4f05b1aac9af096cdc9404395d25d2261522a1db))
* **Stepper:** wrong `item` in `title` & `description` slots ([473194f](https://github.com/nuxt/ui/commit/473194fbaf2a9d21e2acb67d16715c412528d7d2)), closes [#2888](https://github.com/nuxt/ui/issues/2888)
* **templates:** allow any string in colors autocomplete ([5183582](https://github.com/nuxt/ui/commit/5183582a90c0d86bd986ef0f280bc58e740c6458)), closes [#2143](https://github.com/nuxt/ui/issues/2143)
* **templates:** infer variants types in generated theme ([2c99bb8](https://github.com/nuxt/ui/commit/2c99bb80c72fdbde9cd2ff3ad7caae0be632b864))
* **unplugin:** invalid url schema on windows ([#2899](https://github.com/nuxt/ui/issues/2899)) ([9b4694f](https://github.com/nuxt/ui/commit/9b4694f8d9b0fc244e805a7bfb2795d5131f7d18))
* **vue:** head injection ([#2929](https://github.com/nuxt/ui/issues/2929)) ([7302a84](https://github.com/nuxt/ui/commit/7302a846a9c394373c47def12dca00274e58f269))
### Reverts
* Revert "chore(deps): update `typescript`" ([3107039](https://github.com/nuxt/ui/commit/3107039b560cef973c117a251e4407ca5e615a72))
* Revert "chore(deps): update `@nuxt/module-builder`" ([c79acc1](https://github.com/nuxt/ui/commit/c79acc15b00f23b189821ebe2f4430e900cac34f))
* Revert "build: remove `cjs` support" ([15b411d](https://github.com/nuxt/ui/commit/15b411de4a6a7d322a3dea5703a5a5464c4e709a))
## [3.0.0-alpha.10](https://github.com/nuxt/ui/compare/v3.0.0-alpha.9...v3.0.0-alpha.10) (2024-12-09)
### ⚠ BREAKING CHANGES
* **module:** migrate to `reka-ui` (#2448)
* **Form:** resolve async validation in yup & issue directly mutate state (#2702)
### Features
* **Avatar:** add `default` slot for fallback ([b741ef3](https://github.com/nuxt/ui/commit/b741ef3313bb894beaed0eaa7323ee3d951bf935))
* **Calendar:** add `icon` props ([#2778](https://github.com/nuxt/ui/issues/2778)) ([0f64802](https://github.com/nuxt/ui/commit/0f648024e0468d34c1499bb5b5d2ed32e0e7de4f))
* **Calendar:** implement component ([#2618](https://github.com/nuxt/ui/issues/2618)) ([2e9aeb5](https://github.com/nuxt/ui/commit/2e9aeb5f05e94d63ea453c4f07a3e84ee2a02773))
* **ColorPicker:** implement component ([#2670](https://github.com/nuxt/ui/issues/2670)) ([e475b64](https://github.com/nuxt/ui/commit/e475b6438d405e4695ffb19155d456534d16b897))
* **CommandPalette:** add `active` field on items for consistency ([3765537](https://github.com/nuxt/ui/commit/37655377e9675982e2fce422bdd79ea651424548))
* **css:** use `color-scheme` utilities on body ([a2512f6](https://github.com/nuxt/ui/commit/a2512f680dc0df7add48bc17ef3be30d579be782))
* **i18n:** add Dutch locale ([#2728](https://github.com/nuxt/ui/issues/2728)) ([3baddfd](https://github.com/nuxt/ui/commit/3baddfd12186a68cc302f31cf0934cb9cf48060d))
* **i18n:** add Turkish locale ([#2716](https://github.com/nuxt/ui/issues/2716)) ([de8228e](https://github.com/nuxt/ui/commit/de8228e504affd1a57106101f5168a33702d4d53))
* **locale:** add Brazilian Portuguese language ([#2825](https://github.com/nuxt/ui/issues/2825)) ([b7ff7d8](https://github.com/nuxt/ui/commit/b7ff7d8aa63c41cf7afbecaa31824e098ea291af))
* **locale:** add Japanese language ([#2794](https://github.com/nuxt/ui/issues/2794)) ([ecc4755](https://github.com/nuxt/ui/commit/ecc4755a17874e59e06e70307a40dfd3fb3f20a0))
* **locale:** add Portuguese language ([#2855](https://github.com/nuxt/ui/issues/2855)) ([8b5d412](https://github.com/nuxt/ui/commit/8b5d412fd70b14a53cffa9129f5edd8a40e0f2e8))
* **locale:** add Slovak language ([#2821](https://github.com/nuxt/ui/issues/2821)) ([68a10f0](https://github.com/nuxt/ui/commit/68a10f09d5f164f2f5f07e65297e29fa2d939425))
* **locale:** translate Korean ([#2703](https://github.com/nuxt/ui/issues/2703)) ([2cbf83e](https://github.com/nuxt/ui/commit/2cbf83eb8484ad9abebd6ca01ad344918570af5b))
* **module:** migrate to `reka-ui` ([#2448](https://github.com/nuxt/ui/issues/2448)) ([81ac076](https://github.com/nuxt/ui/commit/81ac076219c3d7ef151f641414a0fbeca2da0bdd))
* **NavigationMenu:** handle `item.trailingIcon` display ([4b653ef](https://github.com/nuxt/ui/commit/4b653ef7735d9d2dfea65260433ade05eb3d3bd7))
* **Stepper:** new component ([#2733](https://github.com/nuxt/ui/issues/2733)) ([6484d01](https://github.com/nuxt/ui/commit/6484d010a1eee6f5d86968e4701b945953089b17))
* **Table:** handle `meta.class` on `th` and `td` ([#2790](https://github.com/nuxt/ui/issues/2790)) ([004a577](https://github.com/nuxt/ui/commit/004a5774678da24ccc267e96697c6088c51d5eea))
### Bug Fixes
* **Breadcrumb:** missing `aria-hidden` on presentation items ([a7a1227](https://github.com/nuxt/ui/commit/a7a1227c93110727e24f822fa50b547eb66bb16e)), closes [#2725](https://github.com/nuxt/ui/issues/2725)
* **Calendar:** handle icons in RTL mode ([#2770](https://github.com/nuxt/ui/issues/2770)) ([e7b69b7](https://github.com/nuxt/ui/commit/e7b69b7d6f0ebb3c578b9f58bcddf8ad36e6c6ce))
* **Calendar:** omit `as` / `asChild` props ([9478fc0](https://github.com/nuxt/ui/commit/9478fc076846d4a7fef13e63bdc274cd8d161063))
* **ColorPicker:** handle RTL mode ([#2858](https://github.com/nuxt/ui/issues/2858)) ([f98b91c](https://github.com/nuxt/ui/commit/f98b91c22ae21071a25f69cc8682eb6197a54c5a))
* **CommandPalette:** keep `ignoreFilter` groups at their place ([#2833](https://github.com/nuxt/ui/issues/2833)) ([3b9ca22](https://github.com/nuxt/ui/commit/3b9ca2263de1b936639b1b20ad0baf1cb059fda5))
* **components:** apply class on `trigger` instead of `content` when present ([a6ecef0](https://github.com/nuxt/ui/commit/a6ecef0f0d87a8dff4e4cb9ec507058ec94ed82b)), closes [#2132](https://github.com/nuxt/ui/issues/2132)
* **components:** specify collisionPadding to all menus ([148b024](https://github.com/nuxt/ui/commit/148b02464d47ada421313327585924b17f4e3f2d))
* **ContextMenu:** remove close animation ([#2798](https://github.com/nuxt/ui/issues/2798)) ([ed27222](https://github.com/nuxt/ui/commit/ed2722257a22c770eda811fbad58980bcef9dad5))
* **defineShortcuts:** return `useEventListener` to unregister the listener ([80befc1](https://github.com/nuxt/ui/commit/80befc107c6c6e7ab99dbe12376976babf315158)), closes [#2031](https://github.com/nuxt/ui/issues/2031)
* **devtools:** error with renderer when `colorMode` is disabled ([#2792](https://github.com/nuxt/ui/issues/2792)) ([f06fbaf](https://github.com/nuxt/ui/commit/f06fbafc1e709c7b4e54e2ba40d44c5770685a5d))
* **Form:** resolve async validation in yup & issue directly mutate state ([#2702](https://github.com/nuxt/ui/issues/2702)) ([c9806da](https://github.com/nuxt/ui/commit/c9806da6d850ea50ff8d2f11a1fbc5a43459b71f))
* **icons:** make `loading` icon clockwise ([#2797](https://github.com/nuxt/ui/issues/2797)) ([bc2bcb3](https://github.com/nuxt/ui/commit/bc2bcb30d97e2e873c4c7d535f82a4980cd35b02))
* **Link:** partial query match for Vue ([#2787](https://github.com/nuxt/ui/issues/2787)) ([a6c2205](https://github.com/nuxt/ui/commit/a6c22052e1c70e4ce6b2c7f783667a7f8c6cafa4))
* **locale:** improve German translation ([#2826](https://github.com/nuxt/ui/issues/2826)) ([c440c91](https://github.com/nuxt/ui/commit/c440c91a29fc1acd281a7f9d9b0cf74f5341553d))
* **Modal:** prevent from going out of screen ([b7ba2c7](https://github.com/nuxt/ui/commit/b7ba2c7759485ddb0a8bae589e4b6536ac9b1c96)), closes [#2711](https://github.com/nuxt/ui/issues/2711)
* **NavigationMenu:** wrong badge class ([86f2b48](https://github.com/nuxt/ui/commit/86f2b4856cc6beaf0440795500a5c74f9af04f36)), closes [#2766](https://github.com/nuxt/ui/issues/2766)
* **Progress:** handle `horizontal` animation in RTL mode ([#2723](https://github.com/nuxt/ui/issues/2723)) ([0baa3a0](https://github.com/nuxt/ui/commit/0baa3a06d449ab97093c451bd16215cf83c39447))
* **Stepper:** handle RTL mode ([#2844](https://github.com/nuxt/ui/issues/2844)) ([198d04d](https://github.com/nuxt/ui/commit/198d04de51d16ec7fcaa546370e4f67aa73bfee0))
* **Stepper:** missing import ([816bb69](https://github.com/nuxt/ui/commit/816bb69debdbf83f36c3ed3627985142e62b7dd1))
* **Table:** handle `loading` animation in RTL mode ([#2771](https://github.com/nuxt/ui/issues/2771)) ([b1550d5](https://github.com/nuxt/ui/commit/b1550d58adfeb09977619ad3ff7e776782a89603))
* **Tabs:** prevent hover on disabled ([a938d24](https://github.com/nuxt/ui/commit/a938d24f90431494c2da89411c301a228ab8d3f7))
* **Tabs:** truncate not working ([c1ff978](https://github.com/nuxt/ui/commit/c1ff978370fb343950837b380ccf02a33db53ccb))
* **types:** handle array of strings in AppConfig ([#2854](https://github.com/nuxt/ui/issues/2854)) ([4b241ba](https://github.com/nuxt/ui/commit/4b241ba3c32f4456252768b664488799a8278f0e))
* **useLocale:** update locale import to enable tree shaking ([#2735](https://github.com/nuxt/ui/issues/2735)) ([3bccb67](https://github.com/nuxt/ui/commit/3bccb6782a601e686df5d0ee405d738572f182e1))
## [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) ## [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 ### ⚠ BREAKING CHANGES

View File

@@ -1,4 +1,4 @@
[![nuxt-ui.png](https://volta.s3.fr-par.scw.cloud/nuxt_ui_social_card_531d133fa2.png)](https://ui.nuxt.com) [![nuxt-ui.png](https://repository-images.githubusercontent.com/428329515/43fec891-9030-4601-8233-5d45ba5c6013)](https://ui.nuxt.com)
# Nuxt UI # Nuxt UI
@@ -7,10 +7,10 @@
[![License][license-src]][license-href] [![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href] [![Nuxt][nuxt-src]][nuxt-href]
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 [Reka UI](https://reka-ui.com/), [Tailwind CSS v4](https://tailwindcss.com/docs/v4-beta), 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. 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.
> [!NOTE] > [!NOTE]
> You are on the `v3` development branch, check out the [dev branch](https://github.com/nuxt/ui/tree/dev) for Nuxt UI v2. > You are on the `v3` development branch, check out the [dev branch](https://github.com/nuxt/ui) for Nuxt UI v2.
## Documentation ## Documentation
@@ -74,18 +74,11 @@ export default defineConfig({
```ts [main.ts] ```ts [main.ts]
import { createApp } from 'vue' import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ui from '@nuxt/ui/vue-plugin' import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue' import App from './App.vue'
const app = createApp(App) const app = createApp(App)
const router = createRouter({
routes: [],
history: createWebHistory()
})
app.use(router)
app.use(ui) app.use(ui)
app.mount('#app') app.mount('#app')
@@ -106,13 +99,13 @@ Learn more in the [installation guide](https://ui3.nuxt.dev/getting-started/inst
- [nuxt/icon](https://github.com/nuxt/icon) - [nuxt/icon](https://github.com/nuxt/icon)
- [nuxt/fonts](https://github.com/nuxt/fonts) - [nuxt/fonts](https://github.com/nuxt/fonts)
- [nuxt-modules/color-mode](https://github.com/nuxt-modules/color-mode) - [nuxt-modules/color-mode](https://github.com/nuxt-modules/color-mode)
- [unovue/reka-ui](https://github.com/unovue/reka-ui) - [radix-vue/radix-vue](https://github.com/radix-vue/radix-vue)
- [tailwindlabs/tailwindcss](https://github.com/tailwindlabs/tailwindcss) - [tailwindlabs/tailwindcss](https://github.com/tailwindlabs/tailwindcss)
- [vueuse/vueuse](https://github.com/vueuse/vueuse) - [vueuse/vueuse](https://github.com/vueuse/vueuse)
## License ## License
Licensed under the [MIT license](https://github.com/nuxt/ui/blob/v3/LICENSE.md). Licensed under the [MIT license](https://github.com/nuxt/ui/blob/dev/LICENSE.md).
<!-- Badges --> <!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@nuxt/ui/next.svg?style=flat&colorA=18181B&colorB=28CF8D [npm-version-src]: https://img.shields.io/npm/v/@nuxt/ui/next.svg?style=flat&colorA=18181B&colorB=28CF8D
@@ -122,7 +115,7 @@ Licensed under the [MIT license](https://github.com/nuxt/ui/blob/v3/LICENSE.md).
[npm-downloads-href]: https://npm.chart.dev/@nuxt/ui [npm-downloads-href]: https://npm.chart.dev/@nuxt/ui
[license-src]: https://img.shields.io/github/license/nuxt/ui.svg?style=flat&colorA=18181B&colorB=28CF8D [license-src]: https://img.shields.io/github/license/nuxt/ui.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://github.com/nuxt/ui/blob/v3/LICENSE.md [license-href]: https://github.com/nuxt/ui/blob/main/LICENSE.md
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com [nuxt-href]: https://nuxt.com

View File

@@ -32,10 +32,6 @@ export default defineCommand({
content: { content: {
type: 'boolean', type: 'boolean',
description: 'Create a content component (with --pro).' description: 'Create a content component (with --pro).'
},
template: {
type: 'string',
description: 'Only generate template.'
} }
}, },
async setup({ args }) { async setup({ args }) {
@@ -57,10 +53,6 @@ export default defineCommand({
const path = resolve('.') const path = resolve('.')
for (const template of Object.keys(templates)) { for (const template of Object.keys(templates)) {
if (args.template && template !== args.template) {
continue
}
const { filename, contents } = templates[template](args) const { filename, contents } = templates[template](args)
if (!contents) { if (!contents) {
continue continue
@@ -78,10 +70,6 @@ export default defineCommand({
consola.success(`🪄 Generated ${filePath}!`) consola.success(`🪄 Generated ${filePath}!`)
} }
if (args.template) {
return
}
const themePath = resolve(path, `src/theme/${args.prose ? 'prose/' : ''}${args.content ? 'content/' : ''}index.ts`) const themePath = resolve(path, `src/theme/${args.prose ? 'prose/' : ''}${args.content ? 'content/' : ''}index.ts`)
await appendFile(themePath, `export { default as ${camelCase(name)} } from './${kebabCase(name)}'`) await appendFile(themePath, `export { default as ${camelCase(name)} } from './${kebabCase(name)}'`)
await sortFile(themePath) await sortFile(themePath)

View File

@@ -17,10 +17,6 @@ export default defineCommand({
name: { name: {
description: 'Locale name to create. For example: English.', description: 'Locale name to create. For example: English.',
required: true required: true
},
dir: {
description: 'Locale direction. For example: rtl.',
default: 'ltr'
} }
}, },
async setup({ args }) { async setup({ args }) {
@@ -36,11 +32,6 @@ export default defineCommand({
process.exit(1) 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})?$/)) { 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`) consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`)
process.exit(1) process.exit(1)
@@ -54,9 +45,7 @@ export default defineCommand({
// Create new locale file // Create new locale file
await fsp.copyFile(originLocaleFilePath, newLocaleFilePath) await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8') const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
const rewrittenLocaleFile = localeFile const rewrittenLocaleFile = localeFile.replace(/defineLocale\('(.*)'/, `defineLocale('${args.name}', '${normalizeLocale(args.code)}'`)
.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) await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
consola.success(`🪄 Generated ${newLocaleFilePath}`) consola.success(`🪄 Generated ${newLocaleFilePath}`)

View File

@@ -6,8 +6,8 @@
}, },
"dependencies": { "dependencies": {
"citty": "^0.1.6", "citty": "^0.1.6",
"consola": "^3.3.3", "consola": "^3.2.3",
"pathe": "^2.0.1", "pathe": "^1.1.2",
"scule": "^1.3.0" "scule": "^1.3.0"
} }
} }

View File

@@ -30,10 +30,10 @@ const component = ({ name, primitive, pro, prose, content }) => {
contents: primitive contents: primitive
? ` ? `
<script lang="ts"> <script lang="ts">
import { tv } from 'tailwind-variants'
import type { AppConfig } from '@nuxt/schema' import type { AppConfig } from '@nuxt/schema'
import _appConfig from '#build/app.config' import _appConfig from '#build/app.config'
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}' import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
import { tv } from '${pro ? '#ui/utils/tv' : '../utils/tv'}'
const appConfig = _appConfig as AppConfig & { ${key}: { ${prose ? 'prose: { ' : ''}${camelName}: Partial<typeof theme> } }${prose ? ' }' : ''} const appConfig = _appConfig as AppConfig & { ${key}: { ${prose ? 'prose: { ' : ''}${camelName}: Partial<typeof theme> } }${prose ? ' }' : ''}
@@ -55,9 +55,9 @@ export interface ${upperName}Slots {
</script> </script>
<script setup lang="ts"> <script setup lang="ts">
import { Primitive } from 'reka-ui' import { Primitive } from 'radix-vue'
const props = defineProps<${upperName}Props>() const props = withDefaults(defineProps<${upperName}Props>(), { as: 'div' })
defineSlots<${upperName}Slots>() defineSlots<${upperName}Slots>()
const ui = ${camelName}() const ui = ${camelName}()
@@ -71,12 +71,11 @@ const ui = ${camelName}()
` `
: ` : `
<script lang="ts"> <script lang="ts">
import type { VariantProps } from 'tailwind-variants' import { tv, type VariantProps } from 'tailwind-variants'
import type { ${upperName}RootProps, ${upperName}RootEmits } from 'reka-ui' import type { ${upperName}RootProps, ${upperName}RootEmits } from 'radix-vue'
import type { AppConfig } from '@nuxt/schema' import type { AppConfig } from '@nuxt/schema'
import _appConfig from '#build/app.config' import _appConfig from '#build/app.config'
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}' import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
import { tv } from '${pro ? '#ui/utils/tv' : '../utils/tv'}'
const appConfig = _appConfig as AppConfig & { ${key}: { ${prose ? 'prose: { ' : ''}${camelName}: Partial<typeof theme> } }${prose ? ' }' : ''} const appConfig = _appConfig as AppConfig & { ${key}: { ${prose ? 'prose: { ' : ''}${camelName}: Partial<typeof theme> } }${prose ? ' }' : ''}
@@ -95,7 +94,7 @@ export interface ${upperName}Slots {}
</script> </script>
<script setup lang="ts"> <script setup lang="ts">
import { ${upperName}Root, useForwardPropsEmits } from 'reka-ui' import { ${upperName}Root, useForwardPropsEmits } from 'radix-vue'
import { reactivePick } from '@vueuse/core' import { reactivePick } from '@vueuse/core'
const props = defineProps<${upperName}Props>() const props = defineProps<${upperName}Props>()
@@ -150,7 +149,7 @@ import ComponentRender from '../${content ? '../' : ''}component-render'
describe('${upperName}', () => { describe('${upperName}', () => {
it.each([ it.each([
// Props // Props
['with as', { props: { as: 'section' } }], ['with as', { props: { as: 'div' } }],
['with class', { props: { class: '' } }], ['with class', { props: { class: '' } }],
['with ui', { props: { ui: {} } }], ['with ui', { props: { ui: {} } }],
// Slots // Slots
@@ -164,58 +163,9 @@ describe('${upperName}', () => {
} }
} }
const docs = ({ name, pro, primitive }) => {
const kebabName = kebabCase(name)
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
return {
filename: `docs/content/3.components/${kebabName}.md`,
contents: `---
title: ${upperName}
description: ''${pro
? `
module: ui-pro`
: ''}
links:${primitive
? ''
: `
- label: ${upperName}
icon: i-custom-reka-ui
to: https://www.reka-ui.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${pro ? '{pro}' : ''}
### Slots
:component-slots${pro ? '{pro}' : ''}
### Emits
:component-emits${pro ? '{pro}' : ''}
## Theme
:component-theme${pro ? '{pro}' : ''}
`
}
}
export default { export default {
playground, playground,
component, component,
theme, theme,
test, test
docs
} }

View File

@@ -168,7 +168,7 @@ const isDark = computed({
@import '@nuxt/ui'; @import '@nuxt/ui';
@theme { @theme {
--font-sans: 'DM Sans', sans-serif; --font-family-sans: 'DM Sans', sans-serif;
--color-primary-50: var(--ui-color-primary-50); --color-primary-50: var(--ui-color-primary-50);
--color-primary-100: var(--ui-color-primary-100); --color-primary-100: var(--ui-color-primary-100);

View File

@@ -43,9 +43,9 @@ const code = computed(() => {
const slotsTemplate = props.themeSlots const slotsTemplate = props.themeSlots
? genPropValue(Object.keys(props.themeSlots).filter(key => key !== 'base').reduce((acc, key) => { ? genPropValue(Object.keys(props.themeSlots).filter(key => key !== 'base').reduce((acc, key) => {
acc[key] = genPropValue(props.themeSlots?.[key]) acc[key] = genPropValue(props.themeSlots?.[key])
return acc return acc
}, {} as Record<string, string>)) }, {} as Record<string, string>))
: undefined : undefined
const extraTemplate = [ const extraTemplate = [

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import * as z from 'zod' import { z } from 'zod'
export const arrayInputSchema = z.object({ export const arrayInputSchema = z.object({
kind: z.literal('array'), kind: z.literal('array'),

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import * as z from 'zod' import { z } from 'zod'
export const booleanInputSchema = z.literal('boolean').or(z.object({ export const booleanInputSchema = z.literal('boolean').or(z.object({
kind: z.literal('enum'), kind: z.literal('enum'),

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import * as z from 'zod' import { z } from 'zod'
export const numberInputSchema = z.literal('number') export const numberInputSchema = z.literal('number')
export type NumberInputSchema = z.infer<typeof numberInputSchema> export type NumberInputSchema = z.infer<typeof numberInputSchema>

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import * as z from 'zod' import { z } from 'zod'
export const objectInputSchema = z.object({ export const objectInputSchema = z.object({
kind: z.literal('object'), kind: z.literal('object'),

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import * as z from 'zod' import { z } from 'zod'
export const stringEnumInputSchema = z.object({ export const stringEnumInputSchema = z.object({
kind: z.literal('enum'), kind: z.literal('enum'),

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import * as z from 'zod' 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 const stringInputSchema = z.literal('string').or(z.string().transform(t => t.split('|').find(s => s.trim() === 'string')).pipe(z.string()))

View File

@@ -11,9 +11,9 @@
}, },
"dependencies": { "dependencies": {
"@nuxt/ui": "latest", "@nuxt/ui": "latest",
"knitwork": "^1.2.0", "knitwork": "^1.1.0",
"nuxt": "^3.15.1", "nuxt": "^3.14.159",
"prettier": "^3.4.2", "prettier": "^3.3.3",
"zod": "^3.24.1" "zod": "^3.23.8"
} }
} }

View File

@@ -7,7 +7,7 @@ const route = useRoute()
const appConfig = useAppConfig() const appConfig = useAppConfig()
const colorMode = useColorMode() const colorMode = useColorMode()
const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('content', ['framework', 'module'])) const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('content'))
const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('content'), { const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('content'), {
server: false server: false
}) })
@@ -73,10 +73,24 @@ useServerSeoMeta({
twitterCard: 'summary_large_image' twitterCard: 'summary_large_image'
}) })
const { frameworks, modules } = useSharedData() const updatedNavigation = computed(() => navigation.value?.map(item => ({
const { mappedNavigation, filteredNavigation } = useContentNavigation(navigation) ...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', mappedNavigation) provide('navigation', updatedNavigation)
</script> </script>
<template> <template>
@@ -84,7 +98,7 @@ provide('navigation', mappedNavigation)
<NuxtLoadingIndicator color="#FFF" /> <NuxtLoadingIndicator color="#FFF" />
<template v-if="!route.path.startsWith('/examples')"> <template v-if="!route.path.startsWith('/examples')">
<!-- <Banner /> --> <Banner />
<Header :links="links" /> <Header :links="links" />
</template> </template>
@@ -94,24 +108,10 @@ provide('navigation', mappedNavigation)
</NuxtLayout> </NuxtLayout>
<template v-if="!route.path.startsWith('/examples')"> <template v-if="!route.path.startsWith('/examples')">
<!-- <Footer /> --> <Footer />
<ClientOnly> <ClientOnly>
<LazyUContentSearch <LazyUContentSearch v-model:search-term="searchTerm" :files="files" :navigation="navigation" :fuse="{ resultLimit: 42 }" />
v-model:search-term="searchTerm"
:files="files"
:groups="[{
id: 'framework',
label: 'Framework',
items: frameworks
}, {
id: 'module',
label: 'Module',
items: modules
}]"
:navigation="filteredNavigation"
:fuse="{ resultLimit: 42 }"
/>
</ClientOnly> </ClientOnly>
</template> </template>
</UApp> </UApp>
@@ -121,12 +121,12 @@ provide('navigation', mappedNavigation)
@import "tailwindcss"; @import "tailwindcss";
@import "@nuxt/ui-pro"; @import "@nuxt/ui-pro";
@source "../content"; @source "../content/**/*.md";
@theme { @theme {
--container-8xl: 90rem; --container-8xl: 90rem;
--font-sans: 'Public Sans', sans-serif; --font-family-sans: 'Public Sans', sans-serif;
--color-green-50: #EFFDF5; --color-green-50: #EFFDF5;
--color-green-100: #D9FBE8; --color-green-100: #D9FBE8;
@@ -144,13 +144,4 @@ provide('navigation', mappedNavigation)
:root { :root {
--ui-container: var(--container-8xl); --ui-container: var(--container-8xl);
} }
html[data-framework="nuxt"] .vue-only,
html[data-framework="vue"] .nuxt-only,
html[data-module="ui-pro"] .ui-only,
html[data-module="ui"] .ui-pro-only {
display: none;
}
/* Safelist (do not remove): [&>div]:*:my-0 [&>div]:*:w-full */
</style> </style>

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 90 90">
<g transform="translate(0,90) scale(0.1,-0.1)" fill="#9b59b6" stroke="none">
<path d="M385 796 c-17 -12 -18 -19 -7 -109 20 -164 25 -158 -75 -77 -50 39 -97 70 -110 70 -26 0 -73 -72 -73 -112 0 -23 10 -30 103 -68 56 -24 106 -46 110 -50 4 -4 -32 -22 -80 -40 -146 -54 -155 -66 -108 -147 19 -31 32 -43 49 -43 13 0 61 29 109 65 99 75 94 80 75 -72 -11 -90 -10 -97 7 -109 24 -18 106 -18 130 0 17 12 18 19 7 109 -19 152 -24 147 75 72 47 -36 96 -65 109 -65 16 0 30 13 48 44 47 81 39 92 -107 147 -48 18 -84 36 -80 39 5 4 54 26 111 50 92 38 102 45 102 68 0 41 -47 112 -74 112 -13 0 -59 -29 -109 -70 -100 -81 -95 -86 -75 77 11 90 10 97 -7 109 -10 8 -40 14 -65 14 -25 0 -55 -6 -65 -14z" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 756 B

View File

@@ -1,10 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 283.46 283.46">
<defs>
<style>
.cls-1{fill:#231815;}
@media (prefers-color-scheme: dark) { .cls-1{fill:#ffffff;} }
</style>
</defs>
<path class="cls-1" d="M144.89,89.86c-33.46,0-54.44,14.56-66.14,26.76a86,86,0,0,0-23.69,58.94c0,22.64,8.81,43.48,24.8,58.67,15.7,14.92,36.9,23.14,59.68,23.14,23.81,0,46-8.49,62.49-23.91,17-15.9,26.37-37.93,26.37-62C228.4,120.37,185.94,89.86,144.89,89.86Zm.49,153.67a61.49,61.49,0,0,1-46.45-20.4c-12.33-13.76-18.85-32.64-18.85-54.62,0-20.7,6.07-37.67,17.57-49.07,10.11-10,24.39-15.62,40.19-15.74,19,0,35.22,6.56,46.76,19,12.6,13.58,19.27,34,19.27,58.95C203.87,224.39,174.49,243.53,145.38,243.53Z"/>
<polygon class="cls-1" points="198.75 74.96 179.45 74.96 142.09 37.83 104.51 74.96 86.14 74.96 138.09 24.25 146.81 24.25 198.75 74.96"/>
</svg>

Before

Width:  |  Height:  |  Size: 855 B

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1,28 +0,0 @@
<script setup lang="ts">
const { framework, frameworks } = useSharedData()
const value = ref<string | undefined>(undefined)
onMounted(() => {
value.value = framework.value
})
watch(framework, () => {
value.value = framework.value
})
</script>
<template>
<UTabs
v-model="value"
:items="frameworks"
:content="false"
color="neutral"
:ui="{
indicator: 'bg-[var(--ui-bg)]',
trigger: 'px-1 data-[state=active]:text-[var(--ui-text-highlighted)]'
}"
size="sm"
@update:model-value="(framework = $event as string)"
/>
</template>

View File

@@ -7,50 +7,26 @@ const props = defineProps<{
}>() }>()
const config = useRuntimeConfig().public const config = useRuntimeConfig().public
const { module } = useSharedData()
const value = ref<string | undefined>(module.value)
watch(module, () => {
value.value = module.value
})
onMounted(() => {
value.value = module.value
})
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation') const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
const items = computed(() => props.links.map(({ icon, ...link }) => link)) const items = computed(() => props.links.map(({ icon, ...link }) => link))
defineShortcuts({
meta_g: () => {
window.open('https://github.com/nuxt/ui/tree/v3', '_blank')
}
})
</script> </script>
<template> <template>
<UHeader :ui="{ left: 'min-w-0' }" mode="drawer" :menu="{ shouldScaleBackground: true }"> <UHeader :ui="{ left: 'min-w-0' }">
<template #left> <template #left>
<NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-[var(--ui-text-highlighted)] min-w-0 focus-visible:outline-[var(--ui-primary)] shrink-0" aria-label="Nuxt UI"> <NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-[var(--ui-text-highlighted)] min-w-0 focus-visible:outline-[var(--ui-primary)]" aria-label="Nuxt UI">
<LogoPro class="w-auto h-6 shrink-0 ui-pro-only" /> <Logo class="w-auto h-6 shrink-0" />
<Logo class="w-auto h-6 shrink-0 ui-only" />
</NuxtLink>
<UDropdownMenu <UBadge :label="`v${config.version}`" variant="subtle" size="sm" class="-mb-[2px] rounded-[var(--ui-radius)] font-semibold inline-block truncate" />
v-slot="{ open }" </NuxtLink>
:modal="false"
:items="[{ label: `v${config.version}`, active: true, color: 'primary', checked: true, type: 'checkbox' }, { label: module === 'ui-pro' ? 'v1.5' : 'v2.19', to: module === 'ui-pro' ? 'https://ui.nuxt.com/pro' : 'https://ui.nuxt.com' }]"
:ui="{ content: 'w-(--reka-dropdown-menu-trigger-width) min-w-0' }"
size="xs"
>
<UButton
:label="`v${config.version}`"
variant="subtle"
trailing-icon="i-lucide-chevron-down"
size="xs"
class="-mb-[6px] font-semibold rounded-full truncate"
:class="[open && 'bg-[var(--ui-primary)]/15 ']"
:ui="{
trailingIcon: ['transition-transform duration-200', open ? 'rotate-180' : undefined].filter(Boolean).join(' ')
}"
/>
</UDropdownMenu>
</template> </template>
<UNavigationMenu :items="items" variant="link" /> <UNavigationMenu :items="items" variant="link" />
@@ -62,11 +38,11 @@ const items = computed(() => props.links.map(({ icon, ...link }) => link))
<UContentSearchButton /> <UContentSearchButton />
</UTooltip> </UTooltip>
<UTooltip text="Open on GitHub" class="hidden lg:flex"> <UTooltip text="Open on GitHub" :kbds="['meta', 'G']">
<UButton <UButton
color="neutral" color="neutral"
variant="ghost" variant="ghost"
:to="`https://github.com/nuxt/${value}`" to="https://github.com/nuxt/ui/tree/v3"
target="_blank" target="_blank"
icon="i-simple-icons-github" icon="i-simple-icons-github"
aria-label="GitHub" aria-label="GitHub"
@@ -75,24 +51,11 @@ const items = computed(() => props.links.map(({ icon, ...link }) => link))
</template> </template>
<template #content> <template #content>
<UNavigationMenu orientation="vertical" :items="links" class="-mx-2.5" /> <UNavigationMenu orientation="vertical" :items="links" class="-ml-2.5" />
<USeparator type="dashed" class="mt-4 mb-6" /> <USeparator type="dashed" class="my-4" />
<div class="flex flex-col gap-2 w-[calc(100%+1.25rem)] mb-5.5 -mx-2.5"> <UContentNavigation :navigation="navigation" highlight />
<FrameworkSelect />
<ModuleSelect />
</div>
<UContentNavigation :navigation="navigation" highlight :ui="{ linkTrailingBadge: 'font-semibold uppercase' }">
<template #link-title="{ link }">
<span class="inline-flex items-center gap-0.5">
{{ link.title }}
<sup v-if="link.module === 'ui-pro' && link.path.startsWith('/components')" class="text-[8px] font-medium text-(--ui-primary)">PRO</sup>
</span>
</template>
</UContentNavigation>
</template> </template>
</UHeader> </UHeader>
</template> </template>

View File

@@ -1,14 +0,0 @@
<template>
<svg width="1352" height="200" viewBox="0 0 1352 200" fill="none" xmlns="http://www.w3.org/2000/svg">
<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-primary)" />
<path d="M958 60.0001H938C933.524 60.0001 929.926 59.9395 927 63C924.074 65.8905 925 67.5792 925 72V141C925 151.372 923.648 156.899 919 162C914.352 166.931 908.468 169 899 169C889.705 169 882.648 166.931 878 162C873.352 156.899 873 151.372 873 141V72.0001C873 67.5793 872.926 65.8906 870 63.0001C867.074 59.9396 863.476 60.0001 859 60.0001H840V141C840 159.023 845.016 173.458 855 184C865.156 194.542 879.893 200 899 200C918.107 200 932.844 194.542 943 184C953.156 173.458 958 159.023 958 141V60.0001Z" fill="currentColor" />
<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 d="M1060 200V60H1117C1126.67 60 1134.98 61.2896 1142 65C1149.16 68.7104 1155.29 74.3744 1159 81C1162.71 87.6256 1164 95.3867 1164 104C1164 112.481 1162.71 120.374 1159 127C1155.29 133.626 1149.16 138.157 1142 142C1134.98 145.71 1126.67 148 1117 148H1090V200H1060ZM1115 123C1121.63 123 1126.69 121.578 1130 118C1133.31 114.29 1135 109.433 1135 104C1135 98.567 1133.31 93.5778 1130 90C1126.69 86.2896 1121.63 85 1115 85H1090V123H1115Z" fill="var(--ui-primary)" />
<path d="M1226 123C1219.37 123 1214.31 124.965 1211 130C1207.69 135.035 1206 142.122 1206 151V200H1178V100H1200C1203.31 100 1206 102.686 1206 106V116C1208.65 109.904 1211.16 106.518 1215 104C1218.98 101.482 1224.77 100 1231 100H1242V123H1226Z" fill="var(--ui-primary)" />
<path d="M1299 200C1288.93 200 1280.08 197.373 1272 193C1263.92 188.495 1257.51 182.818 1253 175C1248.49 167.049 1246 157.806 1246 148C1246 138.194 1248.49 129.818 1253 122C1257.51 114.049 1263.92 107.373 1272 103C1280.08 98.4946 1288.93 97 1299 97C1309.07 97 1318.92 98.4946 1327 103C1335.08 107.373 1340.49 114.049 1345 122C1349.51 129.818 1352 138.194 1352 148C1352 157.806 1349.51 167.049 1345 175C1340.49 182.818 1335.08 188.495 1327 193C1318.92 197.373 1309.07 200 1299 200ZM1299 176C1306.42 176 1312.36 173.168 1317 168C1321.64 162.832 1324 156.216 1324 148C1324 139.652 1321.64 133.168 1317 128C1312.36 122.832 1306.42 120 1299 120C1291.58 120 1285.64 122.832 1281 128C1276.36 133.168 1274 139.652 1274 148C1274 156.216 1276.36 162.832 1281 168C1285.64 173.168 1291.58 176 1299 176Z" fill="var(--ui-primary)" />
</svg>
</template>

View File

@@ -1,28 +0,0 @@
<script setup lang="ts">
const { module, modules } = useSharedData()
const value = ref<string | undefined>(undefined)
onMounted(() => {
value.value = module.value
})
watch(module, () => {
value.value = module.value
})
</script>
<template>
<UTabs
v-model="value"
:items="modules"
:content="false"
color="neutral"
:ui="{
indicator: 'bg-[var(--ui-bg)]',
trigger: 'px-1 data-[state=active]:text-[var(--ui-text-highlighted)]'
}"
size="sm"
@update:model-value="(module = $event as string)"
/>
</template>

View File

@@ -3,47 +3,10 @@
import json5 from 'json5' import json5 from 'json5'
import { upperFirst, camelCase, kebabCase } from 'scule' import { upperFirst, camelCase, kebabCase } from 'scule'
import { hash } from 'ohash' import { hash } from 'ohash'
import { CalendarDate } from '@internationalized/date'
import * as theme from '#build/ui' import * as theme from '#build/ui'
import * as themePro from '#build/ui-pro'
import { get, set } from '#ui/utils' import { get, set } from '#ui/utils'
interface Cast {
get: (args: any) => any
template: (args: any) => string
}
type CastDateValue = [number, number, number]
const castMap: Record<string, Cast> = {
'DateValue': {
get: (args: CastDateValue) => new CalendarDate(...args),
template: (value: CalendarDate) => {
return value ? `new CalendarDate(${value.year}, ${value.month}, ${value.day})` : 'null'
}
},
'DateValue[]': {
get: (args: CastDateValue[]) => args.map(date => new CalendarDate(...date)),
template: (value: CalendarDate[]) => {
return value ? `[${value.map(date => `new CalendarDate(${date.year}, ${date.month}, ${date.day})`).join(', ')}]` : '[]'
}
},
'DateRange': {
get: (args: { start: CastDateValue, end: CastDateValue }) => ({ start: new CalendarDate(...args.start), end: new CalendarDate(...args.end) }),
template: (value: { start: CalendarDate, end: CalendarDate }) => {
if (!value.start || !value.end) {
return `{ start: null, end: null }`
}
return `{ start: new CalendarDate(${value.start.year}, ${value.start.month}, ${value.start.day}), end: new CalendarDate(${value.end.year}, ${value.end.month}, ${value.end.day}) }`
}
}
}
const props = defineProps<{ const props = defineProps<{
pro?: boolean
prose?: boolean
prefix?: string
/** Override the slug taken from the route */ /** Override the slug taken from the route */
slug?: string slug?: string
class?: any class?: any
@@ -55,8 +18,6 @@ const props = defineProps<{
external?: string[] external?: string[]
/** List of props to use with `v-model` */ /** List of props to use with `v-model` */
model?: string[] model?: string[]
/** List of props to cast from code and selection */
cast?: { [key: string]: string }
/** List of items for each prop */ /** List of items for each prop */
items?: { [key: string]: string[] } items?: { [key: string]: string[] }
props?: { [key: string]: any } props?: { [key: string]: any }
@@ -75,44 +36,16 @@ const props = defineProps<{
* A list of line numbers to highlight in the code block * A list of line numbers to highlight in the code block
*/ */
highlights?: number[] highlights?: number[]
/**
* Whether to add overflow-hidden to wrapper
*/
overflowHidden?: boolean
}>() }>()
const route = useRoute() const route = useRoute()
const { $prettier } = useNuxtApp() const { $prettier } = useNuxtApp()
const camelName = camelCase(props.slug ?? route.params.slug?.[route.params.slug.length - 1] ?? '') const camelName = camelCase(props.slug ?? route.params.slug?.[route.params.slug.length - 1] ?? '')
const name = `${props.prose ? 'Prose' : 'U'}${upperFirst(camelName)}` const name = `U${upperFirst(camelName)}`
const component = defineAsyncComponent(() => { const component = defineAsyncComponent(() => import(`#ui/components/${upperFirst(camelName)}.vue`))
if (props.pro) {
if (props.prefix) {
return import(`#ui-pro/components/${props.prefix}/${upperFirst(camelName)}.vue`)
}
if (props.prose) { const componentProps = reactive({ ...(props.props || {}) })
return import(`#ui-pro/components/prose/${upperFirst(camelName)}.vue`)
}
return import(`#ui-pro/components/${upperFirst(camelName)}.vue`)
}
return import(`#ui/components/${upperFirst(camelName)}.vue`)
})
const componentProps = reactive({
...Object.fromEntries(Object.entries(props.props || {}).map(([key, value]) => {
const cast = props.cast?.[key]
if (cast && !castMap[cast]) {
throw new Error(`Unknown cast: ${cast}`)
}
return [key, cast ? castMap[cast]!.get(value) : value]
}))
})
const componentEvents = reactive({ const componentEvents = reactive({
...Object.fromEntries((props.model || []).map(key => [`onUpdate:${key}`, (e: any) => setComponentProp(key, e)])), ...Object.fromEntries((props.model || []).map(key => [`onUpdate:${key}`, (e: any) => setComponentProp(key, e)])),
...(componentProps.modelValue ? { [`onUpdate:modelValue`]: (e: any) => setComponentProp('modelValue', e) } : {}) ...(componentProps.modelValue ? { [`onUpdate:modelValue`]: (e: any) => setComponentProp('modelValue', e) } : {})
@@ -126,7 +59,7 @@ function setComponentProp(name: string, value: any) {
set(componentProps, name, value) set(componentProps, name, value)
} }
const componentTheme = ((props.pro ? props.prose ? themePro.prose : themePro : theme) as any)[camelName] const componentTheme = (theme as any)[camelName]
const meta = await fetchComponentMeta(name as any) const meta = await fetchComponentMeta(name as any)
function mapKeys(obj: object, parentKey = ''): any { function mapKeys(obj: object, parentKey = ''): any {
@@ -149,23 +82,21 @@ const options = computed(() => {
const propItems = get(props.items, key, []) const propItems = get(props.items, key, [])
const items = propItems.length const items = propItems.length
? propItems.map((item: any) => ({ ? propItems.map((item: any) => ({
value: item, value: item,
label: String(item) label: item
})) }))
: prop?.type === 'boolean' || prop?.type === 'boolean | undefined' : prop?.type === 'boolean' || prop?.type === 'boolean | undefined'
? [{ value: true, label: 'true' }, { value: false, label: 'false' }] ? [{ value: true, label: 'true' }, { value: false, label: 'false' }]
: Object.keys(componentTheme?.variants?.[key] || {}).filter((variant) => { : Object.keys(componentTheme?.variants?.[key] || {}).map(variant => ({
return variant !== 'true' && variant !== 'false' value: variant,
}).map(variant => ({ label: variant,
value: variant, chip: key.toLowerCase().endsWith('color') ? { color: variant } : undefined
label: variant, }))
chip: key.toLowerCase().endsWith('color') ? { color: variant } : undefined
}))
return { return {
name: key, name: key,
label: key, label: key,
type: props?.cast?.[key] ?? prop?.type, type: prop?.type,
items items
} }
}) })
@@ -174,30 +105,6 @@ const options = computed(() => {
const code = computed(() => { const code = computed(() => {
let code = '' let code = ''
if (props.prose) {
code += `\`\`\`mdc
::${camelName}`
const proseProps = Object.entries(componentProps).map(([key, value]) => {
if (value === undefined || value === null || value === '' || props.hide?.includes(key)) {
return
}
return `${key}="${value}"`
}).filter(Boolean).join(' ')
if (proseProps.length) {
code += `{${proseProps}}`
}
code += `
${props.slots?.default}
::
\`\`\``
return code
}
if (props.collapse) { if (props.collapse) {
code += `::code-collapse code += `::code-collapse
` `
@@ -210,10 +117,7 @@ ${props.slots?.default}
<script setup lang="ts"> <script setup lang="ts">
` `
for (const key of props.external) { for (const key of props.external) {
const cast = props.cast?.[key] code += `const ${key === 'modelValue' ? 'value' : key} = ref(${json5.stringify(componentProps[key], null, 2).replace(/,([ |\t\n]+[}|\]])/g, '$1')})
const value = cast ? castMap[cast]!.template(componentProps[key]) : json5.stringify(componentProps[key], null, 2).replace(/,([ |\t\n]+[}|\]])/g, '$1')
code += `const ${key === 'modelValue' ? 'value' : key} = ref(${value})
` `
} }
code += `<\/script> code += `<\/script>
@@ -239,28 +143,28 @@ ${props.slots?.default}
} }
const prop = meta?.meta?.props?.find((prop: any) => prop.name === key) const prop = meta?.meta?.props?.find((prop: any) => prop.name === key)
const propDefault = prop && (prop.default ?? prop.tags?.find(tag => tag.name === 'defaultValue')?.text ?? componentTheme?.defaultVariants?.[prop.name])
const name = kebabCase(key) const name = kebabCase(key)
if (typeof value === 'boolean') { if (typeof value === 'boolean') {
if (value && (propDefault === 'true' || propDefault === '`true`' || propDefault === true)) { if (value && prop?.default === 'true') {
continue continue
} }
if (!value && (!propDefault || propDefault === 'false' || propDefault === '`false`' || propDefault === false)) { if (!value && (!prop?.default || prop.default === 'false')) {
continue continue
} }
code += value ? ` ${name}` : ` :${name}="false"` code += value ? ` ${name}` : ` :${key}="false"`
} else if (typeof value === 'object') { } else if (typeof value === 'object') {
const parsedValue = !props.external?.includes(key) ? json5.stringify(value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1') : key const parsedValue = !props.external?.includes(key) ? json5.stringify(value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1') : key
code += ` :${name}="${parsedValue}"` code += ` :${name}="${parsedValue}"`
} else { } else {
const propDefault = prop && (prop.default ?? prop.tags?.find(tag => tag.name === 'defaultValue')?.text ?? componentTheme?.defaultVariants?.[prop.name])
if (propDefault === value) { if (propDefault === value) {
continue continue
} }
code += ` ${typeof value === 'number' ? ':' : ''}${name}="${value}"` code += ` ${prop?.type.includes('number') ? ':' : ''}${name}="${value}"`
} }
} }
@@ -273,7 +177,7 @@ ${props.slots?.default}
code += ` code += `
<template #${key}> <template #${key}>
${value} ${value}
</template>\n` </template>`
} }
} }
code += (Object.keys(props.slots).length > 1 ? '\n' : '') + `</${name}>` code += (Object.keys(props.slots).length > 1 ? '\n' : '') + `</${name}>`
@@ -316,7 +220,7 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
<template> <template>
<div class="my-5"> <div class="my-5">
<div> <div>
<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"> <div v-if="options.length" class="flex items-center gap-2.5 border border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)] border-b-0 relative rounded-t-[calc(var(--ui-radius)*1.5)] px-4 py-2.5 overflow-x-auto">
<template v-for="option in options" :key="option.name"> <template v-for="option in options" :key="option.name">
<UFormField <UFormField
:label="option.label" :label="option.label"
@@ -328,7 +232,7 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
container: 'mt-0' container: 'mt-0'
}" }"
> >
<USelect <USelectMenu
v-if="option.items?.length" v-if="option.items?.length"
:model-value="getComponentProp(option.name)" :model-value="getComponentProp(option.name)"
:items="option.items" :items="option.items"
@@ -336,6 +240,7 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
color="neutral" color="neutral"
variant="soft" variant="soft"
class="rounded-[var(--ui-radius)] rounded-l-none min-w-12" class="rounded-[var(--ui-radius)] rounded-l-none min-w-12"
:search-input="false"
:class="[option.name.toLowerCase().endsWith('color') && 'pl-6']" :class="[option.name.toLowerCase().endsWith('color') && 'pl-6']"
:ui="{ itemLeadingChip: 'size-2' }" :ui="{ itemLeadingChip: 'size-2' }"
@update:model-value="setComponentProp(option.name, $event)" @update:model-value="setComponentProp(option.name, $event)"
@@ -350,10 +255,10 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
class="size-2" class="size-2"
/> />
</template> </template>
</USelect> </USelectMenu>
<UInput <UInput
v-else v-else
:type="option.type?.includes('number') && typeof getComponentProp(option.name) === 'number' ? 'number' : 'text'" :type="option.type?.includes('number') ? 'number' : 'text'"
:model-value="getComponentProp(option.name)" :model-value="getComponentProp(option.name)"
color="neutral" color="neutral"
variant="soft" variant="soft"
@@ -364,12 +269,12 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props:
</template> </template>
</div> </div>
<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, { 'overflow-hidden': props.overflowHidden }]"> <div v-if="component" class="flex justify-center border border-b-0 border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)] relative p-4 z-[1]" :class="[!options.length && 'rounded-t-[calc(var(--ui-radius)*1.5)]', props.class]">
<component :is="component" v-bind="{ ...componentProps, ...componentEvents }"> <component :is="component" v-bind="{ ...componentProps, ...componentEvents }">
<template v-for="slot in Object.keys(slots || {})" :key="slot" #[slot]> <template v-for="slot in Object.keys(slots || {})" :key="slot" #[slot]>
<slot :name="slot" mdc-unwrap="p"> <MDCSlot :name="slot" unwrap="p">
{{ slots?.[slot] }} {{ slots?.[slot] }}
</slot> </MDCSlot>
</template> </template>
</component> </component>
</div> </div>

View File

@@ -1,14 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { upperFirst, camelCase } from 'scule' import { upperFirst, camelCase } from 'scule'
const props = defineProps<{
prose?: boolean
}>()
const route = useRoute() const route = useRoute()
const camelName = camelCase(route.params.slug?.[route.params.slug.length - 1] ?? '') const camelName = camelCase(route.params.slug?.[route.params.slug.length - 1] ?? '')
const name = props.prose ? `Prose${upperFirst(camelName)}` : `U${upperFirst(camelName)}` const name = `U${upperFirst(camelName)}`
const meta = await fetchComponentMeta(name as any) const meta = await fetchComponentMeta(name as any)
</script> </script>

View File

@@ -1,21 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { camelCase } from 'scule' import { camelCase } from 'scule'
import { useElementSize } from '@vueuse/core'
import { get, set } from '#ui/utils' import { get, set } from '#ui/utils'
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
name: string name: string
class?: any class?: any
/**
* Whether to render the component in an iframe
* @defaultValue false
*/
iframe?: boolean | { [key: string]: any }
/**
* Whether to display the component in a mobile-sized iframe viewport
* @defaultValue false
*/
iframeMobile?: boolean
props?: { [key: string]: any } props?: { [key: string]: any }
/** /**
* Whether to format the code with Prettier * Whether to format the code with Prettier
@@ -53,10 +42,6 @@ const props = withDefaults(defineProps<{
* A list of line numbers to highlight in the code block * A list of line numbers to highlight in the code block
*/ */
highlights?: number[] highlights?: number[]
/**
* Whether to add overflow-hidden to wrapper
*/
overflowHidden?: boolean
}>(), { }>(), {
preview: true, preview: true,
source: true source: true
@@ -64,13 +49,9 @@ const props = withDefaults(defineProps<{
const slots = defineSlots<{ const slots = defineSlots<{
options(props?: {}): any options(props?: {}): any
code(props?: {}): any
}>() }>()
const el = ref<HTMLElement | null>(null)
const { $prettier } = useNuxtApp() const { $prettier } = useNuxtApp()
const { width } = useElementSize(el)
const camelName = camelCase(props.name) const camelName = camelCase(props.name)
@@ -131,19 +112,13 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
} }
return acc return acc
}, {} as Record<string, any>) || {}) }, {} as Record<string, any>) || {})
const urlSearchParams = computed(() => new URLSearchParams({
...optionsValues.value,
...componentProps,
width: Math.round(width.value).toString()
}).toString())
</script> </script>
<template> <template>
<div ref="el" class="my-5"> <div class="my-5">
<template v-if="preview"> <template v-if="preview">
<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, 'overflow-hidden': props.overflowHidden }]"> <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-border-muted)]"> <div v-if="props.options?.length || !!slots.options" class="flex gap-4 p-4 border-b border-[var(--ui-color-neutral-200)] dark:border-[var(--ui-color-neutral-700)]">
<slot name="options" /> <slot name="options" />
<UFormField <UFormField
@@ -194,24 +169,12 @@ const urlSearchParams = computed(() => new URLSearchParams({
</UFormField> </UFormField>
</div> </div>
<iframe <div class="flex justify-center p-4" :class="props.class">
v-if="iframe"
v-bind="typeof iframe === 'object' ? iframe : {}"
:src="`/examples/${name}?${urlSearchParams}`"
class="relative w-full"
:class="[props.class, !iframeMobile && 'lg:left-1/2 lg:-translate-x-1/2 lg:w-[1024px]']"
/>
<div v-else class="flex justify-center p-4" :class="props.class">
<component :is="camelName" v-bind="{ ...componentProps, ...optionsValues }" /> <component :is="camelName" v-bind="{ ...componentProps, ...optionsValues }" />
</div> </div>
</div> </div>
</template> </template>
<template v-if="props.source"> <MDCRenderer v-if="ast && props.source" :body="ast.body" :data="ast.data" class="[&_pre]:!rounded-t-none [&_div.my-5]:!mt-0" />
<div v-if="!!slots.code" class="[&_pre]:!rounded-t-none [&_div.my-5]:!mt-0">
<slot name="code" />
</div>
<MDCRenderer v-else-if="ast" :body="ast.body" :data="ast.data" class="[&_pre]:!rounded-t-none [&_div.my-5]:!mt-0" />
</template>
</div> </div>
</template> </template>

View File

@@ -2,13 +2,9 @@
import { upperFirst, camelCase } from 'scule' import { upperFirst, camelCase } from 'scule'
import type { ComponentMeta } from 'vue-component-meta' import type { ComponentMeta } from 'vue-component-meta'
import * as theme from '#build/ui' import * as theme from '#build/ui'
import * as themePro from '#build/ui-pro'
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
name?: string
ignore?: string[] ignore?: string[]
pro?: boolean
prose?: boolean
}>(), { }>(), {
ignore: () => [ ignore: () => [
'activeClass', 'activeClass',
@@ -27,18 +23,17 @@ const props = withDefaults(defineProps<{
'exactQuery', 'exactQuery',
'exactHash', 'exactHash',
'external', 'external',
'onClick', 'onClick'
'viewTransition'
] ]
}) })
const route = useRoute() const route = useRoute()
const camelName = camelCase(props.name ?? route.params.slug?.[route.params.slug.length - 1] ?? '') const camelName = camelCase(route.params.slug?.[route.params.slug.length - 1] ?? '')
const componentName = props.prose ? `Prose${upperFirst(camelName)}` : `U${upperFirst(camelName)}` const name = `U${upperFirst(camelName)}`
const componentTheme = ((props.pro ? props.prose ? themePro.prose : themePro : theme) as any)[camelName] const componentTheme = (theme as any)[camelName]
const meta = await fetchComponentMeta(componentName as any) const meta = await fetchComponentMeta(name as any)
const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => { const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
if (!meta?.meta?.props?.length) { if (!meta?.meta?.props?.length) {
@@ -48,17 +43,7 @@ const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
return meta.meta.props.filter((prop) => { return meta.meta.props.filter((prop) => {
return !props.ignore?.includes(prop.name) return !props.ignore?.includes(prop.name)
}).map((prop) => { }).map((prop) => {
if (prop.default) { prop.default = prop.default ?? prop.tags?.find(tag => tag.name === 'defaultValue')?.text ?? componentTheme?.defaultVariants?.[prop.name]
prop.default = prop.default.replace(' as never', '').replace(/^"(.*)"$/, '\'$1\'')
} else {
const tag = prop.tags?.find(tag => tag.name === 'defaultValue')?.text
if (tag) {
prop.default = tag
} else if (componentTheme?.defaultVariants?.[prop.name]) {
prop.default = typeof componentTheme?.defaultVariants?.[prop.name] === 'string' ? `'${componentTheme?.defaultVariants?.[prop.name]}'` : componentTheme?.defaultVariants?.[prop.name]
}
}
// @ts-expect-error - Type is not correct // @ts-expect-error - Type is not correct
prop.type = !prop.type.startsWith('boolean') && prop.schema?.kind === 'enum' && Object.keys(prop.schema.schema)?.length ? Object.values(prop.schema.schema).map(schema => schema?.type ? schema.type : schema).join(' | ') : prop.type prop.type = !prop.type.startsWith('boolean') && prop.schema?.kind === 'enum' && Object.keys(prop.schema.schema)?.length ? Object.values(prop.schema.schema).map(schema => schema?.type ? schema.type : schema).join(' | ') : prop.type
return prop return prop

View File

@@ -35,7 +35,7 @@ const schemaProps = computed(() => {
</script> </script>
<template> <template>
<ProseCollapsible v-if="schemaProps?.length" class="mt-1"> <Collapsible v-if="schemaProps?.length" class="mt-1">
<ProseUl> <ProseUl>
<ProseLi v-for="schemaProp in schemaProps" :key="schemaProp.name"> <ProseLi v-for="schemaProp in schemaProps" :key="schemaProp.name">
<HighlightInlineType :type="`${schemaProp.name}${schemaProp.required === false ? '?' : ''}: ${schemaProp.type}`" /> <HighlightInlineType :type="`${schemaProp.name}${schemaProp.required === false ? '?' : ''}: ${schemaProp.type}`" />
@@ -43,5 +43,5 @@ const schemaProps = computed(() => {
<MDC v-if="schemaProp.description" :value="schemaProp.description" class="text-[var(--ui-text-muted)] my-1" /> <MDC v-if="schemaProp.description" :value="schemaProp.description" class="text-[var(--ui-text-muted)] my-1" />
</ProseLi> </ProseLi>
</ProseUl> </ProseUl>
</ProseCollapsible> </Collapsible>
</template> </template>

View File

@@ -1,15 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { upperFirst, camelCase } from 'scule' import { upperFirst, camelCase } from 'scule'
const props = defineProps<{
prose?: boolean
slug?: string
}>()
const route = useRoute() const route = useRoute()
const camelName = camelCase(props.slug ?? route.params.slug?.[route.params.slug.length - 1] ?? '') const camelName = camelCase(route.params.slug?.[route.params.slug.length - 1] ?? '')
const name = `${props.prose ? 'Prose' : 'U'}${upperFirst(camelName)}` const name = `U${upperFirst(camelName)}`
const meta = await fetchComponentMeta(name as any) const meta = await fetchComponentMeta(name as any)
</script> </script>

View File

@@ -2,31 +2,16 @@
import json5 from 'json5' import json5 from 'json5'
import { camelCase } from 'scule' import { camelCase } from 'scule'
import * as theme from '#build/ui' import * as theme from '#build/ui'
import * as themePro from '#build/ui-pro'
const props = defineProps<{
pro?: boolean
prose?: boolean
slug?: string
extra?: string[]
}>()
const route = useRoute() const route = useRoute()
const { framework } = useSharedData()
const name = camelCase(props.slug ?? route.params.slug?.[route.params.slug.length - 1] ?? '') const name = camelCase(route.params.slug?.[route.params.slug.length - 1] ?? '')
const strippedCompoundVariants = ref(false) const strippedCompoundVariants = ref(false)
const computedTheme = computed(() => props.pro ? props.prose ? themePro.prose : themePro : theme) function stripCompoundVariants(component?: any) {
if (component?.compoundVariants) {
const strippedTheme = computed(() => { component.compoundVariants = component.compoundVariants.filter((compoundVariant: any) => {
const strippedTheme = {
...(computedTheme.value as any)[name]
}
if (strippedTheme?.compoundVariants) {
strippedTheme.compoundVariants = strippedTheme.compoundVariants.filter((compoundVariant: any) => {
if (compoundVariant.color) { if (compoundVariant.color) {
if (!['primary', 'neutral'].includes(compoundVariant.color)) { if (!['primary', 'neutral'].includes(compoundVariant.color)) {
strippedCompoundVariants.value = true strippedCompoundVariants.value = true
@@ -55,58 +40,26 @@ const strippedTheme = computed(() => {
}) })
} }
return strippedTheme return component
}) }
const component = computed(() => { const component = computed(() => {
const baseKey = props.pro ? 'uiPro' : 'ui'
const content = props.prose
? { prose: { [name]: strippedTheme.value } }
: { [name]: strippedTheme.value }
if (props.extra?.length) {
props.extra.forEach((extra) => {
const target = props.prose ? content.prose! : content
target[extra as keyof typeof target] = computedTheme.value[extra as keyof typeof computedTheme.value]
})
}
return { return {
[baseKey]: content ui: {
[name]: stripCompoundVariants((theme as any)[name])
}
} }
}) })
const { data: ast } = await useAsyncData(`component-theme-${name}`, async () => { const { data: ast } = await useAsyncData(`component-theme-${name}`, async () => {
const md = ` const md = `
::code-collapse{class="nuxt-only"} ::code-collapse
\`\`\`ts [app.config.ts] \`\`\`ts [app.config.ts]
export default defineAppConfig(${json5.stringify(component.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')}) export default defineAppConfig(${json5.stringify(component.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
\`\`\`\ \`\`\`\
:: ::
::code-collapse{class="vue-only"}
\`\`\`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(${json5.stringify(component.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')
.split('\n')
.map((line, i) => i === 0 ? line : ` ${line}`)
.join('\n')})
]
})
\`\`\`
::
${strippedCompoundVariants.value ${strippedCompoundVariants.value
? ` ? `
::callout{icon="i-simple-icons-github" to="https://github.com/nuxt/ui/blob/v3/src/theme/${name}.ts"} ::callout{icon="i-simple-icons-github" to="https://github.com/nuxt/ui/blob/v3/src/theme/${name}.ts"}
@@ -116,7 +69,7 @@ Some colors in \`compoundVariants\` are omitted for readability. Check out the s
` `
return parseMarkdown(md) return parseMarkdown(md)
}, { watch: [framework] }) })
</script> </script>
<template> <template>

View File

@@ -1,12 +0,0 @@
<script setup lang="ts">
import { Slot } from 'reka-ui'
</script>
<template>
<Slot class="nuxt-only">
<slot name="nuxt" />
</Slot>
<Slot class="vue-only">
<slot name="vue" />
</Slot>
</template>

View File

@@ -2,13 +2,8 @@
import json5 from 'json5' import json5 from 'json5'
import icons from '../../../../src/theme/icons' import icons from '../../../../src/theme/icons'
const appConfig = useAppConfig()
const { framework, module } = useSharedData()
const { data: ast } = await useAsyncData(`icons-theme`, async () => { const { data: ast } = await useAsyncData(`icons-theme`, async () => {
const md = ` const md = `
::code-collapse{class="ui-only nuxt-only"}
\`\`\`ts [app.config.ts] \`\`\`ts [app.config.ts]
export default defineAppConfig(${json5.stringify({ export default defineAppConfig(${json5.stringify({
ui: { ui: {
@@ -16,52 +11,10 @@ export default defineAppConfig(${json5.stringify({
} }
}, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')}) }, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
\`\`\`\ \`\`\`\
::
::code-collapse{class="ui-pro-only nuxt-only"}
\`\`\`ts [app.config.ts]
export default defineAppConfig(${json5.stringify({
ui: {
icons: appConfig.ui.icons
}
}, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
\`\`\`\
::
::caution{class="ui-pro-only vue-only"}
Nuxt UI Pro v3 does not support Vue yet.
::
::code-collapse{class="vue-only"}
\`\`\`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(${json5.stringify({
ui: {
icons
}
}, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')
.split('\n')
.map((line, i) => i === 0 ? line : ` ${line}`)
.join('\n')})
]
})
\`\`\`
::
` `
return parseMarkdown(md) return parseMarkdown(md)
}, { watch: [framework, module] }) })
</script> </script>
<template> <template>

View File

@@ -1,12 +0,0 @@
<script setup lang="ts">
import { Slot } from 'reka-ui'
</script>
<template>
<Slot class="ui-only">
<slot name="ui" />
</Slot>
<Slot class="ui-pro-only">
<slot name="ui-pro" />
</Slot>
</template>

View File

@@ -7,61 +7,28 @@ const props = withDefaults(defineProps<{
default: 'en' default: 'en'
}) })
function getEmojiFlag(locale: string): string { const getLocaleKeys = () => Object.keys(locales) as Array<keyof typeof locales>
const languageToCountry: Record<string, string> = { const localesList = getLocaleKeys().map(locale => [locale, locales[locale].name])
ar: 'sa',
cs: 'cz',
da: 'dk',
el: 'gr',
et: 'ee',
en: 'gb',
ja: 'jp',
kh: 'km',
ko: 'kr',
nb: 'no',
sv: 'se',
uk: 'ua',
vi: 'vn',
zh: 'cn'
}
const baseLanguage = locale.split('-')[0]?.toLowerCase() || locale
const countryCode = languageToCountry[baseLanguage] || locale.replace(/^.*-/, '').slice(0, 2)
return countryCode.toUpperCase()
.split('')
.map(char => String.fromCodePoint(0x1F1A5 + char.charCodeAt(0)))
.join('')
}
</script> </script>
<!-- eslint-disable vue/singleline-html-element-content-newline --> <!-- eslint-disable vue/singleline-html-element-content-newline -->
<template> <template>
<div> <div>
<ProseP> <ProseUl>
By default, the <ProseCode>{{ props.default }}</ProseCode> locale is used. <ProseLi v-for="[key, label] in localesList" :key="key">
</ProseP> <ProseCode>{{ key }}</ProseCode> - {{ label }}
<div class="grid gap-6 grid-cols-2 md:grid-cols-3"> <template v-if="key === props.default">
<div v-for="locale in locales" :key="locale.code"> (default)
<div class="flex gap-3 items-center"> </template>
<UAvatar size="xl"> </ProseLi>
{{ getEmojiFlag(locale.code) }} </ProseUl>
</UAvatar> <Note to="https://github.com/nuxt/ui/tree/v3/src/runtime/locale" target="_blank">
<div class="text-sm">
<div class="font-semibold">{{ locale.name }}</div>
<div class="mt-1">Code: <ProseCode class="text-xs">{{ locale.code }}</ProseCode></div>
</div>
</div>
</div>
</div>
<ProseNote 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>. If you need additional languages, you can contribute by creating a PR to add a new locale in <ProseCode>src/runtime/locale/</ProseCode>.
</ProseNote> </Note>
<ProseTip> <Tip>
You can use the <ProseCode>nuxt-ui</ProseCode> CLI to create a new locale: 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> <ProsePre language="bash">nuxt-ui make locale --code "en" --name "English"</ProsePre>
</ProseTip> </Tip>
</div> </div>
</template> </template>

View File

@@ -1,21 +0,0 @@
<script setup lang="ts">
import { CalendarDate, DateFormatter, getLocalTimeZone } from '@internationalized/date'
const df = new DateFormatter('en-US', {
dateStyle: 'medium'
})
const modelValue = shallowRef(new CalendarDate(2022, 1, 10))
</script>
<template>
<UPopover>
<UButton color="neutral" variant="subtle" icon="i-lucide-calendar">
{{ df.format(modelValue.toDate(getLocalTimeZone())) }}
</UButton>
<template #content>
<UCalendar v-model="modelValue" class="p-2" />
</template>
</UPopover>
</template>

View File

@@ -1,35 +0,0 @@
<script setup lang="ts">
import { CalendarDate, DateFormatter, getLocalTimeZone } from '@internationalized/date'
const df = new DateFormatter('en-US', {
dateStyle: 'medium'
})
const modelValue = shallowRef({
start: new CalendarDate(2022, 1, 20),
end: new CalendarDate(2022, 2, 10)
})
</script>
<template>
<UPopover>
<UButton color="neutral" variant="subtle" icon="i-lucide-calendar">
<template v-if="modelValue.start">
<template v-if="modelValue.end">
{{ df.format(modelValue.start.toDate(getLocalTimeZone())) }} - {{ df.format(modelValue.end.toDate(getLocalTimeZone())) }}
</template>
<template v-else>
{{ df.format(modelValue.start.toDate(getLocalTimeZone())) }}
</template>
</template>
<template v-else>
Pick a date
</template>
</UButton>
<template #content>
<UCalendar v-model="modelValue" class="p-2" :number-of-months="2" range />
</template>
</UPopover>
</template>

View File

@@ -1,17 +0,0 @@
<script setup lang="ts">
import { CalendarDate } from '@internationalized/date'
import type { Matcher } from 'reka-ui/date'
const modelValue = shallowRef({
start: new CalendarDate(2022, 1, 1),
end: new CalendarDate(2022, 1, 9)
})
const isDateDisabled: Matcher = (date) => {
return date.day >= 10 && date.day <= 16
}
</script>
<template>
<UCalendar v-model="modelValue" :is-date-disabled="isDateDisabled" range />
</template>

View File

@@ -1,30 +0,0 @@
<script setup lang="ts">
import { CalendarDate } from '@internationalized/date'
const modelValue = shallowRef(new CalendarDate(2022, 1, 10))
function getColorByDate(date: Date) {
const isWeekend = date.getDay() % 6 == 0
const isDayMeeting = date.getDay() % 3 == 0
if (isWeekend) {
return undefined
}
if (isDayMeeting) {
return 'error'
}
return 'success'
}
</script>
<template>
<UCalendar v-model="modelValue">
<template #day="{ day }">
<UChip :show="!!getColorByDate(day.toDate('UTC'))" :color="getColorByDate(day.toDate('UTC'))" size="2xs">
{{ day.day }}
</UChip>
</template>
</UCalendar>
</template>

View File

@@ -1,11 +0,0 @@
<script setup lang="ts">
import { CalendarDate } from '@internationalized/date'
const modelValue = shallowRef(new CalendarDate(2023, 9, 10))
const minDate = new CalendarDate(2023, 9, 1)
const maxDate = new CalendarDate(2023, 9, 30)
</script>
<template>
<UCalendar v-model="modelValue" :min-value="minDate" :max-value="maxDate" />
</template>

View File

@@ -1,17 +0,0 @@
<script setup lang="ts">
import { CalendarDate } from '@internationalized/date'
import type { Matcher } from 'reka-ui/date'
const modelValue = shallowRef({
start: new CalendarDate(2022, 1, 1),
end: new CalendarDate(2022, 1, 9)
})
const isDateUnavailable: Matcher = (date) => {
return date.day >= 10 && date.day <= 16
}
</script>
<template>
<UCalendar v-model="modelValue" :is-date-unavailable="isDateUnavailable" range />
</template>

View File

@@ -1,19 +0,0 @@
<script setup lang="ts">
const color = ref('#00C16A')
const chip = computed(() => ({ backgroundColor: color.value }))
</script>
<template>
<UPopover>
<UButton label="Choose color" color="neutral" variant="outline">
<template #leading>
<span :style="chip" class="size-3 rounded-full" />
</template>
</UButton>
<template #content>
<UColorPicker v-model="color" class="p-2" />
</template>
</UPopover>
</template>

View File

@@ -14,7 +14,7 @@ const groups = computed(() => [{
id: 'users', id: 'users',
label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users', label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users',
items: users.value || [], items: users.value || [],
ignoreFilter: true filter: false
}]) }])
</script> </script>

View File

@@ -11,8 +11,8 @@ const items = [
level: 2 level: 2
}, },
{ {
id: '/getting-started#reka-ui-radix-vue', id: '/getting-started#radix-vue-3',
label: 'Reka UI', label: 'Radix Vue',
level: 3 level: 3
}, },
{ {

View File

@@ -72,7 +72,7 @@ const users = [
} }
] ]
const searchTerm = ref('B') const searchTerm = ref('')
function onSelect() { function onSelect() {
searchTerm.value = '' searchTerm.value = ''

View File

@@ -32,7 +32,7 @@ const items = computed(() => [{
</script> </script>
<template> <template>
<UContextMenu :items="items" :ui="{ content: 'w-48' }"> <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"> <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 Right click here
</div> </div>

View File

@@ -25,7 +25,7 @@ const items = [
</script> </script>
<template> <template>
<UContextMenu :items="items" :ui="{ content: 'w-48' }"> <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"> <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 Right click here
</div> </div>

View File

@@ -12,7 +12,7 @@ const items = [{
</script> </script>
<template> <template>
<UContextMenu :items="items" :ui="{ content: 'w-48' }"> <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"> <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 Right click here
</div> </div>
@@ -22,7 +22,7 @@ const items = [{
</template> </template>
<template #refresh-trailing> <template #refresh-trailing>
<UIcon v-if="loading" name="i-lucide-refresh-cw" 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> </template>
</UContextMenu> </UContextMenu>
</template> </template>

View File

@@ -13,7 +13,7 @@ const groups = computed(() => [{
id: 'users', id: 'users',
label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users', label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users',
items: users.value || [], items: users.value || [],
ignoreFilter: true filter: false
}]) }])
</script> </script>

View File

@@ -1,21 +0,0 @@
<script setup lang="ts">
const open = ref(false)
</script>
<template>
<UDrawer v-model:open="open" :dismissible="false" :ui="{ header: 'flex items-center justify-between' }">
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
<template #header>
<h2 class="text-[var(--ui-text-highlighted)] font-semibold">
Drawer non-dismissible
</h2>
<UButton color="neutral" variant="ghost" icon="i-lucide-x" @click="open = false" />
</template>
<template #body>
<Placeholder class="h-48" />
</template>
</UDrawer>
</template>

View File

@@ -40,7 +40,7 @@ const items = computed(() => [{
</script> </script>
<template> <template>
<UDropdownMenu :items="items" :content="{ align: 'start' }" :ui="{ content: 'w-48' }"> <UDropdownMenu :items="items" :content="{ align: 'start' }" class="w-48">
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" /> <UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
</UDropdownMenu> </UDropdownMenu>
</template> </template>

View File

@@ -25,7 +25,7 @@ const items = [
</script> </script>
<template> <template>
<UDropdownMenu :items="items" :ui="{ content: 'w-48' }"> <UDropdownMenu :items="items" class="w-48">
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" /> <UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
<template #profile-trailing> <template #profile-trailing>

View File

@@ -13,7 +13,7 @@ const items = [{
</script> </script>
<template> <template>
<UDropdownMenu :items="items" :ui="{ content: 'w-48' }"> <UDropdownMenu :items="items" class="w-48">
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" /> <UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
<template #profile-trailing> <template #profile-trailing>

View File

@@ -18,7 +18,7 @@ const items = [{
</script> </script>
<template> <template>
<UDropdownMenu v-model:open="open" :items="items" :ui="{ content: 'w-48' }"> <UDropdownMenu v-model:open="open" :items="items" class="w-48">
<UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" /> <UButton label="Open" color="neutral" variant="outline" icon="i-lucide-menu" />
</UDropdownMenu> </UDropdownMenu>
</template> </template>

View File

@@ -1,10 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import * as z from 'zod' import { z } from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui' import type { FormSubmitEvent } from '@nuxt/ui'
const schema = z.object({ const schema = z.object({
input: z.string().min(10), input: z.string().min(10),
inputNumber: z.number().min(10),
inputMenu: z.any().refine(option => option?.value === 'option-2', { inputMenu: z.any().refine(option => option?.value === 'option-2', {
message: 'Select Option 2' message: 'Select Option 2'
}), }),
@@ -30,11 +29,10 @@ const schema = z.object({
radioGroup: z.string().refine(value => value === 'option-2', { radioGroup: z.string().refine(value => value === 'option-2', {
message: 'Select 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.input<typeof schema> type Schema = z.output<typeof schema>
const state = reactive<Partial<Schema>>({}) const state = reactive<Partial<Schema>>({})
@@ -54,10 +52,10 @@ async function onSubmit(event: FormSubmitEvent<any>) {
</script> </script>
<template> <template>
<UForm ref="form" :state="state" :schema="schema" class="w-full" @submit="onSubmit"> <UForm ref="form" :state="state" :schema="schema" @submit="onSubmit">
<div class="grid grid-cols-3 gap-4"> <div class="grid grid-cols-3 gap-4">
<UFormField label="Input" name="input"> <UFormField label="Input" name="input">
<UInput v-model="state.input" placeholder="john@lennon.com" class="w-full" /> <UInput v-model="state.input" placeholder="john@lennon.com" class="w-40" />
</UFormField> </UFormField>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
@@ -75,40 +73,34 @@ async function onSubmit(event: FormSubmitEvent<any>) {
</UFormField> </UFormField>
<UFormField name="select" label="Select"> <UFormField name="select" label="Select">
<USelect v-model="state.select" :items="items" class="w-full" /> <USelect v-model="state.select" :items="items" class="w-48" />
</UFormField> </UFormField>
<UFormField name="selectMenu" label="Select Menu"> <UFormField name="selectMenu" label="Select Menu">
<USelectMenu v-model="state.selectMenu" :items="items" class="w-full" /> <USelectMenu v-model="state.selectMenu" :items="items" class="w-48" />
</UFormField> </UFormField>
<UFormField name="selectMenuMultiple" label="Select Menu (Multiple)"> <UFormField name="selectMenuMultiple" label="Select Menu (Multiple)">
<USelectMenu v-model="state.selectMenuMultiple" multiple :items="items" class="w-full" /> <USelectMenu v-model="state.selectMenuMultiple" multiple :items="items" class="w-48" />
</UFormField> </UFormField>
<UFormField name="inputMenu" label="Input Menu"> <UFormField name="inputMenu" label="Input Menu">
<UInputMenu v-model="state.inputMenu" :items="items" class="w-full" /> <UInputMenu v-model="state.inputMenu" :items="items" />
</UFormField> </UFormField>
<UFormField name="inputMenuMultiple" label="Input Menu (Multiple)"> <UFormField name="inputMenuMultiple" label="Input Menu (Multiple)">
<UInputMenu v-model="state.inputMenuMultiple" multiple :items="items" class="w-full" /> <UInputMenu v-model="state.inputMenuMultiple" multiple :items="items" />
</UFormField> </UFormField>
<UFormField name="inputNumber" label="Input Number"> <span />
<UInputNumber v-model="state.inputNumber" class="w-full" />
</UFormField>
<UFormField label="Textarea" name="textarea"> <UFormField label="Textarea" name="textarea">
<UTextarea v-model="state.textarea" class="w-full" /> <UTextarea v-model="state.textarea" />
</UFormField> </UFormField>
<UFormField name="radioGroup"> <UFormField name="radioGroup">
<URadioGroup v-model="state.radioGroup" legend="Radio group" :items="items" /> <URadioGroup v-model="state.radioGroup" legend="Radio group" :items="items" />
</UFormField> </UFormField>
<UFormField name="pin" label="Pin Input" :error-pattern="/(pin)\..*/">
<UPinInput v-model="state.pin" />
</UFormField>
</div> </div>
<div class="flex gap-2 mt-8"> <div class="flex gap-2 mt-8">

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import * as z from 'zod' import { z } from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui' import type { FormSubmitEvent } from '@nuxt/ui'
const schema = z.object({ const schema = z.object({

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import * as z from 'zod' import { z } from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui' import type { FormSubmitEvent } from '@nuxt/ui'
const schema = z.object({ const schema = z.object({

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import * as z from 'zod' import { z } from 'zod'
import type { FormSubmitEvent } from '#ui/types' import type { FormSubmitEvent } from '#ui/types'
const schema = z.object({ const schema = z.object({

View File

@@ -1,20 +0,0 @@
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
function onCreate(item: string) {
items.value.push(item)
value.value = item
}
</script>
<template>
<UInputMenu
v-model="value"
create-item
:items="items"
class="w-48"
@create="onCreate"
/>
</template>

View File

@@ -20,7 +20,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
v-model:search-term="searchTerm" v-model:search-term="searchTerm"
:items="users || []" :items="users || []"
:loading="status === 'pending'" :loading="status === 'pending'"
ignore-filter :filter="false"
icon="i-lucide-user" icon="i-lucide-user"
placeholder="Select user" placeholder="Select user"
> >

View File

@@ -16,7 +16,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
<UInputMenu <UInputMenu
:items="users || []" :items="users || []"
:loading="status === 'pending'" :loading="status === 'pending'"
:filter-fields="['label', 'email']" :filter="['label', 'email']"
icon="i-lucide-user" icon="i-lucide-user"
placeholder="Select user" placeholder="Select user"
class="w-80" class="w-80"

View File

@@ -1,15 +0,0 @@
<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>

View File

@@ -1,13 +0,0 @@
<script setup lang="ts">
const value = ref(5)
</script>
<template>
<UInputNumber
v-model="value"
:format-options="{
signDisplay: 'exceptZero',
minimumFractionDigits: 1
}"
/>
</template>

View File

@@ -1,9 +0,0 @@
<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>

View File

@@ -1,13 +0,0 @@
<script setup lang="ts">
const value = ref(0.05)
</script>
<template>
<UInputNumber
v-model="value"
:step="0.01"
:format-options="{
style: 'percent'
}"
/>
</template>

View File

@@ -1,15 +0,0 @@
<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>

View File

@@ -6,7 +6,7 @@ const value = ref('Click to clear')
<UInput <UInput
v-model="value" v-model="value"
placeholder="Type something..." placeholder="Type something..."
:ui="{ trailing: 'pe-1' }" :ui="{ trailing: 'pr-0.5' }"
> >
<template v-if="value?.length" #trailing> <template v-if="value?.length" #trailing>
<UButton <UButton

View File

@@ -1,33 +0,0 @@
<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>

View File

@@ -1,21 +0,0 @@
<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>

View File

@@ -40,7 +40,7 @@ const text = computed(() => {
placeholder="Password" placeholder="Password"
:color="color" :color="color"
:type="show ? 'text' : 'password'" :type="show ? 'text' : 'password'"
:ui="{ trailing: 'pe-1' }" :ui="{ trailing: 'pr-0.5' }"
:aria-invalid="score < 4" :aria-invalid="score < 4"
aria-describedby="password-strength" aria-describedby="password-strength"
class="w-full" class="w-full"

View File

@@ -8,7 +8,7 @@ const password = ref('password')
v-model="password" v-model="password"
placeholder="Password" placeholder="Password"
:type="show ? 'text' : 'password'" :type="show ? 'text' : 'password'"
:ui="{ trailing: 'pe-1' }" :ui="{ trailing: 'pr-0.5' }"
> >
<template #trailing> <template #trailing>
<UButton <UButton

View File

@@ -13,7 +13,7 @@ const groups = computed(() => [{
id: 'users', id: 'users',
label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users', label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users',
items: users.value || [], items: users.value || [],
ignoreFilter: true filter: false
}]) }])
</script> </script>

View File

@@ -4,21 +4,12 @@ const modal = useModal()
defineProps<{ defineProps<{
count: number count: number
}>() }>()
const emit = defineEmits(['success'])
function onSuccess() {
emit('success')
}
</script> </script>
<template> <template>
<UModal :title="`This modal was opened programmatically ${count} times`"> <UModal :title="`This modal was opened programmatically ${count} times`">
<template #footer> <template #footer>
<div class="flex gap-2"> <UButton color="neutral" label="Close" @click="modal.close()" />
<UButton color="neutral" label="Close" @click="modal.close()" />
<UButton label="Success" @click="onSuccess" />
</div>
</template> </template>
</UModal> </UModal>
</template> </template>

View File

@@ -3,7 +3,6 @@ import { LazyModalExample } from '#components'
const count = ref(0) const count = ref(0)
const toast = useToast()
const modal = useModal() const modal = useModal()
function open() { function open() {
@@ -11,13 +10,7 @@ function open() {
modal.open(LazyModalExample, { modal.open(LazyModalExample, {
description: 'And you can even provide a description!', description: 'And you can even provide a description!',
count: count.value, count: count.value
onSuccess() {
toast.add({
title: 'Success !',
id: 'modal-success'
})
}
}) })
} }
</script> </script>

View File

@@ -59,9 +59,9 @@ const items = [
<template> <template>
<UNavigationMenu <UNavigationMenu
:items="items" :items="items"
class="w-full justify-center" class="justify-center"
:ui="{ :ui="{
viewport: 'sm:w-[var(--reka-navigation-menu-viewport-width)]', viewport: 'sm:w-[var(--radix-navigation-menu-viewport-width)]',
childList: 'sm:w-96', childList: 'sm:w-96',
childLinkDescription: 'text-balance line-clamp-2' childLinkDescription: 'text-balance line-clamp-2'
}" }"

View File

@@ -19,7 +19,7 @@ const items = [
</script> </script>
<template> <template>
<UNavigationMenu :items="items" class="w-full justify-center"> <UNavigationMenu :items="items" class="justify-center">
<template #components-trailing> <template #components-trailing>
<UBadge label="44" variant="subtle" size="sm" /> <UBadge label="44" variant="subtle" size="sm" />
</template> </template>

View File

@@ -111,5 +111,5 @@ defineShortcuts({
</script> </script>
<template> <template>
<UNavigationMenu v-model="active" :items="items" class="w-full justify-center" /> <UNavigationMenu v-model="active" :items="items" class="justify-center" />
</template> </template>

View File

@@ -1,21 +0,0 @@
<script setup lang="ts">
const open = ref(false)
</script>
<template>
<UPopover v-model:open="open" :dismissible="false" :ui="{ content: 'p-4' }">
<UButton label="Open" color="neutral" variant="subtle" />
<template #content>
<div class="flex items-center gap-4 mb-4">
<h2 class="text-[var(--ui-text-highlighted)] font-semibold">
Popover non-dismissible
</h2>
<UButton color="neutral" variant="ghost" icon="i-lucide-x" @click="open = false" />
</div>
<Placeholder class="size-full min-h-48" />
</template>
</UPopover>
</template>

View File

@@ -1,20 +0,0 @@
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
function onCreate(item: string) {
items.value.push(item)
value.value = item
}
</script>
<template>
<USelectMenu
v-model="value"
create-item
:items="items"
class="w-48"
@create="onCreate"
/>
</template>

View File

@@ -20,7 +20,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
v-model:search-term="searchTerm" v-model:search-term="searchTerm"
:items="users || []" :items="users || []"
:loading="status === 'pending'" :loading="status === 'pending'"
ignore-filter :filter="false"
icon="i-lucide-user" icon="i-lucide-user"
placeholder="Select user" placeholder="Select user"
class="w-48" class="w-48"

View File

@@ -16,7 +16,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
<USelectMenu <USelectMenu
:items="users || []" :items="users || []"
:loading="status === 'pending'" :loading="status === 'pending'"
:filter-fields="['label', 'email']" :filter="['label', 'email']"
icon="i-lucide-user" icon="i-lucide-user"
placeholder="Select user" placeholder="Select user"
class="w-80" class="w-80"

View File

@@ -26,7 +26,7 @@ function getUserAvatar(value: string) {
<template #leading="{ modelValue, ui }"> <template #leading="{ modelValue, ui }">
<UAvatar <UAvatar
v-if="modelValue" v-if="modelValue"
v-bind="getUserAvatar(modelValue as string)" v-bind="getUserAvatar(modelValue)"
:size="ui.leadingAvatarSize()" :size="ui.leadingAvatarSize()"
:class="ui.leadingAvatar()" :class="ui.leadingAvatar()"
/> />

View File

@@ -34,7 +34,7 @@ function getChip(value: string) {
<template #leading="{ modelValue, ui }"> <template #leading="{ modelValue, ui }">
<UChip <UChip
v-if="modelValue" v-if="modelValue"
v-bind="getChip(modelValue as string)" v-bind="getChip(modelValue)"
inset inset
standalone standalone
:size="ui.itemLeadingChipSize()" :size="ui.itemLeadingChipSize()"

View File

@@ -4,12 +4,6 @@ const slideover = useSlideover()
defineProps<{ defineProps<{
count: number count: number
}>() }>()
const emit = defineEmits(['success'])
function onSuccess() {
emit('success')
}
</script> </script>
<template> <template>
@@ -19,10 +13,7 @@ function onSuccess() {
</template> </template>
<template #footer> <template #footer>
<div class="flex gap-2"> <UButton color="neutral" label="Close" @click="slideover.close()" />
<UButton color="neutral" label="Close" @click="slideover.close()" />
<UButton label="Success" @click="onSuccess" />
</div>
</template> </template>
</USlideover> </USlideover>
</template> </template>

View File

@@ -3,7 +3,6 @@ import { LazySlideoverExample } from '#components'
const count = ref(0) const count = ref(0)
const toast = useToast()
const slideover = useSlideover() const slideover = useSlideover()
function open() { function open() {
@@ -11,13 +10,7 @@ function open() {
slideover.open(LazySlideoverExample, { slideover.open(LazySlideoverExample, {
title: 'Slideover', title: 'Slideover',
count: count.value, count: count.value
onSuccess() {
toast.add({
title: 'Success !',
id: 'modal-success'
})
}
}) })
} }
</script> </script>

View File

@@ -1,26 +0,0 @@
<script setup lang="ts">
const items = [
{
title: 'Address',
description: 'Add your address here',
icon: 'i-lucide-house'
}, {
title: 'Shipping',
description: 'Set your preferred shipping method',
icon: 'i-lucide-truck'
}, {
title: 'Checkout',
description: 'Confirm your order'
}
]
</script>
<template>
<UStepper ref="stepper" :items="items" class="w-full">
<template #content="{ item }">
<Placeholder class="aspect-video">
This is the {{ item?.title }} step.
</Placeholder>
</template>
</UStepper>
</template>

View File

@@ -1,41 +0,0 @@
<script setup lang="ts">
const items = [
{
slot: 'address',
title: 'Address',
description: 'Add your address here',
icon: 'i-lucide-house'
}, {
slot: 'shipping',
title: 'Shipping',
description: 'Set your preferred shipping method',
icon: 'i-lucide-truck'
}, {
slot: 'checkout',
title: 'Checkout',
description: 'Confirm your order'
}
]
</script>
<template>
<UStepper :items="items" class="w-full">
<template #address>
<Placeholder class="aspect-video">
Address
</Placeholder>
</template>
<template #shipping>
<Placeholder class="aspect-video">
Shipping
</Placeholder>
</template>
<template #checkout>
<Placeholder class="aspect-video">
Checkout
</Placeholder>
</template>
</UStepper>
</template>

View File

@@ -1,37 +0,0 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
const items = [
{
title: 'Address',
description: 'Add your address here',
icon: 'i-lucide-house'
}, {
title: 'Shipping',
description: 'Set your preferred shipping method',
icon: 'i-lucide-truck'
}, {
title: 'Checkout',
description: 'Confirm your order'
}
]
const active = ref(0)
// Note: This is for demonstration purposes only. Don't do this at home.
onMounted(() => {
setInterval(() => {
active.value = (active.value + 1) % items.length
}, 2000)
})
</script>
<template>
<UStepper v-model="active" :items="items" class="w-full">
<template #content="{ item }">
<Placeholder class="aspect-video">
This is the {{ item?.title }} step.
</Placeholder>
</template>
</UStepper>
</template>

View File

@@ -1,51 +0,0 @@
<script setup lang="ts">
const items = [
{
slot: 'address',
title: 'Address',
description: 'Add your address here',
icon: 'i-lucide-house'
}, {
slot: 'shipping',
title: 'Shipping',
description: 'Set your preferred shipping method',
icon: 'i-lucide-truck'
}, {
slot: 'checkout',
title: 'Checkout',
description: 'Confirm your order'
}
]
const stepper = useTemplateRef('stepper')
</script>
<template>
<div class="w-full">
<UStepper ref="stepper" :items="items">
<template #content="{ item }">
<Placeholder class="aspect-video">
{{ item.title }}
</Placeholder>
</template>
</UStepper>
<div class="flex gap-2 justify-between mt-4">
<UButton
leading-icon="i-lucide-arrow-left"
:disabled="!stepper?.hasPrev"
@click="stepper?.prev()"
>
Prev
</UButton>
<UButton
trailing-icon="i-lucide-arrow-right"
:disabled="!stepper?.hasNext"
@click="stepper?.next()"
>
Next
</UButton>
</div>
</div>
</template>

View File

@@ -143,13 +143,14 @@ const data = ref<Payment[]>([{
const columns: TableColumn<Payment>[] = [{ const columns: TableColumn<Payment>[] = [{
id: 'select', id: 'select',
header: ({ table }) => h(UCheckbox, { header: ({ table }) => h(UCheckbox, {
'modelValue': table.getIsSomePageRowsSelected() ? 'indeterminate' : table.getIsAllPageRowsSelected(), 'modelValue': table.getIsAllPageRowsSelected(),
'onUpdate:modelValue': (value: boolean | 'indeterminate') => table.toggleAllPageRowsSelected(!!value), 'indeterminate': table.getIsSomePageRowsSelected(),
'onUpdate:modelValue': (value: boolean) => table.toggleAllPageRowsSelected(!!value),
'ariaLabel': 'Select all' 'ariaLabel': 'Select all'
}), }),
cell: ({ row }) => h(UCheckbox, { cell: ({ row }) => h(UCheckbox, {
'modelValue': row.getIsSelected(), 'modelValue': row.getIsSelected(),
'onUpdate:modelValue': (value: boolean | 'indeterminate') => row.toggleSelected(!!value), 'onUpdate:modelValue': (value: boolean) => row.toggleSelected(!!value),
'ariaLabel': 'Select row' 'ariaLabel': 'Select row'
}), }),
enableSorting: false, enableSorting: false,

View File

@@ -48,13 +48,14 @@ const data = ref<Payment[]>([{
const columns: TableColumn<Payment>[] = [{ const columns: TableColumn<Payment>[] = [{
id: 'select', id: 'select',
header: ({ table }) => h(UCheckbox, { header: ({ table }) => h(UCheckbox, {
'modelValue': table.getIsSomePageRowsSelected() ? 'indeterminate' : table.getIsAllPageRowsSelected(), 'modelValue': table.getIsAllPageRowsSelected(),
'onUpdate:modelValue': (value: boolean | 'indeterminate') => table.toggleAllPageRowsSelected(!!value), 'indeterminate': table.getIsSomePageRowsSelected(),
'onUpdate:modelValue': (value: boolean) => table.toggleAllPageRowsSelected(!!value),
'ariaLabel': 'Select all' 'ariaLabel': 'Select all'
}), }),
cell: ({ row }) => h(UCheckbox, { cell: ({ row }) => h(UCheckbox, {
'modelValue': row.getIsSelected(), 'modelValue': row.getIsSelected(),
'onUpdate:modelValue': (value: boolean | 'indeterminate') => row.toggleSelected(!!value), 'onUpdate:modelValue': (value: boolean) => row.toggleSelected(!!value),
'ariaLabel': 'Select row' 'ariaLabel': 'Select row'
}) })
}, { }, {

View File

@@ -10,7 +10,7 @@ function showToast() {
title: 'Uh oh! Something went wrong.', title: 'Uh oh! Something went wrong.',
description: props.description, description: props.description,
actions: [{ actions: [{
icon: 'i-lucide-refresh-cw', icon: 'i-lucide-refresh-ccw',
label: 'Retry', label: 'Retry',
color: 'neutral', color: 'neutral',
variant: 'outline', variant: 'outline',

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