@nuxt/ui 3.0.0-alpha.8 → 3.0.0-beta.1
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 +2 -2
- package/.nuxt/ui/alert.ts +122 -95
- package/.nuxt/ui/avatar-group.ts +14 -2
- package/.nuxt/ui/avatar.ts +16 -4
- package/.nuxt/ui/badge.ts +139 -93
- package/.nuxt/ui/breadcrumb.ts +5 -5
- package/.nuxt/ui/button-group.ts +13 -0
- package/.nuxt/ui/button.ts +167 -136
- package/.nuxt/ui/calendar.ts +103 -0
- package/.nuxt/ui/card.ts +27 -1
- package/.nuxt/ui/carousel.ts +9 -7
- package/.nuxt/ui/checkbox.ts +45 -27
- package/.nuxt/ui/chip.ts +44 -15
- package/.nuxt/ui/color-picker.ts +47 -0
- package/.nuxt/ui/command-palette.ts +28 -18
- package/.nuxt/ui/container.ts +1 -1
- package/.nuxt/ui/context-menu.ts +64 -46
- package/.nuxt/ui/drawer.ts +83 -15
- package/.nuxt/ui/dropdown-menu.ts +65 -47
- package/.nuxt/ui/form-field.ts +15 -7
- package/.nuxt/ui/index.ts +7 -1
- package/.nuxt/ui/input-menu.ts +150 -116
- package/.nuxt/ui/input-number.ts +235 -0
- package/.nuxt/ui/input.ts +111 -76
- package/.nuxt/ui/kbd.ts +18 -6
- package/.nuxt/ui/link.ts +3 -3
- package/.nuxt/ui/modal.ts +8 -7
- package/.nuxt/ui/navigation-menu.ts +244 -131
- package/.nuxt/ui/pin-input.ts +171 -0
- package/.nuxt/ui/popover.ts +2 -2
- package/.nuxt/ui/progress.ts +111 -72
- package/.nuxt/ui/radio-group.ts +45 -22
- package/.nuxt/ui/select-menu.ts +127 -96
- package/.nuxt/ui/select.ts +120 -84
- package/.nuxt/ui/separator.ts +60 -31
- package/.nuxt/ui/skeleton.ts +1 -1
- package/.nuxt/ui/slideover.ts +17 -9
- package/.nuxt/ui/slider.ts +61 -38
- package/.nuxt/ui/stepper.ts +202 -0
- package/.nuxt/ui/switch.ts +40 -22
- package/.nuxt/ui/table.ts +49 -31
- package/.nuxt/ui/tabs.ts +101 -73
- package/.nuxt/ui/textarea.ts +111 -76
- package/.nuxt/ui/toast.ts +53 -33
- package/.nuxt/ui/toaster.ts +31 -15
- package/.nuxt/ui/tooltip.ts +2 -2
- package/.nuxt/ui/tree.ts +154 -0
- package/.nuxt/ui.css +92 -0
- package/README.md +69 -18
- package/cli/commands/{init.mjs → make/component.mjs} +16 -4
- package/cli/commands/make/index.mjs +14 -0
- package/cli/commands/make/locale.mjs +64 -0
- package/cli/index.mjs +2 -2
- package/cli/package.json +2 -2
- package/cli/templates.mjs +62 -12
- package/cli/utils.mjs +14 -0
- package/dist/module.cjs +9 -170
- package/dist/module.d.cts +5 -15
- package/dist/module.d.mts +5 -15
- package/dist/module.d.ts +5 -15
- package/dist/module.json +2 -2
- package/dist/module.mjs +12 -167
- package/dist/runtime/components/Accordion.vue +8 -39
- package/dist/runtime/components/Alert.vue +25 -21
- package/dist/runtime/components/App.vue +15 -15
- package/dist/runtime/components/Avatar.vue +33 -21
- package/dist/runtime/components/AvatarGroup.vue +5 -7
- package/dist/runtime/components/Badge.vue +10 -8
- package/dist/runtime/components/Breadcrumb.vue +13 -34
- package/dist/runtime/components/Button.vue +5 -8
- package/dist/runtime/components/ButtonGroup.vue +5 -7
- package/dist/runtime/components/Calendar.vue +194 -0
- package/dist/runtime/components/Card.vue +10 -9
- package/dist/runtime/components/Carousel.vue +26 -17
- package/dist/runtime/components/Checkbox.vue +32 -38
- package/dist/runtime/components/Chip.vue +6 -8
- package/dist/runtime/components/Collapsible.vue +10 -11
- package/dist/runtime/components/ColorPicker.vue +297 -0
- package/dist/runtime/components/CommandPalette.vue +114 -98
- package/dist/runtime/components/Container.vue +4 -7
- package/dist/runtime/components/ContextMenu.vue +16 -69
- package/dist/runtime/components/ContextMenuContent.vue +14 -10
- package/dist/runtime/components/Drawer.vue +23 -12
- package/dist/runtime/components/DropdownMenu.vue +18 -59
- package/dist/runtime/components/DropdownMenuContent.vue +14 -10
- package/dist/runtime/components/Form.vue +78 -49
- package/dist/runtime/components/FormField.vue +28 -15
- package/dist/runtime/components/Icon.vue +1 -1
- package/dist/runtime/components/Input.vue +15 -7
- package/dist/runtime/components/InputMenu.vue +133 -66
- package/dist/runtime/components/InputNumber.vue +197 -0
- package/dist/runtime/components/Kbd.vue +5 -6
- package/dist/runtime/components/Link.vue +24 -13
- package/dist/runtime/components/LinkBase.vue +1 -1
- package/dist/runtime/components/Modal.vue +56 -34
- package/dist/runtime/components/NavigationMenu.vue +129 -112
- package/dist/runtime/components/OverlayProvider.vue +28 -0
- package/dist/runtime/components/Pagination.vue +18 -14
- package/dist/runtime/components/PinInput.vue +95 -0
- package/dist/runtime/components/Popover.vue +28 -14
- package/dist/runtime/components/Progress.vue +28 -12
- package/dist/runtime/components/RadioGroup.vue +9 -12
- package/dist/runtime/components/Select.vue +61 -35
- package/dist/runtime/components/SelectMenu.vue +201 -130
- package/dist/runtime/components/Separator.vue +6 -5
- package/dist/runtime/components/Skeleton.vue +4 -7
- package/dist/runtime/components/Slideover.vue +56 -33
- package/dist/runtime/components/Slider.vue +8 -7
- package/dist/runtime/components/Stepper.vue +170 -0
- package/dist/runtime/components/Switch.vue +19 -23
- package/dist/runtime/components/Table.vue +157 -32
- package/dist/runtime/components/Tabs.vue +12 -31
- package/dist/runtime/components/Textarea.vue +18 -9
- package/dist/runtime/components/Toast.vue +39 -25
- package/dist/runtime/components/Toaster.vue +31 -24
- package/dist/runtime/components/Tooltip.vue +9 -12
- package/dist/runtime/components/Tree.vue +196 -0
- 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 -2
- package/dist/runtime/composables/useFormField.d.ts +11 -4
- package/dist/runtime/composables/useFormField.js +19 -9
- package/dist/runtime/composables/useLocale.d.ts +4 -0
- package/dist/runtime/composables/useLocale.js +10 -0
- package/dist/runtime/composables/useOverlay.d.ts +30 -0
- package/dist/runtime/composables/useOverlay.js +70 -0
- package/dist/runtime/composables/useToast.d.ts +4 -3
- package/dist/runtime/composables/useToast.js +20 -6
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/keyframes.css +1 -1
- package/dist/runtime/locale/ar.d.ts +2 -0
- package/dist/runtime/locale/ar.js +55 -0
- package/dist/runtime/locale/az.d.ts +2 -0
- package/dist/runtime/locale/az.js +54 -0
- package/dist/runtime/locale/bn.d.ts +2 -0
- package/dist/runtime/locale/bn.js +54 -0
- package/dist/runtime/locale/cs.d.ts +2 -0
- package/dist/runtime/locale/cs.js +54 -0
- package/dist/runtime/locale/da.d.ts +2 -0
- package/dist/runtime/locale/da.js +54 -0
- package/dist/runtime/locale/de.d.ts +2 -0
- package/dist/runtime/locale/de.js +54 -0
- package/dist/runtime/locale/el.d.ts +2 -0
- package/dist/runtime/locale/el.js +54 -0
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +54 -0
- package/dist/runtime/locale/es.d.ts +2 -0
- package/dist/runtime/locale/es.js +54 -0
- package/dist/runtime/locale/et.d.ts +2 -0
- package/dist/runtime/locale/et.js +54 -0
- package/dist/runtime/locale/fa_ir.d.ts +2 -0
- package/dist/runtime/locale/fa_ir.js +55 -0
- package/dist/runtime/locale/fi.d.ts +2 -0
- package/dist/runtime/locale/fi.js +54 -0
- package/dist/runtime/locale/fr.d.ts +2 -0
- package/dist/runtime/locale/fr.js +54 -0
- package/dist/runtime/locale/he.d.ts +2 -0
- package/dist/runtime/locale/he.js +53 -0
- package/dist/runtime/locale/hi.d.ts +2 -0
- package/dist/runtime/locale/hi.js +54 -0
- package/dist/runtime/locale/hu.d.ts +2 -0
- package/dist/runtime/locale/hu.js +54 -0
- package/dist/runtime/locale/id.d.ts +2 -0
- package/dist/runtime/locale/id.js +54 -0
- package/dist/runtime/locale/index.d.ts +34 -0
- package/dist/runtime/locale/index.js +34 -0
- package/dist/runtime/locale/it.d.ts +2 -0
- package/dist/runtime/locale/it.js +54 -0
- package/dist/runtime/locale/ja.d.ts +2 -0
- package/dist/runtime/locale/ja.js +54 -0
- package/dist/runtime/locale/km.d.ts +2 -0
- package/dist/runtime/locale/km.js +54 -0
- package/dist/runtime/locale/ko.d.ts +2 -0
- package/dist/runtime/locale/ko.js +54 -0
- package/dist/runtime/locale/nb_no.d.ts +2 -0
- package/dist/runtime/locale/nb_no.js +54 -0
- package/dist/runtime/locale/nl.d.ts +2 -0
- package/dist/runtime/locale/nl.js +54 -0
- package/dist/runtime/locale/pl.d.ts +2 -0
- package/dist/runtime/locale/pl.js +54 -0
- package/dist/runtime/locale/pt.d.ts +2 -0
- package/dist/runtime/locale/pt.js +54 -0
- package/dist/runtime/locale/pt_br.d.ts +2 -0
- package/dist/runtime/locale/pt_br.js +54 -0
- package/dist/runtime/locale/ru.d.ts +2 -0
- package/dist/runtime/locale/ru.js +54 -0
- package/dist/runtime/locale/sk.d.ts +2 -0
- package/dist/runtime/locale/sk.js +54 -0
- package/dist/runtime/locale/sv.d.ts +2 -0
- package/dist/runtime/locale/sv.js +54 -0
- package/dist/runtime/locale/th.d.ts +2 -0
- package/dist/runtime/locale/th.js +54 -0
- package/dist/runtime/locale/tr.d.ts +2 -0
- package/dist/runtime/locale/tr.js +54 -0
- package/dist/runtime/locale/uk.d.ts +2 -0
- package/dist/runtime/locale/uk.js +54 -0
- package/dist/runtime/locale/vi.d.ts +2 -0
- package/dist/runtime/locale/vi.js +54 -0
- package/dist/runtime/locale/zh_cn.d.ts +2 -0
- package/dist/runtime/locale/zh_cn.js +54 -0
- package/dist/runtime/locale/zh_tw.d.ts +2 -0
- package/dist/runtime/locale/zh_tw.js +54 -0
- package/dist/runtime/plugins/colors.js +8 -5
- package/dist/runtime/types/form.d.ts +29 -15
- package/dist/runtime/types/form.js +2 -2
- package/dist/runtime/types/index.d.ts +8 -0
- package/dist/runtime/types/index.js +8 -0
- package/dist/runtime/types/locale.d.ts +56 -0
- package/dist/runtime/types/locale.js +0 -0
- package/dist/runtime/types/utils.d.ts +7 -3
- package/dist/runtime/utils/form.d.ts +5 -9
- package/dist/runtime/utils/form.js +113 -50
- package/dist/runtime/utils/index.d.ts +1 -1
- package/dist/runtime/utils/index.js +15 -2
- package/dist/runtime/utils/link.d.ts +1 -1
- package/dist/runtime/utils/locale.d.ts +15 -0
- package/dist/runtime/utils/locale.js +25 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/components/Icon.vue +2 -2
- package/dist/runtime/vue/components/Link.vue +87 -23
- package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
- package/dist/runtime/vue/composables/useAppConfig.js +2 -0
- package/dist/runtime/vue/plugins/head.d.ts +1 -1
- package/dist/runtime/vue/plugins/head.js +3 -3
- package/dist/runtime/vue/stubs.d.ts +19 -0
- package/dist/runtime/vue/stubs.js +37 -0
- package/dist/shared/{ui.BufKhDiD.mjs → ui.DSPu6Y8j.mjs} +1071 -409
- package/dist/shared/{ui.BU7wzH0D.cjs → ui.DfK2RX6G.cjs} +1074 -409
- package/dist/unplugin.cjs +62 -26
- package/dist/unplugin.d.cts +17 -3
- package/dist/unplugin.d.mts +17 -3
- package/dist/unplugin.d.ts +17 -3
- package/dist/unplugin.mjs +61 -25
- package/dist/vite.cjs +3 -2
- package/dist/vite.d.cts +2 -0
- package/dist/vite.d.mts +2 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.mjs +3 -2
- package/package.json +110 -67
- package/dist/chunks/component-meta.cjs +0 -73264
- package/dist/chunks/component-meta.mjs +0 -73262
- package/dist/client/devtools/200.html +0 -1
- package/dist/client/devtools/404.html +0 -1
- 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/Bj9hdafK.js +0 -1
- package/dist/client/devtools/_nuxt/DM3_wAgz.js +0 -62
- package/dist/client/devtools/_nuxt/builds/latest.json +0 -1
- package/dist/client/devtools/_nuxt/builds/meta/e6b425f7-b919-4014-915b-0ea07c316790.json +0 -1
- package/dist/client/devtools/_nuxt/entry.DaJP-ZMB.css +0 -24
- package/dist/client/devtools/_nuxt/error-404.B0Nmv3fV.css +0 -1
- package/dist/client/devtools/_nuxt/error-500.C8fgTxVz.css +0 -1
- package/dist/client/devtools/_nuxt/hKiujHsR.js +0 -1
- package/dist/client/devtools/favicon.svg +0 -1
- package/dist/client/devtools/index.html +0 -1
- package/dist/devtools/runtime/DevtoolsRenderer.vue +0 -53
- package/dist/devtools/runtime/examples/AvatarGroupExample.vue +0 -7
- package/dist/devtools/runtime/examples/ButtonGroupExample.vue +0 -8
- package/dist/devtools/runtime/examples/CardExample.vue +0 -13
- package/dist/devtools/runtime/examples/CarouselExample.vue +0 -13
- package/dist/devtools/runtime/examples/ChipExample.vue +0 -5
- package/dist/devtools/runtime/examples/CollapsibleExample.vue +0 -8
- package/dist/devtools/runtime/examples/CommandPaletteExample.vue +0 -29
- package/dist/devtools/runtime/examples/ContainerExample.vue +0 -5
- package/dist/devtools/runtime/examples/ContextMenuExample.vue +0 -5
- package/dist/devtools/runtime/examples/DrawerExample.vue +0 -8
- package/dist/devtools/runtime/examples/DropdownMenuExample.vue +0 -5
- package/dist/devtools/runtime/examples/FormExample.vue +0 -30
- package/dist/devtools/runtime/examples/FormFieldExample.vue +0 -5
- package/dist/devtools/runtime/examples/LinkExample.vue +0 -5
- package/dist/devtools/runtime/examples/ModalExample.vue +0 -8
- package/dist/devtools/runtime/examples/PopoverExample.vue +0 -8
- package/dist/devtools/runtime/examples/SkeletonExample.vue +0 -3
- package/dist/devtools/runtime/examples/SlideoverExample.vue +0 -8
- package/dist/devtools/runtime/examples/ToasterExample.vue +0 -11
- package/dist/devtools/runtime/examples/TooltipExample.vue +0 -5
- package/dist/runtime/components/ModalProvider.vue +0 -12
- package/dist/runtime/components/SlideoverProvider.vue +0 -12
- package/dist/runtime/composables/extendDevtoolsMeta.d.ts +0 -7
- package/dist/runtime/composables/extendDevtoolsMeta.js +0 -2
- package/dist/runtime/composables/useModal.d.ts +0 -17
- package/dist/runtime/composables/useModal.js +0 -46
- package/dist/runtime/composables/useSlideover.d.ts +0 -17
- package/dist/runtime/composables/useSlideover.js +0 -46
- package/dist/runtime/plugins/modal.d.ts +0 -2
- package/dist/runtime/plugins/modal.js +0 -10
- package/dist/runtime/plugins/slideover.d.ts +0 -2
- package/dist/runtime/plugins/slideover.js +0 -10
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import type { PopoverRootProps, HoverCardRootProps, PopoverRootEmits, PopoverContentProps, PopoverArrowProps } from 'radix-vue'
|
|
2
|
+
import type { PopoverRootProps, HoverCardRootProps, PopoverRootEmits, PopoverContentProps, PopoverArrowProps } from 'reka-ui'
|
|
4
3
|
import type { AppConfig } from '@nuxt/schema'
|
|
5
4
|
import _appConfig from '#build/app.config'
|
|
6
5
|
import theme from '#build/ui/popover'
|
|
7
|
-
import {
|
|
6
|
+
import { tv } from '../utils/tv'
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const appConfigPopover = _appConfig as AppConfig & { ui: { popover: Partial<typeof theme> } }
|
|
10
9
|
|
|
11
|
-
const popover = tv({ extend: tv(theme), ...(
|
|
10
|
+
const popover = tv({ extend: tv(theme), ...(appConfigPopover.ui?.popover || {}) })
|
|
12
11
|
|
|
13
12
|
export interface PopoverProps extends PopoverRootProps, Pick<HoverCardRootProps, 'openDelay' | 'closeDelay'> {
|
|
14
13
|
/**
|
|
@@ -18,7 +17,7 @@ export interface PopoverProps extends PopoverRootProps, Pick<HoverCardRootProps,
|
|
|
18
17
|
mode?: 'click' | 'hover'
|
|
19
18
|
/**
|
|
20
19
|
* The content of the popover.
|
|
21
|
-
* @defaultValue { side: 'bottom', sideOffset: 8 }
|
|
20
|
+
* @defaultValue { side: 'bottom', sideOffset: 8, collisionPadding: 8 }
|
|
22
21
|
*/
|
|
23
22
|
content?: Omit<PopoverContentProps, 'as' | 'asChild' | 'forceMount'>
|
|
24
23
|
/**
|
|
@@ -31,6 +30,11 @@ export interface PopoverProps extends PopoverRootProps, Pick<HoverCardRootProps,
|
|
|
31
30
|
* @defaultValue true
|
|
32
31
|
*/
|
|
33
32
|
portal?: boolean
|
|
33
|
+
/**
|
|
34
|
+
* When `false`, the popover will not close when clicking outside or pressing escape.
|
|
35
|
+
* @defaultValue true
|
|
36
|
+
*/
|
|
37
|
+
dismissible?: boolean
|
|
34
38
|
class?: any
|
|
35
39
|
ui?: Partial<typeof popover.slots>
|
|
36
40
|
}
|
|
@@ -41,29 +45,39 @@ export interface PopoverSlots {
|
|
|
41
45
|
default(props: { open: boolean }): any
|
|
42
46
|
content(props?: {}): any
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
extendDevtoolsMeta({ example: 'PopoverExample' })
|
|
46
48
|
</script>
|
|
47
49
|
|
|
48
50
|
<script setup lang="ts">
|
|
49
51
|
import { computed, toRef } from 'vue'
|
|
50
52
|
import { defu } from 'defu'
|
|
51
|
-
import { useForwardPropsEmits } from '
|
|
52
|
-
import { Popover, HoverCard } from '
|
|
53
|
+
import { useForwardPropsEmits } from 'reka-ui'
|
|
54
|
+
import { Popover, HoverCard } from 'reka-ui/namespaced'
|
|
53
55
|
import { reactivePick } from '@vueuse/core'
|
|
54
56
|
|
|
55
57
|
const props = withDefaults(defineProps<PopoverProps>(), {
|
|
56
58
|
portal: true,
|
|
57
59
|
mode: 'click',
|
|
58
60
|
openDelay: 0,
|
|
59
|
-
closeDelay: 0
|
|
61
|
+
closeDelay: 0,
|
|
62
|
+
dismissible: true
|
|
60
63
|
})
|
|
61
64
|
const emits = defineEmits<PopoverEmits>()
|
|
62
65
|
const slots = defineSlots<PopoverSlots>()
|
|
63
66
|
|
|
64
67
|
const pick = props.mode === 'hover' ? reactivePick(props, 'defaultOpen', 'open', 'openDelay', 'closeDelay') : reactivePick(props, 'defaultOpen', 'open', 'modal')
|
|
65
68
|
const rootProps = useForwardPropsEmits(pick, emits)
|
|
66
|
-
const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8 }) as PopoverContentProps)
|
|
69
|
+
const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8 }) as PopoverContentProps)
|
|
70
|
+
const contentEvents = computed(() => {
|
|
71
|
+
if (!props.dismissible) {
|
|
72
|
+
return {
|
|
73
|
+
pointerDownOutside: (e: Event) => e.preventDefault(),
|
|
74
|
+
interactOutside: (e: Event) => e.preventDefault(),
|
|
75
|
+
escapeKeyDown: (e: Event) => e.preventDefault()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {}
|
|
80
|
+
})
|
|
67
81
|
const arrowProps = toRef(() => props.arrow as PopoverArrowProps)
|
|
68
82
|
|
|
69
83
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
@@ -76,12 +90,12 @@ const Component = computed(() => props.mode === 'hover' ? HoverCard : Popover)
|
|
|
76
90
|
|
|
77
91
|
<template>
|
|
78
92
|
<Component.Root v-slot="{ open }" v-bind="rootProps">
|
|
79
|
-
<Component.Trigger v-if="!!slots.default" as-child>
|
|
93
|
+
<Component.Trigger v-if="!!slots.default" as-child :class="props.class">
|
|
80
94
|
<slot :open="open" />
|
|
81
95
|
</Component.Trigger>
|
|
82
96
|
|
|
83
97
|
<Component.Portal :disabled="!portal">
|
|
84
|
-
<Component.Content v-bind="contentProps" :class="ui.content({ class: [props.class, props.ui?.content] })">
|
|
98
|
+
<Component.Content v-bind="contentProps" :class="ui.content({ class: [!slots.default && props.class, props.ui?.content] })" v-on="contentEvents">
|
|
85
99
|
<slot name="content" />
|
|
86
100
|
|
|
87
101
|
<Component.Arrow v-if="!!arrow" v-bind="arrowProps" :class="ui.arrow({ class: props.ui?.arrow })" />
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<!-- eslint-disable vue/block-tag-newline -->
|
|
2
2
|
<script lang="ts">
|
|
3
|
-
import {
|
|
4
|
-
import type { ProgressRootProps, ProgressRootEmits } from '
|
|
3
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
4
|
+
import type { ProgressRootProps, ProgressRootEmits } from 'reka-ui'
|
|
5
5
|
import type { AppConfig } from '@nuxt/schema'
|
|
6
6
|
import _appConfig from '#build/app.config'
|
|
7
7
|
import theme from '#build/ui/progress'
|
|
8
|
+
import { tv } from '../utils/tv'
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const appConfigProgress = _appConfig as AppConfig & { ui: { progress: Partial<typeof theme> } }
|
|
10
11
|
|
|
11
|
-
const progress = tv({ extend: tv(theme), ...(
|
|
12
|
+
const progress = tv({ extend: tv(theme), ...(appConfigProgress.ui?.progress || {}) })
|
|
12
13
|
|
|
13
14
|
type ProgressVariants = VariantProps<typeof progress>
|
|
14
15
|
|
|
@@ -48,8 +49,9 @@ export type ProgressSlots = {
|
|
|
48
49
|
|
|
49
50
|
<script setup lang="ts">
|
|
50
51
|
import { computed } from 'vue'
|
|
51
|
-
import {
|
|
52
|
+
import { Primitive, ProgressRoot, ProgressIndicator, useForwardPropsEmits } from 'reka-ui'
|
|
52
53
|
import { reactivePick } from '@vueuse/core'
|
|
54
|
+
import { useLocale } from '../composables/useLocale'
|
|
53
55
|
|
|
54
56
|
const props = withDefaults(defineProps<ProgressProps>(), {
|
|
55
57
|
inverted: false,
|
|
@@ -57,9 +59,11 @@ const props = withDefaults(defineProps<ProgressProps>(), {
|
|
|
57
59
|
orientation: 'horizontal'
|
|
58
60
|
})
|
|
59
61
|
const emits = defineEmits<ProgressEmits>()
|
|
60
|
-
defineSlots<ProgressSlots>()
|
|
62
|
+
const slots = defineSlots<ProgressSlots>()
|
|
61
63
|
|
|
62
|
-
const
|
|
64
|
+
const { dir } = useLocale()
|
|
65
|
+
|
|
66
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'getValueLabel', 'modelValue'), emits)
|
|
63
67
|
|
|
64
68
|
const isIndeterminate = computed(() => rootProps.value.modelValue === null)
|
|
65
69
|
const hasSteps = computed(() => Array.isArray(props.max))
|
|
@@ -93,8 +97,20 @@ const indicatorStyle = computed(() => {
|
|
|
93
97
|
return
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
if (props.orientation === 'vertical') {
|
|
101
|
+
return {
|
|
102
|
+
transform: `translateY(${props.inverted ? '' : '-'}${100 - percent.value}%)`
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
if (dir.value === 'rtl') {
|
|
106
|
+
return {
|
|
107
|
+
transform: `translateX(${props.inverted ? '-' : ''}${100 - percent.value}%)`
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
return {
|
|
111
|
+
transform: `translateX(${props.inverted ? '' : '-'}${100 - percent.value}%)`
|
|
112
|
+
}
|
|
113
|
+
}
|
|
98
114
|
}
|
|
99
115
|
})
|
|
100
116
|
|
|
@@ -144,8 +160,8 @@ const ui = computed(() => progress({
|
|
|
144
160
|
</script>
|
|
145
161
|
|
|
146
162
|
<template>
|
|
147
|
-
<
|
|
148
|
-
<div v-if="!isIndeterminate && (status ||
|
|
163
|
+
<Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
164
|
+
<div v-if="!isIndeterminate && (status || !!slots.status)" :class="ui.status({ class: props.ui?.status })" :style="statusStyle">
|
|
149
165
|
<slot name="status" :percent="percent">
|
|
150
166
|
{{ percent }}%
|
|
151
167
|
</slot>
|
|
@@ -162,5 +178,5 @@ const ui = computed(() => progress({
|
|
|
162
178
|
</slot>
|
|
163
179
|
</div>
|
|
164
180
|
</div>
|
|
165
|
-
</
|
|
181
|
+
</Primitive>
|
|
166
182
|
</template>
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import type { RadioGroupRootProps, RadioGroupRootEmits } from '
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { RadioGroupRootProps, RadioGroupRootEmits, AcceptableValue } from 'reka-ui'
|
|
4
4
|
import type { AppConfig } from '@nuxt/schema'
|
|
5
5
|
import _appConfig from '#build/app.config'
|
|
6
6
|
import theme from '#build/ui/radio-group'
|
|
7
|
-
import {
|
|
8
|
-
import type { AcceptableValue } from '../types/utils'
|
|
7
|
+
import { tv } from '../utils/tv'
|
|
9
8
|
|
|
10
|
-
const
|
|
9
|
+
const appConfigRadioGroup = _appConfig as AppConfig & { ui: { radioGroup: Partial<typeof theme> } }
|
|
11
10
|
|
|
12
|
-
const radioGroup = tv({ extend: tv(theme), ...(
|
|
11
|
+
const radioGroup = tv({ extend: tv(theme), ...(appConfigRadioGroup.ui?.radioGroup || {}) })
|
|
13
12
|
|
|
14
13
|
type RadioGroupVariants = VariantProps<typeof radioGroup>
|
|
15
14
|
|
|
@@ -58,20 +57,18 @@ export type RadioGroupEmits = RadioGroupRootEmits & {
|
|
|
58
57
|
change: [payload: Event]
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
type SlotProps<T> = (props: { item: T, modelValue?:
|
|
60
|
+
type SlotProps<T> = (props: { item: T, modelValue?: AcceptableValue }) => any
|
|
62
61
|
|
|
63
62
|
export interface RadioGroupSlots<T> {
|
|
64
63
|
legend(props?: {}): any
|
|
65
64
|
label: SlotProps<T>
|
|
66
65
|
description: SlotProps<T>
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
extendDevtoolsMeta({ defaultProps: { items: ['Option 1', 'Option 2', 'Option 3'] } })
|
|
70
67
|
</script>
|
|
71
68
|
|
|
72
69
|
<script setup lang="ts" generic="T extends RadioGroupItem | AcceptableValue">
|
|
73
70
|
import { computed, useId } from 'vue'
|
|
74
|
-
import { RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, Label, useForwardPropsEmits } from '
|
|
71
|
+
import { RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, Label, useForwardPropsEmits } from 'reka-ui'
|
|
75
72
|
import { reactivePick } from '@vueuse/core'
|
|
76
73
|
import { useFormField } from '../composables/useFormField'
|
|
77
74
|
import { get } from '../utils'
|
|
@@ -87,7 +84,7 @@ const slots = defineSlots<RadioGroupSlots<T>>()
|
|
|
87
84
|
|
|
88
85
|
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'loop', 'required'), emits)
|
|
89
86
|
|
|
90
|
-
const { emitFormChange, emitFormInput, color, name, size, id: _id, disabled } = useFormField<RadioGroupProps<T>>(props, { bind: false })
|
|
87
|
+
const { emitFormChange, emitFormInput, color, name, size, id: _id, disabled, ariaAttrs } = useFormField<RadioGroupProps<T>>(props, { bind: false })
|
|
91
88
|
const id = _id.value ?? useId()
|
|
92
89
|
|
|
93
90
|
const ui = computed(() => radioGroup({
|
|
@@ -147,7 +144,7 @@ function onUpdate(value: any) {
|
|
|
147
144
|
:class="ui.root({ class: [props.class, props.ui?.root] })"
|
|
148
145
|
@update:model-value="onUpdate"
|
|
149
146
|
>
|
|
150
|
-
<fieldset :class="ui.fieldset({ class: props.ui?.fieldset })">
|
|
147
|
+
<fieldset :class="ui.fieldset({ class: props.ui?.fieldset })" v-bind="ariaAttrs">
|
|
151
148
|
<legend v-if="legend || !!slots.legend" :class="ui.legend({ class: props.ui?.legend })">
|
|
152
149
|
<slot name="legend">
|
|
153
150
|
{{ legend }}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import type { SelectRootProps, SelectRootEmits, SelectContentProps, SelectArrowProps } from '
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { SelectRootProps, SelectRootEmits, SelectContentProps, SelectArrowProps, AcceptableValue } from 'reka-ui'
|
|
4
4
|
import type { AppConfig } from '@nuxt/schema'
|
|
5
5
|
import _appConfig from '#build/app.config'
|
|
6
6
|
import theme from '#build/ui/select'
|
|
7
7
|
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
8
|
-
import {
|
|
8
|
+
import { tv } from '../utils/tv'
|
|
9
9
|
import type { AvatarProps, ChipProps, InputProps } from '../types'
|
|
10
|
-
import type {
|
|
10
|
+
import type { PartialString, MaybeArrayOfArray, MaybeArrayOfArrayItem, SelectModelValue, SelectModelValueEmits, SelectItemKey } from '../types/utils'
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const appConfigSelect = _appConfig as AppConfig & { ui: { select: Partial<typeof theme> } }
|
|
13
13
|
|
|
14
|
-
const select = tv({ extend: tv(theme), ...(
|
|
14
|
+
const select = tv({ extend: tv(theme), ...(appConfigSelect.ui?.select || {}) })
|
|
15
15
|
|
|
16
16
|
export interface SelectItem {
|
|
17
17
|
label?: string
|
|
@@ -29,7 +29,7 @@ export interface SelectItem {
|
|
|
29
29
|
|
|
30
30
|
type SelectVariants = VariantProps<typeof select>
|
|
31
31
|
|
|
32
|
-
export interface SelectProps<T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectItem | AcceptableValue> = MaybeArrayOfArray<SelectItem | AcceptableValue>, V extends SelectItemKey<T> | undefined = undefined> extends Omit<SelectRootProps
|
|
32
|
+
export interface SelectProps<T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectItem | AcceptableValue | boolean> = MaybeArrayOfArray<SelectItem | AcceptableValue | boolean>, V extends SelectItemKey<T> | undefined = undefined, M extends boolean = false> extends Omit<SelectRootProps<T>, 'dir' | 'multiple' | 'modelValue' | 'defaultValue' | 'by'>, UseComponentIconsProps {
|
|
33
33
|
id?: string
|
|
34
34
|
/** The placeholder text when the select is empty. */
|
|
35
35
|
placeholder?: string
|
|
@@ -48,7 +48,7 @@ export interface SelectProps<T extends MaybeArrayOfArrayItem<I>, I extends Maybe
|
|
|
48
48
|
selectedIcon?: string
|
|
49
49
|
/**
|
|
50
50
|
* The content of the menu.
|
|
51
|
-
* @defaultValue { side: 'bottom', sideOffset: 8, position: 'popper' }
|
|
51
|
+
* @defaultValue { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }
|
|
52
52
|
*/
|
|
53
53
|
content?: Omit<SelectContentProps, 'as' | 'asChild' | 'forceMount'>
|
|
54
54
|
/**
|
|
@@ -70,64 +70,69 @@ export interface SelectProps<T extends MaybeArrayOfArrayItem<I>, I extends Maybe
|
|
|
70
70
|
* When `items` is an array of objects, select the field to use as the label.
|
|
71
71
|
* @defaultValue 'label'
|
|
72
72
|
*/
|
|
73
|
-
labelKey?:
|
|
73
|
+
labelKey?: V
|
|
74
74
|
items?: I
|
|
75
|
+
/** The value of the Select when initially rendered. Use when you do not need to control the state of the Select. */
|
|
76
|
+
defaultValue?: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>
|
|
77
|
+
/** The controlled value of the Select. Can be bind as `v-model`. */
|
|
78
|
+
modelValue?: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>
|
|
79
|
+
/** Whether multiple options can be selected or not. */
|
|
80
|
+
multiple?: M & boolean
|
|
75
81
|
/** Highlight the ring color like a focus state. */
|
|
76
82
|
highlight?: boolean
|
|
77
83
|
class?: any
|
|
78
84
|
ui?: PartialString<typeof select.slots>
|
|
79
|
-
/** The controlled value of the Select. Can be bind as `v-model`. */
|
|
80
|
-
modelValue?: SelectModelValue<T, V, false, T extends { value: infer U } ? U : never>
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
export type SelectEmits<T, V> = Omit<SelectRootEmits
|
|
87
|
+
export type SelectEmits<T, V, M extends boolean> = Omit<SelectRootEmits<T>, 'update:modelValue'> & {
|
|
84
88
|
change: [payload: Event]
|
|
85
89
|
blur: [payload: FocusEvent]
|
|
86
90
|
focus: [payload: FocusEvent]
|
|
87
|
-
} & SelectModelValueEmits<T, V,
|
|
91
|
+
} & SelectModelValueEmits<T, V, M, T extends { value: infer U } ? U : never>
|
|
88
92
|
|
|
89
93
|
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
90
94
|
|
|
91
|
-
export interface SelectSlots<T> {
|
|
92
|
-
'leading'(props: { modelValue:
|
|
93
|
-
'
|
|
95
|
+
export interface SelectSlots<T, M extends boolean> {
|
|
96
|
+
'leading'(props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: any }): any
|
|
97
|
+
'default'(props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean }): any
|
|
98
|
+
'trailing'(props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: any }): any
|
|
94
99
|
'item': SlotProps<T>
|
|
95
100
|
'item-leading': SlotProps<T>
|
|
96
101
|
'item-label': SlotProps<T>
|
|
97
102
|
'item-trailing': SlotProps<T>
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
extendDevtoolsMeta({ defaultProps: { items: ['Option 1', 'Option 2', 'Option 3'] } })
|
|
101
104
|
</script>
|
|
102
105
|
|
|
103
|
-
<script setup lang="ts" generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectItem | AcceptableValue> = MaybeArrayOfArray<SelectItem | AcceptableValue>, V extends SelectItemKey<T> | undefined = undefined">
|
|
106
|
+
<script setup lang="ts" generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectItem | AcceptableValue | boolean> = MaybeArrayOfArray<SelectItem | AcceptableValue | boolean>, V extends SelectItemKey<T> | undefined = undefined, M extends boolean = false">
|
|
104
107
|
import { computed, toRef } from 'vue'
|
|
105
|
-
import { SelectRoot, SelectArrow, SelectTrigger,
|
|
108
|
+
import { SelectRoot, SelectArrow, SelectTrigger, SelectPortal, SelectContent, SelectViewport, SelectLabel, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectSeparator, useForwardPropsEmits } from 'reka-ui'
|
|
106
109
|
import { defu } from 'defu'
|
|
107
110
|
import { reactivePick } from '@vueuse/core'
|
|
108
111
|
import { useAppConfig } from '#imports'
|
|
109
112
|
import { useButtonGroup } from '../composables/useButtonGroup'
|
|
110
113
|
import { useComponentIcons } from '../composables/useComponentIcons'
|
|
111
114
|
import { useFormField } from '../composables/useFormField'
|
|
112
|
-
import { get } from '../utils'
|
|
115
|
+
import { get, compare } from '../utils'
|
|
113
116
|
import UIcon from './Icon.vue'
|
|
114
117
|
import UAvatar from './Avatar.vue'
|
|
115
118
|
import UChip from './Chip.vue'
|
|
116
119
|
|
|
117
|
-
|
|
120
|
+
defineOptions({ inheritAttrs: false })
|
|
121
|
+
|
|
122
|
+
const props = withDefaults(defineProps<SelectProps<T, I, V, M>>(), {
|
|
118
123
|
valueKey: 'value' as never,
|
|
119
124
|
labelKey: 'label' as never,
|
|
120
125
|
portal: true
|
|
121
126
|
})
|
|
122
|
-
const emits = defineEmits<SelectEmits<T, V>>()
|
|
123
|
-
const slots = defineSlots<SelectSlots<T>>()
|
|
127
|
+
const emits = defineEmits<SelectEmits<T, V, M>>()
|
|
128
|
+
const slots = defineSlots<SelectSlots<T, M>>()
|
|
124
129
|
|
|
125
130
|
const appConfig = useAppConfig()
|
|
126
|
-
const rootProps = useForwardPropsEmits(reactivePick(props, '
|
|
127
|
-
const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, position: 'popper' }) as SelectContentProps)
|
|
131
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen', 'disabled', 'autocomplete', 'required', 'multiple'), emits)
|
|
132
|
+
const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }) as SelectContentProps)
|
|
128
133
|
const arrowProps = toRef(() => props.arrow as SelectArrowProps)
|
|
129
134
|
|
|
130
|
-
const { emitFormChange, emitFormInput, emitFormBlur, size: formGroupSize, color, id, name, highlight, disabled } = useFormField<InputProps>(props)
|
|
135
|
+
const { emitFormChange, emitFormInput, emitFormBlur, emitFormFocus, size: formGroupSize, color, id, name, highlight, disabled, ariaAttrs } = useFormField<InputProps>(props)
|
|
131
136
|
const { orientation, size: buttonGroupSize } = useButtonGroup<InputProps>(props)
|
|
132
137
|
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(props, { trailingIcon: appConfig.ui.icons.chevronDown })))
|
|
133
138
|
|
|
@@ -145,6 +150,17 @@ const ui = computed(() => select({
|
|
|
145
150
|
}))
|
|
146
151
|
|
|
147
152
|
const groups = computed(() => props.items?.length ? (Array.isArray(props.items[0]) ? props.items : [props.items]) as SelectItem[][] : [])
|
|
153
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
154
|
+
const items = computed(() => groups.value.flatMap(group => group) as T[])
|
|
155
|
+
|
|
156
|
+
function displayValue(value?: AcceptableValue | AcceptableValue[]): string | undefined {
|
|
157
|
+
if (props.multiple && Array.isArray(value)) {
|
|
158
|
+
return value.map(v => displayValue(v)).filter(Boolean).join(', ')
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const item = items.value.find(item => compare(typeof item === 'object' ? get(item as Record<string, any>, props.valueKey as string) : item, value))
|
|
162
|
+
return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
|
|
163
|
+
}
|
|
148
164
|
|
|
149
165
|
function onUpdate(value: any) {
|
|
150
166
|
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
|
@@ -162,35 +178,45 @@ function onUpdateOpen(value: boolean) {
|
|
|
162
178
|
} else {
|
|
163
179
|
const event = new FocusEvent('focus')
|
|
164
180
|
emits('focus', event)
|
|
181
|
+
emitFormFocus()
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
184
|
</script>
|
|
168
185
|
|
|
186
|
+
<!-- eslint-disable vue/no-template-shadow -->
|
|
169
187
|
<template>
|
|
170
188
|
<SelectRoot
|
|
171
|
-
:id="id"
|
|
172
189
|
v-slot="{ modelValue, open }"
|
|
173
|
-
v-bind="rootProps"
|
|
174
190
|
:name="name"
|
|
175
|
-
|
|
176
|
-
:model-value="(modelValue as string)"
|
|
191
|
+
v-bind="rootProps"
|
|
177
192
|
:autocomplete="autocomplete"
|
|
178
193
|
:disabled="disabled"
|
|
194
|
+
:default-value="(defaultValue as (AcceptableValue | AcceptableValue[] | undefined))"
|
|
195
|
+
:model-value="(modelValue as (AcceptableValue | AcceptableValue[] | undefined))"
|
|
179
196
|
@update:model-value="onUpdate"
|
|
180
197
|
@update:open="onUpdateOpen"
|
|
181
198
|
>
|
|
182
|
-
<SelectTrigger :class="ui.base({ class: [props.class, props.ui?.base] })">
|
|
199
|
+
<SelectTrigger :id="id" :class="ui.base({ class: [props.class, props.ui?.base] })" v-bind="{ ...$attrs, ...ariaAttrs }">
|
|
183
200
|
<span v-if="isLeading || !!avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })">
|
|
184
|
-
<slot name="leading" :model-value="modelValue" :open="open" :ui="ui">
|
|
201
|
+
<slot name="leading" :model-value="(modelValue as M extends true ? AcceptableValue[] : AcceptableValue)" :open="open" :ui="ui">
|
|
185
202
|
<UIcon v-if="isLeading && leadingIconName" :name="leadingIconName" :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" />
|
|
186
203
|
<UAvatar v-else-if="!!avatar" :size="((props.ui?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="avatar" :class="ui.itemLeadingAvatar({ class: props.ui?.itemLeadingAvatar })" />
|
|
187
204
|
</slot>
|
|
188
205
|
</span>
|
|
189
206
|
|
|
190
|
-
<
|
|
207
|
+
<slot :model-value="(modelValue as M extends true ? AcceptableValue[] : AcceptableValue)" :open="open">
|
|
208
|
+
<template v-for="displayedModelValue in [displayValue(modelValue)]" :key="displayedModelValue">
|
|
209
|
+
<span v-if="displayedModelValue" :class="ui.value({ class: props.ui?.value })">
|
|
210
|
+
{{ displayedModelValue }}
|
|
211
|
+
</span>
|
|
212
|
+
<span v-else :class="ui.placeholder({ class: props.ui?.placeholder })">
|
|
213
|
+
{{ placeholder ?? ' ' }}
|
|
214
|
+
</span>
|
|
215
|
+
</template>
|
|
216
|
+
</slot>
|
|
191
217
|
|
|
192
218
|
<span v-if="isTrailing || !!slots.trailing" :class="ui.trailing({ class: props.ui?.trailing })">
|
|
193
|
-
<slot name="trailing" :model-value="modelValue" :open="open" :ui="ui">
|
|
219
|
+
<slot name="trailing" :model-value="(modelValue as M extends true ? AcceptableValue[] : AcceptableValue)" :open="open" :ui="ui">
|
|
194
220
|
<UIcon v-if="trailingIconName" :name="trailingIconName" :class="ui.trailingIcon({ class: props.ui?.trailingIcon })" />
|
|
195
221
|
</slot>
|
|
196
222
|
</span>
|