@nuxt/ui 3.0.2 → 3.1.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 +29 -29
- package/.nuxt/ui/avatar-group.ts +1 -1
- package/.nuxt/ui/avatar.ts +3 -3
- package/.nuxt/ui/badge.ts +33 -33
- package/.nuxt/ui/breadcrumb.ts +5 -5
- package/.nuxt/ui/button.ts +43 -43
- package/.nuxt/ui/calendar.ts +17 -17
- package/.nuxt/ui/card.ts +5 -5
- package/.nuxt/ui/carousel.ts +6 -6
- package/.nuxt/ui/checkbox-group.ts +61 -0
- package/.nuxt/ui/checkbox.ts +140 -27
- package/.nuxt/ui/chip.ts +8 -8
- package/.nuxt/ui/color-picker.ts +3 -3
- package/.nuxt/ui/command-palette.ts +14 -14
- package/.nuxt/ui/context-menu.ts +33 -33
- package/.nuxt/ui/drawer.ts +10 -10
- package/.nuxt/ui/dropdown-menu.ts +34 -34
- package/.nuxt/ui/form-field.ts +6 -6
- package/.nuxt/ui/index.ts +1 -0
- package/.nuxt/ui/input-menu.ts +42 -42
- package/.nuxt/ui/input-number.ts +20 -20
- package/.nuxt/ui/input.ts +23 -23
- package/.nuxt/ui/kbd.ts +4 -4
- package/.nuxt/ui/link.ts +3 -3
- package/.nuxt/ui/modal.ts +5 -5
- package/.nuxt/ui/navigation-menu.ts +78 -80
- package/.nuxt/ui/pin-input.ts +20 -20
- package/.nuxt/ui/popover.ts +2 -2
- package/.nuxt/ui/progress.ts +17 -17
- package/.nuxt/ui/radio-group.ts +250 -35
- package/.nuxt/ui/select-menu.ts +36 -33
- package/.nuxt/ui/select.ts +32 -32
- package/.nuxt/ui/separator.ts +8 -8
- package/.nuxt/ui/skeleton.ts +1 -1
- package/.nuxt/ui/slideover.ts +4 -4
- package/.nuxt/ui/slider.ts +16 -16
- package/.nuxt/ui/stepper.ts +18 -18
- package/.nuxt/ui/switch.ts +20 -20
- package/.nuxt/ui/table.ts +15 -15
- package/.nuxt/ui/tabs.ts +32 -32
- package/.nuxt/ui/textarea.ts +40 -35
- package/.nuxt/ui/toast.ts +24 -24
- package/.nuxt/ui/tooltip.ts +2 -2
- package/.nuxt/ui/tree.ts +18 -18
- package/.nuxt/ui.css +63 -12
- package/README.md +15 -0
- package/cli/templates.mjs +18 -17
- package/dist/module.json +5 -5
- package/dist/module.mjs +12 -7
- package/dist/runtime/components/Accordion.vue +36 -93
- package/dist/runtime/components/Accordion.vue.d.ts +75 -0
- package/dist/runtime/components/Alert.vue +37 -100
- package/dist/runtime/components/Alert.vue.d.ts +81 -0
- package/dist/runtime/components/App.vue +28 -34
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +42 -75
- package/dist/runtime/components/Avatar.vue.d.ts +39 -0
- package/dist/runtime/components/AvatarGroup.vue +40 -77
- package/dist/runtime/components/AvatarGroup.vue.d.ts +31 -0
- package/dist/runtime/components/Badge.vue +33 -62
- package/dist/runtime/components/Badge.vue.d.ts +41 -0
- package/dist/runtime/components/Breadcrumb.vue +37 -90
- package/dist/runtime/components/Breadcrumb.vue.d.ts +64 -0
- package/dist/runtime/components/Button.vue +95 -104
- package/dist/runtime/components/Button.vue.d.ts +48 -0
- package/dist/runtime/components/ButtonGroup.vue +20 -46
- package/dist/runtime/components/ButtonGroup.vue.d.ts +34 -0
- package/dist/runtime/components/Calendar.vue +67 -150
- package/dist/runtime/components/Calendar.vue.d.ts +111 -0
- package/dist/runtime/components/Card.vue +18 -40
- package/dist/runtime/components/Card.vue.d.ts +29 -0
- package/dist/runtime/components/Carousel.vue +112 -234
- package/dist/runtime/components/Carousel.vue.d.ts +122 -0
- package/dist/runtime/components/Checkbox.vue +52 -93
- package/dist/runtime/components/Checkbox.vue.d.ts +73 -0
- package/dist/runtime/components/CheckboxGroup.vue +121 -0
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +78 -0
- package/dist/runtime/components/Chip.vue +26 -69
- package/dist/runtime/components/Chip.vue.d.ts +57 -0
- package/dist/runtime/components/Collapsible.vue +22 -41
- package/dist/runtime/components/Collapsible.vue.d.ts +35 -0
- package/dist/runtime/components/ColorPicker.vue +111 -197
- package/dist/runtime/components/ColorPicker.vue.d.ts +48 -0
- package/dist/runtime/components/CommandPalette.vue +96 -237
- package/dist/runtime/components/CommandPalette.vue.d.ts +161 -0
- package/dist/runtime/components/Container.vue +15 -28
- package/dist/runtime/components/Container.vue.d.ts +18 -0
- package/dist/runtime/components/ContextMenu.vue +34 -133
- package/dist/runtime/components/ContextMenu.vue.d.ts +107 -0
- package/dist/runtime/components/ContextMenuContent.vue +73 -81
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +65 -0
- package/dist/runtime/components/Drawer.vue +49 -83
- package/dist/runtime/components/Drawer.vue.d.ts +78 -0
- package/dist/runtime/components/DropdownMenu.vue +39 -142
- package/dist/runtime/components/DropdownMenu.vue.d.ts +117 -0
- package/dist/runtime/components/DropdownMenuContent.vue +78 -88
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +68 -0
- package/dist/runtime/components/Form.vue +135 -220
- package/dist/runtime/components/Form.vue.d.ts +69 -0
- package/dist/runtime/components/FormField.vue +35 -77
- package/dist/runtime/components/FormField.vue.d.ts +61 -0
- package/dist/runtime/components/Icon.vue +12 -19
- package/dist/runtime/components/Icon.vue.d.ts +8 -0
- package/dist/runtime/components/Input.vue +82 -140
- package/dist/runtime/components/Input.vue.d.ts +76 -0
- package/dist/runtime/components/InputMenu.vue +185 -332
- package/dist/runtime/components/InputMenu.vue.d.ts +324 -0
- package/dist/runtime/components/InputNumber.vue +71 -133
- package/dist/runtime/components/InputNumber.vue.d.ts +182 -0
- package/dist/runtime/components/Kbd.vue +20 -46
- package/dist/runtime/components/Kbd.vue.d.ts +34 -0
- package/dist/runtime/components/Link.vue +98 -176
- package/dist/runtime/components/Link.vue.d.ts +93 -0
- package/dist/runtime/components/LinkBase.vue +33 -42
- package/dist/runtime/components/LinkBase.vue.d.ts +25 -0
- package/dist/runtime/components/Modal.vue +53 -116
- package/dist/runtime/components/Modal.vue.d.ts +93 -0
- package/dist/runtime/components/NavigationMenu.vue +77 -209
- package/dist/runtime/components/NavigationMenu.vue.d.ts +139 -0
- package/dist/runtime/components/OverlayProvider.vue +14 -18
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +46 -140
- package/dist/runtime/components/Pagination.vue.d.ts +119 -0
- package/dist/runtime/components/PinInput.vue +61 -78
- package/dist/runtime/components/PinInput.vue.d.ts +57 -0
- package/dist/runtime/components/Popover.vue +47 -84
- package/dist/runtime/components/Popover.vue.d.ts +63 -0
- package/dist/runtime/components/Progress.vue +70 -131
- package/dist/runtime/components/Progress.vue.d.ts +66 -0
- package/dist/runtime/components/RadioGroup.vue +70 -132
- package/dist/runtime/components/RadioGroup.vue.d.ts +91 -0
- package/dist/runtime/components/Select.vue +110 -224
- package/dist/runtime/components/Select.vue.d.ts +145 -0
- package/dist/runtime/components/SelectMenu.vue +161 -310
- package/dist/runtime/components/SelectMenu.vue.d.ts +196 -0
- package/dist/runtime/components/Separator.vue +29 -71
- package/dist/runtime/components/Separator.vue.d.ts +54 -0
- package/dist/runtime/components/Skeleton.vue +21 -23
- package/dist/runtime/components/Skeleton.vue.d.ts +17 -0
- package/dist/runtime/components/Slideover.vue +53 -120
- package/dist/runtime/components/Slideover.vue.d.ts +94 -0
- package/dist/runtime/components/Slider.vue +46 -84
- package/dist/runtime/components/Slider.vue.d.ts +52 -0
- package/dist/runtime/components/Stepper.vue +45 -115
- package/dist/runtime/components/Stepper.vue.d.ts +83 -0
- package/dist/runtime/components/Switch.vue +45 -93
- package/dist/runtime/components/Switch.vue.d.ts +70 -0
- package/dist/runtime/components/Table.vue +163 -267
- package/dist/runtime/components/Table.vue.d.ts +183 -0
- package/dist/runtime/components/Tabs.vue +41 -107
- package/dist/runtime/components/Tabs.vue.d.ts +88 -0
- package/dist/runtime/components/Textarea.vue +113 -158
- package/dist/runtime/components/Textarea.vue.d.ts +78 -0
- package/dist/runtime/components/Toast.vue +49 -110
- package/dist/runtime/components/Toast.vue.d.ts +157 -0
- package/dist/runtime/components/Toaster.vue +70 -107
- package/dist/runtime/components/Toaster.vue.d.ts +38 -0
- package/dist/runtime/components/Tooltip.vue +38 -65
- package/dist/runtime/components/Tooltip.vue.d.ts +50 -0
- package/dist/runtime/components/Tree.vue +59 -166
- package/dist/runtime/components/Tree.vue.d.ts +111 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +6 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormField.d.ts +2 -2
- package/dist/runtime/composables/useKbd.d.ts +1 -0
- package/dist/runtime/composables/useKbd.js +4 -3
- package/dist/runtime/composables/useOverlay.d.ts +14 -8
- package/dist/runtime/composables/useOverlay.js +20 -7
- package/dist/runtime/composables/usePortal.d.ts +6 -0
- package/dist/runtime/composables/usePortal.js +17 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/inertia/components/Link.vue +146 -0
- package/dist/runtime/inertia/components/Link.vue.d.ts +63 -0
- package/dist/runtime/inertia/stubs.d.ts +43 -0
- package/dist/runtime/inertia/stubs.js +82 -0
- package/dist/runtime/locale/bg.d.ts +3 -0
- package/dist/runtime/locale/bg.js +54 -0
- package/dist/runtime/locale/index.d.ts +5 -1
- package/dist/runtime/locale/index.js +5 -1
- package/dist/runtime/locale/kk.d.ts +3 -0
- package/dist/runtime/locale/kk.js +54 -0
- package/dist/runtime/locale/tj.d.ts +3 -0
- package/dist/runtime/locale/tj.js +54 -0
- package/dist/runtime/locale/ug_cn.d.ts +3 -0
- package/dist/runtime/locale/ug_cn.js +55 -0
- package/dist/runtime/types/form.d.ts +4 -1
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/tv.d.ts +53 -0
- package/dist/runtime/types/tv.js +0 -0
- package/dist/runtime/types/utils.d.ts +7 -17
- package/dist/runtime/types/utils.js +1 -0
- package/dist/runtime/utils/link.d.ts +3 -3
- package/dist/runtime/utils/link.js +1 -0
- package/dist/runtime/utils/tv.js +2 -2
- package/dist/runtime/vue/components/Icon.vue +7 -8
- package/dist/runtime/vue/components/Icon.vue.d.ts +5 -0
- package/dist/runtime/vue/components/Link.vue +118 -202
- package/dist/runtime/vue/components/Link.vue.d.ts +93 -0
- package/dist/runtime/vue/stubs.d.ts +2 -2
- package/dist/shared/{ui.BkNUP964.mjs → ui.CbtTMMzt.mjs} +631 -366
- package/dist/types.d.mts +3 -5
- package/dist/unplugin.d.mts +6 -2
- package/dist/unplugin.mjs +25 -4
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +96 -54
- package/dist/module.cjs +0 -62
- package/dist/module.d.cts +0 -45
- package/dist/module.d.ts +0 -45
- package/dist/shared/ui.BL-XB3u1.cjs +0 -3555
- package/dist/types.d.ts +0 -7
- package/dist/unplugin.cjs +0 -232
- package/dist/unplugin.d.cts +0 -62
- package/dist/unplugin.d.ts +0 -62
- package/dist/vite.cjs +0 -23
- package/dist/vite.d.cts +0 -15
- package/dist/vite.d.ts +0 -15
|
@@ -1,168 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { VariantProps } from 'tailwind-variants'
|
|
4
|
-
import type { TreeRootProps, TreeRootEmits } from 'reka-ui'
|
|
5
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
6
|
-
import _appConfig from '#build/app.config'
|
|
7
|
-
import theme from '#build/ui/tree'
|
|
8
|
-
import { tv } from '../utils/tv'
|
|
9
|
-
import type {
|
|
10
|
-
DynamicSlots,
|
|
11
|
-
GetItemKeys,
|
|
12
|
-
GetModelValue,
|
|
13
|
-
GetModelValueEmits,
|
|
14
|
-
NestedItem,
|
|
15
|
-
PartialString
|
|
16
|
-
} from '../types/utils'
|
|
17
|
-
|
|
18
|
-
const appConfig = _appConfig as AppConfig & { ui: { tree: Partial<typeof theme> } }
|
|
19
|
-
|
|
20
|
-
const tree = tv({ extend: tv(theme), ...(appConfig.ui?.tree || {}) })
|
|
21
|
-
|
|
22
|
-
type TreeVariants = VariantProps<typeof tree>
|
|
23
|
-
|
|
24
|
-
export type TreeItem = {
|
|
25
|
-
/**
|
|
26
|
-
* @IconifyIcon
|
|
27
|
-
*/
|
|
28
|
-
icon?: string
|
|
29
|
-
label?: string
|
|
30
|
-
/**
|
|
31
|
-
* @IconifyIcon
|
|
32
|
-
*/
|
|
33
|
-
trailingIcon?: string
|
|
34
|
-
defaultExpanded?: boolean
|
|
35
|
-
disabled?: boolean
|
|
36
|
-
value?: string
|
|
37
|
-
slot?: string
|
|
38
|
-
children?: TreeItem[]
|
|
39
|
-
onToggle?(e: Event): void
|
|
40
|
-
onSelect?(e?: Event): void
|
|
41
|
-
[key: string]: any
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface TreeProps<T extends TreeItem[] = TreeItem[], VK extends GetItemKeys<T> = 'value', M extends boolean = false> extends Pick<TreeRootProps<T>, 'expanded' | 'defaultExpanded' | 'selectionBehavior' | 'propagateSelect' | 'disabled'> {
|
|
45
|
-
/**
|
|
46
|
-
* The element or component this component should render as.
|
|
47
|
-
* @defaultValue 'ul'
|
|
48
|
-
*/
|
|
49
|
-
as?: any
|
|
50
|
-
/**
|
|
51
|
-
* @defaultValue 'primary'
|
|
52
|
-
*/
|
|
53
|
-
color?: TreeVariants['color']
|
|
54
|
-
/**
|
|
55
|
-
* @defaultValue 'md'
|
|
56
|
-
*/
|
|
57
|
-
size?: TreeVariants['size']
|
|
58
|
-
/**
|
|
59
|
-
* The key used to get the value from the item.
|
|
60
|
-
* @defaultValue 'value'
|
|
61
|
-
*/
|
|
62
|
-
valueKey?: VK
|
|
63
|
-
/**
|
|
64
|
-
* The key used to get the label from the item.
|
|
65
|
-
* @defaultValue 'label'
|
|
66
|
-
*/
|
|
67
|
-
labelKey?: keyof NestedItem<T>
|
|
68
|
-
/**
|
|
69
|
-
* The icon displayed on the right side of a parent node.
|
|
70
|
-
* @defaultValue appConfig.ui.icons.chevronDown
|
|
71
|
-
* @IconifyIcon
|
|
72
|
-
*/
|
|
73
|
-
trailingIcon?: string
|
|
74
|
-
/**
|
|
75
|
-
* The icon displayed when a parent node is expanded.
|
|
76
|
-
* @defaultValue appConfig.ui.icons.folderOpen
|
|
77
|
-
* @IconifyIcon
|
|
78
|
-
*/
|
|
79
|
-
expandedIcon?: string
|
|
80
|
-
/**
|
|
81
|
-
* The icon displayed when a parent node is collapsed.
|
|
82
|
-
* @defaultValue appConfig.ui.icons.folder
|
|
83
|
-
* @IconifyIcon
|
|
84
|
-
*/
|
|
85
|
-
collapsedIcon?: string
|
|
86
|
-
items?: T
|
|
87
|
-
/** The controlled value of the Tree. Can be bind as `v-model`. */
|
|
88
|
-
modelValue?: GetModelValue<T, VK, M>
|
|
89
|
-
/** The value of the Tree when initially rendered. Use when you do not need to control the state of the Tree. */
|
|
90
|
-
defaultValue?: GetModelValue<T, VK, M>
|
|
91
|
-
/** Whether multiple options can be selected or not. */
|
|
92
|
-
multiple?: M & boolean
|
|
93
|
-
class?: any
|
|
94
|
-
ui?: PartialString<typeof tree.slots>
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type TreeEmits<A extends TreeItem[], VK extends GetItemKeys<A> | undefined, M extends boolean> = Omit<TreeRootEmits, 'update:modelValue'> & GetModelValueEmits<A, VK, M>
|
|
98
|
-
|
|
99
|
-
type SlotProps<T extends TreeItem> = (props: { item: T, index: number, level: number, expanded: boolean, selected: boolean }) => any
|
|
100
|
-
|
|
101
|
-
export type TreeSlots<
|
|
102
|
-
A extends TreeItem[] = TreeItem[],
|
|
103
|
-
T extends NestedItem<A> = NestedItem<A>
|
|
104
|
-
> = {
|
|
105
|
-
'item': SlotProps<T>
|
|
106
|
-
'item-leading': SlotProps<T>
|
|
107
|
-
'item-label': SlotProps<T>
|
|
108
|
-
'item-trailing': SlotProps<T>
|
|
109
|
-
} & DynamicSlots<T, undefined, { index: number, level: number, expanded: boolean, selected: boolean }>
|
|
110
|
-
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/tree";
|
|
111
3
|
</script>
|
|
112
4
|
|
|
113
|
-
<script setup
|
|
114
|
-
import { computed } from
|
|
115
|
-
import
|
|
116
|
-
import {
|
|
117
|
-
import {
|
|
118
|
-
import { get } from
|
|
119
|
-
import
|
|
120
|
-
|
|
121
|
-
const props =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed } from "vue";
|
|
7
|
+
import { TreeRoot, TreeItem, useForwardPropsEmits } from "reka-ui";
|
|
8
|
+
import { reactivePick, createReusableTemplate } from "@vueuse/core";
|
|
9
|
+
import { useAppConfig } from "#imports";
|
|
10
|
+
import { get } from "../utils";
|
|
11
|
+
import { tv } from "../utils/tv";
|
|
12
|
+
import UIcon from "./Icon.vue";
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
as: { type: null, required: false },
|
|
15
|
+
color: { type: null, required: false },
|
|
16
|
+
size: { type: null, required: false },
|
|
17
|
+
valueKey: { type: null, required: false, default: "value" },
|
|
18
|
+
labelKey: { type: null, required: false, default: "label" },
|
|
19
|
+
trailingIcon: { type: String, required: false },
|
|
20
|
+
expandedIcon: { type: String, required: false },
|
|
21
|
+
collapsedIcon: { type: String, required: false },
|
|
22
|
+
items: { type: null, required: false },
|
|
23
|
+
modelValue: { type: null, required: false },
|
|
24
|
+
defaultValue: { type: null, required: false },
|
|
25
|
+
multiple: { type: Boolean, required: false },
|
|
26
|
+
class: { type: null, required: false },
|
|
27
|
+
ui: { type: null, required: false },
|
|
28
|
+
expanded: { type: Array, required: false },
|
|
29
|
+
defaultExpanded: { type: Array, required: false },
|
|
30
|
+
selectionBehavior: { type: String, required: false },
|
|
31
|
+
propagateSelect: { type: Boolean, required: false },
|
|
32
|
+
disabled: { type: Boolean, required: false }
|
|
33
|
+
});
|
|
34
|
+
const emits = defineEmits(["update:expanded", "update:modelValue"]);
|
|
35
|
+
const slots = defineSlots();
|
|
36
|
+
const appConfig = useAppConfig();
|
|
37
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "items", "multiple", "expanded", "disabled", "propagateSelect"), emits);
|
|
38
|
+
const [DefineTreeTemplate, ReuseTreeTemplate] = createReusableTemplate();
|
|
39
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.tree || {} })({
|
|
141
40
|
color: props.color,
|
|
142
41
|
size: props.size
|
|
143
|
-
}))
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return get(item, props.labelKey as string)
|
|
42
|
+
}));
|
|
43
|
+
function getItemLabel(item) {
|
|
44
|
+
return get(item, props.labelKey);
|
|
147
45
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return get(item, props.valueKey as string) ?? get(item, props.labelKey as string)
|
|
46
|
+
function getItemValue(item) {
|
|
47
|
+
return get(item, props.valueKey) ?? get(item, props.labelKey);
|
|
151
48
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return [currentItem, ...childItems].filter(Boolean) as string[]
|
|
49
|
+
function getDefaultOpenedItems(item) {
|
|
50
|
+
const currentItem = item.defaultExpanded ? getItemValue(item) : null;
|
|
51
|
+
const childItems = item.children?.flatMap((child) => getDefaultOpenedItems(child)) ?? [];
|
|
52
|
+
return [currentItem, ...childItems].filter(Boolean);
|
|
158
53
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
54
|
+
const defaultExpanded = computed(
|
|
55
|
+
() => props.defaultExpanded ?? props.items?.flatMap((item) => getDefaultOpenedItems(item))
|
|
56
|
+
);
|
|
163
57
|
</script>
|
|
164
58
|
|
|
165
|
-
<!-- eslint-disable vue/no-template-shadow -->
|
|
166
59
|
<template>
|
|
167
60
|
<DefineTreeTemplate v-slot="{ items, level }">
|
|
168
61
|
<li
|
|
@@ -179,8 +72,8 @@ const defaultExpanded = computed(() =>
|
|
|
179
72
|
@select="item.onSelect"
|
|
180
73
|
>
|
|
181
74
|
<button :disabled="item.disabled || disabled" :class="ui.link({ class: props.ui?.link, selected: isSelected, disabled: item.disabled || disabled })">
|
|
182
|
-
<slot :name="
|
|
183
|
-
<slot :name="
|
|
75
|
+
<slot :name="item.slot || 'item'" v-bind="{ index, level, expanded: isExpanded, selected: isSelected }" :item="item">
|
|
76
|
+
<slot :name="item.slot ? `${item.slot}-leading` : 'item-leading'" v-bind="{ index, level, expanded: isExpanded, selected: isSelected }" :item="item">
|
|
184
77
|
<UIcon
|
|
185
78
|
v-if="item.icon"
|
|
186
79
|
:name="item.icon"
|
|
@@ -188,19 +81,19 @@ const defaultExpanded = computed(() =>
|
|
|
188
81
|
/>
|
|
189
82
|
<UIcon
|
|
190
83
|
v-else-if="item.children?.length"
|
|
191
|
-
:name="isExpanded ?
|
|
84
|
+
:name="isExpanded ? expandedIcon ?? appConfig.ui.icons.folderOpen : collapsedIcon ?? appConfig.ui.icons.folder"
|
|
192
85
|
:class="ui.linkLeadingIcon({ class: props.ui?.linkLeadingIcon })"
|
|
193
86
|
/>
|
|
194
87
|
</slot>
|
|
195
88
|
|
|
196
|
-
<span v-if="getItemLabel(item) || !!slots[
|
|
197
|
-
<slot :name="
|
|
89
|
+
<span v-if="getItemLabel(item) || !!slots[item.slot ? `${item.slot}-label` : 'item-label']" :class="ui.linkLabel({ class: props.ui?.linkLabel })">
|
|
90
|
+
<slot :name="item.slot ? `${item.slot}-label` : 'item-label'" v-bind="{ item, index, level, expanded: isExpanded, selected: isSelected }" :item="item">
|
|
198
91
|
{{ getItemLabel(item) }}
|
|
199
92
|
</slot>
|
|
200
93
|
</span>
|
|
201
94
|
|
|
202
|
-
<span v-if="item.trailingIcon || item.children?.length || !!slots[
|
|
203
|
-
<slot :name="
|
|
95
|
+
<span v-if="item.trailingIcon || item.children?.length || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing']" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
|
|
96
|
+
<slot :name="item.slot ? `${item.slot}-trailing` : 'item-trailing'" v-bind="{ item, index, level, expanded: isExpanded, selected: isSelected }" :item="item">
|
|
204
97
|
<UIcon v-if="item.trailingIcon" :name="item.trailingIcon" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon })" />
|
|
205
98
|
<UIcon v-else-if="item.children?.length" :name="trailingIcon ?? appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon })" />
|
|
206
99
|
</slot>
|
|
@@ -209,19 +102,19 @@ const defaultExpanded = computed(() =>
|
|
|
209
102
|
</button>
|
|
210
103
|
|
|
211
104
|
<ul v-if="item.children?.length && isExpanded" :class="ui.listWithChildren({ class: props.ui?.listWithChildren })">
|
|
212
|
-
<ReuseTreeTemplate :items="
|
|
105
|
+
<ReuseTreeTemplate :items="item.children" :level="level + 1" />
|
|
213
106
|
</ul>
|
|
214
107
|
</TreeItem>
|
|
215
108
|
</li>
|
|
216
109
|
</DefineTreeTemplate>
|
|
217
110
|
|
|
218
111
|
<TreeRoot
|
|
219
|
-
v-bind="
|
|
112
|
+
v-bind="rootProps"
|
|
220
113
|
:class="ui.root({ class: [props.class, props.ui?.root] })"
|
|
221
114
|
:get-key="getItemValue"
|
|
222
115
|
:default-expanded="defaultExpanded"
|
|
223
116
|
:selection-behavior="selectionBehavior"
|
|
224
117
|
>
|
|
225
|
-
<ReuseTreeTemplate :items="
|
|
118
|
+
<ReuseTreeTemplate :items="items" :level="0" />
|
|
226
119
|
</TreeRoot>
|
|
227
120
|
</template>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { TreeRootProps, TreeRootEmits } from 'reka-ui';
|
|
2
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
3
|
+
import theme from '#build/ui/tree';
|
|
4
|
+
import type { DynamicSlots, GetItemKeys, GetModelValue, GetModelValueEmits, NestedItem, ComponentConfig } from '../types/utils';
|
|
5
|
+
type Tree = ComponentConfig<typeof theme, AppConfig, 'tree'>;
|
|
6
|
+
export type TreeItem = {
|
|
7
|
+
/**
|
|
8
|
+
* @IconifyIcon
|
|
9
|
+
*/
|
|
10
|
+
icon?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @IconifyIcon
|
|
14
|
+
*/
|
|
15
|
+
trailingIcon?: string;
|
|
16
|
+
defaultExpanded?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
value?: string;
|
|
19
|
+
slot?: string;
|
|
20
|
+
children?: TreeItem[];
|
|
21
|
+
onToggle?(e: Event): void;
|
|
22
|
+
onSelect?(e?: Event): void;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
export interface TreeProps<T extends TreeItem[] = TreeItem[], VK extends GetItemKeys<T> = 'value', M extends boolean = false> extends Pick<TreeRootProps<T>, 'expanded' | 'defaultExpanded' | 'selectionBehavior' | 'propagateSelect' | 'disabled'> {
|
|
26
|
+
/**
|
|
27
|
+
* The element or component this component should render as.
|
|
28
|
+
* @defaultValue 'ul'
|
|
29
|
+
*/
|
|
30
|
+
as?: any;
|
|
31
|
+
/**
|
|
32
|
+
* @defaultValue 'primary'
|
|
33
|
+
*/
|
|
34
|
+
color?: Tree['variants']['color'];
|
|
35
|
+
/**
|
|
36
|
+
* @defaultValue 'md'
|
|
37
|
+
*/
|
|
38
|
+
size?: Tree['variants']['size'];
|
|
39
|
+
/**
|
|
40
|
+
* The key used to get the value from the item.
|
|
41
|
+
* @defaultValue 'value'
|
|
42
|
+
*/
|
|
43
|
+
valueKey?: VK;
|
|
44
|
+
/**
|
|
45
|
+
* The key used to get the label from the item.
|
|
46
|
+
* @defaultValue 'label'
|
|
47
|
+
*/
|
|
48
|
+
labelKey?: keyof NestedItem<T>;
|
|
49
|
+
/**
|
|
50
|
+
* The icon displayed on the right side of a parent node.
|
|
51
|
+
* @defaultValue appConfig.ui.icons.chevronDown
|
|
52
|
+
* @IconifyIcon
|
|
53
|
+
*/
|
|
54
|
+
trailingIcon?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The icon displayed when a parent node is expanded.
|
|
57
|
+
* @defaultValue appConfig.ui.icons.folderOpen
|
|
58
|
+
* @IconifyIcon
|
|
59
|
+
*/
|
|
60
|
+
expandedIcon?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The icon displayed when a parent node is collapsed.
|
|
63
|
+
* @defaultValue appConfig.ui.icons.folder
|
|
64
|
+
* @IconifyIcon
|
|
65
|
+
*/
|
|
66
|
+
collapsedIcon?: string;
|
|
67
|
+
items?: T;
|
|
68
|
+
/** The controlled value of the Tree. Can be bind as `v-model`. */
|
|
69
|
+
modelValue?: GetModelValue<T, VK, M>;
|
|
70
|
+
/** The value of the Tree when initially rendered. Use when you do not need to control the state of the Tree. */
|
|
71
|
+
defaultValue?: GetModelValue<T, VK, M>;
|
|
72
|
+
/** Whether multiple options can be selected or not. */
|
|
73
|
+
multiple?: M & boolean;
|
|
74
|
+
class?: any;
|
|
75
|
+
ui?: Tree['slots'];
|
|
76
|
+
}
|
|
77
|
+
export type TreeEmits<A extends TreeItem[], VK extends GetItemKeys<A> | undefined, M extends boolean> = Omit<TreeRootEmits, 'update:modelValue'> & GetModelValueEmits<A, VK, M>;
|
|
78
|
+
type SlotProps<T extends TreeItem> = (props: {
|
|
79
|
+
item: T;
|
|
80
|
+
index: number;
|
|
81
|
+
level: number;
|
|
82
|
+
expanded: boolean;
|
|
83
|
+
selected: boolean;
|
|
84
|
+
}) => any;
|
|
85
|
+
export type TreeSlots<A extends TreeItem[] = TreeItem[], T extends NestedItem<A> = NestedItem<A>> = {
|
|
86
|
+
'item': SlotProps<T>;
|
|
87
|
+
'item-leading': SlotProps<T>;
|
|
88
|
+
'item-label': SlotProps<T>;
|
|
89
|
+
'item-trailing': SlotProps<T>;
|
|
90
|
+
} & DynamicSlots<T, undefined, {
|
|
91
|
+
index: number;
|
|
92
|
+
level: number;
|
|
93
|
+
expanded: boolean;
|
|
94
|
+
selected: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
declare const _default: <T extends TreeItem[], VK extends GetItemKeys<T> = "value", M extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
97
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
98
|
+
readonly "onUpdate:modelValue"?: ((payload: GetModelValue<T, VK, M>) => any) | undefined;
|
|
99
|
+
readonly "onUpdate:expanded"?: ((val: string[]) => any) | undefined;
|
|
100
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:modelValue" | "onUpdate:expanded"> & TreeProps<T, VK, M> & Partial<{}>> & import("vue").PublicProps;
|
|
101
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
102
|
+
attrs: any;
|
|
103
|
+
slots: TreeSlots<T, NestedItem<T>>;
|
|
104
|
+
emit: ((evt: "update:modelValue", payload: GetModelValue<T, VK, M>) => void) & ((evt: "update:expanded", val: string[]) => void);
|
|
105
|
+
}>) => import("vue").VNode & {
|
|
106
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
107
|
+
};
|
|
108
|
+
export default _default;
|
|
109
|
+
type __VLS_PrettifyLocal<T> = {
|
|
110
|
+
[K in keyof T]: T[K];
|
|
111
|
+
} & {};
|
|
@@ -11,5 +11,5 @@ export interface ShortcutsOptions {
|
|
|
11
11
|
chainDelay?: number;
|
|
12
12
|
}
|
|
13
13
|
export declare function extractShortcuts(items: any[] | any[][]): Record<string, Handler>;
|
|
14
|
-
export declare function defineShortcuts(config: MaybeRef<ShortcutsConfig>, options?: ShortcutsOptions): import("@vueuse/
|
|
14
|
+
export declare function defineShortcuts(config: MaybeRef<ShortcutsConfig>, options?: ShortcutsOptions): import("@vueuse/shared").Fn;
|
|
15
15
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, computed, toValue } from "vue";
|
|
2
2
|
import { useEventListener, useActiveElement, useDebounceFn } from "@vueuse/core";
|
|
3
|
+
import { useKbd } from "./useKbd.js";
|
|
3
4
|
const chainedShortcutRegex = /^[^-]+.*-.*[^-]+$/;
|
|
4
5
|
const combinedShortcutRegex = /^[^_]+.*_.*[^_]+$/;
|
|
5
6
|
export function extractShortcuts(items) {
|
|
@@ -27,6 +28,7 @@ export function defineShortcuts(config, options = {}) {
|
|
|
27
28
|
chainedInputs.value.splice(0, chainedInputs.value.length);
|
|
28
29
|
};
|
|
29
30
|
const debouncedClearChainedInput = useDebounceFn(clearChainedInput, options.chainDelay ?? 800);
|
|
31
|
+
const { macOS } = useKbd();
|
|
30
32
|
const activeElement = useActiveElement();
|
|
31
33
|
const onKeyDown = (e) => {
|
|
32
34
|
if (!e.key) {
|
|
@@ -112,6 +114,10 @@ export function defineShortcuts(config, options = {}) {
|
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
116
|
shortcut.chained = chained;
|
|
117
|
+
if (!macOS.value && shortcut.metaKey && !shortcut.ctrlKey) {
|
|
118
|
+
shortcut.metaKey = false;
|
|
119
|
+
shortcut.ctrlKey = true;
|
|
120
|
+
}
|
|
115
121
|
if (typeof shortcutConfig === "function") {
|
|
116
122
|
shortcut.handler = shortcutConfig;
|
|
117
123
|
} else if (typeof shortcutConfig === "object") {
|
|
@@ -6,5 +6,5 @@ export declare const avatarGroupInjectionKey: InjectionKey<ComputedRef<{
|
|
|
6
6
|
export declare function useAvatarGroup(props: {
|
|
7
7
|
size: AvatarGroupProps['size'];
|
|
8
8
|
}): {
|
|
9
|
-
size: ComputedRef<
|
|
9
|
+
size: ComputedRef<"3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | undefined>;
|
|
10
10
|
};
|
|
@@ -9,7 +9,7 @@ type Props<T> = {
|
|
|
9
9
|
size?: GetObjectField<T, 'size'>;
|
|
10
10
|
};
|
|
11
11
|
export declare function useButtonGroup<T>(props: Props<T>): {
|
|
12
|
-
orientation: ComputedRef<
|
|
13
|
-
size: ComputedRef<
|
|
12
|
+
orientation: ComputedRef<"horizontal" | "vertical" | undefined>;
|
|
13
|
+
size: ComputedRef<"xs" | "sm" | "md" | "lg" | "xl" | NonNullable<GetObjectField<T, "size">> | undefined>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -26,12 +26,12 @@ export declare function useFormField<T>(props?: Props<T>, opts?: {
|
|
|
26
26
|
}): {
|
|
27
27
|
id: ComputedRef<string | undefined>;
|
|
28
28
|
name: ComputedRef<string | undefined>;
|
|
29
|
-
size: ComputedRef<
|
|
29
|
+
size: ComputedRef<"xs" | "sm" | "md" | "lg" | "xl" | NonNullable<GetObjectField<T, "size">> | undefined>;
|
|
30
30
|
color: ComputedRef<"error" | GetObjectField<T, "color"> | undefined>;
|
|
31
31
|
highlight: ComputedRef<boolean | undefined>;
|
|
32
32
|
disabled: ComputedRef<boolean | undefined>;
|
|
33
33
|
emitFormBlur: () => void;
|
|
34
|
-
emitFormInput: import("@vueuse/
|
|
34
|
+
emitFormInput: import("@vueuse/shared").UseDebounceFnReturn<() => void>;
|
|
35
35
|
emitFormChange: () => void;
|
|
36
36
|
emitFormFocus: () => void;
|
|
37
37
|
ariaAttrs: ComputedRef<{
|
|
@@ -7,6 +7,7 @@ export const kbdKeysMap = {
|
|
|
7
7
|
win: "\u229E",
|
|
8
8
|
command: "\u2318",
|
|
9
9
|
shift: "\u21E7",
|
|
10
|
+
control: "\u2303",
|
|
10
11
|
option: "\u2325",
|
|
11
12
|
enter: "\u21B5",
|
|
12
13
|
delete: "\u2326",
|
|
@@ -31,9 +32,9 @@ const _useKbd = () => {
|
|
|
31
32
|
ctrl: " "
|
|
32
33
|
});
|
|
33
34
|
onMounted(() => {
|
|
34
|
-
kbdKeysSpecificMap.meta = macOS.value ? kbdKeysMap.command :
|
|
35
|
-
kbdKeysSpecificMap.
|
|
36
|
-
kbdKeysSpecificMap.
|
|
35
|
+
kbdKeysSpecificMap.meta = macOS.value ? kbdKeysMap.command : "Ctrl";
|
|
36
|
+
kbdKeysSpecificMap.ctrl = macOS.value ? kbdKeysMap.control : "Ctrl";
|
|
37
|
+
kbdKeysSpecificMap.alt = macOS.value ? kbdKeysMap.option : "Alt";
|
|
37
38
|
});
|
|
38
39
|
function getKbdKey(value) {
|
|
39
40
|
if (!value) {
|
|
@@ -6,26 +6,32 @@ export type OverlayOptions<OverlayAttrs = Record<string, any>> = {
|
|
|
6
6
|
props?: OverlayAttrs;
|
|
7
7
|
destroyOnClose?: boolean;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
interface ManagedOverlayOptionsPrivate<T extends Component> {
|
|
10
10
|
component?: T;
|
|
11
11
|
id: symbol;
|
|
12
12
|
isMounted: boolean;
|
|
13
|
-
|
|
14
|
-
resolvePromise?: (value:
|
|
15
|
-
}
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
resolvePromise?: (value: any) => void;
|
|
15
|
+
}
|
|
16
16
|
export type Overlay = OverlayOptions<Component> & ManagedOverlayOptionsPrivate<Component>;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
type OverlayInstance<T extends Component> = Omit<ManagedOverlayOptionsPrivate<T>, 'component'> & {
|
|
18
|
+
id: symbol;
|
|
19
|
+
open: (props?: ComponentProps<T>) => OpenedOverlay<T>;
|
|
19
20
|
close: (value?: any) => void;
|
|
20
21
|
patch: (props: Partial<ComponentProps<T>>) => void;
|
|
21
|
-
}
|
|
22
|
+
};
|
|
23
|
+
type OpenedOverlay<T extends Component> = Omit<OverlayInstance<T>, 'open' | 'close' | 'patch' | 'modelValue' | 'resolvePromise'> & {
|
|
24
|
+
result: Promise<CloseEventArgType<ComponentEmit<T>>>;
|
|
25
|
+
};
|
|
22
26
|
declare function _useOverlay(): {
|
|
23
27
|
overlays: import("vue").ShallowReactive<Overlay[]>;
|
|
24
|
-
open: <T extends Component>(id: symbol, props?: ComponentProps<T>) =>
|
|
28
|
+
open: <T extends Component>(id: symbol, props?: ComponentProps<T>) => OpenedOverlay<T>;
|
|
25
29
|
close: (id: symbol, value?: any) => void;
|
|
30
|
+
closeAll: () => void;
|
|
26
31
|
create: <T extends Component>(component: T, _options?: OverlayOptions<ComponentProps<T>>) => OverlayInstance<T>;
|
|
27
32
|
patch: <T extends Component>(id: symbol, props: Partial<ComponentProps<T>>) => void;
|
|
28
33
|
unMount: (id: symbol) => void;
|
|
34
|
+
isOpen: (id: symbol) => boolean;
|
|
29
35
|
};
|
|
30
36
|
export declare const useOverlay: typeof _useOverlay;
|
|
31
37
|
export {};
|
|
@@ -6,7 +6,7 @@ function _useOverlay() {
|
|
|
6
6
|
const { props, defaultOpen, destroyOnClose } = _options || {};
|
|
7
7
|
const options = reactive({
|
|
8
8
|
id: Symbol(import.meta.dev ? "useOverlay" : ""),
|
|
9
|
-
|
|
9
|
+
isOpen: !!defaultOpen,
|
|
10
10
|
component: markRaw(component),
|
|
11
11
|
isMounted: !!defaultOpen,
|
|
12
12
|
destroyOnClose: !!destroyOnClose,
|
|
@@ -14,6 +14,7 @@ function _useOverlay() {
|
|
|
14
14
|
});
|
|
15
15
|
overlays.push(options);
|
|
16
16
|
return {
|
|
17
|
+
...options,
|
|
17
18
|
open: (props2) => open(options.id, props2),
|
|
18
19
|
close: (value) => close(options.id, value),
|
|
19
20
|
patch: (props2) => patch(options.id, props2)
|
|
@@ -24,20 +25,26 @@ function _useOverlay() {
|
|
|
24
25
|
if (props) {
|
|
25
26
|
patch(overlay.id, props);
|
|
26
27
|
}
|
|
27
|
-
overlay.
|
|
28
|
+
overlay.isOpen = true;
|
|
28
29
|
overlay.isMounted = true;
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
isMounted: overlay.isMounted,
|
|
33
|
+
isOpen: overlay.isOpen,
|
|
34
|
+
result: new Promise((resolve) => overlay.resolvePromise = resolve)
|
|
35
|
+
};
|
|
32
36
|
};
|
|
33
37
|
const close = (id, value) => {
|
|
34
38
|
const overlay = getOverlay(id);
|
|
35
|
-
overlay.
|
|
39
|
+
overlay.isOpen = false;
|
|
36
40
|
if (overlay.resolvePromise) {
|
|
37
41
|
overlay.resolvePromise(value);
|
|
38
42
|
overlay.resolvePromise = void 0;
|
|
39
43
|
}
|
|
40
44
|
};
|
|
45
|
+
const closeAll = () => {
|
|
46
|
+
overlays.forEach((overlay) => close(overlay.id));
|
|
47
|
+
};
|
|
41
48
|
const unMount = (id) => {
|
|
42
49
|
const overlay = getOverlay(id);
|
|
43
50
|
overlay.isMounted = false;
|
|
@@ -59,13 +66,19 @@ function _useOverlay() {
|
|
|
59
66
|
}
|
|
60
67
|
return overlay;
|
|
61
68
|
};
|
|
69
|
+
const isOpen = (id) => {
|
|
70
|
+
const overlay = getOverlay(id);
|
|
71
|
+
return overlay.isOpen;
|
|
72
|
+
};
|
|
62
73
|
return {
|
|
63
74
|
overlays,
|
|
64
75
|
open,
|
|
65
76
|
close,
|
|
77
|
+
closeAll,
|
|
66
78
|
create,
|
|
67
79
|
patch,
|
|
68
|
-
unMount
|
|
80
|
+
unMount,
|
|
81
|
+
isOpen
|
|
69
82
|
};
|
|
70
83
|
}
|
|
71
84
|
export const useOverlay = /* @__PURE__ */ createSharedComposable(_useOverlay);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Ref, type InjectionKey } from 'vue';
|
|
2
|
+
export declare const portalTargetInjectionKey: InjectionKey<Ref<string | HTMLElement>>;
|
|
3
|
+
export declare function usePortal(portal: Ref<string | HTMLElement | boolean | undefined>): import("vue").ComputedRef<{
|
|
4
|
+
to: string | HTMLElement;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { inject, provide, computed } from "vue";
|
|
2
|
+
export const portalTargetInjectionKey = Symbol("nuxt-ui.portal-target");
|
|
3
|
+
export function usePortal(portal) {
|
|
4
|
+
const portalTarget = inject(portalTargetInjectionKey, void 0);
|
|
5
|
+
const to = computed(() => {
|
|
6
|
+
if (typeof portal.value === "boolean" || portal.value === void 0) {
|
|
7
|
+
return portalTarget?.value ?? "body";
|
|
8
|
+
}
|
|
9
|
+
return portal.value;
|
|
10
|
+
});
|
|
11
|
+
const disabled = computed(() => typeof portal.value === "boolean" ? !portal.value : false);
|
|
12
|
+
provide(portalTargetInjectionKey, computed(() => to.value));
|
|
13
|
+
return computed(() => ({
|
|
14
|
+
to: to.value,
|
|
15
|
+
disabled: disabled.value
|
|
16
|
+
}));
|
|
17
|
+
}
|
package/dist/runtime/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "#build/ui.css";@import "./keyframes.css";@variant light (&:where(.light, .light *));@variant dark (&:where(.dark, .dark *));@layer base{body{@apply antialiased text-
|
|
1
|
+
@import "#build/ui.css";@import "./keyframes.css";@variant light (&:where(.light, .light *));@variant dark (&:where(.dark, .dark *));@layer base{body{@apply antialiased text-default bg-default scheme-light dark:scheme-dark}.light,:root{--ui-text-dimmed:var(--ui-color-neutral-400);--ui-text-muted:var(--ui-color-neutral-500);--ui-text-toned:var(--ui-color-neutral-600);--ui-text:var(--ui-color-neutral-700);--ui-text-highlighted:var(--ui-color-neutral-900);--ui-text-inverted:var(--color-white);--ui-bg:var(--color-white);--ui-bg-muted:var(--ui-color-neutral-50);--ui-bg-elevated:var(--ui-color-neutral-100);--ui-bg-accented:var(--ui-color-neutral-200);--ui-bg-inverted:var(--ui-color-neutral-900);--ui-border:var(--ui-color-neutral-200);--ui-border-muted:var(--ui-color-neutral-200);--ui-border-accented:var(--ui-color-neutral-300);--ui-border-inverted:var(--ui-color-neutral-900);--ui-radius:0.25rem;--ui-container:var(--container-7xl)}.dark{--ui-text-dimmed:var(--ui-color-neutral-500);--ui-text-muted:var(--ui-color-neutral-400);--ui-text-toned:var(--ui-color-neutral-300);--ui-text:var(--ui-color-neutral-200);--ui-text-highlighted:var(--color-white);--ui-text-inverted:var(--ui-color-neutral-900);--ui-bg:var(--ui-color-neutral-900);--ui-bg-muted:var(--ui-color-neutral-800);--ui-bg-elevated:var(--ui-color-neutral-800);--ui-bg-accented:var(--ui-color-neutral-700);--ui-bg-inverted:var(--color-white);--ui-border:var(--ui-color-neutral-800);--ui-border-muted:var(--ui-color-neutral-700);--ui-border-accented:var(--ui-color-neutral-700);--ui-border-inverted:var(--color-white)}}
|