@vue-widget/hooks
Version:
hooks from react to vue
27 lines (26 loc) • 703 B
JavaScript
import { ref } from "vue";
var uuid = 0;
/** Is client side and not jsdom */
export var isBrowserClient = !!(typeof window !== "undefined" &&
window.document &&
window.document.createElement);
/** Get unique id for accessibility usage */
export function getUUID() {
var retId;
// Test never reach
/* istanbul ignore if */
if (isBrowserClient) {
retId = uuid;
uuid += 1;
}
else {
retId = "TEST_OR_SSR";
}
return retId;
}
export function useId(id) {
if (id === void 0) { id = ref(""); }
// Inner id for accessibility usage. Only work in client side
var innerId = "rv_unique_".concat(getUUID());
return id.value || innerId;
}