@stonecrop/aform 0.60.1 → 0.60.2

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/dist/aform.js CHANGED
@@ -3182,19 +3182,22 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3182
3182
  const id = linkId(modelValue.value);
3183
3183
  return id !== void 0 && String(option.id) === String(id);
3184
3184
  };
3185
+ let latestSearch = 0;
3185
3186
  const openDropdown = async (text) => {
3186
3187
  if (!__props.filterFunction || __props.mode === "read") return;
3188
+ const search = ++latestSearch;
3187
3189
  activeIndex.value = null;
3188
3190
  dropdownOpen.value = true;
3189
3191
  if (__props.isAsync) loading.value = true;
3192
+ let results;
3190
3193
  try {
3191
- const fn = typeof __props.filterFunction === "string" ? deserializeFunction(__props.filterFunction) : __props.filterFunction;
3192
- dropdownResults.value = await fn(text) ?? [];
3194
+ results = await (typeof __props.filterFunction === "string" ? deserializeFunction(__props.filterFunction) : __props.filterFunction)(text) ?? [];
3193
3195
  } catch {
3194
- dropdownResults.value = [];
3195
- } finally {
3196
- loading.value = false;
3196
+ results = [];
3197
3197
  }
3198
+ if (search !== latestSearch) return;
3199
+ dropdownResults.value = results;
3200
+ loading.value = false;
3198
3201
  };
3199
3202
  const closeDropdown = () => {
3200
3203
  dropdownOpen.value = false;
@@ -3219,17 +3222,21 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3219
3222
  dropdownOpen.value = false;
3220
3223
  activeIndex.value = null;
3221
3224
  };
3225
+ const listShown = () => dropdownOpen.value && !loading.value;
3222
3226
  const selectNext = () => {
3227
+ if (!listShown()) return;
3223
3228
  const len = dropdownResults.value.length;
3224
3229
  if (!len) return;
3225
3230
  activeIndex.value = activeIndex.value === null ? 0 : (activeIndex.value + 1) % len;
3226
3231
  };
3227
3232
  const selectPrev = () => {
3233
+ if (!listShown()) return;
3228
3234
  if (!dropdownResults.value.length) return;
3229
3235
  if (activeIndex.value === null || activeIndex.value === 0) activeIndex.value = null;
3230
3236
  else activeIndex.value -= 1;
3231
3237
  };
3232
3238
  const selectCurrent = () => {
3239
+ if (!listShown()) return;
3233
3240
  if (activeIndex.value !== null && dropdownResults.value[activeIndex.value]) selectOption(dropdownResults.value[activeIndex.value]);
3234
3241
  };
3235
3242
  return (_ctx, _cache) => {
@@ -3307,7 +3314,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3307
3314
  ])) : createCommentVNode("", true)])), [[unref(vOnClickOutside), onClickOutside]]), __props.label && !__props.embedded ? (openBlock(), createElementBlock("label", _hoisted_15, toDisplayString(__props.label), 1)) : createCommentVNode("", true)], 64))], 2);
3308
3315
  };
3309
3316
  }
3310
- }), [["__scopeId", "data-v-cca04ca2"]]);
3317
+ }), [["__scopeId", "data-v-7ea13bc7"]]);
3311
3318
  // src/components/form/ANumericInput.vue?vue&type=script&setup=true&lang.ts
3312
3319
  var _hoisted_1$11 = { class: "aform_form-element" };
3313
3320
  var _hoisted_2$7 = { class: "aform_display-value" };