combobox: improve props, fix placement with scroll

This commit is contained in:
Elijah Duffy
2025-07-03 10:57:21 -07:00
parent f2994abad2
commit a307ffee92
6 changed files with 60 additions and 37 deletions

17
src/lib/util.ts Normal file
View File

@@ -0,0 +1,17 @@
/**
* Generates a unique identifier string unless an identifier is provided.
* If a prefix is provided, it will be prepended to the identifier.
* The identifier is a combination of a random part and a timestamp.
*
* @param {string} [prefix] - Optional prefix to prepend to the identifier.
* @param {string} [identifier] - Optional identifier to use instead of generating a new one.
* @returns {string} - A unique identifier string.
*/
export const generateIdentifier = (prefix?: string, identifier?: string): string => {
if (identifier) {
return `${prefix ? prefix + '-' : ''}${identifier}`;
}
const randomPart = Math.random().toString(36).substring(2, 10);
const timestampPart = Date.now().toString(36);
return `${prefix ? prefix + '-' : ''}${randomPart}-${timestampPart}`;
};