@destyler/combobox 0.0.2 → 0.0.4
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/README.md +7 -0
- package/dist/component.cjs +346 -392
- package/dist/component.d.cts +150 -83
- package/dist/component.d.mts +150 -83
- package/dist/component.d.ts +150 -83
- package/dist/component.mjs +319 -385
- package/dist/index.cjs +34 -16
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +5 -2
- package/dist/resolver.cjs +20 -6
- package/dist/resolver.d.cts +3 -3
- package/dist/resolver.d.mts +3 -3
- package/dist/resolver.d.ts +3 -3
- package/dist/resolver.mjs +19 -5
- package/dist/shared/combobox.2a62f7db.d.cts +1794 -0
- package/dist/shared/combobox.2a62f7db.d.mts +1794 -0
- package/dist/shared/combobox.2a62f7db.d.ts +1794 -0
- package/package.json +22 -23
- package/dist/shared/combobox.27206b6f.d.cts +0 -1290
- package/dist/shared/combobox.27206b6f.d.mts +0 -1290
- package/dist/shared/combobox.27206b6f.d.ts +0 -1290
package/dist/component.mjs
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
import { defineComponent, h, mergeProps, toRefs, ref,
|
|
2
|
-
import {
|
|
3
|
-
import { useForwardExpose, useDirection, useVModel, useFormControl,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { defineComponent, h, mergeProps, toRefs, ref, watch, computed, nextTick, onMounted, withDirectives, withKeys } from 'vue';
|
|
2
|
+
import { primitiveProps, Primitive } from '@destyler/primitive';
|
|
3
|
+
import { useForwardExpose, useDirection, useVModel, useFormControl, useBodyScrollLock, useHideOthers, useForwardProps, useForwardPropsEmits, useId, useMutationObserver } from '@destyler/composition';
|
|
4
|
+
import { PopperAnchor, PopperRoot, popperContentProps, PopperContent, PopperArrow } from '@destyler/popper';
|
|
5
|
+
import { popperArrowProps } from '@destyler/popper/component';
|
|
6
|
+
import { createContext, handleAndDispatchCustomEvent } from '@destyler/shared';
|
|
6
7
|
import isEqual from 'fast-deep-equal';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { VisuallyHiddenInput } from '@destyler/visually-hidden/component';
|
|
9
|
+
import { createCollection } from '@destyler/collection/composition';
|
|
10
|
+
import { CollectionSlot, CollectionItem } from '@destyler/collection';
|
|
11
|
+
import { dismissableLayerProps, DismissableLayer } from '@destyler/dismissable-layer';
|
|
12
|
+
import { dismissableLayerEmits } from '@destyler/dismissable-layer/component';
|
|
10
13
|
import { BindOnceDirective } from '@destyler/directives';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
14
|
+
import { Presence } from '@destyler/presence';
|
|
15
|
+
import { teleportPrimitiveProps, TeleportPrimitive } from '@destyler/teleport';
|
|
13
16
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
type: [String, Object],
|
|
17
|
-
required: false,
|
|
18
|
-
default: "div"
|
|
19
|
-
},
|
|
20
|
-
asChild: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
required: false,
|
|
23
|
-
default: false
|
|
24
|
-
}
|
|
17
|
+
const comboboxAnchorProps = {
|
|
18
|
+
...primitiveProps
|
|
25
19
|
};
|
|
26
|
-
const
|
|
20
|
+
const ComboboxAnchor = defineComponent({
|
|
27
21
|
name: "DestylerComboboxAnchor",
|
|
28
|
-
props:
|
|
22
|
+
props: comboboxAnchorProps,
|
|
29
23
|
setup() {
|
|
30
24
|
const { forwardRef } = useForwardExpose();
|
|
31
25
|
return {
|
|
@@ -33,84 +27,138 @@ const DestylerComboboxAnchor = defineComponent({
|
|
|
33
27
|
};
|
|
34
28
|
},
|
|
35
29
|
render() {
|
|
36
|
-
return h(
|
|
30
|
+
return h(PopperAnchor, {
|
|
37
31
|
asChild: true
|
|
38
|
-
}, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
}
|
|
32
|
+
}, () => {
|
|
33
|
+
return h(Primitive, mergeProps(this.$attrs, {
|
|
34
|
+
ref: (el) => this.forwardRef(el),
|
|
35
|
+
as: this.$props.as,
|
|
36
|
+
asChild: this.$props.asChild
|
|
37
|
+
}), {
|
|
38
|
+
default: () => this.$slots.default?.()
|
|
39
|
+
});
|
|
48
40
|
});
|
|
49
41
|
}
|
|
50
42
|
});
|
|
51
43
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type: Boolean,
|
|
60
|
-
required: false,
|
|
61
|
-
default: false
|
|
62
|
-
},
|
|
44
|
+
const comboboxRootProps = {
|
|
45
|
+
...primitiveProps,
|
|
46
|
+
/**
|
|
47
|
+
* The controlled value of the Combobox. Can be binded-with with `v-model`.
|
|
48
|
+
*
|
|
49
|
+
* @default undefined
|
|
50
|
+
*/
|
|
63
51
|
modelValue: {
|
|
64
|
-
type: [String, Number, Boolean, Object],
|
|
65
|
-
required: false
|
|
52
|
+
type: [String, Number, Boolean, Object, Array],
|
|
53
|
+
required: false,
|
|
54
|
+
default: void 0
|
|
66
55
|
},
|
|
56
|
+
/**
|
|
57
|
+
* The value of the combobox when initially rendered.
|
|
58
|
+
* Use when you do not need to control the state of the Combobox
|
|
59
|
+
*
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
67
62
|
defaultValue: {
|
|
68
|
-
type: [String, Number, Boolean, Object],
|
|
69
|
-
required: false
|
|
63
|
+
type: [String, Number, Boolean, Object, Array],
|
|
64
|
+
required: false,
|
|
65
|
+
default: void 0
|
|
70
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* The controlled open state of the Combobox. Can be binded-with with `v-model:open`.
|
|
69
|
+
*
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
71
72
|
open: {
|
|
72
73
|
type: Boolean,
|
|
73
74
|
required: false,
|
|
74
75
|
default: void 0
|
|
75
76
|
},
|
|
77
|
+
/**
|
|
78
|
+
* The open state of the combobox when it is initially rendered.
|
|
79
|
+
* Use when you do not need to control its open state.
|
|
80
|
+
*/
|
|
76
81
|
defaultOpen: {
|
|
77
82
|
type: Boolean,
|
|
78
83
|
required: false
|
|
79
84
|
},
|
|
85
|
+
/**
|
|
86
|
+
* The controlled search term of the Combobox.
|
|
87
|
+
* Can be binded-with with `v-model:searchTerm`.
|
|
88
|
+
*/
|
|
80
89
|
searchTerm: {
|
|
81
90
|
type: String,
|
|
82
91
|
required: false
|
|
83
92
|
},
|
|
93
|
+
/**
|
|
94
|
+
* Whether multiple options can be selected or not.
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
84
98
|
multiple: {
|
|
85
99
|
type: Boolean,
|
|
86
|
-
required: false
|
|
100
|
+
required: false,
|
|
101
|
+
default: false
|
|
87
102
|
},
|
|
103
|
+
/**
|
|
104
|
+
* When `true`, prevents the user from interacting with Combobox.
|
|
105
|
+
*
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
88
108
|
disabled: {
|
|
89
109
|
type: Boolean,
|
|
90
|
-
required: false
|
|
110
|
+
required: false,
|
|
111
|
+
default: false
|
|
91
112
|
},
|
|
113
|
+
/**
|
|
114
|
+
* The name of the Combobox. Submitted with its owning form as part of a name/value pair.
|
|
115
|
+
*/
|
|
92
116
|
name: {
|
|
93
117
|
type: String,
|
|
94
118
|
required: false
|
|
95
119
|
},
|
|
120
|
+
/**
|
|
121
|
+
* The reading direction of the combobox when applicable.
|
|
122
|
+
*/
|
|
96
123
|
dir: {
|
|
97
124
|
type: String,
|
|
98
125
|
required: false
|
|
99
126
|
},
|
|
127
|
+
/**
|
|
128
|
+
* The custom filter function for filtering `ComboboxItem`.
|
|
129
|
+
*/
|
|
100
130
|
filterFunction: {
|
|
101
131
|
type: Function,
|
|
102
132
|
required: false
|
|
103
133
|
},
|
|
134
|
+
/**
|
|
135
|
+
* The display value of input for selected item. Does not work with `multiple`.
|
|
136
|
+
*/
|
|
104
137
|
displayValue: {
|
|
105
138
|
type: Function,
|
|
106
139
|
required: false
|
|
107
140
|
}
|
|
108
141
|
};
|
|
142
|
+
const comboboxRootEmits = {
|
|
143
|
+
/**
|
|
144
|
+
* Event handler called when the value changes.
|
|
145
|
+
*/
|
|
146
|
+
"update:modelValue": (_value) => true,
|
|
147
|
+
/**
|
|
148
|
+
* Event handler called when the open state of the combobox changes.
|
|
149
|
+
*/
|
|
150
|
+
"update:open": (_value) => true,
|
|
151
|
+
/**
|
|
152
|
+
* Event handler called when the searchTerm of the combobox changes.
|
|
153
|
+
*/
|
|
154
|
+
"update:searchTerm": (_value) => true
|
|
155
|
+
};
|
|
109
156
|
const [injectComboboxRootContext, provideComboboxRootContext] = createContext("DestylerComboboxRoot");
|
|
110
|
-
const
|
|
157
|
+
const ComboboxRoot = defineComponent({
|
|
111
158
|
name: "DestylerComboboxRoot",
|
|
112
|
-
props:
|
|
113
|
-
emits:
|
|
159
|
+
props: comboboxRootProps,
|
|
160
|
+
emits: comboboxRootEmits,
|
|
161
|
+
slots: Object,
|
|
114
162
|
setup(props, { emit }) {
|
|
115
163
|
const { multiple, disabled, dir: propDir } = toRefs(props);
|
|
116
164
|
const dir = useDirection(propDir);
|
|
@@ -128,11 +176,11 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
128
176
|
passive: props.open === void 0
|
|
129
177
|
});
|
|
130
178
|
const selectedValue = ref();
|
|
131
|
-
const isUserInputted = ref(false);
|
|
132
179
|
const inputElement = ref();
|
|
133
180
|
const contentElement = ref();
|
|
134
181
|
const { forwardRef, currentElement: parentElement } = useForwardExpose();
|
|
135
182
|
const { getItems, reactiveItems, itemMapSize } = createCollection("data-destyler-combobox-item");
|
|
183
|
+
const isUserInputted = ref(false);
|
|
136
184
|
async function onOpenChange(val) {
|
|
137
185
|
open.value = val;
|
|
138
186
|
await nextTick();
|
|
@@ -159,20 +207,22 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
159
207
|
onOpenChange(false);
|
|
160
208
|
}
|
|
161
209
|
}
|
|
162
|
-
const options =
|
|
163
|
-
|
|
164
|
-
|
|
210
|
+
const options = ref([]);
|
|
211
|
+
watch(() => itemMapSize.value, () => {
|
|
212
|
+
options.value = getItems().map((i) => i.value);
|
|
213
|
+
}, { immediate: true });
|
|
165
214
|
const filteredOptions = computed(() => {
|
|
166
215
|
if (isUserInputted.value) {
|
|
167
216
|
if (props.filterFunction)
|
|
168
217
|
return props.filterFunction(options.value, searchTerm.value);
|
|
169
|
-
|
|
170
|
-
|
|
218
|
+
const optionsWithTypeString = options.value.filter((i) => typeof i === "string");
|
|
219
|
+
if (optionsWithTypeString.length)
|
|
220
|
+
return optionsWithTypeString.filter((i) => i.toLowerCase().includes(searchTerm.value?.toLowerCase()));
|
|
171
221
|
}
|
|
172
222
|
return options.value;
|
|
173
223
|
});
|
|
174
224
|
function resetSearchTerm() {
|
|
175
|
-
if (!multiple.value && modelValue.value) {
|
|
225
|
+
if (!multiple.value && modelValue.value && !Array.isArray(modelValue.value)) {
|
|
176
226
|
if (props.displayValue)
|
|
177
227
|
searchTerm.value = props.displayValue(modelValue.value);
|
|
178
228
|
else if (typeof modelValue.value !== "object")
|
|
@@ -187,7 +237,9 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
187
237
|
const selectedElement = computed(() => {
|
|
188
238
|
return reactiveItems.value.find((i) => i.value === selectedValue.value)?.ref;
|
|
189
239
|
});
|
|
190
|
-
|
|
240
|
+
const stringifiedModelValue = computed(() => JSON.stringify(modelValue.value));
|
|
241
|
+
watch(stringifiedModelValue, async () => {
|
|
242
|
+
await nextTick();
|
|
191
243
|
await nextTick();
|
|
192
244
|
resetSearchTerm();
|
|
193
245
|
}, { immediate: true });
|
|
@@ -212,7 +264,7 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
212
264
|
open,
|
|
213
265
|
onOpenChange,
|
|
214
266
|
filteredOptions,
|
|
215
|
-
contentId:
|
|
267
|
+
contentId: "",
|
|
216
268
|
inputElement,
|
|
217
269
|
onInputElementChange: (val) => inputElement.value = val,
|
|
218
270
|
onInputNavigation: async (val) => {
|
|
@@ -246,9 +298,9 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
246
298
|
};
|
|
247
299
|
},
|
|
248
300
|
render() {
|
|
249
|
-
return h(
|
|
301
|
+
return h(PopperRoot, null, {
|
|
250
302
|
default: () => {
|
|
251
|
-
return h(
|
|
303
|
+
return h(Primitive, mergeProps(this.$attrs, {
|
|
252
304
|
ref: (el) => this.forwardRef(el),
|
|
253
305
|
style: {
|
|
254
306
|
pointerEvents: this.open ? "auto" : void 0
|
|
@@ -260,7 +312,7 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
260
312
|
default: () => {
|
|
261
313
|
return [
|
|
262
314
|
this.$slots.default?.({ open: this.open, modelValue: this.modelValue }),
|
|
263
|
-
this.isFormControl && this.$props.name ? h(
|
|
315
|
+
this.isFormControl && this.$props.name ? h(VisuallyHiddenInput, {
|
|
264
316
|
name: this.$props.name,
|
|
265
317
|
value: this.modelValue
|
|
266
318
|
}) : null
|
|
@@ -272,111 +324,47 @@ const DestylerComboboxRoot = defineComponent({
|
|
|
272
324
|
}
|
|
273
325
|
});
|
|
274
326
|
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
},
|
|
286
|
-
side: {
|
|
287
|
-
type: String,
|
|
288
|
-
required: false,
|
|
289
|
-
default: "bottom"
|
|
290
|
-
},
|
|
291
|
-
sideOffset: {
|
|
292
|
-
type: Number,
|
|
293
|
-
required: false,
|
|
294
|
-
default: 0
|
|
295
|
-
},
|
|
296
|
-
align: {
|
|
297
|
-
type: String,
|
|
298
|
-
required: false,
|
|
299
|
-
default: "center"
|
|
300
|
-
},
|
|
301
|
-
alignOffset: {
|
|
302
|
-
type: Number,
|
|
303
|
-
required: false,
|
|
304
|
-
default: 0
|
|
305
|
-
},
|
|
306
|
-
avoidCollisions: {
|
|
307
|
-
type: Boolean,
|
|
308
|
-
required: false,
|
|
309
|
-
default: true
|
|
310
|
-
},
|
|
311
|
-
collisionBoundary: {
|
|
312
|
-
type: [Object, Array, null],
|
|
313
|
-
required: false,
|
|
314
|
-
default: () => []
|
|
315
|
-
},
|
|
316
|
-
collisionPadding: {
|
|
317
|
-
type: [Number, Object],
|
|
318
|
-
required: false,
|
|
319
|
-
default: 0
|
|
320
|
-
},
|
|
321
|
-
arrowPadding: {
|
|
322
|
-
type: Number,
|
|
323
|
-
required: false,
|
|
324
|
-
default: 0
|
|
325
|
-
},
|
|
326
|
-
sticky: {
|
|
327
|
-
type: String,
|
|
328
|
-
required: false,
|
|
329
|
-
default: "partial"
|
|
330
|
-
},
|
|
331
|
-
hideWhenDetached: {
|
|
332
|
-
type: Boolean,
|
|
333
|
-
required: false,
|
|
334
|
-
default: false
|
|
335
|
-
},
|
|
336
|
-
updatePositionStrategy: {
|
|
337
|
-
type: String,
|
|
338
|
-
required: false,
|
|
339
|
-
default: "optimized"
|
|
340
|
-
},
|
|
341
|
-
onPlaced: {
|
|
342
|
-
type: Function,
|
|
343
|
-
required: false
|
|
344
|
-
},
|
|
345
|
-
prioritizePosition: {
|
|
346
|
-
type: Boolean,
|
|
347
|
-
required: false,
|
|
348
|
-
default: false
|
|
349
|
-
},
|
|
350
|
-
disableOutsidePointerEvents: {
|
|
351
|
-
type: Boolean,
|
|
352
|
-
required: false,
|
|
353
|
-
default: false
|
|
354
|
-
},
|
|
355
|
-
isDismissable: {
|
|
356
|
-
type: Boolean,
|
|
357
|
-
required: false,
|
|
358
|
-
default: true
|
|
359
|
-
},
|
|
327
|
+
const comboboxContentImplProps = {
|
|
328
|
+
...dismissableLayerProps,
|
|
329
|
+
...popperContentProps,
|
|
330
|
+
/**
|
|
331
|
+
* The positioning mode to use, <br>
|
|
332
|
+
* `inline` is the default and you can control the position using CSS. <br>
|
|
333
|
+
* `popper` positions content in the same way as our other primitives, for example `Popover` or `DropdownMenu`.
|
|
334
|
+
*
|
|
335
|
+
* @default inline
|
|
336
|
+
*/
|
|
360
337
|
position: {
|
|
361
338
|
type: String,
|
|
362
339
|
required: false,
|
|
363
340
|
default: "inline"
|
|
364
341
|
},
|
|
342
|
+
/**
|
|
343
|
+
* The document.body will be lock, and scrolling will be disabled.
|
|
344
|
+
*/
|
|
365
345
|
bodyLock: {
|
|
366
346
|
type: Boolean,
|
|
367
347
|
required: false
|
|
368
348
|
},
|
|
349
|
+
/**
|
|
350
|
+
* Allow component to be dismissableLayer.
|
|
351
|
+
*
|
|
352
|
+
* @default true
|
|
353
|
+
*/
|
|
369
354
|
dismissable: {
|
|
370
355
|
type: Boolean,
|
|
371
356
|
required: false,
|
|
372
357
|
default: true
|
|
373
358
|
}
|
|
374
359
|
};
|
|
360
|
+
const comboboxContentImplEmits = {
|
|
361
|
+
...dismissableLayerEmits
|
|
362
|
+
};
|
|
375
363
|
const [injectComboboxContentContext, provideComboboxContentContext] = createContext("DestylerComboboxContent");
|
|
376
|
-
const
|
|
364
|
+
const ComboboxContentImpl = defineComponent({
|
|
377
365
|
name: "DestylerComboboxContentImpl",
|
|
378
|
-
props:
|
|
379
|
-
emits:
|
|
366
|
+
props: comboboxContentImplProps,
|
|
367
|
+
emits: comboboxContentImplEmits,
|
|
380
368
|
setup(props) {
|
|
381
369
|
const { position } = toRefs(props);
|
|
382
370
|
const rootContext = injectComboboxRootContext();
|
|
@@ -398,26 +386,27 @@ const DestylerComboboxContentImpl = defineComponent({
|
|
|
398
386
|
});
|
|
399
387
|
const popperStyle = {
|
|
400
388
|
"boxSizing": "border-box",
|
|
401
|
-
"--
|
|
402
|
-
"--
|
|
403
|
-
"--
|
|
404
|
-
"--
|
|
405
|
-
"--
|
|
389
|
+
"--destyler-combobox-content-transform-origin": "var(--destyler-popper-transform-origin)",
|
|
390
|
+
"--destyler-combobox-content-available-width": "var(--destyler-popper-available-width)",
|
|
391
|
+
"--destyler-combobox-content-available-height": "var(--destyler-popper-available-height)",
|
|
392
|
+
"--destyler-combobox-trigger-width": "var(--destyler-popper-anchor-width)",
|
|
393
|
+
"--destyler-combobox-trigger-height": "var(--destyler-popper-anchor-height)"
|
|
406
394
|
};
|
|
407
395
|
provideComboboxContentContext({ position });
|
|
408
396
|
return {
|
|
409
397
|
rootContext,
|
|
410
398
|
popperStyle,
|
|
411
399
|
forwardedProps,
|
|
400
|
+
pickedProps,
|
|
412
401
|
forwardRef,
|
|
413
402
|
handleLeave
|
|
414
403
|
};
|
|
415
404
|
},
|
|
416
405
|
render() {
|
|
417
|
-
return h(
|
|
406
|
+
return h(CollectionSlot, null, {
|
|
418
407
|
default: () => {
|
|
419
408
|
return [
|
|
420
|
-
this.$props.dismissable ? h(
|
|
409
|
+
this.$props.dismissable ? h(DismissableLayer, {
|
|
421
410
|
asChild: true,
|
|
422
411
|
disableOutsidePointerEvents: this.$props.disableOutsidePointerEvents,
|
|
423
412
|
onDismiss: () => {
|
|
@@ -439,9 +428,9 @@ const DestylerComboboxContentImpl = defineComponent({
|
|
|
439
428
|
event.preventDefault();
|
|
440
429
|
this.$emit("pointerDownOutside", event);
|
|
441
430
|
}
|
|
442
|
-
}
|
|
431
|
+
}, {
|
|
443
432
|
default: () => {
|
|
444
|
-
return withDirectives(h(this.$props.position === "popper" ?
|
|
433
|
+
return withDirectives(h(this.$props.position === "popper" ? PopperContent : Primitive, mergeProps(this.$attrs, this.forwardedProps, {
|
|
445
434
|
"ref": (el) => this.forwardRef(el),
|
|
446
435
|
"role": "listbox",
|
|
447
436
|
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
@@ -454,13 +443,13 @@ const DestylerComboboxContentImpl = defineComponent({
|
|
|
454
443
|
"onPointerleave": () => {
|
|
455
444
|
this.handleLeave();
|
|
456
445
|
}
|
|
457
|
-
}, {
|
|
446
|
+
}), {
|
|
458
447
|
default: () => this.$slots.default?.()
|
|
459
448
|
}), [
|
|
460
449
|
[BindOnceDirective, { id: this.rootContext.contentId }]
|
|
461
450
|
]);
|
|
462
451
|
}
|
|
463
|
-
}) : withDirectives(h(this.$props.position === "popper" ?
|
|
452
|
+
}) : withDirectives(h(this.$props.position === "popper" ? PopperContent : Primitive, mergeProps(this.$attrs, this.pickedProps, {
|
|
464
453
|
"ref": (el) => this.forwardRef(el),
|
|
465
454
|
"role": "listbox",
|
|
466
455
|
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
@@ -473,7 +462,7 @@ const DestylerComboboxContentImpl = defineComponent({
|
|
|
473
462
|
"onPointerleave": () => {
|
|
474
463
|
this.handleLeave();
|
|
475
464
|
}
|
|
476
|
-
}, {
|
|
465
|
+
}), {
|
|
477
466
|
default: () => this.$slots.default?.()
|
|
478
467
|
}), [
|
|
479
468
|
[BindOnceDirective, { id: this.rootContext.contentId }]
|
|
@@ -484,31 +473,12 @@ const DestylerComboboxContentImpl = defineComponent({
|
|
|
484
473
|
}
|
|
485
474
|
});
|
|
486
475
|
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
type: Boolean,
|
|
490
|
-
required: false,
|
|
491
|
-
default: false
|
|
492
|
-
},
|
|
493
|
-
width: {
|
|
494
|
-
type: Number,
|
|
495
|
-
required: false,
|
|
496
|
-
default: 10
|
|
497
|
-
},
|
|
498
|
-
height: {
|
|
499
|
-
type: Number,
|
|
500
|
-
required: false,
|
|
501
|
-
default: 5
|
|
502
|
-
},
|
|
503
|
-
as: {
|
|
504
|
-
type: [String, Object],
|
|
505
|
-
required: false,
|
|
506
|
-
default: "svg"
|
|
507
|
-
}
|
|
476
|
+
const comboboxArrowProps = {
|
|
477
|
+
...popperArrowProps
|
|
508
478
|
};
|
|
509
|
-
const
|
|
479
|
+
const ComboboxArrow = defineComponent({
|
|
510
480
|
name: "DestylerComboboxArrow",
|
|
511
|
-
props:
|
|
481
|
+
props: comboboxArrowProps,
|
|
512
482
|
setup() {
|
|
513
483
|
useForwardExpose();
|
|
514
484
|
const rootContext = injectComboboxRootContext();
|
|
@@ -519,29 +489,26 @@ const DestylerComboboxArrow = defineComponent({
|
|
|
519
489
|
};
|
|
520
490
|
},
|
|
521
491
|
render() {
|
|
522
|
-
if (this.rootContext.open.value && this.contentContext.position.value === "popper")
|
|
523
|
-
return h(
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
492
|
+
if (this.rootContext.open.value && this.contentContext.position.value === "popper")
|
|
493
|
+
return h(PopperArrow, this.$props, () => this.$slots.default?.());
|
|
494
|
+
else
|
|
495
|
+
return null;
|
|
527
496
|
}
|
|
528
497
|
});
|
|
529
498
|
|
|
530
|
-
const
|
|
499
|
+
const comboboxCancelProps = {
|
|
500
|
+
...primitiveProps,
|
|
501
|
+
/**
|
|
502
|
+
* @default button
|
|
503
|
+
*/
|
|
531
504
|
as: {
|
|
532
|
-
|
|
533
|
-
required: false,
|
|
505
|
+
...primitiveProps.as,
|
|
534
506
|
default: "button"
|
|
535
|
-
},
|
|
536
|
-
asChild: {
|
|
537
|
-
type: Boolean,
|
|
538
|
-
required: false,
|
|
539
|
-
default: false
|
|
540
507
|
}
|
|
541
508
|
};
|
|
542
|
-
const
|
|
509
|
+
const ComboboxCancel = defineComponent({
|
|
543
510
|
name: "DestylerComboboxCancel",
|
|
544
|
-
props:
|
|
511
|
+
props: comboboxCancelProps,
|
|
545
512
|
setup() {
|
|
546
513
|
useForwardExpose();
|
|
547
514
|
const rootContext = injectComboboxRootContext();
|
|
@@ -555,33 +522,39 @@ const DestylerComboboxCancel = defineComponent({
|
|
|
555
522
|
};
|
|
556
523
|
},
|
|
557
524
|
render() {
|
|
558
|
-
return h(
|
|
525
|
+
return h(Primitive, mergeProps(this.$props, {
|
|
559
526
|
type: this.$props.as === "button" ? "button" : void 0,
|
|
560
527
|
tabindex: "-1",
|
|
561
528
|
onClick: () => {
|
|
562
529
|
this.handleClick();
|
|
563
530
|
}
|
|
564
|
-
}),
|
|
565
|
-
default: () => this.$slots.default?.()
|
|
566
|
-
});
|
|
531
|
+
}), () => this.$slots.default?.());
|
|
567
532
|
}
|
|
568
533
|
});
|
|
569
534
|
|
|
570
|
-
const
|
|
571
|
-
...
|
|
535
|
+
const comboboxContentProps = {
|
|
536
|
+
...comboboxContentImplProps,
|
|
537
|
+
/**
|
|
538
|
+
* Used to force mounting when more control is needed.
|
|
539
|
+
* Useful when controlling animation with Vue animation libraries.
|
|
540
|
+
*/
|
|
572
541
|
forceMount: {
|
|
573
542
|
type: Boolean,
|
|
574
543
|
required: false
|
|
575
544
|
}
|
|
576
545
|
};
|
|
577
|
-
const
|
|
546
|
+
const comboboxContentEmits = {
|
|
547
|
+
...comboboxContentImplEmits
|
|
548
|
+
};
|
|
549
|
+
const ComboboxContent = defineComponent({
|
|
578
550
|
name: "DestylerComboboxContent",
|
|
579
|
-
props:
|
|
580
|
-
emits:
|
|
551
|
+
props: comboboxContentProps,
|
|
552
|
+
emits: comboboxContentEmits,
|
|
581
553
|
setup(props, { emit }) {
|
|
582
554
|
const forwarded = useForwardPropsEmits(props, emit);
|
|
583
555
|
const { forwardRef } = useForwardExpose();
|
|
584
556
|
const rootContext = injectComboboxRootContext();
|
|
557
|
+
rootContext.contentId || (rootContext.contentId = useId(void 0, "destyler-combobox-content"));
|
|
585
558
|
return {
|
|
586
559
|
forwardRef,
|
|
587
560
|
forwarded,
|
|
@@ -589,35 +562,20 @@ const DestylerComboboxContent = defineComponent({
|
|
|
589
562
|
};
|
|
590
563
|
},
|
|
591
564
|
render() {
|
|
592
|
-
return h(
|
|
565
|
+
return h(Presence, {
|
|
593
566
|
present: this.$props.forceMount || this.rootContext.open.value
|
|
594
|
-
}, {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
ref: (el) => this.forwardRef(el)
|
|
598
|
-
}), {
|
|
599
|
-
default: () => this.$slots.default?.()
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
});
|
|
567
|
+
}, () => h(ComboboxContentImpl, mergeProps(this.$attrs, this.forwarded, {
|
|
568
|
+
ref: (el) => this.forwardRef(el)
|
|
569
|
+
}), () => this.$slots.default?.()));
|
|
603
570
|
}
|
|
604
571
|
});
|
|
605
572
|
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
type: [String, Object],
|
|
609
|
-
required: false,
|
|
610
|
-
default: "button"
|
|
611
|
-
},
|
|
612
|
-
asChild: {
|
|
613
|
-
type: Boolean,
|
|
614
|
-
required: false,
|
|
615
|
-
default: false
|
|
616
|
-
}
|
|
573
|
+
const comboboxEmptyProps = {
|
|
574
|
+
...primitiveProps
|
|
617
575
|
};
|
|
618
|
-
const
|
|
576
|
+
const ComboboxEmpty = defineComponent({
|
|
619
577
|
name: "DestylerComboboxEmpty",
|
|
620
|
-
props:
|
|
578
|
+
props: comboboxEmptyProps,
|
|
621
579
|
setup() {
|
|
622
580
|
useForwardExpose();
|
|
623
581
|
const rootContext = injectComboboxRootContext();
|
|
@@ -629,32 +587,23 @@ const DestylerComboboxEmpty = defineComponent({
|
|
|
629
587
|
},
|
|
630
588
|
render() {
|
|
631
589
|
if (this.isEmpty) {
|
|
632
|
-
return h(
|
|
590
|
+
return h(Primitive, this.$props, {
|
|
633
591
|
default: () => this.$slots.default ? this.$slots.default?.() : "No options"
|
|
634
592
|
});
|
|
635
593
|
}
|
|
636
594
|
}
|
|
637
595
|
});
|
|
638
596
|
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
type: [String, Object],
|
|
642
|
-
required: false,
|
|
643
|
-
default: "div"
|
|
644
|
-
},
|
|
645
|
-
asChild: {
|
|
646
|
-
type: Boolean,
|
|
647
|
-
required: false,
|
|
648
|
-
default: false
|
|
649
|
-
}
|
|
597
|
+
const comboboxGroupProps = {
|
|
598
|
+
...primitiveProps
|
|
650
599
|
};
|
|
651
600
|
const [injectComboboxGroupContext, provideComboboxGroupContext] = createContext("DestylerComboboxGroup");
|
|
652
|
-
const
|
|
601
|
+
const ComboboxGroup = defineComponent({
|
|
653
602
|
name: "DestylerComboboxGroup",
|
|
654
|
-
props:
|
|
603
|
+
props: comboboxGroupProps,
|
|
655
604
|
setup() {
|
|
656
605
|
const { currentRef, currentElement } = useForwardExpose();
|
|
657
|
-
const id = useId();
|
|
606
|
+
const id = useId(void 0, "destyler-combobox-group");
|
|
658
607
|
const rootContext = injectComboboxRootContext();
|
|
659
608
|
const hasOptions = ref(false);
|
|
660
609
|
function checkCollectionItem() {
|
|
@@ -665,12 +614,16 @@ const DestylerComboboxGroup = defineComponent({
|
|
|
665
614
|
}
|
|
666
615
|
useMutationObserver(currentElement, () => {
|
|
667
616
|
checkCollectionItem();
|
|
668
|
-
}, {
|
|
617
|
+
}, {
|
|
618
|
+
childList: true
|
|
619
|
+
});
|
|
669
620
|
watch(() => rootContext.searchTerm.value, () => {
|
|
670
621
|
nextTick(() => {
|
|
671
622
|
checkCollectionItem();
|
|
672
623
|
});
|
|
673
|
-
}, {
|
|
624
|
+
}, {
|
|
625
|
+
immediate: true
|
|
626
|
+
});
|
|
674
627
|
provideComboboxGroupContext({
|
|
675
628
|
id
|
|
676
629
|
});
|
|
@@ -681,7 +634,7 @@ const DestylerComboboxGroup = defineComponent({
|
|
|
681
634
|
};
|
|
682
635
|
},
|
|
683
636
|
render() {
|
|
684
|
-
return h(
|
|
637
|
+
return h(Primitive, mergeProps(this.$props, {
|
|
685
638
|
"ref": "currentRef",
|
|
686
639
|
"role": "group",
|
|
687
640
|
"aria-labelledby": this.id,
|
|
@@ -692,34 +645,45 @@ const DestylerComboboxGroup = defineComponent({
|
|
|
692
645
|
}
|
|
693
646
|
});
|
|
694
647
|
|
|
695
|
-
const
|
|
648
|
+
const comboboxInputProps = {
|
|
649
|
+
...primitiveProps,
|
|
650
|
+
/**
|
|
651
|
+
* @default input
|
|
652
|
+
*/
|
|
696
653
|
as: {
|
|
697
|
-
|
|
698
|
-
required: false,
|
|
654
|
+
...primitiveProps.as,
|
|
699
655
|
default: "input"
|
|
700
656
|
},
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
657
|
+
/**
|
|
658
|
+
* Native input type
|
|
659
|
+
*
|
|
660
|
+
* @default text
|
|
661
|
+
*/
|
|
706
662
|
type: {
|
|
707
663
|
type: String,
|
|
708
664
|
required: false,
|
|
709
665
|
default: "text"
|
|
710
666
|
},
|
|
667
|
+
/**
|
|
668
|
+
* When `true`, prevents the user from interacting with item
|
|
669
|
+
*/
|
|
711
670
|
disabled: {
|
|
712
671
|
type: Boolean,
|
|
713
672
|
required: false
|
|
714
673
|
},
|
|
674
|
+
/**
|
|
675
|
+
* Focus on element when mounted.
|
|
676
|
+
*
|
|
677
|
+
* @default false
|
|
678
|
+
*/
|
|
715
679
|
autoFocus: {
|
|
716
680
|
type: Boolean,
|
|
717
681
|
required: false
|
|
718
682
|
}
|
|
719
683
|
};
|
|
720
|
-
const
|
|
684
|
+
const ComboboxInput = defineComponent({
|
|
721
685
|
name: "DestylerComboboxInput",
|
|
722
|
-
props:
|
|
686
|
+
props: comboboxInputProps,
|
|
723
687
|
setup(props) {
|
|
724
688
|
const rootContext = injectComboboxRootContext();
|
|
725
689
|
const { forwardRef, currentElement } = useForwardExpose();
|
|
@@ -761,7 +725,7 @@ const DestylerComboboxInput = defineComponent({
|
|
|
761
725
|
};
|
|
762
726
|
},
|
|
763
727
|
render() {
|
|
764
|
-
return h(
|
|
728
|
+
return h(Primitive, {
|
|
765
729
|
"ref": (el) => this.forwardRef(el),
|
|
766
730
|
"as": this.$props.as,
|
|
767
731
|
"asChild": this.$props.asChild,
|
|
@@ -801,41 +765,45 @@ const DestylerComboboxInput = defineComponent({
|
|
|
801
765
|
});
|
|
802
766
|
|
|
803
767
|
const COMBOBOX_SELECT = "combobox.select";
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
},
|
|
810
|
-
asChild: {
|
|
811
|
-
type: Boolean,
|
|
812
|
-
required: false,
|
|
813
|
-
default: false
|
|
814
|
-
},
|
|
768
|
+
const comboboxItemProps = {
|
|
769
|
+
...primitiveProps,
|
|
770
|
+
/**
|
|
771
|
+
* The value given as data when submitted with a `name`.
|
|
772
|
+
*/
|
|
815
773
|
value: {
|
|
816
774
|
type: [String, Number, Boolean, Object],
|
|
817
775
|
required: true
|
|
818
776
|
},
|
|
777
|
+
/**
|
|
778
|
+
* When true, prevents the user from interacting with the `item`.
|
|
779
|
+
*/
|
|
819
780
|
disabled: {
|
|
820
781
|
type: Boolean,
|
|
821
782
|
required: false
|
|
822
783
|
}
|
|
823
784
|
};
|
|
785
|
+
const comboboxItemEmits = {
|
|
786
|
+
/**
|
|
787
|
+
* Event handler called when the selecting item. <br>
|
|
788
|
+
* It can be prevented by calling `event.preventDefault`.
|
|
789
|
+
*/
|
|
790
|
+
select: (_ev) => true
|
|
791
|
+
};
|
|
824
792
|
const [injectComboboxItemContext, provideComboboxItemContext] = createContext("DestylerComboboxItem");
|
|
825
|
-
const
|
|
793
|
+
const ComboboxItem = defineComponent({
|
|
826
794
|
name: "DestylerComboboxItem",
|
|
827
|
-
props:
|
|
828
|
-
emits:
|
|
795
|
+
props: comboboxItemProps,
|
|
796
|
+
emits: comboboxItemEmits,
|
|
829
797
|
setup(props, { emit }) {
|
|
830
798
|
const { disabled } = toRefs(props);
|
|
831
799
|
const rootContext = injectComboboxRootContext();
|
|
832
800
|
injectComboboxGroupContext({ id: "", options: ref([]) });
|
|
833
801
|
const { forwardRef } = useForwardExpose();
|
|
834
802
|
const isSelected = computed(
|
|
835
|
-
() => rootContext.multiple.value && Array.isArray(rootContext.modelValue.value) ? rootContext.modelValue.value?.
|
|
803
|
+
() => rootContext.multiple.value && Array.isArray(rootContext.modelValue.value) ? rootContext.modelValue.value?.some((val) => isEqual(val, props.value)) : isEqual(rootContext.modelValue?.value, props.value)
|
|
836
804
|
);
|
|
837
805
|
const isFocused = computed(() => isEqual(rootContext.selectedValue.value, props.value));
|
|
838
|
-
const textId = useId();
|
|
806
|
+
const textId = useId(void 0, "destyler-combobox-item");
|
|
839
807
|
const isInOption = computed(() => rootContext.isUserInputted.value ? rootContext.searchTerm.value === "" || !!rootContext.filteredOptions.value.find((i) => isEqual(i, props.value)) : true);
|
|
840
808
|
async function handleSelect(ev) {
|
|
841
809
|
emit("select", ev);
|
|
@@ -875,9 +843,9 @@ const DestylerComboboxItem = defineComponent({
|
|
|
875
843
|
};
|
|
876
844
|
},
|
|
877
845
|
render() {
|
|
878
|
-
return h(
|
|
846
|
+
return h(CollectionItem, null, {
|
|
879
847
|
default: () => {
|
|
880
|
-
return h(
|
|
848
|
+
return h(Primitive, {
|
|
881
849
|
"ref": (el) => this.forwardRef(el),
|
|
882
850
|
"role": "option",
|
|
883
851
|
"tabindex": "-1",
|
|
@@ -905,21 +873,19 @@ const DestylerComboboxItem = defineComponent({
|
|
|
905
873
|
}
|
|
906
874
|
});
|
|
907
875
|
|
|
908
|
-
const
|
|
876
|
+
const comboboxItemIndicatorProps = {
|
|
877
|
+
...primitiveProps,
|
|
878
|
+
/**
|
|
879
|
+
* @default span
|
|
880
|
+
*/
|
|
909
881
|
as: {
|
|
910
|
-
|
|
911
|
-
required: false,
|
|
882
|
+
...primitiveProps.as,
|
|
912
883
|
default: "span"
|
|
913
|
-
},
|
|
914
|
-
asChild: {
|
|
915
|
-
type: Boolean,
|
|
916
|
-
required: false,
|
|
917
|
-
default: false
|
|
918
884
|
}
|
|
919
885
|
};
|
|
920
|
-
const
|
|
886
|
+
const ComboboxItemIndicator = defineComponent({
|
|
921
887
|
name: "DestylerComboboxItemIndicator",
|
|
922
|
-
props:
|
|
888
|
+
props: comboboxItemIndicatorProps,
|
|
923
889
|
setup() {
|
|
924
890
|
useForwardExpose();
|
|
925
891
|
const itemContext = injectComboboxItemContext();
|
|
@@ -929,7 +895,7 @@ const DestylerComboboxItemIndicator = defineComponent({
|
|
|
929
895
|
},
|
|
930
896
|
render() {
|
|
931
897
|
if (this.itemContext.isSelected.value) {
|
|
932
|
-
return h(
|
|
898
|
+
return h(Primitive, mergeProps(this.$props, {
|
|
933
899
|
"aria-hidden": ""
|
|
934
900
|
}), {
|
|
935
901
|
default: () => this.$slots.default?.()
|
|
@@ -938,25 +904,19 @@ const DestylerComboboxItemIndicator = defineComponent({
|
|
|
938
904
|
}
|
|
939
905
|
});
|
|
940
906
|
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
},
|
|
947
|
-
asChild: {
|
|
948
|
-
type: Boolean,
|
|
949
|
-
required: false,
|
|
950
|
-
default: false
|
|
951
|
-
},
|
|
907
|
+
const comboboxLabelProps = {
|
|
908
|
+
...primitiveProps,
|
|
909
|
+
/**
|
|
910
|
+
* The id of the element the label is associated with.
|
|
911
|
+
*/
|
|
952
912
|
for: {
|
|
953
913
|
type: String,
|
|
954
914
|
required: false
|
|
955
915
|
}
|
|
956
916
|
};
|
|
957
|
-
const
|
|
917
|
+
const ComboboxLabel = defineComponent({
|
|
958
918
|
name: "DestylerComboboxLabel",
|
|
959
|
-
props:
|
|
919
|
+
props: comboboxLabelProps,
|
|
960
920
|
setup() {
|
|
961
921
|
useForwardExpose();
|
|
962
922
|
const groupContext = injectComboboxGroupContext({ id: "" });
|
|
@@ -965,7 +925,7 @@ const DestylerComboboxLabel = defineComponent({
|
|
|
965
925
|
};
|
|
966
926
|
},
|
|
967
927
|
render() {
|
|
968
|
-
return withDirectives(h(
|
|
928
|
+
return withDirectives(h(Primitive, this.$props, {
|
|
969
929
|
default: () => this.$slots.default?.()
|
|
970
930
|
}), [
|
|
971
931
|
[BindOnceDirective, { id: this.groupContext.id }]
|
|
@@ -973,77 +933,55 @@ const DestylerComboboxLabel = defineComponent({
|
|
|
973
933
|
}
|
|
974
934
|
});
|
|
975
935
|
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
type: [String, Object],
|
|
979
|
-
required: false,
|
|
980
|
-
default: "body"
|
|
981
|
-
},
|
|
982
|
-
disabled: {
|
|
983
|
-
type: Boolean,
|
|
984
|
-
required: false,
|
|
985
|
-
default: false
|
|
986
|
-
},
|
|
987
|
-
forceMount: {
|
|
988
|
-
type: Boolean,
|
|
989
|
-
required: false,
|
|
990
|
-
default: false
|
|
991
|
-
}
|
|
936
|
+
const comboboxPortalProps = {
|
|
937
|
+
...teleportPrimitiveProps
|
|
992
938
|
};
|
|
993
|
-
const
|
|
939
|
+
const ComboboxPortal = defineComponent({
|
|
994
940
|
name: "DestylerComboboxPortal",
|
|
995
|
-
props:
|
|
941
|
+
props: comboboxPortalProps,
|
|
996
942
|
render() {
|
|
997
|
-
return h(
|
|
943
|
+
return h(TeleportPrimitive, this.$props, {
|
|
998
944
|
default: () => this.$slots.default?.()
|
|
999
945
|
});
|
|
1000
946
|
}
|
|
1001
947
|
});
|
|
1002
948
|
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
type: [String, Object],
|
|
1006
|
-
required: false,
|
|
1007
|
-
default: "div"
|
|
1008
|
-
},
|
|
1009
|
-
asChild: {
|
|
1010
|
-
type: Boolean,
|
|
1011
|
-
required: false,
|
|
1012
|
-
default: false
|
|
1013
|
-
}
|
|
949
|
+
const comboboxSeparatorProps = {
|
|
950
|
+
...primitiveProps
|
|
1014
951
|
};
|
|
1015
|
-
const
|
|
952
|
+
const ComboboxSeparator = defineComponent({
|
|
1016
953
|
name: "DestylerComboboxSeparator",
|
|
1017
|
-
props:
|
|
954
|
+
props: comboboxSeparatorProps,
|
|
1018
955
|
setup() {
|
|
1019
956
|
useForwardExpose();
|
|
1020
957
|
},
|
|
1021
958
|
render() {
|
|
1022
|
-
return h(
|
|
959
|
+
return h(Primitive, mergeProps(this.$props, {
|
|
1023
960
|
"aria-hidden": ""
|
|
1024
|
-
}));
|
|
961
|
+
}), () => this.$slots.default?.());
|
|
1025
962
|
}
|
|
1026
963
|
});
|
|
1027
964
|
|
|
1028
|
-
const
|
|
965
|
+
const comboboxTriggerProps = {
|
|
966
|
+
...primitiveProps,
|
|
967
|
+
/**
|
|
968
|
+
* @default button
|
|
969
|
+
*/
|
|
1029
970
|
as: {
|
|
1030
|
-
|
|
1031
|
-
required: false,
|
|
971
|
+
...primitiveProps.as,
|
|
1032
972
|
default: "button"
|
|
1033
973
|
},
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
default: false
|
|
1038
|
-
},
|
|
974
|
+
/**
|
|
975
|
+
* When `true`, prevents the user from interacting with item.
|
|
976
|
+
*/
|
|
1039
977
|
disabled: {
|
|
1040
978
|
type: Boolean,
|
|
1041
979
|
required: false
|
|
1042
980
|
}
|
|
1043
981
|
};
|
|
1044
|
-
const
|
|
982
|
+
const ComboboxTrigger = defineComponent({
|
|
1045
983
|
name: "DestylerComboboxTrigger",
|
|
1046
|
-
props:
|
|
984
|
+
props: comboboxTriggerProps,
|
|
1047
985
|
setup(props) {
|
|
1048
986
|
useForwardExpose();
|
|
1049
987
|
const rootContext = injectComboboxRootContext();
|
|
@@ -1054,7 +992,7 @@ const DestylerComboboxTrigger = defineComponent({
|
|
|
1054
992
|
};
|
|
1055
993
|
},
|
|
1056
994
|
render() {
|
|
1057
|
-
return h(
|
|
995
|
+
return h(Primitive, mergeProps(this.$props, {
|
|
1058
996
|
"type": this.$props.as === "button" ? "button" : void 0,
|
|
1059
997
|
"tabindex": "-1",
|
|
1060
998
|
"aria-label": "Show popup",
|
|
@@ -1074,21 +1012,20 @@ const DestylerComboboxTrigger = defineComponent({
|
|
|
1074
1012
|
}
|
|
1075
1013
|
});
|
|
1076
1014
|
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
required: false,
|
|
1086
|
-
default: false
|
|
1015
|
+
const comboboxViewportProps = {
|
|
1016
|
+
...primitiveProps,
|
|
1017
|
+
/**
|
|
1018
|
+
* Will add `nonce` attribute to the style tag which can be used by Content Security Policy.
|
|
1019
|
+
*/
|
|
1020
|
+
nonce: {
|
|
1021
|
+
type: String,
|
|
1022
|
+
required: false
|
|
1087
1023
|
}
|
|
1088
1024
|
};
|
|
1089
|
-
const
|
|
1025
|
+
const ComboboxViewport = defineComponent({
|
|
1090
1026
|
name: "DestylerComboboxViewport",
|
|
1091
|
-
props:
|
|
1027
|
+
props: comboboxViewportProps,
|
|
1028
|
+
inheritAttrs: false,
|
|
1092
1029
|
setup() {
|
|
1093
1030
|
const { forwardRef } = useForwardExpose();
|
|
1094
1031
|
return {
|
|
@@ -1097,7 +1034,7 @@ const DestylerComboboxViewport = defineComponent({
|
|
|
1097
1034
|
},
|
|
1098
1035
|
render() {
|
|
1099
1036
|
return [
|
|
1100
|
-
h(
|
|
1037
|
+
h(Primitive, mergeProps(this.$attrs, this.$props, {
|
|
1101
1038
|
"ref": (el) => this.forwardRef(el),
|
|
1102
1039
|
"data-destyler-combobox-viewport": "",
|
|
1103
1040
|
"role": "presentation",
|
|
@@ -1106,26 +1043,23 @@ const DestylerComboboxViewport = defineComponent({
|
|
|
1106
1043
|
flex: 1,
|
|
1107
1044
|
overflow: "auto"
|
|
1108
1045
|
}
|
|
1109
|
-
},
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
`
|
|
1126
|
-
})
|
|
1046
|
+
}), () => this.$slots.default?.()),
|
|
1047
|
+
h(Primitive, {
|
|
1048
|
+
as: "style",
|
|
1049
|
+
nonce: this.$props.nonce
|
|
1050
|
+
}, () => `
|
|
1051
|
+
/* Hide scrollbars cross-browser and enable momentum scroll for touch devices */
|
|
1052
|
+
[data-destyler-combobox-viewport] {
|
|
1053
|
+
scrollbar-width:none;
|
|
1054
|
+
-ms-overflow-style: none;
|
|
1055
|
+
-webkit-overflow-scrolling: touch;
|
|
1056
|
+
}
|
|
1057
|
+
[data-destyler-combobox-viewport]::-webkit-scrollbar {
|
|
1058
|
+
display: none;
|
|
1059
|
+
}
|
|
1060
|
+
`)
|
|
1127
1061
|
];
|
|
1128
1062
|
}
|
|
1129
1063
|
});
|
|
1130
1064
|
|
|
1131
|
-
export {
|
|
1065
|
+
export { ComboboxAnchor, ComboboxArrow, ComboboxCancel, ComboboxContent, ComboboxContentImpl, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxSeparator, ComboboxTrigger, ComboboxViewport, comboboxAnchorProps, comboboxArrowProps, comboboxCancelProps, comboboxContentEmits, comboboxContentImplEmits, comboboxContentImplProps, comboboxContentProps, comboboxEmptyProps, comboboxGroupProps, comboboxInputProps, comboboxItemEmits, comboboxItemIndicatorProps, comboboxItemProps, comboboxLabelProps, comboboxPortalProps, comboboxRootEmits, comboboxRootProps, comboboxSeparatorProps, comboboxTriggerProps, comboboxViewportProps };
|