@v-c/util 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useId.d.ts +8 -0
- package/dist/hooks/useId.js +4 -1
- package/package.json +1 -1
package/dist/hooks/useId.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export default function (id?: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Generate a valid HTML id from prefix and key.
|
|
4
|
+
* Sanitizes the key by replacing invalid characters with hyphens.
|
|
5
|
+
* @param prefix - The prefix for the id
|
|
6
|
+
* @param key - The key from React element, may contain spaces or invalid characters
|
|
7
|
+
* @returns A valid HTML id string
|
|
8
|
+
*/
|
|
9
|
+
export declare function getId(prefix: string, key: string): string;
|
package/dist/hooks/useId.js
CHANGED
|
@@ -9,4 +9,7 @@ function useId_default(id) {
|
|
|
9
9
|
if (process.env.NODE_ENV === "test") return "test-id";
|
|
10
10
|
return vueId;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
function getId(prefix, key) {
|
|
13
|
+
return `${prefix}-${key.replace(/[^a-zA-Z0-9_.:-]/g, "-")}`;
|
|
14
|
+
}
|
|
15
|
+
export { useId_default as default, getId };
|