@destyler/combobox 0.0.3 → 0.0.5

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