mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-20 15:01:46 +01:00
Compare commits
146 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ecd7cefde | ||
|
|
aafdfdb59c | ||
|
|
453ff6ca20 | ||
|
|
55832b6b99 | ||
|
|
6b93bbe5cd | ||
|
|
1402553145 | ||
|
|
5d84dfd05b | ||
|
|
7dc59a05ec | ||
|
|
4bd994985d | ||
|
|
c83d3b7147 | ||
|
|
f022665351 | ||
|
|
f29c325dc7 | ||
|
|
876f9578c2 | ||
|
|
f69f584188 | ||
|
|
377b4189ca | ||
|
|
f76a9f0ab0 | ||
|
|
37b2271bf0 | ||
|
|
fa49d52f17 | ||
|
|
fd4b608150 | ||
|
|
fef93f3198 | ||
|
|
0826ef8d59 | ||
|
|
0e3066d865 | ||
|
|
fb9d6cb544 | ||
|
|
531a89cdb8 | ||
|
|
6970c2d665 | ||
|
|
9719ea3858 | ||
|
|
a4af6b3805 | ||
|
|
3493c138d9 | ||
|
|
d08e64d53f | ||
|
|
6aecb082d2 | ||
|
|
63e27f8b4b | ||
|
|
7970aefcb0 | ||
|
|
a893d7fa2e | ||
|
|
8ace629ff8 | ||
|
|
0d35b82ecb | ||
|
|
5f37077835 | ||
|
|
948f4b89b1 | ||
|
|
e6d0dd5898 | ||
|
|
4702a4f103 | ||
|
|
efa9674815 | ||
|
|
97d40395d3 | ||
|
|
a2fb22d835 | ||
|
|
d14a1a82c2 | ||
|
|
a566627a23 | ||
|
|
ee3352278c | ||
|
|
b1d9e01818 | ||
|
|
ca171f3095 | ||
|
|
c0e493d96a | ||
|
|
d0d3235860 | ||
|
|
18915975be | ||
|
|
f5d068be9d | ||
|
|
6018f009a8 | ||
|
|
2b78b5d7dc | ||
|
|
87f3f0b4c0 | ||
|
|
41bf56f2ae | ||
|
|
b7795f4ef6 | ||
|
|
57f8145a8d | ||
|
|
70fbcb6b24 | ||
|
|
bea47b5906 | ||
|
|
fc1b3b2f17 | ||
|
|
5bf5a314c4 | ||
|
|
3558eb1a4f | ||
|
|
1c4d46e056 | ||
|
|
1b0ed9e732 | ||
|
|
b72037a777 | ||
|
|
a7644860b8 | ||
|
|
c90cd9c4f3 | ||
|
|
7805168685 | ||
|
|
27717a55b3 | ||
|
|
d651a22dce | ||
|
|
c3ecbf4b20 | ||
|
|
d8b10f3eef | ||
|
|
1071b80b39 | ||
|
|
c5e9a1ef46 | ||
|
|
afe69a570d | ||
|
|
e6ed834cea | ||
|
|
30c5412a6b | ||
|
|
01f56d9553 | ||
|
|
91f273c117 | ||
|
|
cda8ce32a3 | ||
|
|
2bc0eb05d1 | ||
|
|
cfc4bdfbfe | ||
|
|
370d05921d | ||
|
|
b6455a151d | ||
|
|
8c0e0ec823 | ||
|
|
4f56921096 | ||
|
|
6a5ee32e05 | ||
|
|
4ea07e1077 | ||
|
|
5fd65d0917 | ||
|
|
2ec0cee1d9 | ||
|
|
758e6f1400 | ||
|
|
275fa1831d | ||
|
|
8b5e08f6f2 | ||
|
|
1635f57de6 | ||
|
|
b3e0122001 | ||
|
|
4f9d20e603 | ||
|
|
f7add47cf2 | ||
|
|
99c1c683eb | ||
|
|
ff9f6c251d | ||
|
|
e0c703ca6c | ||
|
|
2210faa160 | ||
|
|
19589b5e05 | ||
|
|
7051fa39a7 | ||
|
|
911278e95e | ||
|
|
c015148f29 | ||
|
|
cb1fd55801 | ||
|
|
16fd1c0ca3 | ||
|
|
84ac92ed7a | ||
|
|
0ade69de26 | ||
|
|
d9193abf55 | ||
|
|
44a78d7f67 | ||
|
|
3ce600f89a | ||
|
|
662dd9ee65 | ||
|
|
3be3751bfc | ||
|
|
5042b5806b | ||
|
|
2535301bcd | ||
|
|
629bb72424 | ||
|
|
543b4e025f | ||
|
|
7f18c6bdc7 | ||
|
|
0ea924ca0d | ||
|
|
22f3d42470 | ||
|
|
1ad96065fd | ||
|
|
952786ed79 | ||
|
|
9cf92e34ab | ||
|
|
6321d3ed8d | ||
|
|
bc0c168c0b | ||
|
|
9975305f2a | ||
|
|
edc1bd677b | ||
|
|
32d1f21299 | ||
|
|
f901e417e1 | ||
|
|
23921e1ae2 | ||
|
|
8a5f52dbc8 | ||
|
|
04d5ce1c51 | ||
|
|
3a300f72c1 | ||
|
|
927debfb6b | ||
|
|
44176ee897 | ||
|
|
7f9d69183c | ||
|
|
23e5f4c501 | ||
|
|
24998e3ac5 | ||
|
|
bebf18a89a | ||
|
|
1b56b50d4d | ||
|
|
3337559b89 | ||
|
|
d33a23ebc0 | ||
|
|
28586c35a5 | ||
|
|
e521e1ac24 | ||
|
|
8ea3223071 |
3
.github/workflows/ci-dev.yml
vendored
3
.github/workflows/ci-dev.yml
vendored
@@ -41,6 +41,9 @@ jobs:
|
|||||||
- name: Lint
|
- name: Lint
|
||||||
run: yarn lint
|
run: yarn lint
|
||||||
|
|
||||||
|
- name: Typecheck
|
||||||
|
run: yarn typecheck
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
|
|
||||||
|
|||||||
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -41,6 +41,9 @@ jobs:
|
|||||||
- name: Lint
|
- name: Lint
|
||||||
run: yarn lint
|
run: yarn lint
|
||||||
|
|
||||||
|
- name: Typecheck
|
||||||
|
run: yarn typecheck
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
|
|
||||||
|
|||||||
238
CHANGELOG.md
238
CHANGELOG.md
@@ -2,6 +2,244 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [1.2.7](https://github.com/nuxtlabs/ui/compare/v1.2.6...v1.2.7) (2023-04-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **useTimer:** remaining after pause ([aafdfdb](https://github.com/nuxtlabs/ui/commit/aafdfdb59c365c542f93703dd52b4306ac935040))
|
||||||
|
|
||||||
|
### [1.2.6](https://github.com/nuxtlabs/ui/compare/v1.2.5...v1.2.6) (2023-04-04)
|
||||||
|
|
||||||
|
### [1.2.5](https://github.com/nuxtlabs/ui/compare/v1.2.4...v1.2.5) (2023-04-04)
|
||||||
|
|
||||||
|
### [1.2.4](https://github.com/nuxtlabs/ui/compare/v1.2.3...v1.2.4) (2023-04-04)
|
||||||
|
|
||||||
|
### [1.2.3](https://github.com/nuxtlabs/ui/compare/v1.2.2...v1.2.3) (2023-03-22)
|
||||||
|
|
||||||
|
### [1.2.2](https://github.com/nuxtlabs/ui/compare/v1.2.1...v1.2.2) (2023-03-20)
|
||||||
|
|
||||||
|
### [1.2.1](https://github.com/nuxtlabs/ui/compare/v1.2.0...v1.2.1) (2023-03-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **defineShortcuts:** shift + alphabetic character handling ([#140](https://github.com/nuxtlabs/ui/issues/140)) ([377b418](https://github.com/nuxtlabs/ui/commit/377b4189ca85603db0b7f040949260ba7494c46f))
|
||||||
|
|
||||||
|
## [1.2.0](https://github.com/nuxtlabs/ui/compare/v1.1.4...v1.2.0) (2023-03-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **defineShortcuts:** add missing import ([37b2271](https://github.com/nuxtlabs/ui/commit/37b2271bf04adfe6bee4d984fa12452b2168318c))
|
||||||
|
* **Tooltip:** `shortcutsClass` prop type ([fa49d52](https://github.com/nuxtlabs/ui/commit/fa49d52f17752eaa06f997a9b6e8df8adcab983f))
|
||||||
|
|
||||||
|
### [1.1.4](https://github.com/nuxtlabs/ui/compare/v1.1.3...v1.1.4) (2023-03-02)
|
||||||
|
|
||||||
|
### [1.1.3](https://github.com/nuxtlabs/ui/compare/v1.1.2...v1.1.3) (2023-03-02)
|
||||||
|
|
||||||
|
### [1.1.2](https://github.com/nuxtlabs/ui/compare/v1.1.1...v1.1.2) (2023-02-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Tooltip:** truncate ([d08e64d](https://github.com/nuxtlabs/ui/commit/d08e64d53fa439f34d51909bcb6812f1bcd95d83))
|
||||||
|
* **VerticalNavigation:** links `to` type ([7970aef](https://github.com/nuxtlabs/ui/commit/7970aefcb032ce01fcb11e9285fa61ce87f59519))
|
||||||
|
|
||||||
|
### [1.1.1](https://github.com/nuxtlabs/ui/compare/v1.1.0...v1.1.1) (2023-02-20)
|
||||||
|
|
||||||
|
## [1.1.0](https://github.com/nuxtlabs/ui/compare/v1.0.0...v1.1.0) (2023-02-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **CommandPalette:** handle async search for specific groups ([efa9674](https://github.com/nuxtlabs/ui/commit/efa9674815ab4de756079690da0a381c3703d564))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **CommandPalette:** types ([4702a4f](https://github.com/nuxtlabs/ui/commit/4702a4f10379201c167cc52099519778756a5780))
|
||||||
|
|
||||||
|
## [1.0.0](https://github.com/nuxtlabs/ui/compare/v0.2.1...v1.0.0) (2023-02-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* migrate to `@egoist/tailwindcss-icons` ([ee33522](https://github.com/nuxtlabs/ui/commit/ee3352278cf03fdd12f2a4663b403052de3f089a))
|
||||||
|
|
||||||
|
### [0.2.1](https://github.com/nuxtlabs/ui/compare/v0.2.0...v0.2.1) (2023-02-16)
|
||||||
|
|
||||||
|
## [0.2.0](https://github.com/nuxtlabs/ui/compare/v0.1.39...v0.2.0) (2023-02-16)
|
||||||
|
|
||||||
|
### [0.1.39](https://github.com/nuxtlabs/ui/compare/v0.1.38...v0.1.39) (2023-02-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* use `nuxt-icon` ([f5d068b](https://github.com/nuxtlabs/ui/commit/f5d068be9d5778b3d4fcdc11d06d9d765e62075d))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **SelectCustom:** handle search on string arrays ([6018f00](https://github.com/nuxtlabs/ui/commit/6018f009a86cca196d15e4e72dd5eb41aaeb4bad))
|
||||||
|
|
||||||
|
### [0.1.38](https://github.com/nuxtlabs/ui/compare/v0.1.37...v0.1.38) (2023-02-03)
|
||||||
|
|
||||||
|
### [0.1.37](https://github.com/nuxtlabs/ui/compare/v0.1.36...v0.1.37) (2023-02-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **CommandPalette:** improve accessibility ([#129](https://github.com/nuxtlabs/ui/issues/129)) ([bea47b5](https://github.com/nuxtlabs/ui/commit/bea47b5906d1bc665717830d6dc2f3ff2a0374f3))
|
||||||
|
|
||||||
|
### [0.1.36](https://github.com/nuxtlabs/ui/compare/v0.1.35...v0.1.36) (2023-02-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **CommandPalette:** put back cursor on top only when query changes ([5bf5a31](https://github.com/nuxtlabs/ui/commit/5bf5a314c414b96c656190719bd56acca10676f5))
|
||||||
|
|
||||||
|
### [0.1.35](https://github.com/nuxtlabs/ui/compare/v0.1.34...v0.1.35) (2023-02-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **AvatarGroup:** preset size prop ([c90cd9c](https://github.com/nuxtlabs/ui/commit/c90cd9c4f37bc3ce5f6e13f3279dc2c574c76524))
|
||||||
|
* **Dropdown:** lint ([1c4d46e](https://github.com/nuxtlabs/ui/commit/1c4d46e056adf84d69462a12af8ac29f93cbf87a))
|
||||||
|
* **Dropdown:** prevent panel display when no items ([a764486](https://github.com/nuxtlabs/ui/commit/a7644860b8c22a0163e01ca2c0eab2c48b09745a))
|
||||||
|
|
||||||
|
### [0.1.34](https://github.com/nuxtlabs/ui/compare/v0.1.33...v0.1.34) (2023-01-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **CommandPalette:** typecheck ([27717a5](https://github.com/nuxtlabs/ui/commit/27717a55b3e5120f32fba2bcea30f5a91262f1c5))
|
||||||
|
|
||||||
|
### [0.1.33](https://github.com/nuxtlabs/ui/compare/v0.1.32...v0.1.33) (2023-01-27)
|
||||||
|
|
||||||
|
### [0.1.32](https://github.com/nuxtlabs/ui/compare/v0.1.31...v0.1.32) (2023-01-23)
|
||||||
|
|
||||||
|
### [0.1.31](https://github.com/nuxtlabs/ui/compare/v0.1.30...v0.1.31) (2023-01-17)
|
||||||
|
|
||||||
|
### [0.1.30](https://github.com/nuxtlabs/ui/compare/v0.1.29...v0.1.30) (2023-01-17)
|
||||||
|
|
||||||
|
### [0.1.29](https://github.com/nuxtlabs/ui/compare/v0.1.28...v0.1.29) (2023-01-17)
|
||||||
|
|
||||||
|
### [0.1.28](https://github.com/nuxtlabs/ui/compare/v0.1.27...v0.1.28) (2023-01-13)
|
||||||
|
|
||||||
|
### [0.1.27](https://github.com/nuxtlabs/ui/compare/v0.1.26...v0.1.27) (2023-01-12)
|
||||||
|
|
||||||
|
### [0.1.26](https://github.com/nuxtlabs/ui/compare/v0.1.25...v0.1.26) (2023-01-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **CommandPalette:** select first item on search changes ([#126](https://github.com/nuxtlabs/ui/issues/126)) ([4f56921](https://github.com/nuxtlabs/ui/commit/4f56921096f5885cdab8b7cb5c5aa01304188e11))
|
||||||
|
|
||||||
|
### [0.1.25](https://github.com/nuxtlabs/ui/compare/v0.1.24...v0.1.25) (2023-01-09)
|
||||||
|
|
||||||
|
### [0.1.24](https://github.com/nuxtlabs/ui/compare/v0.1.23...v0.1.24) (2023-01-04)
|
||||||
|
|
||||||
|
### [0.1.23](https://github.com/nuxtlabs/ui/compare/v0.1.22...v0.1.23) (2022-12-20)
|
||||||
|
|
||||||
|
### [0.1.22](https://github.com/nuxtlabs/ui/compare/v0.1.21...v0.1.22) (2022-12-19)
|
||||||
|
|
||||||
|
### [0.1.21](https://github.com/nuxtlabs/ui/compare/v0.1.20...v0.1.21) (2022-12-19)
|
||||||
|
|
||||||
|
### [0.1.20](https://github.com/nuxtlabs/ui/compare/v0.1.19...v0.1.20) (2022-12-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* avoid referring to complex types in props ([#123](https://github.com/nuxtlabs/ui/issues/123)) ([ff9f6c2](https://github.com/nuxtlabs/ui/commit/ff9f6c251df59641862d82587e5d963c8e6ea298))
|
||||||
|
|
||||||
|
### [0.1.19](https://github.com/nuxtlabs/ui/compare/v0.1.18...v0.1.19) (2022-12-16)
|
||||||
|
|
||||||
|
### [0.1.18](https://github.com/nuxtlabs/ui/compare/v0.1.17...v0.1.18) (2022-12-15)
|
||||||
|
|
||||||
|
### [0.1.17](https://github.com/nuxtlabs/ui/compare/v0.1.16...v0.1.17) (2022-12-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove stop propagation on mode hover ([16fd1c0](https://github.com/nuxtlabs/ui/commit/16fd1c0ca38f1438e791c0d44399f590d9f20d02))
|
||||||
|
|
||||||
|
### [0.1.16](https://github.com/nuxtlabs/ui/compare/v0.1.15...v0.1.16) (2022-12-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Popover:** preset from tooltip ([0ade69d](https://github.com/nuxtlabs/ui/commit/0ade69de2689b094b11a2dead8f71e3d2dccd552))
|
||||||
|
|
||||||
|
### [0.1.15](https://github.com/nuxtlabs/ui/compare/v0.1.14...v0.1.15) (2022-12-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Dropdown:** better handle item click to preventDefault ([#119](https://github.com/nuxtlabs/ui/issues/119)) ([44a78d7](https://github.com/nuxtlabs/ui/commit/44a78d7f679812c59d4410d0bbc01f09abaa78dd))
|
||||||
|
|
||||||
|
### [0.1.14](https://github.com/nuxtlabs/ui/compare/v0.1.13...v0.1.14) (2022-12-02)
|
||||||
|
|
||||||
|
### [0.1.13](https://github.com/nuxtlabs/ui/compare/v0.1.12...v0.1.13) (2022-12-01)
|
||||||
|
|
||||||
|
### [0.1.12](https://github.com/nuxtlabs/ui/compare/v0.1.11...v0.1.12) (2022-11-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Checkbox:** types ([629bb72](https://github.com/nuxtlabs/ui/commit/629bb724249cfe1fdd999cf52f8e72ca444bd94d))
|
||||||
|
|
||||||
|
### [0.1.11](https://github.com/nuxtlabs/ui/compare/v0.1.10...v0.1.11) (2022-11-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Checkbox:** revert type fix as it breaks checkboxes ([7f18c6b](https://github.com/nuxtlabs/ui/commit/7f18c6bdc7c0054b2e5d4f9bf4e362847a3ba3a3))
|
||||||
|
|
||||||
|
### [0.1.10](https://github.com/nuxtlabs/ui/compare/v0.1.9...v0.1.10) (2022-11-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* default popper options ([1ad9606](https://github.com/nuxtlabs/ui/commit/1ad96065fd706d828b906db3a5d578226ff08c36))
|
||||||
|
* default props for command palette ([#116](https://github.com/nuxtlabs/ui/issues/116)) ([952786e](https://github.com/nuxtlabs/ui/commit/952786ed79cd9cdf523f6eac5958f68790bacbea))
|
||||||
|
|
||||||
|
### [0.1.9](https://github.com/nuxtlabs/ui/compare/v0.1.8...v0.1.9) (2022-11-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Icon:** couldn't load anymore ([6321d3e](https://github.com/nuxtlabs/ui/commit/6321d3ed8d5c9478cb1dafc1da94b21d0c7edb88))
|
||||||
|
* **Icon:** eslint ignore ([bc0c168](https://github.com/nuxtlabs/ui/commit/bc0c168c0b0feae96d6a1848c3a356d846e2cbb5))
|
||||||
|
|
||||||
|
### [0.1.8](https://github.com/nuxtlabs/ui/compare/v0.1.7...v0.1.8) (2022-11-16)
|
||||||
|
|
||||||
|
### [0.1.7](https://github.com/nuxtlabs/ui/compare/v0.1.6...v0.1.7) (2022-11-16)
|
||||||
|
|
||||||
|
### [0.1.6](https://github.com/nuxtlabs/ui/compare/v0.1.5...v0.1.6) (2022-11-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **SelectCustom:** add `w-full` on `ComboboxButton` ([3a300f7](https://github.com/nuxtlabs/ui/commit/3a300f72c1eca756ffd8f07ab871bf9c7bd7868d))
|
||||||
|
|
||||||
|
### [0.1.5](https://github.com/nuxtlabs/ui/compare/v0.1.4...v0.1.5) (2022-11-08)
|
||||||
|
|
||||||
|
### [0.1.4](https://github.com/nuxtlabs/ui/compare/v0.1.3...v0.1.4) (2022-11-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **button:** support `RouteLocationRaw` type for `to` ([#112](https://github.com/nuxtlabs/ui/issues/112)) ([1b56b50](https://github.com/nuxtlabs/ui/commit/1b56b50d4d54a5cb9e5febacdf42867988ae6c5d))
|
||||||
|
|
||||||
|
### [0.1.3](https://github.com/nuxtlabs/ui/compare/v0.1.2...v0.1.3) (2022-11-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **docs:** component input string field ([e521e1a](https://github.com/nuxtlabs/ui/commit/e521e1ac2421dc331652f1ea4ac2b0b2959dc069))
|
||||||
|
* **types:** add missing field in command palette type ([#111](https://github.com/nuxtlabs/ui/issues/111)) ([28586c3](https://github.com/nuxtlabs/ui/commit/28586c35a558d9e925094f86e07acdb928d54ad7))
|
||||||
|
|
||||||
### [0.1.2](https://github.com/nuxtlabs/ui/compare/v0.1.1...v0.1.2) (2022-10-27)
|
### [0.1.2](https://github.com/nuxtlabs/ui/compare/v0.1.1...v0.1.2) (2022-10-27)
|
||||||
|
|
||||||
### [0.1.1](https://github.com/nuxtlabs/ui/compare/v0.1.0...v0.1.1) (2022-10-26)
|
### [0.1.1](https://github.com/nuxtlabs/ui/compare/v0.1.0...v0.1.1) (2022-10-26)
|
||||||
|
|||||||
12
build.config.ts
Normal file
12
build.config.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import fs from 'node:fs/promises'
|
||||||
|
import { join, resolve } from 'node:path'
|
||||||
|
import { defineBuildConfig } from 'unbuild'
|
||||||
|
|
||||||
|
export default defineBuildConfig({
|
||||||
|
hooks: {
|
||||||
|
'rollup:done': async (ctx) => {
|
||||||
|
// copy env.d.ts to dist
|
||||||
|
await fs.copyFile(resolve('src/env.d.ts'), join(ctx.options.outDir, 'env.d.ts'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
19
docs/app.vue
19
docs/app.vue
@@ -9,11 +9,11 @@
|
|||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center">
|
||||||
<ColorScheme placeholder="" tag="span">
|
<ColorScheme placeholder="" tag="span">
|
||||||
<UButton variant="transparent" :icon="colorMode.value === 'dark' ? 'heroicons-outline:moon' : 'heroicons-outline:sun'" @click="toggleDark" />
|
<UButton variant="transparent" :icon="colorMode.value === 'dark' ? 'i-heroicons-moon' : 'i-heroicons-sun'" @click="toggleDark" />
|
||||||
</ColorScheme>
|
</ColorScheme>
|
||||||
<UButton to="https://github.com/nuxtlabs/ui" target="_blank" variant="transparent" icon="fa-brands:github" />
|
<UButton to="https://github.com/nuxtlabs/ui" target="_blank" variant="transparent" icon="i-mdi-github" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</UContainer>
|
</UContainer>
|
||||||
@@ -59,7 +59,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
useMeta({
|
useHead({
|
||||||
|
title: '@nuxthq/ui',
|
||||||
|
meta: [
|
||||||
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1' }
|
||||||
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' }
|
||||||
|
],
|
||||||
bodyAttrs: {
|
bodyAttrs: {
|
||||||
class: 'antialiased font-sans text-gray-700 bg-gray-50 dark:bg-gray-900 dark:text-gray-200 bg-white dark:bg-black'
|
class: 'antialiased font-sans text-gray-700 bg-gray-50 dark:bg-gray-900 dark:text-gray-200 bg-white dark:bg-black'
|
||||||
}
|
}
|
||||||
@@ -72,12 +79,12 @@ const toggleDark = () => {
|
|||||||
|
|
||||||
const sections = [
|
const sections = [
|
||||||
{ label: 'Getting Started', links: [{ label: 'Usage', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] },
|
{ label: 'Getting Started', links: [{ label: 'Usage', to: '/' }, { label: 'Examples', to: '/examples' }, { label: 'Migration', to: '/migration' }, { label: 'Dark mode', to: '/dark' }] },
|
||||||
{ label: 'Elements', links: [{ label: 'Avatar', to: '/components/Avatar' }, { label: 'AvatarGroup', to: '/components/AvatarGroup' }, { label: 'Badge', to: '/components/Badge' }, { label: 'Button', to: '/components/Button' }, { label: 'Dropdown', to: '/components/Dropdown' }, { label: 'Icon', to: '/components/Icon' }] },
|
{ label: 'Elements', links: [{ label: 'Avatar', to: '/components/Avatar' }, { label: 'AvatarGroup', to: '/components/AvatarGroup' }, { label: 'Badge', to: '/components/Badge' }, { label: 'Button', to: '/components/Button' }, { label: 'Dropdown', to: '/components/Dropdown' }] },
|
||||||
{ label: 'Feedback', links: [{ label: 'Alert', to: '/components/Alert' }, { label: 'AlertDialog', to: '/components/AlertDialog' }] },
|
{ label: 'Feedback', links: [{ label: 'Alert', to: '/components/Alert' }, { label: 'AlertDialog', to: '/components/AlertDialog' }] },
|
||||||
{ label: 'Forms', links: [{ label: 'Checkbox', to: '/components/Checkbox' }, { label: 'Input', to: '/components/Input' }, { label: 'FormGroup', to: '/components/FormGroup' }, { label: 'Radio', to: '/components/Radio' }, { label: 'Select', to: '/components/Select' }, { label: 'SelectCustom', to: '/components/SelectCustom' }, { label: 'Textarea', to: '/components/Textarea' }, { label: 'Toggle', to: '/components/Toggle' }] },
|
{ label: 'Forms', links: [{ label: 'Checkbox', to: '/components/Checkbox' }, { label: 'Input', to: '/components/Input' }, { label: 'FormGroup', to: '/components/FormGroup' }, { label: 'Radio', to: '/components/Radio' }, { label: 'Select', to: '/components/Select' }, { label: 'SelectCustom', to: '/components/SelectCustom' }, { label: 'Textarea', to: '/components/Textarea' }, { label: 'Toggle', to: '/components/Toggle' }] },
|
||||||
{ label: 'Layout', links: [{ label: 'Card', to: '/components/Card' }, { label: 'Container', to: '/components/Container' }] },
|
{ label: 'Layout', links: [{ label: 'Card', to: '/components/Card' }, { label: 'Container', to: '/components/Container' }] },
|
||||||
{ label: 'Navigation', links: [{ label: 'Pills', to: '/components/Pills' }, { label: 'Tabs', to: '/components/Tabs' }, { label: 'VerticalNavigation', to: '/components/VerticalNavigation' }, { label: 'CommandPalette', to: '/components/CommandPalette' }] },
|
{ label: 'Navigation', links: [{ label: 'Pills', to: '/components/Pills' }, { label: 'Tabs', to: '/components/Tabs' }, { label: 'VerticalNavigation', to: '/components/VerticalNavigation' }, { label: 'CommandPalette', to: '/components/CommandPalette' }] },
|
||||||
{ label: 'Overlays', links: [{ label: 'Modal', to: '/components/Modal' }, { label: 'Notification', to: '/components/Notification' }, { label: 'Popover', to: '/components/Popover' }, { label: 'Slideover', to: '/components/Slideover' }, { label: 'Tooltip', to: '/components/Tooltip' }] }
|
{ label: 'Overlays', links: [{ label: 'ContextMenu', to: '/components/ContextMenu' }, { label: 'Modal', to: '/components/Modal' }, { label: 'Notification', to: '/components/Notification' }, { label: 'Popover', to: '/components/Popover' }, { label: 'Slideover', to: '/components/Slideover' }, { label: 'Tooltip', to: '/components/Tooltip' }] }
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ import nuxtUI from '../src/module'
|
|||||||
|
|
||||||
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
|
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
meta: {
|
app: {
|
||||||
title: '@nuxthq/ui',
|
head: {
|
||||||
meta: [
|
htmlAttrs: {
|
||||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1' }
|
lang: 'en'
|
||||||
],
|
}
|
||||||
link: [
|
}
|
||||||
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
// @ts-ignore
|
||||||
modules: [
|
modules: [
|
||||||
|
// @ts-ignore
|
||||||
nuxtUI
|
nuxtUI
|
||||||
],
|
],
|
||||||
components: {
|
components: {
|
||||||
@@ -25,6 +25,7 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
preset: {
|
preset: {
|
||||||
},
|
},
|
||||||
|
icons: ['heroicons', 'mdi'],
|
||||||
tailwindcss: {
|
tailwindcss: {
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<UButton
|
<UButton
|
||||||
class="absolute top-0 right-0"
|
class="absolute top-0 right-0"
|
||||||
:icon="copied ? 'heroicons-outline:clipboard-check' : 'heroicons-outline:clipboard-copy'"
|
:icon="copied ? 'i-heroicons-clipboard-document-check' : 'i-heroicons-clipboard-document'"
|
||||||
variant="transparent"
|
variant="transparent"
|
||||||
size="sm"
|
size="sm"
|
||||||
:custom-class="copied ? '!text-green-500' : ''"
|
:custom-class="copied ? '!text-green-500' : ''"
|
||||||
@@ -56,7 +56,6 @@
|
|||||||
v-if="prop.type === 'Boolean'"
|
v-if="prop.type === 'Boolean'"
|
||||||
v-model="prop.value"
|
v-model="prop.value"
|
||||||
:name="prop.key"
|
:name="prop.key"
|
||||||
:label="prop.key"
|
|
||||||
/>
|
/>
|
||||||
<USelect
|
<USelect
|
||||||
v-else-if="prop.values"
|
v-else-if="prop.values"
|
||||||
@@ -67,7 +66,7 @@
|
|||||||
size="sm"
|
size="sm"
|
||||||
/>
|
/>
|
||||||
<UInput
|
<UInput
|
||||||
v-else-if="prop.type === 'String' && typeof prop.value === 'string'"
|
v-else-if="prop.type === 'String'"
|
||||||
v-model="prop.value"
|
v-model="prop.value"
|
||||||
:name="prop.key"
|
:name="prop.key"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -121,6 +120,31 @@ const toggle = ref(false)
|
|||||||
const modal = ref(false)
|
const modal = ref(false)
|
||||||
const slideover = ref(false)
|
const slideover = ref(false)
|
||||||
|
|
||||||
|
const x = ref(0)
|
||||||
|
const y = ref(0)
|
||||||
|
const isContextMenuOpen = ref(false)
|
||||||
|
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('mousemove', ({ clientX, clientY }) => {
|
||||||
|
x.value = clientX
|
||||||
|
y.value = clientY
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function openContextMenu () {
|
||||||
|
const top = unref(y)
|
||||||
|
const left = unref(x)
|
||||||
|
|
||||||
|
virtualElement.value.getBoundingClientRect = () => ({
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
top,
|
||||||
|
left
|
||||||
|
})
|
||||||
|
isContextMenuOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
Button: {
|
Button: {
|
||||||
label: 'Button text'
|
label: 'Button text'
|
||||||
@@ -132,7 +156,9 @@ const defaultProps = {
|
|||||||
title: 'A new software update is available. See what’s new in version 2.0.4.'
|
title: 'A new software update is available. See what’s new in version 2.0.4.'
|
||||||
},
|
},
|
||||||
AlertDialog: {
|
AlertDialog: {
|
||||||
title: 'Are you sure you want to close this modal?',
|
icon: 'i-heroicons-exclamation-triangle',
|
||||||
|
title: 'Deactivate account',
|
||||||
|
description: 'Are you sure you want to deactivate your account? All of your data will be permanently removed from our servers forever. This action cannot be undone.',
|
||||||
modelValue: alertDialog,
|
modelValue: alertDialog,
|
||||||
'onUpdate:modelValue': (v) => { alertDialog.value = v },
|
'onUpdate:modelValue': (v) => { alertDialog.value = v },
|
||||||
component: {
|
component: {
|
||||||
@@ -154,21 +180,21 @@ const defaultProps = {
|
|||||||
items: [
|
items: [
|
||||||
[{
|
[{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
icon: 'heroicons-solid:pencil'
|
icon: 'i-heroicons-pencil-square-20-solid'
|
||||||
}, {
|
}, {
|
||||||
label: 'Duplicate',
|
label: 'Duplicate',
|
||||||
icon: 'heroicons-solid:duplicate'
|
icon: 'i-heroicons-document-duplicate-20-solid'
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
label: 'Archive',
|
label: 'Archive',
|
||||||
icon: 'heroicons-solid:archive'
|
icon: 'i-heroicons-archive-box-20-solid'
|
||||||
}, {
|
}, {
|
||||||
label: 'Move',
|
label: 'Move',
|
||||||
icon: 'heroicons-solid:external-link'
|
icon: 'i-heroicons-arrow-right-circle-20-solid'
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
icon: 'heroicons-solid:trash'
|
icon: 'i-heroicons-trash-20-solid'
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -176,22 +202,22 @@ const defaultProps = {
|
|||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
label: 'Home',
|
label: 'Home',
|
||||||
icon: 'heroicons-outline:home',
|
icon: 'i-heroicons-home',
|
||||||
to: '/'
|
to: '/'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Examples',
|
label: 'Examples',
|
||||||
icon: 'heroicons-outline:book-open',
|
icon: 'i-heroicons-book-open',
|
||||||
to: '/examples'
|
to: '/examples'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Migration',
|
label: 'Migration',
|
||||||
icon: 'heroicons-outline:refresh',
|
icon: 'i-heroicons-arrow-path',
|
||||||
to: '/migration'
|
to: '/migration'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'External link',
|
label: 'External link',
|
||||||
icon: 'heroicons-outline:external-link',
|
icon: 'i-heroicons-link',
|
||||||
to: 'https://google.fr',
|
to: 'https://google.fr',
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
}
|
}
|
||||||
@@ -207,7 +233,7 @@ const defaultProps = {
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
Icon: {
|
Icon: {
|
||||||
name: 'heroicons-outline:bell'
|
name: 'i-heroicons-bell'
|
||||||
},
|
},
|
||||||
Input: {
|
Input: {
|
||||||
name: 'input',
|
name: 'input',
|
||||||
@@ -259,6 +285,31 @@ const defaultProps = {
|
|||||||
title: 'Notification title',
|
title: 'Notification title',
|
||||||
callback: 'console.log(\'Timer expired\')'
|
callback: 'console.log(\'Timer expired\')'
|
||||||
},
|
},
|
||||||
|
ContextMenu: {
|
||||||
|
modelValue: isContextMenuOpen,
|
||||||
|
'onUpdate:modelValue': (v) => { isContextMenuOpen.value = v },
|
||||||
|
virtualElement,
|
||||||
|
component: {
|
||||||
|
name: 'Card',
|
||||||
|
props: {
|
||||||
|
variant: 'secondary',
|
||||||
|
label: 'Open context menu',
|
||||||
|
onClick: () => { isContextMenuOpen.value = false },
|
||||||
|
onContextmenu: (e) => {
|
||||||
|
e?.preventDefault()
|
||||||
|
openContextMenu()
|
||||||
|
},
|
||||||
|
class: 'relative w-[300px] h-[100px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
default: {
|
||||||
|
tag: 'div',
|
||||||
|
html: 'Context menu content',
|
||||||
|
class: 'rounded border u-border-gray-200 p-2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
Modal: {
|
Modal: {
|
||||||
modelValue: modal,
|
modelValue: modal,
|
||||||
'onUpdate:modelValue': (v) => { modal.value = v },
|
'onUpdate:modelValue': (v) => { modal.value = v },
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
Button:
|
Button:
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UButton variant="primary" icon="heroicons-outline:mail">
|
<UButton variant="primary" icon="i-heroicons-envelope">
|
||||||
Button text
|
Button text
|
||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<UModal v-model="isModalOpen" @submit.prevent="onSubmit">
|
<UModal v-model="isModalOpen" @submit.prevent="onSubmit">
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||||
<UIcon name="heroicons-outline:exclamation" class="h-6 w-6 text-red-600" aria-hidden="true" />
|
<UIcon name="i-heroicons-exclamation" class="h-6 w-6 text-red-600" aria-hidden="true" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
||||||
<h3 class="text-lg leading-6 font-medium u-text-gray-900">
|
<h3 class="text-lg leading-6 font-medium u-text-gray-900">
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UDropdown v-slot="{ open }" :items="dropdownItems" placement="bottom-start">
|
<UDropdown v-slot="{ open }" :items="dropdownItems" placement="bottom-start">
|
||||||
<UButton variant="white" :icon="open ? 'heroicons-solid:chevron-up' : 'heroicons-solid:chevron-down'" trailing icon-class="transition">
|
<UButton variant="white" :icon="open ? 'i-heroicons-chevron-up-20-solid' : 'i-heroicons-chevron-down-20-solid'" trailing icon-class="transition">
|
||||||
Open menu!
|
Open menu!
|
||||||
</UButton>
|
</UButton>
|
||||||
</UDropdown>
|
</UDropdown>
|
||||||
@@ -96,54 +96,16 @@
|
|||||||
Popover:
|
Popover:
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UPopover mode="hover" wrapper-class="inline-block relative">
|
<UPopover wrapper-class="inline-block relative">
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
<UButton variant="secondary" :icon="open ? 'heroicons-solid:chevron-up' : 'heroicons-solid:chevron-down'" trailing icon-class="transition">
|
<UButton variant="secondary" :icon="open ? 'i-heroicons-chevron-up-20-solid-20' : 'i-heroicons-chevron-down-20-solid'" trailing icon-class="transition">
|
||||||
Open popover!
|
Open popover!
|
||||||
</UButton>
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #panel>
|
<template #panel>
|
||||||
<div
|
<div class="p-2">
|
||||||
class="overflow-hidden rounded-lg shadow-lg ring-1 ring-black ring-opacity-5"
|
Panel
|
||||||
>
|
|
||||||
<div class="relative grid gap-8 bg-white p-7">
|
|
||||||
<a
|
|
||||||
v-for="item in solutions"
|
|
||||||
:key="item.name"
|
|
||||||
:href="item.href"
|
|
||||||
class="flex items-center p-2 -m-3 transition duration-150 ease-in-out rounded-lg hover:bg-gray-50 focus:outline-none focus-visible:ring focus-visible:ring-orange-500 focus-visible:ring-opacity-50"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="flex items-center justify-center flex-shrink-0 w-10 h-10 text-white sm:h-12 sm:w-12"
|
|
||||||
>
|
|
||||||
<div v-html="item.icon" />
|
|
||||||
</div>
|
|
||||||
<div class="ml-4">
|
|
||||||
<p class="text-sm font-medium u-text-gray-900">
|
|
||||||
{{ item.name }}
|
|
||||||
</p>
|
|
||||||
<p class="text-sm u-text-gray-500">
|
|
||||||
{{ item.description }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="p-4 bg-gray-50">
|
|
||||||
<a
|
|
||||||
href="##"
|
|
||||||
class="flow-root px-2 py-2 transition duration-150 ease-in-out rounded-md hover:bg-gray-100 focus:outline-none focus-visible:ring focus-visible:ring-orange-500 focus-visible:ring-opacity-50"
|
|
||||||
>
|
|
||||||
<span class="flex items-center">
|
|
||||||
<span class="text-sm font-medium u-text-gray-900">
|
|
||||||
Documentation
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span class="block text-sm u-text-gray-500">
|
|
||||||
Start integrating products and tools
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</UPopover>
|
</UPopover>
|
||||||
@@ -155,7 +117,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UTooltip text="Hello tooltip!" :shortcuts="['⌘', 'G']">
|
<UTooltip text="Hello tooltip!" :shortcuts="['⌘', 'G']">
|
||||||
<UIcon name="heroicons-outline:information-circle" class="w-6 h-6 u-text-gray-900 cursor-pointer" />
|
<UIcon name="i-heroicons-information-circle" class="w-6 h-6 u-text-gray-900 cursor-pointer" />
|
||||||
</UTooltip>
|
</UTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -163,7 +125,17 @@
|
|||||||
<div class="font-medium text-sm mb-1 u-text-gray-700">
|
<div class="font-medium text-sm mb-1 u-text-gray-700">
|
||||||
Notifications:
|
Notifications:
|
||||||
</div>
|
</div>
|
||||||
<UButton icon="heroicons-outline:bell" variant="red" label="Trigger an error" @click="onNotificationClick" />
|
<UButton icon="i-heroicons-bell" variant="red" label="Trigger an error" @click="onNotificationClick" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="font-medium text-sm mb-1 u-text-gray-700">
|
||||||
|
Copy text to clipboard:
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<UInput v-model="textToCopy" name="textToCopy" />
|
||||||
|
<UButton icon="i-heroicons-document-duplicate-solid" variant="primary" label="Copy text" @click="onCopyTextClick" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -171,11 +143,11 @@
|
|||||||
Context menu:
|
Context menu:
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UCard ref="contextMenuRef" class="relative" body-class="h-64" @click="isContextMenuOpen = false" @contextmenu.prevent="openContextMenu">
|
<UCard class="relative" body-class="h-64" @click="isContextMenuOpen = false" @contextmenu.prevent="openContextMenu">
|
||||||
<UContextMenu v-model="isContextMenuOpen" :virtual-element="virtualElement" width-class="w-48">
|
<UContextMenu v-model="isContextMenuOpen" :virtual-element="virtualElement" width-class="w-48">
|
||||||
<UCard @click.stop>
|
<div class="p-2">
|
||||||
Menu
|
Menu
|
||||||
</UCard>
|
</div>
|
||||||
</UContextMenu>
|
</UContextMenu>
|
||||||
</UCard>
|
</UCard>
|
||||||
</div>
|
</div>
|
||||||
@@ -187,18 +159,13 @@
|
|||||||
|
|
||||||
<UCard body-class="">
|
<UCard body-class="">
|
||||||
<UCommandPalette
|
<UCommandPalette
|
||||||
v-model="form.persons"
|
|
||||||
multiple
|
|
||||||
:placeholder="false"
|
:placeholder="false"
|
||||||
:options="{
|
:options="{
|
||||||
fuseOptions: {
|
fuseOptions: {
|
||||||
includeMatches: true
|
includeMatches: true
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
:groups="[{
|
:groups="commandPaletteGroups"
|
||||||
key: 'persons',
|
|
||||||
commands: people
|
|
||||||
}]"
|
|
||||||
command-attribute="name"
|
command-attribute="name"
|
||||||
/>
|
/>
|
||||||
</UCard>
|
</UCard>
|
||||||
@@ -212,7 +179,7 @@
|
|||||||
<UCard body-class="flex">
|
<UCard body-class="flex">
|
||||||
<div class="flex-1 px-4 py-5 sm:p-6 space-y-3">
|
<div class="flex-1 px-4 py-5 sm:p-6 space-y-3">
|
||||||
<UFormGroup label="Email" name="email" required>
|
<UFormGroup label="Email" name="email" required>
|
||||||
<UInput v-model="form.email" type="email" name="email" required icon="heroicons-outline:mail" />
|
<UInput v-model="form.email" type="email" name="email" required icon="i-heroicons-mail" />
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
<UFormGroup label="Description" name="description">
|
<UFormGroup label="Description" name="description">
|
||||||
@@ -227,7 +194,7 @@
|
|||||||
placeholder="Select a person"
|
placeholder="Select a person"
|
||||||
text-attribute="name"
|
text-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
icon="heroicons-outline:user"
|
icon="i-heroicons-user"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
@@ -236,7 +203,7 @@
|
|||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
<UFormGroup label="Toggle" name="toggle">
|
<UFormGroup label="Toggle" name="toggle">
|
||||||
<UToggle v-model="form.toggle" name="toggle" icon-off="heroicons-solid:x" icon-on="heroicons-solid:check" />
|
<UToggle v-model="form.toggle" name="toggle" icon-off="i-heroicons-x-mark-20-solid" icon-on="i-heroicons-check-20-solid" />
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
<UFormGroup label="Notifications" label-class="text-base font-medium u-text-gray-900" description="How do you prefer to receive notifications?">
|
<UFormGroup label="Notifications" label-class="text-base font-medium u-text-gray-900" description="How do you prefer to receive notifications?">
|
||||||
@@ -273,6 +240,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
const isModalOpen = ref(false)
|
const isModalOpen = ref(false)
|
||||||
|
const textToCopy = ref('Copied text')
|
||||||
|
|
||||||
const people = ref([
|
const people = ref([
|
||||||
{ id: 1, name: 'Durward Reynolds', disabled: false },
|
{ id: 1, name: 'Durward Reynolds', disabled: false },
|
||||||
@@ -294,12 +262,25 @@ const form = reactive({
|
|||||||
persons: ref([people.value[0]])
|
persons: ref([people.value[0]])
|
||||||
})
|
})
|
||||||
|
|
||||||
const { $toast } = useNuxtApp()
|
const toast = useToast()
|
||||||
|
const clipboard = useCopyToClipboard()
|
||||||
|
|
||||||
const x = ref(0)
|
const x = ref(0)
|
||||||
const y = ref(0)
|
const y = ref(0)
|
||||||
const isContextMenuOpen = ref(false)
|
const isContextMenuOpen = ref(false)
|
||||||
const contextMenuRef = ref(null)
|
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
|
||||||
|
|
||||||
|
const commandPaletteGroups = computed(() => ([{
|
||||||
|
key: 'people',
|
||||||
|
commands: people.value
|
||||||
|
}, {
|
||||||
|
key: 'search',
|
||||||
|
label: q => q && `Search results for "${q}"...`,
|
||||||
|
search: async (q) => {
|
||||||
|
if (!q) { return [] }
|
||||||
|
return await $fetch(`https://jsonplaceholder.typicode.com/users?q=${q}`)
|
||||||
|
}
|
||||||
|
}]))
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.addEventListener('mousemove', ({ clientX, clientY }) => {
|
document.addEventListener('mousemove', ({ clientX, clientY }) => {
|
||||||
@@ -308,8 +289,6 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
|
|
||||||
|
|
||||||
function openContextMenu () {
|
function openContextMenu () {
|
||||||
const top = unref(y)
|
const top = unref(y)
|
||||||
const left = unref(x)
|
const left = unref(x)
|
||||||
@@ -340,27 +319,27 @@ function onSubmit () {
|
|||||||
const dropdownItems = [
|
const dropdownItems = [
|
||||||
[{
|
[{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
icon: 'heroicons-solid:pencil',
|
icon: 'i-heroicons-pencil-square-20-solid',
|
||||||
click: (e) => {
|
click: (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
onClick()
|
onClick()
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: 'Duplicate',
|
label: 'Duplicate',
|
||||||
icon: 'heroicons-solid:duplicate'
|
icon: 'i-heroicons-document-duplicate-20-solid'
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
label: 'Archive',
|
label: 'Archive',
|
||||||
icon: 'heroicons-solid:archive'
|
icon: 'i-heroicons-archive-box-20-solid'
|
||||||
}, {
|
}, {
|
||||||
label: 'Move',
|
label: 'Move',
|
||||||
icon: 'heroicons-solid:external-link',
|
icon: 'i-heroicons-arrow-right-circle-20-solid',
|
||||||
to: 'https://www.google.fr',
|
to: 'https://www.google.fr',
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
icon: 'heroicons-solid:trash'
|
icon: 'i-heroicons-trash-20-solid'
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -373,101 +352,16 @@ const customDropdownItems = [
|
|||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
label: 'About',
|
label: 'About',
|
||||||
icon: 'heroicons-solid:plus',
|
icon: 'i-heroicons-plus-20-solid',
|
||||||
to: '/about'
|
to: '/about'
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
|
|
||||||
const solutions = [
|
|
||||||
{
|
|
||||||
name: 'Insights',
|
|
||||||
description: 'Measure actions your users take',
|
|
||||||
href: '##',
|
|
||||||
icon: `
|
|
||||||
<svg
|
|
||||||
width="48"
|
|
||||||
height="48"
|
|
||||||
viewBox="0 0 48 48"
|
|
||||||
fill="none"
|
|
||||||
aria-hidden='true'
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<rect width="48" height="48" rx="8" fill="#FFEDD5" />
|
|
||||||
<path
|
|
||||||
d="M24 11L35.2583 17.5V30.5L24 37L12.7417 30.5V17.5L24 11Z"
|
|
||||||
stroke="#FB923C"
|
|
||||||
stroke-width="2"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
d="M16.7417 19.8094V28.1906L24 32.3812L31.2584 28.1906V19.8094L24 15.6188L16.7417 19.8094Z"
|
|
||||||
stroke="#FDBA74"
|
|
||||||
stroke-width="2"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
d="M20.7417 22.1196V25.882L24 27.7632L27.2584 25.882V22.1196L24 20.2384L20.7417 22.1196Z"
|
|
||||||
stroke="#FDBA74"
|
|
||||||
stroke-width="2"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Automations',
|
|
||||||
description: 'Create your own targeted content',
|
|
||||||
href: '##',
|
|
||||||
icon: `
|
|
||||||
<svg
|
|
||||||
width="48"
|
|
||||||
height="48"
|
|
||||||
viewBox="0 0 48 48"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<rect width="48" height="48" rx="8" fill="#FFEDD5" />
|
|
||||||
<path
|
|
||||||
d="M28.0413 20L23.9998 13L19.9585 20M32.0828 27.0001L36.1242 34H28.0415M19.9585 34H11.8755L15.9171 27"
|
|
||||||
stroke="#FB923C"
|
|
||||||
stroke-width="2"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
d="M18.804 30H29.1963L24.0001 21L18.804 30Z"
|
|
||||||
stroke="#FDBA74"
|
|
||||||
stroke-width="2"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Reports',
|
|
||||||
description: 'Keep track of your growth',
|
|
||||||
href: '##',
|
|
||||||
icon: `
|
|
||||||
<svg
|
|
||||||
width="48"
|
|
||||||
height="48"
|
|
||||||
viewBox="0 0 48 48"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<rect width="48" height="48" rx="8" fill="#FFEDD5" />
|
|
||||||
<rect x="13" y="32" width="2" height="4" fill="#FDBA74" />
|
|
||||||
<rect x="17" y="28" width="2" height="8" fill="#FDBA74" />
|
|
||||||
<rect x="21" y="24" width="2" height="12" fill="#FDBA74" />
|
|
||||||
<rect x="25" y="20" width="2" height="16" fill="#FDBA74" />
|
|
||||||
<rect x="29" y="16" width="2" height="20" fill="#FB923C" />
|
|
||||||
<rect x="33" y="12" width="2" height="24" fill="#FB923C" />
|
|
||||||
</svg>
|
|
||||||
`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const onNotificationClick = () => {
|
const onNotificationClick = () => {
|
||||||
$toast.error({ title: 'Error', description: 'This is an error message' })
|
toast.error({ title: 'Error', description: 'This is an error message' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const onCopyTextClick = () => {
|
||||||
|
clipboard.copy(textToCopy.value, { title: 'Text copied successfully!' })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -105,13 +105,6 @@ const components = [
|
|||||||
preset: true,
|
preset: true,
|
||||||
typescript: true
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Icon',
|
|
||||||
to: '/components/Icon',
|
|
||||||
nuxt3: true,
|
|
||||||
capi: true,
|
|
||||||
typescript: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Link',
|
label: 'Link',
|
||||||
to: '/components/Link',
|
to: '/components/Link',
|
||||||
|
|||||||
50
package.json
50
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nuxthq/ui",
|
"name": "@nuxthq/ui",
|
||||||
"version": "0.1.2",
|
"version": "1.2.7",
|
||||||
"repository": "https://github.com/nuxtlabs/ui",
|
"repository": "https://github.com/nuxtlabs/ui",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -20,40 +20,40 @@
|
|||||||
"dev": "nuxi dev docs",
|
"dev": "nuxi dev docs",
|
||||||
"build:docs": "nuxi generate docs",
|
"build:docs": "nuxi generate docs",
|
||||||
"lint": "eslint --ext .ts,.js,.vue .",
|
"lint": "eslint --ext .ts,.js,.vue .",
|
||||||
|
"typecheck": "nuxi typecheck",
|
||||||
"prepare": "nuxi prepare docs",
|
"prepare": "nuxi prepare docs",
|
||||||
"release": "yarn lint && standard-version && git push --follow-tags"
|
"release": "yarn lint && standard-version && git push --follow-tags"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@headlessui/vue": "^1.7.3",
|
"@egoist/tailwindcss-icons": "^1.0.7",
|
||||||
"@iconify/vue": "^4.0.0",
|
"@headlessui/vue": "1.7.10",
|
||||||
"@nuxt/kit": "^3.0.0-rc.12",
|
"@iconify-json/heroicons": "^1.1.10",
|
||||||
"@nuxtjs/color-mode": "^3.1.8",
|
"@nuxt/kit": "^3.3.3",
|
||||||
"@nuxtjs/tailwindcss": "^6.1.1",
|
"@nuxtjs/color-mode": "^3.2.0",
|
||||||
"@popperjs/core": "^2.11.6",
|
"@nuxtjs/tailwindcss": "^6.6.5",
|
||||||
|
"@popperjs/core": "^2.11.7",
|
||||||
"@tailwindcss/aspect-ratio": "^0.4.2",
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
||||||
"@tailwindcss/forms": "^0.5.3",
|
"@tailwindcss/forms": "^0.5.3",
|
||||||
"@tailwindcss/line-clamp": "^0.4.2",
|
"@tailwindcss/line-clamp": "^0.4.4",
|
||||||
"@tailwindcss/typography": "^0.5.7",
|
"@tailwindcss/typography": "^0.5.9",
|
||||||
"@vueuse/core": "^9.4.0",
|
"@vueuse/core": "^9.13.0",
|
||||||
"@vueuse/integrations": "^9.4.0",
|
"@vueuse/integrations": "^9.13.0",
|
||||||
"defu": "^6.1.0",
|
"@vueuse/math": "^9.13.0",
|
||||||
|
"defu": "^6.1.2",
|
||||||
"fuse.js": "^6.6.2",
|
"fuse.js": "^6.6.2",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"tailwindcss": "^3.2.1"
|
"tailwindcss": "^3.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/module-builder": "^0.2.0",
|
"@iconify-json/mdi": "^1.1.50",
|
||||||
"@nuxtjs/eslint-config-typescript": "^11.0.0",
|
"@nuxt/module-builder": "^0.2.1",
|
||||||
"@types/lodash-es": "^4.17.6",
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
||||||
"eslint": "^8.26.0",
|
"@types/lodash-es": "^4.17.7",
|
||||||
"nuxt": "^3.0.0-rc.9",
|
"@types/node": "^18.15.11",
|
||||||
|
"eslint": "^8.37.0",
|
||||||
|
"nuxt": "^3.3.3",
|
||||||
"standard-version": "^9.5.0",
|
"standard-version": "^9.5.0",
|
||||||
"vue-tsc": "^1.0.9"
|
"unbuild": "^1.2.0",
|
||||||
},
|
"vue-tsc": "^1.2.0"
|
||||||
"build": {
|
|
||||||
"externals": [
|
|
||||||
"tailwindcss",
|
|
||||||
"tailwindcss/colors.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
src/env.d.ts
vendored
Normal file
6
src/env.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import type { DefaultPreset } from './runtime/presets/default'
|
||||||
|
|
||||||
|
declare module '#build/ui' {
|
||||||
|
declare const preset: DefaultPreset
|
||||||
|
export default preset
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, addTemplate, addPlugin, createResolver } from '@nuxt/kit'
|
import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, addTemplate, createResolver } from '@nuxt/kit'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import colors from 'tailwindcss/colors.js'
|
import colors from 'tailwindcss/colors.js'
|
||||||
import type { Config } from 'tailwindcss'
|
import type { Config } from 'tailwindcss'
|
||||||
|
import { iconsPlugin, getIconCollections } from '@egoist/tailwindcss-icons'
|
||||||
import { name, version } from '../package.json'
|
import { name, version } from '../package.json'
|
||||||
import { colorsAsRegex, excludeColors } from './runtime/utils/colors'
|
import { colorsAsRegex, excludeColors } from './runtime/utils/colors'
|
||||||
import defaultPreset from './runtime/presets/default'
|
import defaultPreset from './runtime/presets/default'
|
||||||
@@ -39,6 +40,8 @@ export interface ModuleOptions {
|
|||||||
|
|
||||||
colors?: ColorsOptions
|
colors?: ColorsOptions
|
||||||
|
|
||||||
|
icons: string[]
|
||||||
|
|
||||||
tailwindcss?: Partial<Config>
|
tailwindcss?: Partial<Config>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +52,7 @@ const defaults = {
|
|||||||
primary: 'indigo',
|
primary: 'indigo',
|
||||||
gray: 'gray'
|
gray: 'gray'
|
||||||
},
|
},
|
||||||
|
icons: ['heroicons'],
|
||||||
tailwindcss: {
|
tailwindcss: {
|
||||||
theme: {}
|
theme: {}
|
||||||
}
|
}
|
||||||
@@ -72,7 +76,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
// Transpile runtime
|
// Transpile runtime
|
||||||
const runtimeDir = resolve('./runtime')
|
const runtimeDir = resolve('./runtime')
|
||||||
nuxt.options.build.transpile.push(runtimeDir)
|
nuxt.options.build.transpile.push(runtimeDir)
|
||||||
nuxt.options.build.transpile.push('@popperjs/core', '@headlessui/vue', '@iconify/vue')
|
nuxt.options.build.transpile.push('@popperjs/core', '@headlessui/vue')
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
nuxt.hook('tailwindcss:config', function (tailwindConfig: TailwindConfig) {
|
nuxt.hook('tailwindcss:config', function (tailwindConfig: TailwindConfig) {
|
||||||
@@ -108,6 +112,9 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
variants: ['focus']
|
variants: ['focus']
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
tailwindConfig.plugins = tailwindConfig.plugins || []
|
||||||
|
tailwindConfig.plugins.push(iconsPlugin({ collections: getIconCollections(options.icons as any[]) }))
|
||||||
|
|
||||||
const ui: object = defu(preset, defaultPreset(variantColors))
|
const ui: object = defu(preset, defaultPreset(variantColors))
|
||||||
|
|
||||||
addTemplate({
|
addTemplate({
|
||||||
@@ -148,9 +155,6 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
cssPath: resolve(runtimeDir, 'tailwind.css')
|
cssPath: resolve(runtimeDir, 'tailwind.css')
|
||||||
})
|
})
|
||||||
|
|
||||||
addPlugin(resolve(runtimeDir, 'plugins', 'toast.client'))
|
|
||||||
addPlugin(resolve(runtimeDir, 'plugins', 'clipboard.client'))
|
|
||||||
|
|
||||||
addComponentsDir({
|
addComponentsDir({
|
||||||
path: resolve(runtimeDir, 'components', 'elements'),
|
path: resolve(runtimeDir, 'components', 'elements'),
|
||||||
prefix,
|
prefix,
|
||||||
|
|||||||
@@ -38,12 +38,8 @@ const props = defineProps({
|
|||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
chip: {
|
chip: {
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
chipVariant: {
|
|
||||||
type: String,
|
type: String,
|
||||||
default: 'primary',
|
default: null,
|
||||||
validator (value: string) {
|
validator (value: string) {
|
||||||
return Object.keys($ui.avatar.chip.variant).includes(value)
|
return Object.keys($ui.avatar.chip.variant).includes(value)
|
||||||
}
|
}
|
||||||
@@ -92,8 +88,8 @@ const avatarClass = computed(() => {
|
|||||||
const chipClass = computed(() => {
|
const chipClass = computed(() => {
|
||||||
return classNames(
|
return classNames(
|
||||||
$ui.avatar.chip.base,
|
$ui.avatar.chip.base,
|
||||||
|
$ui.avatar.chip.variant[props.chip],
|
||||||
$ui.avatar.chip.position[props.chipPosition],
|
$ui.avatar.chip.position[props.chipPosition],
|
||||||
$ui.avatar.chip.variant[props.chipVariant],
|
|
||||||
$ui.avatar.chip.size[props.size]
|
$ui.avatar.chip.size[props.size]
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'md',
|
default: 'md',
|
||||||
validator (value: string) {
|
validator (value: string) {
|
||||||
return ['xxxs', 'xxs', 'xs', 'sm', 'md', 'lg', 'xl'].includes(value)
|
return Object.keys($ui.avatar.size).includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
max: {
|
max: {
|
||||||
|
|||||||
@@ -6,16 +6,21 @@
|
|||||||
:aria-label="ariaLabel"
|
:aria-label="ariaLabel"
|
||||||
v-bind="buttonProps"
|
v-bind="buttonProps"
|
||||||
>
|
>
|
||||||
<Icon v-if="isLeading" :name="leadingIconName" :class="leadingIconClass" aria-hidden="true" />
|
<Icon v-if="isLeading && leadingIconName" :name="leadingIconName" :class="leadingIconClass" aria-hidden="true" />
|
||||||
<slot><span :class="truncate ? 'text-left break-all line-clamp-1' : ''">{{ label }}</span></slot>
|
<slot>
|
||||||
<Icon v-if="isTrailing" :name="trailingIconName" :class="trailingIconClass" aria-hidden="true" />
|
<span :class="[truncate ? 'text-left break-all line-clamp-1' : '', compact ? 'hidden sm:block' : '']">
|
||||||
|
<span :class="[labelCompact && 'hidden sm:block']">{{ label }}</span>
|
||||||
|
<span v-if="labelCompact" class="sm:hidden">{{ labelCompact }}</span>
|
||||||
|
</span>
|
||||||
|
</slot>
|
||||||
|
<Icon v-if="isTrailing && trailingIconName" :name="trailingIconName" :class="trailingIconClass" aria-hidden="true" />
|
||||||
</component>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, useSlots } from 'vue'
|
import { ref, computed, useSlots } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import type { RouteLocationNormalized } from 'vue-router'
|
import type { RouteLocationNormalized, RouteLocationRaw } from 'vue-router'
|
||||||
import NuxtLink from '#app/components/nuxt-link'
|
import NuxtLink from '#app/components/nuxt-link'
|
||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
@@ -34,6 +39,10 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
labelCompact: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@@ -81,7 +90,7 @@ const props = defineProps({
|
|||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
to: {
|
to: {
|
||||||
type: [String, Object] as PropType<string | RouteLocationNormalized>,
|
type: [String, Object] as PropType<string | RouteLocationNormalized | RouteLocationRaw>,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
target: {
|
target: {
|
||||||
@@ -127,6 +136,10 @@ const props = defineProps({
|
|||||||
truncate: {
|
truncate: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
compact: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -164,7 +177,7 @@ const buttonClass = computed(() => {
|
|||||||
return classNames(
|
return classNames(
|
||||||
props.baseClass,
|
props.baseClass,
|
||||||
$ui.button.size[props.size],
|
$ui.button.size[props.size],
|
||||||
$ui.button[isSquare.value ? 'square' : 'spacing'][props.size],
|
$ui.button[isSquare.value ? 'square' : (props.compact ? 'compact' : 'spacing')][props.size],
|
||||||
$ui.button.variant[props.variant],
|
$ui.button.variant[props.variant],
|
||||||
props.block ? 'w-full flex justify-center items-center' : 'inline-flex items-center',
|
props.block ? 'w-full flex justify-center items-center' : 'inline-flex items-center',
|
||||||
props.rounded ? 'rounded-full' : props.roundedClass,
|
props.rounded ? 'rounded-full' : props.roundedClass,
|
||||||
@@ -192,7 +205,7 @@ const leadingIconClass = computed(() => {
|
|||||||
return classNames(
|
return classNames(
|
||||||
props.iconBaseClass,
|
props.iconBaseClass,
|
||||||
$ui.button.icon.size[props.size],
|
$ui.button.icon.size[props.size],
|
||||||
(!!slots.default || !!props.label?.length) && $ui.button.icon.leading.spacing[props.size],
|
(!!slots.default || !!props.label?.length) && $ui.button.icon.leading[props.compact ? 'compactSpacing' : 'spacing'][props.size],
|
||||||
props.leadingIconClass,
|
props.leadingIconClass,
|
||||||
props.loading && 'animate-spin'
|
props.loading && 'animate-spin'
|
||||||
)
|
)
|
||||||
@@ -202,7 +215,7 @@ const trailingIconClass = computed(() => {
|
|||||||
return classNames(
|
return classNames(
|
||||||
props.iconBaseClass,
|
props.iconBaseClass,
|
||||||
$ui.button.icon.size[props.size],
|
$ui.button.icon.size[props.size],
|
||||||
(!!slots.default || !!props.label?.length) && $ui.button.icon.trailing.spacing[props.size],
|
(!!slots.default || !!props.label?.length) && $ui.button.icon.trailing[props.compact ? 'compactSpacing' : 'spacing'][props.size],
|
||||||
props.trailingIconClass,
|
props.trailingIconClass,
|
||||||
props.loading && !isLeading.value && 'animate-spin'
|
props.loading && !isLeading.value && 'animate-spin'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<Menu v-slot="{ open }" as="div" :class="wrapperClass" @mouseleave="onMouseLeave">
|
<Menu v-slot="{ open }" as="div" :class="wrapperClass" @mouseleave="onMouseLeave">
|
||||||
<MenuButton ref="trigger" as="div" class="inline-flex" @mouseover="onMouseOver">
|
<MenuButton
|
||||||
|
ref="trigger"
|
||||||
|
as="div"
|
||||||
|
:disabled="disabled"
|
||||||
|
class="inline-flex w-full"
|
||||||
|
role="button"
|
||||||
|
@mouseover="onMouseOver"
|
||||||
|
>
|
||||||
<slot :open="open">
|
<slot :open="open">
|
||||||
<button>Open</button>
|
<button :disabled="disabled">
|
||||||
|
Open
|
||||||
|
</button>
|
||||||
</slot>
|
</slot>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|
||||||
<div v-if="open" ref="container" :class="[containerClass, widthClass]" @mouseover="onMouseOver">
|
<div v-if="open && items.length" ref="container" :class="[containerClass, widthClass]" @mouseover="onMouseOver">
|
||||||
<transition appear v-bind="transitionClass">
|
<transition appear v-bind="transitionClass">
|
||||||
<MenuItems :class="baseClass" static>
|
<MenuItems :class="[baseClass, divideClass, ringClass, roundedClass, shadowClass, backgroundClass]" static>
|
||||||
<div v-for="(subItems, index) of items" :key="index" :class="groupClass">
|
<div v-for="(subItems, index) of items" :key="index" :class="groupClass">
|
||||||
<MenuItem v-for="(item, subIndex) of subItems" :key="subIndex" v-slot="{ active, disabled }" :disabled="item.disabled" @click="e => item.click?.(e)">
|
<MenuItem v-for="(item, subIndex) of subItems" :key="subIndex" v-slot="{ active, disabled: itemDisabled }" :disabled="item.disabled">
|
||||||
<Component v-bind="item" :is="(item.to && NuxtLink) || (item.click && 'button') || 'div'" :class="resolveItemClass({ active, disabled })">
|
<Component
|
||||||
|
v-bind="omit(item, ['click'])"
|
||||||
|
:is="(item.to && NuxtLink) || (item.click && 'button') || 'div'"
|
||||||
|
:class="resolveItemClass({ active, disabled: itemDisabled })"
|
||||||
|
@click="item.click"
|
||||||
|
>
|
||||||
<slot :name="item.slot" :item="item">
|
<slot :name="item.slot" :item="item">
|
||||||
<Icon v-if="item.icon" :name="item.icon" :class="[itemIconClass, item.iconClass]" />
|
<Icon v-if="item.icon" :name="item.icon" :class="[itemIconClass, item.iconClass]" />
|
||||||
<Avatar v-if="item.avatar" v-bind="{ size: 'xxs', ...item.avatar }" :class="itemAvatarClass" />
|
<Avatar v-if="item.avatar" v-bind="{ size: 'xxs', ...item.avatar }" :class="itemAvatarClass" />
|
||||||
@@ -38,14 +52,14 @@ import {
|
|||||||
MenuItems,
|
MenuItems,
|
||||||
MenuItem
|
MenuItem
|
||||||
} from '@headlessui/vue'
|
} from '@headlessui/vue'
|
||||||
import type { Ref, PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import type { RouteLocationNormalized } from 'vue-router'
|
import type { RouteLocationNormalized } from 'vue-router'
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import NuxtLink from '#app/components/nuxt-link'
|
import NuxtLink from '#app/components/nuxt-link'
|
||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import Avatar from '../elements/Avatar.vue'
|
import Avatar from '../elements/Avatar.vue'
|
||||||
import { classNames } from '../../utils'
|
import { classNames, omit } from '../../utils'
|
||||||
import { usePopper } from '../../composables/usePopper'
|
import { usePopper } from '../../composables/usePopper'
|
||||||
import type { Avatar as AvatarType } from '../../types/avatar'
|
import type { Avatar as AvatarType } from '../../types/avatar'
|
||||||
import type { PopperOptions } from '../../types'
|
import type { PopperOptions } from '../../types'
|
||||||
@@ -54,8 +68,8 @@ import $ui from '#build/ui'
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
items: {
|
items: {
|
||||||
type: Array as PropType<{
|
type: Array as PropType<{
|
||||||
to: RouteLocationNormalized
|
to?: RouteLocationNormalized
|
||||||
exact: boolean
|
exact?: boolean
|
||||||
label: string
|
label: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
slot?: string
|
slot?: string
|
||||||
@@ -74,6 +88,10 @@ const props = defineProps({
|
|||||||
return ['click', 'hover'].includes(value)
|
return ['click', 'hover'].includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
wrapperClass: {
|
wrapperClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.dropdown.wrapper
|
default: () => $ui.dropdown.wrapper
|
||||||
@@ -86,6 +104,26 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.dropdown.width
|
default: () => $ui.dropdown.width
|
||||||
},
|
},
|
||||||
|
backgroundClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.dropdown.background
|
||||||
|
},
|
||||||
|
shadowClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.dropdown.shadow
|
||||||
|
},
|
||||||
|
roundedClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.dropdown.rounded
|
||||||
|
},
|
||||||
|
ringClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.dropdown.ring
|
||||||
|
},
|
||||||
|
divideClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.dropdown.divide
|
||||||
|
},
|
||||||
baseClass: {
|
baseClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.dropdown.base
|
default: () => $ui.dropdown.base
|
||||||
@@ -128,7 +166,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
type: Object as PropType<PopperOptions>,
|
type: Object as PropType<PopperOptions>,
|
||||||
default: () => {}
|
default: () => ({})
|
||||||
},
|
},
|
||||||
openDelay: {
|
openDelay: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -153,25 +191,20 @@ function resolveItemClass ({ active, disabled }: { active: boolean, disabled: bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/tailwindlabs/headlessui/blob/f66f4926c489fc15289d528294c23a3dc2aee7b1/packages/%40headlessui-vue/src/components/menu/menu.ts#L131
|
// https://github.com/tailwindlabs/headlessui/blob/f66f4926c489fc15289d528294c23a3dc2aee7b1/packages/%40headlessui-vue/src/components/menu/menu.ts#L131
|
||||||
const menuApi: Ref<any> = ref(null)
|
const menuApi = ref<any>(null)
|
||||||
|
|
||||||
let openTimeout: NodeJS.Timeout | null = null
|
let openTimeout: NodeJS.Timeout | null = null
|
||||||
let closeTimeout: NodeJS.Timeout | null = null
|
let closeTimeout: NodeJS.Timeout | null = null
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// @ts-expect-error internals
|
||||||
const menuProvides = trigger.value?.$.provides
|
const menuProvides = trigger.value?.$.provides
|
||||||
if (!menuProvides) {
|
if (!menuProvides) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const menuProvidesSymbols = Object.getOwnPropertySymbols(menuProvides)
|
const menuProvidesSymbols = Object.getOwnPropertySymbols(menuProvides)
|
||||||
menuApi.value = menuProvidesSymbols.length && menuProvides[menuProvidesSymbols[0]]
|
menuApi.value = menuProvidesSymbols.length && menuProvides[menuProvidesSymbols[0]]
|
||||||
// stop trigger click propagation on hover
|
|
||||||
menuApi.value?.buttonRef?.addEventListener('click', (e: Event) => {
|
|
||||||
if (props.mode === 'hover') {
|
|
||||||
e.stopPropagation()
|
|
||||||
}
|
|
||||||
}, true)
|
|
||||||
}, 200)
|
}, 200)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<span v-if="isFetching" />
|
<span :class="name" />
|
||||||
<Iconify v-else-if="icon" :icon="icon" />
|
|
||||||
<Component :is="component" v-else-if="component" />
|
|
||||||
<span v-else>{{ name }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { IconifyIcon } from '@iconify/vue'
|
defineProps({
|
||||||
import { Icon as Iconify } from '@iconify/vue/dist/offline'
|
|
||||||
import { loadIcon } from '@iconify/vue'
|
|
||||||
import { useNuxtApp, useState, computed, watch, onMounted } from '#imports'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const nuxtApp = useNuxtApp()
|
|
||||||
const state = useState('u-icons', () => ({}))
|
|
||||||
|
|
||||||
const isFetching = computed(() => !!state.value?.[props.name]?.then)
|
|
||||||
const icon = computed<IconifyIcon | null>(() => !state.value?.[props.name] || state.value[props.name].then ? null : state.value[props.name])
|
|
||||||
const component = computed(() => nuxtApp.vueApp.component(props.name))
|
|
||||||
|
|
||||||
const loadIconComponent = (name: string) => {
|
|
||||||
state.value = state.value || {}
|
|
||||||
if (nuxtApp.vueApp.component(props.name) || state.value[name] || state.value[name] === null) { return state.value[name] }
|
|
||||||
|
|
||||||
state.value[name] = loadIcon(name)
|
|
||||||
.then((res) => { state.value[name] = res })
|
|
||||||
// We won't try to load this icon again if it fails
|
|
||||||
.catch(() => { state.value[name] = null })
|
|
||||||
|
|
||||||
// return an awaitable promise
|
|
||||||
return state.value[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
watch(() => props.name, loadIconComponent, { immediate: true })
|
|
||||||
})
|
|
||||||
|
|
||||||
if (process.server) {
|
|
||||||
await loadIconComponent(props.name)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<router-link
|
<router-link
|
||||||
v-else
|
v-else
|
||||||
v-slot="{ href, navigate, isActive, isExactActive }"
|
v-slot="{ href, navigate, isActive, isExactActive }"
|
||||||
v-bind="$props"
|
v-bind="$props as RouterLinkProps"
|
||||||
custom
|
custom
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
@@ -25,10 +25,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import type { RouteLocationNormalized } from 'vue-router'
|
import type { RouteLocationNormalized, RouterLinkProps } from 'vue-router'
|
||||||
import { RouterLink } from 'vue-router'
|
import { RouterLink } from 'vue-router'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
// @ts-expect-error internal props
|
||||||
...RouterLink.props,
|
...RouterLink.props,
|
||||||
to: {
|
to: {
|
||||||
type: [String, Object] as PropType<string | RouteLocationNormalized>,
|
type: [String, Object] as PropType<string | RouteLocationNormalized>,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="rounded-md p-4" :class="variantClass">
|
<div class="rounded-md p-4" :class="variantClass">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div class="flex-shrink-0">
|
<div class="inline-flex flex-shrink-0">
|
||||||
<Icon :name="iconName" :class="iconClass" class="h-5 w-5" />
|
<Icon v-if="iconName" :name="iconName" :class="iconClass" class="h-5 w-5" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-3 flex-1 md:flex md:justify-between">
|
<div class="ml-3 flex-1 md:flex md:justify-between">
|
||||||
<p v-if="title" class="text-sm leading-5" :class="titleClass">
|
<p v-if="title" class="text-sm leading-5" :class="titleClass">
|
||||||
@@ -57,10 +57,10 @@ const props = defineProps({
|
|||||||
|
|
||||||
const iconName = computed(() => {
|
const iconName = computed(() => {
|
||||||
return ({
|
return ({
|
||||||
info: 'heroicons-solid:information-circle',
|
info: 'i-heroicons-information-circle',
|
||||||
warning: 'heroicons-solid:exclamation',
|
warning: 'i-heroicons-exclamation',
|
||||||
error: 'heroicons-solid:x-circle',
|
error: 'i-heroicons-x-circle',
|
||||||
success: 'heroicons-solid:check-circle'
|
success: 'i-heroicons-check-circle'
|
||||||
})[props.variant]
|
})[props.variant]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { DialogTitle, DialogDescription } from '@headlessui/vue'
|
import { DialogTitle, DialogDescription } from '@headlessui/vue'
|
||||||
|
import Icon from '../elements/Icon.vue'
|
||||||
import Modal from '../overlays/Modal.vue'
|
import Modal from '../overlays/Modal.vue'
|
||||||
import Button from '../elements/Button.vue'
|
import Button from '../elements/Button.vue'
|
||||||
import Icon from '../elements/Icon.vue'
|
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -55,7 +55,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
titleClass: {
|
titleClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.alertDialog.icon.title
|
default: () => $ui.alertDialog.title
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const props = defineProps({
|
|||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number, Boolean, Array],
|
type: [Boolean, Array],
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
|
|||||||
@@ -13,22 +13,21 @@
|
|||||||
:autocomplete="autocomplete"
|
:autocomplete="autocomplete"
|
||||||
:spellcheck="spellcheck"
|
:spellcheck="spellcheck"
|
||||||
:class="inputClass"
|
:class="inputClass"
|
||||||
@input="onInput($event.target.value)"
|
@input="onInput(($event.target as any).value)"
|
||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="$emit('blur', $event)"
|
@blur="$emit('blur', $event)"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
<div v-if="isLeading" :class="iconLeadingWrapperClass">
|
<div v-if="isLeading" :class="iconLeadingWrapperClass">
|
||||||
<Icon :name="iconName" :class="iconClass" />
|
<Icon v-if="iconName" :name="iconName" :class="iconClass" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isTrailing" :class="iconTrailingWrapperClass">
|
<div v-if="isTrailing" :class="iconTrailingWrapperClass">
|
||||||
<Icon :name="iconName" :class="iconClass" />
|
<Icon v-if="iconName" :name="iconName" :class="iconClass" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Ref } from 'vue'
|
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
@@ -129,11 +128,11 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'focus', 'blur'])
|
const emit = defineEmits(['update:modelValue', 'focus', 'blur'])
|
||||||
|
|
||||||
const input: Ref<HTMLInputElement> = ref(null)
|
const input = ref<HTMLInputElement | null>(null)
|
||||||
|
|
||||||
const autoFocus = () => {
|
const autoFocus = () => {
|
||||||
if (props.autofocus) {
|
if (props.autofocus) {
|
||||||
input.value.focus()
|
input.value?.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
:required="required"
|
:required="required"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:class="selectClass"
|
:class="selectClass"
|
||||||
@input="onInput($event.target.value)"
|
@input="onInput(($event.target as any).value)"
|
||||||
>
|
>
|
||||||
<template v-for="(option, index) in normalizedOptionsWithPlaceholder">
|
<template v-for="(option, index) in normalizedOptionsWithPlaceholder">
|
||||||
<optgroup
|
<optgroup
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { get } from 'lodash-es'
|
import { get } from 'lodash-es'
|
||||||
import Icon from '../elements/Icon.vue'
|
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
|
import Icon from '../elements/Icon.vue'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@@ -10,18 +10,18 @@
|
|||||||
:class="wrapperClass"
|
:class="wrapperClass"
|
||||||
@update:model-value="onUpdate"
|
@update:model-value="onUpdate"
|
||||||
>
|
>
|
||||||
<input :value="modelValue" :required="required" class="absolute inset-0 w-px opacity-0 cursor-default" tabindex="-1">
|
<input :value="modelValue" :required="required" class="absolute inset-0 w-px opacity-0 cursor-default" tabindex="-1" aria-hidden="true">
|
||||||
|
|
||||||
<ComboboxButton ref="trigger" v-slot="{ disabled: buttonDisabled }" as="div">
|
<ComboboxButton ref="trigger" v-slot="{ disabled: buttonDisabled }" as="div" role="button" class="inline-flex w-full">
|
||||||
<slot :open="open" :disabled="buttonDisabled">
|
<slot :open="open" :disabled="buttonDisabled">
|
||||||
<button :class="selectCustomClass" :disabled="disabled" type="button">
|
<button :class="selectCustomClass" :disabled="disabled" type="button">
|
||||||
<slot name="label">
|
<slot name="label">
|
||||||
<span v-if="modelValue" class="block truncate">{{ modelValue[textAttribute] }}</span>
|
<span v-if="modelValue" class="block truncate">{{ (modelValue as any)[textAttribute] }}</span>
|
||||||
<span v-else class="block truncate u-text-gray-400">{{ placeholder }}</span>
|
<span v-else class="block truncate u-text-gray-400">{{ placeholder }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<span :class="iconWrapperClass">
|
<span :class="iconWrapperClass">
|
||||||
<Icon :name="icon" :class="iconClass" aria-hidden="true" />
|
<Icon v-if="icon" :name="icon" :class="iconClass" aria-hidden="true" />
|
||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span v-if="selected" :class="resolveOptionIconClass({ active })">
|
<span v-if="selected" :class="resolveOptionIconClass({ active })">
|
||||||
<Icon :name="listOptionIcon" :class="listOptionIconSizeClass" aria-hidden="true" />
|
<Icon v-if="listOptionIcon" :name="listOptionIcon" :class="listOptionIconSizeClass" aria-hidden="true" />
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ComboboxOption>
|
</ComboboxOption>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
import type { PropType, ComponentPublicInstance } from 'vue'
|
import type { PropType, ComponentPublicInstance } from 'vue'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import {
|
import {
|
||||||
@@ -110,7 +110,7 @@ const props = defineProps({
|
|||||||
default: undefined
|
default: undefined
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Array as PropType<{ [key: string]: any, disabled?: boolean }[]>,
|
type: Array as PropType<{ [key: string]: any, disabled?: boolean }[] | string[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
required: {
|
required: {
|
||||||
@@ -257,11 +257,11 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
type: Object as PropType<PopperOptions>,
|
type: Object as PropType<PopperOptions>,
|
||||||
default: () => {}
|
default: () => ({})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue', 'open', 'close'])
|
||||||
|
|
||||||
const popperOptions = computed<PopperOptions>(() => defu({}, props.popperOptions, $ui.selectCustom.popperOptions))
|
const popperOptions = computed<PopperOptions>(() => defu({}, props.popperOptions, $ui.selectCustom.popperOptions))
|
||||||
|
|
||||||
@@ -292,11 +292,11 @@ const iconClass = computed(() => {
|
|||||||
const filteredOptions = computed(() =>
|
const filteredOptions = computed(() =>
|
||||||
query.value === ''
|
query.value === ''
|
||||||
? props.options
|
? props.options
|
||||||
: props.options.filter((option: any) => {
|
: (props.options as any[]).filter((option: any) => {
|
||||||
return (props.searchAttributes?.length ? props.searchAttributes : [props.textAttribute]).some((searchAttribute: any) => {
|
return (props.searchAttributes?.length ? props.searchAttributes : [props.textAttribute]).some((searchAttribute: any) => {
|
||||||
return option[searchAttribute] && option[searchAttribute].search(new RegExp(query.value, 'i')) !== -1
|
return typeof option === 'string' ? option.search(new RegExp(query.value, 'i')) !== -1 : (option[searchAttribute] && option[searchAttribute].search(new RegExp(query.value, 'i')) !== -1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const queryOption = computed(() => {
|
const queryOption = computed(() => {
|
||||||
@@ -307,6 +307,14 @@ const iconWrapperClass = classNames(
|
|||||||
$ui.selectCustom.icon.trailing.wrapper
|
$ui.selectCustom.icon.trailing.wrapper
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(container, (value) => {
|
||||||
|
if (value) {
|
||||||
|
emit('open')
|
||||||
|
} else {
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function resolveOptionClass ({ active, selected, disabled }: { active: boolean, selected: boolean, disabled?: boolean }) {
|
function resolveOptionClass ({ active, selected, disabled }: { active: boolean, selected: boolean, disabled?: boolean }) {
|
||||||
return classNames(
|
return classNames(
|
||||||
props.listOptionBaseClass,
|
props.listOptionBaseClass,
|
||||||
@@ -323,7 +331,7 @@ function resolveOptionIconClass ({ active }: { active: boolean }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUpdate (event) {
|
function onUpdate (event: any) {
|
||||||
if (query.value && searchInput.value?.$el) {
|
if (query.value && searchInput.value?.$el) {
|
||||||
query.value = ''
|
query.value = ''
|
||||||
// explicitly set input text because `ComboboxInput` `displayValue` is not reactive
|
// explicitly set input text because `ComboboxInput` `displayValue` is not reactive
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:autocomplete="autocomplete"
|
:autocomplete="autocomplete"
|
||||||
:class="textareaClass"
|
:class="textareaClass"
|
||||||
@input="onInput($event.target.value)"
|
@input="onInput(($event.target as any).value)"
|
||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="$emit('blur', $event)"
|
@blur="$emit('blur', $event)"
|
||||||
/>
|
/>
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Ref } from 'vue'
|
|
||||||
import { ref, computed, watch, onMounted, nextTick } from 'vue'
|
import { ref, computed, watch, onMounted, nextTick } from 'vue'
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
@@ -95,11 +94,11 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'focus', 'blur'])
|
const emit = defineEmits(['update:modelValue', 'focus', 'blur'])
|
||||||
|
|
||||||
const textarea: Ref<HTMLTextAreaElement> = ref(null)
|
const textarea = ref<HTMLTextAreaElement | null>(null)
|
||||||
|
|
||||||
const autoFocus = () => {
|
const autoFocus = () => {
|
||||||
if (props.autofocus) {
|
if (props.autofocus) {
|
||||||
textarea.value.focus()
|
textarea.value?.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,23 +7,45 @@
|
|||||||
:nullable="nullable"
|
:nullable="nullable"
|
||||||
@update:model-value="onSelect"
|
@update:model-value="onSelect"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col flex-1 min-h-0 divide-y divide-gray-100 dark:divide-gray-800">
|
<div :class="$ui.commandPalette.wrapper">
|
||||||
<div v-show="searchable" class="relative flex items-center">
|
<div v-show="searchable" class="relative flex items-center">
|
||||||
<Icon :name="inputIcon" class="pointer-events-none absolute top-3.5 left-5 h-5 w-5 u-text-gray-400" aria-hidden="true" />
|
<Icon v-if="inputIcon" :name="inputIcon" :class="$ui.commandPalette.input.icon.base" aria-hidden="true" />
|
||||||
<ComboboxInput
|
<ComboboxInput
|
||||||
ref="comboboxInput"
|
ref="comboboxInput"
|
||||||
:value="query"
|
:value="query"
|
||||||
class="w-full h-12 pr-4 placeholder-gray-400 dark:placeholder-gray-500 bg-transparent border-0 pl-[3.25rem] u-text-gray-900 focus:ring-0 sm:text-sm"
|
:class="$ui.commandPalette.input.base"
|
||||||
:placeholder="inputPlaceholder"
|
:placeholder="inputPlaceholder"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
@change="query = $event.target.value"
|
@change="query = $event.target.value"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button v-if="closeIcon" :icon="closeIcon" variant="transparent" class="absolute right-3" @click="onClear" />
|
<Button
|
||||||
|
v-if="inputCloseIcon"
|
||||||
|
:icon="inputCloseIcon"
|
||||||
|
:class="$ui.commandPalette.input.close.base"
|
||||||
|
:size="$ui.commandPalette.input.close.size"
|
||||||
|
:variant="$ui.commandPalette.input.close.variant"
|
||||||
|
aria-label="Close"
|
||||||
|
@click="onClear"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ComboboxOptions v-if="groups.length" static hold class="relative flex-1 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 scroll-py-2">
|
<ComboboxOptions
|
||||||
<CommandPaletteGroup v-for="group of groups" :key="group.key" :group="group" :group-attribute="groupAttribute" :command-attribute="commandAttribute">
|
v-if="groups.length"
|
||||||
|
static
|
||||||
|
hold
|
||||||
|
as="div"
|
||||||
|
aria-label="Commands"
|
||||||
|
class="relative flex-1 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 scroll-py-2"
|
||||||
|
>
|
||||||
|
<CommandPaletteGroup
|
||||||
|
v-for="group of groups"
|
||||||
|
:key="group.key"
|
||||||
|
:query="query"
|
||||||
|
:group="group"
|
||||||
|
:group-attribute="groupAttribute"
|
||||||
|
:command-attribute="commandAttribute"
|
||||||
|
>
|
||||||
<template v-for="(_, name) in $slots" #[name]="slotData">
|
<template v-for="(_, name) in $slots" #[name]="slotData">
|
||||||
<slot :name="name" v-bind="slotData" />
|
<slot :name="name" v-bind="slotData" />
|
||||||
</template>
|
</template>
|
||||||
@@ -31,8 +53,8 @@
|
|||||||
</ComboboxOptions>
|
</ComboboxOptions>
|
||||||
|
|
||||||
<div v-else-if="placeholder" class="flex flex-col items-center justify-center flex-1 px-6 py-14 sm:px-14">
|
<div v-else-if="placeholder" class="flex flex-col items-center justify-center flex-1 px-6 py-14 sm:px-14">
|
||||||
<Icon :name="emptyIcon" class="w-6 h-6 mx-auto u-text-gray-400" aria-hidden="true" />
|
<Icon v-if="emptyIcon" :name="emptyIcon" class="w-6 h-6 mx-auto u-text-gray-400 mb-4" aria-hidden="true" />
|
||||||
<p class="mt-4 text-sm text-center u-text-gray-900">
|
<p class="text-sm text-center u-text-gray-900">
|
||||||
{{ query ? "We couldn't find any items with that term. Please try again." : "We couldn't find any items." }}
|
{{ query ? "We couldn't find any items with that term. Please try again." : "We couldn't find any items." }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,9 +63,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, watch, onMounted } from 'vue'
|
||||||
import { Combobox, ComboboxInput, ComboboxOptions } from '@headlessui/vue'
|
import { Combobox, ComboboxInput, ComboboxOptions } from '@headlessui/vue'
|
||||||
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue'
|
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue'
|
||||||
|
import { useDebounceFn } from '@vueuse/core'
|
||||||
import { useFuse } from '@vueuse/integrations/useFuse'
|
import { useFuse } from '@vueuse/integrations/useFuse'
|
||||||
import { groupBy, map } from 'lodash-es'
|
import { groupBy, map } from 'lodash-es'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
@@ -52,6 +75,7 @@ import type { Group, Command } from '../../types/command-palette'
|
|||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import Button from '../elements/Button.vue'
|
import Button from '../elements/Button.vue'
|
||||||
import CommandPaletteGroup from './CommandPaletteGroup.vue'
|
import CommandPaletteGroup from './CommandPaletteGroup.vue'
|
||||||
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -78,13 +102,13 @@ const props = defineProps({
|
|||||||
type: Array as PropType<Group[]>,
|
type: Array as PropType<Group[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
closeIcon: {
|
|
||||||
type: String,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
inputIcon: {
|
inputIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'heroicons-outline:search'
|
default: () => $ui.commandPalette.input.icon.name
|
||||||
|
},
|
||||||
|
inputCloseIcon: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.commandPalette.input.close.icon.name
|
||||||
},
|
},
|
||||||
inputPlaceholder: {
|
inputPlaceholder: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -92,7 +116,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
emptyIcon: {
|
emptyIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'heroicons-outline:search'
|
default: () => $ui.commandPalette.empty.icon.name
|
||||||
},
|
},
|
||||||
groupAttribute: {
|
groupAttribute: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -104,15 +128,23 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Object as PropType<Partial<UseFuseOptions<Command>>>,
|
type: Object as PropType<Partial<UseFuseOptions<Command>>>,
|
||||||
default: () => {}
|
default: () => ({})
|
||||||
},
|
},
|
||||||
autoselect: {
|
autoselect: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
autoclear: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
},
|
||||||
|
debounce: {
|
||||||
|
type: Number,
|
||||||
|
default: 200
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -130,6 +162,7 @@ onMounted(() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// @ts-expect-error internals
|
||||||
const popoverProvides = comboboxInput.value?.$.provides
|
const popoverProvides = comboboxInput.value?.$.provides
|
||||||
if (!popoverProvides) {
|
if (!popoverProvides) {
|
||||||
return
|
return
|
||||||
@@ -147,33 +180,56 @@ const options: ComputedRef<Partial<UseFuseOptions<Command>>> = computed(() => de
|
|||||||
matchAllWhenSearchEmpty: true
|
matchAllWhenSearchEmpty: true
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const commands = computed(() => props.groups.reduce((acc, group) => {
|
const commands = computed(() => props.groups.filter(group => !group.search).reduce((acc, group) => {
|
||||||
return acc.concat(group.commands.map(command => ({ ...command, group: group.key })))
|
return acc.concat(group.commands.map(command => ({ ...command, group: group.key })))
|
||||||
}, [] as Command[]))
|
}, [] as Command[]))
|
||||||
|
|
||||||
|
const searchResults = ref<{ [key: string]: any }>({})
|
||||||
|
|
||||||
const { results } = useFuse(query, commands, options)
|
const { results } = useFuse(query, commands, options)
|
||||||
|
|
||||||
const groups = computed(() => map(groupBy(results.value, command => command.item.group), (results, key) => {
|
const groups = computed(() => ([
|
||||||
const commands = results.map((result) => {
|
...map(groupBy(results.value, command => command.item.group), (results, key) => {
|
||||||
const { item, ...data } = result
|
const commands = results.map((result) => {
|
||||||
|
const { item, ...data } = result
|
||||||
|
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...props.groups.find(group => group.key === key),
|
||||||
...data
|
commands: commands.slice(0, options.value.resultLimit)
|
||||||
}
|
} as Group
|
||||||
})
|
}),
|
||||||
|
...props.groups.filter(group => !!group.search).map(group => ({ ...group, commands: (searchResults.value[group.key] || []).slice(0, options.value.resultLimit) })).filter(group => group.commands.length)
|
||||||
|
]))
|
||||||
|
|
||||||
return {
|
const debouncedSearch = useDebounceFn(async () => {
|
||||||
...props.groups.find(group => group.key === key),
|
const searchableGroups = props.groups.filter(group => !!group.search)
|
||||||
commands: commands.slice(0, options.value.resultLimit)
|
|
||||||
}
|
await Promise.all(searchableGroups.map(async (group) => {
|
||||||
}))
|
searchResults.value[group.key] = await group.search(query.value)
|
||||||
|
}))
|
||||||
|
}, props.debounce)
|
||||||
|
|
||||||
|
watch(query, () => {
|
||||||
|
debouncedSearch()
|
||||||
|
|
||||||
|
// Select first item on search changes
|
||||||
|
setTimeout(() => {
|
||||||
|
// https://github.com/tailwindlabs/headlessui/blob/6fa6074cd5d3a96f78a2d965392aa44101f5eede/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L804
|
||||||
|
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'PageUp' }))
|
||||||
|
}, 0)
|
||||||
|
})
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
|
|
||||||
function activateFirstOption () {
|
function activateFirstOption () {
|
||||||
// hack combobox by using keyboard event
|
// hack combobox by using keyboard event
|
||||||
// https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L692
|
// https://github.com/tailwindlabs/headlessui/blob/6fa6074cd5d3a96f78a2d965392aa44101f5eede/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L769
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
|
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
|
||||||
}, 0)
|
}, 0)
|
||||||
@@ -183,7 +239,7 @@ function onSelect (option: Command | Command[]) {
|
|||||||
emit('update:modelValue', option, { query: query.value })
|
emit('update:modelValue', option, { query: query.value })
|
||||||
|
|
||||||
// Clear input after selection
|
// Clear input after selection
|
||||||
if (!props.multiple) {
|
if (props.autoclear) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
query.value = ''
|
query.value = ''
|
||||||
}, 0)
|
}, 0)
|
||||||
@@ -199,7 +255,8 @@ function onClear () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
updateQuery: (q) => {
|
query,
|
||||||
|
updateQuery: (q: string) => {
|
||||||
query.value = q
|
query.value = q
|
||||||
},
|
},
|
||||||
comboboxApi,
|
comboboxApi,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<li class="p-2">
|
<div class="p-2" role="option">
|
||||||
<h2 v-if="group[groupAttribute]" class="px-3 my-2 text-xs font-semibold u-text-gray-900">
|
<h2 v-if="label" class="px-3 my-2 text-xs font-semibold u-text-gray-900">
|
||||||
{{ group[groupAttribute] }}
|
{{ label }}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<ul class="text-sm u-text-gray-700">
|
<div class="text-sm u-text-gray-700" role="listbox" :aria-label="group[groupAttribute]">
|
||||||
<ComboboxOption
|
<ComboboxOption
|
||||||
v-for="(command, index) of group.commands"
|
v-for="(command, index) of group.commands"
|
||||||
:key="`${group.key}-${index}`"
|
:key="`${group.key}-${index}`"
|
||||||
@@ -13,15 +13,18 @@
|
|||||||
:disabled="command.disabled"
|
:disabled="command.disabled"
|
||||||
as="template"
|
as="template"
|
||||||
>
|
>
|
||||||
<li :class="['flex justify-between select-none items-center rounded-md px-3 py-2 gap-3 relative', active && 'bg-gray-100 dark:bg-gray-800 u-text-gray-900', command.disabled ? 'cursor-not-allowed' : 'cursor-pointer']">
|
<div :class="['flex justify-between select-none items-center rounded-md px-3 py-2 gap-3 relative', active && 'bg-gray-100 dark:bg-gray-800 u-text-gray-900', command.disabled ? 'cursor-not-allowed' : 'cursor-pointer']">
|
||||||
<div class="flex items-center gap-2 min-w-0">
|
<div class="flex items-center gap-2 min-w-0">
|
||||||
<Icon v-if="command.icon" :name="command.icon" :class="['h-4 w-4 flex-shrink-0', active ? 'text-opacity-100 dark:text-opacity-100' : 'text-opacity-40 dark:text-opacity-40', command.iconClass || 'text-gray-900 dark:text-gray-50']" aria-hidden="true" />
|
<slot :name="`${group.key}-icon`" :group="group" :command="command">
|
||||||
<Avatar
|
<Icon v-if="command.icon" :name="command.icon" :class="['h-4 w-4 flex-shrink-0', active ? 'text-opacity-100 dark:text-opacity-100' : 'text-opacity-40 dark:text-opacity-40', command.iconClass || 'text-gray-900 dark:text-gray-50']" aria-hidden="true" />
|
||||||
v-else-if="command.avatar"
|
<Avatar
|
||||||
v-bind="{ size: 'xxxs', ...command.avatar }"
|
v-else-if="command.avatar"
|
||||||
class="flex-shrink-0"
|
v-bind="{ size: 'xxxs', ...command.avatar }"
|
||||||
/>
|
class="flex-shrink-0"
|
||||||
<span v-else-if="command.chip" class="flex-shrink-0 w-2 h-2 mx-1 rounded-full" :style="{ background: `#${command.chip}` }" />
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span v-else-if="command.chip" class="flex-shrink-0 w-2 h-2 mx-1 rounded-full" :style="{ background: `#${command.chip}` }" />
|
||||||
|
</slot>
|
||||||
|
|
||||||
<div class="flex items-center gap-1.5 min-w-0" :class="{ 'opacity-50': command.disabled }">
|
<div class="flex items-center gap-1.5 min-w-0" :class="{ 'opacity-50': command.disabled }">
|
||||||
<slot :name="`${group.key}-command`" :group="group" :command="command">
|
<slot :name="`${group.key}-command`" :group="group" :command="command">
|
||||||
@@ -34,34 +37,40 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Icon v-if="selected" name="heroicons-outline:check" class="h-5 w-5 u-text-gray-900 flex-shrink-0" aria-hidden="true" />
|
<Icon v-if="selected" :name="$ui.commandPalette.option.selected.icon.name" class="h-5 w-5 u-text-gray-900 flex-shrink-0" aria-hidden="true" />
|
||||||
<slot v-else-if="active && (group.active || $slots[`${group.key}-active`])" :name="`${group.key}-active`" :group="group" :command="command">
|
<slot v-else-if="active && (group.active || $slots[`${group.key}-active`])" :name="`${group.key}-active`" :group="group" :command="command">
|
||||||
<span v-if="group.active" class="flex-shrink-0 u-text-gray-500">{{ group.active }}</span>
|
<span v-if="group.active" class="flex-shrink-0 u-text-gray-500">{{ group.active }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
<slot v-else :name="`${group.key}-inactive`" :group="group" :command="command">
|
<slot v-else :name="`${group.key}-inactive`" :group="group" :command="command">
|
||||||
<span v-if="command.shortcuts?.length" class="flex-shrink-0 text-xs font-semibold u-text-gray-500">
|
<span v-if="command.shortcuts?.length" :class="$ui.commandPalette.option.shortcuts">
|
||||||
<kbd v-for="shortcut of command.shortcuts" :key="shortcut" class="font-sans">{{ shortcut }}</kbd>
|
<kbd v-for="shortcut of command.shortcuts" :key="shortcut" class="font-sans">{{ shortcut }}</kbd>
|
||||||
</span>
|
</span>
|
||||||
<span v-else-if="!command.disabled && group.inactive" class="flex-shrink-0 u-text-gray-500">{{ group.inactive }}</span>
|
<span v-else-if="!command.disabled && group.inactive" class="flex-shrink-0 u-text-gray-500">{{ group.inactive }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</li>
|
</div>
|
||||||
</ComboboxOption>
|
</ComboboxOption>
|
||||||
</ul>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
import { ComboboxOption } from '@headlessui/vue'
|
import { ComboboxOption } from '@headlessui/vue'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import Avatar from '../elements/Avatar.vue'
|
import Avatar from '../elements/Avatar.vue'
|
||||||
import type { Group } from '../../types/command-palette'
|
import type { Group } from '../../types/command-palette'
|
||||||
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
group: {
|
group: {
|
||||||
type: Object as PropType<Group>,
|
type: Object as PropType<Group>,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
query: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
groupAttribute: {
|
groupAttribute: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
@@ -72,7 +81,13 @@ defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function highlight ({ indices, value }, i = 1) {
|
const label = computed(() => {
|
||||||
|
const label = props.group[props.groupAttribute]
|
||||||
|
|
||||||
|
return typeof label === 'function' ? label(props.query) : label
|
||||||
|
})
|
||||||
|
|
||||||
|
function highlight ({ indices, value }: { indices: number[][], value:string }, i = 1): string {
|
||||||
const pair = indices[indices.length - i]
|
const pair = indices[indices.length - i]
|
||||||
if (!pair) {
|
if (!pair) {
|
||||||
return value
|
return value
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
v-slot="{ isActive }"
|
v-slot="{ isActive }"
|
||||||
:key="index"
|
:key="index"
|
||||||
v-bind="link"
|
v-bind="link"
|
||||||
:class="[baseClass, spacingClass]"
|
:class="[baseClass, spacingClass].join(' ')"
|
||||||
:active-class="activeClass"
|
:active-class="activeClass"
|
||||||
:inactive-class="inactiveClass"
|
:inactive-class="inactiveClass"
|
||||||
@click="link.click && link.click()"
|
@click="link.click && link.click()"
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
|
import type { RouteLocationNormalized } from 'vue-router'
|
||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import Link from '../elements/Link.vue'
|
import Link from '../elements/Link.vue'
|
||||||
import Avatar from '../elements/Avatar.vue'
|
import Avatar from '../elements/Avatar.vue'
|
||||||
@@ -48,6 +49,8 @@ import $ui from '#build/ui'
|
|||||||
defineProps({
|
defineProps({
|
||||||
links: {
|
links: {
|
||||||
type: Array as PropType<{
|
type: Array as PropType<{
|
||||||
|
to?: RouteLocationNormalized | string
|
||||||
|
exact?: boolean
|
||||||
label: string
|
label: string
|
||||||
icon?: string
|
icon?: string
|
||||||
iconClass?: string
|
iconClass?: string
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="isOpen" ref="container" :class="[containerClass, widthClass]">
|
<div v-if="isOpen" ref="container" :class="[containerClass, widthClass]">
|
||||||
<transition appear v-bind="transitionClass">
|
<transition appear v-bind="transitionClass">
|
||||||
<div :class="baseClass">
|
<div :class="[baseClass, ringClass, roundedClass, shadowClass, backgroundClass]">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -9,8 +9,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType, computed, toRef } from 'vue'
|
import type { PropType, Ref } from 'vue'
|
||||||
|
import { computed, toRef } from 'vue'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
|
import type { VirtualElement } from '@popperjs/core'
|
||||||
import { usePopper } from '../../composables/usePopper'
|
import { usePopper } from '../../composables/usePopper'
|
||||||
import type { PopperOptions } from '../../types'
|
import type { PopperOptions } from '../../types'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
@@ -36,6 +38,22 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.contextMenu.width
|
default: () => $ui.contextMenu.width
|
||||||
},
|
},
|
||||||
|
backgroundClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.contextMenu.background
|
||||||
|
},
|
||||||
|
shadowClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.contextMenu.shadow
|
||||||
|
},
|
||||||
|
roundedClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.contextMenu.rounded
|
||||||
|
},
|
||||||
|
ringClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.contextMenu.ring
|
||||||
|
},
|
||||||
baseClass: {
|
baseClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.contextMenu.base
|
default: () => $ui.contextMenu.base
|
||||||
@@ -46,7 +64,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
type: Object as PropType<PopperOptions>,
|
type: Object as PropType<PopperOptions>,
|
||||||
default: () => {}
|
default: () => ({})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -61,7 +79,7 @@ const isOpen = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const virtualElement = toRef(props, 'virtualElement')
|
const virtualElement = toRef(props, 'virtualElement') as Ref<VirtualElement>
|
||||||
|
|
||||||
const popperOptions = computed<PopperOptions>(() => defu({}, props.popperOptions, $ui.contextMenu.popperOptions))
|
const popperOptions = computed<PopperOptions>(() => defu({}, props.popperOptions, $ui.contextMenu.popperOptions))
|
||||||
|
|
||||||
|
|||||||
@@ -20,24 +20,24 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-if="description && actions.length" class="mt-3 flex items-center gap-6">
|
<div v-if="description && actions.length" class="mt-3 flex items-center gap-6">
|
||||||
<button v-for="(action, index) of actions" :key="index" type="button" class="text-sm font-medium focus:outline-none text-primary-500 hover:text-primary-600 dark:hover:text-primary-400" @click.stop="onAction(action)">
|
<button v-for="(action, index) of actions" :key="index" type="button" class="text-sm font-medium focus:outline-none text-primary-500 dark:text-primary-400 hover:text-primary-400 dark:hover:text-primary-500" @click.stop="onAction(action)">
|
||||||
{{ action.label }}
|
{{ action.label }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-shrink-0 flex items-center gap-3">
|
<div class="flex-shrink-0 flex items-center gap-3">
|
||||||
<div v-if="!description && actions.length" class="flex items-center gap-2">
|
<div v-if="!description && actions.length" class="flex items-center gap-2">
|
||||||
<button v-for="(action, index) of actions" :key="index" type="button" class="text-sm font-medium focus:outline-none text-primary-500 hover:text-primary-600 dark:hover:text-primary-400" @click.stop="onAction(action)">
|
<button v-for="(action, index) of actions" :key="index" type="button" class="text-sm font-medium focus:outline-none text-primary-500 dark:text-primary-400 hover:text-primary-400 dark:hover:text-primary-500" @click.stop="onAction(action)">
|
||||||
{{ action.label }}
|
{{ action.label }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="transition duration-150 ease-in-out u-text-gray-400 focus:outline-none hover:u-text-gray-500 focus:u-text-gray-500"
|
class="inline-flex transition duration-150 ease-in-out u-text-gray-400 focus:outline-none hover:u-text-gray-500 focus:u-text-gray-500"
|
||||||
@click.stop="onClose"
|
@click.stop="onClose"
|
||||||
>
|
>
|
||||||
<span class="sr-only">Close</span>
|
<span class="sr-only">Close</span>
|
||||||
<Icon name="heroicons-solid:x" class="w-5 h-5" />
|
<Icon :name="$ui.notification.close.icon.name" class="w-5 h-5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,6 +56,7 @@ import type { PropType } from 'vue'
|
|||||||
import Icon from '../elements/Icon.vue'
|
import Icon from '../elements/Icon.vue'
|
||||||
import { useTimer } from '../../composables/useTimer'
|
import { useTimer } from '../../composables/useTimer'
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
|
import type { ToastNotificationAction } from '../../types'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -172,7 +173,7 @@ function onClose () {
|
|||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAction (action) {
|
function onAction (action: ToastNotificationAction) {
|
||||||
if (timer) {
|
if (timer) {
|
||||||
timer.stop()
|
timer.stop()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
v-bind="notification"
|
v-bind="notification"
|
||||||
:class="notification.click && 'cursor-pointer'"
|
:class="notification.click && 'cursor-pointer'"
|
||||||
@click="notification.click && notification.click(notification)"
|
@click="notification.click && notification.click(notification)"
|
||||||
@close="$toast.removeNotification(notification.id)"
|
@close="toast.removeNotification(notification.id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -17,11 +17,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { ToastNotification } from '../../types'
|
||||||
|
import { useToast } from '../../composables/useToast'
|
||||||
import Notification from './Notification.vue'
|
import Notification from './Notification.vue'
|
||||||
import { useNuxtApp, useState } from '#imports'
|
import { useState } from '#imports'
|
||||||
|
|
||||||
const { $toast } = useNuxtApp()
|
const toast = useToast()
|
||||||
const notifications = useState('notifications', () => [])
|
const notifications = useState<ToastNotification[]>('notifications', () => [])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<Popover v-slot="{ open, close }" :class="wrapperClass" @mouseleave="onMouseLeave">
|
<Popover v-slot="{ open, close }" :class="wrapperClass" @mouseleave="onMouseLeave">
|
||||||
<PopoverButton ref="trigger" as="div" class="inline-flex" @mouseover="onMouseOver">
|
<PopoverButton
|
||||||
|
ref="trigger"
|
||||||
|
as="div"
|
||||||
|
:disabled="disabled"
|
||||||
|
class="inline-flex w-full"
|
||||||
|
role="button"
|
||||||
|
@mouseover="onMouseOver"
|
||||||
|
>
|
||||||
<slot :open="open" :close="close">
|
<slot :open="open" :close="close">
|
||||||
<button>Open</button>
|
<button :disabled="disabled">
|
||||||
|
Open
|
||||||
|
</button>
|
||||||
</slot>
|
</slot>
|
||||||
</PopoverButton>
|
</PopoverButton>
|
||||||
|
|
||||||
<div v-if="open" ref="container" :class="[containerClass, widthClass]" @mouseover="onMouseOver">
|
<div v-if="open" ref="container" :class="[containerClass, widthClass]" @mouseover="onMouseOver">
|
||||||
<transition appear v-bind="transitionClass">
|
<transition appear v-bind="transitionClass">
|
||||||
<PopoverPanel :class="baseClass" static>
|
<PopoverPanel :class="[baseClass, ringClass, roundedClass, shadowClass, backgroundClass]" static>
|
||||||
<slot name="panel" :open="open" :close="close" />
|
<slot name="panel" :open="open" :close="close" />
|
||||||
</PopoverPanel>
|
</PopoverPanel>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -17,8 +26,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Ref, PropType } from 'vue'
|
|
||||||
import { computed, ref, onMounted } from 'vue'
|
import { computed, ref, onMounted } from 'vue'
|
||||||
|
import type { PropType } from 'vue'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
|
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
|
||||||
import { usePopper } from '../../composables/usePopper'
|
import { usePopper } from '../../composables/usePopper'
|
||||||
@@ -33,6 +42,10 @@ const props = defineProps({
|
|||||||
return ['click', 'hover'].includes(value)
|
return ['click', 'hover'].includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
wrapperClass: {
|
wrapperClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.popover.wrapper
|
default: () => $ui.popover.wrapper
|
||||||
@@ -43,19 +56,35 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
widthClass: {
|
widthClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.tooltip.width
|
default: () => $ui.popover.width
|
||||||
},
|
},
|
||||||
baseClass: {
|
baseClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.popover.base
|
default: () => $ui.popover.base
|
||||||
},
|
},
|
||||||
|
backgroundClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.popover.background
|
||||||
|
},
|
||||||
|
shadowClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.popover.shadow
|
||||||
|
},
|
||||||
|
roundedClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.popover.rounded
|
||||||
|
},
|
||||||
|
ringClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.popover.ring
|
||||||
|
},
|
||||||
transitionClass: {
|
transitionClass: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => $ui.popover.transition
|
default: () => $ui.popover.transition
|
||||||
},
|
},
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
type: Object as PropType<PopperOptions>,
|
type: Object as PropType<PopperOptions>,
|
||||||
default: () => {}
|
default: () => ({})
|
||||||
},
|
},
|
||||||
openDelay: {
|
openDelay: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -72,25 +101,20 @@ const popperOptions = computed<PopperOptions>(() => defu({}, props.popperOptions
|
|||||||
const [trigger, container] = usePopper(popperOptions.value)
|
const [trigger, container] = usePopper(popperOptions.value)
|
||||||
|
|
||||||
// https://github.com/tailwindlabs/headlessui/blob/f66f4926c489fc15289d528294c23a3dc2aee7b1/packages/%40headlessui-vue/src/components/popover/popover.ts#L151
|
// https://github.com/tailwindlabs/headlessui/blob/f66f4926c489fc15289d528294c23a3dc2aee7b1/packages/%40headlessui-vue/src/components/popover/popover.ts#L151
|
||||||
const popoverApi: Ref<any> = ref(null)
|
const popoverApi = ref<any>(null)
|
||||||
|
|
||||||
let openTimeout: NodeJS.Timeout | null = null
|
let openTimeout: NodeJS.Timeout | null = null
|
||||||
let closeTimeout: NodeJS.Timeout | null = null
|
let closeTimeout: NodeJS.Timeout | null = null
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// @ts-expect-error internals
|
||||||
const popoverProvides = trigger.value?.$.provides
|
const popoverProvides = trigger.value?.$.provides
|
||||||
if (!popoverProvides) {
|
if (!popoverProvides) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const popoverProvidesSymbols = Object.getOwnPropertySymbols(popoverProvides)
|
const popoverProvidesSymbols = Object.getOwnPropertySymbols(popoverProvides)
|
||||||
popoverApi.value = popoverProvidesSymbols.length && popoverProvides[popoverProvidesSymbols[0]]
|
popoverApi.value = popoverProvidesSymbols.length && popoverProvides[popoverProvidesSymbols[0]]
|
||||||
// stop trigger click propagation on hover
|
|
||||||
popoverApi.value?.button?.addEventListener('click', (e: Event) => {
|
|
||||||
if (props.mode === 'hover') {
|
|
||||||
e.stopPropagation()
|
|
||||||
}
|
|
||||||
}, true)
|
|
||||||
}, 200)
|
}, 200)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
||||||
<Dialog :class="[wrapperClass, { 'justify-end': side === 'right' }]" @close="isOpen = false">
|
<Dialog :class="[wrapperClass, { 'justify-end': side === 'right' }]" @close="close">
|
||||||
<TransitionChild
|
<TransitionChild
|
||||||
v-if="overlay"
|
v-if="overlay"
|
||||||
as="template"
|
as="template"
|
||||||
@@ -89,7 +89,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue', 'close'])
|
||||||
|
|
||||||
const isOpen: WritableComputedRef<boolean> = computed({
|
const isOpen: WritableComputedRef<boolean> = computed({
|
||||||
get () {
|
get () {
|
||||||
@@ -129,6 +129,11 @@ const slideoverTransition = computed(() => {
|
|||||||
...props.transitionClass
|
...props.transitionClass
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function close (value: boolean) {
|
||||||
|
isOpen.value = value
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
Hover me
|
Hover me
|
||||||
</slot>
|
</slot>
|
||||||
|
|
||||||
<div v-if="open" ref="container" :class="[containerClass, widthClass]">
|
<div v-if="open && !prevent" ref="container" :class="[containerClass, widthClass]">
|
||||||
<transition appear v-bind="transitionClass">
|
<transition appear v-bind="transitionClass">
|
||||||
<div :class="[baseClass, backgroundClass, roundedClass, shadowClass, ringClass]">
|
<div :class="[baseClass, backgroundClass, roundedClass, shadowClass, ringClass]">
|
||||||
<slot name="text">
|
<slot name="text">
|
||||||
<span class="truncate">{{ text }}</span>
|
{{ text }}
|
||||||
</slot>
|
</slot>
|
||||||
|
|
||||||
<span v-if="shortcuts?.length" class="inline-flex items-center justify-end flex-shrink-0 gap-0.5 ml-1">
|
<span v-if="shortcuts?.length" :class="shortcutsClass">
|
||||||
<span class="mr-1 u-text-gray-700">·</span>
|
<span class="mr-1 u-text-gray-700">·</span>
|
||||||
<kbd v-for="shortcut of shortcuts" :key="shortcut" class="flex items-center justify-center font-sans px-1 h-4 min-w-[16px] text-[10px] u-bg-gray-100 rounded u-text-gray-900">
|
<kbd v-for="shortcut of shortcuts" :key="shortcut" class="flex items-center justify-center font-sans px-1 h-4 min-w-[16px] text-[10px] u-bg-gray-100 rounded u-text-gray-900">
|
||||||
{{ shortcut }}
|
{{ shortcut }}
|
||||||
@@ -36,6 +36,10 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
prevent: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
shortcuts: {
|
shortcuts: {
|
||||||
type: Array as PropType<string[]>,
|
type: Array as PropType<string[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
@@ -78,7 +82,11 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
popperOptions: {
|
popperOptions: {
|
||||||
type: Object as PropType<PopperOptions>,
|
type: Object as PropType<PopperOptions>,
|
||||||
default: () => {}
|
default: () => ({})
|
||||||
|
},
|
||||||
|
shortcutsClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.tooltip.shortcuts
|
||||||
},
|
},
|
||||||
openDelay: {
|
openDelay: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
109
src/runtime/composables/defineShortcuts.ts
Normal file
109
src/runtime/composables/defineShortcuts.ts
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import type { Ref, ComputedRef } from 'vue'
|
||||||
|
import { logicAnd, logicNot } from '@vueuse/math'
|
||||||
|
import { computed, onMounted, onBeforeUnmount } from 'vue'
|
||||||
|
import { useShortcuts } from './useShortcuts'
|
||||||
|
|
||||||
|
export interface ShortcutConfig {
|
||||||
|
handler: Function
|
||||||
|
usingInput?: string | boolean
|
||||||
|
whenever?: Ref<Boolean>[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShortcutsConfig {
|
||||||
|
[key: string]: ShortcutConfig | Function
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Shortcut {
|
||||||
|
handler: Function
|
||||||
|
condition: ComputedRef<Boolean>
|
||||||
|
// KeyboardEvent attributes
|
||||||
|
key: string
|
||||||
|
ctrlKey: boolean
|
||||||
|
metaKey: boolean
|
||||||
|
shiftKey: boolean
|
||||||
|
altKey: boolean
|
||||||
|
// code?: string
|
||||||
|
// keyCode?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defineShortcuts = (config: ShortcutsConfig) => {
|
||||||
|
const { macOS, usingInput } = useShortcuts()
|
||||||
|
|
||||||
|
let shortcuts: Shortcut[] = []
|
||||||
|
|
||||||
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
|
const alphabeticalKey = /^[a-z]{1}$/i.test(e.key)
|
||||||
|
|
||||||
|
for (const shortcut of shortcuts) {
|
||||||
|
if (e.key.toLowerCase() !== shortcut.key) { continue }
|
||||||
|
if (e.metaKey !== shortcut.metaKey) { continue }
|
||||||
|
if (e.ctrlKey !== shortcut.ctrlKey) { continue }
|
||||||
|
// shift modifier is only checked in combination with alphabetical keys
|
||||||
|
// (shift with non-alphabetical keys would change the key)
|
||||||
|
if (alphabeticalKey && e.shiftKey !== shortcut.shiftKey) { continue }
|
||||||
|
// alt modifier changes the combined key anyways
|
||||||
|
// if (e.altKey !== shortcut.altKey) { continue }
|
||||||
|
|
||||||
|
if (shortcut.condition.value) {
|
||||||
|
e.preventDefault()
|
||||||
|
shortcut.handler()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// Map config to full detailled shortcuts
|
||||||
|
shortcuts = Object.entries(config).map(([key, shortcutConfig]) => {
|
||||||
|
if (!shortcutConfig) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse key and modifiers
|
||||||
|
const keySplit = key.toLowerCase().split('_').map(k => k)
|
||||||
|
let shortcut: Partial<Shortcut> = {
|
||||||
|
key: keySplit.filter(k => !['meta', 'ctrl', 'shift', 'alt'].includes(k)).join('_'),
|
||||||
|
metaKey: keySplit.includes('meta'),
|
||||||
|
ctrlKey: keySplit.includes('ctrl'),
|
||||||
|
shiftKey: keySplit.includes('shift'),
|
||||||
|
altKey: keySplit.includes('alt')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert Meta to Ctrl for non-MacOS
|
||||||
|
if (!macOS.value && shortcut.metaKey && !shortcut.ctrlKey) {
|
||||||
|
shortcut.metaKey = false
|
||||||
|
shortcut.ctrlKey = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve handler function
|
||||||
|
if (typeof shortcutConfig === 'function') {
|
||||||
|
shortcut.handler = shortcutConfig
|
||||||
|
} else if (typeof shortcutConfig === 'object') {
|
||||||
|
shortcut = { ...shortcut, handler: shortcutConfig.handler }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shortcut.handler) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.trace('[Shortcut] Invalid value')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create shortcut computed
|
||||||
|
const conditions = []
|
||||||
|
if (!(shortcutConfig as ShortcutConfig).usingInput) {
|
||||||
|
conditions.push(logicNot(usingInput))
|
||||||
|
} else if (typeof (shortcutConfig as ShortcutConfig).usingInput === 'string') {
|
||||||
|
conditions.push(computed(() => usingInput.value === (shortcutConfig as ShortcutConfig).usingInput))
|
||||||
|
}
|
||||||
|
shortcut.condition = logicAnd(...conditions, ...((shortcutConfig as ShortcutConfig).whenever || []))
|
||||||
|
|
||||||
|
return shortcut as Shortcut
|
||||||
|
}).filter(Boolean) as Shortcut[]
|
||||||
|
|
||||||
|
document.addEventListener('keydown', onKeyDown)
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
document.removeEventListener('keydown', onKeyDown)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { useClipboard } from '@vueuse/core'
|
import { useClipboard } from '@vueuse/core'
|
||||||
import { defineNuxtPlugin } from '#app'
|
import { useToast } from './useToast'
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export function useCopyToClipboard () {
|
||||||
const { copy: copyToClipboard, isSupported } = useClipboard()
|
const { copy: copyToClipboard, isSupported } = useClipboard()
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
function copy (text: string, success: { title?: string, description?: string } = {}, failure: { title?: string, description?: string } = {}) {
|
function copy (text: string, success: { title?: string, description?: string } = {}, failure: { title?: string, description?: string } = {}) {
|
||||||
if (!isSupported) {
|
if (!isSupported) {
|
||||||
@@ -14,9 +15,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nuxtApp.$toast.success(success)
|
toast.success(success)
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
nuxtApp.$toast.error({
|
toast.error({
|
||||||
...failure,
|
...failure,
|
||||||
description: failure.description || e.message
|
description: failure.description || e.message
|
||||||
})
|
})
|
||||||
@@ -24,10 +25,6 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
provide: {
|
copy
|
||||||
clipboard: {
|
|
||||||
copy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ref, onMounted, watchEffect } from 'vue'
|
import { ref, onMounted, watchEffect } from 'vue'
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
import { popperGenerator, defaultModifiers } from '@popperjs/core/lib/popper-lite'
|
import { popperGenerator, defaultModifiers, VirtualElement } from '@popperjs/core/lib/popper-lite'
|
||||||
import type { Instance } from '@popperjs/core'
|
import type { Instance } from '@popperjs/core'
|
||||||
import { omitBy, isUndefined } from 'lodash-es'
|
import { omitBy, isUndefined } from 'lodash-es'
|
||||||
import flip from '@popperjs/core/lib/modifiers/flip'
|
import flip from '@popperjs/core/lib/modifiers/flip'
|
||||||
@@ -8,6 +8,7 @@ import offset from '@popperjs/core/lib/modifiers/offset'
|
|||||||
import preventOverflow from '@popperjs/core/lib/modifiers/preventOverflow'
|
import preventOverflow from '@popperjs/core/lib/modifiers/preventOverflow'
|
||||||
import computeStyles from '@popperjs/core/lib/modifiers/computeStyles'
|
import computeStyles from '@popperjs/core/lib/modifiers/computeStyles'
|
||||||
import eventListeners from '@popperjs/core/lib/modifiers/eventListeners'
|
import eventListeners from '@popperjs/core/lib/modifiers/eventListeners'
|
||||||
|
import { MaybeElement, unrefElement } from '@vueuse/core'
|
||||||
import type { PopperOptions } from '../types'
|
import type { PopperOptions } from '../types'
|
||||||
|
|
||||||
export const createPopper = popperGenerator({
|
export const createPopper = popperGenerator({
|
||||||
@@ -25,21 +26,22 @@ export function usePopper ({
|
|||||||
resize = true,
|
resize = true,
|
||||||
placement,
|
placement,
|
||||||
strategy
|
strategy
|
||||||
}: PopperOptions, virtualReference: Ref<Object> = null) {
|
}: PopperOptions, virtualReference?: Ref<Element | VirtualElement>) {
|
||||||
const reference: Ref<HTMLElement> = ref(null)
|
const reference = ref<MaybeElement>(null)
|
||||||
const popper: Ref<HTMLElement> = ref(null)
|
const popper = ref<MaybeElement>(null)
|
||||||
const instance: Ref<Instance> = ref(null)
|
const instance = ref<Instance | null>(null)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
watchEffect((onInvalidate) => {
|
watchEffect((onInvalidate) => {
|
||||||
if (!popper.value) { return }
|
if (!popper.value) { return }
|
||||||
if (!reference.value && !virtualReference.value) { return }
|
if (!reference.value && !virtualReference?.value) { return }
|
||||||
|
|
||||||
const popperEl = popper.value.$el || popper.value
|
const popperEl = unrefElement(popper)
|
||||||
const referenceEl = virtualReference?.value || reference.value.$el || reference.value
|
const referenceEl = virtualReference?.value || unrefElement(reference)
|
||||||
|
|
||||||
// if (!(referenceEl instanceof HTMLElement)) { return }
|
// if (!(referenceEl instanceof HTMLElement)) { return }
|
||||||
if (!(popperEl instanceof HTMLElement)) { return }
|
if (!(popperEl instanceof HTMLElement)) { return }
|
||||||
|
if (!referenceEl) { return }
|
||||||
|
|
||||||
instance.value = createPopper(referenceEl, popperEl, omitBy({
|
instance.value = createPopper(referenceEl, popperEl, omitBy({
|
||||||
placement,
|
placement,
|
||||||
@@ -76,5 +78,5 @@ export function usePopper ({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return [reference, popper, instance]
|
return [reference, popper, instance] as const
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/runtime/composables/useShortcuts.ts
Normal file
32
src/runtime/composables/useShortcuts.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { createSharedComposable, useActiveElement } from '@vueuse/core'
|
||||||
|
import { ref, computed, onMounted } from 'vue'
|
||||||
|
|
||||||
|
export const _useShortcuts = () => {
|
||||||
|
const macOS = computed(() => process.client && navigator && navigator.userAgent && navigator.userAgent.match(/Macintosh;/))
|
||||||
|
|
||||||
|
const metaSymbol = ref(' ')
|
||||||
|
|
||||||
|
const activeElement = useActiveElement()
|
||||||
|
const usingInput = computed(() => {
|
||||||
|
const usingInput = !!(activeElement.value?.tagName === 'INPUT' || activeElement.value?.tagName === 'TEXTAREA' || activeElement.value?.contentEditable === 'true')
|
||||||
|
|
||||||
|
if (usingInput) {
|
||||||
|
return ((activeElement.value as any)?.name as string) || true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
metaSymbol.value = macOS.value ? '⌘' : 'Ctrl'
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
macOS,
|
||||||
|
metaSymbol,
|
||||||
|
activeElement,
|
||||||
|
usingInput
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useShortcuts = createSharedComposable(_useShortcuts)
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
import { Ref, ref, computed } from 'vue-demi'
|
import { ref, computed } from 'vue-demi'
|
||||||
import { useTimestamp } from '@vueuse/core'
|
import { useTimestamp } from '@vueuse/core'
|
||||||
|
import type { UseTimestampOptions } from '@vueuse/core'
|
||||||
|
|
||||||
export function useTimer (cb: (...args: unknown[]) => any, interval: number) {
|
export function useTimer (cb: (...args: unknown[]) => any, interval: number, options?: UseTimestampOptions<true>) {
|
||||||
let timer: number | null = null
|
let timer: number | null = null
|
||||||
const timestamp = useTimestamp({ controls: true })
|
const { pause: tPause, resume: tResume, timestamp } = useTimestamp({ ...(options || {}), controls: true })
|
||||||
const startTime: Ref<number | null> = ref(null)
|
const startTime = ref<number | null>(null)
|
||||||
|
|
||||||
const remaining = computed(() => {
|
const remaining = computed(() => {
|
||||||
if (!startTime.value) {
|
if (!startTime.value) {
|
||||||
return
|
return 0
|
||||||
}
|
}
|
||||||
return interval - (timestamp.timestamp.value - startTime.value)
|
return interval - (timestamp.value - startTime.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
function set (...args: unknown[]) {
|
function set (...args: unknown[]) {
|
||||||
@@ -37,18 +38,18 @@ export function useTimer (cb: (...args: unknown[]) => any, interval: number) {
|
|||||||
|
|
||||||
function stop () {
|
function stop () {
|
||||||
clear()
|
clear()
|
||||||
timestamp.pause()
|
tPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
function pause () {
|
function pause () {
|
||||||
clear()
|
clear()
|
||||||
timestamp.pause()
|
tPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
function resume () {
|
function resume () {
|
||||||
startTime.value += (Date.now() - timestamp.timestamp.value)
|
|
||||||
timestamp.resume()
|
|
||||||
set()
|
set()
|
||||||
|
tResume()
|
||||||
|
startTime.value = (startTime.value || 0) + (Date.now() - timestamp.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
|
|||||||
41
src/runtime/composables/useToast.ts
Normal file
41
src/runtime/composables/useToast.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import type { ToastNotification } from '../types'
|
||||||
|
import { useState } from '#imports'
|
||||||
|
|
||||||
|
export function useToast () {
|
||||||
|
const notifications = useState<ToastNotification[]>('notifications', () => [])
|
||||||
|
|
||||||
|
function addNotification (notification: Partial<ToastNotification>) {
|
||||||
|
const body = {
|
||||||
|
id: new Date().getTime().toString(),
|
||||||
|
...notification
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = notifications.value.findIndex((n: ToastNotification) => n.id === body.id)
|
||||||
|
if (index === -1) {
|
||||||
|
notifications.value.push(body as ToastNotification)
|
||||||
|
}
|
||||||
|
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeNotification (id: string) {
|
||||||
|
notifications.value = notifications.value.filter((n: ToastNotification) => n.id !== id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const success = (notification: Partial<ToastNotification> = {}) => addNotification({ type: 'success', ...notification })
|
||||||
|
|
||||||
|
const info = (notification: Partial<ToastNotification> = {}) => addNotification({ type: 'info', ...notification })
|
||||||
|
|
||||||
|
const warning = (notification: Partial<ToastNotification> = {}) => addNotification({ type: 'warning', ...notification })
|
||||||
|
|
||||||
|
const error = (notification: Partial<ToastNotification>) => addNotification({ type: 'error', title: 'An error occurred!', ...notification })
|
||||||
|
|
||||||
|
return {
|
||||||
|
addNotification,
|
||||||
|
removeNotification,
|
||||||
|
success,
|
||||||
|
info,
|
||||||
|
warning,
|
||||||
|
error
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import type { Ref } from 'vue'
|
|
||||||
import { defineNuxtPlugin, useState } from '#app'
|
|
||||||
import type { ToastNotification } from '../types'
|
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
|
||||||
const notifications: Ref<ToastNotification[]> = useState('notifications', () => [])
|
|
||||||
|
|
||||||
function addNotification (notification: Partial<ToastNotification>) {
|
|
||||||
const body = {
|
|
||||||
id: new Date().getTime().toString(),
|
|
||||||
...notification
|
|
||||||
}
|
|
||||||
|
|
||||||
const index = notifications.value.findIndex((n: ToastNotification) => n.id === body.id)
|
|
||||||
if (index === -1) {
|
|
||||||
notifications.value.push(body as ToastNotification)
|
|
||||||
}
|
|
||||||
|
|
||||||
return body
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeNotification (id: string) {
|
|
||||||
notifications.value = notifications.value.filter((n: ToastNotification) => n.id !== id)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
provide: {
|
|
||||||
toast: {
|
|
||||||
addNotification,
|
|
||||||
removeNotification,
|
|
||||||
success (notification: Partial<ToastNotification> = {}) {
|
|
||||||
return addNotification({ type: 'success', ...notification })
|
|
||||||
},
|
|
||||||
info (notification: Partial<ToastNotification> = {}) {
|
|
||||||
return addNotification({ type: 'info', ...notification })
|
|
||||||
},
|
|
||||||
warning (notification: Partial<ToastNotification> = {}) {
|
|
||||||
return addNotification({ type: 'warning', ...notification })
|
|
||||||
},
|
|
||||||
error (notification: Partial<ToastNotification>) {
|
|
||||||
return addNotification({ type: 'error', title: 'An error occurred!', ...notification })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (variantColors: string[]) => {
|
export default function defaultPreset (variantColors: string[]) {
|
||||||
const button = {
|
const button = {
|
||||||
base: 'font-medium focus:outline-none disabled:cursor-not-allowed disabled:opacity-75 focus:ring-offset-white dark:focus:ring-offset-black',
|
base: 'font-medium focus:outline-none disabled:cursor-not-allowed disabled:opacity-75 focus:ring-offset-white dark:focus:ring-offset-black',
|
||||||
rounded: 'rounded-md',
|
rounded: 'rounded-md',
|
||||||
@@ -26,6 +26,14 @@ export default (variantColors: string[]) => {
|
|||||||
lg: 'p-2',
|
lg: 'p-2',
|
||||||
xl: 'p-3'
|
xl: 'p-3'
|
||||||
},
|
},
|
||||||
|
compact: {
|
||||||
|
xxs: 'p-1 sm:px-2',
|
||||||
|
xs: 'p-1.5 sm:px-2.5',
|
||||||
|
sm: 'p-2 sm:px-3',
|
||||||
|
md: 'p-2 sm:px-4',
|
||||||
|
lg: 'p-2 sm:px-4',
|
||||||
|
xl: 'p-3 sm:px-6'
|
||||||
|
},
|
||||||
variant: {
|
variant: {
|
||||||
...variantColors.reduce((acc: any, color: string) => {
|
...variantColors.reduce((acc: any, color: string) => {
|
||||||
acc[color] = `shadow-sm border border-transparent text-white bg-${color}-600 hover:bg-${color}-700 disabled:bg-${color}-600 focus:ring-2 focus:ring-offset-2 focus:ring-${color}-500`
|
acc[color] = `shadow-sm border border-transparent text-white bg-${color}-600 hover:bg-${color}-700 disabled:bg-${color}-600 focus:ring-2 focus:ring-offset-2 focus:ring-${color}-500`
|
||||||
@@ -40,7 +48,7 @@ export default (variantColors: string[]) => {
|
|||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
base: 'flex-shrink-0',
|
base: 'flex-shrink-0',
|
||||||
loading: 'heroicons-outline:refresh',
|
loading: 'i-heroicons-arrow-path',
|
||||||
size: {
|
size: {
|
||||||
xxs: 'h-3.5 w-3.5',
|
xxs: 'h-3.5 w-3.5',
|
||||||
xs: 'h-4 w-4',
|
xs: 'h-4 w-4',
|
||||||
@@ -57,6 +65,14 @@ export default (variantColors: string[]) => {
|
|||||||
md: '-ml-1 mr-2',
|
md: '-ml-1 mr-2',
|
||||||
lg: '-ml-1 mr-3',
|
lg: '-ml-1 mr-3',
|
||||||
xl: '-ml-1 mr-3'
|
xl: '-ml-1 mr-3'
|
||||||
|
},
|
||||||
|
compactSpacing: {
|
||||||
|
xxs: 'sm:-ml-0.5 sm:mr-1',
|
||||||
|
xs: 'sm:-ml-0.5 sm:mr-1.5',
|
||||||
|
sm: 'sm:-ml-0.5 sm:mr-2',
|
||||||
|
md: 'sm:-ml-1 sm:mr-2',
|
||||||
|
lg: 'sm:-ml-1 sm:mr-3',
|
||||||
|
xl: 'sm:-ml-1 sm:mr-3'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
trailing: {
|
trailing: {
|
||||||
@@ -67,6 +83,14 @@ export default (variantColors: string[]) => {
|
|||||||
md: 'ml-2 -mr-1',
|
md: 'ml-2 -mr-1',
|
||||||
lg: 'ml-3 -mr-1',
|
lg: 'ml-3 -mr-1',
|
||||||
xl: 'ml-3 -mr-1'
|
xl: 'ml-3 -mr-1'
|
||||||
|
},
|
||||||
|
compactSpacing: {
|
||||||
|
xxs: 'sm:ml-1 sm:-mr-0.5',
|
||||||
|
xs: 'sm:ml-1.5 sm:-mr-0.5',
|
||||||
|
sm: 'sm:ml-2 sm:-mr-0.5',
|
||||||
|
md: 'sm:ml-2 sm:-mr-1',
|
||||||
|
lg: 'sm:ml-3 sm:-mr-1',
|
||||||
|
xl: 'sm:ml-3 sm:-mr-1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +168,7 @@ export default (variantColors: string[]) => {
|
|||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
base: 'u-text-gray-400',
|
base: 'u-text-gray-400',
|
||||||
loading: 'heroicons-outline:refresh',
|
loading: 'i-heroicons-arrow-path',
|
||||||
size: {
|
size: {
|
||||||
xxs: 'h-3 w-3',
|
xxs: 'h-3 w-3',
|
||||||
xs: 'h-4 w-4',
|
xs: 'h-4 w-4',
|
||||||
@@ -191,7 +215,7 @@ export default (variantColors: string[]) => {
|
|||||||
wrapper: 'relative',
|
wrapper: 'relative',
|
||||||
base: `${select.base} text-left cursor-default`,
|
base: `${select.base} text-left cursor-default`,
|
||||||
icon: {
|
icon: {
|
||||||
name: 'heroicons-solid:selector',
|
name: 'i-heroicons-chevron-up-down-20-solid',
|
||||||
...select.icon
|
...select.icon
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
@@ -209,7 +233,7 @@ export default (variantColors: string[]) => {
|
|||||||
disabled: 'cursor-not-allowed opacity-50',
|
disabled: 'cursor-not-allowed opacity-50',
|
||||||
empty: 'text-sm u-text-gray-400 px-4 py-2',
|
empty: 'text-sm u-text-gray-400 px-4 py-2',
|
||||||
icon: {
|
icon: {
|
||||||
name: 'heroicons-solid:check',
|
name: 'i-heroicons-check-20-solid',
|
||||||
base: 'absolute inset-y-0 right-0 flex items-center pr-4',
|
base: 'absolute inset-y-0 right-0 flex items-center pr-4',
|
||||||
active: 'text-white',
|
active: 'text-white',
|
||||||
inactive: 'text-primary-600',
|
inactive: 'text-primary-600',
|
||||||
@@ -331,18 +355,23 @@ export default (variantColors: string[]) => {
|
|||||||
|
|
||||||
const alertDialog = {
|
const alertDialog = {
|
||||||
icon: {
|
icon: {
|
||||||
wrapper: 'h-12 w-12 sm:h-10 sm:w-10 bg-primary-100',
|
wrapper: 'mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-primary-100 sm:mx-0 sm:h-10 sm:w-10',
|
||||||
base: 'text-primary-600'
|
base: 'h-6 w-6 text-primary-600'
|
||||||
},
|
},
|
||||||
title: 'text-lg leading-6 font-medium text-gray-900',
|
title: 'text-lg leading-6 font-medium u-text-gray-900',
|
||||||
description: 'text-sm text-gray-500'
|
description: 'text-sm u-text-gray-500'
|
||||||
}
|
}
|
||||||
|
|
||||||
const dropdown = {
|
const dropdown = {
|
||||||
wrapper: 'relative inline-flex text-left',
|
wrapper: 'relative inline-flex text-left',
|
||||||
container: 'z-20',
|
container: 'z-20',
|
||||||
width: 'w-48',
|
width: 'w-48',
|
||||||
base: 'u-bg-white divide-y u-divide-gray-100 rounded-md ring-1 u-ring-gray-200 shadow-lg focus:outline-none',
|
background: 'u-bg-white',
|
||||||
|
shadow: 'shadow-lg',
|
||||||
|
rounded: 'rounded-md',
|
||||||
|
ring: 'ring-1 u-ring-gray-200',
|
||||||
|
base: 'focus:outline-none',
|
||||||
|
divide: 'divide-y u-divide-gray-100',
|
||||||
group: 'py-1',
|
group: 'py-1',
|
||||||
item: {
|
item: {
|
||||||
base: 'group flex items-center gap-3 px-4 py-2 text-sm w-full',
|
base: 'group flex items-center gap-3 px-4 py-2 text-sm w-full',
|
||||||
@@ -351,7 +380,7 @@ export default (variantColors: string[]) => {
|
|||||||
disabled: 'cursor-not-allowed opacity-50',
|
disabled: 'cursor-not-allowed opacity-50',
|
||||||
icon: 'h-5 w-5 u-text-gray-400 group-hover:u-text-gray-500 flex-shrink-0',
|
icon: 'h-5 w-5 u-text-gray-400 group-hover:u-text-gray-500 flex-shrink-0',
|
||||||
avatar: '-m-0.5 group-hover:u-bg-gray-200 flex-shrink-0',
|
avatar: '-m-0.5 group-hover:u-bg-gray-200 flex-shrink-0',
|
||||||
shortcuts: 'flex-shrink-0 text-xs font-semibold u-text-gray-500 ml-auto'
|
shortcuts: 'hidden md:inline-flex flex-shrink-0 text-xs font-semibold u-text-gray-500 ml-auto'
|
||||||
},
|
},
|
||||||
transition: {
|
transition: {
|
||||||
enterActiveClass: 'transition duration-100 ease-out',
|
enterActiveClass: 'transition duration-100 ease-out',
|
||||||
@@ -459,10 +488,10 @@ export default (variantColors: string[]) => {
|
|||||||
rounded: 'rounded-lg',
|
rounded: 'rounded-lg',
|
||||||
ring: 'ring-1 u-ring-gray-200',
|
ring: 'ring-1 u-ring-gray-200',
|
||||||
type: {
|
type: {
|
||||||
info: 'heroicons-outline:information-circle',
|
info: 'i-heroicons-information-circle',
|
||||||
success: 'heroicons-outline:check-circle',
|
success: 'i-heroicons-check-circle',
|
||||||
warning: 'heroicons-outline:exclamation-circle',
|
warning: 'i-heroicons-exclamation-circle',
|
||||||
error: 'heroicons-outline:x-circle'
|
error: 'i-heroicons-x-circle'
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
base: 'w-6 h-6',
|
base: 'w-6 h-6',
|
||||||
@@ -473,6 +502,11 @@ export default (variantColors: string[]) => {
|
|||||||
error: 'text-red-400'
|
error: 'text-red-400'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
close: {
|
||||||
|
icon: {
|
||||||
|
name: 'i-heroicons-x-mark-20-solid'
|
||||||
|
}
|
||||||
|
},
|
||||||
transition: {
|
transition: {
|
||||||
enterActiveClass: 'transform ease-out duration-300 transition',
|
enterActiveClass: 'transform ease-out duration-300 transition',
|
||||||
enterFromClass: 'translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2',
|
enterFromClass: 'translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2',
|
||||||
@@ -491,7 +525,8 @@ export default (variantColors: string[]) => {
|
|||||||
shadow: 'shadow',
|
shadow: 'shadow',
|
||||||
rounded: 'rounded',
|
rounded: 'rounded',
|
||||||
ring: 'ring-1 u-ring-gray-200',
|
ring: 'ring-1 u-ring-gray-200',
|
||||||
base: 'invisible lg:visible h-6 px-2 py-1 text-xs font-normal',
|
base: 'invisible lg:visible h-6 px-2 py-1 text-xs font-normal truncate',
|
||||||
|
shortcuts: 'hidden md:inline-flex items-center justify-end flex-shrink-0 gap-0.5 ml-1',
|
||||||
transition: {
|
transition: {
|
||||||
enterActiveClass: 'transition ease-out duration-200',
|
enterActiveClass: 'transition ease-out duration-200',
|
||||||
enterFromClass: 'opacity-0 translate-y-1',
|
enterFromClass: 'opacity-0 translate-y-1',
|
||||||
@@ -509,7 +544,11 @@ export default (variantColors: string[]) => {
|
|||||||
wrapper: 'relative',
|
wrapper: 'relative',
|
||||||
container: 'z-20',
|
container: 'z-20',
|
||||||
width: '',
|
width: '',
|
||||||
base: '',
|
background: 'u-bg-white',
|
||||||
|
shadow: 'shadow-lg',
|
||||||
|
rounded: 'rounded-md',
|
||||||
|
ring: 'ring-1 u-ring-gray-200',
|
||||||
|
base: 'overflow-hidden focus:outline-none',
|
||||||
transition: {
|
transition: {
|
||||||
enterActiveClass: 'transition ease-out duration-200',
|
enterActiveClass: 'transition ease-out duration-200',
|
||||||
enterFromClass: 'opacity-0 translate-y-1',
|
enterFromClass: 'opacity-0 translate-y-1',
|
||||||
@@ -527,7 +566,11 @@ export default (variantColors: string[]) => {
|
|||||||
wrapper: 'relative',
|
wrapper: 'relative',
|
||||||
container: 'z-20',
|
container: 'z-20',
|
||||||
width: '',
|
width: '',
|
||||||
base: '',
|
background: 'u-bg-white',
|
||||||
|
shadow: 'shadow-lg',
|
||||||
|
rounded: 'rounded-md',
|
||||||
|
ring: 'ring-1 u-ring-gray-200',
|
||||||
|
base: 'overflow-hidden focus:outline-none',
|
||||||
transition: {
|
transition: {
|
||||||
enterActiveClass: 'transition ease-out duration-200',
|
enterActiveClass: 'transition ease-out duration-200',
|
||||||
enterFromClass: 'opacity-0 translate-y-1',
|
enterFromClass: 'opacity-0 translate-y-1',
|
||||||
@@ -542,6 +585,38 @@ export default (variantColors: string[]) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const commandPalette = {
|
||||||
|
wrapper: 'flex flex-col flex-1 min-h-0 divide-y divide-gray-100 dark:divide-gray-800',
|
||||||
|
input: {
|
||||||
|
base: 'w-full h-12 pr-4 placeholder-gray-400 dark:placeholder-gray-500 bg-transparent border-0 pl-[3.25rem] u-text-gray-900 focus:ring-0 sm:text-sm',
|
||||||
|
icon: {
|
||||||
|
base: 'pointer-events-none absolute top-3.5 left-5 h-5 w-5 u-text-gray-400',
|
||||||
|
name: 'i-heroicons-magnifying-glass'
|
||||||
|
},
|
||||||
|
close: {
|
||||||
|
base: 'absolute right-2',
|
||||||
|
variant: 'transparent',
|
||||||
|
size: 'md',
|
||||||
|
icon: {
|
||||||
|
name: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
empty: {
|
||||||
|
icon: {
|
||||||
|
name: 'i-heroicons-magnifying-glass'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
selected: {
|
||||||
|
icon: {
|
||||||
|
name: 'i-heroicons-check-20-solid'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
shortcuts: 'hidden md:inline-flex flex-shrink-0 text-xs font-semibold u-text-gray-500'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
card,
|
card,
|
||||||
modal,
|
modal,
|
||||||
@@ -567,6 +642,9 @@ export default (variantColors: string[]) => {
|
|||||||
notification,
|
notification,
|
||||||
tooltip,
|
tooltip,
|
||||||
popover,
|
popover,
|
||||||
contextMenu
|
contextMenu,
|
||||||
|
commandPalette
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type DefaultPreset = ReturnType<typeof defaultPreset>
|
||||||
|
|||||||
3
src/runtime/types/avatar.d.ts
vendored
3
src/runtime/types/avatar.d.ts
vendored
@@ -4,7 +4,6 @@ export interface Avatar {
|
|||||||
text: string
|
text: string
|
||||||
size: string
|
size: string
|
||||||
rounded: boolean
|
rounded: boolean
|
||||||
chip: boolean
|
chip: string
|
||||||
chipVariant: string
|
|
||||||
chipPosition: string
|
chipPosition: string
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/runtime/types/command-palette.d.ts
vendored
4
src/runtime/types/command-palette.d.ts
vendored
@@ -1,6 +1,7 @@
|
|||||||
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
|
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
|
||||||
import type { FuseSortFunctionMatch, FuseSortFunctionMatchList } from 'fuse.js'
|
import type { FuseSortFunctionMatch, FuseSortFunctionMatchList } from 'fuse.js'
|
||||||
import type { Avatar } from './avatar'
|
import type { Avatar } from './avatar'
|
||||||
|
|
||||||
export interface Command {
|
export interface Command {
|
||||||
id: string | number
|
id: string | number
|
||||||
prefix?: string
|
prefix?: string
|
||||||
@@ -14,6 +15,7 @@ export interface Command {
|
|||||||
group?: string
|
group?: string
|
||||||
score?: number
|
score?: number
|
||||||
matches?: (FuseSortFunctionMatch | FuseSortFunctionMatchList)[]
|
matches?: (FuseSortFunctionMatch | FuseSortFunctionMatchList)[]
|
||||||
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Group {
|
export interface Group {
|
||||||
@@ -21,5 +23,5 @@ export interface Group {
|
|||||||
active?: string
|
active?: string
|
||||||
inactive?: string
|
inactive?: string
|
||||||
commands: Command[]
|
commands: Command[]
|
||||||
options?: Partial<UseFuseOptions<Command>>
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/runtime/types/toast.d.ts
vendored
18
src/runtime/types/toast.d.ts
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
export interface ToastNotificationAction {
|
||||||
|
label: string,
|
||||||
|
click: Function
|
||||||
|
}
|
||||||
|
|
||||||
export interface ToastNotification {
|
export interface ToastNotification {
|
||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
@@ -5,16 +10,7 @@ export interface ToastNotification {
|
|||||||
type: string
|
type: string
|
||||||
icon?: string
|
icon?: string
|
||||||
timeout: number
|
timeout: number
|
||||||
actions?: {
|
actions?: ToastNotificationAction[]
|
||||||
label: string,
|
click?: Function
|
||||||
click: Function
|
|
||||||
}[]
|
|
||||||
callback?: Function
|
callback?: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ToastPlugin {
|
|
||||||
addNotification: (notification: Partial<Notification>) => Notification
|
|
||||||
removeNotification: (id: string) => void
|
|
||||||
success: (options: { title?: string, description?: string }) => void
|
|
||||||
error: (options: { title?: string, description?: string }) => void
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user