diff --git a/package-lock.json b/package-lock.json index a47b7722..f3d3648d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@surfnet/sds", - "version": "0.0.101", + "version": "0.0.102", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@surfnet/sds", - "version": "0.0.101", + "version": "0.0.102", "license": "MIT", "devDependencies": { "@babel/core": "^7.16.0", diff --git a/package.json b/package.json index a596c791..1a5ea308 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@surfnet/sds", - "version": "0.0.101", + "version": "0.0.102", "description": "SURF Design System for React", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/common/utils.ts b/src/common/utils.ts index 935c5127..a157a90a 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -33,5 +33,6 @@ export function sanitize(text: string) { } export function pseudoGuid() { - return (crypto.randomUUID && crypto.randomUUID()) || Math.round((new Date().getTime() * Math.random() * 1000)).toString() + return (crypto.randomUUID && typeof crypto.randomUUID === "function" && crypto.randomUUID()) || + Math.round((new Date().getTime() * Math.random() * 1000)).toString() } diff --git a/src/components/RadioButton/RadioButton.tsx b/src/components/RadioButton/RadioButton.tsx index 52c64f2b..5a34521f 100644 --- a/src/components/RadioButton/RadioButton.tsx +++ b/src/components/RadioButton/RadioButton.tsx @@ -1,6 +1,7 @@ import React, {ChangeEventHandler} from "react"; import Tooltip from "../Tooltip/index"; import "../Tooltip/TooltipParent.scss"; +import {pseudoGuid} from "../../common/utils"; export interface RadioButtonProps { label: string; @@ -15,7 +16,7 @@ export interface RadioButtonProps { } const RadioButton = (props: RadioButtonProps) => { - const id = props.id || crypto.randomUUID(); + const id = props.id || pseudoGuid(); const className = `sds--radio-container ${ props.tooltip ? "sds--tooltip-parent" : "" }`; diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx index 6a8799ca..75d2df5d 100644 --- a/src/components/Tooltip/Tooltip.tsx +++ b/src/components/Tooltip/Tooltip.tsx @@ -2,7 +2,7 @@ import React from "react"; import "./Tooltip.scss"; import {PlacesType, Tooltip as ReactTooltip} from "react-tooltip"; import {ReactComponent as InfoIcon} from "../../icons/functional-icons/info.svg"; -import {sanitize} from "../../common/utils"; +import {pseudoGuid, sanitize} from "../../common/utils"; export interface TooltipProps { tip: string; @@ -12,7 +12,7 @@ export interface TooltipProps { } const Tooltip = (props: React.PropsWithChildren) => { - const uniqueAnchorId = "A" + crypto.randomUUID(); + const uniqueAnchorId = "A" + pseudoGuid(); return (
{props.children ? React.Children.map(props.children, (child: any) => child) : }