mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 08:20:39 +01:00
Compare commits
199 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b830f63c89 | ||
|
|
71dac5e5b0 | ||
|
|
7b81bfa1ae | ||
|
|
bf1c9e7c94 | ||
|
|
23d9b51a58 | ||
|
|
2e6ba71e89 | ||
|
|
ea4007c62d | ||
|
|
69d6997210 | ||
|
|
6565472570 | ||
|
|
ee408e522e | ||
|
|
461e6173a9 | ||
|
|
b824f0682e | ||
|
|
7ce6af4870 | ||
|
|
b4cc9a5ab4 | ||
|
|
06eceff68b | ||
|
|
40f3e3b486 | ||
|
|
a5458765dc | ||
|
|
ac574b239b | ||
|
|
feb716c941 | ||
|
|
15da5cf71e | ||
|
|
125a28190b | ||
|
|
569fa7619b | ||
|
|
0ff2448655 | ||
|
|
a6c3daa363 | ||
|
|
e16eeee8c1 | ||
|
|
53ac62eae5 | ||
|
|
9c36d37b84 | ||
|
|
0462edb84e | ||
|
|
91e77bb09c | ||
|
|
84e35d1a79 | ||
|
|
28f29e98b8 | ||
|
|
81d7ca0cd1 | ||
|
|
89d3766835 | ||
|
|
9104213d35 | ||
|
|
d699558e38 | ||
|
|
7cbc3913d9 | ||
|
|
d2ceeadae7 | ||
|
|
c7f64b64c7 | ||
|
|
72ab47e77d | ||
|
|
5b187d6fbd | ||
|
|
f9e61fc422 | ||
|
|
1291e95e1c | ||
|
|
f943203770 | ||
|
|
f2d387622a | ||
|
|
b02dc4d5b7 | ||
|
|
6dddadc370 | ||
|
|
d89ecce472 | ||
|
|
efb74668bd | ||
|
|
e065734d58 | ||
|
|
0c5bea5f11 | ||
|
|
f6d4dd3b88 | ||
|
|
d9d4f1915a | ||
|
|
c70d29702e | ||
|
|
a0d8935f64 | ||
|
|
04aefcf81f | ||
|
|
e68b9795be | ||
|
|
b8c8718560 | ||
|
|
2a33a8171d | ||
|
|
23cfc046e7 | ||
|
|
e68cb53ab6 | ||
|
|
109b857472 | ||
|
|
ea15e21cdc | ||
|
|
b7153cd879 | ||
|
|
5047d448ed | ||
|
|
a0fee0fa73 | ||
|
|
b762d29220 | ||
|
|
98c19be71a | ||
|
|
8cf9f27d53 | ||
|
|
c0455c831f | ||
|
|
0360ea7a3c | ||
|
|
711539f3ce | ||
|
|
80d6d89467 | ||
|
|
d573fb636f | ||
|
|
1d08d319a7 | ||
|
|
b654c93e93 | ||
|
|
b7e04db645 | ||
|
|
e6034a2765 | ||
|
|
a8c38224c6 | ||
|
|
a9ef6406ea | ||
|
|
96e846ddee | ||
|
|
16dbc1b536 | ||
|
|
c6b2ae45e5 | ||
|
|
547c657ee7 | ||
|
|
b16b434041 | ||
|
|
fb12323304 | ||
|
|
0a404615ff | ||
|
|
cbf0f22efd | ||
|
|
4cde571e38 | ||
|
|
023497d144 | ||
|
|
56d4ca3b74 | ||
|
|
11b8c3d9db | ||
|
|
419a24f703 | ||
|
|
854bb81295 | ||
|
|
bf8e3954a4 | ||
|
|
637ec4d27b | ||
|
|
f3632ddee5 | ||
|
|
dbd2aed20b | ||
|
|
51c8b8e3e5 | ||
|
|
588a908358 | ||
|
|
d692a81b1e | ||
|
|
ec98d415b4 | ||
|
|
c80d2e6c12 | ||
|
|
ce61a2b6db | ||
|
|
eee5bb9939 | ||
|
|
d3804157ec | ||
|
|
03e24f4583 | ||
|
|
d0e626c551 | ||
|
|
670d8bfbac | ||
|
|
64b703df8d | ||
|
|
976b03f241 | ||
|
|
35e3b8c720 | ||
|
|
07ef771b17 | ||
|
|
5c75b5c490 | ||
|
|
53df9d9a8c | ||
|
|
0d1a76e3c6 | ||
|
|
b2ed4662af | ||
|
|
423c48879d | ||
|
|
acecff40ec | ||
|
|
1fd5fac295 | ||
|
|
b23f2decfc | ||
|
|
7154254ac2 | ||
|
|
49f85d55c5 | ||
|
|
97037864b3 | ||
|
|
0abccabc26 | ||
|
|
ac323c4ccc | ||
|
|
d4e408cfd8 | ||
|
|
f3bf69c233 | ||
|
|
d6daf466ac | ||
|
|
6e66990372 | ||
|
|
56e28d80db | ||
|
|
24e61ccc8b | ||
|
|
c9e6256e7f | ||
|
|
ce955d24f1 | ||
|
|
bf580863af | ||
|
|
f38a217032 | ||
|
|
717a027bad | ||
|
|
159acd664c | ||
|
|
212f7df35b | ||
|
|
d0d37a06d2 | ||
|
|
cb6f5f2d71 | ||
|
|
22da1a839a | ||
|
|
c5f76a25db | ||
|
|
ceecb60c3b | ||
|
|
23971efdb0 | ||
|
|
1a94b55caa | ||
|
|
c71fdc8795 | ||
|
|
6844f7bbd9 | ||
|
|
1acd01a440 | ||
|
|
0b2a3989a2 | ||
|
|
5f8d645231 | ||
|
|
2cc838ea8b | ||
|
|
2e41e3f238 | ||
|
|
7cb8218ed5 | ||
|
|
ddf67a060b | ||
|
|
54e713d31a | ||
|
|
09e232ed05 | ||
|
|
1d455b092d | ||
|
|
13957ba206 | ||
|
|
ff1806143c | ||
|
|
b6ed1c59ff | ||
|
|
424efe783e | ||
|
|
c3cd3c9940 | ||
|
|
8ab4a14394 | ||
|
|
25378df1d8 | ||
|
|
070d2f89b6 | ||
|
|
8e413f0681 | ||
|
|
03ac697167 | ||
|
|
c6a9b499e3 | ||
|
|
cae4f0c4a8 | ||
|
|
b29fcd2650 | ||
|
|
3671b2fbbe | ||
|
|
2577eb2780 | ||
|
|
3d1be39221 | ||
|
|
49e04389fa | ||
|
|
ee364318d1 | ||
|
|
b14afbebe9 | ||
|
|
4bf81be364 | ||
|
|
7846ca35b5 | ||
|
|
b72d3434e9 | ||
|
|
20fb46a3ba | ||
|
|
1b7e36cf70 | ||
|
|
3768cd9803 | ||
|
|
3d0bba2e83 | ||
|
|
494e73932b | ||
|
|
38200aa392 | ||
|
|
19b01f43f1 | ||
|
|
c36964b5ea | ||
|
|
4de8f2e2f7 | ||
|
|
3cf19ea5af | ||
|
|
9dd7e615e9 | ||
|
|
33b9a445c4 | ||
|
|
46cec7ecd1 | ||
|
|
f8e2c94375 | ||
|
|
71e0492179 | ||
|
|
3cda6c6478 | ||
|
|
428ee44fc0 | ||
|
|
c68ba76fd0 | ||
|
|
dd0d0551be | ||
|
|
3efcf3026a |
@@ -1,14 +0,0 @@
|
|||||||
node_modules
|
|
||||||
dist
|
|
||||||
.nuxt
|
|
||||||
coverage
|
|
||||||
*.log*
|
|
||||||
.DS_Store
|
|
||||||
.code
|
|
||||||
*.iml
|
|
||||||
package-lock.json
|
|
||||||
templates/*
|
|
||||||
sw.js
|
|
||||||
|
|
||||||
# Templates
|
|
||||||
src/templates
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
extends: ['@nuxt/eslint-config'],
|
|
||||||
rules: {
|
|
||||||
// General
|
|
||||||
semi: ['error', 'never'],
|
|
||||||
quotes: ['error', 'single'],
|
|
||||||
'comma-dangle': ['error', 'never'],
|
|
||||||
'comma-spacing': ['error', { before: false, after: true }],
|
|
||||||
'keyword-spacing': ['error', { before: true, after: true }],
|
|
||||||
'space-before-function-paren': ['error', 'always'],
|
|
||||||
'object-curly-spacing': ['error', 'always'],
|
|
||||||
'arrow-spacing': ['error', { before: true, after: true }],
|
|
||||||
'key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'strict' }],
|
|
||||||
'space-before-blocks': ['error', 'always'],
|
|
||||||
'space-infix-ops': ['error', { int32Hint: false }],
|
|
||||||
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
|
|
||||||
'no-trailing-spaces': ['error'],
|
|
||||||
|
|
||||||
// Typescript
|
|
||||||
'@typescript-eslint/type-annotation-spacing': 'error',
|
|
||||||
|
|
||||||
// Vuejs
|
|
||||||
'vue/multi-word-component-names': 0,
|
|
||||||
'vue/html-indent': ['error', 2],
|
|
||||||
'vue/comma-spacing': ['error', { before: false, after: true }],
|
|
||||||
'vue/script-indent': ['error', 2, { baseIndent: 0 }],
|
|
||||||
'vue/keyword-spacing': ['error', { before: true, after: true }],
|
|
||||||
'vue/object-curly-spacing': ['error', 'always'],
|
|
||||||
'vue/key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'strict' }],
|
|
||||||
'vue/arrow-spacing': ['error', { before: true, after: true }],
|
|
||||||
'vue/array-bracket-spacing': ['error', 'never'],
|
|
||||||
'vue/block-spacing': ['error', 'always'],
|
|
||||||
'vue/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
||||||
'vue/space-infix-ops': ['error', { int32Hint: false }],
|
|
||||||
'vue/max-attributes-per-line': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
singleline: {
|
|
||||||
max: 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'vue/padding-line-between-blocks': ['error', 'always']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
11
.github/ISSUE_TEMPLATE/bug-v3.yml
vendored
11
.github/ISSUE_TEMPLATE/bug-v3.yml
vendored
@@ -29,11 +29,20 @@ body:
|
|||||||
- Build Modules: `-`
|
- Build Modules: `-`
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: package
|
||||||
|
attributes:
|
||||||
|
label: Is this bug related to Nuxt or Vue?
|
||||||
|
options:
|
||||||
|
- Nuxt
|
||||||
|
- Vue
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
- type: input
|
- type: input
|
||||||
id: version
|
id: version
|
||||||
attributes:
|
attributes:
|
||||||
label: Version
|
label: Version
|
||||||
placeholder: v3.0.0-alpha.5
|
placeholder: v3.0.0-alpha.x
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
9
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
9
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -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:
|
||||||
|
|||||||
9
.github/ISSUE_TEMPLATE/question.yml
vendored
9
.github/ISSUE_TEMPLATE/question.yml
vendored
@@ -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:
|
||||||
|
|||||||
17
.github/workflows/ci-dev.yml
vendored
17
.github/workflows/ci-dev.yml
vendored
@@ -37,16 +37,6 @@ jobs:
|
|||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
|
||||||
- name: Filter changes
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
id: changes
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
src:
|
|
||||||
- 'src/**'
|
|
||||||
- 'package.json'
|
|
||||||
- 'pnpm-lock.yaml'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
@@ -65,8 +55,5 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: pnpm run test run
|
run: pnpm run test run
|
||||||
|
|
||||||
- name: Release Edge
|
- name: Publish
|
||||||
if: github.event_name == 'push' && steps.changes.outputs.src == 'true'
|
run: pnpx pkg-pr-new publish --compact --no-template --pnpm
|
||||||
run: ./scripts/release-edge.sh
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
|
|
||||||
|
|||||||
100
CHANGELOG.md
100
CHANGELOG.md
@@ -1,5 +1,105 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [2.21.1](https://github.com/nuxt/ui/compare/v2.21.0...v2.21.1) (2025-03-08)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **Form:** add standard schema support ([#2880](https://github.com/nuxt/ui/issues/2880)) ([9c36d37](https://github.com/nuxt/ui/commit/9c36d37b847468d1cbd76eea38ac00cbc22549ca))
|
||||||
|
* **module:** add `colorMode` option ([d2ceead](https://github.com/nuxt/ui/commit/d2ceeadae796254128697d94a3e317234bc2ecda)), closes [#3143](https://github.com/nuxt/ui/issues/3143)
|
||||||
|
* **SelectMenu:** add inputTargetForm prop to handle input validation ([#3107](https://github.com/nuxt/ui/issues/3107)) ([feb716c](https://github.com/nuxt/ui/commit/feb716c941f1e7315009b53861a4dc0c2f233052))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Alert/Notification:** allow description ui override ([125a281](https://github.com/nuxt/ui/commit/125a28190b1a83e2456457e7a4ec618384b2446c)), closes [#2554](https://github.com/nuxt/ui/issues/2554)
|
||||||
|
* **Table:** revert [#2600](https://github.com/nuxt/ui/issues/2600) to fix excessive column data slot re-renders ([#3375](https://github.com/nuxt/ui/issues/3375)) ([23d9b51](https://github.com/nuxt/ui/commit/23d9b51a5861f5d1f32f68a3141a600655a0598a))
|
||||||
|
|
||||||
|
## [2.21.0](https://github.com/nuxt/ui/compare/v2.20.0...v2.21.0) (2025-01-14)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **module:** handle `tailwindMerge` config from `app.config` ([#2902](https://github.com/nuxt/ui/issues/2902)) ([ea15e21](https://github.com/nuxt/ui/commit/ea15e21cdcba00e21302415829113e8c6def8a6e))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Table:** `v-model` causing first column missing ([#2890](https://github.com/nuxt/ui/issues/2890)) ([d573fb6](https://github.com/nuxt/ui/commit/d573fb636f7f749ce95b93c5fb1ae2a053eeeeb0))
|
||||||
|
* **Table:** remove `[@select](https://github.com/select)` event on checkbox ([#3042](https://github.com/nuxt/ui/issues/3042)) ([d9d4f19](https://github.com/nuxt/ui/commit/d9d4f1915aac586ae1abf3ebe67ca9aff65b9be0))
|
||||||
|
* **tailwind:** use mjs template ([#2945](https://github.com/nuxt/ui/issues/2945)) ([8cf9f27](https://github.com/nuxt/ui/commit/8cf9f27d537bad5ffe4e136f52ff71548a451c5f))
|
||||||
|
|
||||||
|
## [2.20.0](https://github.com/nuxt/ui/compare/v2.19.2...v2.20.0) (2024-12-09)
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* **Form:** resolve async validation in yup & issue directly mutate state (#2701)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **Accordion:** add `close` event ([#2750](https://github.com/nuxt/ui/issues/2750)) ([419a24f](https://github.com/nuxt/ui/commit/419a24f7034cefda2c6669f3c26742552e500f63))
|
||||||
|
* **Badge:** handle `icon` prop ([#2594](https://github.com/nuxt/ui/issues/2594)) ([0d1a76e](https://github.com/nuxt/ui/commit/0d1a76e3c69e08534abb295b96548e67cfbea00c))
|
||||||
|
* **InputMenu/SelectMenu:** add support for `dot notation` in `by` prop ([#2607](https://github.com/nuxt/ui/issues/2607)) ([53df9d9](https://github.com/nuxt/ui/commit/53df9d9a8cd6850803bdafc7ef6efe4e7404d334))
|
||||||
|
* **Link:** allow partial query match for `activeClass` ([#2663](https://github.com/nuxt/ui/issues/2663)) ([03e24f4](https://github.com/nuxt/ui/commit/03e24f45836bdddd94b30cbaecc2288a78b56b0b))
|
||||||
|
* **Notification:** add `pauseTimeoutOnHover` prop ([#2661](https://github.com/nuxt/ui/issues/2661)) ([11b8c3d](https://github.com/nuxt/ui/commit/11b8c3d9db1ec62b1c3557703c7ab5c99cb42df5))
|
||||||
|
* **Table:** add contextmenu handling to table rows ([#2283](https://github.com/nuxt/ui/issues/2283)) ([c9e6256](https://github.com/nuxt/ui/commit/c9e6256e7f2c06da8bfda13700f56f6994e76eab))
|
||||||
|
* **Table:** add custom `[@select](https://github.com/select):all` event ([#2581](https://github.com/nuxt/ui/issues/2581)) ([ac323c4](https://github.com/nuxt/ui/commit/ac323c4cccd930f2cd8c1f54b325bd509acd40bf))
|
||||||
|
* **Table:** allow dynamically render `checkbox` ([#2549](https://github.com/nuxt/ui/issues/2549)) ([d6daf46](https://github.com/nuxt/ui/commit/d6daf466ace42b828151c45b18cd47179e85d66d))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **AvatarGroup/ButtonGroup/MeterGroup:** allow deeply partial `ui` config ([#2542](https://github.com/nuxt/ui/issues/2542)) ([bf58086](https://github.com/nuxt/ui/commit/bf580863af11d6a1a4c6c6774b44ec37b082e933))
|
||||||
|
* **Carousel:** wrong `ui` type with `strategy` ([07ef771](https://github.com/nuxt/ui/commit/07ef771b17c72e275508a273371454a5e8a62257))
|
||||||
|
* **components:** replace `as const` with correct type in config ([#2652](https://github.com/nuxt/ui/issues/2652)) ([51c8b8e](https://github.com/nuxt/ui/commit/51c8b8e3e59d7eceff72625650a199fcf7c6feca))
|
||||||
|
* **date-picker:** undefined `dayIndex` ([#2545](https://github.com/nuxt/ui/issues/2545)) ([ce955d2](https://github.com/nuxt/ui/commit/ce955d24f1dfd222e87ce88428c0612c3f13cd50))
|
||||||
|
* **Form:** resolve async validation in yup & issue directly mutate state ([#2701](https://github.com/nuxt/ui/issues/2701)) ([f3632dd](https://github.com/nuxt/ui/commit/f3632ddee511f0fccb24d4fc37403421e84ffdae))
|
||||||
|
* **Form:** use parsed value from `joi` instead of original state ([#2587](https://github.com/nuxt/ui/issues/2587)) ([acecff4](https://github.com/nuxt/ui/commit/acecff40ec0156e45b4934c5d10c4dfa7c135f8e))
|
||||||
|
* **InputMenu/SelectMenu:** use `by` prop to compare objects & support dot notation in `value-attribute` ([#2566](https://github.com/nuxt/ui/issues/2566)) ([7154254](https://github.com/nuxt/ui/commit/7154254ac22830f651ec200f7f3af2f5577f2de0))
|
||||||
|
* **Link:** `exactQuery` prop type ([#2781](https://github.com/nuxt/ui/issues/2781)) ([4cde571](https://github.com/nuxt/ui/commit/4cde571e387775a9b12759f6f8c99117c84cbcff))
|
||||||
|
* **Notification:** element renders even when no `notification` is present ([#2561](https://github.com/nuxt/ui/issues/2561)) ([d4e408c](https://github.com/nuxt/ui/commit/d4e408cfd8e2ef26021519f2f30f57e9120e1939))
|
||||||
|
* **Table:** data outdated when rows change ([#2600](https://github.com/nuxt/ui/issues/2600)) ([b23f2de](https://github.com/nuxt/ui/commit/b23f2decfc9607555a315d0d087d0a042f03a938))
|
||||||
|
* **Table:** missing type on props `loadingState` ([#2551](https://github.com/nuxt/ui/issues/2551)) ([6e66990](https://github.com/nuxt/ui/commit/6e66990372ef6bd7c109a64c753d9b50e96a450b))
|
||||||
|
* **Table:** prevent `onClick` while blocking element ([#2592](https://github.com/nuxt/ui/issues/2592)) ([9703786](https://github.com/nuxt/ui/commit/97037864b39749db228fa5f51981f19e4a9c29dd))
|
||||||
|
* **types:** improve `DeepPartial` type for App Config ([#2621](https://github.com/nuxt/ui/issues/2621)) ([976b03f](https://github.com/nuxt/ui/commit/976b03f241ef9626a6338685e43c844a8b3953fd))
|
||||||
|
|
||||||
|
## [2.19.2](https://github.com/nuxt/ui/compare/v2.19.1...v2.19.2) (2024-11-05)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Button:** put back `target` override ([212f7df](https://github.com/nuxt/ui/commit/212f7df35b9f81d189e1ee3e34f6fd2234cf52fe))
|
||||||
|
|
||||||
|
## [2.19.1](https://github.com/nuxt/ui/compare/v2.19.0...v2.19.1) (2024-11-05)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **InputMenu/SelectMenu:** regex breaks build ([cb6f5f2](https://github.com/nuxt/ui/commit/cb6f5f2d71ea8bb526a8f958daec8e9871469b63))
|
||||||
|
|
||||||
|
## [2.19.0](https://github.com/nuxt/ui/compare/v2.18.7...v2.19.0) (2024-11-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **Form:** add `superstruct` validation ([#2357](https://github.com/nuxt/ui/issues/2357)) ([3cda6c6](https://github.com/nuxt/ui/commit/3cda6c6478d5284a3ffcb973270831601e8e5657))
|
||||||
|
* **Form:** apply transformations ([#2460](https://github.com/nuxt/ui/issues/2460)) ([ceecb60](https://github.com/nuxt/ui/commit/ceecb60c3bbd5507b1f54faed001818639d9269c))
|
||||||
|
* **Input/Textarea:** nullify model modifier ([#2309](https://github.com/nuxt/ui/issues/2309)) ([9dd7e61](https://github.com/nuxt/ui/commit/9dd7e615e97b6bf3c4c4096edd35a86ca3cfd53c))
|
||||||
|
* **InputMenu:** allows to customize labels ([#2295](https://github.com/nuxt/ui/issues/2295)) ([ddf67a0](https://github.com/nuxt/ui/commit/ddf67a060ba659f102673eff31eb2e30231c2d93))
|
||||||
|
* **Pagination:** improve slot props ([#2522](https://github.com/nuxt/ui/issues/2522)) ([c71fdc8](https://github.com/nuxt/ui/commit/c71fdc8795812bed779ab247451efd3db031e4cd))
|
||||||
|
* **SelectMenu:** allows to customize labels ([#2266](https://github.com/nuxt/ui/issues/2266)) ([54e713d](https://github.com/nuxt/ui/commit/54e713d31ae0b80b0f69dd507f71387100204ac3))
|
||||||
|
* **Table:** improve `expanded` row ([#2485](https://github.com/nuxt/ui/issues/2485)) ([1acd01a](https://github.com/nuxt/ui/commit/1acd01a440db7a7fa765189d8bde424ade9074e9))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Accordion:** improve `items` type ([#2487](https://github.com/nuxt/ui/issues/2487)) ([25378df](https://github.com/nuxt/ui/commit/25378df1d894546c4b08eb43a58b02b40ab9649b))
|
||||||
|
* **Button:** wrong `to` type ([8ab4a14](https://github.com/nuxt/ui/commit/8ab4a14394e0890b33a610e6491d891e89386959)), closes [#1253](https://github.com/nuxt/ui/issues/1253)
|
||||||
|
* **Divider:** default `type` from app config ([7846ca3](https://github.com/nuxt/ui/commit/7846ca35b5332a9e70f9990059f6041d60770e79)), closes [nuxt/ui#2398](https://github.com/nuxt/ui/issues/2398)
|
||||||
|
* **HorizontalNavigation/VerticalNavigation:** handle `badge` in RTL mode ([#2420](https://github.com/nuxt/ui/issues/2420)) ([4bf81be](https://github.com/nuxt/ui/commit/4bf81be36463bf280f31099c97a751e65240dcf5))
|
||||||
|
* **InputMenu/SelectMenu:** allow access nested object in `option-attribute` ([#2465](https://github.com/nuxt/ui/issues/2465)) ([ff18061](https://github.com/nuxt/ui/commit/ff1806143c45a7d83b00e78bec979a8f412a2827))
|
||||||
|
* **InputMenu/SelectMenu:** escape regexp before search ([c68ba76](https://github.com/nuxt/ui/commit/c68ba76fd0eebf411ccd5f047ee9a01b8ec5f5de)), closes [nuxt/ui#2308](https://github.com/nuxt/ui/issues/2308)
|
||||||
|
* **InputMenu/SelectMenu:** prevent unnecessary updates when modelValue is unchanged ([#2507](https://github.com/nuxt/ui/issues/2507)) ([1a94b55](https://github.com/nuxt/ui/commit/1a94b55caac91685f518ae4c24ca8dcbee827f86))
|
||||||
|
* **module:** missing types in `ui` config ([#2467](https://github.com/nuxt/ui/issues/2467)) ([23971ef](https://github.com/nuxt/ui/commit/23971efdb007701352ce58412db597cd95b9996b))
|
||||||
|
* **Progress:** handle `carousel` and `carousel-inverse` animations in RTL mode ([#2400](https://github.com/nuxt/ui/issues/2400)) ([20fb46a](https://github.com/nuxt/ui/commit/20fb46a3ba8d74fcaa1407b23d65b117cc9d6802))
|
||||||
|
* **RadioGroup:** rendering empty slots ([#2456](https://github.com/nuxt/ui/issues/2456)) ([b6ed1c5](https://github.com/nuxt/ui/commit/b6ed1c59ffe8c8aaac78a34d8559ca793bb92eaa))
|
||||||
|
* **Table:** `checkbox` not checked while using props by ([#2401](https://github.com/nuxt/ui/issues/2401)) ([1b7e36c](https://github.com/nuxt/ui/commit/1b7e36cf70a7252915c58657bc878cb29c719a7f))
|
||||||
|
* **Table:** `indeterminate` checkbox with pagination ([#2439](https://github.com/nuxt/ui/issues/2439)) ([070d2f8](https://github.com/nuxt/ui/commit/070d2f89b6d1cb9c236eeb779cb3918ed5770434))
|
||||||
|
* **Table:** export `TableRow` and `TableColumn` types ([c36964b](https://github.com/nuxt/ui/commit/c36964b5eacbd61a661f02953f0297a390fd1d34)), closes [nuxt/ui#2373](https://github.com/nuxt/ui/issues/2373)
|
||||||
|
* **Table:** handle dot nation with `by` prop ([#2413](https://github.com/nuxt/ui/issues/2413)) ([b72d343](https://github.com/nuxt/ui/commit/b72d3434e9ab024e8622611d32b5a4467c8364b9))
|
||||||
|
* **Tabs:** allow `aria-label` on items ([3cf19ea](https://github.com/nuxt/ui/commit/3cf19ea5afcf97ef226d8be231d3b297c5f23b9f)), closes [nuxt/ui#1934](https://github.com/nuxt/ui/issues/1934)
|
||||||
|
|
||||||
## [2.18.7](https://github.com/nuxt/ui/compare/v2.18.6...v2.18.7) (2024-10-09)
|
## [2.18.7](https://github.com/nuxt/ui/compare/v2.18.6...v2.18.7) (2024-10-09)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -1,4 +1,4 @@
|
|||||||
[](https://ui.nuxt.com)
|
[](https://ui.nuxt.com)
|
||||||
|
|
||||||
# Nuxt UI
|
# Nuxt UI
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ Its goal is to provide everything related to UI when building a Nuxt app. This i
|
|||||||
- Keyboard shortcuts
|
- Keyboard shortcuts
|
||||||
- Bundled icons
|
- Bundled icons
|
||||||
- Fully typed
|
- Fully typed
|
||||||
- [Figma Kit](https://www.figma.com/community/file/1288455405058138934)
|
- [Figma Kit](https://www.figma.com/community/file/1436401057300493073)
|
||||||
|
|
||||||
Read more on [ui.nuxt.com](https://ui.nuxt.com)
|
Read more on [ui.nuxt.com](https://ui.nuxt.com)
|
||||||
|
|
||||||
@@ -30,16 +30,6 @@ Read more on [ui.nuxt.com](https://ui.nuxt.com)
|
|||||||
npx nuxi@latest module add ui
|
npx nuxi@latest module add ui
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want latest updates, please use `@nuxt/ui-edge` in your `package.json`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"devDependencies": {
|
|
||||||
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Visit https://ui.nuxt.com to explore the documentation.
|
Visit https://ui.nuxt.com to explore the documentation.
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ const links = computed(() => {
|
|||||||
icon: 'i-heroicons-book-open',
|
icon: 'i-heroicons-book-open',
|
||||||
to: '/getting-started',
|
to: '/getting-started',
|
||||||
active: route.path.startsWith('/getting-started') || route.path.startsWith('/components')
|
active: route.path.startsWith('/getting-started') || route.path.startsWith('/components')
|
||||||
}, ...(navigation.value.find(item => item._path === '/pro') ? [{
|
}, ...(navigation.value.find(item => item._path === '/pro')
|
||||||
|
? [{
|
||||||
label: 'Pro',
|
label: 'Pro',
|
||||||
icon: 'i-heroicons-square-3-stack-3d',
|
icon: 'i-heroicons-square-3-stack-3d',
|
||||||
to: '/pro',
|
to: '/pro',
|
||||||
@@ -63,7 +64,8 @@ const links = computed(() => {
|
|||||||
label: 'Templates',
|
label: 'Templates',
|
||||||
icon: 'i-heroicons-computer-desktop',
|
icon: 'i-heroicons-computer-desktop',
|
||||||
to: '/pro/templates'
|
to: '/pro/templates'
|
||||||
}] : []), {
|
}]
|
||||||
|
: []), {
|
||||||
label: 'Releases',
|
label: 'Releases',
|
||||||
icon: 'i-heroicons-rocket-launch',
|
icon: 'i-heroicons-rocket-launch',
|
||||||
to: '/releases'
|
to: '/releases'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const id = 'nuxt-ui-banner-1'
|
const id = 'nuxt-ui-banner-3'
|
||||||
const to = '/pro/pricing'
|
const to = '/pro/pricing'
|
||||||
|
|
||||||
const hideBanner = () => {
|
const hideBanner = () => {
|
||||||
@@ -25,7 +25,13 @@ if (import.meta.server) {
|
|||||||
<template>
|
<template>
|
||||||
<div class="relative bg-primary hover:bg-primary/90 transition-[background] backdrop-blur z-50 app-banner">
|
<div class="relative bg-primary hover:bg-primary/90 transition-[background] backdrop-blur z-50 app-banner">
|
||||||
<UContainer class="py-2">
|
<UContainer class="py-2">
|
||||||
<NuxtLink v-if="to" :to="to" class="focus:outline-none" aria-label="Nuxt UI Pro pricing" tabindex="-1">
|
<NuxtLink
|
||||||
|
v-if="to"
|
||||||
|
:to="to"
|
||||||
|
class="focus:outline-none"
|
||||||
|
aria-label="20% off on all Nuxt UI Pro products for Black Friday week"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
<span class="absolute inset-0 " aria-hidden="true" />
|
<span class="absolute inset-0 " aria-hidden="true" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
|
||||||
@@ -33,10 +39,20 @@ if (import.meta.server) {
|
|||||||
<div class="lg:flex-1 hidden lg:flex items-center" />
|
<div class="lg:flex-1 hidden lg:flex items-center" />
|
||||||
|
|
||||||
<p class="text-sm font-medium text-white dark:text-gray-900 truncate">
|
<p class="text-sm font-medium text-white dark:text-gray-900 truncate">
|
||||||
<UIcon name="i-heroicons-rocket-launch" class="w-5 h-5 align-top flex-shrink-0 pointer-events-none mr-2" />
|
<UIcon name="i-ri-discount-percent-fill" class="size-5 align-top flex-shrink-0 pointer-events-none mr-2" />
|
||||||
<span class="font-semibold">Nuxt UI Pro v1.0</span> is out with dashboard components!
|
<span class="font-bold">Black Friday Week</span>: <UBadge label="20% off" color="white" class="ring-0 font-semibold" /> on all Nuxt UI Pro products from <span class="font-semibold">Nov 25</span> to <span class="font-semibold">Dec 2</span>!
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<!-- <UButton
|
||||||
|
:to="to"
|
||||||
|
target="_blank"
|
||||||
|
label="Buy now"
|
||||||
|
color="black"
|
||||||
|
variant="solid"
|
||||||
|
size="2xs"
|
||||||
|
trailing-icon="i-heroicons-arrow-right-20-solid"
|
||||||
|
/> -->
|
||||||
|
|
||||||
<div class="flex items-center justify-end lg:flex-1">
|
<div class="flex items-center justify-end lg:flex-1">
|
||||||
<button
|
<button
|
||||||
class="p-1.5 rounded-md inline-flex hover:bg-primary/90"
|
class="p-1.5 rounded-md inline-flex hover:bg-primary/90"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const { $ui } = useNuxtApp()
|
|||||||
const links = [{
|
const links = [{
|
||||||
icon: 'i-simple-icons-figma',
|
icon: 'i-simple-icons-figma',
|
||||||
label: 'Figma Kit',
|
label: 'Figma Kit',
|
||||||
to: 'https://www.figma.com/community/file/1288455405058138934',
|
to: 'https://www.figma.com/community/file/1436401057300493073',
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
}, {
|
}, {
|
||||||
label: 'Playground',
|
label: 'Playground',
|
||||||
|
|||||||
@@ -10,12 +10,34 @@
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<template #left>
|
<template #left>
|
||||||
<NuxtLink to="/" class="flex items-end gap-2 font-bold text-xl text-gray-900 dark:text-white min-w-0" aria-label="Nuxt UI">
|
<NuxtLink to="/" class="flex items-end gap-2 text-xl text-gray-900 dark:text-white min-w-0 shrink-0" aria-label="Nuxt UI">
|
||||||
<LogoPro v-if="$route.path.startsWith('/pro')" class="w-auto h-6 shrink-0" />
|
<LogoPro v-if="$route.path.startsWith('/pro')" class="w-auto h-6 shrink-0" />
|
||||||
<Logo v-else class="w-auto h-6 shrink-0" />
|
<Logo v-else class="w-auto h-6 shrink-0" />
|
||||||
|
|
||||||
<UBadge :label="$route.path.startsWith('/pro') ? `v${pkg.version.split('-')[0]}` : `v${config.version}`" variant="subtle" size="xs" class="-mb-[2px] rounded font-semibold truncate hidden sm:inline-flex" />
|
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
|
||||||
|
<UDropdown
|
||||||
|
:items="[[{ label: $route.path.startsWith('/pro') ? `v${pkg.version.split('-')[0]}` : `v${config.version}`, class: 'text-primary-500 dark:text-primary-400' }, { label: 'v3.0.0-alpha.x', to: 'https://ui3.nuxt.dev' }]]"
|
||||||
|
:popper="{ strategy: 'absolute', offsetDistance: 11, placement: 'bottom-start' }"
|
||||||
|
:ui="{
|
||||||
|
background: 'dark:bg-gray-900',
|
||||||
|
ring: 'dark:ring-gray-800',
|
||||||
|
width: 'w-auto',
|
||||||
|
item: {
|
||||||
|
padding: 'p-1',
|
||||||
|
size: 'text-xs',
|
||||||
|
active: 'dark:bg-gray-800/50'
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<UButton
|
||||||
|
:label="$route.path.startsWith('/pro') ? `v${pkg.version.split('-')[0]}` : `v${config.version}`"
|
||||||
|
trailing-icon="i-lucide-chevron-down"
|
||||||
|
variant="outline"
|
||||||
|
size="2xs"
|
||||||
|
truncate
|
||||||
|
class="-mb-[6px] font-semibold rounded-full truncate ring-primary-500/25 dark:ring-primary-400/25 bg-primary-500/10 dark:bg-primary-400/10 hover:bg-primary-500/15 dark:hover:bg-primary-400/15 transition-colors"
|
||||||
|
/>
|
||||||
|
</UDropdown>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #right>
|
<template #right>
|
||||||
@@ -25,10 +47,10 @@
|
|||||||
<UContentSearchButton :label="null" />
|
<UContentSearchButton :label="null" />
|
||||||
</UTooltip>
|
</UTooltip>
|
||||||
|
|
||||||
<UColorModeButton />
|
<UColorModeButton class="hidden lg:inline-flex" />
|
||||||
|
|
||||||
<UButton
|
<UButton
|
||||||
to="https://github.com/nuxt/ui"
|
to="https://github.com/nuxt/ui/tree/dev"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
icon="i-simple-icons-github"
|
icon="i-simple-icons-github"
|
||||||
aria-label="GitHub"
|
aria-label="GitHub"
|
||||||
@@ -48,8 +70,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NavItem } from '@nuxt/content'
|
import type { NavItem } from '@nuxt/content'
|
||||||
import type { HeaderLink } from '#ui-pro/types'
|
|
||||||
import pkg from '@nuxt/ui-pro/package.json'
|
import pkg from '@nuxt/ui-pro/package.json'
|
||||||
|
import type { HeaderLink } from '#ui-pro/types'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
links: HeaderLink[]
|
links: HeaderLink[]
|
||||||
|
|||||||
@@ -51,11 +51,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { transformContent } from '@nuxt/content/transformers'
|
|
||||||
import { upperFirst, camelCase, kebabCase } from 'scule'
|
import { upperFirst, camelCase, kebabCase } from 'scule'
|
||||||
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
|
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
slug: {
|
slug: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -90,7 +88,7 @@ const props = defineProps({
|
|||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Array as PropType<{ name: string; values: string[]; restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
|
type: Array as PropType<{ name: string, values: string[], restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
backgroundClass: {
|
backgroundClass: {
|
||||||
@@ -115,7 +113,6 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
|
||||||
const baseProps = reactive({ ...props.baseProps })
|
const baseProps = reactive({ ...props.baseProps })
|
||||||
const componentProps = reactive({ ...props.props })
|
const componentProps = reactive({ ...props.props })
|
||||||
|
|
||||||
@@ -159,13 +156,13 @@ const generateOptions = (key: string, schema: { kind: string, schema: [], type:
|
|||||||
const schemaOptions = Object.values(schema?.schema || {})
|
const schemaOptions = Object.values(schema?.schema || {})
|
||||||
|
|
||||||
if (key.toLowerCase() === 'size' && schemaOptions?.length > 0) {
|
if (key.toLowerCase() === 'size' && schemaOptions?.length > 0) {
|
||||||
const baseSizeOrder = { 'xs': 1, 'sm': 2, 'md': 3, 'lg': 4, 'xl': 5 }
|
const baseSizeOrder = { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 }
|
||||||
schemaOptions.sort((a: string, b: string) => {
|
schemaOptions.sort((a: string, b: string) => {
|
||||||
const aBase = a.match(/[a-zA-Z]+/)[0].toLowerCase()
|
const aBase = a.match(/[a-z]+/i)[0].toLowerCase()
|
||||||
const bBase = b.match(/[a-zA-Z]+/)[0].toLowerCase()
|
const bBase = b.match(/[a-z]+/i)[0].toLowerCase()
|
||||||
|
|
||||||
const aNum = parseInt(a.match(/\d+/)?.[0]) || 1
|
const aNum = Number.parseInt(a.match(/\d+/)?.[0]) || 1
|
||||||
const bNum = parseInt(b.match(/\d+/)?.[0]) || 1
|
const bNum = Number.parseInt(b.match(/\d+/)?.[0]) || 1
|
||||||
|
|
||||||
if (aBase === bBase) {
|
if (aBase === bBase) {
|
||||||
return aBase === 'xs' ? bNum - aNum : aNum - bNum
|
return aBase === 'xs' ? bNum - aNum : aNum - bNum
|
||||||
@@ -215,7 +212,6 @@ const propsToSelect = computed(() => Object.keys(componentProps).map((key) => {
|
|||||||
}
|
}
|
||||||
}).filter(Boolean))
|
}).filter(Boolean))
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
|
||||||
const code = computed(() => {
|
const code = computed(() => {
|
||||||
let code = `\`\`\`html
|
let code = `\`\`\`html
|
||||||
<template>
|
<template>
|
||||||
@@ -270,18 +266,20 @@ function renderObject (obj: any) {
|
|||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(
|
const { data: ast } = await useAsyncData(`${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots, code: props.code })}`, async () => {
|
||||||
`${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots, code: props.code })}`,
|
|
||||||
async () => {
|
|
||||||
let formatted = ''
|
let formatted = ''
|
||||||
try {
|
try {
|
||||||
formatted = await $prettier.format(code.value) || code.value
|
// @ts-ignore
|
||||||
} catch (error) {
|
formatted = await $prettier.format(code.value, {
|
||||||
|
trailingComma: 'none',
|
||||||
|
semi: false,
|
||||||
|
singleQuote: true
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
formatted = code.value
|
formatted = code.value
|
||||||
}
|
}
|
||||||
|
|
||||||
return transformContent('content:_markdown.md', formatted, {
|
return parseMarkdown(formatted, {
|
||||||
markdown: {
|
|
||||||
highlight: {
|
highlight: {
|
||||||
highlighter,
|
highlighter,
|
||||||
theme: {
|
theme: {
|
||||||
@@ -290,7 +288,6 @@ const { data: ast } = await useAsyncData(
|
|||||||
dark: 'material-theme-palenight'
|
dark: 'material-theme-palenight'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}, { watch: [code] })
|
}, { watch: [code] })
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="[&>div>pre]:!rounded-t-none [&>div>pre]:!mt-0">
|
<div class="[&>div>pre]:!rounded-t-none [&>div>pre]:!mt-0">
|
||||||
<div
|
<div v-if="hasPreview" class="flex border border-gray-200 dark:border-gray-700 relative rounded-t-md" :class="[{ 'p-4': padding, 'rounded-b-md': !hasCode, 'border-b-0': hasCode, 'not-prose': !prose }, backgroundClass, extraClass]">
|
||||||
v-if="hasPreview"
|
|
||||||
class="flex border border-gray-200 dark:border-gray-700 relative rounded-t-md"
|
|
||||||
:class="[{ 'p-4': padding, 'rounded-b-md': !hasCode, 'border-b-0': hasCode, 'not-prose': !prose }, backgroundClass, extraClass]"
|
|
||||||
>
|
|
||||||
<template v-if="component">
|
<template v-if="component">
|
||||||
<iframe v-if="iframe" :src="`/examples/${component}`" v-bind="iframeProps" :class="backgroundClass" class="w-full" />
|
<iframe v-if="iframe" :src="`/examples/${component}`" v-bind="iframeProps" :class="backgroundClass" class="w-full" />
|
||||||
<component :is="camelName" v-else v-bind="componentProps" :class="componentClass" />
|
<component :is="camelName" v-else v-bind="componentProps" :class="componentClass" />
|
||||||
@@ -22,7 +18,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { camelCase } from 'scule'
|
import { camelCase } from 'scule'
|
||||||
import { fetchContentExampleCode } from '~/composables/useContentExamplesCode'
|
import { fetchContentExampleCode } from '~/composables/useContentExamplesCode'
|
||||||
import { transformContent } from '@nuxt/content/transformers'
|
|
||||||
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
|
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -86,8 +81,7 @@ const highlighter = useShikiHighlighter()
|
|||||||
const hasCode = computed(() => !props.hiddenCode && (data?.code || instance.slots.code))
|
const hasCode = computed(() => !props.hiddenCode && (data?.code || instance.slots.code))
|
||||||
const hasPreview = computed(() => !props.hiddenPreview && (props.component || instance.slots.default))
|
const hasPreview = computed(() => !props.hiddenPreview && (props.component || instance.slots.default))
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(`content-example-${camelName}-ast`, () => transformContent('content:_markdown.md', `\`\`\`vue\n${data?.code ?? ''}\n\`\`\``, {
|
const { data: ast } = await useAsyncData(`content-example-${camelName}-ast`, () => parseMarkdown(`\`\`\`vue\n${data?.code ?? ''}\n\`\`\``, {
|
||||||
markdown: {
|
|
||||||
highlight: {
|
highlight: {
|
||||||
highlighter,
|
highlighter,
|
||||||
theme: {
|
theme: {
|
||||||
@@ -96,6 +90,5 @@ const { data: ast } = await useAsyncData(`content-example-${camelName}-ast`, ()
|
|||||||
dark: 'material-theme-palenight'
|
dark: 'material-theme-palenight'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,11 +3,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { transformContent } from '@nuxt/content/transformers'
|
|
||||||
import { upperFirst, camelCase } from 'scule'
|
import { upperFirst, camelCase } from 'scule'
|
||||||
import json5 from 'json5'
|
import json5 from 'json5'
|
||||||
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
|
|
||||||
import * as config from '#ui/ui.config'
|
import * as config from '#ui/ui.config'
|
||||||
|
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
slug: {
|
slug: {
|
||||||
@@ -18,19 +17,18 @@ const props = defineProps({
|
|||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const highlighter = useShikiHighlighter()
|
const highlighter = useShikiHighlighter()
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
|
||||||
const slug = props.slug || route.params.slug[route.params.slug.length - 1]
|
const slug = props.slug || route.params.slug[route.params.slug.length - 1]
|
||||||
const camelName = camelCase(slug)
|
const camelName = camelCase(slug)
|
||||||
const name = `U${upperFirst(camelName)}`
|
const name = `U${upperFirst(camelName)}`
|
||||||
|
|
||||||
const preset = config[camelName]
|
const preset = config[camelName]
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(`${name}-preset`, () => transformContent('content:_markdown.md', `
|
const { data: ast } = await useAsyncData(`${name}-preset`, () => parseMarkdown(`
|
||||||
\`\`\`yml
|
\`\`\`yml
|
||||||
${json5.stringify(preset, null, 2)}
|
${json5.stringify(preset, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')}
|
||||||
\`\`\`\
|
\`\`\`\
|
||||||
`, {
|
`, {
|
||||||
markdown: {
|
|
||||||
highlight: {
|
highlight: {
|
||||||
highlighter,
|
highlighter,
|
||||||
theme: {
|
theme: {
|
||||||
@@ -39,6 +37,5 @@ ${json5.stringify(preset, null, 2)}
|
|||||||
dark: 'material-theme-palenight'
|
dark: 'material-theme-palenight'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ const actions = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const groups = computed(() =>
|
const groups = computed(() =>
|
||||||
[commandPaletteRef.value?.query ? {
|
[commandPaletteRef.value?.query
|
||||||
|
? {
|
||||||
key: 'users',
|
key: 'users',
|
||||||
commands: users
|
commands: users
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
key: 'recent',
|
key: 'recent',
|
||||||
label: 'Recent searches',
|
label: 'Recent searches',
|
||||||
commands: users.slice(0, 1)
|
commands: users.slice(0, 1)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ const ui = {
|
|||||||
:autoselect="false"
|
:autoselect="false"
|
||||||
command-attribute="title"
|
command-attribute="title"
|
||||||
:fuse="{
|
:fuse="{
|
||||||
fuseOptions: { keys: ['title', 'category'] },
|
fuseOptions: { keys: ['title', 'category'] }
|
||||||
}"
|
}"
|
||||||
placeholder="Search docs"
|
placeholder="Search docs"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const ui = {
|
|||||||
inactive: 'text-gray-400 dark:text-gray-500'
|
inactive: 'text-gray-400 dark:text-gray-500'
|
||||||
},
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
size: '2xs' as const
|
size: '2xs'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
docs/components/content/examples/FormExampleSuperstruct.vue
Normal file
36
docs/components/content/examples/FormExampleSuperstruct.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { object, string, nonempty, type Infer } from 'superstruct'
|
||||||
|
import type { FormSubmitEvent } from '#ui/types'
|
||||||
|
|
||||||
|
const schema = object({
|
||||||
|
email: nonempty(string()),
|
||||||
|
password: nonempty(string())
|
||||||
|
})
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
email: '',
|
||||||
|
password: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
type Schema = Infer<typeof schema>
|
||||||
|
|
||||||
|
async function onSubmit(event: FormSubmitEvent<Schema>) {
|
||||||
|
console.log(event.data)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit">
|
||||||
|
<UFormGroup label="Email" name="email">
|
||||||
|
<UInput v-model="state.email" />
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
|
<UFormGroup label="Password" name="password">
|
||||||
|
<UInput v-model="state.password" type="password" />
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
|
<UButton type="submit">
|
||||||
|
Submit
|
||||||
|
</UButton>
|
||||||
|
</UForm>
|
||||||
|
</template>
|
||||||
15
docs/components/content/examples/InputExampleMaxLength.vue
Normal file
15
docs/components/content/examples/InputExampleMaxLength.vue
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<template>
|
||||||
|
<UInput
|
||||||
|
v-model="name"
|
||||||
|
:maxlength="maxLength"
|
||||||
|
>
|
||||||
|
<template #trailing>
|
||||||
|
<span class="text-xs text-gray-500 dark:text-gray-400">{{ name.length }}/{{ maxLength }}</span>
|
||||||
|
</template>
|
||||||
|
</UInput>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const name = ref('')
|
||||||
|
const maxLength = 10
|
||||||
|
</script>
|
||||||
@@ -5,15 +5,29 @@ const items = ref(Array(55))
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
|
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
|
||||||
<template #first="{ onClick }">
|
<template #first="{ onClick, canGoFirst }">
|
||||||
<UTooltip text="First page">
|
<UTooltip text="First page">
|
||||||
<UButton icon="i-heroicons-arrow-uturn-left" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:first-child]:rotate-180 me-2" @click="onClick" />
|
<UButton
|
||||||
|
icon="i-heroicons-arrow-uturn-left"
|
||||||
|
color="primary"
|
||||||
|
:ui="{ rounded: 'rounded-full' }"
|
||||||
|
class="rtl:[&_span:first-child]:rotate-180 me-2"
|
||||||
|
:disabled="!canGoFirst"
|
||||||
|
@click="onClick"
|
||||||
|
/>
|
||||||
</UTooltip>
|
</UTooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #last="{ onClick }">
|
<template #last="{ onClick, canGoLast }">
|
||||||
<UTooltip text="Last page">
|
<UTooltip text="Last page">
|
||||||
<UButton icon="i-heroicons-arrow-uturn-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:last-child]:rotate-180 ms-2" @click="onClick" />
|
<UButton
|
||||||
|
icon="i-heroicons-arrow-uturn-right-20-solid"
|
||||||
|
color="primary"
|
||||||
|
:ui="{ rounded: 'rounded-full' }"
|
||||||
|
class="rtl:[&_span:last-child]:rotate-180 ms-2"
|
||||||
|
:disabled="!canGoLast"
|
||||||
|
@click="onClick"
|
||||||
|
/>
|
||||||
</UTooltip>
|
</UTooltip>
|
||||||
</template>
|
</template>
|
||||||
</UPagination>
|
</UPagination>
|
||||||
|
|||||||
@@ -5,15 +5,29 @@ const items = ref(Array(55))
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
|
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
|
||||||
<template #prev="{ onClick }">
|
<template #prev="{ onClick, canGoPrev }">
|
||||||
<UTooltip text="Previous page">
|
<UTooltip text="Previous page">
|
||||||
<UButton icon="i-heroicons-arrow-small-left-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:first-child]:rotate-180 me-2" @click="onClick" />
|
<UButton
|
||||||
|
icon="i-heroicons-arrow-small-left-20-solid"
|
||||||
|
color="primary"
|
||||||
|
:ui="{ rounded: 'rounded-full' }"
|
||||||
|
class="rtl:[&_span:first-child]:rotate-180 me-2"
|
||||||
|
:disabled="!canGoPrev"
|
||||||
|
@click="onClick"
|
||||||
|
/>
|
||||||
</UTooltip>
|
</UTooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #next="{ onClick }">
|
<template #next="{ onClick, canGoNext }">
|
||||||
<UTooltip text="Next page">
|
<UTooltip text="Next page">
|
||||||
<UButton icon="i-heroicons-arrow-small-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:last-child]:rotate-180 ms-2" @click="onClick" />
|
<UButton
|
||||||
|
icon="i-heroicons-arrow-small-right-20-solid"
|
||||||
|
color="primary"
|
||||||
|
:ui="{ rounded: 'rounded-full' }"
|
||||||
|
class="rtl:[&_span:last-child]:rotate-180 ms-2"
|
||||||
|
:disabled="!canGoNext"
|
||||||
|
@click="onClick"
|
||||||
|
/>
|
||||||
</UTooltip>
|
</UTooltip>
|
||||||
</template>
|
</template>
|
||||||
</UPagination>
|
</UPagination>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const items = ref(Array(50))
|
|||||||
:to="(page: number) => ({
|
:to="(page: number) => ({
|
||||||
query: { page },
|
query: { page },
|
||||||
// Hash is specified here to prevent the page from scrolling to the top
|
// Hash is specified here to prevent the page from scrolling to the top
|
||||||
hash: '#links',
|
hash: '#links'
|
||||||
})"
|
})"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const labels = computed({
|
|||||||
|
|
||||||
const showCreateOption = (query, results) => {
|
const showCreateOption = (query, results) => {
|
||||||
const lowercaseQuery = String.prototype.toLowerCase.apply(query || '')
|
const lowercaseQuery = String.prototype.toLowerCase.apply(query || '')
|
||||||
return lowercaseQuery.length >= 3 && !results.find(option => {
|
return lowercaseQuery.length >= 3 && !results.find((option) => {
|
||||||
return String.prototype.toLowerCase.apply(option['name'] || '') === lowercaseQuery
|
return String.prototype.toLowerCase.apply(option['name'] || '') === lowercaseQuery
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
count: {
|
count: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -8,7 +7,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
close: [];
|
close: []
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// Columns
|
// Columns
|
||||||
const columns = [{
|
const columns = [{
|
||||||
|
key: 'select',
|
||||||
|
class: 'w-2'
|
||||||
|
}, {
|
||||||
key: 'id',
|
key: 'id',
|
||||||
label: '#',
|
label: '#',
|
||||||
sortable: true
|
sortable: true
|
||||||
@@ -19,13 +22,14 @@ const columns = [{
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
const selectedColumns = ref(columns)
|
const selectedColumns = ref(columns)
|
||||||
const columnsTable = computed(() => columns.filter((column) => selectedColumns.value.includes(column)))
|
const columnsTable = computed(() => columns.filter(column => selectedColumns.value.includes(column)))
|
||||||
|
const excludeSelectColumn = computed(() => columns.filter(v => v.key !== 'select'))
|
||||||
|
|
||||||
// Selected Rows
|
// Selected Rows
|
||||||
const selectedRows = ref([])
|
const selectedRows = ref([])
|
||||||
|
|
||||||
function select(row) {
|
function select(row) {
|
||||||
const index = selectedRows.value.findIndex((item) => item.id === row.id)
|
const index = selectedRows.value.findIndex(item => item.id === row.id)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
selectedRows.value.push(row)
|
selectedRows.value.push(row)
|
||||||
} else {
|
} else {
|
||||||
@@ -92,10 +96,10 @@ const { data: todos, status } = await useLazyAsyncData<{
|
|||||||
}[]>('todos', () => ($fetch as any)(`https://jsonplaceholder.typicode.com/todos${searchStatus.value}`, {
|
}[]>('todos', () => ($fetch as any)(`https://jsonplaceholder.typicode.com/todos${searchStatus.value}`, {
|
||||||
query: {
|
query: {
|
||||||
q: search.value,
|
q: search.value,
|
||||||
'_page': page.value,
|
_page: page.value,
|
||||||
'_limit': pageCount.value,
|
_limit: pageCount.value,
|
||||||
'_sort': sort.value.column,
|
_sort: sort.value.column,
|
||||||
'_order': sort.value.direction
|
_order: sort.value.direction
|
||||||
}
|
}
|
||||||
}), {
|
}), {
|
||||||
default: () => [],
|
default: () => [],
|
||||||
@@ -153,7 +157,7 @@ const { data: todos, status } = await useLazyAsyncData<{
|
|||||||
</UButton>
|
</UButton>
|
||||||
</UDropdown>
|
</UDropdown>
|
||||||
|
|
||||||
<USelectMenu v-model="selectedColumns" :options="columns" multiple>
|
<USelectMenu v-model="selectedColumns" :options="excludeSelectColumn" multiple>
|
||||||
<UButton
|
<UButton
|
||||||
icon="i-heroicons-view-columns"
|
icon="i-heroicons-view-columns"
|
||||||
color="gray"
|
color="gray"
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const people = [{
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
function select(row) {
|
function select(row) {
|
||||||
const index = selected.value.findIndex((item) => item.id === row.id)
|
const index = selected.value.findIndex(item => item.id === row.id)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
selected.value.push(row)
|
selected.value.push(row)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
66
docs/components/content/examples/TableExampleContextmenu.vue
Normal file
66
docs/components/content/examples/TableExampleContextmenu.vue
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const people = [{
|
||||||
|
id: 1,
|
||||||
|
name: 'Lindsay Walton',
|
||||||
|
title: 'Front-end Developer',
|
||||||
|
email: 'lindsay.walton@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}, {
|
||||||
|
id: 2,
|
||||||
|
name: 'Courtney Henry',
|
||||||
|
title: 'Designer',
|
||||||
|
email: 'courtney.henry@example.com',
|
||||||
|
role: 'Admin'
|
||||||
|
}, {
|
||||||
|
id: 3,
|
||||||
|
name: 'Tom Cook',
|
||||||
|
title: 'Director of Product',
|
||||||
|
email: 'tom.cook@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}, {
|
||||||
|
id: 4,
|
||||||
|
name: 'Whitney Francis',
|
||||||
|
title: 'Copywriter',
|
||||||
|
email: 'whitney.francis@example.com',
|
||||||
|
role: 'Admin'
|
||||||
|
}, {
|
||||||
|
id: 5,
|
||||||
|
name: 'Leonard Krasner',
|
||||||
|
title: 'Senior Designer',
|
||||||
|
email: 'leonard.krasner@example.com',
|
||||||
|
role: 'Owner'
|
||||||
|
}]
|
||||||
|
|
||||||
|
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
|
||||||
|
const contextMenuRow = ref()
|
||||||
|
|
||||||
|
function contextmenu(event: MouseEvent, row: any) {
|
||||||
|
// Prevent the default context menu
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
virtualElement.value.getBoundingClientRect = () => ({
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
top: event.clientY,
|
||||||
|
left: event.clientX
|
||||||
|
})
|
||||||
|
|
||||||
|
contextMenuRow.value = row
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<UTable :rows="people" @contextmenu.stop="contextmenu" />
|
||||||
|
|
||||||
|
<UContextMenu
|
||||||
|
:virtual-element="virtualElement"
|
||||||
|
:model-value="!!contextMenuRow"
|
||||||
|
@update:model-value="contextMenuRow = null"
|
||||||
|
>
|
||||||
|
<div class="p-4">
|
||||||
|
{{ contextMenuRow.id }} - {{ contextMenuRow.name }}
|
||||||
|
</div>
|
||||||
|
</UContextMenu>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<script setup>
|
||||||
|
const people = [{
|
||||||
|
id: 1,
|
||||||
|
name: 'Lindsay Walton',
|
||||||
|
title: 'Front-end Developer',
|
||||||
|
email: 'lindsay.walton@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}, {
|
||||||
|
id: 2,
|
||||||
|
name: 'Courtney Henry',
|
||||||
|
title: 'Designer',
|
||||||
|
email: 'courtney.henry@example.com',
|
||||||
|
role: 'Admin',
|
||||||
|
disabledExpand: true
|
||||||
|
}, {
|
||||||
|
id: 3,
|
||||||
|
name: 'Tom Cook',
|
||||||
|
title: 'Director of Product',
|
||||||
|
email: 'tom.cook@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}, {
|
||||||
|
id: 4,
|
||||||
|
name: 'Whitney Francis',
|
||||||
|
title: 'Copywriter',
|
||||||
|
email: 'whitney.francis@example.com',
|
||||||
|
role: 'Admin',
|
||||||
|
disabledExpand: true
|
||||||
|
}, {
|
||||||
|
id: 5,
|
||||||
|
name: 'Leonard Krasner',
|
||||||
|
title: 'Senior Designer',
|
||||||
|
email: 'leonard.krasner@example.com',
|
||||||
|
role: 'Owner'
|
||||||
|
}, {
|
||||||
|
id: 6,
|
||||||
|
name: 'Floyd Miles',
|
||||||
|
title: 'Principal Designer',
|
||||||
|
email: 'floyd.miles@example.com',
|
||||||
|
role: 'Member',
|
||||||
|
disabledExpand: true
|
||||||
|
}]
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
label: 'Name',
|
||||||
|
key: 'name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'title',
|
||||||
|
key: 'title'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Email',
|
||||||
|
key: 'email'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'role',
|
||||||
|
key: 'role'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const expand = ref({
|
||||||
|
openedRows: [],
|
||||||
|
row: null
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UTable v-model:expand="expand" :rows="people" :columns="columns">
|
||||||
|
<template #expand="{ row }">
|
||||||
|
<div class="p-4">
|
||||||
|
<pre>{{ row }}</pre>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const people = [{
|
||||||
|
id: 1,
|
||||||
|
name: 'Lindsay Walton',
|
||||||
|
title: 'Front-end Developer',
|
||||||
|
email: 'lindsay.walton@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}, {
|
||||||
|
id: 2,
|
||||||
|
name: 'Courtney Henry',
|
||||||
|
title: 'Designer',
|
||||||
|
email: 'courtney.henry@example.com',
|
||||||
|
role: 'Admin'
|
||||||
|
}, {
|
||||||
|
id: 3,
|
||||||
|
name: 'Tom Cook',
|
||||||
|
title: 'Director of Product',
|
||||||
|
email: 'tom.cook@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}, {
|
||||||
|
id: 4,
|
||||||
|
name: 'Whitney Francis',
|
||||||
|
title: 'Copywriter',
|
||||||
|
email: 'whitney.francis@example.com',
|
||||||
|
role: 'Admin'
|
||||||
|
}, {
|
||||||
|
id: 5,
|
||||||
|
name: 'Leonard Krasner',
|
||||||
|
title: 'Senior Designer',
|
||||||
|
email: 'leonard.krasner@example.com',
|
||||||
|
role: 'Owner'
|
||||||
|
}, {
|
||||||
|
id: 6,
|
||||||
|
name: 'Floyd Miles',
|
||||||
|
title: 'Principal Designer',
|
||||||
|
email: 'floyd.miles@example.com',
|
||||||
|
role: 'Member'
|
||||||
|
}]
|
||||||
|
|
||||||
|
const selected = ref([people[1]])
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
key: 'id',
|
||||||
|
label: 'ID'
|
||||||
|
}, {
|
||||||
|
key: 'name',
|
||||||
|
label: 'User name'
|
||||||
|
}, {
|
||||||
|
key: 'title',
|
||||||
|
label: 'Job position'
|
||||||
|
}, {
|
||||||
|
key: 'email',
|
||||||
|
label: 'Email'
|
||||||
|
}, {
|
||||||
|
key: 'role'
|
||||||
|
}, {
|
||||||
|
key: 'select',
|
||||||
|
class: 'w-2'
|
||||||
|
}]
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UTable v-model="selected" :rows="people" :columns="columns" />
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<script setup lang='ts'>
|
||||||
|
const people = [{
|
||||||
|
id: 1,
|
||||||
|
name: 'Lindsay Walton',
|
||||||
|
title: 'Front-end Developer',
|
||||||
|
email: 'lindsay.walton@example.com',
|
||||||
|
role: 'Member',
|
||||||
|
hasExpand: false
|
||||||
|
}, {
|
||||||
|
id: 2,
|
||||||
|
name: 'Courtney Henry',
|
||||||
|
title: 'Designer',
|
||||||
|
email: 'courtney.henry@example.com',
|
||||||
|
role: 'Admin',
|
||||||
|
hasExpand: true
|
||||||
|
}, {
|
||||||
|
id: 3,
|
||||||
|
name: 'Tom Cook',
|
||||||
|
title: 'Director of Product',
|
||||||
|
email: 'tom.cook@example.com',
|
||||||
|
role: 'Member',
|
||||||
|
hasExpand: false
|
||||||
|
}, {
|
||||||
|
id: 4,
|
||||||
|
name: 'Whitney Francis',
|
||||||
|
title: 'Copywriter',
|
||||||
|
email: 'whitney.francis@example.com',
|
||||||
|
role: 'Admin',
|
||||||
|
hasExpand: true
|
||||||
|
}, {
|
||||||
|
id: 5,
|
||||||
|
name: 'Leonard Krasner',
|
||||||
|
title: 'Senior Designer',
|
||||||
|
email: 'leonard.krasner@example.com',
|
||||||
|
role: 'Owner',
|
||||||
|
hasExpand: false
|
||||||
|
}, {
|
||||||
|
id: 6,
|
||||||
|
name: 'Floyd Miles',
|
||||||
|
title: 'Principal Designer',
|
||||||
|
email: 'floyd.miles@example.com',
|
||||||
|
role: 'Member',
|
||||||
|
hasExpand: true
|
||||||
|
}]
|
||||||
|
|
||||||
|
const expand = ref({
|
||||||
|
openedRows: [people.find(v => v.hasExpand)],
|
||||||
|
row: {}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UTable v-model:expand="expand" :rows="people">
|
||||||
|
<template #expand="{ row }">
|
||||||
|
<div class="p-4">
|
||||||
|
<pre>{{ row }}</pre>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #expand-action="{ row, isExpanded, toggle }">
|
||||||
|
<UButton v-if="row.hasExpand" @click="toggle">
|
||||||
|
{{ isExpanded ? 'collapse' : 'expand' }}
|
||||||
|
</UButton>
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang='ts'>
|
||||||
const people = [{
|
const people = [{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Lindsay Walton',
|
name: 'Lindsay Walton',
|
||||||
@@ -36,10 +36,15 @@ const people = [{
|
|||||||
email: 'floyd.miles@example.com',
|
email: 'floyd.miles@example.com',
|
||||||
role: 'Member'
|
role: 'Member'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
const expand = ref({
|
||||||
|
openedRows: [people[0]],
|
||||||
|
row: {}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UTable :rows="people">
|
<UTable v-model:expand="expand" :rows="people">
|
||||||
<template #expand="{ row }">
|
<template #expand="{ row }">
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<pre>{{ row }}</pre>
|
<pre>{{ row }}</pre>
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ const pending = ref(true)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@keyframes loader-6 {
|
@keyframes loader-6 {
|
||||||
0%, 100% {
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
transform: none;
|
transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const people = [{
|
|||||||
role: 'Member'
|
role: 'Member'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
const items = (row) => [
|
const items = row => [
|
||||||
[{
|
[{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
icon: 'i-heroicons-pencil-square-20-solid',
|
icon: 'i-heroicons-pencil-square-20-solid',
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const router = useRouter()
|
|||||||
|
|
||||||
const selected = computed({
|
const selected = computed({
|
||||||
get() {
|
get() {
|
||||||
const index = items.findIndex((item) => item.label === route.query.tab)
|
const index = items.findIndex(item => item.label === route.query.tab)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useBreakpoints, breakpointsTailwind } from '@vueuse/core'
|
|
||||||
import { DatePicker as VCalendarDatePicker } from 'v-calendar'
|
import { DatePicker as VCalendarDatePicker } from 'v-calendar'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
|
import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
|
||||||
@@ -26,22 +25,34 @@ const date = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
|
||||||
|
|
||||||
const smallerThanSm = breakpoints.smaller('sm')
|
|
||||||
|
|
||||||
const attrs = {
|
const attrs = {
|
||||||
transparent: true,
|
'transparent': true,
|
||||||
borderless: true,
|
'borderless': true,
|
||||||
color: 'primary',
|
'color': 'primary',
|
||||||
'is-dark': { selector: 'html', darkClass: 'dark' },
|
'is-dark': { selector: 'html', darkClass: 'dark' },
|
||||||
'first-day-of-week': 2
|
'first-day-of-week': 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDayClick(_: any, event: MouseEvent): void {
|
||||||
|
const target = event.target as HTMLElement
|
||||||
|
target.blur()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VCalendarDatePicker v-if="date && (date as DatePickerRangeObject)?.start && (date as DatePickerRangeObject)?.end" v-model.range="date" :columns="smallerThanSm ? 1 : 2" :rows="smallerThanSm ? 2 : 1" v-bind="{ ...attrs, ...$attrs }" />
|
<VCalendarDatePicker
|
||||||
<VCalendarDatePicker v-else v-model="date" v-bind="{ ...attrs, ...$attrs }" />
|
v-if="date && (date as DatePickerRangeObject)?.start && (date as DatePickerRangeObject)?.end"
|
||||||
|
v-model.range="date"
|
||||||
|
:columns="2"
|
||||||
|
v-bind="{ ...attrs, ...$attrs }"
|
||||||
|
@dayclick="onDayClick"
|
||||||
|
/>
|
||||||
|
<VCalendarDatePicker
|
||||||
|
v-else
|
||||||
|
v-model="date"
|
||||||
|
v-bind="{ ...attrs, ...$attrs }"
|
||||||
|
@dayclick="onDayClick"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
v-else
|
v-else
|
||||||
class="font-semibold flex flex-col gap-1 text-center"
|
class="font-semibold flex flex-col gap-1 text-center"
|
||||||
:class="[
|
:class="[
|
||||||
!block.slot && (block.inactive || block.inactive === undefined ? 'text-gray-900 dark:text-white' : 'text-white dark:text-gray-900'),
|
!block.slot && (block.inactive || block.inactive === undefined ? 'text-gray-900 dark:text-white' : 'text-white dark:text-gray-900')
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
{{ block.name }}
|
{{ block.name }}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ function createGrid () {
|
|||||||
grid.value = []
|
grid.value = []
|
||||||
|
|
||||||
for (let i = 0; i <= rows.value; i++) {
|
for (let i = 0; i <= rows.value; i++) {
|
||||||
|
// eslint-disable-next-line unicorn/no-new-array
|
||||||
grid.value.push(new Array(cols.value).fill(null))
|
grid.value.push(new Array(cols.value).fill(null))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ export async function fetchComponentMeta (name: string) {
|
|||||||
await state.value[name]
|
await state.value[name]
|
||||||
return state.value[name]
|
return state.value[name]
|
||||||
}
|
}
|
||||||
if (state.value[name]) { return state.value[name] }
|
if (state.value[name]) {
|
||||||
|
return state.value[name]
|
||||||
|
}
|
||||||
|
|
||||||
// Store promise to avoid multiple calls
|
// Store promise to avoid multiple calls
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ export async function fetchContentExampleCode (name?: string) {
|
|||||||
await state.value[name]
|
await state.value[name]
|
||||||
return state.value[name]
|
return state.value[name]
|
||||||
}
|
}
|
||||||
if (state.value[name]) { return state.value[name] }
|
if (state.value[name]) {
|
||||||
|
return state.value[name]
|
||||||
|
}
|
||||||
|
|
||||||
// add to nitro prerender
|
// add to nitro prerender
|
||||||
if (import.meta.server) {
|
if (import.meta.server) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Its goal is to provide everything related to UI when building a Nuxt app. This i
|
|||||||
- Keyboard shortcuts
|
- Keyboard shortcuts
|
||||||
- Bundled icons
|
- Bundled icons
|
||||||
- Fully typed
|
- Fully typed
|
||||||
- [Figma Kit](https://www.figma.com/community/file/1288455405058138934)
|
- [Figma Kit](https://www.figma.com/community/file/1436401057300493073)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
|||||||
@@ -243,19 +243,21 @@ export default defineNuxtConfig({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Edge
|
## Continuous Releases
|
||||||
|
|
||||||
To use the latest updates pushed on the [`dev`](https://github.com/nuxt/ui/tree/dev) branch, you can use `@nuxt/ui-edge`.
|
Nuxt UI uses [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) for continuous preview releases, providing developers with instant access to the latest features and bug fixes without waiting for official releases.
|
||||||
|
|
||||||
Update your `package.json` to the following:
|
Preview releases are automatically generated for every commit to the `dev` branch and pull requests targeting the `dev` branch. To use it into your project, replace the version in your `package.json` with the commit hash or pull request number.
|
||||||
|
|
||||||
```diff [package.json]
|
```diff [package.json]
|
||||||
{
|
{
|
||||||
"devDependencies": {
|
"dependencies": {
|
||||||
- "@nuxt/ui": "^2.11.0"
|
- "@nuxt/ui": "^2.21.0",
|
||||||
+ "@nuxt/ui": "npm:@nuxt/ui-edge@latest"
|
+ "@nuxt/ui": "https://pkg.pr.new/@nuxt/ui@bf1c9e7",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Then run `pnpm install`, `yarn install` or `npm install`.
|
::note
|
||||||
|
**pkg.pr.new** will automatically comment on PRs with the installation URL, making it easy to test changes.
|
||||||
|
::
|
||||||
|
|||||||
@@ -221,6 +221,52 @@ export default defineAppConfig({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Extend Tailwind Merge
|
||||||
|
|
||||||
|
Tailwind Merge is a library that allows you to efficiently merge Tailwind CSS classes. It is used by this module to merge the classes from the `ui` prop, the `class` attribute, and the default classes.
|
||||||
|
|
||||||
|
::callout{icon="i-heroicons-light-bulb" to="https://github.com/dcastil/tailwind-merge" target="_blank"}
|
||||||
|
Learn more about Tailwind Merge.
|
||||||
|
::
|
||||||
|
|
||||||
|
By default, Tailwind Merge doesn't handle custom Tailwind CSS configuration like custom colors, spacing, or other utilities you may have defined. You'll need to extend it to handle your custom configuration.
|
||||||
|
|
||||||
|
You can extend Tailwind Merge by using the `tailwindMerge` option in your `app.config.ts`:
|
||||||
|
|
||||||
|
::code-group
|
||||||
|
```ts [app.config.ts]
|
||||||
|
export default defineAppConfig({
|
||||||
|
ui: {
|
||||||
|
tailwindMerge: {
|
||||||
|
extend: {
|
||||||
|
theme: {
|
||||||
|
spacing: ['sm', 'md', 'lg', 'xl', '2xl']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts [tailwind.config.ts]
|
||||||
|
import type { Config } from 'tailwindcss'
|
||||||
|
|
||||||
|
export default <Partial<Config>>{
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
spacing: {
|
||||||
|
sm: '0.5rem',
|
||||||
|
md: '1rem',
|
||||||
|
lg: '1.5rem',
|
||||||
|
xl: '2rem',
|
||||||
|
'2xl': '2.5rem'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
::
|
||||||
|
|
||||||
## Dark mode
|
## Dark mode
|
||||||
|
|
||||||
All the components are styled with dark mode in mind.
|
All the components are styled with dark mode in mind.
|
||||||
@@ -343,6 +389,12 @@ export default defineAppConfig({
|
|||||||
loadingIcon: 'i-octicon-sync-24'
|
loadingIcon: 'i-octicon-sync-24'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
inputMenu: {
|
||||||
|
default: {
|
||||||
|
selectedIcon: 'i-octicon-check-24',
|
||||||
|
trailingIcon: 'i-octicon-chevron-down-24'
|
||||||
|
}
|
||||||
|
},
|
||||||
select: {
|
select: {
|
||||||
default: {
|
default: {
|
||||||
loadingIcon: 'i-octicon-sync-24',
|
loadingIcon: 'i-octicon-sync-24',
|
||||||
@@ -378,6 +430,9 @@ export default defineAppConfig({
|
|||||||
sortButton: {
|
sortButton: {
|
||||||
icon: 'i-octicon-arrow-switch-24'
|
icon: 'i-octicon-arrow-switch-24'
|
||||||
},
|
},
|
||||||
|
expandButton: {
|
||||||
|
icon: 'i-octicon-chevron-down-24'
|
||||||
|
},
|
||||||
loadingState: {
|
loadingState: {
|
||||||
icon: 'i-octicon-sync-24'
|
icon: 'i-octicon-sync-24'
|
||||||
},
|
},
|
||||||
@@ -411,6 +466,21 @@ export default defineAppConfig({
|
|||||||
default: {
|
default: {
|
||||||
divider: 'i-octicon-chevron-right-24'
|
divider: 'i-octicon-chevron-right-24'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
carousel: {
|
||||||
|
default: {
|
||||||
|
prevButton: {
|
||||||
|
icon: 'i-octicon-chevron-left-24'
|
||||||
|
},
|
||||||
|
nextButton: {
|
||||||
|
icon: 'i-octicon-chevron-right-24'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggle: {
|
||||||
|
default: {
|
||||||
|
loadingIcon: 'i-octicon-sync-24'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -49,18 +49,22 @@ defineShortcuts({
|
|||||||
Shortcuts keys are written as the literal keyboard key value. Combinations are made with `_` separator. Chained shortcuts are made with `-` separator.
|
Shortcuts keys are written as the literal keyboard key value. Combinations are made with `_` separator. Chained shortcuts are made with `-` separator.
|
||||||
|
|
||||||
Modifiers are also available:
|
Modifiers are also available:
|
||||||
- `meta`: acts as `Command` for MacOS and `Control` for others
|
| Modifier | Description |
|
||||||
- `ctrl`: acts as `Control`
|
|----------|-------------|
|
||||||
- `shift`: acts as `Shift` and is only necessary for alphabetic keys
|
| `meta` | Acts as `Command (⌘)` on macOS and `Control (Ctrl)` on Windows/Linux. |
|
||||||
|
| `ctrl` | Represents the `Control (Ctrl)` key across all operating systems. |
|
||||||
|
| `shift` | Represents the `Shift` key, only needed for alphabetic keys (e.g., `shift_e`). |
|
||||||
|
|
||||||
Examples of keys:
|
Examples of keys:
|
||||||
- `escape`: will trigger by hitting `Esc`
|
| Shortcut Key | Action |
|
||||||
- `meta_k`: will trigger by hitting `⌘` and `K` at the same time on MacOS, and `Ctrl` and `K` on Windows and Linux
|
|---------------|--------|
|
||||||
- `ctrl_k`: will trigger by hitting `Ctrl` and `K` at the same time on MacOS, Windows and Linux
|
| `escape` | Triggers when `Esc` is pressed |
|
||||||
- `shift_e`: will trigger by hitting `Shift` and `E` at the same time on MacOS, Windows and Linux
|
| `meta_k` | `⌘ + K` on Mac, `Ctrl + K` on Windows/Linux |
|
||||||
- `?`: will trigger by hitting `?` on some keyboard layouts, or for example `Shift` and `/`, which results in `?` on US Mac keyboards
|
| `ctrl_k` | Triggers `Ctrl + K` on all OS |
|
||||||
- `g-d`: will trigger by hitting `g` then `d` with a maximum delay of 800ms by default
|
| `shift_e` | Triggers `Shift + E` on all OS |
|
||||||
- `arrowleft`: will trigger by hitting `←` (also: `arrowright`, `arrowup`, `arrowdown`)
|
| `?` | Triggers `?` (Shift + `/` on US Mac keyboards) |
|
||||||
|
| `g-d` | Triggers when `g` then `d` are pressed within 800ms |
|
||||||
|
| `arrowleft` | Triggers when `←` is pressed (also: `arrowright`, `arrowup`, `arrowdown`) |
|
||||||
|
|
||||||
::callout{icon="i-heroicons-light-bulb"}
|
::callout{icon="i-heroicons-light-bulb"}
|
||||||
For a complete list of available shortcut keys, refer to the [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values) API docs. Note the `KeyboardEvent.key` has to be written in lowercase.
|
For a complete list of available shortcut keys, refer to the [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values) API docs. Note the `KeyboardEvent.key` has to be written in lowercase.
|
||||||
|
|||||||
@@ -141,6 +141,74 @@ Badge
|
|||||||
You can customize the whole [preset](#preset) by using the `ui` prop.
|
You can customize the whole [preset](#preset) by using the `ui` prop.
|
||||||
::
|
::
|
||||||
|
|
||||||
|
### Icon
|
||||||
|
|
||||||
|
Use any icon from [Iconify](https://icones.js.org) by setting the `icon` prop by using this pattern: `i-{collection_name}-{icon_name}`.
|
||||||
|
|
||||||
|
Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
props:
|
||||||
|
icon: 'i-heroicons-rocket-launch'
|
||||||
|
size: 'sm'
|
||||||
|
color: 'primary'
|
||||||
|
variant: 'solid'
|
||||||
|
label: Badge
|
||||||
|
trailing: false
|
||||||
|
options:
|
||||||
|
- name: variant
|
||||||
|
restriction: only
|
||||||
|
values:
|
||||||
|
- solid
|
||||||
|
excludedProps:
|
||||||
|
- icon
|
||||||
|
- label
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
## Slots
|
||||||
|
|
||||||
|
### `leading`
|
||||||
|
|
||||||
|
Use the `#leading` slot to set the content of the leading icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
leading: <UAvatar src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs" />
|
||||||
|
baseProps:
|
||||||
|
color: 'gray'
|
||||||
|
props:
|
||||||
|
label: Badge
|
||||||
|
color: 'gray'
|
||||||
|
excludedProps:
|
||||||
|
- color
|
||||||
|
---
|
||||||
|
|
||||||
|
#leading
|
||||||
|
:u-avatar{src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs"}
|
||||||
|
::
|
||||||
|
|
||||||
|
### `trailing`
|
||||||
|
|
||||||
|
Use the `#trailing` slot to set the content of the trailing icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
trailing: <UIcon name="i-heroicons-rocket-launch" class="w-4 h-4" />
|
||||||
|
props:
|
||||||
|
label: Badge
|
||||||
|
color: 'gray'
|
||||||
|
excludedProps:
|
||||||
|
- color
|
||||||
|
---
|
||||||
|
|
||||||
|
#trailing
|
||||||
|
:u-icon{name="i-heroicons-rocket-launch" class="w-4 h-4"}
|
||||||
|
::
|
||||||
|
|
||||||
## Props
|
## Props
|
||||||
|
|
||||||
:component-props
|
:component-props
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ slots:
|
|||||||
[Label]{.italic}
|
[Label]{.italic}
|
||||||
::
|
::
|
||||||
|
|
||||||
### `help` :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"}
|
### `help`
|
||||||
|
|
||||||
Like the `#label` slot, use the `#help` slot to override the content of the help text.
|
Like the `#label` slot, use the `#help` slot to override the content of the help text.
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,14 @@ The following example is styled based on the `primary` and `gray` colors and sup
|
|||||||
```vue [components/DatePicker.vue]
|
```vue [components/DatePicker.vue]
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DatePicker as VCalendarDatePicker } from 'v-calendar'
|
import { DatePicker as VCalendarDatePicker } from 'v-calendar'
|
||||||
|
// @ts-ignore
|
||||||
import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
|
import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
|
||||||
import 'v-calendar/dist/style.css'
|
import 'v-calendar/dist/style.css'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false
|
||||||
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [Date, Object] as PropType<DatePickerDate | DatePickerRangeObject | null>,
|
type: [Date, Object] as PropType<DatePickerDate | DatePickerRangeObject | null>,
|
||||||
@@ -59,17 +64,33 @@ const date = computed({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const attrs = {
|
const attrs = {
|
||||||
transparent: true,
|
'transparent': true,
|
||||||
borderless: true,
|
'borderless': true,
|
||||||
color: 'primary',
|
'color': 'primary',
|
||||||
'is-dark': { selector: 'html', darkClass: 'dark' },
|
'is-dark': { selector: 'html', darkClass: 'dark' },
|
||||||
'first-day-of-week': 2,
|
'first-day-of-week': 2
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDayClick(_: any, event: MouseEvent): void {
|
||||||
|
const target = event.target as HTMLElement
|
||||||
|
target.blur()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VCalendarDatePicker v-if="date && (typeof date === 'object')" v-model.range="date" :columns="2" v-bind="{ ...attrs, ...$attrs }" />
|
<VCalendarDatePicker
|
||||||
<VCalendarDatePicker v-else v-model="date" v-bind="{ ...attrs, ...$attrs }" />
|
v-if="date && (date as DatePickerRangeObject)?.start && (date as DatePickerRangeObject)?.end"
|
||||||
|
v-model.range="date"
|
||||||
|
:columns="2"
|
||||||
|
v-bind="{ ...attrs, ...$attrs }"
|
||||||
|
@dayclick="onDayClick"
|
||||||
|
/>
|
||||||
|
<VCalendarDatePicker
|
||||||
|
v-else
|
||||||
|
v-model="date"
|
||||||
|
v-bind="{ ...attrs, ...$attrs }"
|
||||||
|
@dayclick="onDayClick"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ links:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use the Form component to validate form data using schema libraries such as [Yup](https://github.com/jquense/yup), [Zod](https://github.com/colinhacks/zod), [Joi](https://github.com/hapijs/joi), [Valibot](https://github.com/fabian-hiller/valibot), or your own validation logic.
|
Use the Form component to validate form data using schema libraries such as [Yup](https://github.com/jquense/yup), [Zod](https://github.com/colinhacks/zod), [Joi](https://github.com/hapijs/joi), [Valibot](https://github.com/fabian-hiller/valibot), [Superstruct](https://github.com/ianstormtaylor/superstruct), or your own validation logic.
|
||||||
|
|
||||||
It works with the [FormGroup](/components/form-group) component to display error messages around form elements automatically.
|
It works with the [FormGroup](/components/form-group) component to display error messages around form elements automatically.
|
||||||
|
|
||||||
The form component requires two props:
|
The form component requires two props:
|
||||||
- `state` - a reactive object holding the form's state.
|
- `state` - a reactive object holding the form's state.
|
||||||
- `schema` - a schema object from a validation library like [Yup](https://github.com/jquense/yup), [Zod](https://github.com/colinhacks/zod), [Joi](https://github.com/hapijs/joi) or [Valibot](https://github.com/fabian-hiller/valibot).
|
- `schema` - a schema object from a validation library like [Yup](https://github.com/jquense/yup), [Zod](https://github.com/colinhacks/zod), [Joi](https://github.com/hapijs/joi), [Valibot](https://github.com/fabian-hiller/valibot) or [Superstruct](https://github.com/ianstormtaylor/superstruct).
|
||||||
|
|
||||||
::callout{icon="i-heroicons-light-bulb"}
|
::callout{icon="i-heroicons-light-bulb"}
|
||||||
Note that **no validation library is included** by default, so ensure you **install the one you need**.
|
Note that **no validation library is included** by default, so ensure you **install the one you need**.
|
||||||
@@ -52,6 +52,13 @@ Note that **no validation library is included** by default, so ensure you **inst
|
|||||||
class: 'w-60'
|
class: 'w-60'
|
||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
::component-example{label="Superstruct"}
|
||||||
|
---
|
||||||
|
component: 'form-example-superstruct'
|
||||||
|
componentProps:
|
||||||
|
class: 'w-60'
|
||||||
|
---
|
||||||
|
::
|
||||||
::
|
::
|
||||||
|
|
||||||
## Custom validation
|
## Custom validation
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ This component does not support multiple values. Use the [SelectMenu](/component
|
|||||||
|
|
||||||
### Objects
|
### Objects
|
||||||
|
|
||||||
You can pass an array of objects to `options` and either compare on the whole object or use the `by` prop to compare on a specific key. You can configure which field will be used to display the label through the `option-attribute` prop that defaults to `label`.
|
You can pass an array of objects to `options` and either compare on the whole object or use the `by` prop to compare on a specific key. You can configure which field will be used to display the label through the `option-attribute` prop that defaults to `label`. Additionally, you can use dot notation (e.g., `user.name`) to access nested object properties.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
@@ -174,6 +174,8 @@ componentProps:
|
|||||||
|
|
||||||
Use the `#option-empty` slot to customize the content displayed when the `searchable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope.
|
Use the `#option-empty` slot to customize the content displayed when the `searchable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope.
|
||||||
|
|
||||||
|
You can also configure this globally through the `ui.inputMenu.default.optionEmpty.label` config. The token `{query}` will be replaced by `query` property. Defaults to `No results for "{query}".`.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
component: 'input-menu-example-option-empty-slot'
|
component: 'input-menu-example-option-empty-slot'
|
||||||
@@ -186,6 +188,8 @@ componentProps:
|
|||||||
|
|
||||||
Use the `#empty` slot to customize the content displayed when there is no options. Defaults to `No options.`.
|
Use the `#empty` slot to customize the content displayed when there is no options. Defaults to `No options.`.
|
||||||
|
|
||||||
|
You can also configure this globally through the `ui.inputMenu.default.empty.label` config. Defaults to `No options.`.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
component: 'input-menu-example-empty-slot'
|
component: 'input-menu-example-empty-slot'
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ props:
|
|||||||
|
|
||||||
### Loading
|
### Loading
|
||||||
|
|
||||||
Use the `loading` prop to show a loading icon and disable the Input.
|
Use the `loading` prop to show a loading icon in the Input.
|
||||||
|
|
||||||
Use the `loading-icon` prop to set a different icon or change it globally in `ui.input.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`.
|
Use the `loading-icon` prop to set a different icon or change it globally in `ui.input.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`.
|
||||||
|
|
||||||
@@ -173,6 +173,13 @@ baseProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
### Limit
|
||||||
|
|
||||||
|
Use the `maxlength` prop to limit the length of the Input.
|
||||||
|
|
||||||
|
:component-example{component="input-example-max-length"}
|
||||||
|
|
||||||
|
|
||||||
## Slots
|
## Slots
|
||||||
|
|
||||||
### `leading`
|
### `leading`
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ The Link component is a wrapper around [`<NuxtLink>`](https://nuxt.com/docs/api/
|
|||||||
- `inactive-class` prop to set a class when the link is inactive, `active-class` is used when active.
|
- `inactive-class` prop to set a class when the link is inactive, `active-class` is used when active.
|
||||||
- `exact` prop to style with `active-class` when the link is active and the route is exactly the same as the current route.
|
- `exact` prop to style with `active-class` when the link is active and the route is exactly the same as the current route.
|
||||||
- `exact-query` and `exact-hash` props to style with `active-class` when the link is active and the query or hash is exactly the same as the current query or hash.
|
- `exact-query` and `exact-hash` props to style with `active-class` when the link is active and the query or hash is exactly the same as the current query or hash.
|
||||||
|
- use `exact-query="partial"` to style with `active-class` when the link is active and the query partially match the current query.
|
||||||
|
|
||||||
The incentive behind this is to provide the same API as NuxtLink back in Nuxt 2 / Vue 2. You can read more about it in the Vue Router [migration from Vue 2](https://router.vuejs.org/guide/migration/#removal-of-the-exact-prop-in-router-link) guide.
|
The incentive behind this is to provide the same API as NuxtLink back in Nuxt 2 / Vue 2. You can read more about it in the Vue Router [migration from Vue 2](https://router.vuejs.org/guide/migration/#removal-of-the-exact-prop-in-router-link) guide.
|
||||||
|
|
||||||
|
|||||||
@@ -29,12 +29,16 @@ export default defineAppConfig({
|
|||||||
ui: {
|
ui: {
|
||||||
notifications: {
|
notifications: {
|
||||||
// Show toasts at the top right of the screen
|
// Show toasts at the top right of the screen
|
||||||
position: 'top-0 right-0'
|
position: 'top-0 bottom-[unset]'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
::callout{icon="i-heroicons-light-bulb"}
|
||||||
|
The `position` defaults to `bottom-0 end-0`, the `bottom-[unset]` class overrides `bottom-0` so the result is `top-0 end-0`.
|
||||||
|
::
|
||||||
|
|
||||||
Then, you can use the `useToast` composable to add notifications to your app:
|
Then, you can use the `useToast` composable to add notifications to your app:
|
||||||
|
|
||||||
:component-example{component="notification-example-basic"}
|
:component-example{component="notification-example-basic"}
|
||||||
@@ -133,9 +137,9 @@ excludedProps:
|
|||||||
|
|
||||||
### Timeout
|
### Timeout
|
||||||
|
|
||||||
Use the `timeout` prop to configure how long the Notification will remain. The default value is `5000`, set it to `0` to disable the timeout.
|
Use the `timeout` prop to configure how long the Notification will remain. The default value is `5000`, set it to `0` to disable the timeout. The `pauseTimeoutOnHover` prop (`true` by default) controls whether hovering the notification should pause the timeout.
|
||||||
|
|
||||||
You will see a progress bar at the bottom of the Notification which will indicate the remaining time. When hovering the Notification, the progress bar will be paused.
|
You will see a progress bar at the bottom of the Notification which will indicate the remaining time. When hovering the Notification, the progress bar will be paused if `pauseTimeoutOnHover` is enabled; otherwise, it won't stop.
|
||||||
|
|
||||||
::component-card
|
::component-card
|
||||||
---
|
---
|
||||||
@@ -145,6 +149,7 @@ baseProps:
|
|||||||
description: 'This is a notification.'
|
description: 'This is a notification.'
|
||||||
props:
|
props:
|
||||||
timeout: 60000
|
timeout: 60000
|
||||||
|
pauseTimeoutOnHover: true
|
||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ slots:
|
|||||||
[Label]{.italic}
|
[Label]{.italic}
|
||||||
::
|
::
|
||||||
|
|
||||||
### `help` :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"}
|
### `help`
|
||||||
|
|
||||||
Like the `#label` slot, use the `#help` slot to override the content of the help text.
|
Like the `#label` slot, use the `#help` slot to override the content of the help text.
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ componentProps:
|
|||||||
|
|
||||||
### Objects
|
### Objects
|
||||||
|
|
||||||
You can pass an array of objects to `options` and either compare on the whole object or use the `by` prop to compare on a specific key. You can configure which field will be used to display the label through the `option-attribute` prop that defaults to `label`.
|
You can pass an array of objects to `options` and either compare on the whole object or use the `by` prop to compare on a specific key. You can configure which field will be used to display the label through the `option-attribute` prop that defaults to `label`. Additionally, you can use dot notation (e.g., `user.name`) to access nested object properties.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
@@ -85,7 +85,7 @@ Learn how to customize icons from the [Select](/components/select#icon) componen
|
|||||||
|
|
||||||
Use the `searchable` prop to enable search.
|
Use the `searchable` prop to enable search.
|
||||||
|
|
||||||
Use the `searchable-placeholder` prop to set a different placeholder.
|
Use the `searchable-placeholder` prop to set a different placeholder or globally through the `ui.selectMenu.default.searchablePlaceholder.label` config. Defaults to `Search...`.
|
||||||
|
|
||||||
This will use Headless UI [Combobox](https://headlessui.com/v1/vue/combobox) component instead of [Listbox](https://headlessui.com/v1/vue/listbox).
|
This will use Headless UI [Combobox](https://headlessui.com/v1/vue/combobox) component instead of [Listbox](https://headlessui.com/v1/vue/listbox).
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ componentProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
Pass a function to the `show-create-option-when` prop to control wether or not to show the create option. This function takes two arguments: the query (as the first argument) and an array of current results (as the second argument). It should return true to display the create option. :u-badge{label="New" class="!rounded-full" variant="subtle"}
|
Pass a function to the `show-create-option-when` prop to control wether or not to show the create option. This function takes two arguments: the query (as the first argument) and an array of current results (as the second argument). It should return true to display the create option.
|
||||||
|
|
||||||
The example below shows how to make the create option visible when the query is at least three characters long and does not exactly match any of the current results (case insensitive).
|
The example below shows how to make the create option visible when the query is at least three characters long and does not exactly match any of the current results (case insensitive).
|
||||||
|
|
||||||
@@ -258,6 +258,8 @@ componentProps:
|
|||||||
|
|
||||||
Use the `#option-empty` slot to customize the content displayed when the `searchable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope.
|
Use the `#option-empty` slot to customize the content displayed when the `searchable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope.
|
||||||
|
|
||||||
|
You can also configure this globally through the `ui.selectMenu.default.optionEmpty.label` config. The token `{query}` will be replaced by `query` property. Defaults to `No results for "{query}".`.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
component: 'select-menu-example-option-empty-slot'
|
component: 'select-menu-example-option-empty-slot'
|
||||||
@@ -276,7 +278,9 @@ An example is available in the [Creatable](#creatable) section.
|
|||||||
|
|
||||||
### `empty`
|
### `empty`
|
||||||
|
|
||||||
Use the `#empty` slot to customize the content displayed when there is no options. Defaults to `No options.`.
|
Use the `#empty` slot to customize the content displayed when there is no options.
|
||||||
|
|
||||||
|
You can also configure this globally through the `ui.selectMenu.default.empty.label` config. Defaults to `No options.`.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Use the `columns` prop to configure which columns to display. It's an array of o
|
|||||||
- `sortable` - Whether the column is sortable. Defaults to `false`.
|
- `sortable` - Whether the column is sortable. Defaults to `false`.
|
||||||
- `direction` - The sort direction to use on first click. Defaults to `asc`.
|
- `direction` - The sort direction to use on first click. Defaults to `asc`.
|
||||||
- `class` - The class to apply to the column cells.
|
- `class` - The class to apply to the column cells.
|
||||||
- `rowClass` - The class to apply to the data column cells. :u-badge{label="New" class="!rounded-full" variant="subtle"}
|
- `rowClass` - The class to apply to the data column cells.
|
||||||
- `sort` - Pass your own `sort` function. Defaults to a simple _greater than_ / _less than_ comparison.
|
- `sort` - Pass your own `sort` function. Defaults to a simple _greater than_ / _less than_ comparison.
|
||||||
|
|
||||||
Arguments for the `sort` function are: Value A, Value B, Direction - 'asc' or 'desc'
|
Arguments for the `sort` function are: Value A, Value B, Direction - 'asc' or 'desc'
|
||||||
@@ -62,7 +62,7 @@ extraClass: 'overflow-hidden'
|
|||||||
padding: false
|
padding: false
|
||||||
component: 'table-example-columns-selectable'
|
component: 'table-example-columns-selectable'
|
||||||
componentProps:
|
componentProps:
|
||||||
class: 'flex-1 flex-col overflow-hidden'
|
class: 'flex-1 flex-col overflow-hidden min-h-[230px]'
|
||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
@@ -285,6 +285,81 @@ componentProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
|
||||||
|
#### Event Selectable
|
||||||
|
The `UTable` component provides two key events for handling row selection:
|
||||||
|
|
||||||
|
##### ***@select:all***
|
||||||
|
The `@select:all` event is emitted when the header checkbox in a selectable table is toggled. This event returns a boolean value indicating whether all rows are selected (true) or deselected (false).
|
||||||
|
|
||||||
|
##### ***@update:modelValue***
|
||||||
|
The `@update:modelValue` event is emitted whenever the selection state changes, including both individual row selection and bulk selection. This event returns an array containing the currently selected rows.
|
||||||
|
|
||||||
|
Here's how to implement both events:
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<script setup lang="ts">
|
||||||
|
const selected = ref([])
|
||||||
|
|
||||||
|
const onHandleSelectAll = (isSelected: boolean) => {
|
||||||
|
console.log('All rows selected:', isSelected)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onUpdateSelection = (selectedRows: any[]) => {
|
||||||
|
console.log('Currently selected rows:', selectedRows)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UTable
|
||||||
|
v-model="selected"
|
||||||
|
:rows="people"
|
||||||
|
@select:all="onHandleSelectAll"
|
||||||
|
@update:modelValue="onUpdateSelection"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Single Select Mode
|
||||||
|
Control how the select function allows only one row to be selected at a time.
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<!-- Allow only one row to be selectable at a time -->
|
||||||
|
<UTable :single-select="true" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Checkbox Placement
|
||||||
|
You can customize the checkbox column position by using the `select` key in the `columns` configuration.
|
||||||
|
|
||||||
|
::component-example{class="grid"}
|
||||||
|
---
|
||||||
|
extraClass: 'overflow-hidden'
|
||||||
|
padding: false
|
||||||
|
component: 'table-example-dynamically-render-selectable'
|
||||||
|
componentProps:
|
||||||
|
class: 'flex-1'
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
### Contextmenu
|
||||||
|
|
||||||
|
Use the `contextmenu` listener on your Table to make the rows right-clickable. The function will receive the original event as the first argument and the row as the second argument.
|
||||||
|
|
||||||
|
You can use this to open a [ContextMenu](/components/context-menu) for that row.
|
||||||
|
|
||||||
|
::component-example{class="grid"}
|
||||||
|
---
|
||||||
|
extraClass: 'overflow-hidden'
|
||||||
|
padding: false
|
||||||
|
component: 'table-example-contextmenu'
|
||||||
|
componentProps:
|
||||||
|
class: 'flex-1 flex-col overflow-hidden'
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
### Searchable
|
### Searchable
|
||||||
|
|
||||||
You can easily use the [Input](/components/input) component to filter the rows.
|
You can easily use the [Input](/components/input) component to filter the rows.
|
||||||
@@ -313,12 +388,15 @@ componentProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
### Expandable :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"}
|
### Expandable
|
||||||
|
|
||||||
You can use the `expand` slot to display extra information about a row. You will have access to the `row` property in the slot scope.
|
You can use the `v-model:expand` to enables row expansion functionality in the table component. It maintains an object containing an `openedRows` an array and `row` an object, which tracks the indices of currently expanded rows.
|
||||||
|
|
||||||
|
When using the expand slot, you have access to the `row` property in the slot scope, which contains the data of the row that triggered the expand/collapse action. This allows you to customize the expanded content based on the row's data.
|
||||||
|
|
||||||
::component-example{class="grid"}
|
::component-example{class="grid"}
|
||||||
---
|
---
|
||||||
|
extraClass: 'overflow-hidden'
|
||||||
padding: false
|
padding: false
|
||||||
component: 'table-example-expandable'
|
component: 'table-example-expandable'
|
||||||
componentProps:
|
componentProps:
|
||||||
@@ -326,6 +404,72 @@ componentProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
#### Event expand
|
||||||
|
|
||||||
|
The `@update:expand` event is emitted when a row is expanded. This event provides the current state of expanded rows and the data of the row that triggered the event.
|
||||||
|
|
||||||
|
To use the `@update:expand` event, add it to your `UTable` component. The event handler will receive an object with the following properties:
|
||||||
|
- `openedRows`: An array of indices of the currently expanded rows.
|
||||||
|
- `row`: The row data that triggered the expand/collapse action.
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<script setup lang="ts">
|
||||||
|
const { data, pending } = await useLazyFetch(() => `/api/users`)
|
||||||
|
|
||||||
|
const handleExpand = ({ openedRows, row }) => {
|
||||||
|
console.log('opened Rows:', openedRows);
|
||||||
|
console.log('Row Data:', row);
|
||||||
|
};
|
||||||
|
|
||||||
|
const expand = ref({
|
||||||
|
openedRows: [],
|
||||||
|
row: null
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<UTable v-model="expand" :loading="pending" :rows="data" @update:expand="handleExpand">
|
||||||
|
<template #expand="{ row }">
|
||||||
|
<div class="p-4">
|
||||||
|
<pre>{{ row }}</pre>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Multiple expand
|
||||||
|
Controls whether multiple rows can be expanded simultaneously in the table.
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<!-- Allow only one row to be expanded at a time -->
|
||||||
|
<UTable :multiple-expand="false" />
|
||||||
|
|
||||||
|
<!-- Default behavior: Allow multiple rows to be expanded simultaneously -->
|
||||||
|
<UTable :multiple-expand="true" />
|
||||||
|
|
||||||
|
<!-- Or simply -->
|
||||||
|
<UTable />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Disable Row Expansion
|
||||||
|
|
||||||
|
You can disable the expansion functionality for specific rows in the UTable component by adding the `disabledExpand` property to your row data.
|
||||||
|
|
||||||
|
> Important: When using `disabledExpand`, you must define the `columns` prop for the UTable component. Otherwise, the table will render all properties as columns, including the `disabledExpand` property.
|
||||||
|
|
||||||
|
::component-example{class="grid"}
|
||||||
|
---
|
||||||
|
extraClass: 'overflow-hidden'
|
||||||
|
padding: false
|
||||||
|
component: 'table-example-disabled-expandable'
|
||||||
|
componentProps:
|
||||||
|
class: 'flex-1'
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
### Loading
|
### Loading
|
||||||
|
|
||||||
Use the `loading` prop to indicate that data is currently loading with an indeterminate [Progress](/components/progress#indeterminate) bar.
|
Use the `loading` prop to indicate that data is currently loading with an indeterminate [Progress](/components/progress#indeterminate) bar.
|
||||||
@@ -448,6 +592,119 @@ componentProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
### `select-header`
|
||||||
|
This slot allows you to customize the checkbox appearance in the table header for selecting all rows at once while using feature [Selectable](#selectable).
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<UTable v-model="selectable">
|
||||||
|
<template #select-header="{ checked, change, indeterminate }">
|
||||||
|
<!-- Place your custom component here -->
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Props
|
||||||
|
|
||||||
|
| Prop | Type | Description |
|
||||||
|
|------|------|-------------|
|
||||||
|
| `checked` | `Boolean` | Indicates if all rows are selected |
|
||||||
|
| `change` | `Function` | Function to handle selection state changes. Must receive a boolean value (true/false) |
|
||||||
|
| `indeterminate` | `Boolean` | Indicates partial selection (when some rows are selected) |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<UTable>
|
||||||
|
<!-- Header checkbox customization -->
|
||||||
|
<template #select-header="{ indeterminate, checked, change }">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
:indeterminate="indeterminate"
|
||||||
|
:checked="checked"
|
||||||
|
@change="e => change(e.target.checked)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
### `select-data`
|
||||||
|
This slot allows you to customize the checkbox appearance for each row in the table while using feature [Selectable](#selectable).
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<UTable v-model="selectable">
|
||||||
|
<template #select-data="{ checked, change }">
|
||||||
|
<!-- Place your custom component here -->
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Props
|
||||||
|
|
||||||
|
| Prop | Type | Description |
|
||||||
|
|------|------|-------------|
|
||||||
|
| `checked` | `Boolean` | Indicates if the current row is selected |
|
||||||
|
| `change` | `Function` | Function to handle selection state changes. Must receive a boolean value (true/false) |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<UTable>
|
||||||
|
<!-- Row checkbox customization -->
|
||||||
|
<template #select-data="{ checked, change }">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
:checked="checked"
|
||||||
|
@change="e => change(e.target.checked)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
### `expand-action`
|
||||||
|
|
||||||
|
The `#expand-action` slot allows you to customize the expansion control interface for expandable table rows. This feature provides a flexible way to implement custom expand/collapse functionality while maintaining access to essential row data and state.
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<UTable>
|
||||||
|
<template #expand-action="{ row, toggle, isExpanded }">
|
||||||
|
<!-- Your custom expand action content -->
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Slot Props
|
||||||
|
|
||||||
|
The slot provides three key props:
|
||||||
|
|
||||||
|
| Prop | Type | Description |
|
||||||
|
|------|------|-------------|
|
||||||
|
| `row` | `Object` | Contains the current row's data |
|
||||||
|
| `toggle` | `Function` | Function to toggle the expanded state |
|
||||||
|
| `isExpanded` | `Boolean` | Current expansion state of the row |
|
||||||
|
|
||||||
|
::component-example{class="grid"}
|
||||||
|
---
|
||||||
|
extraClass: 'overflow-hidden'
|
||||||
|
padding: false
|
||||||
|
component: 'table-example-expand-action-slot'
|
||||||
|
componentProps:
|
||||||
|
class: 'flex-1'
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
|
||||||
### `loading-state`
|
### `loading-state`
|
||||||
|
|
||||||
Use the `#loading-state` slot to customize the loading state.
|
Use the `#loading-state` slot to customize the loading state.
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ Use the `#default` slot to customize the content of the trigger buttons. You wil
|
|||||||
|
|
||||||
:component-example{component="tabs-example-default-slot"}
|
:component-example{component="tabs-example-default-slot"}
|
||||||
|
|
||||||
### `icon` :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"}
|
### `icon`
|
||||||
|
|
||||||
Use the `#icon` slot to customize the icon of the trigger buttons. You will have access to the `item`, `index`, `selected` and `disabled` in the slot scope.
|
Use the `#icon` slot to customize the icon of the trigger buttons. You will have access to the `item`, `index`, `selected` and `disabled` in the slot scope.
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NuxtError } from '#app'
|
|
||||||
import type { ParsedContent } from '@nuxt/content'
|
import type { ParsedContent } from '@nuxt/content'
|
||||||
|
import type { NuxtError } from '#app'
|
||||||
|
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: 'Page not found',
|
title: 'Page not found',
|
||||||
@@ -57,7 +57,8 @@ const links = computed(() => {
|
|||||||
icon: 'i-heroicons-book-open',
|
icon: 'i-heroicons-book-open',
|
||||||
to: '/getting-started',
|
to: '/getting-started',
|
||||||
active: route.path.startsWith('/getting-started') || route.path.startsWith('/components')
|
active: route.path.startsWith('/getting-started') || route.path.startsWith('/components')
|
||||||
}, ...(navigation.value.find(item => item._path === '/pro') ? [{
|
}, ...(navigation.value.find(item => item._path === '/pro')
|
||||||
|
? [{
|
||||||
label: 'Pro',
|
label: 'Pro',
|
||||||
icon: 'i-heroicons-square-3-stack-3d',
|
icon: 'i-heroicons-square-3-stack-3d',
|
||||||
to: '/pro',
|
to: '/pro',
|
||||||
@@ -70,7 +71,8 @@ const links = computed(() => {
|
|||||||
label: 'Templates',
|
label: 'Templates',
|
||||||
icon: 'i-heroicons-computer-desktop',
|
icon: 'i-heroicons-computer-desktop',
|
||||||
to: '/pro/templates'
|
to: '/pro/templates'
|
||||||
}] : []), {
|
}]
|
||||||
|
: []), {
|
||||||
label: 'Releases',
|
label: 'Releases',
|
||||||
icon: 'i-heroicons-rocket-launch',
|
icon: 'i-heroicons-rocket-launch',
|
||||||
to: '/releases'
|
to: '/releases'
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { existsSync, readFileSync } from 'node:fs'
|
||||||
|
import fsp from 'node:fs/promises'
|
||||||
|
import { dirname, join } from 'pathe'
|
||||||
import {
|
import {
|
||||||
defineNuxtModule,
|
defineNuxtModule,
|
||||||
addTemplate,
|
addTemplate,
|
||||||
@@ -5,10 +8,6 @@ import {
|
|||||||
createResolver
|
createResolver
|
||||||
} from '@nuxt/kit'
|
} from '@nuxt/kit'
|
||||||
|
|
||||||
import { existsSync, readFileSync } from 'fs'
|
|
||||||
import { dirname, join } from 'pathe'
|
|
||||||
import fsp from 'fs/promises'
|
|
||||||
|
|
||||||
export default defineNuxtModule({
|
export default defineNuxtModule({
|
||||||
meta: {
|
meta: {
|
||||||
name: 'content-examples-code'
|
name: 'content-examples-code'
|
||||||
@@ -74,7 +73,7 @@ export default defineNuxtModule({
|
|||||||
|
|
||||||
nuxt.hook('components:extend', async (_components) => {
|
nuxt.hook('components:extend', async (_components) => {
|
||||||
components = _components
|
components = _components
|
||||||
.filter((v) => v.shortPath.includes('components/content/examples/'))
|
.filter(v => v.shortPath.includes('components/content/examples/'))
|
||||||
.reduce((acc, component) => {
|
.reduce((acc, component) => {
|
||||||
acc[component.pascalName] = component
|
acc[component.pascalName] = component
|
||||||
return acc
|
return acc
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ const { resolve } = createResolver(import.meta.url)
|
|||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
extends: process.env.NUXT_UI_PRO_PATH ? [
|
extends: process.env.NUXT_UI_PRO_PATH
|
||||||
|
? [
|
||||||
process.env.NUXT_UI_PRO_PATH,
|
process.env.NUXT_UI_PRO_PATH,
|
||||||
resolve(process.env.NUXT_UI_PRO_PATH, '.docs')
|
resolve(process.env.NUXT_UI_PRO_PATH, '.docs')
|
||||||
] : [
|
]
|
||||||
|
: [
|
||||||
'@nuxt/ui-pro',
|
'@nuxt/ui-pro',
|
||||||
process.env.NUXT_GITHUB_TOKEN && ['github:nuxt/ui-pro/.docs#dev', { giget: { auth: process.env.NUXT_GITHUB_TOKEN } }]
|
process.env.NUXT_GITHUB_TOKEN && ['github:nuxt/ui-pro/.docs#dev', { giget: { auth: process.env.NUXT_GITHUB_TOKEN } }]
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
@@ -25,19 +27,11 @@ export default defineNuxtConfig({
|
|||||||
'@nuxtjs/plausible',
|
'@nuxtjs/plausible',
|
||||||
'@vueuse/nuxt',
|
'@vueuse/nuxt',
|
||||||
'nuxt-component-meta',
|
'nuxt-component-meta',
|
||||||
'nuxt-cloudflare-analytics',
|
'nuxt-cloudflare-analytics'
|
||||||
'modules/content-examples-code'
|
|
||||||
],
|
],
|
||||||
|
|
||||||
runtimeConfig: {
|
site: {
|
||||||
public: {
|
url: 'https://ui.nuxt.com'
|
||||||
version: pkg.version
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
ui: {
|
|
||||||
global: true,
|
|
||||||
safelistColors: excludeColors(colors)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
content: {
|
content: {
|
||||||
@@ -48,31 +42,42 @@ export default defineNuxtConfig({
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
sources: {
|
sources: {
|
||||||
pro: process.env.NUXT_UI_PRO_PATH ? {
|
pro: process.env.NUXT_UI_PRO_PATH
|
||||||
|
? {
|
||||||
prefix: '/pro',
|
prefix: '/pro',
|
||||||
driver: 'fs',
|
driver: 'fs',
|
||||||
base: resolve(process.env.NUXT_UI_PRO_PATH, '.docs/content/pro')
|
base: resolve(process.env.NUXT_UI_PRO_PATH, '.docs/content/pro')
|
||||||
} : process.env.NUXT_GITHUB_TOKEN ? {
|
}
|
||||||
|
: process.env.NUXT_GITHUB_TOKEN
|
||||||
|
? {
|
||||||
prefix: '/pro',
|
prefix: '/pro',
|
||||||
driver: 'github',
|
driver: 'github',
|
||||||
repo: 'nuxt/ui-pro',
|
repo: 'nuxt/ui-pro',
|
||||||
branch: 'dev',
|
branch: 'dev',
|
||||||
dir: '.docs/content/pro',
|
dir: '.docs/content/pro',
|
||||||
token: process.env.NUXT_GITHUB_TOKEN || ''
|
token: process.env.NUXT_GITHUB_TOKEN || ''
|
||||||
} : undefined
|
}
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
image: {
|
ui: {
|
||||||
provider: 'ipx'
|
global: true,
|
||||||
|
safelistColors: excludeColors(colors)
|
||||||
},
|
},
|
||||||
|
|
||||||
icon: {
|
runtimeConfig: {
|
||||||
clientBundle: {
|
public: {
|
||||||
scan: true
|
version: pkg.version
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
routeRules: {
|
||||||
|
'/components': { redirect: '/components/accordion', prerender: false }
|
||||||
|
},
|
||||||
|
|
||||||
|
compatibilityDate: '2024-07-23',
|
||||||
|
|
||||||
nitro: {
|
nitro: {
|
||||||
prerender: {
|
prerender: {
|
||||||
routes: [
|
routes: [
|
||||||
@@ -86,8 +91,32 @@ export default defineNuxtConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
routeRules: {
|
vite: {
|
||||||
'/components': { redirect: '/components/accordion', prerender: false }
|
optimizeDeps: {
|
||||||
|
include: ['date-fns']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
typescript: {
|
||||||
|
strict: false
|
||||||
|
},
|
||||||
|
|
||||||
|
hooks: {
|
||||||
|
// Related to https://github.com/nuxt/nuxt/pull/22558
|
||||||
|
'components:extend': (components) => {
|
||||||
|
components.forEach((component) => {
|
||||||
|
if (component.shortPath.includes(process.env.NUXT_UI_PRO_PATH || '@nuxt/ui-pro')) {
|
||||||
|
component.global = true
|
||||||
|
} else if (component.global) {
|
||||||
|
component.global = 'sync'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
cloudflareAnalytics: {
|
||||||
|
token: '1e2b0c5e9a214f0390b9b94e043d8d4c',
|
||||||
|
scriptPath: false
|
||||||
},
|
},
|
||||||
|
|
||||||
componentMeta: {
|
componentMeta: {
|
||||||
@@ -111,37 +140,13 @@ export default defineNuxtConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
cloudflareAnalytics: {
|
icon: {
|
||||||
token: '1e2b0c5e9a214f0390b9b94e043d8d4c',
|
clientBundle: {
|
||||||
scriptPath: false
|
scan: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hooks: {
|
image: {
|
||||||
// Related to https://github.com/nuxt/nuxt/pull/22558
|
provider: 'ipx'
|
||||||
'components:extend': (components) => {
|
|
||||||
components.forEach((component) => {
|
|
||||||
if (component.shortPath.includes(process.env.NUXT_UI_PRO_PATH || '@nuxt/ui-pro')) {
|
|
||||||
component.global = true
|
|
||||||
} else if (component.global) {
|
|
||||||
component.global = 'sync'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
typescript: {
|
|
||||||
strict: false
|
|
||||||
},
|
|
||||||
|
|
||||||
site: {
|
|
||||||
url: 'https://ui.nuxt.com'
|
|
||||||
},
|
|
||||||
|
|
||||||
vite: {
|
|
||||||
optimizeDeps: {
|
|
||||||
include: ['date-fns']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
compatibilityDate: '2024-07-23'
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -3,30 +3,29 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iconify-json/heroicons": "^1.2.1",
|
"@iconify-json/heroicons": "^1.2.2",
|
||||||
"@iconify-json/simple-icons": "^1.2.7",
|
"@iconify-json/lucide": "^1.2.28",
|
||||||
"@iconify-json/vscode-icons": "^1.2.2",
|
"@iconify-json/simple-icons": "^1.2.27",
|
||||||
"@nuxt/content": "^2.13.2",
|
"@iconify-json/vscode-icons": "^1.2.16",
|
||||||
"@nuxt/eslint-config": "^0.4.0",
|
"@nuxt/content": "^2.13.4",
|
||||||
"@nuxt/fonts": "^0.10.0",
|
"@nuxt/fonts": "^0.10.3",
|
||||||
"@nuxt/image": "^1.8.1",
|
"@nuxt/image": "^1.9.0",
|
||||||
"@nuxt/ui": "latest",
|
"@nuxt/ui": "latest",
|
||||||
"@nuxt/ui-pro": "^1.4.3",
|
"@nuxt/ui-pro": "^1.7.0",
|
||||||
"@nuxtjs/plausible": "^1.0.3",
|
"@nuxtjs/plausible": "^1.2.0",
|
||||||
"@octokit/rest": "^21.0.2",
|
"@octokit/rest": "^21.1.1",
|
||||||
"@vueuse/nuxt": "^11.1.0",
|
"@vueuse/nuxt": "^12.8.2",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"eslint": "^8.57.0",
|
|
||||||
"joi": "^17.13.3",
|
"joi": "^17.13.3",
|
||||||
"nuxt": "^3.13.2",
|
"nuxt": "^3.16.0",
|
||||||
"nuxt-cloudflare-analytics": "^1.0.8",
|
"nuxt-cloudflare-analytics": "^1.0.8",
|
||||||
"nuxt-component-meta": "^0.8.2",
|
"nuxt-component-meta": "^0.10.0",
|
||||||
"nuxt-og-image": "^3.0.4",
|
"nuxt-og-image": "^4.2.0",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.5.3",
|
||||||
"ufo": "^1.5.4",
|
"ufo": "^1.5.4",
|
||||||
"v-calendar": "^3.1.2",
|
"v-calendar": "^3.1.2",
|
||||||
"valibot": "^0.42.1",
|
"valibot": "^0.42.1",
|
||||||
"yup": "^1.4.0",
|
"yup": "^1.6.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.24.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ const communityLinks = computed(() => [{
|
|||||||
const resourcesLinks = [{
|
const resourcesLinks = [{
|
||||||
icon: 'i-simple-icons-figma',
|
icon: 'i-simple-icons-figma',
|
||||||
label: 'Figma Kit',
|
label: 'Figma Kit',
|
||||||
to: 'https://www.figma.com/community/file/1288455405058138934',
|
to: 'https://www.figma.com/community/file/1436401057300493073',
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
}, {
|
}, {
|
||||||
label: 'Playground',
|
label: 'Playground',
|
||||||
|
|||||||
@@ -295,7 +295,7 @@
|
|||||||
wrapper: 'px-4 py-2.5 border-gray-800/10 dark:border-gray-200/10 cursor-pointer',
|
wrapper: 'px-4 py-2.5 border-gray-800/10 dark:border-gray-200/10 cursor-pointer',
|
||||||
icon: {
|
icon: {
|
||||||
wrapper: 'mb-2 p-1',
|
wrapper: 'mb-2 p-1',
|
||||||
base: 'h-4 w-4',
|
base: 'h-4 w-4'
|
||||||
},
|
},
|
||||||
title: 'text-sm',
|
title: 'text-sm',
|
||||||
description: 'text-xs'
|
description: 'text-xs'
|
||||||
@@ -423,6 +423,7 @@ const { data: module } = await useFetch<{
|
|||||||
username: string
|
username: string
|
||||||
}[]
|
}[]
|
||||||
}>('https://api.nuxt.com/modules/ui', {
|
}>('https://api.nuxt.com/modules/ui', {
|
||||||
|
key: 'stats',
|
||||||
transform: ({ stats, contributors }) => ({ stats, contributors })
|
transform: ({ stats, contributors }) => ({ stats, contributors })
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -466,7 +467,8 @@ const steps = {
|
|||||||
|
|
||||||
const inc = computed(() => (height.value - 32 - 64 - 32 - 32) / 4)
|
const inc = computed(() => (height.value - 32 - 64 - 32 - 32) / 4)
|
||||||
|
|
||||||
const landingBlocks = computed(() => isAfterStep(steps.landing) && isBeforeStep(steps.docs) ? [{
|
const landingBlocks = computed(() => isAfterStep(steps.landing) && isBeforeStep(steps.docs)
|
||||||
|
? [{
|
||||||
class: 'inset-x-0 top-20 bottom-20 overflow-hidden',
|
class: 'inset-x-0 top-20 bottom-20 overflow-hidden',
|
||||||
inactive: true,
|
inactive: true,
|
||||||
children: [{
|
children: [{
|
||||||
@@ -506,34 +508,42 @@ const landingBlocks = computed(() => isAfterStep(steps.landing) && isBeforeStep(
|
|||||||
to: '/pro/components/landing-grid',
|
to: '/pro/components/landing-grid',
|
||||||
class: ['inset-x-4 bottom-4 top-48', isAfterStep(steps.landing + 8) && 'grid grid-cols-4 gap-4 p-4'].filter(Boolean).join(' '),
|
class: ['inset-x-4 bottom-4 top-48', isAfterStep(steps.landing + 8) && 'grid grid-cols-4 gap-4 p-4'].filter(Boolean).join(' '),
|
||||||
inactive: isAfterStep(steps.landing + 8),
|
inactive: isAfterStep(steps.landing + 8),
|
||||||
children: [isAfterStep(steps.landing + 9) ? {
|
children: [isAfterStep(steps.landing + 9)
|
||||||
|
? {
|
||||||
slot: 'landing-card-1',
|
slot: 'landing-card-1',
|
||||||
class: '!relative'
|
class: '!relative'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: 'ULandingCard',
|
name: 'ULandingCard',
|
||||||
to: '/pro/components/landing-card',
|
to: '/pro/components/landing-card',
|
||||||
class: '!relative h-full',
|
class: '!relative h-full',
|
||||||
inactive: false
|
inactive: false
|
||||||
}, isAfterStep(steps.landing + 9) ? {
|
}, isAfterStep(steps.landing + 9)
|
||||||
|
? {
|
||||||
slot: 'landing-card-2',
|
slot: 'landing-card-2',
|
||||||
class: '!relative h-full'
|
class: '!relative h-full'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: 'ULandingCard',
|
name: 'ULandingCard',
|
||||||
to: '/pro/components/landing-card',
|
to: '/pro/components/landing-card',
|
||||||
class: '!relative h-full',
|
class: '!relative h-full',
|
||||||
inactive: false
|
inactive: false
|
||||||
}, isAfterStep(steps.landing + 9) ? {
|
}, isAfterStep(steps.landing + 9)
|
||||||
|
? {
|
||||||
slot: 'landing-card-3',
|
slot: 'landing-card-3',
|
||||||
class: '!relative h-full'
|
class: '!relative h-full'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: 'ULandingCard',
|
name: 'ULandingCard',
|
||||||
to: '/pro/components/landing-card',
|
to: '/pro/components/landing-card',
|
||||||
class: '!relative h-full',
|
class: '!relative h-full',
|
||||||
inactive: false
|
inactive: false
|
||||||
}, isAfterStep(steps.landing + 9) ? {
|
}, isAfterStep(steps.landing + 9)
|
||||||
|
? {
|
||||||
slot: 'landing-card-4',
|
slot: 'landing-card-4',
|
||||||
class: '!relative h-full'
|
class: '!relative h-full'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: 'ULandingCard',
|
name: 'ULandingCard',
|
||||||
to: '/pro/components/landing-card',
|
to: '/pro/components/landing-card',
|
||||||
class: '!relative h-full',
|
class: '!relative h-full',
|
||||||
@@ -563,25 +573,30 @@ const landingBlocks = computed(() => isAfterStep(steps.landing) && isBeforeStep(
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}].filter(Boolean)
|
}].filter(Boolean)
|
||||||
}] : [])
|
}]
|
||||||
|
: [])
|
||||||
|
|
||||||
const docsBlocks = computed(() => [isAfterStep(steps.docs) && {
|
const docsBlocks = computed(() => [isAfterStep(steps.docs) && {
|
||||||
name: 'UPage',
|
name: 'UPage',
|
||||||
to: '/pro/components/page',
|
to: '/pro/components/page',
|
||||||
class: 'inset-x-0 top-20 bottom-20',
|
class: 'inset-x-0 top-20 bottom-20',
|
||||||
inactive: isAfterStep(steps.docs + 1),
|
inactive: isAfterStep(steps.docs + 1),
|
||||||
children: [isAfterStep(steps.docs + 2) ? {
|
children: [isAfterStep(steps.docs + 2)
|
||||||
|
? {
|
||||||
name: 'UAside',
|
name: 'UAside',
|
||||||
to: '/pro/components/aside',
|
to: '/pro/components/aside',
|
||||||
class: 'left-4 inset-y-4 w-64',
|
class: 'left-4 inset-y-4 w-64',
|
||||||
inactive: isAfterStep(steps.docs + 3),
|
inactive: isAfterStep(steps.docs + 3),
|
||||||
children: [isAfterStep(steps.docs + 4) ? {
|
children: [isAfterStep(steps.docs + 4)
|
||||||
|
? {
|
||||||
slot: 'aside-top',
|
slot: 'aside-top',
|
||||||
class: 'inset-x-4 top-4'
|
class: 'inset-x-4 top-4'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#top',
|
name: '#top',
|
||||||
class: 'inset-x-4 top-4 h-9'
|
class: 'inset-x-4 top-4 h-9'
|
||||||
}, isAfterStep(steps.docs + 5) ? {
|
}, isAfterStep(steps.docs + 5)
|
||||||
|
? {
|
||||||
name: 'UNavigationTree',
|
name: 'UNavigationTree',
|
||||||
to: '/pro/components/navigation-tree',
|
to: '/pro/components/navigation-tree',
|
||||||
class: ['inset-x-4 top-[4.25rem] bottom-4', isAfterStep(steps.docs + 6) && '!bg-transparent !border-0'].join(' '),
|
class: ['inset-x-4 top-[4.25rem] bottom-4', isAfterStep(steps.docs + 6) && '!bg-transparent !border-0'].join(' '),
|
||||||
@@ -590,19 +605,23 @@ const docsBlocks = computed(() => [isAfterStep(steps.docs) && {
|
|||||||
slot: 'aside-default',
|
slot: 'aside-default',
|
||||||
class: 'inset-0'
|
class: 'inset-0'
|
||||||
}]
|
}]
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#default',
|
name: '#default',
|
||||||
class: 'inset-x-4 top-[4.25rem] bottom-4'
|
class: 'inset-x-4 top-[4.25rem] bottom-4'
|
||||||
}]
|
}]
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#left',
|
name: '#left',
|
||||||
class: 'left-4 inset-y-4 w-64'
|
class: 'left-4 inset-y-4 w-64'
|
||||||
}, isAfterStep(steps.docs + 7) ? {
|
}, isAfterStep(steps.docs + 7)
|
||||||
|
? {
|
||||||
name: 'UPage',
|
name: 'UPage',
|
||||||
to: '/pro/components/page',
|
to: '/pro/components/page',
|
||||||
class: 'left-72 right-4 inset-y-4',
|
class: 'left-72 right-4 inset-y-4',
|
||||||
inactive: isAfterStep(steps.docs + 8),
|
inactive: isAfterStep(steps.docs + 8),
|
||||||
children: [...(isAfterStep(steps.docs + 9) ? [{
|
children: [...(isAfterStep(steps.docs + 9)
|
||||||
|
? [{
|
||||||
name: 'UPageHeader',
|
name: 'UPageHeader',
|
||||||
to: '/pro/components/page-header',
|
to: '/pro/components/page-header',
|
||||||
class: 'top-4 left-4 right-72 h-32',
|
class: 'top-4 left-4 right-72 h-32',
|
||||||
@@ -619,19 +638,23 @@ const docsBlocks = computed(() => [isAfterStep(steps.docs) && {
|
|||||||
children: [{
|
children: [{
|
||||||
slot: 'page-body',
|
slot: 'page-body',
|
||||||
class: 'inset-x-4 top-4 justify-start'
|
class: 'inset-x-4 top-4 justify-start'
|
||||||
}, isAfterStep(steps.docs + 12) ? {
|
}, isAfterStep(steps.docs + 12)
|
||||||
|
? {
|
||||||
slot: 'content-surround',
|
slot: 'content-surround',
|
||||||
class: 'bottom-4 inset-x-4 h-28'
|
class: 'bottom-4 inset-x-4 h-28'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: 'UContentSurround',
|
name: 'UContentSurround',
|
||||||
to: '/pro/components/content-surround',
|
to: '/pro/components/content-surround',
|
||||||
class: 'bottom-4 inset-x-4 h-28',
|
class: 'bottom-4 inset-x-4 h-28',
|
||||||
inactive: false
|
inactive: false
|
||||||
}]
|
}]
|
||||||
}] : [{
|
}]
|
||||||
|
: [{
|
||||||
name: '#default',
|
name: '#default',
|
||||||
class: 'left-4 right-72 inset-y-4'
|
class: 'left-4 right-72 inset-y-4'
|
||||||
}]), isAfterStep(steps.docs + 13) ? {
|
}]), isAfterStep(steps.docs + 13)
|
||||||
|
? {
|
||||||
name: 'UContentToc',
|
name: 'UContentToc',
|
||||||
to: '/pro/components/content-toc',
|
to: '/pro/components/content-toc',
|
||||||
class: 'right-4 inset-y-4 w-64',
|
class: 'right-4 inset-y-4 w-64',
|
||||||
@@ -640,11 +663,13 @@ const docsBlocks = computed(() => [isAfterStep(steps.docs) && {
|
|||||||
slot: 'content-toc',
|
slot: 'content-toc',
|
||||||
class: 'inset-4 overflow-y-auto'
|
class: 'inset-4 overflow-y-auto'
|
||||||
}]
|
}]
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#right',
|
name: '#right',
|
||||||
class: 'right-4 inset-y-4 w-64'
|
class: 'right-4 inset-y-4 w-64'
|
||||||
}]
|
}]
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#default',
|
name: '#default',
|
||||||
class: 'left-72 right-4 inset-y-4'
|
class: 'left-72 right-4 inset-y-4'
|
||||||
}]
|
}]
|
||||||
@@ -655,22 +680,28 @@ const blocks = computed(() => [isAfterStep(steps.header) && {
|
|||||||
to: '/pro/components/header',
|
to: '/pro/components/header',
|
||||||
class: 'h-16 inset-x-0 top-0',
|
class: 'h-16 inset-x-0 top-0',
|
||||||
inactive: isAfterStep(steps.header + 1),
|
inactive: isAfterStep(steps.header + 1),
|
||||||
children: [isAfterStep(steps.header + 2) ? {
|
children: [isAfterStep(steps.header + 2)
|
||||||
|
? {
|
||||||
slot: 'header-left',
|
slot: 'header-left',
|
||||||
class: 'left-4 top-4'
|
class: 'left-4 top-4'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#left',
|
name: '#left',
|
||||||
class: 'left-4 inset-y-4 w-64'
|
class: 'left-4 inset-y-4 w-64'
|
||||||
}, isAfterStep(steps.header + 3) ? {
|
}, isAfterStep(steps.header + 3)
|
||||||
|
? {
|
||||||
slot: 'header-center',
|
slot: 'header-center',
|
||||||
class: 'inset-x-72 top-5'
|
class: 'inset-x-72 top-5'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#center',
|
name: '#center',
|
||||||
class: 'inset-x-72 inset-y-4'
|
class: 'inset-x-72 inset-y-4'
|
||||||
}, isAfterStep(steps.header + 4) ? {
|
}, isAfterStep(steps.header + 4)
|
||||||
|
? {
|
||||||
slot: 'header-right',
|
slot: 'header-right',
|
||||||
class: 'right-4 top-4'
|
class: 'right-4 top-4'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#right',
|
name: '#right',
|
||||||
class: 'right-4 inset-y-4 w-64'
|
class: 'right-4 inset-y-4 w-64'
|
||||||
}]
|
}]
|
||||||
@@ -679,22 +710,28 @@ const blocks = computed(() => [isAfterStep(steps.header) && {
|
|||||||
to: '/pro/components/footer',
|
to: '/pro/components/footer',
|
||||||
class: 'h-16 inset-x-0 bottom-0',
|
class: 'h-16 inset-x-0 bottom-0',
|
||||||
inactive: isAfterStep(steps.footer + 1),
|
inactive: isAfterStep(steps.footer + 1),
|
||||||
children: [isAfterStep(steps.footer + 2) ? {
|
children: [isAfterStep(steps.footer + 2)
|
||||||
|
? {
|
||||||
slot: 'footer-left',
|
slot: 'footer-left',
|
||||||
class: 'left-4 bottom-5'
|
class: 'left-4 bottom-5'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#left',
|
name: '#left',
|
||||||
class: 'left-4 inset-y-4 w-64'
|
class: 'left-4 inset-y-4 w-64'
|
||||||
}, isAfterStep(steps.footer + 3) ? {
|
}, isAfterStep(steps.footer + 3)
|
||||||
|
? {
|
||||||
slot: 'footer-center',
|
slot: 'footer-center',
|
||||||
class: 'inset-x-72 bottom-5'
|
class: 'inset-x-72 bottom-5'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#center',
|
name: '#center',
|
||||||
class: 'inset-x-72 inset-y-4'
|
class: 'inset-x-72 inset-y-4'
|
||||||
}, isAfterStep(steps.footer + 4) ? {
|
}, isAfterStep(steps.footer + 4)
|
||||||
|
? {
|
||||||
slot: 'footer-right',
|
slot: 'footer-right',
|
||||||
class: 'right-4 bottom-4'
|
class: 'right-4 bottom-4'
|
||||||
} : {
|
}
|
||||||
|
: {
|
||||||
name: '#right',
|
name: '#right',
|
||||||
class: 'right-4 inset-y-4 w-64'
|
class: 'right-4 inset-y-4 w-64'
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ if (!page.value) {
|
|||||||
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
|
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: releases } = await useFetch('/api/releases.json')
|
const { data: releases } = await useFetch('/api/releases.json', { key: 'releases-list' })
|
||||||
const { data: pulls } = await useLazyFetch('/api/pulls.json', { default: () => [] })
|
const { data: pulls } = await useLazyFetch('/api/pulls.json', { default: () => [], key: 'pulls-list' })
|
||||||
|
|
||||||
const dates = computed(() => {
|
const dates = computed(() => {
|
||||||
const first = releases.value[releases.value.length - 1]
|
const first = releases.value[releases.value.length - 1]
|
||||||
@@ -50,7 +50,7 @@ const dates = computed(() => {
|
|||||||
|
|
||||||
const days = eachDayOfInterval({ start: new Date(first.published_at), end: new Date() })
|
const days = eachDayOfInterval({ start: new Date(first.published_at), end: new Date() })
|
||||||
|
|
||||||
return days.reverse().map(day => {
|
return days.reverse().map((day) => {
|
||||||
return {
|
return {
|
||||||
day,
|
day,
|
||||||
release: releases.value.find(release => isSameDay(new Date(release.published_at), day)),
|
release: releases.value.find(release => isSameDay(new Date(release.published_at), day)),
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import type { Options } from 'prettier'
|
import type { Options } from 'prettier'
|
||||||
|
import { defu } from 'defu'
|
||||||
import PrettierWorker from '@/workers/prettier.js?worker&inline'
|
import PrettierWorker from '@/workers/prettier.js?worker&inline'
|
||||||
|
|
||||||
export interface SimplePrettier {
|
export interface SimplePrettier {
|
||||||
format: (source: string, options?: Options) => Promise<string>;
|
format: (source: string, options?: Options) => Promise<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPrettierWorkerApi(worker: Worker): SimplePrettier {
|
function createPrettierWorkerApi(worker: Worker): SimplePrettier {
|
||||||
let counter = 0
|
let counter = 0
|
||||||
const handlers = {}
|
const handlers: any = {}
|
||||||
|
|
||||||
worker.addEventListener('message', (event) => {
|
worker.addEventListener('message', (event) => {
|
||||||
const { uid, message, error } = event.data
|
const { uid, message, error } = event.data
|
||||||
@@ -17,6 +18,7 @@ function createPrettierWorkerApi (worker: Worker): SimplePrettier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [resolve, reject] = handlers[uid]
|
const [resolve, reject] = handlers[uid]
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||||
delete handlers[uid]
|
delete handlers[uid]
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -26,7 +28,7 @@ function createPrettierWorkerApi (worker: Worker): SimplePrettier {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function postMessage<T> (message) {
|
function postMessage<T>(message: any) {
|
||||||
const uid = ++counter
|
const uid = ++counter
|
||||||
return new Promise<T>((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
handlers[uid] = [resolve, reject]
|
handlers[uid] = [resolve, reject]
|
||||||
@@ -41,16 +43,15 @@ function createPrettierWorkerApi (worker: Worker): SimplePrettier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineNuxtPlugin({
|
export default defineNuxtPlugin(async () => {
|
||||||
async setup () {
|
|
||||||
let prettier: SimplePrettier
|
let prettier: SimplePrettier
|
||||||
if (import.meta.server) {
|
if (import.meta.server) {
|
||||||
const prettierModule = await import('prettier')
|
const prettierModule = await import('prettier')
|
||||||
prettier = {
|
prettier = {
|
||||||
format (source, options = {
|
format(source, options = {}) {
|
||||||
|
return prettierModule.format(source, defu(options, {
|
||||||
parser: 'markdown'
|
parser: 'markdown'
|
||||||
}) {
|
}))
|
||||||
return prettierModule.format(source, options)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -63,5 +64,4 @@ export default defineNuxtPlugin({
|
|||||||
prettier
|
prettier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
import('https://unpkg.com/prettier@3.0.3/standalone.js')
|
|
||||||
import('https://unpkg.com/prettier@3.0.3/plugins/html.js')
|
|
||||||
import('https://unpkg.com/prettier@3.0.3/plugins/markdown.js')
|
|
||||||
|
|
||||||
self.onmessage = async function (event) {
|
self.onmessage = async function (event) {
|
||||||
self.postMessage({
|
self.postMessage({
|
||||||
uid: event.data.uid,
|
uid: event.data.uid,
|
||||||
@@ -18,6 +14,14 @@ function handleMessage (message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleFormatMessage(message) {
|
async function handleFormatMessage(message) {
|
||||||
|
if (!globalThis.prettier) {
|
||||||
|
await Promise.all([
|
||||||
|
import('https://unpkg.com/prettier@3.3.3/standalone.js'),
|
||||||
|
import('https://unpkg.com/prettier@3.3.3/plugins/html.js'),
|
||||||
|
import('https://unpkg.com/prettier@3.3.3/plugins/markdown.js')
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
const { options, source } = message
|
const { options, source } = message
|
||||||
const formatted = await prettier.format(source, {
|
const formatted = await prettier.format(source, {
|
||||||
parser: 'markdown',
|
parser: 'markdown',
|
||||||
|
|||||||
19
eslint.config.mjs
Normal file
19
eslint.config.mjs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
|
||||||
|
|
||||||
|
export default createConfigForNuxt({
|
||||||
|
features: {
|
||||||
|
tooling: true,
|
||||||
|
stylistic: {
|
||||||
|
commaDangle: 'never',
|
||||||
|
braceStyle: '1tbs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).overrideRules({
|
||||||
|
'vue/multi-word-component-names': 'off',
|
||||||
|
'vue/max-attributes-per-line': ['error', { singleline: 5 }],
|
||||||
|
'@typescript-eslint/ban-types': 'off',
|
||||||
|
'@typescript-eslint/ban-ts-comment': 'off',
|
||||||
|
'@typescript-eslint/no-unsafe-function-type': 'off',
|
||||||
|
'@typescript-eslint/no-empty-object-type': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off'
|
||||||
|
})
|
||||||
68
package.json
68
package.json
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@nuxt/ui",
|
"name": "@nuxt/ui",
|
||||||
"description": "A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.",
|
"description": "A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.",
|
||||||
"version": "2.18.7",
|
"version": "2.21.1",
|
||||||
"packageManager": "pnpm@9.12.1",
|
"packageManager": "pnpm@10.6.1",
|
||||||
"repository": "nuxt/ui",
|
"repository": "nuxt/ui",
|
||||||
"homepage": "https://ui.nuxt.com",
|
"homepage": "https://ui.nuxt.com",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -32,52 +32,58 @@
|
|||||||
"test": "vitest"
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@headlessui/tailwindcss": "^0.2.1",
|
"@headlessui/tailwindcss": "^0.2.2",
|
||||||
"@headlessui/vue": "^1.7.23",
|
"@headlessui/vue": "^1.7.23",
|
||||||
"@iconify-json/heroicons": "^1.2.1",
|
"@iconify-json/heroicons": "^1.2.2",
|
||||||
"@nuxt/icon": "^1.5.5",
|
"@nuxt/icon": "^1.10.3",
|
||||||
"@nuxt/kit": "^3.13.2",
|
"@nuxt/kit": "^3.16.0",
|
||||||
"@nuxtjs/color-mode": "^3.5.1",
|
"@nuxtjs/color-mode": "^3.5.2",
|
||||||
"@nuxtjs/tailwindcss": "^6.12.1",
|
"@nuxtjs/tailwindcss": "^6.13.1",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@tailwindcss/aspect-ratio": "^0.4.2",
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tailwindcss/forms": "^0.5.9",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
"@vueuse/core": "^11.1.0",
|
"@vueuse/core": "^12.8.2",
|
||||||
"@vueuse/integrations": "^11.1.0",
|
"@vueuse/integrations": "^12.8.2",
|
||||||
"@vueuse/math": "^11.1.0",
|
"@vueuse/math": "^12.8.2",
|
||||||
"defu": "^6.1.4",
|
"defu": "^6.1.4",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.1.0",
|
||||||
"ohash": "^1.1.4",
|
"ohash": "^2.0.11",
|
||||||
"pathe": "^1.1.2",
|
"pathe": "^2.0.3",
|
||||||
"scule": "^1.3.0",
|
"scule": "^1.3.0",
|
||||||
"tailwind-merge": "^2.5.3",
|
"tailwind-merge": "^2.6.0",
|
||||||
"tailwindcss": "^3.4.13"
|
"tailwindcss": "^3.4.17"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/eslint-config": "^0.4.0",
|
"@nuxt/eslint-config": "^1.1.0",
|
||||||
"@nuxt/module-builder": "^0.8.4",
|
"@nuxt/module-builder": "^0.8.4",
|
||||||
"@nuxt/test-utils": "^3.14.3",
|
"@standard-schema/spec": "^1.0.0",
|
||||||
"@release-it/conventional-changelog": "^8.0.2",
|
"@nuxt/test-utils": "^3.17.1",
|
||||||
|
"@release-it/conventional-changelog": "^10.0.0",
|
||||||
"@vue/test-utils": "^2.4.6",
|
"@vue/test-utils": "^2.4.6",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^9.22.0",
|
||||||
"happy-dom": "^14.12.3",
|
"happy-dom": "^17.1.8",
|
||||||
"joi": "^17.13.3",
|
"joi": "^17.13.3",
|
||||||
"nuxt": "^3.13.2",
|
"nuxt": "^3.16.0",
|
||||||
"release-it": "^17.7.0",
|
"release-it": "^18.1.2",
|
||||||
"unbuild": "^2.0.0",
|
"superstruct": "^2.0.2",
|
||||||
|
"typescript": "^5.6.3",
|
||||||
"valibot": "^0.42.1",
|
"valibot": "^0.42.1",
|
||||||
"valibot30": "npm:valibot@0.30.0",
|
"valibot30": "npm:valibot@0.30.0",
|
||||||
"valibot31": "npm:valibot@0.31.0",
|
"valibot31": "npm:valibot@0.31.0",
|
||||||
"vitest": "^2.1.2",
|
"vitest": "^3.0.8",
|
||||||
"vitest-environment-nuxt": "^1.0.1",
|
"vitest-environment-nuxt": "^1.0.1",
|
||||||
"vue-tsc": "^2.1.6",
|
"vue-tsc": "^2.1.10",
|
||||||
"yup": "^1.4.0",
|
"yup": "^1.6.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.24.2"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@nuxt/ui": "workspace:*",
|
"@nuxt/ui": "workspace:*",
|
||||||
"@nuxtjs/mdc": "0.9.0"
|
"@nuxt/content": "2.13.2",
|
||||||
|
"@nuxtjs/mdc": "0.9.0",
|
||||||
|
"chokidar": "3.6.0",
|
||||||
|
"vue-tsc": "2.1.10",
|
||||||
|
"typescript": "5.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/ui": "latest",
|
"@nuxt/ui": "latest",
|
||||||
"nuxt": "^3.13.2"
|
"nuxt": "^3.16.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10508
pnpm-lock.yaml
generated
10508
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,6 @@
|
|||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"ignoreDeps": [
|
"ignoreDeps": [
|
||||||
"@nuxt/eslint-config",
|
|
||||||
"eslint",
|
|
||||||
"happy-dom",
|
|
||||||
"valibot30",
|
"valibot30",
|
||||||
"valibot31"
|
"valibot31"
|
||||||
],
|
],
|
||||||
@@ -23,5 +20,9 @@
|
|||||||
"@tailwindcss/postcss",
|
"@tailwindcss/postcss",
|
||||||
"@tailwindcss/vite"
|
"@tailwindcss/vite"
|
||||||
]
|
]
|
||||||
}]
|
}, {
|
||||||
|
"matchDepTypes": ["resolutions"],
|
||||||
|
"enabled": false
|
||||||
|
}],
|
||||||
|
"postUpdateOptions": ["pnpmDedupe"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
import { promises as fsp } from 'fs'
|
|
||||||
import { resolve } from 'path'
|
|
||||||
import { execSync } from 'child_process'
|
|
||||||
|
|
||||||
async function loadPackage (dir: string) {
|
|
||||||
const pkgPath = resolve(dir, 'package.json')
|
|
||||||
|
|
||||||
const data = JSON.parse(await fsp.readFile(pkgPath, 'utf-8').catch(() => '{}'))
|
|
||||||
|
|
||||||
const save = () => fsp.writeFile(pkgPath, JSON.stringify(data, null, 2) + '\n')
|
|
||||||
|
|
||||||
return {
|
|
||||||
dir,
|
|
||||||
data,
|
|
||||||
save
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main () {
|
|
||||||
const pkg = await loadPackage(process.cwd())
|
|
||||||
|
|
||||||
const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim()
|
|
||||||
|
|
||||||
const date = Math.round(Date.now() / (1000 * 60))
|
|
||||||
|
|
||||||
pkg.data.name = `${pkg.data.name}-edge`
|
|
||||||
|
|
||||||
pkg.data.version = `${pkg.data.version}-${date}.${commit}`
|
|
||||||
|
|
||||||
pkg.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch((err) => {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error(err)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Restore all git changes
|
|
||||||
git restore -s@ -SW -- .
|
|
||||||
|
|
||||||
# Bump versions to edge
|
|
||||||
pnpm jiti ./scripts/bump-edge
|
|
||||||
|
|
||||||
# Update token
|
|
||||||
if [[ ! -z ${NODE_AUTH_TOKEN} ]] ; then
|
|
||||||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
|
|
||||||
echo "registry=https://registry.npmjs.org/" >> ~/.npmrc
|
|
||||||
echo "always-auth=true" >> ~/.npmrc
|
|
||||||
npm whoami
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Release package
|
|
||||||
echo "Publishing @nuxt/ui"
|
|
||||||
npm publish -q --access public
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { createRequire } from 'node:module'
|
import { createRequire } from 'node:module'
|
||||||
import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, createResolver, addPlugin } from '@nuxt/kit'
|
import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, createResolver, addPlugin } from '@nuxt/kit'
|
||||||
|
import type { ConfigExtension, DefaultClassGroupIds, DefaultThemeGroupIds } from 'tailwind-merge'
|
||||||
import { name, version } from '../package.json'
|
import { name, version } from '../package.json'
|
||||||
import createTemplates from './templates'
|
import createTemplates from './templates'
|
||||||
import * as config from './runtime/ui.config'
|
import type * as config from './runtime/ui.config'
|
||||||
import type { DeepPartial, Strategy } from './runtime/types'
|
import type { DeepPartial, Strategy } from './runtime/types'
|
||||||
import installTailwind from './tailwind'
|
import installTailwind from './tailwind'
|
||||||
|
|
||||||
@@ -20,8 +21,9 @@ type UI = {
|
|||||||
gray?: string
|
gray?: string
|
||||||
colors?: string[]
|
colors?: string[]
|
||||||
strategy?: Strategy
|
strategy?: Strategy
|
||||||
|
tailwindMerge?: ConfigExtension<DefaultClassGroupIds, DefaultThemeGroupIds>
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
} & DeepPartial<typeof config, string>
|
} & DeepPartial<typeof config, string | number | boolean>
|
||||||
|
|
||||||
declare module '@nuxt/schema' {
|
declare module '@nuxt/schema' {
|
||||||
interface AppConfigInput {
|
interface AppConfigInput {
|
||||||
@@ -41,6 +43,11 @@ export interface ModuleOptions {
|
|||||||
*/
|
*/
|
||||||
global?: boolean
|
global?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
colorMode?: boolean
|
||||||
|
|
||||||
safelistColors?: string[]
|
safelistColors?: string[]
|
||||||
/**
|
/**
|
||||||
* Disables the global css styles added by the module.
|
* Disables the global css styles added by the module.
|
||||||
@@ -59,6 +66,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
},
|
},
|
||||||
defaults: {
|
defaults: {
|
||||||
prefix: 'U',
|
prefix: 'U',
|
||||||
|
colorMode: true,
|
||||||
safelistColors: ['primary'],
|
safelistColors: ['primary'],
|
||||||
disableGlobalStyles: false
|
disableGlobalStyles: false
|
||||||
},
|
},
|
||||||
@@ -81,7 +89,9 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
// Modules
|
// Modules
|
||||||
|
|
||||||
await installModule('@nuxt/icon')
|
await installModule('@nuxt/icon')
|
||||||
|
if (options.colorMode) {
|
||||||
await installModule('@nuxtjs/color-mode', { classSuffix: '' })
|
await installModule('@nuxtjs/color-mode', { classSuffix: '' })
|
||||||
|
}
|
||||||
await installTailwind(options, nuxt, resolve)
|
await installTailwind(options, nuxt, resolve)
|
||||||
|
|
||||||
// Plugins
|
// Plugins
|
||||||
|
|||||||
@@ -8,22 +8,27 @@
|
|||||||
</slot>
|
</slot>
|
||||||
<thead :class="ui.thead">
|
<thead :class="ui.thead">
|
||||||
<tr :class="ui.tr.base">
|
<tr :class="ui.tr.base">
|
||||||
<th v-if="modelValue" scope="col" :class="ui.checkbox.padding">
|
<th v-if="expand" scope="col" :class="ui.tr.base">
|
||||||
<UCheckbox :model-value="indeterminate || selected.length === rows.length" :indeterminate="indeterminate" v-bind="ui.default.checkbox" aria-label="Select all" @change="onChange" />
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th v-if="$slots.expand" scope="col" :class="ui.tr.base">
|
|
||||||
<span class="sr-only">Expand</span>
|
<span class="sr-only">Expand</span>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<th
|
<th
|
||||||
v-for="(column, index) in columns"
|
v-for="(column, index) in columns"
|
||||||
:key="index"
|
:key="index"
|
||||||
scope="col"
|
scope="col"
|
||||||
:class="[ui.th.base, ui.th.padding, ui.th.color, ui.th.font, ui.th.size, column.class]"
|
:class="[ui.th.base, ui.th.padding, ui.th.color, ui.th.font, ui.th.size, column.key === 'select' && ui.checkbox.padding, column.class]"
|
||||||
:aria-sort="getAriaSort(column)"
|
:aria-sort="getAriaSort(column)"
|
||||||
>
|
>
|
||||||
<slot :name="`${column.key}-header`" :column="column" :sort="sort" :on-sort="onSort">
|
<slot v-if="!singleSelect && modelValue && column.key === 'select'" name="select-header" :indeterminate="indeterminate" :checked="isAllRowChecked" :change="onChange">
|
||||||
|
<UCheckbox
|
||||||
|
:model-value="isAllRowChecked"
|
||||||
|
:indeterminate="indeterminate"
|
||||||
|
v-bind="ui.default.checkbox"
|
||||||
|
aria-label="Select all"
|
||||||
|
@change="onChange"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
|
||||||
|
<slot v-else :name="`${column.key}-header`" :column="column" :sort="sort" :on-sort="onSort">
|
||||||
<UButton
|
<UButton
|
||||||
v-if="column.sortable"
|
v-if="column.sortable"
|
||||||
v-bind="{ ...(ui.default.sortButton || {}), ...sortButton }"
|
v-bind="{ ...(ui.default.sortButton || {}), ...sortButton }"
|
||||||
@@ -44,7 +49,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody :class="ui.tbody">
|
<tbody :class="ui.tbody">
|
||||||
<tr v-if="loadingState && loading && !rows.length">
|
<tr v-if="loadingState && loading && !rows.length">
|
||||||
<td :colspan="columns.length + (modelValue ? 1 : 0) + ($slots.expand ? 1 : 0)">
|
<td :colspan="columns.length + (modelValue ? 1 : 0) + (expand ? 1 : 0)">
|
||||||
<slot name="loading-state">
|
<slot name="loading-state">
|
||||||
<div :class="ui.loadingState.wrapper">
|
<div :class="ui.loadingState.wrapper">
|
||||||
<UIcon v-if="loadingState.icon" :name="loadingState.icon" :class="ui.loadingState.icon" aria-hidden="true" />
|
<UIcon v-if="loadingState.icon" :name="loadingState.icon" :class="ui.loadingState.icon" aria-hidden="true" />
|
||||||
@@ -57,7 +62,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr v-else-if="emptyState && !rows.length">
|
<tr v-else-if="emptyState && !rows.length">
|
||||||
<td :colspan="columns.length + (modelValue ? 1 : 0) + ($slots.expand ? 1 : 0)">
|
<td :colspan="columns.length + (modelValue ? 1 : 0) + (expand ? 1 : 0)">
|
||||||
<slot name="empty-state">
|
<slot name="empty-state">
|
||||||
<div :class="ui.emptyState.wrapper">
|
<div :class="ui.emptyState.wrapper">
|
||||||
<UIcon v-if="emptyState.icon" :name="emptyState.icon" :class="ui.emptyState.icon" aria-hidden="true" />
|
<UIcon v-if="emptyState.icon" :name="emptyState.icon" :class="ui.emptyState.icon" aria-hidden="true" />
|
||||||
@@ -71,29 +76,45 @@
|
|||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<template v-for="(row, index) in rows" :key="index">
|
<template v-for="(row, index) in rows" :key="index">
|
||||||
<tr :class="[ui.tr.base, isSelected(row) && ui.tr.selected, $attrs.onSelect && ui.tr.active, row?.class]" @click="() => onSelect(row)">
|
<tr :class="[ui.tr.base, isSelected(row) && ui.tr.selected, isExpanded(row) && ui.tr.expanded, $attrs.onSelect && ui.tr.active, row?.class]" @click="() => onSelect(row)" @contextmenu="(event) => onContextmenu(event, row)">
|
||||||
<td v-if="modelValue" :class="ui.checkbox.padding">
|
|
||||||
<UCheckbox v-model="selected" :value="row" v-bind="ui.default.checkbox" aria-label="Select row" @click.capture.stop="() => onSelect(row)" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td
|
<td
|
||||||
v-if="$slots.expand"
|
v-if="expand"
|
||||||
:class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size]"
|
:class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size]"
|
||||||
>
|
>
|
||||||
|
<template v-if="$slots['expand-action']">
|
||||||
|
<slot name="expand-action" :row="row" :is-expanded="isExpanded(row)" :toggle="() => toggleOpened(row)" />
|
||||||
|
</template>
|
||||||
<UButton
|
<UButton
|
||||||
|
v-else
|
||||||
|
:disabled="row.disabledExpand"
|
||||||
v-bind="{ ...(ui.default.expandButton || {}), ...expandButton }"
|
v-bind="{ ...(ui.default.expandButton || {}), ...expandButton }"
|
||||||
:ui="{ icon: { base: [ui.expand.icon, openedRows.includes(index) && 'rotate-180'].join(' ') } }"
|
:ui="{ icon: { base: [ui.expand.icon, isExpanded(row) && 'rotate-180'].join(' ') } }"
|
||||||
@click="toggleOpened(index)"
|
@click.capture.stop="toggleOpened(row)"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size, column?.rowClass, row[column.key]?.class, column.key === 'select' && ui.checkbox.padding]">
|
||||||
|
<slot v-if="modelValue && column.key === 'select' " name="select-data" :checked="isSelected(row)" :change="(ev: boolean) => onChangeCheckbox(ev, row)">
|
||||||
|
<UCheckbox
|
||||||
|
:model-value="isSelected(row)"
|
||||||
|
v-bind="ui.default.checkbox"
|
||||||
|
aria-label="Select row"
|
||||||
|
@change="onChangeCheckbox($event, row)"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
|
||||||
<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size, column?.rowClass, row[column.key]?.class]">
|
<slot
|
||||||
<slot :name="`${column.key}-data`" :column="column" :row="row" :index="index" :get-row-data="(defaultValue) => getRowData(row, column.key, defaultValue)">
|
v-else
|
||||||
|
:name="`${column.key}-data`"
|
||||||
|
:column="column"
|
||||||
|
:row="row"
|
||||||
|
:index="index"
|
||||||
|
:get-row-data="(defaultValue) => getRowData(row, column.key, defaultValue)"
|
||||||
|
>
|
||||||
{{ getRowData(row, column.key) }}
|
{{ getRowData(row, column.key) }}
|
||||||
</slot>
|
</slot>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="openedRows.includes(index)">
|
<tr v-if="isExpanded(row)">
|
||||||
<td colspan="100%">
|
<td colspan="100%">
|
||||||
<slot
|
<slot
|
||||||
name="expand"
|
name="expand"
|
||||||
@@ -110,18 +131,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, computed, defineComponent, toRaw, toRef } from 'vue'
|
import { computed, defineComponent, toRaw, toRef } from 'vue'
|
||||||
import type { PropType, AriaAttributes } from 'vue'
|
import type { PropType, AriaAttributes } from 'vue'
|
||||||
import { upperFirst } from 'scule'
|
import { upperFirst } from 'scule'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
|
import { isEqual } from 'ohash/utils'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import UButton from '../elements/Button.vue'
|
import UButton from '../elements/Button.vue'
|
||||||
import UProgress from '../elements/Progress.vue'
|
import UProgress from '../elements/Progress.vue'
|
||||||
import UCheckbox from '../forms/Checkbox.vue'
|
import UCheckbox from '../forms/Checkbox.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig, get } from '../../utils'
|
import { get, mergeConfig } from '../../utils'
|
||||||
import type { Strategy, Button, ProgressColor, ProgressAnimation, DeepPartial } from '../../types/index'
|
import type { TableRow, TableColumn, Strategy, Button, ProgressColor, ProgressAnimation, DeepPartial, Expanded } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { table } from '#ui/ui.config'
|
import { table } from '#ui/ui.config'
|
||||||
@@ -129,7 +151,7 @@ import { table } from '#ui/ui.config'
|
|||||||
const config = mergeConfig<typeof table>(appConfig.ui.strategy, appConfig.ui.table, table)
|
const config = mergeConfig<typeof table>(appConfig.ui.strategy, appConfig.ui.table, table)
|
||||||
|
|
||||||
function defaultComparator<T>(a: T, z: T): boolean {
|
function defaultComparator<T>(a: T, z: T): boolean {
|
||||||
return a === z
|
return isEqual(a, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
function defaultSort(a: any, b: any, direction: 'asc' | 'desc') {
|
function defaultSort(a: any, b: any, direction: 'asc' | 'desc') {
|
||||||
@@ -144,14 +166,12 @@ function defaultSort (a: any, b: any, direction: 'asc' | 'desc') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Column {
|
function getStringifiedSet(arr: TableRow[]) {
|
||||||
key: string
|
return new Set(arr.map(item => JSON.stringify(item)))
|
||||||
sortable?: boolean
|
}
|
||||||
sort?: (a: any, b: any, direction: 'asc' | 'desc') => number
|
|
||||||
direction?: 'asc' | 'desc'
|
function accessor<T extends Record<string, any>>(key: string) {
|
||||||
class?: string
|
return (obj: T) => get(obj, key)
|
||||||
rowClass?: string
|
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -172,11 +192,11 @@ export default defineComponent({
|
|||||||
default: () => defaultComparator
|
default: () => defaultComparator
|
||||||
},
|
},
|
||||||
rows: {
|
rows: {
|
||||||
type: Array as PropType<{ [key: string]: any }[]>,
|
type: Array as PropType<TableRow[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
columns: {
|
columns: {
|
||||||
type: Array as PropType<Column[]>,
|
type: Array as PropType<TableColumn[]>,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
columnAttribute: {
|
columnAttribute: {
|
||||||
@@ -207,12 +227,16 @@ export default defineComponent({
|
|||||||
type: Object as PropType<Button>,
|
type: Object as PropType<Button>,
|
||||||
default: () => config.default.expandButton as Button
|
default: () => config.default.expandButton as Button
|
||||||
},
|
},
|
||||||
|
expand: {
|
||||||
|
type: Object as PropType<Expanded<TableRow>>,
|
||||||
|
default: () => null
|
||||||
|
},
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
loadingState: {
|
loadingState: {
|
||||||
type: Object as PropType<{ icon: string, label: string }>,
|
type: Object as PropType<{ icon: string, label: string } | null>,
|
||||||
default: () => config.default.loadingState
|
default: () => config.default.loadingState
|
||||||
},
|
},
|
||||||
emptyState: {
|
emptyState: {
|
||||||
@@ -234,17 +258,53 @@ export default defineComponent({
|
|||||||
ui: {
|
ui: {
|
||||||
type: Object as PropType<DeepPartial<typeof config> & { strategy?: Strategy }>,
|
type: Object as PropType<DeepPartial<typeof config> & { strategy?: Strategy }>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
|
},
|
||||||
|
multipleExpand: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
singleSelect: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['update:modelValue', 'update:sort'],
|
emits: ['update:modelValue', 'update:sort', 'update:expand', 'select:all'],
|
||||||
setup(props, { emit, attrs: $attrs }) {
|
setup(props, { emit, attrs: $attrs }) {
|
||||||
const { ui, attrs } = useUI('table', toRef(props, 'ui'), config, toRef(props, 'class'))
|
const { ui, attrs } = useUI('table', toRef(props, 'ui'), config, toRef(props, 'class'))
|
||||||
|
|
||||||
const columns = computed(() => props.columns ?? Object.keys(props.rows[0] ?? {}).map((key) => ({ key, label: upperFirst(key), sortable: false, class: undefined, sort: defaultSort }) as Column))
|
const columns = computed(() => {
|
||||||
|
const defaultColumns = props.columns ?? (
|
||||||
|
Object.keys(props.rows[0]).map(key => ({
|
||||||
|
key,
|
||||||
|
label: upperFirst(key),
|
||||||
|
sortable: false,
|
||||||
|
class: undefined,
|
||||||
|
sort: defaultSort
|
||||||
|
}))
|
||||||
|
) as TableColumn[]
|
||||||
|
|
||||||
|
const hasColumnSelect = defaultColumns.find(v => v.key === 'select')
|
||||||
|
|
||||||
|
if (hasColumnSelect || !props.modelValue) {
|
||||||
|
return defaultColumns
|
||||||
|
}
|
||||||
|
|
||||||
|
return [{
|
||||||
|
key: 'select',
|
||||||
|
sortable: false,
|
||||||
|
class: undefined,
|
||||||
|
sort: defaultSort
|
||||||
|
}, ...defaultColumns]
|
||||||
|
})
|
||||||
|
|
||||||
const sort = useVModel(props, 'sort', emit, { passive: true, defaultValue: defu({}, props.sort, { column: null, direction: 'asc' }) })
|
const sort = useVModel(props, 'sort', emit, { passive: true, defaultValue: defu({}, props.sort, { column: null, direction: 'asc' }) })
|
||||||
|
const expand = useVModel(props, 'expand', emit, {
|
||||||
const openedRows = ref([])
|
passive: true,
|
||||||
|
defaultValue: defu({}, props.expand, {
|
||||||
|
openedRows: [],
|
||||||
|
row: null
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
const savedSort = { column: sort.value.column, direction: null }
|
const savedSort = { column: sort.value.column, direction: null }
|
||||||
|
|
||||||
@@ -259,7 +319,7 @@ export default defineComponent({
|
|||||||
const aValue = get(a, column)
|
const aValue = get(a, column)
|
||||||
const bValue = get(b, column)
|
const bValue = get(b, column)
|
||||||
|
|
||||||
const sort = columns.value.find((col) => col.key === column)?.sort ?? defaultSort
|
const sort = columns.value.find(col => col.key === column)?.sort ?? defaultSort
|
||||||
|
|
||||||
return sort(aValue, bValue, direction)
|
return sort(aValue, bValue, direction)
|
||||||
})
|
})
|
||||||
@@ -274,7 +334,21 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const indeterminate = computed(() => selected.value && selected.value.length > 0 && selected.value.length < props.rows.length)
|
const totalRows = computed(() => props.rows.length)
|
||||||
|
|
||||||
|
const countCheckedRow = computed(() => {
|
||||||
|
const selectedData = getStringifiedSet(selected.value)
|
||||||
|
const rowsData = getStringifiedSet(props.rows)
|
||||||
|
|
||||||
|
return Array.from(selectedData).filter(item => rowsData.has(item)).length
|
||||||
|
})
|
||||||
|
|
||||||
|
const indeterminate = computed(() => {
|
||||||
|
if (!selected.value || !props.rows) return false
|
||||||
|
return countCheckedRow.value > 0 && countCheckedRow.value < totalRows.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const isAllRowChecked = computed(() => countCheckedRow.value === totalRows.value)
|
||||||
|
|
||||||
const emptyState = computed(() => {
|
const emptyState = computed(() => {
|
||||||
if (props.emptyState === null) return null
|
if (props.emptyState === null) return null
|
||||||
@@ -288,18 +362,18 @@ export default defineComponent({
|
|||||||
|
|
||||||
function compare(a: any, z: any) {
|
function compare(a: any, z: any) {
|
||||||
if (typeof props.by === 'string') {
|
if (typeof props.by === 'string') {
|
||||||
const property = props.by as unknown as any
|
const accesorFn = accessor(props.by)
|
||||||
return a?.[property] === z?.[property]
|
return accesorFn(a) === accesorFn(z)
|
||||||
}
|
}
|
||||||
return props.by(a, z)
|
return props.by(a, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSelected (row) {
|
function isSelected(row: TableRow) {
|
||||||
if (!props.modelValue) {
|
if (!props.modelValue) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return selected.value.some((item) => compare(toRaw(item), toRaw(row)))
|
return selected.value.some(item => compare(toRaw(item), toRaw(row)))
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSort(column: { key: string, direction?: 'asc' | 'desc' }) {
|
function onSort(column: { key: string, direction?: 'asc' | 'desc' }) {
|
||||||
@@ -316,7 +390,12 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelect (row) {
|
function onSelect(row: TableRow) {
|
||||||
|
const selection = window.getSelection()
|
||||||
|
if (selection && selection.toString().length > 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!$attrs.onSelect) {
|
if (!$attrs.onSelect) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -325,6 +404,15 @@ export default defineComponent({
|
|||||||
$attrs.onSelect(row)
|
$attrs.onSelect(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onContextmenu(event, row) {
|
||||||
|
if (!$attrs.onContextmenu) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
$attrs.onContextmenu(event, row)
|
||||||
|
}
|
||||||
|
|
||||||
function selectAllRows() {
|
function selectAllRows() {
|
||||||
// Create a new array to ensure reactivity
|
// Create a new array to ensure reactivity
|
||||||
const newSelected = [...selected.value]
|
const newSelected = [...selected.value]
|
||||||
@@ -346,21 +434,33 @@ export default defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
selected.value = []
|
selected.value = []
|
||||||
}
|
}
|
||||||
|
emit('select:all', checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRowData (row: Object, rowKey: string | string[], defaultValue: any = '') {
|
function onChangeCheckbox(checked: boolean, row: TableRow) {
|
||||||
|
if (checked) {
|
||||||
|
selected.value = props.singleSelect ? [row] : [...selected.value, row]
|
||||||
|
} else {
|
||||||
|
selected.value = selected.value.filter(value => !compare(toRaw(value), toRaw(row)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRowData(row: TableRow, rowKey: string | string[], defaultValue: any = '') {
|
||||||
return get(row, rowKey, defaultValue)
|
return get(row, rowKey, defaultValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleOpened (index: number) {
|
function isExpanded(row: TableRow) {
|
||||||
if (openedRows.value.includes(index)) {
|
return expand.value?.openedRows ? expand.value.openedRows.some(openedRow => compare(openedRow, row)) : false
|
||||||
openedRows.value = openedRows.value.filter((i) => i !== index)
|
}
|
||||||
} else {
|
|
||||||
openedRows.value.push(index)
|
function toggleOpened(row: TableRow) {
|
||||||
|
expand.value = {
|
||||||
|
openedRows: isExpanded(row) ? expand.value.openedRows.filter(v => !compare(v, row)) : props.multipleExpand ? [...expand.value.openedRows, row] : [row],
|
||||||
|
row
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAriaSort (column: Column): AriaAttributes['aria-sort'] {
|
function getAriaSort(column: TableColumn): AriaAttributes['aria-sort'] {
|
||||||
if (!column.sortable) {
|
if (!column.sortable) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
@@ -396,14 +496,17 @@ export default defineComponent({
|
|||||||
emptyState,
|
emptyState,
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
loadingState,
|
loadingState,
|
||||||
openedRows,
|
isAllRowChecked,
|
||||||
|
onChangeCheckbox,
|
||||||
isSelected,
|
isSelected,
|
||||||
onSort,
|
onSort,
|
||||||
onSelect,
|
onSelect,
|
||||||
|
onContextmenu,
|
||||||
onChange,
|
onChange,
|
||||||
getRowData,
|
getRowData,
|
||||||
toggleOpened,
|
toggleOpened,
|
||||||
getAriaSort
|
getAriaSort,
|
||||||
|
isExpanded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export default defineComponent({
|
|||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['open'],
|
emits: ['open', 'close'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const { ui, attrs } = useUI('accordion', toRef(props, 'ui'), config, toRef(props, 'class'))
|
const { ui, attrs } = useUI('accordion', toRef(props, 'ui'), config, toRef(props, 'class'))
|
||||||
|
|
||||||
@@ -142,6 +142,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
if (!isOpenBefore && isOpenAfter) {
|
if (!isOpenBefore && isOpenAfter) {
|
||||||
emit('open', index)
|
emit('open', index)
|
||||||
|
} else if (isOpenBefore && !isOpenAfter) {
|
||||||
|
emit('close', index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
@@ -161,6 +163,7 @@ export default defineComponent({
|
|||||||
function onEnter(_el: Element, done: () => void) {
|
function onEnter(_el: Element, done: () => void) {
|
||||||
const el = _el as HTMLElement
|
const el = _el as HTMLElement
|
||||||
el.style.height = '0'
|
el.style.height = '0'
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||||
el.offsetHeight // Trigger a reflow, flushing the CSS changes
|
el.offsetHeight // Trigger a reflow, flushing the CSS changes
|
||||||
el.style.height = el.scrollHeight + 'px'
|
el.style.height = el.scrollHeight + 'px'
|
||||||
|
|
||||||
@@ -170,6 +173,7 @@ export default defineComponent({
|
|||||||
function onBeforeLeave(_el: Element) {
|
function onBeforeLeave(_el: Element) {
|
||||||
const el = _el as HTMLElement
|
const el = _el as HTMLElement
|
||||||
el.style.height = el.scrollHeight + 'px'
|
el.style.height = el.scrollHeight + 'px'
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||||
el.offsetHeight // Trigger a reflow, flushing the CSS changes
|
el.offsetHeight // Trigger a reflow, flushing the CSS changes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
{{ title }}
|
{{ title }}
|
||||||
</slot>
|
</slot>
|
||||||
</p>
|
</p>
|
||||||
<div v-if="description || $slots.description" :class="twMerge(ui.description, !title && !$slots.title && 'mt-0 leading-5')">
|
<div v-if="description || $slots.description" :class="twMerge(ui.description, !title && !$slots.title && ui.descriptionOnly)">
|
||||||
<slot name="description" :description="description">
|
<slot name="description" :description="description">
|
||||||
{{ description }}
|
{{ description }}
|
||||||
</slot>
|
</slot>
|
||||||
@@ -42,13 +42,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, toRef, defineComponent } from 'vue'
|
import { computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import UAvatar from '../elements/Avatar.vue'
|
import UAvatar from '../elements/Avatar.vue'
|
||||||
import UButton from '../elements/Button.vue'
|
import UButton from '../elements/Button.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import type { Avatar, Button, AlertColor, AlertVariant, AlertAction, Strategy, DeepPartial } from '../../types/index'
|
import type { Avatar, Button, AlertColor, AlertVariant, AlertAction, Strategy, DeepPartial } from '../../types/index'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { alert } from '#ui/ui.config'
|
import { alert } from '#ui/ui.config'
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, computed, toRef, watch } from 'vue'
|
import { defineComponent, ref, computed, toRef, watch } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import type { AvatarSize, AvatarChipColor, AvatarChipPosition, Strategy, DeepPartial } from '../../types/index'
|
import type { AvatarSize, AvatarChipColor, AvatarChipPosition, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { h, cloneVNode, computed, toRef, defineComponent } from 'vue'
|
import { h, cloneVNode, computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UAvatar from './Avatar.vue'
|
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig, getSlotsChildren } from '../../utils'
|
import { getSlotsChildren, mergeConfig, twMerge } from '../../utils'
|
||||||
import type { AvatarSize, Strategy } from '../../types/index'
|
import type { AvatarSize, DeepPartial, Strategy } from '../../types/index'
|
||||||
|
import UAvatar from './Avatar.vue'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { avatar, avatarGroup } from '#ui/ui.config'
|
import { avatar, avatarGroup } from '#ui/ui.config'
|
||||||
@@ -32,7 +32,7 @@ export default defineComponent({
|
|||||||
default: () => ''
|
default: () => ''
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
type: Object as PropType<Partial<typeof avatarGroupConfig> & { strategy?: Strategy }>,
|
type: Object as PropType<DeepPartial<typeof avatarGroupConfig> & { strategy?: Strategy }>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -41,7 +41,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const children = computed(() => getSlotsChildren(slots))
|
const children = computed(() => getSlotsChildren(slots))
|
||||||
|
|
||||||
const max = computed(() => typeof props.max === 'string' ? parseInt(props.max, 10) : props.max)
|
const max = computed(() => typeof props.max === 'string' ? Number.parseInt(props.max, 10) : props.max)
|
||||||
|
|
||||||
const clones = computed(() => children.value.map((node, index) => {
|
const clones = computed(() => children.value.map((node, index) => {
|
||||||
const vProps: any = {}
|
const vProps: any = {}
|
||||||
|
|||||||
@@ -1,15 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<span :class="badgeClass" v-bind="attrs">
|
<span :class="badgeClass" v-bind="attrs">
|
||||||
<slot>{{ label }}</slot>
|
<slot name="leading">
|
||||||
|
<UIcon v-if="isLeading && leadingIconName" :name="leadingIconName" :class="leadingIconClass" aria-hidden="true" />
|
||||||
|
</slot>
|
||||||
|
|
||||||
|
<slot>
|
||||||
|
<span v-if="label">
|
||||||
|
{{ label }}
|
||||||
|
</span>
|
||||||
|
</slot>
|
||||||
|
|
||||||
|
<slot name="trailing">
|
||||||
|
<UIcon v-if="isTrailing && trailingIconName" :name="trailingIconName" :class="trailingIconClass" aria-hidden="true" />
|
||||||
|
</slot>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, toRef, defineComponent } from 'vue'
|
import { computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
|
import UIcon from '../elements/Icon.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { BadgeColor, BadgeSize, BadgeVariant, DeepPartial, Strategy } from '../../types/index'
|
import type { BadgeColor, BadgeSize, BadgeVariant, DeepPartial, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -19,6 +32,9 @@ import { badge } from '#ui/ui.config'
|
|||||||
const config = mergeConfig<typeof badge>(appConfig.ui.strategy, appConfig.ui.badge, badge)
|
const config = mergeConfig<typeof badge>(appConfig.ui.strategy, appConfig.ui.badge, badge)
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
components: {
|
||||||
|
UIcon
|
||||||
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
size: {
|
size: {
|
||||||
@@ -49,6 +65,26 @@ export default defineComponent({
|
|||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
leadingIcon: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
trailingIcon: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
trailing: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
leading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
class: {
|
class: {
|
||||||
type: [String, Object, Array] as PropType<any>,
|
type: [String, Object, Array] as PropType<any>,
|
||||||
default: () => ''
|
default: () => ''
|
||||||
@@ -63,6 +99,14 @@ export default defineComponent({
|
|||||||
|
|
||||||
const { size, rounded } = useInjectButtonGroup({ ui, props })
|
const { size, rounded } = useInjectButtonGroup({ ui, props })
|
||||||
|
|
||||||
|
const isLeading = computed(() => {
|
||||||
|
return (props.icon && props.leading) || (props.icon && !props.trailing) || !props.trailing || props.leadingIcon
|
||||||
|
})
|
||||||
|
|
||||||
|
const isTrailing = computed(() => {
|
||||||
|
return (props.icon && props.trailing) || props.trailing || props.trailingIcon
|
||||||
|
})
|
||||||
|
|
||||||
const badgeClass = computed(() => {
|
const badgeClass = computed(() => {
|
||||||
const variant = ui.value.color?.[props.color as string]?.[props.variant as string] || ui.value.variant[props.variant]
|
const variant = ui.value.color?.[props.color as string]?.[props.variant as string] || ui.value.variant[props.variant]
|
||||||
|
|
||||||
@@ -71,13 +115,42 @@ export default defineComponent({
|
|||||||
ui.value.font,
|
ui.value.font,
|
||||||
rounded.value,
|
rounded.value,
|
||||||
ui.value.size[size.value],
|
ui.value.size[size.value],
|
||||||
|
ui.value.gap[size.value],
|
||||||
variant?.replaceAll('{color}', props.color)
|
variant?.replaceAll('{color}', props.color)
|
||||||
), props.class)
|
), props.class)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const leadingIconName = computed(() => {
|
||||||
|
return props.leadingIcon || props.icon
|
||||||
|
})
|
||||||
|
|
||||||
|
const trailingIconName = computed(() => {
|
||||||
|
return props.trailingIcon || props.icon
|
||||||
|
})
|
||||||
|
|
||||||
|
const leadingIconClass = computed(() => {
|
||||||
|
return twJoin(
|
||||||
|
ui.value.icon.base,
|
||||||
|
ui.value.icon.size[size.value]
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
const trailingIconClass = computed(() => {
|
||||||
|
return twJoin(
|
||||||
|
ui.value.icon.base,
|
||||||
|
ui.value.icon.size[size.value]
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attrs,
|
attrs,
|
||||||
badgeClass
|
isLeading,
|
||||||
|
isTrailing,
|
||||||
|
badgeClass,
|
||||||
|
leadingIconName,
|
||||||
|
trailingIconName,
|
||||||
|
leadingIconClass,
|
||||||
|
trailingIconClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, toRef } from 'vue'
|
import { computed, defineComponent, toRef } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import ULink from '../elements/Link.vue'
|
import ULink from '../elements/Link.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig, nuxtLinkProps, getNuxtLinkProps } from '../../utils'
|
import { getNuxtLinkProps, mergeConfig, nuxtLinkProps, twMerge } from '../../utils'
|
||||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { ButtonColor, ButtonSize, ButtonVariant, DeepPartial, Strategy } from '../../types/index'
|
import type { ButtonColor, ButtonSize, ButtonVariant, DeepPartial, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { h, computed, toRef, defineComponent } from 'vue'
|
import { h, computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig, getSlotsChildren } from '../../utils'
|
import { getSlotsChildren, mergeConfig, twMerge } from '../../utils'
|
||||||
import { useProvideButtonGroup } from '../../composables/useButtonGroup'
|
import { useProvideButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { ButtonSize, Strategy } from '../../types/index'
|
import type { ButtonSize, DeepPartial, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { button, buttonGroup } from '#ui/ui.config'
|
import { button, buttonGroup } from '#ui/ui.config'
|
||||||
@@ -35,7 +35,7 @@ export default defineComponent({
|
|||||||
default: () => ''
|
default: () => ''
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
type: Object as PropType<Partial<typeof buttonGroupConfig> & { strategy?: Strategy }>,
|
type: Object as PropType<DeepPartial<typeof buttonGroupConfig> & { strategy?: Strategy }>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -58,13 +58,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, toRef, computed, defineComponent } from 'vue'
|
import { ref, toRef, computed, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge } from 'tailwind-merge'
|
import { useScroll, useResizeObserver, useElementSize } from '@vueuse/core'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import UButton from '../elements/Button.vue'
|
import UButton from '../elements/Button.vue'
|
||||||
import type { Strategy, Button, DeepPartial } from '../../types/index'
|
import type { Strategy, Button, DeepPartial } from '../../types/index'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useCarouselScroll } from '../../composables/useCarouselScroll'
|
import { useCarouselScroll } from '../../composables/useCarouselScroll'
|
||||||
import { useScroll, useResizeObserver, useElementSize } from '@vueuse/core'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { carousel } from '#ui/ui.config'
|
import { carousel } from '#ui/ui.config'
|
||||||
@@ -106,7 +105,7 @@ export default defineComponent({
|
|||||||
default: () => ''
|
default: () => ''
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
type: Object as PropType<DeepPartial<typeof config & { strategy?: Strategy }>>,
|
type: Object as PropType<DeepPartial<typeof config> & { strategy?: Strategy }>,
|
||||||
default: undefined
|
default: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -60,13 +60,13 @@ import { defineComponent, ref, computed, watch, toRef, onMounted, resolveCompone
|
|||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { Menu as HMenu, MenuButton as HMenuButton, MenuItems as HMenuItems, MenuItem as HMenuItem, provideUseId } from '@headlessui/vue'
|
import { Menu as HMenu, MenuButton as HMenuButton, MenuItems as HMenuItems, MenuItem as HMenuItem, provideUseId } from '@headlessui/vue'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import UAvatar from '../elements/Avatar.vue'
|
import UAvatar from '../elements/Avatar.vue'
|
||||||
import UKbd from '../elements/Kbd.vue'
|
import UKbd from '../elements/Kbd.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { usePopper } from '../../composables/usePopper'
|
import { usePopper } from '../../composables/usePopper'
|
||||||
import { mergeConfig, getNuxtLinkProps } from '../../utils'
|
import { getNuxtLinkProps, mergeConfig, twMerge } from '../../utils'
|
||||||
import type { DeepPartial, DropdownItem, PopperOptions, Strategy } from '../../types/index'
|
import type { DeepPartial, DropdownItem, PopperOptions, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
@@ -209,7 +209,9 @@ export default defineComponent({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
openTimeout = openTimeout || setTimeout(() => {
|
openTimeout = openTimeout || setTimeout(() => {
|
||||||
menuApi.value.openMenu && menuApi.value.openMenu()
|
if (menuApi.value.openMenu) {
|
||||||
|
menuApi.value.openMenu()
|
||||||
|
}
|
||||||
openTimeout = null
|
openTimeout = null
|
||||||
}, props.openDelay)
|
}, props.openDelay)
|
||||||
}
|
}
|
||||||
@@ -229,7 +231,9 @@ export default defineComponent({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
closeTimeout = closeTimeout || setTimeout(() => {
|
closeTimeout = closeTimeout || setTimeout(() => {
|
||||||
menuApi.value.closeMenu && menuApi.value.closeMenu()
|
if (menuApi.value.closeMenu) {
|
||||||
|
menuApi.value.closeMenu()
|
||||||
|
}
|
||||||
closeTimeout = null
|
closeTimeout = null
|
||||||
}, props.closeDelay)
|
}, props.closeDelay)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toRef, defineComponent, computed } from 'vue'
|
import { toRef, defineComponent, computed } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import type { DeepPartial, KbdSize, Strategy } from '../../types/index'
|
import type { DeepPartial, KbdSize, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { isEqual } from 'ohash'
|
import { isEqual, diff } from 'ohash/utils'
|
||||||
import { defineComponent } from 'vue'
|
import { type PropType, defineComponent } from 'vue'
|
||||||
import { nuxtLinkProps } from '../../utils'
|
import { nuxtLinkProps } from '../../utils'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -61,7 +61,7 @@ export default defineComponent({
|
|||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
exactQuery: {
|
exactQuery: {
|
||||||
type: Boolean,
|
type: [Boolean, String] as PropType<boolean | 'partial'>,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
exactHash: {
|
exactHash: {
|
||||||
@@ -74,9 +74,25 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
function isPartiallyEqual(item1: any, item2: any) {
|
||||||
|
const diffedKeys = diff(item1, item2).reduce((filtered, q) => {
|
||||||
|
if (q.type === 'added') {
|
||||||
|
filtered.add(q.key)
|
||||||
|
}
|
||||||
|
return filtered
|
||||||
|
}, new Set<string>())
|
||||||
|
|
||||||
|
const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)))
|
||||||
|
const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)))
|
||||||
|
|
||||||
|
return isEqual(item1Filtered, item2Filtered)
|
||||||
|
}
|
||||||
|
|
||||||
function resolveLinkClass(route, $route, { isActive, isExactActive }: { isActive: boolean, isExactActive: boolean }) {
|
function resolveLinkClass(route, $route, { isActive, isExactActive }: { isActive: boolean, isExactActive: boolean }) {
|
||||||
if (props.exactQuery && !isEqual(route.query, $route.query)) {
|
if (props.exactQuery === 'partial') {
|
||||||
return props.inactiveClass
|
if (!isPartiallyEqual(route.query, $route.query)) return props.inactiveClass
|
||||||
|
} else if (props.exactQuery === true) {
|
||||||
|
if (!isEqual(route.query, $route.query)) return props.inactiveClass
|
||||||
}
|
}
|
||||||
if (props.exactHash && route.hash !== $route.hash) {
|
if (props.exactHash && route.hash !== $route.hash) {
|
||||||
return props.inactiveClass
|
return props.inactiveClass
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
slots: Object as SlotsType<{
|
slots: Object as SlotsType<{
|
||||||
indicator?: { percent: number, value: number },
|
indicator?: { percent: number, value: number }
|
||||||
label?: { percent: number, value: number },
|
label?: { percent: number, value: number }
|
||||||
}>,
|
}>,
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import { h, cloneVNode, computed, toRef, defineComponent } from 'vue'
|
|||||||
import type { ComputedRef, VNode, SlotsType, PropType } from 'vue'
|
import type { ComputedRef, VNode, SlotsType, PropType } from 'vue'
|
||||||
import { twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import Meter from './Meter.vue'
|
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { mergeConfig, getSlotsChildren } from '../../utils'
|
import { getSlotsChildren, mergeConfig } from '../../utils'
|
||||||
import type { Strategy, MeterSize } from '../../types/index'
|
import type { DeepPartial, Strategy, MeterSize } from '../../types/index'
|
||||||
|
import type Meter from './Meter.vue'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { meter, meterGroup } from '#ui/ui.config'
|
import { meter, meterGroup } from '#ui/ui.config'
|
||||||
@@ -19,8 +19,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
slots: Object as SlotsType<{
|
slots: Object as SlotsType<{
|
||||||
default?: typeof Meter[],
|
default?: typeof Meter[]
|
||||||
indicator?: { percent: number },
|
indicator?: { percent: number }
|
||||||
}>,
|
}>,
|
||||||
props: {
|
props: {
|
||||||
min: {
|
min: {
|
||||||
@@ -51,7 +51,7 @@ export default defineComponent({
|
|||||||
default: () => ''
|
default: () => ''
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
type: Object as PropType<Partial<typeof meterGroupConfig> & { strategy?: Strategy }>,
|
type: Object as PropType<DeepPartial<typeof meterGroupConfig> & { strategy?: Strategy }>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -256,6 +256,20 @@ progress:indeterminate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[dir=rtl] &.bar-animation-carousel {
|
||||||
|
&:after {
|
||||||
|
animation: carousel-rtl 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-progress-value {
|
||||||
|
animation: carousel-rtl 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-moz-progress-bar {
|
||||||
|
animation: carousel-rtl 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.bar-animation-carousel-inverse {
|
&.bar-animation-carousel-inverse {
|
||||||
&:after {
|
&:after {
|
||||||
animation: carousel-inverse 2s ease-in-out infinite;
|
animation: carousel-inverse 2s ease-in-out infinite;
|
||||||
@@ -270,6 +284,20 @@ progress:indeterminate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[dir=rtl] &.bar-animation-carousel-inverse {
|
||||||
|
&:after {
|
||||||
|
animation: carousel-inverse-rtl 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-progress-value {
|
||||||
|
animation: carousel-inverse-rtl 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-moz-progress-bar {
|
||||||
|
animation: carousel-inverse-rtl 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.bar-animation-swing {
|
&.bar-animation-swing {
|
||||||
&:after {
|
&:after {
|
||||||
animation: swing 3s ease-in-out infinite;
|
animation: swing 3s ease-in-out infinite;
|
||||||
@@ -315,6 +343,22 @@ progress:indeterminate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes carousel-rtl {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
width: 50%
|
||||||
|
}
|
||||||
|
|
||||||
|
0% {
|
||||||
|
transform: translateX(100%)
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: translateX(-200%)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes carousel-inverse {
|
@keyframes carousel-inverse {
|
||||||
|
|
||||||
0%,
|
0%,
|
||||||
@@ -331,6 +375,22 @@ progress:indeterminate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes carousel-inverse-rtl {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
width: 50%
|
||||||
|
}
|
||||||
|
|
||||||
|
0% {
|
||||||
|
transform: translateX(-200%)
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: translateX(100%)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes swing {
|
@keyframes swing {
|
||||||
|
|
||||||
0%,
|
0%,
|
||||||
@@ -361,4 +421,5 @@ progress:indeterminate {
|
|||||||
width: 90%;
|
width: 90%;
|
||||||
margin-left: 5%
|
margin-left: 5%
|
||||||
}
|
}
|
||||||
}</style>
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -32,15 +32,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, toRef, defineComponent } from 'vue'
|
import { computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import type { DeepPartial, Strategy } from '../../types/index'
|
import type { DeepPartial, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { checkbox } from '#ui/ui.config'
|
import { checkbox } from '#ui/ui.config'
|
||||||
import colors from '#ui-colors'
|
import type colors from '#ui-colors'
|
||||||
import { useId } from '#app'
|
import { useId } from '#app'
|
||||||
|
|
||||||
const config = mergeConfig<typeof checkbox>(appConfig.ui.strategy, appConfig.ui.checkbox, checkbox)
|
const config = mergeConfig<typeof checkbox>(appConfig.ui.strategy, appConfig.ui.checkbox, checkbox)
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import type { ObjectSchema as YupObjectSchema, ValidationError as YupError } fro
|
|||||||
import type { BaseSchema as ValibotSchema30, BaseSchemaAsync as ValibotSchemaAsync30 } from 'valibot30'
|
import type { BaseSchema as ValibotSchema30, BaseSchemaAsync as ValibotSchemaAsync30 } from 'valibot30'
|
||||||
import type { GenericSchema as ValibotSchema31, GenericSchemaAsync as ValibotSchemaAsync31, SafeParser as ValibotSafeParser31, SafeParserAsync as ValibotSafeParserAsync31 } from 'valibot31'
|
import type { GenericSchema as ValibotSchema31, GenericSchemaAsync as ValibotSchemaAsync31, SafeParser as ValibotSafeParser31, SafeParserAsync as ValibotSafeParserAsync31 } from 'valibot31'
|
||||||
import type { GenericSchema as ValibotSchema, GenericSchemaAsync as ValibotSchemaAsync, SafeParser as ValibotSafeParser, SafeParserAsync as ValibotSafeParserAsync } from 'valibot'
|
import type { GenericSchema as ValibotSchema, GenericSchemaAsync as ValibotSchemaAsync, SafeParser as ValibotSafeParser, SafeParserAsync as ValibotSafeParserAsync } from 'valibot'
|
||||||
import type { FormError, FormEvent, FormEventType, FormSubmitEvent, FormErrorEvent, Form } from '../../types/form'
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||||
|
import type { Struct } from 'superstruct'
|
||||||
|
import type { FormError, FormEvent, FormEventType, FormSubmitEvent, FormErrorEvent, Form, ValidateReturnSchema } from '../../types/form'
|
||||||
import { useId } from '#imports'
|
import { useId } from '#imports'
|
||||||
|
|
||||||
class FormException extends Error {
|
class FormException extends Error {
|
||||||
@@ -24,18 +26,20 @@ class FormException extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
type Schema = PropType<ZodSchema>
|
||||||
props: {
|
|
||||||
schema: {
|
|
||||||
type: [Object, Function] as
|
|
||||||
| PropType<ZodSchema>
|
|
||||||
| PropType<YupObjectSchema<any>>
|
| PropType<YupObjectSchema<any>>
|
||||||
| PropType<JoiSchema>
|
| PropType<JoiSchema>
|
||||||
| PropType<ValibotSchema30 | ValibotSchemaAsync30>
|
| PropType<ValibotSchema30 | ValibotSchemaAsync30>
|
||||||
| PropType<ValibotSchema31 | ValibotSchemaAsync31>
|
| PropType<ValibotSchema31 | ValibotSchemaAsync31>
|
||||||
| PropType<ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any>>
|
| PropType<ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any>>
|
||||||
| PropType<ValibotSchema | ValibotSchemaAsync>
|
| PropType<ValibotSchema | ValibotSchemaAsync>
|
||||||
| PropType<ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any>>,
|
| PropType<ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any>> | PropType<Struct<any, any>>
|
||||||
|
| PropType<StandardSchemaV1>
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
props: {
|
||||||
|
schema: {
|
||||||
|
type: [Object, Function] as Schema,
|
||||||
default: undefined
|
default: undefined
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
@@ -58,6 +62,8 @@ export default defineComponent({
|
|||||||
const formId = useId()
|
const formId = useId()
|
||||||
const bus = useEventBus<FormEvent>(`form-${formId}`)
|
const bus = useEventBus<FormEvent>(`form-${formId}`)
|
||||||
|
|
||||||
|
const parsedValue = ref(null)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
bus.on(async (event) => {
|
bus.on(async (event) => {
|
||||||
if (event.type !== 'submit' && props.validateOn?.includes(event.type)) {
|
if (event.type !== 'submit' && props.validateOn?.includes(event.type)) {
|
||||||
@@ -71,6 +77,7 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const errors = ref<FormError[]>([])
|
const errors = ref<FormError[]>([])
|
||||||
|
|
||||||
provide('form-errors', errors)
|
provide('form-errors', errors)
|
||||||
provide('form-events', bus)
|
provide('form-events', bus)
|
||||||
const inputs = ref({})
|
const inputs = ref({})
|
||||||
@@ -80,16 +87,11 @@ export default defineComponent({
|
|||||||
let errs = await props.validate(props.state)
|
let errs = await props.validate(props.state)
|
||||||
|
|
||||||
if (props.schema) {
|
if (props.schema) {
|
||||||
if (isZodSchema(props.schema)) {
|
const { errors, result } = await parseSchema(props.state, props.schema as unknown as Schema)
|
||||||
errs = errs.concat(await getZodErrors(props.state, props.schema))
|
if (errors) {
|
||||||
} else if (isYupSchema(props.schema)) {
|
errs = errs.concat(errors)
|
||||||
errs = errs.concat(await getYupErrors(props.state, props.schema))
|
|
||||||
} else if (isJoiSchema(props.schema)) {
|
|
||||||
errs = errs.concat(await getJoiErrors(props.state, props.schema))
|
|
||||||
} else if (isValibotSchema(props.schema)) {
|
|
||||||
errs = errs.concat(await getValibotError(props.state, props.schema))
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Form validation failed: Unsupported form schema')
|
parsedValue.value = result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +107,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
if (paths) {
|
if (paths) {
|
||||||
const otherErrors = errors.value.filter(
|
const otherErrors = errors.value.filter(
|
||||||
(error) => !paths.includes(error.path)
|
error => !paths.includes(error.path)
|
||||||
)
|
)
|
||||||
const pathErrors = (await getErrors()).filter(
|
const pathErrors = (await getErrors()).filter(
|
||||||
(error) => paths.includes(error.path)
|
error => paths.includes(error.path)
|
||||||
)
|
)
|
||||||
errors.value = otherErrors.concat(pathErrors)
|
errors.value = otherErrors.concat(pathErrors)
|
||||||
} else {
|
} else {
|
||||||
@@ -132,7 +134,7 @@ export default defineComponent({
|
|||||||
if (props.validateOn?.includes('submit')) {
|
if (props.validateOn?.includes('submit')) {
|
||||||
await validate()
|
await validate()
|
||||||
}
|
}
|
||||||
event.data = props.state
|
event.data = props.schema ? parsedValue.value : props.state
|
||||||
emit('submit', event)
|
emit('submit', event)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!(error instanceof FormException)) {
|
if (!(error instanceof FormException)) {
|
||||||
@@ -141,7 +143,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const errorEvent: FormErrorEvent = {
|
const errorEvent: FormErrorEvent = {
|
||||||
...event,
|
...event,
|
||||||
errors: errors.value.map((err) => ({
|
errors: errors.value.map(err => ({
|
||||||
...err,
|
...err,
|
||||||
id: inputs.value[err.path]
|
id: inputs.value[err.path]
|
||||||
}))
|
}))
|
||||||
@@ -156,7 +158,7 @@ export default defineComponent({
|
|||||||
setErrors(errs: FormError[], path?: string) {
|
setErrors(errs: FormError[], path?: string) {
|
||||||
if (path) {
|
if (path) {
|
||||||
errors.value = errors.value.filter(
|
errors.value = errors.value.filter(
|
||||||
(error) => error.path !== path
|
error => error.path !== path
|
||||||
).concat(errs)
|
).concat(errs)
|
||||||
} else {
|
} else {
|
||||||
errors.value = errs
|
errors.value = errs
|
||||||
@@ -167,13 +169,13 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
getErrors(path?: string) {
|
getErrors(path?: string) {
|
||||||
if (path) {
|
if (path) {
|
||||||
return errors.value.filter((err) => err.path === path)
|
return errors.value.filter(err => err.path === path)
|
||||||
}
|
}
|
||||||
return errors.value
|
return errors.value
|
||||||
},
|
},
|
||||||
clear(path?: string) {
|
clear(path?: string) {
|
||||||
if (path) {
|
if (path) {
|
||||||
errors.value = errors.value.filter((err) => err.path !== path)
|
errors.value = errors.value.filter(err => err.path !== path)
|
||||||
} else {
|
} else {
|
||||||
errors.value = []
|
errors.value = []
|
||||||
}
|
}
|
||||||
@@ -195,41 +197,13 @@ function isYupError (error: any): error is YupError {
|
|||||||
return error.inner !== undefined
|
return error.inner !== undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getYupErrors (
|
function isSuperStructSchema(schema: any): schema is Struct<any, any> {
|
||||||
state: any,
|
return (
|
||||||
schema: YupObjectSchema<any>
|
'schema' in schema
|
||||||
): Promise<FormError[]> {
|
&& typeof schema.coercer === 'function'
|
||||||
try {
|
&& typeof schema.validator === 'function'
|
||||||
await schema.validate(state, { abortEarly: false })
|
&& typeof schema.refiner === 'function'
|
||||||
return []
|
)
|
||||||
} catch (error) {
|
|
||||||
if (isYupError(error)) {
|
|
||||||
return error.inner.map((issue) => ({
|
|
||||||
path: issue.path ?? '',
|
|
||||||
message: issue.message
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isZodSchema (schema: any): schema is ZodSchema {
|
|
||||||
return schema.parse !== undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getZodErrors (
|
|
||||||
state: any,
|
|
||||||
schema: ZodSchema
|
|
||||||
): Promise<FormError[]> {
|
|
||||||
const result = await schema.safeParseAsync(state)
|
|
||||||
if (result.success === false) {
|
|
||||||
return result.error.issues.map((issue) => ({
|
|
||||||
path: issue.path.join('.'),
|
|
||||||
message: issue.message
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
return []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJoiSchema(schema: any): schema is JoiSchema {
|
function isJoiSchema(schema: any): schema is JoiSchema {
|
||||||
@@ -240,38 +214,183 @@ function isJoiError (error: any): error is JoiError {
|
|||||||
return error.isJoi === true
|
return error.isJoi === true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getJoiErrors (
|
function isValibotSchema(schema: any): schema is ValibotSchema30 | ValibotSchemaAsync30 | ValibotSchema31 | ValibotSchemaAsync31 | ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any> | ValibotSchema | ValibotSchemaAsync | ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any> {
|
||||||
|
return '_parse' in schema || '_run' in schema || (typeof schema === 'function' && 'schema' in schema)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isZodSchema(schema: any): schema is ZodSchema {
|
||||||
|
return schema.parse !== undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isStandardSchema(schema: any): schema is StandardSchemaV1 {
|
||||||
|
return '~standard' in schema
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateStandardSchema(
|
||||||
|
state: any,
|
||||||
|
schema: StandardSchemaV1
|
||||||
|
): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
|
const result = await schema['~standard'].validate(state)
|
||||||
|
|
||||||
|
if (!result.issues || result.issues.length === 0) {
|
||||||
|
const output = ('value' in result ? result.value : null)
|
||||||
|
return {
|
||||||
|
errors: null,
|
||||||
|
result: output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const errors = result.issues.map(issue => ({
|
||||||
|
path: issue.path?.map(item => typeof item === 'object' ? item.key : item).join('.') || '',
|
||||||
|
message: issue.message
|
||||||
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors,
|
||||||
|
result: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function validateValibotSchema(
|
||||||
|
state: any,
|
||||||
|
schema: ValibotSchema30 | ValibotSchemaAsync30 | ValibotSchema31 | ValibotSchemaAsync31 | ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any> | ValibotSchema | ValibotSchemaAsync | ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any>
|
||||||
|
): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
|
const result = await ('_parse' in schema ? schema._parse(state) : '_run' in schema ? schema._run({ typed: false, value: state }, {}) : schema(state))
|
||||||
|
|
||||||
|
if (!result.issues || result.issues.length === 0) {
|
||||||
|
const output = ('output' in result
|
||||||
|
? result.output
|
||||||
|
: 'value' in result
|
||||||
|
? result.value
|
||||||
|
: null)
|
||||||
|
return {
|
||||||
|
errors: null,
|
||||||
|
result: output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const errors = result.issues.map(issue => ({
|
||||||
|
path: issue.path?.map(item => item.key).join('.') || '',
|
||||||
|
message: issue.message
|
||||||
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors,
|
||||||
|
result: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function validateJoiSchema(
|
||||||
state: any,
|
state: any,
|
||||||
schema: JoiSchema
|
schema: JoiSchema
|
||||||
): Promise<FormError[]> {
|
): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
try {
|
try {
|
||||||
await schema.validateAsync(state, { abortEarly: false })
|
const result = await schema.validateAsync(state, { abortEarly: false })
|
||||||
return []
|
return {
|
||||||
|
errors: null,
|
||||||
|
result
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isJoiError(error)) {
|
if (isJoiError(error)) {
|
||||||
return error.details.map((detail) => ({
|
const errors = error.details.map(issue => ({
|
||||||
path: detail.path.join('.'),
|
path: issue.path.join('.'),
|
||||||
message: detail.message
|
message: issue.message
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors,
|
||||||
|
result: null
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValibotSchema (schema: any): schema is ValibotSchema30 | ValibotSchemaAsync30 | ValibotSchema31 | ValibotSchemaAsync31 | ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any> | ValibotSchema | ValibotSchemaAsync | ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any> {
|
async function validateZodSchema(
|
||||||
return '_parse' in schema || '_run' in schema || (typeof schema === 'function' && 'schema' in schema)
|
state: any,
|
||||||
|
schema: ZodSchema
|
||||||
|
): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
|
const result = await schema.safeParseAsync(state)
|
||||||
|
if (result.success === false) {
|
||||||
|
const errors = result.error.issues.map(issue => ({
|
||||||
|
path: issue.path.join('.'),
|
||||||
|
message: issue.message
|
||||||
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors,
|
||||||
|
result: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
result: result.data,
|
||||||
|
errors: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getValibotError (
|
async function validateSuperstructSchema(state: any, schema: Struct<any, any>): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
|
const [err, result] = schema.validate(state)
|
||||||
|
if (err) {
|
||||||
|
const errors = err.failures().map(error => ({
|
||||||
|
message: error.message,
|
||||||
|
path: error.path.join('.')
|
||||||
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors,
|
||||||
|
result: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors: null,
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function validateYupSchema(
|
||||||
state: any,
|
state: any,
|
||||||
schema: ValibotSchema30 | ValibotSchemaAsync30 | ValibotSchema31 | ValibotSchemaAsync31 | ValibotSafeParser31<any, any> | ValibotSafeParserAsync31<any, any> | ValibotSchema | ValibotSchemaAsync | ValibotSafeParser<any, any> | ValibotSafeParserAsync<any, any>
|
schema: YupObjectSchema<any>
|
||||||
): Promise<FormError[]> {
|
): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
const result = await ('_parse' in schema ? schema._parse(state) : '_run' in schema ? schema._run({ typed: false, value: state }, {}) : schema(state))
|
try {
|
||||||
return result.issues?.map((issue) => ({
|
const result = await schema.validate(state, { abortEarly: false })
|
||||||
// We know that the key for a form schema is always a string or a number
|
return {
|
||||||
path: issue.path?.map((item) => item.key).join('.') || '',
|
errors: null,
|
||||||
|
result
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (isYupError(error)) {
|
||||||
|
const errors = error.inner.map(issue => ({
|
||||||
|
path: issue.path ?? '',
|
||||||
message: issue.message
|
message: issue.message
|
||||||
})) || []
|
}))
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors,
|
||||||
|
result: null
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseSchema(state: any, schema: Schema): Promise<ValidateReturnSchema<typeof state>> {
|
||||||
|
if (isStandardSchema(schema)) {
|
||||||
|
return validateStandardSchema(state, schema)
|
||||||
|
} else if (isZodSchema(schema)) {
|
||||||
|
return validateZodSchema(state, schema)
|
||||||
|
} else if (isJoiSchema(schema)) {
|
||||||
|
return validateJoiSchema(state, schema)
|
||||||
|
} else if (isValibotSchema(schema)) {
|
||||||
|
return validateValibotSchema(state, schema)
|
||||||
|
} else if (isYupSchema(schema)) {
|
||||||
|
return validateYupSchema(state, schema)
|
||||||
|
} else if (isSuperStructSchema(schema)) {
|
||||||
|
return validateSuperstructSchema(state, schema)
|
||||||
|
} else {
|
||||||
|
throw new Error('Form validation failed: Unsupported form schema')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default defineComponent({
|
|||||||
const error = computed(() => {
|
const error = computed(() => {
|
||||||
return (props.error && typeof props.error === 'string') || typeof props.error === 'boolean'
|
return (props.error && typeof props.error === 'string') || typeof props.error === 'boolean'
|
||||||
? props.error
|
? props.error
|
||||||
: formErrors?.value?.find((error) => error.path === props.name)?.message
|
: formErrors?.value?.find(error => error.path === props.name)?.message
|
||||||
})
|
})
|
||||||
|
|
||||||
const size = computed(() => ui.value.size[props.size ?? config.default.size])
|
const size = computed(() => ui.value.size[props.size ?? config.default.size])
|
||||||
|
|||||||
@@ -33,12 +33,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, computed, toRef, onMounted, defineComponent } from 'vue'
|
import { ref, computed, toRef, onMounted, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
|
import UIcon from '../elements/Icon.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig, looseToNumber } from '../../utils'
|
import { looseToNumber, mergeConfig, twMerge } from '../../utils'
|
||||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { InputSize, InputColor, InputVariant, Strategy, DeepPartial } from '../../types/index'
|
import type { InputSize, InputColor, InputVariant, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -158,7 +158,7 @@ export default defineComponent({
|
|||||||
default: () => ({})
|
default: () => ({})
|
||||||
},
|
},
|
||||||
modelModifiers: {
|
modelModifiers: {
|
||||||
type: Object as PropType<{ trim?: boolean, lazy?: boolean, number?: boolean }>,
|
type: Object as PropType<{ trim?: boolean, lazy?: boolean, number?: boolean, nullify?: boolean }>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -172,7 +172,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const size = computed(() => sizeButtonGroup.value ?? sizeFormGroup.value)
|
const size = computed(() => sizeButtonGroup.value ?? sizeFormGroup.value)
|
||||||
|
|
||||||
const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false }))
|
const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false, nullify: false }))
|
||||||
|
|
||||||
const input = ref<HTMLInputElement | null>(null)
|
const input = ref<HTMLInputElement | null>(null)
|
||||||
|
|
||||||
@@ -184,7 +184,6 @@ export default defineComponent({
|
|||||||
|
|
||||||
// Custom function to handle the v-model properties
|
// Custom function to handle the v-model properties
|
||||||
const updateInput = (value: string) => {
|
const updateInput = (value: string) => {
|
||||||
|
|
||||||
if (modelModifiers.value.trim) {
|
if (modelModifiers.value.trim) {
|
||||||
value = value.trim()
|
value = value.trim()
|
||||||
}
|
}
|
||||||
@@ -193,6 +192,10 @@ export default defineComponent({
|
|||||||
value = looseToNumber(value)
|
value = looseToNumber(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modelModifiers.value.nullify) {
|
||||||
|
value ||= null
|
||||||
|
}
|
||||||
|
|
||||||
emit('update:modelValue', value)
|
emit('update:modelValue', value)
|
||||||
emitFormInput()
|
emitFormInput()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
v-slot="{ active, selected, disabled: optionDisabled }"
|
v-slot="{ active, selected, disabled: optionDisabled }"
|
||||||
:key="index"
|
:key="index"
|
||||||
as="template"
|
as="template"
|
||||||
:value="valueAttribute ? option[valueAttribute] : option"
|
:value="valueAttribute ? accessor(option, valueAttribute) : option"
|
||||||
:disabled="option.disabled"
|
:disabled="option.disabled"
|
||||||
>
|
>
|
||||||
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive, selected && uiMenu.option.selected, optionDisabled && uiMenu.option.disabled]">
|
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive, selected && uiMenu.option.selected, optionDisabled && uiMenu.option.disabled]">
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
/>
|
/>
|
||||||
<span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
|
<span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
|
||||||
|
|
||||||
<span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : option[optionAttribute] }}</span>
|
<span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : accessor(option, optionAttribute) }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -75,12 +75,12 @@
|
|||||||
|
|
||||||
<p v-if="query && !filteredOptions.length" :class="uiMenu.option.empty">
|
<p v-if="query && !filteredOptions.length" :class="uiMenu.option.empty">
|
||||||
<slot name="option-empty" :query="query">
|
<slot name="option-empty" :query="query">
|
||||||
No results for "{{ query }}".
|
{{ uiMenu.default.optionEmpty.label.replace('{query}', query) }}
|
||||||
</slot>
|
</slot>
|
||||||
</p>
|
</p>
|
||||||
<p v-else-if="!filteredOptions.length" :class="uiMenu.empty">
|
<p v-else-if="!filteredOptions.length" :class="uiMenu.empty">
|
||||||
<slot name="empty" :query="query">
|
<slot name="empty" :query="query">
|
||||||
No options.
|
{{ uiMenu.default.empty.label }}
|
||||||
</slot>
|
</slot>
|
||||||
</p>
|
</p>
|
||||||
</HComboboxOptions>
|
</HComboboxOptions>
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, computed, toRef, watch, defineComponent } from 'vue'
|
import { ref, computed, toRef, watch, defineComponent, toRaw } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import {
|
import {
|
||||||
Combobox as HCombobox,
|
Combobox as HCombobox,
|
||||||
@@ -103,13 +103,14 @@ import {
|
|||||||
} from '@headlessui/vue'
|
} from '@headlessui/vue'
|
||||||
import { computedAsync, useDebounceFn } from '@vueuse/core'
|
import { computedAsync, useDebounceFn } from '@vueuse/core'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
|
import { isEqual } from 'ohash/utils'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import UAvatar from '../elements/Avatar.vue'
|
import UAvatar from '../elements/Avatar.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { usePopper } from '../../composables/usePopper'
|
import { usePopper } from '../../composables/usePopper'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { get, mergeConfig } from '../../utils'
|
import { get, mergeConfig, twMerge } from '../../utils'
|
||||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { InputSize, InputColor, InputVariant, PopperOptions, Strategy, DeepPartial } from '../../types/index'
|
import type { InputSize, InputColor, InputVariant, PopperOptions, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -292,6 +293,24 @@ export default defineComponent({
|
|||||||
|
|
||||||
const size = computed(() => sizeButtonGroup.value ?? sizeFormGroup.value)
|
const size = computed(() => sizeButtonGroup.value ?? sizeFormGroup.value)
|
||||||
|
|
||||||
|
const by = computed(() => {
|
||||||
|
if (!props.by) return undefined
|
||||||
|
|
||||||
|
if (typeof props.by === 'function') {
|
||||||
|
return props.by
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = props.by
|
||||||
|
const hasDot = key.indexOf('.')
|
||||||
|
if (hasDot > 0) {
|
||||||
|
return (a: any, z: any) => {
|
||||||
|
return accessor(a, key) === accessor(z, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return key
|
||||||
|
})
|
||||||
|
|
||||||
const internalQuery = ref('')
|
const internalQuery = ref('')
|
||||||
const query = computed({
|
const query = computed({
|
||||||
get() {
|
get() {
|
||||||
@@ -304,15 +323,33 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const label = computed(() => {
|
const label = computed(() => {
|
||||||
if (!props.modelValue) {
|
if (!props.modelValue) return null
|
||||||
return
|
|
||||||
|
function getValue(value: any) {
|
||||||
|
if (props.valueAttribute) {
|
||||||
|
return accessor(value, props.valueAttribute)
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
function compareValues(value1: any, value2: any) {
|
||||||
|
if (by.value && typeof by.value !== 'function' && typeof value1 === 'object' && typeof value2 === 'object') {
|
||||||
|
return isEqual(value1[props.by], value2[props.by])
|
||||||
|
}
|
||||||
|
return isEqual(value1, value2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.valueAttribute) {
|
if (props.valueAttribute) {
|
||||||
const option = options.value.find(option => option[props.valueAttribute] === props.modelValue)
|
const option = options.value.find((option) => {
|
||||||
return option ? option[props.optionAttribute] : null
|
const optionValue = getValue(option)
|
||||||
|
|
||||||
|
return compareValues(optionValue, props.modelValue)
|
||||||
|
})
|
||||||
|
|
||||||
|
return option ? accessor(option, props.optionAttribute) : null
|
||||||
} else {
|
} else {
|
||||||
return ['string', 'number'].includes(typeof props.modelValue) ? props.modelValue : props.modelValue[props.optionAttribute]
|
return ['string', 'number'].includes(typeof props.modelValue) ? props.modelValue : accessor(props.modelValue as Record<string, any>, props.optionAttribute)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -401,20 +438,26 @@ export default defineComponent({
|
|||||||
lazy: props.searchLazy
|
lazy: props.searchLazy
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function escapeRegExp(string: string) {
|
||||||
|
return string.replace(/[.*+?^${}()|[\]\\]/g, match => `\\${match}`)
|
||||||
|
}
|
||||||
|
|
||||||
const filteredOptions = computed(() => {
|
const filteredOptions = computed(() => {
|
||||||
if (!query.value || debouncedSearch) {
|
if (!query.value || debouncedSearch) {
|
||||||
return options.value
|
return options.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const escapedQuery = escapeRegExp(query.value)
|
||||||
|
|
||||||
return options.value.filter((option: any) => {
|
return options.value.filter((option: any) => {
|
||||||
return (props.searchAttributes?.length ? props.searchAttributes : [props.optionAttribute]).some((searchAttribute: any) => {
|
return (props.searchAttributes?.length ? props.searchAttributes : [props.optionAttribute]).some((searchAttribute: any) => {
|
||||||
if (['string', 'number'].includes(typeof option)) {
|
if (['string', 'number'].includes(typeof option)) {
|
||||||
return String(option).search(new RegExp(query.value, 'i')) !== -1
|
return String(option).search(new RegExp(escapedQuery, 'i')) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
const child = get(option, searchAttribute)
|
const child = get(option, searchAttribute)
|
||||||
|
|
||||||
return child !== null && child !== undefined && String(child).search(new RegExp(query.value, 'i')) !== -1
|
return child !== null && child !== undefined && String(child).search(new RegExp(escapedQuery, 'i')) !== -1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -430,12 +473,21 @@ export default defineComponent({
|
|||||||
|
|
||||||
function onUpdate(value: any) {
|
function onUpdate(value: any) {
|
||||||
query.value = ''
|
query.value = ''
|
||||||
|
|
||||||
|
if (toRaw(props.modelValue) === toRaw(value)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
emit('update:modelValue', value)
|
emit('update:modelValue', value)
|
||||||
emit('change', value)
|
emit('change', value)
|
||||||
|
|
||||||
emitFormChange()
|
emitFormChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function accessor<T extends Record<string, any>>(obj: T, key: string) {
|
||||||
|
return get(obj, key)
|
||||||
|
}
|
||||||
|
|
||||||
function onQueryChange(event: any) {
|
function onQueryChange(event: any) {
|
||||||
query.value = event.target.value
|
query.value = event.target.value
|
||||||
}
|
}
|
||||||
@@ -469,8 +521,11 @@ export default defineComponent({
|
|||||||
filteredOptions,
|
filteredOptions,
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
query,
|
query,
|
||||||
|
accessor,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onQueryChange
|
onQueryChange,
|
||||||
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
|
by
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -31,15 +31,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, inject, toRef } from 'vue'
|
import { computed, defineComponent, inject, toRef } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import type { DeepPartial, Strategy } from '../../types/index'
|
import type { DeepPartial, Strategy } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { radio } from '#ui/ui.config'
|
import { radio } from '#ui/ui.config'
|
||||||
import colors from '#ui-colors'
|
import type colors from '#ui-colors'
|
||||||
import { useId } from '#imports'
|
import { useId } from '#imports'
|
||||||
|
|
||||||
const config = mergeConfig<typeof radio>(appConfig.ui.strategy, appConfig.ui.radio, radio)
|
const config = mergeConfig<typeof radio>(appConfig.ui.strategy, appConfig.ui.radio, radio)
|
||||||
|
|||||||
@@ -17,11 +17,11 @@
|
|||||||
:ui="uiRadio"
|
:ui="uiRadio"
|
||||||
@change="onUpdate(option.value)"
|
@change="onUpdate(option.value)"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template v-if="$slots.label" #label>
|
||||||
<slot name="label" v-bind="{ option, selected: option.selected }" />
|
<slot name="label" v-bind="{ option, selected: option.selected }" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #help>
|
<template v-if="$slots.help" #help>
|
||||||
<slot name="help" v-bind="{ option, selected: option.selected }" />
|
<slot name="help" v-bind="{ option, selected: option.selected }" />
|
||||||
</template>
|
</template>
|
||||||
</URadio>
|
</URadio>
|
||||||
@@ -30,17 +30,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import URadio from './Radio.vue'
|
|
||||||
import { computed, defineComponent, provide, toRef } from 'vue'
|
import { computed, defineComponent, provide, toRef } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig, get } from '../../utils'
|
import { get, mergeConfig } from '../../utils'
|
||||||
import type { DeepPartial, Strategy } from '../../types/index'
|
import type { DeepPartial, Strategy } from '../../types/index'
|
||||||
|
import URadio from './Radio.vue'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
import { radioGroup, radio } from '#ui/ui.config'
|
import { radioGroup, radio } from '#ui/ui.config'
|
||||||
import colors from '#ui-colors'
|
import type colors from '#ui-colors'
|
||||||
|
|
||||||
const config = mergeConfig<typeof radioGroup>(appConfig.ui.strategy, appConfig.ui.radioGroup, radioGroup)
|
const config = mergeConfig<typeof radioGroup>(appConfig.ui.strategy, appConfig.ui.radioGroup, radioGroup)
|
||||||
const configRadio = mergeConfig<typeof radio>(appConfig.ui.strategy, appConfig.ui.radio, radio)
|
const configRadio = mergeConfig<typeof radio>(appConfig.ui.strategy, appConfig.ui.radio, radio)
|
||||||
@@ -152,7 +152,7 @@ export default defineComponent({
|
|||||||
uiRadio,
|
uiRadio,
|
||||||
attrs,
|
attrs,
|
||||||
normalizedOptions,
|
normalizedOptions,
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
|
||||||
onUpdate
|
onUpdate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, toRef, defineComponent } from 'vue'
|
import { computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig } from '../../utils'
|
import { mergeConfig, twMerge } from '../../utils'
|
||||||
import type { RangeSize, RangeColor, Strategy, DeepPartial } from '../../types/index'
|
import type { RangeSize, RangeColor, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
|
|||||||
@@ -55,11 +55,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, toRef, defineComponent } from 'vue'
|
import { computed, toRef, defineComponent } from 'vue'
|
||||||
import type { PropType, ComputedRef } from 'vue'
|
import type { PropType, ComputedRef } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig, get } from '../../utils'
|
import { get, mergeConfig, twMerge } from '../../utils'
|
||||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { SelectSize, SelectColor, SelectVariant, Strategy, DeepPartial } from '../../types/index'
|
import type { SelectSize, SelectColor, SelectVariant, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
:value="modelValue"
|
:value="modelValue"
|
||||||
:required="required"
|
:required="required"
|
||||||
:class="uiMenu.required"
|
:class="uiMenu.required"
|
||||||
|
:form="inputTargetForm"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
@@ -71,7 +72,7 @@
|
|||||||
v-slot="{ active, selected: optionSelected, disabled: optionDisabled }"
|
v-slot="{ active, selected: optionSelected, disabled: optionDisabled }"
|
||||||
:key="index"
|
:key="index"
|
||||||
as="template"
|
as="template"
|
||||||
:value="valueAttribute ? option[valueAttribute] : option"
|
:value="valueAttribute ? accessor(option, valueAttribute) : option"
|
||||||
:disabled="option.disabled"
|
:disabled="option.disabled"
|
||||||
>
|
>
|
||||||
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive, optionSelected && uiMenu.option.selected, optionDisabled && uiMenu.option.disabled]">
|
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive, optionSelected && uiMenu.option.selected, optionDisabled && uiMenu.option.disabled]">
|
||||||
@@ -86,7 +87,7 @@
|
|||||||
/>
|
/>
|
||||||
<span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
|
<span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
|
||||||
|
|
||||||
<span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : option[optionAttribute] }}</span>
|
<span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : accessor(option, optionAttribute) }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -100,19 +101,19 @@
|
|||||||
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive]">
|
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive]">
|
||||||
<div :class="uiMenu.option.container">
|
<div :class="uiMenu.option.container">
|
||||||
<slot name="option-create" :option="createOption" :active="active" :selected="optionSelected">
|
<slot name="option-create" :option="createOption" :active="active" :selected="optionSelected">
|
||||||
<span :class="uiMenu.option.create">Create "{{ createOption[optionAttribute] }}"</span>
|
<span :class="uiMenu.option.create">Create "{{ typeof createOption === 'string' ? createOption : accessor(createOption, optionAttribute) }}"</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</component>
|
</component>
|
||||||
<p v-else-if="searchable && query && !filteredOptions?.length" :class="uiMenu.option.empty">
|
<p v-else-if="searchable && query && !filteredOptions?.length" :class="uiMenu.option.empty">
|
||||||
<slot name="option-empty" :query="query">
|
<slot name="option-empty" :query="query">
|
||||||
No results for "{{ query }}".
|
{{ uiMenu.default.optionEmpty.label.replace('{query}', query) }}
|
||||||
</slot>
|
</slot>
|
||||||
</p>
|
</p>
|
||||||
<p v-else-if="!filteredOptions?.length" :class="uiMenu.empty">
|
<p v-else-if="!filteredOptions?.length" :class="uiMenu.empty">
|
||||||
<slot name="empty" :query="query">
|
<slot name="empty" :query="query">
|
||||||
No options.
|
{{ uiMenu.default.empty.label }}
|
||||||
</slot>
|
</slot>
|
||||||
</p>
|
</p>
|
||||||
</component>
|
</component>
|
||||||
@@ -123,7 +124,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, computed, toRef, watch, defineComponent } from 'vue'
|
import { ref, computed, toRef, watch, defineComponent, toRaw } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import {
|
import {
|
||||||
Combobox as HCombobox,
|
Combobox as HCombobox,
|
||||||
@@ -139,13 +140,14 @@ import {
|
|||||||
} from '@headlessui/vue'
|
} from '@headlessui/vue'
|
||||||
import { computedAsync, useDebounceFn } from '@vueuse/core'
|
import { computedAsync, useDebounceFn } from '@vueuse/core'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
|
import { isEqual } from 'ohash/utils'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import UAvatar from '../elements/Avatar.vue'
|
import UAvatar from '../elements/Avatar.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { usePopper } from '../../composables/usePopper'
|
import { usePopper } from '../../composables/usePopper'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { get, mergeConfig } from '../../utils'
|
import { get, mergeConfig, twMerge } from '../../utils'
|
||||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||||
import type { SelectSize, SelectColor, SelectVariant, PopperOptions, Strategy, DeepPartial } from '../../types/index'
|
import type { SelectSize, SelectColor, SelectVariant, PopperOptions, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -247,7 +249,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
searchablePlaceholder: {
|
searchablePlaceholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'Search...'
|
default: () => configMenu.default.searchablePlaceholder.label
|
||||||
},
|
},
|
||||||
searchableLazy: {
|
searchableLazy: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -313,6 +315,10 @@ export default defineComponent({
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
inputTargetForm: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
popper: {
|
popper: {
|
||||||
type: Object as PropType<PopperOptions>,
|
type: Object as PropType<PopperOptions>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
@@ -347,6 +353,24 @@ export default defineComponent({
|
|||||||
|
|
||||||
const [trigger, container] = usePopper(popper.value)
|
const [trigger, container] = usePopper(popper.value)
|
||||||
|
|
||||||
|
const by = computed(() => {
|
||||||
|
if (!props.by) return undefined
|
||||||
|
|
||||||
|
if (typeof props.by === 'function') {
|
||||||
|
return props.by
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = props.by
|
||||||
|
const hasDot = key.indexOf('.')
|
||||||
|
if (hasDot > 0) {
|
||||||
|
return (a: any, z: any) => {
|
||||||
|
return accessor(a, key) === accessor(z, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return key
|
||||||
|
})
|
||||||
|
|
||||||
const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props })
|
const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props })
|
||||||
const { emitFormBlur, emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config)
|
const { emitFormBlur, emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config)
|
||||||
|
|
||||||
@@ -364,39 +388,49 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const selected = computed(() => {
|
const selected = computed(() => {
|
||||||
|
function compareValues(value1: any, value2: any) {
|
||||||
|
if (by.value && typeof by.value !== 'function' && typeof value1 === 'object' && typeof value2 === 'object') {
|
||||||
|
return isEqual(value1[by.value], value2[by.value])
|
||||||
|
}
|
||||||
|
return isEqual(value1, value2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getValue(value: any) {
|
||||||
|
if (props.valueAttribute) {
|
||||||
|
return accessor(value, props.valueAttribute)
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
if (props.multiple) {
|
if (props.multiple) {
|
||||||
if (!Array.isArray(props.modelValue) || !props.modelValue.length) {
|
const modelValue = props.modelValue
|
||||||
|
if (!Array.isArray(modelValue) || !modelValue.length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.valueAttribute) {
|
return options.value.filter((option) => {
|
||||||
return options.value.filter(option => (props.modelValue as any[]).includes(option[props.valueAttribute]))
|
const optionValue = getValue(option)
|
||||||
}
|
return modelValue.some(value => compareValues(value, optionValue))
|
||||||
return options.value.filter(option => (props.modelValue as any[]).includes(option))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.valueAttribute) {
|
return options.value.find((option) => {
|
||||||
return options.value.find(option => option[props.valueAttribute] === props.modelValue)
|
const optionValue = getValue(option)
|
||||||
}
|
return compareValues(optionValue, toRaw(props.modelValue))
|
||||||
return options.value.find(option => option === props.modelValue)
|
}) ?? props.modelValue
|
||||||
})
|
})
|
||||||
|
|
||||||
const label = computed(() => {
|
const label = computed(() => {
|
||||||
if (props.multiple) {
|
if (!props.modelValue) return null
|
||||||
|
|
||||||
if (Array.isArray(props.modelValue) && props.modelValue.length) {
|
if (Array.isArray(props.modelValue) && props.modelValue.length) {
|
||||||
return `${selected.value.length} selected`
|
return `${props.modelValue.length} selected`
|
||||||
} else {
|
} else if (['string', 'number'].includes(typeof props.modelValue)) {
|
||||||
return null
|
return props.valueAttribute ? accessor(selected.value, props.optionAttribute) : props.modelValue
|
||||||
}
|
|
||||||
} else if (props.modelValue !== undefined && props.modelValue !== null) {
|
|
||||||
if (props.valueAttribute) {
|
|
||||||
return selected.value?.[props.optionAttribute] ?? null
|
|
||||||
} else {
|
|
||||||
return ['string', 'number'].includes(typeof props.modelValue) ? props.modelValue : props.modelValue[props.optionAttribute]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return accessor(props.modelValue as Record<string, any>, props.optionAttribute)
|
||||||
})
|
})
|
||||||
|
|
||||||
const selectClass = computed(() => {
|
const selectClass = computed(() => {
|
||||||
@@ -485,20 +519,30 @@ export default defineComponent({
|
|||||||
lazy: props.searchableLazy
|
lazy: props.searchableLazy
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function escapeRegExp(string: string) {
|
||||||
|
return string.replace(/[.*+?^${}()|[\]\\]/g, match => `\\${match}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function accessor<T extends Record<string, any>>(obj: T, key: string) {
|
||||||
|
return get(obj, key)
|
||||||
|
}
|
||||||
|
|
||||||
const filteredOptions = computed(() => {
|
const filteredOptions = computed(() => {
|
||||||
if (!query.value || debouncedSearch) {
|
if (!query.value || debouncedSearch) {
|
||||||
return options.value
|
return options.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const escapedQuery = escapeRegExp(query.value)
|
||||||
|
|
||||||
return options.value.filter((option: any) => {
|
return options.value.filter((option: any) => {
|
||||||
return (props.searchAttributes?.length ? props.searchAttributes : [props.optionAttribute]).some((searchAttribute: any) => {
|
return (props.searchAttributes?.length ? props.searchAttributes : [props.optionAttribute]).some((searchAttribute: any) => {
|
||||||
if (['string', 'number'].includes(typeof option)) {
|
if (['string', 'number'].includes(typeof option)) {
|
||||||
return String(option).search(new RegExp(query.value, 'i')) !== -1
|
return String(option).search(new RegExp(escapedQuery, 'i')) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
const child = get(option, searchAttribute)
|
const child = get(option, searchAttribute)
|
||||||
|
|
||||||
return child !== null && child !== undefined && String(child).search(new RegExp(query.value, 'i')) !== -1
|
return child !== null && child !== undefined && String(child).search(new RegExp(escapedQuery, 'i')) !== -1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -511,7 +555,7 @@ export default defineComponent({
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
if (props.showCreateOptionWhen === 'always') {
|
if (props.showCreateOptionWhen === 'always') {
|
||||||
const existingOption = filteredOptions.value.find(option => ['string', 'number'].includes(typeof option) ? option === query.value : option[props.optionAttribute] === query.value)
|
const existingOption = filteredOptions.value.find(option => ['string', 'number'].includes(typeof option) ? option === query.value : accessor(option, props.optionAttribute) === query.value)
|
||||||
if (existingOption) {
|
if (existingOption) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -541,6 +585,10 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function onUpdate(value: any) {
|
function onUpdate(value: any) {
|
||||||
|
if (toRaw(props.modelValue) === value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
emit('update:modelValue', value)
|
emit('update:modelValue', value)
|
||||||
emit('change', value)
|
emit('change', value)
|
||||||
emitFormChange()
|
emitFormChange()
|
||||||
@@ -567,6 +615,7 @@ export default defineComponent({
|
|||||||
container,
|
container,
|
||||||
selected,
|
selected,
|
||||||
label,
|
label,
|
||||||
|
accessor,
|
||||||
isLeading,
|
isLeading,
|
||||||
isTrailing,
|
isTrailing,
|
||||||
// eslint-disable-next-line vue/no-dupe-keys
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
@@ -582,7 +631,9 @@ export default defineComponent({
|
|||||||
// eslint-disable-next-line vue/no-dupe-keys
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
query,
|
query,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onQueryChange
|
onQueryChange,
|
||||||
|
// eslint-disable-next-line vue/no-dupe-keys
|
||||||
|
by
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,11 +23,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, computed, toRef, watch, onMounted, nextTick, defineComponent } from 'vue'
|
import { ref, computed, toRef, watch, onMounted, nextTick, defineComponent } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twJoin } from 'tailwind-merge'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
import { useFormGroup } from '../../composables/useFormGroup'
|
import { useFormGroup } from '../../composables/useFormGroup'
|
||||||
import { mergeConfig, looseToNumber } from '../../utils'
|
import { looseToNumber, mergeConfig, twMerge } from '../../utils'
|
||||||
import type { TextareaSize, TextareaColor, TextareaVariant, Strategy, DeepPartial } from '../../types/index'
|
import type { TextareaSize, TextareaColor, TextareaVariant, Strategy, DeepPartial } from '../../types/index'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import appConfig from '#build/app.config'
|
import appConfig from '#build/app.config'
|
||||||
@@ -127,7 +127,7 @@ export default defineComponent({
|
|||||||
default: () => ({})
|
default: () => ({})
|
||||||
},
|
},
|
||||||
modelModifiers: {
|
modelModifiers: {
|
||||||
type: Object as PropType<{ trim?: boolean, lazy?: boolean, number?: boolean }>,
|
type: Object as PropType<{ trim?: boolean, lazy?: boolean, number?: boolean, nullify?: boolean }>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -137,7 +137,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config)
|
const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config)
|
||||||
|
|
||||||
const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false }))
|
const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false, nullify: false }))
|
||||||
|
|
||||||
const textarea = ref<HTMLTextAreaElement | null>(null)
|
const textarea = ref<HTMLTextAreaElement | null>(null)
|
||||||
|
|
||||||
@@ -158,10 +158,10 @@ export default defineComponent({
|
|||||||
textarea.value.style.overflow = 'hidden'
|
textarea.value.style.overflow = 'hidden'
|
||||||
|
|
||||||
const styles = window.getComputedStyle(textarea.value)
|
const styles = window.getComputedStyle(textarea.value)
|
||||||
const paddingTop = parseInt(styles.paddingTop)
|
const paddingTop = Number.parseInt(styles.paddingTop)
|
||||||
const paddingBottom = parseInt(styles.paddingBottom)
|
const paddingBottom = Number.parseInt(styles.paddingBottom)
|
||||||
const padding = paddingTop + paddingBottom
|
const padding = paddingTop + paddingBottom
|
||||||
const lineHeight = parseInt(styles.lineHeight)
|
const lineHeight = Number.parseInt(styles.lineHeight)
|
||||||
const { scrollHeight } = textarea.value
|
const { scrollHeight } = textarea.value
|
||||||
const newRows = (scrollHeight - padding) / lineHeight
|
const newRows = (scrollHeight - padding) / lineHeight
|
||||||
|
|
||||||
@@ -183,6 +183,10 @@ export default defineComponent({
|
|||||||
value = looseToNumber(value)
|
value = looseToNumber(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modelModifiers.value.nullify) {
|
||||||
|
value ||= null
|
||||||
|
}
|
||||||
|
|
||||||
emit('update:modelValue', value)
|
emit('update:modelValue', value)
|
||||||
emitFormInput()
|
emitFormInput()
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user