@wallarm-org/design-system 0.66.2 → 0.66.3
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.
|
@@ -12,10 +12,19 @@ interface UseValueMenuDisplayValuesOptions {
|
|
|
12
12
|
highlightValue?: ConditionValue;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Compose the dropdown list
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* Compose the dropdown list.
|
|
16
|
+
*
|
|
17
|
+
* Single-select: pins the selected entry at the top so it is immediately
|
|
18
|
+
* visible even when the list is long.
|
|
19
|
+
*
|
|
20
|
+
* Multi-select: keeps the original `filteredValues` order so selecting an
|
|
21
|
+
* item does not cause the list to jump. Only checked items that are absent
|
|
22
|
+
* from `filteredValues` (e.g. after `values` narrowed via dynamic
|
|
23
|
+
* getSuggestions) are prepended at the top so they remain accessible.
|
|
24
|
+
*
|
|
25
|
+
* Remembers every option ever rendered so a narrowed `values` can still
|
|
26
|
+
* display the selected label/badge; fabricates a plain-text option as last
|
|
27
|
+
* resort.
|
|
19
28
|
*/
|
|
20
29
|
export declare const useValueMenuDisplayValues: ({ values, filteredValues, multiSelect, checkedValues, highlightValue, }: UseValueMenuDisplayValuesOptions) => ValueOption[];
|
|
21
30
|
export {};
|
|
@@ -11,6 +11,20 @@ const useValueMenuDisplayValues = ({ values, filteredValues, multiSelect, checke
|
|
|
11
11
|
highlightValue
|
|
12
12
|
] : [];
|
|
13
13
|
if (0 === selectedList.length) return filteredValues;
|
|
14
|
+
if (multiSelect) {
|
|
15
|
+
const filteredSet = new Set(filteredValues.map((v)=>String(v.value)));
|
|
16
|
+
const orphaned = selectedList.filter((v)=>!filteredSet.has(String(v))).map((v)=>{
|
|
17
|
+
const key = String(v);
|
|
18
|
+
return values.find((opt)=>String(opt.value) === key) ?? optionMemoryRef.current.get(key) ?? {
|
|
19
|
+
value: v,
|
|
20
|
+
label: key
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
return orphaned.length > 0 ? [
|
|
24
|
+
...orphaned,
|
|
25
|
+
...filteredValues
|
|
26
|
+
] : filteredValues;
|
|
27
|
+
}
|
|
14
28
|
const selectedSet = new Set(selectedList.map(String));
|
|
15
29
|
const selectedItems = selectedList.map((v)=>{
|
|
16
30
|
const key = String(v);
|