{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/inline-edit/utils.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\n\nimport { type TypographyVariants } from '../typography';\n\ntype ValidationFunction = (\n  value: string,\n) => Promise<true | string> | true | string;\n\nexport async function validateValue(\n  value: string,\n  validate?: ValidationFunction,\n): Promise<string | null> {\n  if (!validate) {\n    return null;\n  }\n\n  const validation = validate(value);\n\n  let isValid: string | boolean;\n  if (validation instanceof Promise) {\n    isValid = await validation;\n  } else {\n    isValid = validation;\n  }\n\n  if (typeof isValid === 'string') {\n    return isValid;\n  }\n\n  return null;\n}\n\nexport function getIconSizeForVariant(variant: TypographyVariants): number {\n  switch (variant) {\n    case 'display':\n    case 'title-1':\n      return 24;\n    case 'title-2':\n    case 'title-3':\n    case 'title-4':\n    case 'subheading-large':\n      return 20;\n    default:\n      return 16;\n  }\n}\n\nexport const getIconStyle = (\n  variant: TypographyVariants,\n): React.CSSProperties => ({\n  height: `${getIconSizeForVariant(variant)}px`,\n  width: `${getIconSizeForVariant(variant)}px`,\n});\n\nexport const getMinHeight = (variant: TypographyVariants): string => {\n  return `${tokens.typography[variant].lineHeight * parseFloat(tokens.typography[variant].fontSize)}rem`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAsB,cACpB,IACA,KAAA;;;;CADA,iBAAA,kBAAA,WAAA,OACA,UACwB;EACxB,IAAI,CAAC,UACH,OAAO;EAGT,MAAM,aAAa,SAAS,KAAK;EAEjC,IAAI;EACJ,IAAI,sBAAsB,SACxB,UAAU,MAAM;OAEhB,UAAU;EAGZ,IAAI,OAAO,YAAY,UACrB,OAAO;EAGT,OAAO;CACT,CAAA;;;AAEA,SAAgB,sBAAsB,SAAqC;CACzE,QAAQ,SAAR;EACE,KAAK;EACL,KAAK,WACH,OAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,oBACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAa,gBACX,aACyB;CACzB,QAAQ,GAAG,sBAAsB,OAAO,EAAE;CAC1C,OAAO,GAAG,sBAAsB,OAAO,EAAE;AAC3C;AAEA,MAAa,gBAAgB,YAAwC;CACnE,OAAO,GAAG,OAAO,WAAW,QAAQ,CAAC,aAAa,WAAW,OAAO,WAAW,QAAQ,CAAC,QAAQ,EAAE;AACpG"}