UNPKG

@contentstack/live-preview-utils

Version:

Contentstack provides the Live Preview SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane.

1 lines 3.32 kB
{"version":3,"sources":["../../../../src/visualBuilder/components/CslpError.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { visualBuilderStyles } from \"../visualBuilder.style\";\nimport { WarningOctagonIcon } from \"./icons\";\nimport { useEffect, useRef, useState } from \"preact/compat\";\n\ninterface CslpErrorProps {}\n\nexport function CslpError({}: CslpErrorProps) {\n const errorRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n useEffect(() => {\n const errorElement = errorRef.current;\n\n const showTooltip = () => {\n setShowTooltip(true);\n };\n\n const hideTooltip = () => {\n setShowTooltip(false);\n };\n\n if (errorElement) {\n errorElement.addEventListener(\"mouseenter\", showTooltip);\n errorElement.addEventListener(\"mouseleave\", hideTooltip);\n }\n\n return () => {\n if (errorElement) {\n errorElement.removeEventListener(\"mouseenter\", showTooltip);\n errorElement.removeEventListener(\"mouseleave\", hideTooltip);\n }\n };\n }, []);\n\n return (\n <div\n className={classNames(\n visualBuilderStyles()[\"visual-builder__focused-toolbar__error\"]\n )}\n ref={errorRef}\n >\n <WarningOctagonIcon />\n <span\n className={classNames(\n visualBuilderStyles()[\n \"visual-builder__focused-toolbar__error-text\"\n ]\n )}\n >\n Error\n </span>\n {showTooltip ? (\n <div\n className={classNames(\n visualBuilderStyles()[\n \"visual-builder__focused-toolbar__error-toolip\"\n ]\n )}\n >\n <p>Invalid CSLP tag</p>\n <span>\n The CSLP is invalid or incorrectly generated.\n </span>\n </div>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuB;AACvB,2BAAoC;AACpC,mBAAmC;AACnC,oBAA4C;AAuChC;AAnCL,SAAS,UAAU,CAAC,GAAmB;AAC1C,QAAM,eAAW,sBAAuB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