@nuxt/ui 3.0.0-alpha.0 → 3.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxt/ui/accordion.ts +20 -0
- package/.nuxt/ui/alert.ts +242 -0
- package/.nuxt/ui/avatar-group.ts +40 -0
- package/.nuxt/ui/avatar.ts +42 -0
- package/.nuxt/ui/badge.ts +194 -0
- package/.nuxt/ui/breadcrumb.ts +45 -0
- package/.nuxt/ui/button-group.ts +16 -0
- package/.nuxt/ui/button.ts +344 -0
- package/.nuxt/ui/calendar.ts +85 -0
- package/.nuxt/ui/card.ts +8 -0
- package/.nuxt/ui/carousel.ts +41 -0
- package/.nuxt/ui/checkbox.ts +105 -0
- package/.nuxt/ui/chip.ts +67 -0
- package/.nuxt/ui/collapsible.ts +6 -0
- package/.nuxt/ui/color-picker.ts +39 -0
- package/.nuxt/ui/command-palette.ts +50 -0
- package/.nuxt/ui/container.ts +3 -0
- package/.nuxt/ui/context-menu.ts +198 -0
- package/.nuxt/ui/drawer.ts +55 -0
- package/.nuxt/ui/dropdown-menu.ts +199 -0
- package/.nuxt/ui/form-field.ts +40 -0
- package/.nuxt/ui/form.ts +3 -0
- package/.nuxt/ui/index.ts +48 -0
- package/.nuxt/ui/input-menu.ts +410 -0
- package/.nuxt/ui/input-number.ts +204 -0
- package/.nuxt/ui/input.ts +263 -0
- package/.nuxt/ui/kbd.ts +19 -0
- package/.nuxt/ui/link.ts +15 -0
- package/.nuxt/ui/modal.ts +28 -0
- package/.nuxt/ui/navigation-menu.ts +390 -0
- package/.nuxt/ui/pagination.ts +8 -0
- package/.nuxt/ui/pin-input.ts +145 -0
- package/.nuxt/ui/popover.ts +6 -0
- package/.nuxt/ui/progress.ts +258 -0
- package/.nuxt/ui/radio-group.ts +112 -0
- package/.nuxt/ui/select-menu.ts +316 -0
- package/.nuxt/ui/select.ts +315 -0
- package/.nuxt/ui/separator.ts +143 -0
- package/.nuxt/ui/skeleton.ts +3 -0
- package/.nuxt/ui/slideover.ts +63 -0
- package/.nuxt/ui/slider.ts +148 -0
- package/.nuxt/ui/stepper.ts +180 -0
- package/.nuxt/ui/switch.ts +113 -0
- package/.nuxt/ui/table.ts +129 -0
- package/.nuxt/ui/tabs.ts +227 -0
- package/.nuxt/ui/textarea.ts +263 -0
- package/.nuxt/ui/toast.ts +66 -0
- package/.nuxt/ui/toaster.ts +75 -0
- package/.nuxt/ui/tooltip.ts +9 -0
- package/README.md +75 -54
- package/cli/commands/{init.mjs → make/component.mjs} +5 -5
- package/cli/commands/make/index.mjs +14 -0
- package/cli/commands/make/locale.mjs +64 -0
- package/cli/index.mjs +2 -2
- package/cli/templates.mjs +52 -7
- package/cli/utils.mjs +14 -0
- package/dist/chunks/component-meta.cjs +82802 -0
- package/dist/chunks/component-meta.mjs +82800 -0
- package/dist/client/devtools/200.html +1 -0
- package/dist/client/devtools/404.html +1 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKK58UfivUw4aw-SK92LTmKP0.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKy58UfivUw-9uYm8d48E4.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu0-K6z9mXg-VNw7NHvqnp.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu6-K6z9mXgjU0-EkYdMs3MAX.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-7DW3w-R7n06NbhGy.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDG3w-leGNfkTmsj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDW3w-ciElMF03ku.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JCm3w-sB722Uoa0f.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JDW3w-PBDI1JDjwV.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8gCm3w-0q1hqVn09O.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9XCm3w-ByvzuLy2fa.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9uCm3w-5TKCIs6EEw.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat_XDW3w-r2swRDGfn2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAC5thTQ-ldB60l5U8r.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpthTQ-wbFKGFDrgo.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpxhTQ-LLUBv5jskj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwARZthTQ-F71RdTRbNg.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwA_JxhTQ-6nh65gZkc0.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAfJthTQ-aMoWEJLmTt.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAkJxhTQ-WMBvmLOgKm.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAop1hTQ-utGC2hnWq2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAopxhTQ-YpyTieVa5B.woff +0 -0
- package/dist/client/devtools/_nuxt/B1fTd_Rf.js +1 -0
- package/dist/client/devtools/_nuxt/CSUxkedg.js +1 -0
- package/dist/client/devtools/_nuxt/CbRTGpb7.js +1 -0
- package/dist/client/devtools/_nuxt/YQTlxbcT.js +53 -0
- package/dist/client/devtools/_nuxt/builds/latest.json +1 -0
- package/dist/client/devtools/_nuxt/builds/meta/b3465abc-0a92-4ee7-ba6b-e5174891fcc0.json +1 -0
- package/dist/client/devtools/_nuxt/entry.DXXceQev.css +1 -0
- package/dist/client/devtools/_nuxt/error-404.BJpkZFyY.css +1 -0
- package/dist/client/devtools/_nuxt/error-500.D3i9VDlt.css +1 -0
- package/dist/client/devtools/favicon.svg +1 -0
- package/dist/client/devtools/index.html +1 -0
- package/dist/devtools/runtime/DevtoolsRenderer.vue +54 -0
- package/dist/devtools/runtime/examples/AvatarGroupExample.vue +7 -0
- package/dist/devtools/runtime/examples/ButtonGroupExample.vue +8 -0
- package/dist/devtools/runtime/examples/CardExample.vue +13 -0
- package/dist/devtools/runtime/examples/CarouselExample.vue +13 -0
- package/dist/devtools/runtime/examples/ChipExample.vue +5 -0
- package/dist/devtools/runtime/examples/CollapsibleExample.vue +8 -0
- package/dist/devtools/runtime/examples/CommandPaletteExample.vue +29 -0
- package/dist/devtools/runtime/examples/ContainerExample.vue +5 -0
- package/dist/devtools/runtime/examples/ContextMenuExample.vue +5 -0
- package/dist/devtools/runtime/examples/DrawerExample.vue +8 -0
- package/dist/devtools/runtime/examples/DropdownMenuExample.vue +5 -0
- package/dist/devtools/runtime/examples/FormExample.vue +30 -0
- package/dist/devtools/runtime/examples/FormFieldExample.vue +5 -0
- package/dist/devtools/runtime/examples/LinkExample.vue +5 -0
- package/dist/devtools/runtime/examples/ModalExample.vue +8 -0
- package/dist/devtools/runtime/examples/PopoverExample.vue +8 -0
- package/dist/devtools/runtime/examples/SkeletonExample.vue +3 -0
- package/dist/devtools/runtime/examples/SlideoverExample.vue +8 -0
- package/dist/devtools/runtime/examples/StepperExample.vue +44 -0
- package/dist/devtools/runtime/examples/ToasterExample.vue +11 -0
- package/dist/devtools/runtime/examples/TooltipExample.vue +5 -0
- package/dist/module.cjs +223 -4
- package/dist/module.d.cts +54 -0
- package/dist/module.d.mts +38 -7
- package/dist/module.d.ts +38 -7
- package/dist/module.json +4 -3
- package/dist/module.mjs +180 -2617
- package/dist/runtime/components/Accordion.vue +95 -11
- package/dist/runtime/components/Alert.vue +69 -10
- package/dist/runtime/components/App.vue +28 -5
- package/dist/runtime/components/Avatar.vue +57 -12
- package/dist/runtime/components/AvatarGroup.vue +34 -7
- package/dist/runtime/components/Badge.vue +61 -9
- package/dist/runtime/components/Breadcrumb.vue +93 -16
- package/dist/runtime/components/Button.vue +78 -12
- package/dist/runtime/components/ButtonGroup.vue +35 -8
- package/dist/runtime/components/Calendar.vue +190 -0
- package/dist/runtime/components/Card.vue +29 -7
- package/dist/runtime/components/Carousel.vue +322 -0
- package/dist/runtime/components/Checkbox.vue +64 -30
- package/dist/runtime/components/Chip.vue +48 -8
- package/dist/runtime/components/Collapsible.vue +32 -8
- package/dist/runtime/components/ColorPicker.vue +265 -0
- package/dist/runtime/components/CommandPalette.vue +207 -88
- package/dist/runtime/components/Container.vue +26 -7
- package/dist/runtime/components/ContextMenu.vue +150 -11
- package/dist/runtime/components/ContextMenuContent.vue +63 -19
- package/dist/runtime/components/Drawer.vue +68 -15
- package/dist/runtime/components/DropdownMenu.vue +147 -12
- package/dist/runtime/components/DropdownMenuContent.vue +69 -19
- package/dist/runtime/components/Form.vue +80 -42
- package/dist/runtime/components/FormField.vue +58 -21
- package/dist/runtime/components/Icon.vue +13 -3
- package/dist/runtime/components/Input.vue +61 -12
- package/dist/runtime/components/InputMenu.vue +247 -53
- package/dist/runtime/components/InputNumber.vue +192 -0
- package/dist/runtime/components/Kbd.vue +31 -7
- package/dist/runtime/components/Link.vue +148 -21
- package/dist/runtime/components/LinkBase.vue +21 -8
- package/dist/runtime/components/Modal.vue +90 -15
- package/dist/runtime/components/NavigationMenu.vue +234 -69
- package/dist/runtime/components/Pagination.vue +124 -15
- package/dist/runtime/components/PinInput.vue +96 -0
- package/dist/runtime/components/Popover.vue +66 -11
- package/dist/runtime/components/Progress.vue +67 -12
- package/dist/runtime/components/RadioGroup.vue +78 -9
- package/dist/runtime/components/Select.vue +155 -26
- package/dist/runtime/components/SelectMenu.vue +245 -63
- package/dist/runtime/components/Separator.vue +42 -7
- package/dist/runtime/components/Skeleton.vue +22 -7
- package/dist/runtime/components/Slideover.vue +88 -15
- package/dist/runtime/components/Slider.vue +37 -7
- package/dist/runtime/components/Stepper.vue +171 -0
- package/dist/runtime/components/Switch.vue +58 -14
- package/dist/runtime/components/Table.vue +262 -0
- package/dist/runtime/components/Tabs.vue +97 -17
- package/dist/runtime/components/Textarea.vue +55 -9
- package/dist/runtime/components/Toast.vue +66 -9
- package/dist/runtime/components/Toaster.vue +57 -21
- package/dist/runtime/components/Tooltip.vue +49 -10
- package/dist/runtime/composables/defineLocale.d.ts +9 -0
- package/dist/runtime/composables/defineLocale.js +4 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +2 -8
- package/dist/runtime/composables/extendDevtoolsMeta.d.ts +7 -0
- package/dist/runtime/composables/extendDevtoolsMeta.js +2 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +2 -2
- package/dist/runtime/composables/useButtonGroup.d.ts +5 -5
- package/dist/runtime/composables/useComponentIcons.d.ts +3 -0
- package/dist/runtime/composables/useFormField.d.ts +13 -6
- package/dist/runtime/composables/useFormField.js +12 -7
- package/dist/runtime/composables/useKbd.d.ts +10 -3
- package/dist/runtime/composables/useKbd.js +14 -8
- package/dist/runtime/composables/useLocale.d.ts +4 -0
- package/dist/runtime/composables/useLocale.js +10 -0
- package/dist/runtime/composables/useModal.d.ts +2 -2
- package/dist/runtime/composables/useSlideover.d.ts +2 -2
- package/dist/runtime/composables/useToast.d.ts +2 -2
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/keyframes.css +1 -0
- package/dist/runtime/locale/ar.d.ts +2 -0
- package/dist/runtime/locale/ar.js +53 -0
- package/dist/runtime/locale/cs.d.ts +2 -0
- package/dist/runtime/locale/cs.js +52 -0
- package/dist/runtime/locale/de.d.ts +2 -0
- package/dist/runtime/locale/de.js +52 -0
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +52 -0
- package/dist/runtime/locale/es.d.ts +2 -0
- package/dist/runtime/locale/es.js +52 -0
- package/dist/runtime/locale/fa_ir.d.ts +2 -0
- package/dist/runtime/locale/fa_ir.js +53 -0
- package/dist/runtime/locale/fr.d.ts +2 -0
- package/dist/runtime/locale/fr.js +52 -0
- package/dist/runtime/locale/index.d.ts +19 -0
- package/dist/runtime/locale/index.js +19 -0
- package/dist/runtime/locale/it.d.ts +2 -0
- package/dist/runtime/locale/it.js +52 -0
- package/dist/runtime/locale/ja.d.ts +2 -0
- package/dist/runtime/locale/ja.js +52 -0
- package/dist/runtime/locale/ko.d.ts +2 -0
- package/dist/runtime/locale/ko.js +52 -0
- package/dist/runtime/locale/nl.d.ts +2 -0
- package/dist/runtime/locale/nl.js +52 -0
- package/dist/runtime/locale/pl.d.ts +2 -0
- package/dist/runtime/locale/pl.js +52 -0
- package/dist/runtime/locale/pt.d.ts +2 -0
- package/dist/runtime/locale/pt.js +52 -0
- package/dist/runtime/locale/pt_br.d.ts +2 -0
- package/dist/runtime/locale/pt_br.js +52 -0
- package/dist/runtime/locale/ru.d.ts +2 -0
- package/dist/runtime/locale/ru.js +52 -0
- package/dist/runtime/locale/sk.d.ts +2 -0
- package/dist/runtime/locale/sk.js +52 -0
- package/dist/runtime/locale/tr.d.ts +2 -0
- package/dist/runtime/locale/tr.js +52 -0
- package/dist/runtime/locale/zh_hans.d.ts +2 -0
- package/dist/runtime/locale/zh_hans.js +52 -0
- package/dist/runtime/locale/zh_hant.d.ts +2 -0
- package/dist/runtime/locale/zh_hant.js +52 -0
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.js +12 -8
- package/dist/runtime/plugins/modal.d.ts +2 -0
- package/dist/runtime/plugins/slideover.d.ts +2 -0
- package/dist/runtime/types/form.d.ts +10 -4
- package/dist/runtime/types/index.d.ts +50 -42
- package/dist/runtime/types/index.js +8 -0
- package/dist/runtime/types/locale.d.ts +54 -0
- package/dist/runtime/types/utils.d.ts +8 -3
- package/dist/runtime/utils/form.d.ts +7 -5
- package/dist/runtime/utils/form.js +117 -28
- package/dist/runtime/utils/index.d.ts +2 -1
- package/dist/runtime/utils/index.js +16 -0
- package/dist/runtime/utils/link.d.ts +25 -55
- package/dist/runtime/utils/link.js +1 -1
- package/dist/runtime/utils/locale.d.ts +15 -0
- package/dist/runtime/utils/locale.js +25 -0
- package/dist/runtime/vue/components/Icon.vue +15 -0
- package/dist/runtime/vue/components/Link.vue +208 -0
- package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
- package/dist/runtime/vue/plugins/color-mode.js +6 -0
- package/dist/runtime/vue/plugins/head.d.ts +4 -0
- package/dist/runtime/vue/plugins/head.js +6 -0
- package/dist/runtime/vue/stubs.d.ts +15 -0
- package/dist/runtime/vue/stubs.js +27 -0
- package/dist/shared/ui.CwmIkD_Y.cjs +3269 -0
- package/dist/shared/ui.D_93iuwH.mjs +3262 -0
- package/dist/unplugin.cjs +192 -0
- package/dist/unplugin.d.cts +49 -0
- package/dist/unplugin.d.mts +49 -0
- package/dist/unplugin.d.ts +49 -0
- package/dist/unplugin.mjs +181 -0
- package/dist/vite.cjs +22 -0
- package/dist/vite.d.cts +13 -0
- package/dist/vite.d.mts +13 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.mjs +20 -0
- package/package.json +103 -37
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/assets/css/animations.css +0 -1
- package/dist/runtime/components/Accordion.vue.d.ts +0 -492
- package/dist/runtime/components/Alert.vue.d.ts +0 -548
- package/dist/runtime/components/App.vue.d.ts +0 -25
- package/dist/runtime/components/Avatar.vue.d.ts +0 -384
- package/dist/runtime/components/AvatarGroup.vue.d.ts +0 -381
- package/dist/runtime/components/Badge.vue.d.ts +0 -422
- package/dist/runtime/components/Breadcrumb.vue.d.ts +0 -307
- package/dist/runtime/components/Button.vue.d.ts +0 -949
- package/dist/runtime/components/ButtonGroup.vue.d.ts +0 -182
- package/dist/runtime/components/Card.vue.d.ts +0 -191
- package/dist/runtime/components/Checkbox.vue.d.ts +0 -819
- package/dist/runtime/components/Chip.vue.d.ts +0 -590
- package/dist/runtime/components/Collapsible.vue.d.ts +0 -159
- package/dist/runtime/components/CommandPalette.vue.d.ts +0 -684
- package/dist/runtime/components/Container.vue.d.ts +0 -27
- package/dist/runtime/components/ContextMenu.vue.d.ts +0 -796
- package/dist/runtime/components/Drawer.vue.d.ts +0 -343
- package/dist/runtime/components/DropdownMenu.vue.d.ts +0 -815
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +0 -0
- package/dist/runtime/components/Form.vue.d.ts +0 -39
- package/dist/runtime/components/FormField.vue.d.ts +0 -356
- package/dist/runtime/components/Icon.vue.d.ts +0 -17
- package/dist/runtime/components/Input.vue.d.ts +0 -1137
- package/dist/runtime/components/InputMenu.vue.d.ts +0 -2121
- package/dist/runtime/components/Kbd.vue.d.ts +0 -169
- package/dist/runtime/components/Link.vue.d.ts +0 -76
- package/dist/runtime/components/LinkBase.vue.d.ts +0 -49
- package/dist/runtime/components/Modal.vue.d.ts +0 -319
- package/dist/runtime/components/NavigationMenu.vue.d.ts +0 -1789
- package/dist/runtime/components/Pagination.vue.d.ts +0 -295
- package/dist/runtime/components/Popover.vue.d.ts +0 -197
- package/dist/runtime/components/Progress.vue.d.ts +0 -1781
- package/dist/runtime/components/RadioGroup.vue.d.ts +0 -1715
- package/dist/runtime/components/Select.vue.d.ts +0 -1569
- package/dist/runtime/components/SelectMenu.vue.d.ts +0 -1661
- package/dist/runtime/components/Separator.vue.d.ts +0 -0
- package/dist/runtime/components/Skeleton.vue.d.ts +0 -26
- package/dist/runtime/components/Slideover.vue.d.ts +0 -375
- package/dist/runtime/components/Slider.vue.d.ts +0 -0
- package/dist/runtime/components/Switch.vue.d.ts +0 -1676
- package/dist/runtime/components/Tabs.vue.d.ts +0 -934
- package/dist/runtime/components/Textarea.vue.d.ts +0 -1133
- package/dist/runtime/components/Toast.vue.d.ts +0 -0
- package/dist/runtime/components/Toaster.vue.d.ts +0 -362
- package/dist/runtime/components/Tooltip.vue.d.ts +0 -248
- package/dist/runtime/types/component.d.ts +0 -17
- package/dist/runtime/types/component.js +0 -0
- /package/dist/runtime/{components/ContextMenuContent.vue.d.ts → types/locale.js} +0 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tv, type VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { MaybeRefOrGetter } from '@vueuse/shared'
|
|
4
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
+
import _appConfig from '#build/app.config'
|
|
6
|
+
import theme from '#build/ui/color-picker'
|
|
7
|
+
|
|
8
|
+
const appConfig = _appConfig as AppConfig & { ui: { colorPicker: Partial<typeof theme> } }
|
|
9
|
+
|
|
10
|
+
const colorPicker = tv({ extend: tv(theme), ...(appConfig.ui?.colorPicker || {}) })
|
|
11
|
+
|
|
12
|
+
type ColorPickerVariants = VariantProps<typeof colorPicker>
|
|
13
|
+
|
|
14
|
+
type HSVColor = {
|
|
15
|
+
h: number
|
|
16
|
+
s: number
|
|
17
|
+
v: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ColorPickerProps = {
|
|
21
|
+
/**
|
|
22
|
+
* The element or component this component should render as.
|
|
23
|
+
* @defaultValue 'div'
|
|
24
|
+
*/
|
|
25
|
+
as?: any
|
|
26
|
+
/**
|
|
27
|
+
* Throttle time in ms for the color picker
|
|
28
|
+
*/
|
|
29
|
+
throttle?: number
|
|
30
|
+
/**
|
|
31
|
+
* Disable the color picker
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean
|
|
34
|
+
/**
|
|
35
|
+
* The default value of the color picker
|
|
36
|
+
*/
|
|
37
|
+
defaultValue?: string
|
|
38
|
+
/**
|
|
39
|
+
* Format of the color
|
|
40
|
+
* @defaultValue 'hex'
|
|
41
|
+
*/
|
|
42
|
+
format?: 'hex' | 'rgb' | 'hsl' | 'hwb'
|
|
43
|
+
size?: ColorPickerVariants['size']
|
|
44
|
+
class?: any
|
|
45
|
+
ui?: Partial<typeof colorPicker.slots>
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import { ref, nextTick, computed, toValue } from 'vue'
|
|
51
|
+
import { Primitive } from 'reka-ui'
|
|
52
|
+
import { useEventListener, useElementBounding, watchThrottled, watchPausable } from '@vueuse/core'
|
|
53
|
+
import { isClient } from '@vueuse/shared'
|
|
54
|
+
import Color from 'color'
|
|
55
|
+
|
|
56
|
+
const props = withDefaults(defineProps<ColorPickerProps>(), {
|
|
57
|
+
format: 'hex',
|
|
58
|
+
throttle: 50,
|
|
59
|
+
defaultValue: '#FFFFFF'
|
|
60
|
+
})
|
|
61
|
+
const modelValue = defineModel<string>(undefined)
|
|
62
|
+
|
|
63
|
+
const pickedColor = computed<HSVColor>({
|
|
64
|
+
get() {
|
|
65
|
+
try {
|
|
66
|
+
const color = Color(modelValue.value || props.defaultValue)
|
|
67
|
+
return color.hsv().object() as HSVColor
|
|
68
|
+
} catch (_) {
|
|
69
|
+
return { h: 0, s: 0, v: 100 }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
set(value) {
|
|
73
|
+
const color = Color.hsv(value.h, value.s, value.v)
|
|
74
|
+
|
|
75
|
+
switch (props.format) {
|
|
76
|
+
case 'rgb':
|
|
77
|
+
modelValue.value = color.rgb().string()
|
|
78
|
+
break
|
|
79
|
+
case 'hsl':
|
|
80
|
+
modelValue.value = color.hsl().string()
|
|
81
|
+
break
|
|
82
|
+
case 'hwb':
|
|
83
|
+
modelValue.value = color.hwb().string()
|
|
84
|
+
break
|
|
85
|
+
case 'hex':
|
|
86
|
+
default:
|
|
87
|
+
modelValue.value = color.hex()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
function useColorDraggable(targetElement: MaybeRefOrGetter<HTMLElement | null>,
|
|
93
|
+
containerElement: MaybeRefOrGetter<HTMLElement | null>,
|
|
94
|
+
axis: 'x' | 'y' | 'both' = 'both',
|
|
95
|
+
initialPosition = { x: 0, y: 0 },
|
|
96
|
+
disabled?: MaybeRefOrGetter<boolean | undefined>
|
|
97
|
+
) {
|
|
98
|
+
const position = ref<{ x: number, y: number }>(initialPosition)
|
|
99
|
+
const pressedDelta = ref<{ x: number, y: number }>()
|
|
100
|
+
const targetRect = useElementBounding(targetElement)
|
|
101
|
+
const containerRect = useElementBounding(containerElement)
|
|
102
|
+
|
|
103
|
+
function start(event: PointerEvent) {
|
|
104
|
+
if (toValue(disabled)) return event.preventDefault()
|
|
105
|
+
|
|
106
|
+
const container = toValue(containerElement)
|
|
107
|
+
|
|
108
|
+
pressedDelta.value = {
|
|
109
|
+
x: event.clientX - (container ? event.clientX - containerRect.left.value + container.scrollLeft : targetRect.left.value),
|
|
110
|
+
y: event.clientY - (container ? event.clientY - containerRect.top.value + container.scrollTop : targetRect.top.value)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
move(event)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function move(event: PointerEvent) {
|
|
117
|
+
if (!pressedDelta.value) return
|
|
118
|
+
|
|
119
|
+
const container = toValue(containerElement)
|
|
120
|
+
let { x, y } = position.value
|
|
121
|
+
|
|
122
|
+
if (container && (axis === 'x' || axis === 'both')) {
|
|
123
|
+
x = Math.min(Math.max(0, (event.clientX - pressedDelta.value.x) / container.scrollWidth * 100), 100)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (container && (axis === 'y' || axis === 'both')) {
|
|
127
|
+
y = Math.min(Math.max(0, (event.clientY - pressedDelta.value.y) / container.scrollHeight * 100), 100)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
position.value = { x, y }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function end() {
|
|
134
|
+
if (!pressedDelta.value) {
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
pressedDelta.value = undefined
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (isClient) {
|
|
142
|
+
useEventListener(containerElement, 'pointerdown', start)
|
|
143
|
+
useEventListener(window, 'pointermove', move)
|
|
144
|
+
useEventListener(window, 'pointerup', end)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
position
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function normalizeHue(hue: number, dir: 'left' | 'right' = 'left'): number {
|
|
153
|
+
if (dir === 'right') {
|
|
154
|
+
return (hue * 100) / 360
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return (hue / 100) * 360
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function normalizeBrightness(brightness: number): number {
|
|
161
|
+
return 100 - brightness
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const selectorRef = ref<HTMLDivElement | null>(null)
|
|
165
|
+
const selectorThumbRef = ref<HTMLDivElement | null>(null)
|
|
166
|
+
const trackRef = ref<HTMLDivElement | null>(null)
|
|
167
|
+
const trackThumbRef = ref<HTMLDivElement | null>(null)
|
|
168
|
+
|
|
169
|
+
const disabled = computed(() => props.disabled)
|
|
170
|
+
|
|
171
|
+
const { position: selectorThumbPosition } = useColorDraggable(selectorThumbRef, selectorRef, 'both', {
|
|
172
|
+
x: pickedColor.value.s,
|
|
173
|
+
y: normalizeBrightness(pickedColor.value.v)
|
|
174
|
+
}, disabled)
|
|
175
|
+
|
|
176
|
+
const { position: trackThumbPosition } = useColorDraggable(trackThumbRef, trackRef, 'y', {
|
|
177
|
+
x: 0,
|
|
178
|
+
y: normalizeHue(pickedColor.value.h, 'right')
|
|
179
|
+
}, disabled)
|
|
180
|
+
|
|
181
|
+
const { pause: pauseWatchColor, resume: resumeWatchColor } = watchPausable(pickedColor, (hsb) => {
|
|
182
|
+
selectorThumbPosition.value = {
|
|
183
|
+
x: hsb.s,
|
|
184
|
+
y: normalizeBrightness(hsb.v)
|
|
185
|
+
}
|
|
186
|
+
trackThumbPosition.value = {
|
|
187
|
+
x: 0,
|
|
188
|
+
y: normalizeHue(hsb.h, 'right')
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
watchThrottled([selectorThumbPosition, trackThumbPosition], () => {
|
|
193
|
+
pauseWatchColor()
|
|
194
|
+
|
|
195
|
+
pickedColor.value = {
|
|
196
|
+
h: normalizeHue(trackThumbPosition.value.y),
|
|
197
|
+
s: selectorThumbPosition.value.x,
|
|
198
|
+
v: normalizeBrightness(selectorThumbPosition.value.y)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
nextTick(resumeWatchColor)
|
|
202
|
+
}, { throttle: () => props.throttle })
|
|
203
|
+
|
|
204
|
+
const trackThumbColor = computed(() => Color({
|
|
205
|
+
h: normalizeHue(trackThumbPosition.value.y),
|
|
206
|
+
s: 100,
|
|
207
|
+
v: 100
|
|
208
|
+
}).hex())
|
|
209
|
+
|
|
210
|
+
const selectorStyle = computed(() => ({
|
|
211
|
+
backgroundColor: trackThumbColor.value
|
|
212
|
+
}))
|
|
213
|
+
|
|
214
|
+
const selectorThumbStyle = computed(() => ({
|
|
215
|
+
backgroundColor: Color(modelValue.value || props.defaultValue).hex(),
|
|
216
|
+
left: `${selectorThumbPosition.value.x}%`,
|
|
217
|
+
top: `${selectorThumbPosition.value.y}%`
|
|
218
|
+
}))
|
|
219
|
+
|
|
220
|
+
const trackThumbStyle = computed(() => ({
|
|
221
|
+
backgroundColor: trackThumbColor.value,
|
|
222
|
+
top: `${trackThumbPosition.value.y}%`
|
|
223
|
+
}))
|
|
224
|
+
|
|
225
|
+
const ui = computed(() => colorPicker({
|
|
226
|
+
size: props.size
|
|
227
|
+
}))
|
|
228
|
+
</script>
|
|
229
|
+
|
|
230
|
+
<template>
|
|
231
|
+
<Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })" :data-disabled="disabled ? true : undefined">
|
|
232
|
+
<div :class="ui.picker({ class: props.ui?.picker })">
|
|
233
|
+
<div
|
|
234
|
+
ref="selectorRef"
|
|
235
|
+
:class="ui.selector({ class: props.ui?.selector })"
|
|
236
|
+
:style="selectorStyle"
|
|
237
|
+
>
|
|
238
|
+
<div :class="ui.selectorBackground({ class: props.ui?.selectorBackground })" data-color-picker-background>
|
|
239
|
+
<div
|
|
240
|
+
ref="selectorThumbRef"
|
|
241
|
+
:class="ui.selectorThumb({ class: props.ui?.selectorThumb })"
|
|
242
|
+
:style="selectorThumbStyle"
|
|
243
|
+
:data-disabled="disabled ? true : undefined"
|
|
244
|
+
/>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<div
|
|
248
|
+
ref="trackRef"
|
|
249
|
+
:class="ui.track({ class: props.ui?.track })"
|
|
250
|
+
data-color-picker-track
|
|
251
|
+
>
|
|
252
|
+
<div
|
|
253
|
+
ref="trackThumbRef"
|
|
254
|
+
:class="ui.trackThumb({ class: props.ui?.trackThumb })"
|
|
255
|
+
:style="trackThumbStyle"
|
|
256
|
+
:data-disabled="disabled ? true : undefined"
|
|
257
|
+
/>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
</Primitive>
|
|
261
|
+
</template>
|
|
262
|
+
|
|
263
|
+
<style scoped>
|
|
264
|
+
[data-color-picker-background]{background-image:linear-gradient(0deg,#000 0,transparent),linear-gradient(90deg,#fff 0,hsla(0,0%,100%,0))}[data-color-picker-track]{background-image:linear-gradient(0deg,red,#f0f 17%,#00f 33%,#0ff 50%,#0f0 67%,#ff0 83%,red)}
|
|
265
|
+
</style>
|
|
@@ -1,37 +1,156 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { tv } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tv } from 'tailwind-variants'
|
|
3
|
+
import type { ListboxRootProps, ListboxRootEmits } from 'reka-ui'
|
|
4
|
+
import type { FuseResult } from 'fuse.js'
|
|
5
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
6
|
+
import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
|
|
7
|
+
import _appConfig from '#build/app.config'
|
|
8
|
+
import theme from '#build/ui/command-palette'
|
|
9
|
+
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
10
|
+
import { extendDevtoolsMeta } from '../composables/extendDevtoolsMeta'
|
|
11
|
+
import type { AvatarProps, ButtonProps, ChipProps, KbdProps, InputProps } from '../types'
|
|
12
|
+
import type { DynamicSlots, PartialString } from '../types/utils'
|
|
13
|
+
|
|
14
|
+
const appConfig = _appConfig as AppConfig & { ui: { commandPalette: Partial<typeof theme> } }
|
|
15
|
+
|
|
16
|
+
const commandPalette = tv({ extend: tv(theme), ...(appConfig.ui?.commandPalette || {}) })
|
|
17
|
+
|
|
18
|
+
export interface CommandPaletteItem {
|
|
19
|
+
prefix?: string
|
|
20
|
+
label?: string
|
|
21
|
+
suffix?: string
|
|
22
|
+
icon?: string
|
|
23
|
+
avatar?: AvatarProps
|
|
24
|
+
chip?: ChipProps
|
|
25
|
+
kbds?: KbdProps['value'][] | KbdProps[]
|
|
26
|
+
active?: boolean
|
|
27
|
+
loading?: boolean
|
|
28
|
+
disabled?: boolean
|
|
29
|
+
slot?: string
|
|
30
|
+
onSelect?(e?: Event): void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CommandPaletteGroup<T> {
|
|
34
|
+
id: string
|
|
35
|
+
label?: string
|
|
36
|
+
slot?: string
|
|
37
|
+
items?: T[]
|
|
38
|
+
/**
|
|
39
|
+
* Whether to filter group items with [useFuse](https://vueuse.org/integrations/useFuse).
|
|
40
|
+
* When `true`, items will not be filtered which is useful for custom filtering (useAsyncData, useFetch, etc.).
|
|
41
|
+
* @defaultValue false
|
|
42
|
+
*/
|
|
43
|
+
ignoreFilter?: boolean
|
|
44
|
+
/** Filter group items after the search happened. */
|
|
45
|
+
postFilter?: (searchTerm: string, items: T[]) => T[]
|
|
46
|
+
/** The icon displayed when an item is highlighted. */
|
|
47
|
+
highlightedIcon?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CommandPaletteProps<G, T> extends Pick<ListboxRootProps, 'multiple' | 'disabled' | 'modelValue' | 'defaultValue' | 'highlightOnHover'>, Pick<UseComponentIconsProps, 'loading' | 'loadingIcon'> {
|
|
51
|
+
/**
|
|
52
|
+
* The element or component this component should render as.
|
|
53
|
+
* @defaultValue 'div'
|
|
54
|
+
*/
|
|
55
|
+
as?: any
|
|
56
|
+
/**
|
|
57
|
+
* The icon displayed in the input.
|
|
58
|
+
* @defaultValue appConfig.ui.icons.search
|
|
59
|
+
*/
|
|
60
|
+
icon?: string
|
|
61
|
+
/**
|
|
62
|
+
* The icon displayed when an item is selected.
|
|
63
|
+
* @defaultValue appConfig.ui.icons.check
|
|
64
|
+
*/
|
|
65
|
+
selectedIcon?: string
|
|
66
|
+
/**
|
|
67
|
+
* The placeholder text for the input.
|
|
68
|
+
* @defaultValue 'Type a command or search...'
|
|
69
|
+
*/
|
|
70
|
+
placeholder?: InputProps['placeholder']
|
|
71
|
+
/**
|
|
72
|
+
* Display a close button in the input (useful when inside a Modal for example).
|
|
73
|
+
* `{ size: 'md', color: 'neutral', variant: 'ghost' }`{lang="ts-type"}
|
|
74
|
+
* @defaultValue false
|
|
75
|
+
*/
|
|
76
|
+
close?: ButtonProps | boolean
|
|
77
|
+
/**
|
|
78
|
+
* The icon displayed in the close button.
|
|
79
|
+
* @defaultValue appConfig.ui.icons.close
|
|
80
|
+
*/
|
|
81
|
+
closeIcon?: string
|
|
82
|
+
groups?: G[]
|
|
83
|
+
/**
|
|
84
|
+
* Options for [useFuse](https://vueuse.org/integrations/useFuse).
|
|
85
|
+
* @defaultValue {
|
|
86
|
+
fuseOptions: {
|
|
87
|
+
ignoreLocation: true,
|
|
88
|
+
threshold: 0.1,
|
|
89
|
+
keys: ['label', 'suffix']
|
|
90
|
+
},
|
|
91
|
+
resultLimit: 12,
|
|
92
|
+
matchAllWhenSearchEmpty: true
|
|
93
|
+
}
|
|
94
|
+
*/
|
|
95
|
+
fuse?: UseFuseOptions<T>
|
|
96
|
+
/**
|
|
97
|
+
* The key used to get the label from the item.
|
|
98
|
+
* @defaultValue 'label'
|
|
99
|
+
*/
|
|
100
|
+
labelKey?: string
|
|
101
|
+
class?: any
|
|
102
|
+
ui?: PartialString<typeof commandPalette.slots>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type CommandPaletteEmits<T> = ListboxRootEmits<T> & {
|
|
106
|
+
'update:open': [value: boolean]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
110
|
+
|
|
111
|
+
export type CommandPaletteSlots<G extends { slot?: string }, T extends { slot?: string }> = {
|
|
112
|
+
'empty'(props: { searchTerm?: string }): any
|
|
113
|
+
'close'(props: { ui: any }): any
|
|
114
|
+
'item': SlotProps<T>
|
|
115
|
+
'item-leading': SlotProps<T>
|
|
116
|
+
'item-label': SlotProps<T>
|
|
117
|
+
'item-trailing': SlotProps<T>
|
|
118
|
+
} & DynamicSlots<G, SlotProps<T>> & DynamicSlots<T, SlotProps<T>>
|
|
119
|
+
|
|
120
|
+
extendDevtoolsMeta({ example: 'CommandPaletteExample', ignoreProps: ['groups'] })
|
|
7
121
|
</script>
|
|
8
122
|
|
|
9
123
|
<script setup lang="ts" generic="G extends CommandPaletteGroup<T>, T extends CommandPaletteItem">
|
|
10
124
|
import { computed } from 'vue'
|
|
11
|
-
import {
|
|
125
|
+
import { ListboxRoot, ListboxFilter, ListboxContent, ListboxGroup, ListboxGroupLabel, ListboxItem, ListboxItemIndicator, useForwardProps, useForwardPropsEmits } from 'reka-ui'
|
|
12
126
|
import { defu } from 'defu'
|
|
13
127
|
import { reactivePick } from '@vueuse/core'
|
|
14
128
|
import { useFuse } from '@vueuse/integrations/useFuse'
|
|
15
129
|
import { useAppConfig } from '#imports'
|
|
130
|
+
import { useLocale } from '../composables/useLocale'
|
|
131
|
+
import { omit, get } from '../utils'
|
|
132
|
+
import { highlight } from '../utils/fuse'
|
|
16
133
|
import UIcon from './Icon.vue'
|
|
17
134
|
import UAvatar from './Avatar.vue'
|
|
135
|
+
import UButton from './Button.vue'
|
|
18
136
|
import UChip from './Chip.vue'
|
|
19
137
|
import UKbd from './Kbd.vue'
|
|
20
138
|
import UInput from './Input.vue'
|
|
21
|
-
import { omit } from '../utils'
|
|
22
|
-
import { highlight } from '../utils/fuse'
|
|
23
139
|
|
|
24
140
|
const props = withDefaults(defineProps<CommandPaletteProps<G, T>>(), {
|
|
25
141
|
modelValue: '',
|
|
26
|
-
placeholder: 'Type a command or search...'
|
|
142
|
+
placeholder: 'Type a command or search...',
|
|
143
|
+
labelKey: 'label'
|
|
27
144
|
})
|
|
28
145
|
const emits = defineEmits<CommandPaletteEmits<T>>()
|
|
29
146
|
const slots = defineSlots<CommandPaletteSlots<G, T>>()
|
|
30
147
|
|
|
31
148
|
const searchTerm = defineModel<string>('searchTerm', { default: '' })
|
|
32
149
|
|
|
150
|
+
const { t } = useLocale()
|
|
33
151
|
const appConfig = useAppConfig()
|
|
34
|
-
|
|
152
|
+
|
|
153
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'disabled', 'multiple', 'modelValue', 'defaultValue', 'highlightOnHover'), emits)
|
|
35
154
|
const inputProps = useForwardProps(reactivePick(props, 'loading', 'loadingIcon', 'placeholder'))
|
|
36
155
|
|
|
37
156
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
@@ -41,7 +160,7 @@ const fuse = computed(() => defu({}, props.fuse, {
|
|
|
41
160
|
fuseOptions: {
|
|
42
161
|
ignoreLocation: true,
|
|
43
162
|
threshold: 0.1,
|
|
44
|
-
keys: [
|
|
163
|
+
keys: [props.labelKey, 'suffix']
|
|
45
164
|
},
|
|
46
165
|
resultLimit: 12,
|
|
47
166
|
matchAllWhenSearchEmpty: true
|
|
@@ -53,7 +172,7 @@ const items = computed(() => props.groups?.filter((group) => {
|
|
|
53
172
|
return false
|
|
54
173
|
}
|
|
55
174
|
|
|
56
|
-
if (group.
|
|
175
|
+
if (group.ignoreFilter) {
|
|
57
176
|
return false
|
|
58
177
|
}
|
|
59
178
|
|
|
@@ -72,8 +191,8 @@ function getGroupWithItems(group: G, items: (T & { matches?: FuseResult<T>['matc
|
|
|
72
191
|
items: items.slice(0, fuse.value.resultLimit).map((item) => {
|
|
73
192
|
return {
|
|
74
193
|
...item,
|
|
75
|
-
labelHtml: highlight<T>(item, searchTerm.value,
|
|
76
|
-
suffixHtml: highlight<T>(item, searchTerm.value, undefined, [
|
|
194
|
+
labelHtml: highlight<T>(item, searchTerm.value, props.labelKey),
|
|
195
|
+
suffixHtml: highlight<T>(item, searchTerm.value, undefined, [props.labelKey])
|
|
77
196
|
}
|
|
78
197
|
})
|
|
79
198
|
}
|
|
@@ -87,7 +206,7 @@ const groups = computed(() => {
|
|
|
87
206
|
}
|
|
88
207
|
|
|
89
208
|
acc[item.group] ||= []
|
|
90
|
-
acc[item.group]
|
|
209
|
+
acc[item.group]?.push({ ...item, matches })
|
|
91
210
|
|
|
92
211
|
return acc
|
|
93
212
|
}, {} as Record<string, (T & { matches?: FuseResult<T>['matches'] })[]>)
|
|
@@ -101,21 +220,22 @@ const groups = computed(() => {
|
|
|
101
220
|
return getGroupWithItems(group, items)
|
|
102
221
|
}).filter(group => !!group)
|
|
103
222
|
|
|
104
|
-
const nonFuseGroups = props.groups
|
|
105
|
-
|
|
106
|
-
|
|
223
|
+
const nonFuseGroups = props.groups
|
|
224
|
+
?.map((group, index) => ({ ...group, index }))
|
|
225
|
+
?.filter(group => group.ignoreFilter && group.items?.length)
|
|
226
|
+
?.map(group => ({ ...getGroupWithItems(group, group.items || []), index: group.index })) || []
|
|
107
227
|
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
]
|
|
228
|
+
return nonFuseGroups.reduce((acc, group) => {
|
|
229
|
+
acc.splice(group.index, 0, group)
|
|
230
|
+
return acc
|
|
231
|
+
}, [...fuseGroups])
|
|
112
232
|
})
|
|
113
233
|
</script>
|
|
114
234
|
|
|
115
235
|
<!-- eslint-disable vue/no-v-html -->
|
|
116
236
|
<template>
|
|
117
|
-
<
|
|
118
|
-
<
|
|
237
|
+
<ListboxRoot v-bind="rootProps" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
238
|
+
<ListboxFilter v-model="searchTerm" as-child>
|
|
119
239
|
<UInput
|
|
120
240
|
variant="none"
|
|
121
241
|
autofocus
|
|
@@ -130,9 +250,9 @@ const groups = computed(() => {
|
|
|
130
250
|
v-if="close"
|
|
131
251
|
:icon="closeIcon || appConfig.ui.icons.close"
|
|
132
252
|
size="md"
|
|
133
|
-
color="
|
|
253
|
+
color="neutral"
|
|
134
254
|
variant="ghost"
|
|
135
|
-
aria-label="
|
|
255
|
+
:aria-label="t('commandPalette.close')"
|
|
136
256
|
v-bind="typeof close === 'object' ? close : undefined"
|
|
137
257
|
:class="ui.close({ class: props.ui?.close })"
|
|
138
258
|
@click="emits('update:open', false)"
|
|
@@ -140,71 +260,70 @@ const groups = computed(() => {
|
|
|
140
260
|
</slot>
|
|
141
261
|
</template>
|
|
142
262
|
</UInput>
|
|
143
|
-
</
|
|
263
|
+
</ListboxFilter>
|
|
144
264
|
|
|
145
|
-
<
|
|
146
|
-
<
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
{{
|
|
150
|
-
</
|
|
151
|
-
</ComboboxEmpty>
|
|
152
|
-
|
|
153
|
-
<ComboboxViewport :class="ui.viewport({ class: props.ui?.viewport })">
|
|
154
|
-
<ComboboxGroup v-for="(group, groupIndex) in groups" :key="`group-${groupIndex}`" :class="ui.group({ class: props.ui?.group })">
|
|
155
|
-
<ComboboxLabel v-if="group.label" :class="ui.label({ class: props.ui?.label })">
|
|
156
|
-
{{ group.label }}
|
|
157
|
-
</ComboboxLabel>
|
|
158
|
-
|
|
159
|
-
<ComboboxItem
|
|
160
|
-
v-for="(item, index) in group.items"
|
|
161
|
-
:key="`group-${groupIndex}-${index}`"
|
|
162
|
-
:value="omit(item, ['matches' as any, 'group' as any, 'select', 'labelHtml', 'suffixHtml'])"
|
|
163
|
-
:disabled="item.disabled"
|
|
164
|
-
:class="ui.item({ class: props.ui?.item })"
|
|
165
|
-
@select="item.select"
|
|
166
|
-
>
|
|
167
|
-
<slot :name="item.slot || group.slot || 'item'" :item="item" :index="index">
|
|
168
|
-
<slot :name="item.slot ? `${item.slot}-leading` : group.slot ? `${group.slot}-leading` : `item-leading`" :item="item" :index="index">
|
|
169
|
-
<UAvatar v-if="item.avatar" :size="((props.ui?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="ui.itemLeadingAvatar({ class: props.ui?.itemLeadingAvatar })" />
|
|
170
|
-
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.itemLeadingIcon({ class: props.ui?.itemLeadingIcon })" />
|
|
171
|
-
<UChip
|
|
172
|
-
v-else-if="item.chip"
|
|
173
|
-
:size="((props.ui?.itemLeadingChipSize || ui.itemLeadingChipSize()) as ChipProps['size'])"
|
|
174
|
-
inset
|
|
175
|
-
standalone
|
|
176
|
-
v-bind="item.chip"
|
|
177
|
-
:class="ui.itemLeadingChip({ class: props.ui?.itemLeadingChip })"
|
|
178
|
-
/>
|
|
179
|
-
</slot>
|
|
265
|
+
<ListboxContent :class="ui.content({ class: props.ui?.content })">
|
|
266
|
+
<div v-if="groups?.length" :class="ui.viewport({ class: props.ui?.viewport })">
|
|
267
|
+
<ListboxGroup v-for="(group, groupIndex) in groups" :key="`group-${groupIndex}`" :class="ui.group({ class: props.ui?.group })">
|
|
268
|
+
<ListboxGroupLabel v-if="get(group, props.labelKey as string)" :class="ui.label({ class: props.ui?.label })">
|
|
269
|
+
{{ get(group, props.labelKey as string) }}
|
|
270
|
+
</ListboxGroupLabel>
|
|
180
271
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
272
|
+
<ListboxItem
|
|
273
|
+
v-for="(item, index) in group.items"
|
|
274
|
+
:key="`group-${groupIndex}-${index}`"
|
|
275
|
+
:value="omit(item, ['matches' as any, 'group' as any, 'onSelect', 'labelHtml', 'suffixHtml'])"
|
|
276
|
+
:disabled="item.disabled"
|
|
277
|
+
:class="ui.item({ class: props.ui?.item, active: item.active })"
|
|
278
|
+
@select="item.onSelect"
|
|
279
|
+
>
|
|
280
|
+
<slot :name="item.slot || group.slot || 'item'" :item="item" :index="index">
|
|
281
|
+
<slot :name="item.slot ? `${item.slot}-leading` : group.slot ? `${group.slot}-leading` : `item-leading`" :item="item" :index="index">
|
|
282
|
+
<UIcon v-if="item.loading" :name="loadingIcon || appConfig.ui.icons.loading" :class="ui.itemLeadingIcon({ class: props.ui?.itemLeadingIcon, loading: true })" />
|
|
283
|
+
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.itemLeadingIcon({ class: props.ui?.itemLeadingIcon, active: item.active })" />
|
|
284
|
+
<UAvatar v-else-if="item.avatar" :size="((props.ui?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="ui.itemLeadingAvatar({ class: props.ui?.itemLeadingAvatar, active: item.active })" />
|
|
285
|
+
<UChip
|
|
286
|
+
v-else-if="item.chip"
|
|
287
|
+
:size="((props.ui?.itemLeadingChipSize || ui.itemLeadingChipSize()) as ChipProps['size'])"
|
|
288
|
+
inset
|
|
289
|
+
standalone
|
|
290
|
+
v-bind="item.chip"
|
|
291
|
+
:class="ui.itemLeadingChip({ class: props.ui?.itemLeadingChip, active: item.active })"
|
|
292
|
+
/>
|
|
293
|
+
</slot>
|
|
184
294
|
|
|
185
|
-
|
|
295
|
+
<span v-if="item.labelHtml || get(item, props.labelKey as string) || !!slots[item.slot ? `${item.slot}-label` : group.slot ? `${group.slot}-label` : `item-label`]" :class="ui.itemLabel({ class: props.ui?.itemLabel, active: item.active })">
|
|
296
|
+
<slot :name="item.slot ? `${item.slot}-label` : group.slot ? `${group.slot}-label` : `item-label`" :item="item" :index="index">
|
|
297
|
+
<span v-if="item.prefix" :class="ui.itemLabelPrefix({ class: props.ui?.itemLabelPrefix })">{{ item.prefix }}</span>
|
|
186
298
|
|
|
187
|
-
|
|
188
|
-
</slot>
|
|
189
|
-
</span>
|
|
299
|
+
<span :class="ui.itemLabelBase({ class: props.ui?.itemLabelBase, active: item.active })" v-html="item.labelHtml || get(item, props.labelKey as string)" />
|
|
190
300
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
<UKbd v-for="(kbd, kbdIndex) in item.kbds" :key="kbdIndex" :size="((props.ui?.itemTrailingKbdsSize || ui.itemTrailingKbdsSize()) as KbdProps['size'])" v-bind="typeof kbd === 'string' ? { value: kbd } : kbd" />
|
|
195
|
-
</span>
|
|
196
|
-
<UIcon v-else-if="group.highlightedIcon" :name="group.highlightedIcon" :class="ui.itemTrailingHighlightedIcon({ class: props.ui?.itemTrailingHighlightedIcon })" />
|
|
197
|
-
</slot>
|
|
301
|
+
<span :class="ui.itemLabelSuffix({ class: props.ui?.itemLabelSuffix, active: item.active })" v-html="item.suffixHtml || item.suffix" />
|
|
302
|
+
</slot>
|
|
303
|
+
</span>
|
|
198
304
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
305
|
+
<span :class="ui.itemTrailing({ class: props.ui?.itemTrailing })">
|
|
306
|
+
<slot :name="item.slot ? `${item.slot}-trailing` : group.slot ? `${group.slot}-trailing` : `item-trailing`" :item="item" :index="index">
|
|
307
|
+
<span v-if="item.kbds?.length" :class="ui.itemTrailingKbds({ class: props.ui?.itemTrailingKbds })">
|
|
308
|
+
<UKbd v-for="(kbd, kbdIndex) in item.kbds" :key="kbdIndex" :size="((props.ui?.itemTrailingKbdsSize || ui.itemTrailingKbdsSize()) as KbdProps['size'])" v-bind="typeof kbd === 'string' ? { value: kbd } : kbd" />
|
|
309
|
+
</span>
|
|
310
|
+
<UIcon v-else-if="group.highlightedIcon" :name="group.highlightedIcon" :class="ui.itemTrailingHighlightedIcon({ class: props.ui?.itemTrailingHighlightedIcon })" />
|
|
311
|
+
</slot>
|
|
312
|
+
|
|
313
|
+
<ListboxItemIndicator as-child>
|
|
314
|
+
<UIcon :name="selectedIcon || appConfig.ui.icons.check" :class="ui.itemTrailingIcon({ class: props.ui?.itemTrailingIcon })" />
|
|
315
|
+
</ListboxItemIndicator>
|
|
316
|
+
</span>
|
|
317
|
+
</slot>
|
|
318
|
+
</ListboxItem>
|
|
319
|
+
</ListboxGroup>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
<div v-else :class="ui.empty({ class: props.ui?.empty })">
|
|
323
|
+
<slot name="empty" :search-term="searchTerm">
|
|
324
|
+
{{ searchTerm ? t('commandPalette.noMatch', { searchTerm }) : t('commandPalette.noData') }}
|
|
325
|
+
</slot>
|
|
326
|
+
</div>
|
|
327
|
+
</ListboxContent>
|
|
328
|
+
</ListboxRoot>
|
|
210
329
|
</template>
|