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