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 / Select.tsx

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

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import type {SelectableFieldProps} 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
6 */
7 export default function Select({
8 Label,
9 ErrorMessage,
10 placeholder,
11 fieldError,
12 options,
13 description,
14 inputProps,
15 }: SelectableFieldProps) {
16 const autoComplete = autoCompleteAttr(inputProps?.name);
17 const FieldDescription = window.givewp.form.templates.layouts.fieldDescription;
18
19 return (
20 <label>
21 <Label />
22 {description && <FieldDescription description={description} />}
23 <select {...inputProps} aria-invalid={fieldError ? 'true' : 'false'} autoComplete={autoComplete}>
24 {placeholder && (
25 <>
26 <option hidden>{placeholder}</option>
27 <option disabled>{placeholder}</option>
28 </>
29 )}
30 {options.map(({value, label}) => (
31 <option key={value} value={value}>
32 {label ?? value}
33 </option>
34 ))}
35 </select>
36
37 <ErrorMessage />
38 </label>
39 );
40 }
41