@una-ui/nuxt 0.51.6 → 0.52.0
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/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/combobox/Combobox.vue +316 -0
- package/dist/runtime/components/combobox/ComboboxAnchor.vue +30 -0
- package/dist/runtime/components/combobox/ComboboxEmpty.vue +28 -0
- package/dist/runtime/components/combobox/ComboboxGroup.vue +39 -0
- package/dist/runtime/components/combobox/ComboboxInput.vue +49 -0
- package/dist/runtime/components/combobox/ComboboxItem.vue +32 -0
- package/dist/runtime/components/combobox/ComboboxItemIndicator.vue +40 -0
- package/dist/runtime/components/combobox/ComboboxLabel.vue +21 -0
- package/dist/runtime/components/combobox/ComboboxList.vue +40 -0
- package/dist/runtime/components/combobox/ComboboxSeparator.vue +28 -0
- package/dist/runtime/components/combobox/ComboboxTrigger.vue +87 -0
- package/dist/runtime/components/combobox/ComboboxViewport.vue +30 -0
- package/dist/runtime/components/elements/Link.vue.d.ts +1 -4
- package/dist/runtime/components/elements/dialog/DialogContent.vue +1 -0
- package/dist/runtime/components/forms/Checkbox.vue +5 -1
- package/dist/runtime/components/forms/Input.vue +2 -1
- package/dist/runtime/components/forms/select/Select.vue +18 -5
- package/dist/runtime/components/forms/select/SelectItem.vue +1 -1
- package/dist/runtime/components/forms/select/SelectTrigger.vue +6 -3
- package/dist/runtime/components/misc/ThemeSwitcher.vue +6 -4
- package/dist/runtime/components/slots/FormFieldDefault.d.ts +3 -2
- package/dist/runtime/components/slots/FormFieldDefault.js +1 -9
- package/dist/runtime/types/combobox.d.ts +153 -0
- package/dist/runtime/types/combobox.js +0 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/input.d.ts +3 -0
- package/dist/runtime/types/select.d.ts +4 -3
- package/dist/runtime/utils/injectionKeys.d.ts +1 -0
- package/dist/runtime/utils/injectionKeys.js +1 -0
- package/package.json +10 -10
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AcceptableValue, ComboboxRootEmits } from 'reka-ui'
|
|
3
|
+
import type { ExtractItemType, NComboboxGroupProps, NComboboxProps } from '../../types'
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core'
|
|
5
|
+
import { ComboboxRoot, useForwardPropsEmits } from 'reka-ui'
|
|
6
|
+
import { cn } from '../../utils'
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts" generic="T extends AcceptableValue">
|
|
10
|
+
import { computed } from 'vue'
|
|
11
|
+
import ComboboxAnchor from './ComboboxAnchor.vue'
|
|
12
|
+
import ComboboxEmpty from './ComboboxEmpty.vue'
|
|
13
|
+
import ComboboxGroup from './ComboboxGroup.vue'
|
|
14
|
+
import ComboboxInput from './ComboboxInput.vue'
|
|
15
|
+
import ComboboxItem from './ComboboxItem.vue'
|
|
16
|
+
import ComboboxItemIndicator from './ComboboxItemIndicator.vue'
|
|
17
|
+
import ComboboxList from './ComboboxList.vue'
|
|
18
|
+
import ComboboxSeparator from './ComboboxSeparator.vue'
|
|
19
|
+
import ComboboxTrigger from './ComboboxTrigger.vue'
|
|
20
|
+
import ComboboxViewport from './ComboboxViewport.vue'
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(defineProps<NComboboxProps<T>>(), {
|
|
23
|
+
textEmpty: 'No items found.',
|
|
24
|
+
size: 'md',
|
|
25
|
+
})
|
|
26
|
+
const emits = defineEmits<ComboboxRootEmits<ExtractItemType<T>>>()
|
|
27
|
+
|
|
28
|
+
const rootProps = reactiveOmit(props, [
|
|
29
|
+
'items',
|
|
30
|
+
'una',
|
|
31
|
+
'size',
|
|
32
|
+
'label',
|
|
33
|
+
'labelKey',
|
|
34
|
+
'valueKey',
|
|
35
|
+
'groupSeparator',
|
|
36
|
+
'textEmpty',
|
|
37
|
+
'_comboboxAnchor',
|
|
38
|
+
'_comboboxEmpty',
|
|
39
|
+
'_comboboxGroup',
|
|
40
|
+
'_comboboxInput',
|
|
41
|
+
'_comboboxItem',
|
|
42
|
+
'_comboboxItemIndicator',
|
|
43
|
+
'_comboboxLabel',
|
|
44
|
+
'_comboboxList',
|
|
45
|
+
'_comboboxSeparator',
|
|
46
|
+
'_comboboxTrigger',
|
|
47
|
+
'_comboboxViewport',
|
|
48
|
+
'_comboboxCheckbox',
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
const forwarded = useForwardPropsEmits(rootProps, emits)
|
|
52
|
+
|
|
53
|
+
const labelKey = computed(() => props.labelKey?.toString() ?? 'label')
|
|
54
|
+
const valueKey = computed(() => props.valueKey?.toString() ?? 'value')
|
|
55
|
+
|
|
56
|
+
// Check if items are grouped
|
|
57
|
+
const hasGroups = computed(() => {
|
|
58
|
+
return Array.isArray(props.items) && props.items.length > 0
|
|
59
|
+
&& typeof props.items[0] === 'object' && 'items' in (props.items[0] as any)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// Helper function to safely get a property from an item
|
|
63
|
+
function getItemProperty<K extends string>(item: ExtractItemType<T> | null | undefined, key: K): any {
|
|
64
|
+
if (item == null)
|
|
65
|
+
return ''
|
|
66
|
+
|
|
67
|
+
return typeof item !== 'object' ? item : (item as Record<K, unknown>)[key]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Find a matching item from the items list by its value
|
|
71
|
+
function findItemByValue(value: unknown): ExtractItemType<T> | undefined {
|
|
72
|
+
if (!props.items)
|
|
73
|
+
return undefined
|
|
74
|
+
|
|
75
|
+
if (hasGroups.value) {
|
|
76
|
+
// Search in grouped items
|
|
77
|
+
for (const group of props.items as NComboboxGroupProps<ExtractItemType<T>>[]) {
|
|
78
|
+
const found = group.items?.find(item => getItemProperty(item, valueKey.value) === value)
|
|
79
|
+
if (found)
|
|
80
|
+
return found
|
|
81
|
+
}
|
|
82
|
+
return undefined
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// Search in flat items list
|
|
86
|
+
return (props.items as ExtractItemType<T>[]).find(item => getItemProperty(item, valueKey.value) === value)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Display function that handles both single and multiple selections
|
|
91
|
+
function getDisplayValue(val: unknown): string {
|
|
92
|
+
// Handle empty values
|
|
93
|
+
if (!val || (Array.isArray(val) && val.length === 0))
|
|
94
|
+
return ''
|
|
95
|
+
|
|
96
|
+
// Handle multiple selection (array values)
|
|
97
|
+
if (props.multiple && Array.isArray(val)) {
|
|
98
|
+
return val.map((v) => {
|
|
99
|
+
// For primitive values (string/number), find matching item to get label
|
|
100
|
+
if (typeof v !== 'object' || v === null) {
|
|
101
|
+
const item = findItemByValue(v)
|
|
102
|
+
return item ? getItemProperty(item, labelKey.value) : v
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// For objects, try to get the label directly
|
|
106
|
+
return getItemProperty(v, labelKey.value) || getItemProperty(v, valueKey.value) || ''
|
|
107
|
+
}).filter(Boolean).join(', ')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// For single primitive value
|
|
111
|
+
if (typeof val !== 'object' || val === null) {
|
|
112
|
+
const item = findItemByValue(val)
|
|
113
|
+
return item ? getItemProperty(item, labelKey.value) : String(val || '')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// For single object, get its label
|
|
117
|
+
return getItemProperty(val as any, labelKey.value) || getItemProperty(val as any, valueKey.value) || ''
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Check if an item is selected in the current modelValue
|
|
121
|
+
function isItemSelected(item: ExtractItemType<T> | null | undefined): boolean {
|
|
122
|
+
if (item == null)
|
|
123
|
+
return false
|
|
124
|
+
|
|
125
|
+
const itemValue = getItemProperty(item, valueKey.value)
|
|
126
|
+
|
|
127
|
+
// For multiple selection
|
|
128
|
+
if (props.multiple && Array.isArray(props.modelValue)) {
|
|
129
|
+
return props.modelValue.includes(itemValue)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// For single selection
|
|
133
|
+
return typeof props.modelValue === 'object' && props.modelValue !== null
|
|
134
|
+
? getItemProperty(props.modelValue as ExtractItemType<T>, valueKey.value) === itemValue
|
|
135
|
+
: props.modelValue === itemValue
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
138
|
+
|
|
139
|
+
<template>
|
|
140
|
+
<ComboboxRoot
|
|
141
|
+
v-slot="{ modelValue, open }"
|
|
142
|
+
data-slot="combobox"
|
|
143
|
+
:class="cn(
|
|
144
|
+
'combobox',
|
|
145
|
+
props.una?.combobox,
|
|
146
|
+
props.class,
|
|
147
|
+
)"
|
|
148
|
+
v-bind="forwarded"
|
|
149
|
+
>
|
|
150
|
+
<slot>
|
|
151
|
+
<ComboboxAnchor
|
|
152
|
+
v-bind="props._comboboxAnchor"
|
|
153
|
+
:una
|
|
154
|
+
>
|
|
155
|
+
<slot name="anchor">
|
|
156
|
+
<template
|
|
157
|
+
v-if="$slots.trigger || $slots.triggerRoot"
|
|
158
|
+
>
|
|
159
|
+
<slot name="trigger-wrapper">
|
|
160
|
+
<ComboboxTrigger
|
|
161
|
+
v-bind="props._comboboxTrigger"
|
|
162
|
+
:id
|
|
163
|
+
:status
|
|
164
|
+
:class="cn(
|
|
165
|
+
'text-0.875em',
|
|
166
|
+
props._comboboxTrigger?.class,
|
|
167
|
+
)"
|
|
168
|
+
:size
|
|
169
|
+
>
|
|
170
|
+
<slot name="trigger" :model-value :open />
|
|
171
|
+
</ComboboxTrigger>
|
|
172
|
+
</slot>
|
|
173
|
+
</template>
|
|
174
|
+
|
|
175
|
+
<template v-else>
|
|
176
|
+
<slot name="input-wrapper" :model-value :open>
|
|
177
|
+
<ComboboxInput
|
|
178
|
+
:id
|
|
179
|
+
:display-value="(val: unknown) => getDisplayValue(val)"
|
|
180
|
+
name="frameworks"
|
|
181
|
+
:status
|
|
182
|
+
:size
|
|
183
|
+
v-bind="props._comboboxInput"
|
|
184
|
+
/>
|
|
185
|
+
</slot>
|
|
186
|
+
</template>
|
|
187
|
+
</slot>
|
|
188
|
+
</ComboboxAnchor>
|
|
189
|
+
|
|
190
|
+
<ComboboxList
|
|
191
|
+
v-bind="{ ...props._comboboxList, ...props._comboboxContent }"
|
|
192
|
+
:_comboboxPortal
|
|
193
|
+
:size
|
|
194
|
+
:una
|
|
195
|
+
>
|
|
196
|
+
<slot name="list">
|
|
197
|
+
<slot name="input-wrapper" :model-value :open>
|
|
198
|
+
<ComboboxInput
|
|
199
|
+
v-if="$slots.trigger || $slots.triggerRoot"
|
|
200
|
+
:size
|
|
201
|
+
:class="cn(
|
|
202
|
+
'border-0 border-b-1 rounded-none focus-visible:ring-0',
|
|
203
|
+
props._comboboxInput?.class,
|
|
204
|
+
)"
|
|
205
|
+
v-bind="props._comboboxInput"
|
|
206
|
+
/>
|
|
207
|
+
</slot>
|
|
208
|
+
|
|
209
|
+
<slot name="header" />
|
|
210
|
+
|
|
211
|
+
<slot name="body">
|
|
212
|
+
<ComboboxViewport
|
|
213
|
+
v-bind="props._comboboxViewport"
|
|
214
|
+
:una
|
|
215
|
+
>
|
|
216
|
+
<ComboboxEmpty
|
|
217
|
+
v-bind="props._comboboxEmpty"
|
|
218
|
+
:una
|
|
219
|
+
>
|
|
220
|
+
<slot name="empty">
|
|
221
|
+
{{ props.textEmpty }}
|
|
222
|
+
</slot>
|
|
223
|
+
</ComboboxEmpty>
|
|
224
|
+
|
|
225
|
+
<!-- Non-grouped items -->
|
|
226
|
+
<template v-if="!hasGroups">
|
|
227
|
+
<ComboboxGroup
|
|
228
|
+
v-bind="props._comboboxGroup"
|
|
229
|
+
:label="props.label"
|
|
230
|
+
:una
|
|
231
|
+
>
|
|
232
|
+
<slot name="group">
|
|
233
|
+
<ComboboxItem
|
|
234
|
+
v-for="item in items as ExtractItemType<T>[]"
|
|
235
|
+
:key="getItemProperty(item, valueKey)"
|
|
236
|
+
:value="props.multiple ? getItemProperty(item, valueKey) : item"
|
|
237
|
+
:size
|
|
238
|
+
v-bind="props._comboboxItem"
|
|
239
|
+
:class="cn(
|
|
240
|
+
'text-0.875em',
|
|
241
|
+
props._comboboxItem?.class,
|
|
242
|
+
)"
|
|
243
|
+
:una
|
|
244
|
+
>
|
|
245
|
+
<slot name="item" :item="item" :selected="isItemSelected(item)">
|
|
246
|
+
<slot name="label" :item="item">
|
|
247
|
+
{{ getItemProperty(item, labelKey) }}
|
|
248
|
+
</slot>
|
|
249
|
+
|
|
250
|
+
<ComboboxItemIndicator
|
|
251
|
+
v-bind="props._comboboxItemIndicator"
|
|
252
|
+
:una
|
|
253
|
+
>
|
|
254
|
+
<slot name="item-indicator" :item="item">
|
|
255
|
+
<NIcon name="i-lucide-check" />
|
|
256
|
+
</slot>
|
|
257
|
+
</ComboboxItemIndicator>
|
|
258
|
+
</slot>
|
|
259
|
+
</ComboboxItem>
|
|
260
|
+
</slot>
|
|
261
|
+
</ComboboxGroup>
|
|
262
|
+
</template>
|
|
263
|
+
|
|
264
|
+
<!-- Grouped items -->
|
|
265
|
+
<template v-else>
|
|
266
|
+
<ComboboxGroup
|
|
267
|
+
v-for="(group, i) in items as NComboboxGroupProps<ExtractItemType<T>>[]"
|
|
268
|
+
:key="i"
|
|
269
|
+
v-bind="props._comboboxGroup"
|
|
270
|
+
:label="group.label"
|
|
271
|
+
:una
|
|
272
|
+
>
|
|
273
|
+
<ComboboxSeparator
|
|
274
|
+
v-if="i > 0 && props.groupSeparator"
|
|
275
|
+
v-bind="props._comboboxSeparator"
|
|
276
|
+
:una
|
|
277
|
+
/>
|
|
278
|
+
|
|
279
|
+
<slot name="group" :group="group">
|
|
280
|
+
<ComboboxItem
|
|
281
|
+
v-for="item in group.items"
|
|
282
|
+
:key="getItemProperty(item, valueKey)"
|
|
283
|
+
:value="props.multiple ? getItemProperty(item, valueKey) : item"
|
|
284
|
+
:size
|
|
285
|
+
v-bind="{ ...props._comboboxItem, ...group._comboboxItem }"
|
|
286
|
+
:class="cn(
|
|
287
|
+
'text-0.875em',
|
|
288
|
+
props._comboboxItem?.class,
|
|
289
|
+
)"
|
|
290
|
+
:una
|
|
291
|
+
>
|
|
292
|
+
<slot name="item" :item="item" :group="group" :selected="isItemSelected(item)">
|
|
293
|
+
<slot name="label" :item="item">
|
|
294
|
+
{{ getItemProperty(item, labelKey) }}
|
|
295
|
+
</slot>
|
|
296
|
+
|
|
297
|
+
<ComboboxItemIndicator
|
|
298
|
+
v-bind="props._comboboxItemIndicator"
|
|
299
|
+
:una
|
|
300
|
+
>
|
|
301
|
+
<slot name="indicator" :item="item" />
|
|
302
|
+
</ComboboxItemIndicator>
|
|
303
|
+
</slot>
|
|
304
|
+
</ComboboxItem>
|
|
305
|
+
</slot>
|
|
306
|
+
</ComboboxGroup>
|
|
307
|
+
</template>
|
|
308
|
+
</ComboboxViewport>
|
|
309
|
+
</slot>
|
|
310
|
+
|
|
311
|
+
<slot name="footer" />
|
|
312
|
+
</slot>
|
|
313
|
+
</ComboboxList>
|
|
314
|
+
</slot>
|
|
315
|
+
</ComboboxRoot>
|
|
316
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NComboboxAnchorProps } from '../../types'
|
|
3
|
+
import { ComboboxAnchor, useForwardProps } from 'reka-ui'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { cn } from '../../utils'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<NComboboxAnchorProps>()
|
|
8
|
+
|
|
9
|
+
const delegatedProps = computed(() => {
|
|
10
|
+
const { class: _, ...delegated } = props
|
|
11
|
+
|
|
12
|
+
return delegated
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const forwarded = useForwardProps(delegatedProps)
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<ComboboxAnchor
|
|
20
|
+
data-slot="combobox-anchor"
|
|
21
|
+
v-bind="forwarded"
|
|
22
|
+
:class="cn(
|
|
23
|
+
'combobox-anchor',
|
|
24
|
+
props.una?.comboboxAnchor,
|
|
25
|
+
props.class,
|
|
26
|
+
)"
|
|
27
|
+
>
|
|
28
|
+
<slot />
|
|
29
|
+
</ComboboxAnchor>
|
|
30
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NComboboxEmptyProps } from '../../types'
|
|
3
|
+
import { ComboboxEmpty } from 'reka-ui'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { cn } from '../../utils'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<NComboboxEmptyProps>()
|
|
8
|
+
|
|
9
|
+
const delegatedProps = computed(() => {
|
|
10
|
+
const { class: _, ...delegated } = props
|
|
11
|
+
|
|
12
|
+
return delegated
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<ComboboxEmpty
|
|
18
|
+
data-slot="combobox-empty"
|
|
19
|
+
v-bind="delegatedProps"
|
|
20
|
+
:class="cn(
|
|
21
|
+
'combobox-empty',
|
|
22
|
+
props.una?.comboboxEmpty,
|
|
23
|
+
props.class,
|
|
24
|
+
)"
|
|
25
|
+
>
|
|
26
|
+
<slot />
|
|
27
|
+
</ComboboxEmpty>
|
|
28
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AcceptableValue } from 'reka-ui'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts" generic="T extends AcceptableValue">
|
|
6
|
+
import type { NComboboxGroupProps } from '../../types'
|
|
7
|
+
import { ComboboxGroup } from 'reka-ui'
|
|
8
|
+
import { computed } from 'vue'
|
|
9
|
+
import { cn } from '../../utils'
|
|
10
|
+
import ComboboxLabel from './ComboboxLabel.vue'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<NComboboxGroupProps<T>>()
|
|
13
|
+
|
|
14
|
+
const delegatedProps = computed(() => {
|
|
15
|
+
const { class: _, ...delegated } = props
|
|
16
|
+
|
|
17
|
+
return delegated
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<ComboboxGroup
|
|
23
|
+
data-slot="combobox-group"
|
|
24
|
+
v-bind="delegatedProps"
|
|
25
|
+
:class="cn(
|
|
26
|
+
'combobox-group',
|
|
27
|
+
props.una?.comboboxGroup,
|
|
28
|
+
props.class,
|
|
29
|
+
)"
|
|
30
|
+
>
|
|
31
|
+
<ComboboxLabel
|
|
32
|
+
v-if="props.label"
|
|
33
|
+
:una
|
|
34
|
+
>
|
|
35
|
+
{{ props.label }}
|
|
36
|
+
</ComboboxLabel>
|
|
37
|
+
<slot />
|
|
38
|
+
</ComboboxGroup>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ComboboxInputEmits } from 'reka-ui'
|
|
3
|
+
import type { NComboboxInputProps } from '../../types'
|
|
4
|
+
import { ComboboxInput, useForwardPropsEmits } from 'reka-ui'
|
|
5
|
+
import { inject, onMounted, ref } from 'vue'
|
|
6
|
+
import { isInComboboxListKey } from '../../utils/injectionKeys'
|
|
7
|
+
import Input from '../forms/Input.vue'
|
|
8
|
+
|
|
9
|
+
defineOptions({
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<NComboboxInputProps>(), {
|
|
14
|
+
leading: 'combobox-input-leading-icon',
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const emits = defineEmits<ComboboxInputEmits>()
|
|
18
|
+
|
|
19
|
+
const forwarded = useForwardPropsEmits(props, emits)
|
|
20
|
+
const inputRef = ref<InstanceType<typeof Input>>()
|
|
21
|
+
|
|
22
|
+
const isInList = inject(isInComboboxListKey, false)
|
|
23
|
+
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
if (isInList) {
|
|
26
|
+
inputRef.value?.focus()
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<ComboboxInput
|
|
33
|
+
v-bind="props"
|
|
34
|
+
as-child
|
|
35
|
+
>
|
|
36
|
+
<Input
|
|
37
|
+
ref="inputRef"
|
|
38
|
+
data-slot="command-input"
|
|
39
|
+
v-bind="{ ...forwarded, ...$attrs }"
|
|
40
|
+
:_input-wrapper="{
|
|
41
|
+
'data-slot': 'command-input-wrapper',
|
|
42
|
+
}"
|
|
43
|
+
>
|
|
44
|
+
<template v-for="(_, name) in $slots" #[name]="slotData">
|
|
45
|
+
<slot :name="name" v-bind="slotData" />
|
|
46
|
+
</template>
|
|
47
|
+
</Input>
|
|
48
|
+
</ComboboxInput>
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T">
|
|
2
|
+
import type { ComboboxItemEmits } from 'reka-ui'
|
|
3
|
+
import type { NComboboxItemProps } from '../../types'
|
|
4
|
+
import { ComboboxItem, useForwardPropsEmits } from 'reka-ui'
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
import { cn } from '../../utils'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<NComboboxItemProps<T>>()
|
|
9
|
+
const emits = defineEmits<ComboboxItemEmits>()
|
|
10
|
+
|
|
11
|
+
const delegatedProps = computed(() => {
|
|
12
|
+
const { class: _, ...delegated } = props
|
|
13
|
+
|
|
14
|
+
return delegated
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<ComboboxItem
|
|
22
|
+
data-slot="combobox-item"
|
|
23
|
+
v-bind="forwarded"
|
|
24
|
+
:class="cn(
|
|
25
|
+
`combobox-item`,
|
|
26
|
+
props.una?.comboboxItem,
|
|
27
|
+
props.class,
|
|
28
|
+
)"
|
|
29
|
+
>
|
|
30
|
+
<slot />
|
|
31
|
+
</ComboboxItem>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NComboboxItemIndicatorProps } from '../../types'
|
|
3
|
+
import { ComboboxItemIndicator, useForwardProps } from 'reka-ui'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { cn } from '../../utils'
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(defineProps<NComboboxItemIndicatorProps>(), {
|
|
8
|
+
icon: 'combobox-item-indicator-icon-name',
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const delegatedProps = computed(() => {
|
|
12
|
+
const { class: _, ...delegated } = props
|
|
13
|
+
|
|
14
|
+
return delegated
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const forwarded = useForwardProps(delegatedProps)
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<ComboboxItemIndicator
|
|
22
|
+
data-slot="combobox-item-indicator"
|
|
23
|
+
v-bind="forwarded"
|
|
24
|
+
:class="cn(
|
|
25
|
+
'combobox-item-indicator',
|
|
26
|
+
props.una?.comboboxItemIndicator,
|
|
27
|
+
props.class,
|
|
28
|
+
)"
|
|
29
|
+
>
|
|
30
|
+
<slot>
|
|
31
|
+
<NIcon
|
|
32
|
+
:name="props.icon"
|
|
33
|
+
:class="cn(
|
|
34
|
+
'combobox-item-indicator-icon',
|
|
35
|
+
props.una?.comboboxItemIndicatorIcon,
|
|
36
|
+
)"
|
|
37
|
+
/>
|
|
38
|
+
</slot>
|
|
39
|
+
</ComboboxItemIndicator>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NComboboxLabelProps } from '../../types'
|
|
3
|
+
import { ComboboxLabel } from 'reka-ui'
|
|
4
|
+
import { cn } from '../../utils'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<NComboboxLabelProps>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<ComboboxLabel
|
|
11
|
+
:class="cn(
|
|
12
|
+
'combobox-label',
|
|
13
|
+
props.una?.comboboxLabel,
|
|
14
|
+
props.class,
|
|
15
|
+
)"
|
|
16
|
+
>
|
|
17
|
+
<slot>
|
|
18
|
+
{{ props.label }}
|
|
19
|
+
</slot>
|
|
20
|
+
</ComboboxLabel>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ComboboxContentEmits } from 'reka-ui'
|
|
3
|
+
import type { NComboboxListProps } from '../../types'
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core'
|
|
5
|
+
import { ComboboxContent, ComboboxPortal, useForwardPropsEmits } from 'reka-ui'
|
|
6
|
+
import { provide } from 'vue'
|
|
7
|
+
import { cn } from '../../utils'
|
|
8
|
+
import { isInComboboxListKey } from '../../utils/injectionKeys'
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<NComboboxListProps>(), {
|
|
11
|
+
position: 'popper',
|
|
12
|
+
align: 'center',
|
|
13
|
+
sideOffset: 4,
|
|
14
|
+
})
|
|
15
|
+
const emits = defineEmits<ComboboxContentEmits>()
|
|
16
|
+
|
|
17
|
+
provide(isInComboboxListKey, true)
|
|
18
|
+
|
|
19
|
+
const delegatedProps = reactiveOmit(props, 'class', 'viewportClass')
|
|
20
|
+
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<ComboboxPortal
|
|
25
|
+
v-bind="props._comboboxPortal"
|
|
26
|
+
>
|
|
27
|
+
<ComboboxContent
|
|
28
|
+
data-slot="combobox-list"
|
|
29
|
+
v-bind="forwarded"
|
|
30
|
+
:class="cn(
|
|
31
|
+
'origin-(--reka-combobox-content-transform-origin)',
|
|
32
|
+
'combobox-list',
|
|
33
|
+
props.una?.comboboxList,
|
|
34
|
+
props.class,
|
|
35
|
+
)"
|
|
36
|
+
>
|
|
37
|
+
<slot />
|
|
38
|
+
</ComboboxContent>
|
|
39
|
+
</ComboboxPortal>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NComboboxSeparatorProps } from '../../types'
|
|
3
|
+
import { ComboboxSeparator } from 'reka-ui'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { cn } from '../../utils'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<NComboboxSeparatorProps>()
|
|
8
|
+
|
|
9
|
+
const delegatedProps = computed(() => {
|
|
10
|
+
const { class: _, ...delegated } = props
|
|
11
|
+
|
|
12
|
+
return delegated
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<ComboboxSeparator
|
|
18
|
+
data-slot="combobox-separator"
|
|
19
|
+
v-bind="delegatedProps"
|
|
20
|
+
:class="cn(
|
|
21
|
+
'combobox-separator',
|
|
22
|
+
props.una?.comboboxSeparator,
|
|
23
|
+
props.class,
|
|
24
|
+
)"
|
|
25
|
+
>
|
|
26
|
+
<slot />
|
|
27
|
+
</ComboboxSeparator>
|
|
28
|
+
</template>
|