PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.5
GiveWP – Donation Plugin and Fundraising Platform v4.15.5
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 2.3.1 All 257 releases
give / src / DonationForms / resources / registrars / templates / fields / Text.tsx

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

51 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {FieldHasDescriptionProps} from '@givewp/forms/propTypes';
2 import autoCompleteAttr from '@givewp/forms/registrars/templates/fields/utils/autoCompleteAttr';
3
4 /**
5 * @since 4.3.0 Add autoComplete support and aria-labelledby and aria-describedby attributes.
6 */
7 export default function Text({
8 Label,
9 ErrorMessage,
10 fieldError,
11 description,
12 placeholder,
13 inputProps,
14 }: FieldHasDescriptionProps) {
15 const autoComplete = autoCompleteAttr(inputProps?.name);
16 const FieldDescription = window.givewp.form.templates.layouts.fieldDescription;
17 const baseId = `givewp-fields-text-${inputProps.name}`;
18 const inputId = `${baseId}-input`;
19 const labelId = `${baseId}-label`;
20 const descriptionId = `${baseId}-description`;
21
22 return (
23 <label
24 className={fieldError && 'givewp-field-error-label'}
25 htmlFor={inputId}
26 >
27 <span id={labelId}>
28 <Label />
29 </span>
30 {description && (
31 <span id={descriptionId}>
32 <FieldDescription description={description} />
33 </span>
34 )}
35
36 <input
37 id={inputId}
38 type="text"
39 aria-invalid={fieldError ? 'true' : 'false'}
40 aria-labelledby={labelId}
41 aria-describedby={description ? descriptionId : undefined}
42 placeholder={placeholder}
43 {...inputProps}
44 autoComplete={autoComplete}
45 />
46
47 <ErrorMessage />
48 </label>
49 );
50 }
51