PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.0
GiveWP – Donation Plugin and Fundraising Platform v4.15.0
4.18.0.1 4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 All 258 releases
give / src / DonationForms / resources / registrars / templates / fields / Checkbox.tsx

Checkbox.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.15.0, at src/DonationForms/resources/registrars/templates/fields/Checkbox.tsx

24 lines 838 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import type {CheckboxProps} from '@givewp/forms/propTypes';
2
3 /**
4 * @since 4.0.0 updated inputProps and value to prevent checkbox from being a controlled component
5 * @since 3.0.0
6 */
7 export default function Checkbox({Label, ErrorMessage, value, helpText, fieldError, inputProps}: CheckboxProps) {
8 const FieldDescription = window.givewp.form.templates.layouts.fieldDescription;
9
10 const {checked, ...rest} = inputProps;
11 const inputValue = value === null ? undefined : value;
12
13 return (
14 <>
15 <label>
16 <input type="checkbox" value={inputValue} defaultChecked={checked} aria-invalid={fieldError ? 'true' : 'false'} {...rest} />
17 <Label />
18 </label>
19 {helpText && <FieldDescription description={helpText} />}
20 <ErrorMessage />
21 </>
22 );
23 }
24