fixes #2733: Bug where date range is displayed on separate line (#2862)

This commit is contained in:
Amruth Pillai
2026-04-04 12:03:09 +02:00
committed by GitHub
parent 9332e1e3ff
commit 923f5f6173
68 changed files with 2042 additions and 1704 deletions
+23
View File
@@ -0,0 +1,23 @@
type KeyedField<TKey extends string> = {
key: TKey;
};
type KeyValueMap<TKey extends string> = Partial<Record<TKey, string | null | undefined>>;
/**
* Filters keyed field descriptors to only those whose corresponding value in the given
* values object is a non-empty string.
*
* This is useful for rendering or processing only the fields with actual, non-blank content,
* e.g., when displaying optional sections in a UI or assembling objects with present values.
*
* @param values - An object mapping keys to string values (which may be empty, null, or undefined)
* @param fields - Field descriptors with { key: TKey }
* @returns An array of fields whose corresponding values[key] is a non-empty string
*/
export function filterFieldValues<TKey extends string, TField extends KeyedField<TKey>>(
values: KeyValueMap<TKey>,
...fields: TField[]
) {
return fields.filter((field) => Boolean(values[field.key]?.trim()));
}