- finished new flow builder UI;
- fixed reset pass functionality;
This commit is contained in:
54
src/components/FormField/components/PasswordField/index.js
Normal file
54
src/components/FormField/components/PasswordField/index.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import React from 'react';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { Controller } from 'react-hook-form';
|
||||
import { Password } from 'primereact/password';
|
||||
|
||||
const PasswordField = ({
|
||||
fieldName,
|
||||
label,
|
||||
control,
|
||||
errors,
|
||||
defaultValue,
|
||||
config = {},
|
||||
infoText = null,
|
||||
inputgroup = false,
|
||||
icon = null,
|
||||
placeholder = '',
|
||||
disabled = false,
|
||||
onBlurFn = () => {
|
||||
}
|
||||
}) => {
|
||||
const input = <Controller
|
||||
name={fieldName}
|
||||
control={control}
|
||||
defaultValue={defaultValue}
|
||||
rules={config}
|
||||
render={({ field, fieldState }) => (
|
||||
<Password
|
||||
id={field.name}
|
||||
disabled={disabled}
|
||||
{...field}
|
||||
value={field.value ? field.value : ''}
|
||||
onBlur={onBlurFn}
|
||||
placeholder={placeholder}
|
||||
className={classNames({ 'p-invalid': fieldState.invalid })}
|
||||
toggleMask />
|
||||
)}/>
|
||||
return (
|
||||
<>
|
||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||
{label}{config.required || config.isRequired ? <span className="appForm__field--required">*</span> : null}
|
||||
</label>
|
||||
{inputgroup
|
||||
? <div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon">
|
||||
{icon}
|
||||
</span>
|
||||
{input}
|
||||
</div>
|
||||
: input}
|
||||
{infoText ? <small>{infoText}</small> : null}
|
||||
</>)
|
||||
}
|
||||
|
||||
export default PasswordField;
|
||||
@@ -16,6 +16,7 @@ import Wysiwyg from './components/Wysiwyg';
|
||||
import Checkboxes from './components/Checkboxes';
|
||||
import Fileupload from './components/Fileupload';
|
||||
import Table from './components/Table';
|
||||
import PasswordField from './components/PasswordField';
|
||||
|
||||
const FormField = (props) => {
|
||||
const fields = {
|
||||
@@ -31,7 +32,8 @@ const FormField = (props) => {
|
||||
radio: Radio,
|
||||
wysiwyg: Wysiwyg,
|
||||
checkboxes: Checkboxes,
|
||||
table: Table
|
||||
table: Table,
|
||||
password: PasswordField
|
||||
}
|
||||
const Comp = !isNil(fields[props.type]) ? fields[props.type] : null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user