2024-07-25 01:28:55 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
StringEntryObject,
|
|
|
|
|
collectObjectValuesForKey,
|
|
|
|
|
} from "../../Model/Utility/utility";
|
|
|
|
|
|
|
|
|
|
export function PropertyValueList<T>(
|
|
|
|
|
propertyKey: string,
|
|
|
|
|
stringEntryObjectConverter: (object: T) => StringEntryObject,
|
|
|
|
|
objects: React.ListState<T> | React.MapState<T>,
|
2024-07-25 04:12:30 +02:00
|
|
|
viewBuilder: (keys: React.ListState<string>) => HTMLElement
|
2024-07-25 01:28:55 +02:00
|
|
|
) {
|
|
|
|
|
const propertyValues: React.ListState<string> = new React.ListState();
|
|
|
|
|
|
|
|
|
|
function collectValues() {
|
|
|
|
|
propertyValues.clear();
|
|
|
|
|
const values: string[] = collectObjectValuesForKey(
|
|
|
|
|
propertyKey,
|
|
|
|
|
stringEntryObjectConverter,
|
|
|
|
|
[...objects.value.values()]
|
|
|
|
|
);
|
|
|
|
|
propertyValues.add(...values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
objects.subscribe(() => {
|
|
|
|
|
collectValues();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return viewBuilder(propertyValues);
|
|
|
|
|
}
|