All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.account.resources.content.ContentAlert.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.5
Show newest version
{"version":3,"file":"ContentAlert.js","names":["React","Alert","AlertActionCloseButton","AlertGroup","AlertVariant","Msg","ContentAlert","Component","constructor","props","_defineProperty","key","setState","alerts","state","filter","el","Date","getTime","variant","message","params","getUniqueId","push","localize","danger","setTimeout","hideAlert","instance","success","postAlert","warning","info","render","createElement","isToast","map","isLiveRegion","title","actionClose","variantLabel","onClose","_class"],"sources":["../../src/app/content/ContentAlert.tsx"],"sourcesContent":["/*\n * Copyright 2019 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\nimport { Alert, AlertActionCloseButton, AlertGroup, AlertVariant } from '@patternfly/react-core';\nimport { Msg } from '../widgets/Msg';\n\ninterface ContentAlertProps { }\n\ninterface ContentAlertState {\n    alerts: {\n        key: number;\n        message: string;\n        variant: AlertVariant;\n    }[];\n}\nexport class ContentAlert extends React.Component {\n    private static instance: ContentAlert;\n\n    private constructor(props: ContentAlertProps) {\n        super(props);\n\n        this.state = {\n            alerts: []\n        };\n        ContentAlert.instance = this;\n    }\n\n    /**\n     * @param message A literal text message or localization key.\n     */\n    public static success(message: string, params?: string[]): void {\n        ContentAlert.instance.postAlert(AlertVariant.success, message, params);\n    }\n\n    /**\n     * @param message A literal text message or localization key.\n     */\n    public static danger(message: string, params?: string[]): void {\n        ContentAlert.instance.postAlert(AlertVariant.danger, message, params);\n    }\n\n    /**\n     * @param message A literal text message or localization key.\n     */\n    public static warning(message: string, params?: string[]): void {\n        ContentAlert.instance.postAlert(AlertVariant.warning, message, params);\n    }\n\n    /**\n     * @param message A literal text message or localization key.\n     */\n    public static info(message: string, params?: string[]): void {\n        ContentAlert.instance.postAlert(AlertVariant.info, message, params);\n    }\n\n    private hideAlert = (key: number) => {\n        this.setState({ alerts: [...this.state.alerts.filter(el => el.key !== key)] });\n    }\n\n    private getUniqueId = () => (new Date().getTime());\n\n    private postAlert = (variant: AlertVariant, message: string, params?: string[]) => {\n        const alerts = this.state.alerts;\n        const key = this.getUniqueId();\n        alerts.push({\n            key,\n            message: Msg.localize(message, params),\n            variant\n        });\n        this.setState({ alerts });\n\n        if (variant !== AlertVariant.danger) {\n            setTimeout(() => this.hideAlert(key), 8000);\n        }\n    }\n\n    public render(): React.ReactNode {\n        return (\n            \n                {this.state.alerts.map(({ key, variant, message }) => (\n                     this.hideAlert(key)}\n                            />\n                        }\n                        key={key} />\n                ))}\n            \n        );\n    }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK;AACjB,SAASC,KAAK,EAAEC,sBAAsB,EAAEC,UAAU,EAAEC,YAAY;AAChE,SAASC,GAAG;AAWZ,OAAO,MAAMC,YAAY,SAASN,KAAK,CAACO,SAAS,CAAuC;EAG5EC,WAAWA,CAACC,KAAwB,EAAE;IAC1C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAoCIC,GAAW,IAAK;MACjC,IAAI,CAACC,QAAQ,CAAC;QAAEC,MAAM,EAAE,CAAC,GAAG,IAAI,CAACC,KAAK,CAACD,MAAM,CAACE,MAAM,CAACC,EAAE,IAAIA,EAAE,CAACL,GAAG,KAAKA,GAAG,CAAC;MAAE,CAAC,CAAC;IAClF,CAAC;IAAAD,eAAA,sBAEqB,MAAO,IAAIO,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAE;IAAAR,eAAA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