UNPKG

@parkassist/pa-ui-library

Version:
115 lines 2.29 kB
import { jsx as _jsx } from "react/jsx-runtime"; import React from 'react'; import { InputAdornment } from '@mui/material'; import CustomTooltip from '../../Tooltip'; import * as Icons from '../../Icons'; import { FontStyles, Palette } from '../../../index'; const CopyEndAdornment = ({ copied, onCopy }) => { return _jsx(CustomTooltip, { placement: 'top', content: copied ? 'Copied' : 'Copy', contentStyles: { display: 'flex' }, children: _jsx(Icons.CopyIcon, { onClick: onCopy, style: { cursor: 'pointer' } }) }); }; const PasswordEndAdornment = ({ showPassword, onShowPassword }) => { return showPassword ? _jsx(Icons.EyeHidden2Icon, { onClick: onShowPassword, style: { cursor: 'pointer' } }) : _jsx(Icons.EyeVisibleIcon, { onClick: onShowPassword, style: { cursor: 'pointer' } }); }; const EndAdornmentContent = ({ text, icon, copyAdornment, copied, onCopy, passwordAdornment, showPassword, onShowPassword }) => { if (text) { return text; } if (icon) { return icon; } if (copyAdornment) { return _jsx(CopyEndAdornment, { copied: copied, onCopy: onCopy }); } if (passwordAdornment) { return _jsx(PasswordEndAdornment, { showPassword: showPassword, onShowPassword: onShowPassword }); } return null; }; export const StartAdornment = ({ text, icon }) => { return _jsx(InputAdornment, { position: "start", sx: { '&.MuiInputAdornment-root .MuiTypography-root': { color: Palette.DARK_GREY, font: FontStyles.INPUT_FONT } }, children: text || icon }); }; export const EndAdornment = ({ text, icon, copyAdornment, copied, onCopy, passwordAdornment, showPassword, onShowPassword }) => { return _jsx(InputAdornment, { position: "end", sx: { '&': { color: Palette.DARK_GREY, font: FontStyles.INPUT_FONT } }, children: _jsx(EndAdornmentContent, { text: text, icon: icon, copyAdornment: copyAdornment, copied: copied, onCopy: onCopy, passwordAdornment: passwordAdornment, showPassword: showPassword, onShowPassword: onShowPassword }) }); };