fds-vue-core 5.0.2 → 5.1.0
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/fds-vue-core.cjs.js +56 -6
- package/dist/fds-vue-core.cjs.js.map +1 -1
- package/dist/fds-vue-core.es.js +56 -6
- package/dist/fds-vue-core.es.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FdsSearchSelectPro/FdsSearchSelectPro.stories.ts +1 -0
- package/src/components/FdsSearchSelectPro/FdsSearchSelectPro.vue +7 -5
- package/src/components/FdsSearchSelectPro/types.ts +5 -0
- package/src/components/FdsSearchSelectPro/useSearchSelectProItems.ts +65 -4
package/dist/fds-vue-core.cjs.js
CHANGED
|
@@ -10549,14 +10549,61 @@ const useSearchSelectProItems = ({
|
|
|
10549
10549
|
}
|
|
10550
10550
|
return "";
|
|
10551
10551
|
};
|
|
10552
|
+
const reorderExplicitDividerGroups = (items, locale) => {
|
|
10553
|
+
const dividerLabelField = searchFields.value[0] ?? "label";
|
|
10554
|
+
const unspecifiedGroupKey = "__UNSPECIFIED__";
|
|
10555
|
+
const defaultUnspecifiedLabel = locale === "sv" ? "Ospecificerat" : "Unspecified";
|
|
10556
|
+
const unspecifiedLabel = String(props.unspecifiedLabel ?? "").trim() || defaultUnspecifiedLabel;
|
|
10557
|
+
const groups = [];
|
|
10558
|
+
let current = {
|
|
10559
|
+
divider: null,
|
|
10560
|
+
children: [],
|
|
10561
|
+
label: "",
|
|
10562
|
+
unspecified: false
|
|
10563
|
+
};
|
|
10564
|
+
const flush = () => {
|
|
10565
|
+
if (current.divider || current.children.length) groups.push(current);
|
|
10566
|
+
};
|
|
10567
|
+
items.forEach((item) => {
|
|
10568
|
+
if (isDividerItem(item)) {
|
|
10569
|
+
flush();
|
|
10570
|
+
const raw = String(item[dividerLabelField] ?? item.label ?? item.name ?? "").trim();
|
|
10571
|
+
const isUnspecified = !raw || raw === unspecifiedGroupKey;
|
|
10572
|
+
current = {
|
|
10573
|
+
divider: item,
|
|
10574
|
+
children: [],
|
|
10575
|
+
label: isUnspecified ? unspecifiedLabel : raw,
|
|
10576
|
+
unspecified: isUnspecified
|
|
10577
|
+
};
|
|
10578
|
+
} else {
|
|
10579
|
+
current.children.push(item);
|
|
10580
|
+
}
|
|
10581
|
+
});
|
|
10582
|
+
flush();
|
|
10583
|
+
const [prefix, ...rest] = groups;
|
|
10584
|
+
rest.sort((a, b) => {
|
|
10585
|
+
if (a.unspecified && !b.unspecified) return 1;
|
|
10586
|
+
if (b.unspecified && !a.unspecified) return -1;
|
|
10587
|
+
return a.label.localeCompare(b.label, locale);
|
|
10588
|
+
});
|
|
10589
|
+
const ordered = prefix ? [prefix, ...rest] : rest;
|
|
10590
|
+
return ordered.flatMap((g) => g.divider ? [g.divider, ...g.children] : [...g.children]);
|
|
10591
|
+
};
|
|
10552
10592
|
const sourceItems = vue.computed(() => {
|
|
10553
10593
|
const baseItems = props.items ?? [];
|
|
10554
10594
|
const groupField = props.autoDividerBy;
|
|
10555
|
-
if (!groupField)
|
|
10595
|
+
if (!groupField) {
|
|
10596
|
+
const dividerField2 = props.dividerField ?? "isDivider";
|
|
10597
|
+
const hasExplicitDividers = baseItems.some((item) => item[dividerField2] === true || item.type === "divider");
|
|
10598
|
+
if (!hasExplicitDividers) return baseItems;
|
|
10599
|
+
const locale2 = props.locale === "sv" ? "sv" : "en";
|
|
10600
|
+
return reorderExplicitDividerGroups(baseItems, locale2);
|
|
10601
|
+
}
|
|
10556
10602
|
const dividerField = props.dividerField ?? "isDivider";
|
|
10557
10603
|
const levelField = props.levelField ?? "level";
|
|
10558
|
-
const locale = props.locale === "
|
|
10559
|
-
const
|
|
10604
|
+
const locale = props.locale === "sv" ? "sv" : "en";
|
|
10605
|
+
const defaultUnspecifiedLabel = locale === "sv" ? "Ospecificerat" : "Unspecified";
|
|
10606
|
+
const unspecifiedLabel = String(props.unspecifiedLabel ?? "").trim() || defaultUnspecifiedLabel;
|
|
10560
10607
|
const grouped = /* @__PURE__ */ new Map();
|
|
10561
10608
|
const groupLabels = /* @__PURE__ */ new Map();
|
|
10562
10609
|
const unspecifiedGroupKey = "__UNSPECIFIED__";
|
|
@@ -10796,6 +10843,7 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
|
10796
10843
|
noResultPrompt: { default: "" },
|
|
10797
10844
|
maxListHeight: { default: void 0 },
|
|
10798
10845
|
locale: { default: "sv" },
|
|
10846
|
+
unspecifiedLabel: { default: void 0 },
|
|
10799
10847
|
dataTestid: { default: void 0 },
|
|
10800
10848
|
onChange: {},
|
|
10801
10849
|
onClearInput: {},
|
|
@@ -10910,8 +10958,8 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
|
10910
10958
|
});
|
|
10911
10959
|
};
|
|
10912
10960
|
const hasInputValue = vue.computed(() => searchTerm.value.length > 0);
|
|
10913
|
-
const resolvedLoadMoreLabel = vue.computed(() => props.locale === "
|
|
10914
|
-
const resolvedLoadingMoreLabel = vue.computed(() => props.locale === "
|
|
10961
|
+
const resolvedLoadMoreLabel = vue.computed(() => props.locale === "sv" ? "Visa fler" : "Show more");
|
|
10962
|
+
const resolvedLoadingMoreLabel = vue.computed(() => props.locale === "sv" ? "Hämtar fler..." : "Loading more...");
|
|
10915
10963
|
const displayInputValue = vue.computed(() => {
|
|
10916
10964
|
if (!inputHasFocus.value && !hasSelection.value && !searchTerm.value.length && props.displayValue) {
|
|
10917
10965
|
return props.displayValue;
|
|
@@ -11154,7 +11202,9 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
|
11154
11202
|
return selection;
|
|
11155
11203
|
};
|
|
11156
11204
|
const toggleMultipleSelection = (item) => {
|
|
11157
|
-
const itemsToToggle = getRecursiveSelectionItems(item).filter(
|
|
11205
|
+
const itemsToToggle = getRecursiveSelectionItems(item).filter(
|
|
11206
|
+
(candidate) => props.dividerSelectable || !isDividerItem(candidate)
|
|
11207
|
+
);
|
|
11158
11208
|
if (!itemsToToggle.length) return;
|
|
11159
11209
|
const shouldDeselect = isItemSelected(item);
|
|
11160
11210
|
if (shouldDeselect) {
|