combobox: improve props, fix placement with scroll
This commit is contained in:
17
src/lib/util.ts
Normal file
17
src/lib/util.ts
Normal 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}`;
|
||||
};
|
||||
Reference in New Issue
Block a user