@volverjs/ui-vue 0.0.9-beta.10 → 0.0.9-beta.12

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.
@@ -105,7 +105,7 @@
105
105
  expanded.value = false
106
106
  }
107
107
  const onAfterExpand = () => {
108
- if (searchable.value) {
108
+ if (propsDefaults.value.searchable) {
109
109
  if (inputSearchEl.value) {
110
110
  inputSearchEl.value.focus({
111
111
  preventScroll: true,
@@ -114,7 +114,7 @@
114
114
  }
115
115
  }
116
116
  const onAfterCollapse = () => {
117
- if (searchable.value) {
117
+ if (propsDefaults.value.searchable) {
118
118
  searchText.value = ''
119
119
  }
120
120
  }
@@ -131,7 +131,6 @@
131
131
  valid,
132
132
  invalid,
133
133
  floating,
134
- searchable,
135
134
  } = toRefs(props)
136
135
  const hasId = useUniqueId(id)
137
136
  const hasHintId = computed(() => `${hasId.value}-hint`)
@@ -139,6 +138,10 @@
139
138
  const hasSearchId = computed(() => `${hasId.value}-search`)
140
139
  const hasLabelId = computed(() => `${hasId.value}-label`)
141
140
 
141
+ // loading
142
+ const localLoading = ref(false)
143
+ const isLoading = computed(() => localLoading.value || loading.value)
144
+
142
145
  // ref
143
146
  const dropdownEl = ref()
144
147
 
@@ -162,7 +165,7 @@
162
165
  modifiers,
163
166
  computed(() => ({
164
167
  disabled: disabled.value,
165
- loading: loading.value,
168
+ loading: isLoading.value,
166
169
  readonly: readonly.value,
167
170
  'icon-before': Boolean(hasIconBefore.value),
168
171
  'icon-after': Boolean(hasIconAfter.value),
@@ -183,12 +186,17 @@
183
186
  } = useOptions(props)
184
187
 
185
188
  // options filtered by search text
186
- const filteredOptions = computed(() => {
189
+ const filteredOptions = computedAsync(async () => {
187
190
  if (propsDefaults.value.searchFunction) {
188
- return propsDefaults.value.searchFunction(
189
- debouncedSearchText.value,
190
- props.options,
191
+ localLoading.value = true
192
+ const toReturn = await Promise.resolve(
193
+ propsDefaults.value.searchFunction(
194
+ debouncedSearchText.value,
195
+ props.options,
196
+ ),
191
197
  )
198
+ localLoading.value = false
199
+ return toReturn
192
200
  }
193
201
  return props.options?.filter((option) => {
194
202
  return getOptionLabel(option)
@@ -310,7 +318,7 @@
310
318
  invalid: invalid.value,
311
319
  invalidLabel: propsDefaults.value.invalidLabel,
312
320
  hintLabel: propsDefaults.value.hintLabel,
313
- loading: loading.value,
321
+ loading: isLoading.value,
314
322
  loadingLabel: propsDefaults.value.loadingLabel,
315
323
  disabled: disabled.value,
316
324
  readonly: readonly.value,
@@ -339,7 +347,7 @@
339
347
  flip: propsDefaults.value.flip,
340
348
  autoPlacement: propsDefaults.value.autoPlacement,
341
349
  arrow: propsDefaults.value.arrow,
342
- autofocusFirst: searchable.value
350
+ autofocusFirst: propsDefaults.value.searchable
343
351
  ? true
344
352
  : propsDefaults.value.autofocusFirst,
345
353
  triggerWidth: propsDefaults.value.triggerWidth,
@@ -375,7 +383,7 @@
375
383
  <label
376
384
  v-if="label"
377
385
  :id="hasLabelId"
378
- :for="searchable ? hasSearchId : undefined"
386
+ :for="propsDefaults.searchable ? hasSearchId : undefined"
379
387
  >
380
388
  {{ label }}
381
389
  </label>
@@ -389,13 +397,15 @@
389
397
  @after-collapse="onAfterCollapse"
390
398
  >
391
399
  <template
392
- v-if="searchable || $slots['dropdown::before']"
400
+ v-if="
401
+ propsDefaults.searchable || $slots['dropdown::before']
402
+ "
393
403
  #before
394
404
  >
395
405
  <!-- @slot Slot before dropdown items -->
396
406
  <slot name="dropdown::before" />
397
407
  <input
398
- v-if="searchable"
408
+ v-if="propsDefaults.searchable && !disabled"
399
409
  :id="hasSearchId"
400
410
  ref="inputSearchEl"
401
411
  v-model="searchText"
@@ -489,7 +499,7 @@
489
499
  </div>
490
500
  </template>
491
501
  <template #items>
492
- <template v-if="filteredOptions.length">
502
+ <template v-if="!disabled && filteredOptions?.length">
493
503
  <template
494
504
  v-for="(option, index) in filteredOptions"
495
505
  :key="index"
@@ -571,7 +581,7 @@
571
581
  {{ propsDefaults.noOptionsLabel }}
572
582
  </slot>
573
583
  </VvDropdownOption>
574
- <VvDropdownOption v-else modifiers="inert">
584
+ <VvDropdownOption v-else-if="!disabled" modifiers="inert">
575
585
  <!-- @slot Slot for no results available -->
576
586
  <slot name="no-results">
577
587
  {{ propsDefaults.noResultsLabel }}
@@ -98,8 +98,8 @@ export const VvComboboxProps = {
98
98
  type: Function as PropType<
99
99
  (
100
100
  search: string,
101
- options?: (Option | string)[],
102
- ) => (Option | string)[]
101
+ options: (Option | string)[],
102
+ ) => (Option | string)[] | Promise<(Option | string)[]>
103
103
  >,
104
104
  default: undefined,
105
105
  },
@@ -62,7 +62,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
62
62
  }
63
63
 
64
64
  // select second value
65
- if (args.options.length > 1) {
65
+ if (args.options && args.options.length > 1) {
66
66
  await expect(dropdownSecondItem).toBeClicked()
67
67
  await sleep()
68
68
  const secondValue = getOptionValue(