UNPKG

@grafana/ui

Version:
1 lines 1.72 kB
{"version":3,"file":"SecretInput.mjs","sources":["../../../../src/components/SecretInput/SecretInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button } from '../Button/Button';\nimport { Input } from '../Input/Input';\nimport { Stack } from '../Layout/Stack/Stack';\n\nexport type Props = React.ComponentProps<typeof Input> & {\n /** TRUE if the secret was already configured. (It is needed as often the backend doesn't send back the actual secret, only the information that it was configured) */\n isConfigured: boolean;\n /** Called when the user clicks on the \"Reset\" button in order to clear the secret */\n onReset: () => void;\n};\n\nexport const CONFIGURED_TEXT = 'configured';\nexport const RESET_BUTTON_TEXT = 'Reset';\n\nexport const SecretInput = ({ isConfigured, onReset, ...props }: Props) => (\n <Stack>\n {!isConfigured && <Input {...props} type=\"password\" />}\n {isConfigured && (\n <>\n <Input {...props} type=\"text\" disabled={true} value={CONFIGURED_TEXT} />\n <Button onClick={onReset} variant=\"secondary\">\n {RESET_BUTTON_TEXT}\n </Button>\n </>\n )}\n </Stack>\n);\n"],"names":[],"mappings":";;;;;AAaO,MAAM,eAAkB,GAAA;AACxB,MAAM,iBAAoB,GAAA;AAEpB,MAAA,WAAA,GAAc,CAAC,EAAE,YAAA,EAAc,SAAS,GAAG,KAAA,EACtD,qBAAA,IAAA,CAAC,KACE,EAAA,EAAA,QAAA,EAAA;AAAA,EAAA,CAAC,gCAAiB,GAAA,CAAA,KAAA,EAAA,EAAO,GAAG,KAAA,EAAO,MAAK,UAAW,EAAA,CAAA;AAAA,EACnD,gCAEG,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,KAAA,EAAA,EAAO,GAAG,KAAO,EAAA,IAAA,EAAK,QAAO,QAAU,EAAA,IAAA,EAAM,OAAO,eAAiB,EAAA,CAAA;AAAA,wBACrE,MAAO,EAAA,EAAA,OAAA,EAAS,OAAS,EAAA,OAAA,EAAQ,aAC/B,QACH,EAAA,iBAAA,EAAA;AAAA,GACF,EAAA;AAAA,CAEJ,EAAA;;;;"}