fds-vue-core 7.1.1 → 7.1.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.
@@ -11606,6 +11606,9 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
11606
11606
  syncSelectedItemsWithItems();
11607
11607
  }
11608
11608
  filterAndPaginate();
11609
+ if (!selectedItem.value) {
11610
+ resolveInitialSingleSelection();
11611
+ }
11609
11612
  },
11610
11613
  { immediate: true }
11611
11614
  );
@@ -11743,11 +11746,39 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
11743
11746
  }
11744
11747
  return result;
11745
11748
  };
11746
- const selectItem = (item) => {
11749
+ function selectItem(item) {
11747
11750
  selectedItem.value = item;
11748
11751
  setValidSelectedState();
11749
11752
  emit("searchSelected", item);
11750
- };
11753
+ }
11754
+ function getCandidateMatchValues(item) {
11755
+ if (isDividerItem(item) && !props.dividerSelectable) return [];
11756
+ if (searchFields.value.length > 0) {
11757
+ return searchFields.value.map((key) => String(item[key] ?? "").trim()).filter((value) => value.length > 0);
11758
+ }
11759
+ return [String(item.label ?? item.name ?? "").trim()].filter((value) => value.length > 0);
11760
+ }
11761
+ function resolveInitialSingleSelection() {
11762
+ if (isMultiple.value || !props.initialValue) return;
11763
+ const normalizeForInitialMatch = (value) => {
11764
+ const trimmed = value.trim();
11765
+ if (!trimmed) return "";
11766
+ if (!isPidString(trimmed)) {
11767
+ return trimmed.replace(/-$/, "").toLowerCase();
11768
+ }
11769
+ const digits = trimmed.replace(/\D/g, "");
11770
+ return (digits.length > 8 ? `${digits.substring(0, 8)}-${digits.substring(8)}` : digits).toLowerCase();
11771
+ };
11772
+ const normalizedInitialValue = normalizeForInitialMatch(props.initialValue);
11773
+ if (!normalizedInitialValue) return;
11774
+ const initialMatch = sourceItems.value.find(
11775
+ (item) => getCandidateMatchValues(item).some((value) => normalizeForInitialMatch(value) === normalizedInitialValue)
11776
+ );
11777
+ if (!initialMatch) return;
11778
+ const firstField = searchFields.value[0];
11779
+ searchTerm.value = (firstField ? String(initialMatch[firstField] ?? "") : props.initialValue).trim();
11780
+ selectItem(initialMatch);
11781
+ }
11751
11782
  const getHierarchyLevel = (item) => {
11752
11783
  const level = Number(item[props.levelField] ?? 0);
11753
11784
  return Number.isFinite(level) && level >= 0 ? level : 0;
@@ -11957,7 +11988,10 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
11957
11988
  vue.onMounted(() => {
11958
11989
  if (props.initialValue) {
11959
11990
  searchTerm.value = props.initialValue;
11960
- setValidSelectedState();
11991
+ resolveInitialSingleSelection();
11992
+ if (!selectedItem.value) {
11993
+ setValidSelectedState();
11994
+ }
11961
11995
  }
11962
11996
  window.addEventListener("mouseup", onClickOutside);
11963
11997
  vue.nextTick(() => {