UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

32 lines (31 loc) 2.44 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import * as React from 'react'; import { StringExtensions } from '../../../Utilities/Extensions/StringExtensions'; import Dialog from '../../../components/Dialog'; import SimpleButton from '../../../components/SimpleButton'; import Input from '../../../components/Input'; import { useDispatch } from 'react-redux'; import { Box, Flex } from '../../../components/Flex'; export const AdaptablePopupPrompt = (props) => { const dispatch = useDispatch(); const [promptText, setPromptText] = React.useState(props.defaultValue ?? ''); const onCloseForm = () => { setPromptText(''); props.onClose(); }; const onConfirmForm = () => { props.onConfirm(promptText); const confirmationAction = typeof props.onConfirmActionCreator === 'function' && props.onConfirmActionCreator(promptText); if (confirmationAction) { dispatch(confirmationAction); } setPromptText(''); }; const changeContent = (e) => { setPromptText(e.target.value); }; return (_jsx(Dialog, { modal: true, "data-name": `prompt-popup`, isOpen: true, onDismiss: props.onClose, showCloseButton: false, className: "twa:min-h-auto twa:max-w-1/2", children: _jsxs(Flex, { flexDirection: "column", children: [_jsx(Box, { className: "twa:mt-3 twa:mx-2", children: props.header }), StringExtensions.IsNotNullOrEmpty(props.message) && (_jsxs(Box, { className: "twa:mt-3 twa:mx-2", children: [' ', _jsx("div", { style: { display: 'flex', alignItems: 'center' }, children: props.message.split('\n').map(function (item, index) { return (_jsxs("span", { children: [item, _jsx("br", {})] }, index)); }) })] })), _jsx(Input, { autoFocus: true, className: "twa:mt-3 twa:mx-3", value: promptText, type: "string", placeholder: "Enter text", onChange: (e) => changeContent(e) }), _jsx(Box, { className: "twa:mt-3", children: _jsxs(Flex, { className: "twa:p-2", "data-name": "footer", justifyContent: "space-between", children: [_jsx(SimpleButton, { tone: "neutral", variant: "raised", onClick: () => onCloseForm(), "data-name": "cancel", children: "Cancel" }), _jsx(SimpleButton, { tone: "accent", "data-name": "ok", variant: "raised", disabled: StringExtensions.IsNullOrEmpty(promptText), onClick: () => onConfirmForm(), children: "OK" })] }) })] }) })); };