finish custom class and improved options overhaul

This commit is contained in:
Elijah Duffy
2025-07-03 14:45:23 -07:00
parent c54002f5fa
commit 02311a0e7b
16 changed files with 170 additions and 131 deletions

View File

@@ -15,3 +15,31 @@ export const generateIdentifier = (prefix?: string, identifier?: string): string
const timestampPart = Date.now().toString(36);
return `${prefix ? prefix + '-' : ''}${randomPart}-${timestampPart}`;
};
/**
* Option type definition for a select option. Used in various components.
*/
export type Option =
| {
value: string;
label?: string;
}
| string;
/** getLabel returns the option label if it exists*/
export const getLabel = (option: Option): string => {
if (typeof option === 'string') {
return option;
} else {
return option.label ?? option.value;
}
};
/** getValue returns the option value */
export const getValue = (option: Option): string => {
if (typeof option === 'string') {
return option;
} else {
return option.value;
}
};