@signal24/vue-foundation 4.25.6 → 4.25.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.25.6",
4
+ "version": "4.25.7",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -111,8 +111,7 @@ const searchField = ref<HTMLInputElement>();
111
111
  const optionsContainer = ref<HTMLDivElement>();
112
112
 
113
113
  const isLoading = ref(false);
114
- const isLoaded = ref(false);
115
- const loadedOptions = ref<T[]>();
114
+ const remoteOptions = ref<T[]>();
116
115
  const isSearching = ref(false);
117
116
  const searchText = ref('');
118
117
  const selectedOption = ref<T | null>(null);
@@ -122,9 +121,12 @@ const highlightedOptionKey = ref<string | symbol | null>(null);
122
121
  const shouldShowCreateOption = ref(false);
123
122
  const shouldShowCreateTextOnNewItem = computed(() => props.showCreateTextOnNewItem ?? true);
124
123
 
124
+ const isLoaded = computed(() => !!(props.options || remoteOptions.value));
125
+ const loadedOptions = computed(() => props.options ?? remoteOptions.value ?? []);
126
+
125
127
  const effectivePrependOptions = computed(() => props.prependOptions ?? []);
126
128
  const effectiveAppendOptions = computed(() => props.appendOptions ?? []);
127
- const effectiveDisabled = computed(() => !!props.disabled || (!props.options && !loadedOptions.value));
129
+ const effectiveDisabled = computed(() => !!props.disabled || !isLoaded.value);
128
130
  const effectivePlaceholder = computed(() => {
129
131
  if (!isLoaded.value && props.preload) return 'Loading...';
130
132
  if (props.nullTitle) return props.nullTitle;
@@ -158,7 +160,7 @@ const effectiveSelectionFormatter = computed(() => {
158
160
  return effectiveFormatter.value;
159
161
  });
160
162
 
161
- const allOptions = computed(() => [...effectivePrependOptions.value, ...(loadedOptions.value ?? []), ...effectiveAppendOptions.value]);
163
+ const allOptions = computed(() => [...effectivePrependOptions.value, ...loadedOptions.value, ...effectiveAppendOptions.value]);
162
164
  const isGrouped = computed(() => !!(props.groupField || props.groupFormatter));
163
165
 
164
166
  const optionsDescriptors = computed(() => {
@@ -254,13 +256,6 @@ const groupedOptions = computed(() => {
254
256
 
255
257
  // watch props
256
258
  watch(() => props.modelValue, handleValueChanged);
257
- watch(
258
- () => props.options,
259
- () => {
260
- loadedOptions.value = props.options;
261
- isLoaded.value = true;
262
- }
263
- );
264
259
 
265
260
  // watch data
266
261
 
@@ -306,10 +301,7 @@ watch(effectiveOptions, () => {
306
301
  onMounted(async () => {
307
302
  shouldShowCreateOption.value = props.onCreateItem !== undefined;
308
303
 
309
- if (props.options) {
310
- loadedOptions.value = [...props.options];
311
- isLoaded.value = true;
312
- } else if (props.loadOptions && props.preload) {
304
+ if (props.loadOptions && props.preload) {
313
305
  await loadRemoteOptions();
314
306
  }
315
307
 
@@ -341,15 +333,14 @@ onBeforeUnmount(() => {
341
333
 
342
334
  async function loadRemoteOptions() {
343
335
  await reloadOptions();
344
- if (loadedOptions.value) emit('optionsLoaded', loadedOptions.value);
336
+ if (remoteOptions.value) emit('optionsLoaded', remoteOptions.value);
345
337
  }
346
338
 
347
339
  async function reloadOptions() {
348
340
  const effectiveSearchText = props.remoteSearch && isSearching.value && searchText.value.length ? searchText.value : null;
349
341
  isLoading.value = true;
350
- loadedOptions.value = (await props.loadOptions?.(effectiveSearchText)) ?? [];
342
+ remoteOptions.value = (await props.loadOptions?.(effectiveSearchText)) ?? [];
351
343
  isLoading.value = false;
352
- isLoaded.value = true;
353
344
  }
354
345
 
355
346
  function reloadOptionsIfSearching() {
@@ -575,7 +566,7 @@ function handleValueChanged() {
575
566
  }
576
567
 
577
568
  function addRemoteOption(option: T) {
578
- loadedOptions.value!.unshift(option);
569
+ remoteOptions.value!.unshift(option);
579
570
  }
580
571
 
581
572
  function focusNextInput() {