render.js
40 lines
| 1 | import { captchaItems } from './options'; |
| 2 | |
| 3 | const { |
| 4 | __, |
| 5 | } = wp.i18n; |
| 6 | const { |
| 7 | useMetaState, |
| 8 | } = JetFBHooks; |
| 9 | const { |
| 10 | CaptchaOptions, |
| 11 | } = JetFBComponents; |
| 12 | const { |
| 13 | SelectControl, |
| 14 | } = wp.components; |
| 15 | |
| 16 | function PluginCaptcha() { |
| 17 | const [ args, setArgs ] = useMetaState( '_jf_recaptcha' ); |
| 18 | |
| 19 | return <> |
| 20 | <SelectControl |
| 21 | label={ __( 'Captcha Provider', 'jet-form-builder' ) } |
| 22 | value={ args.captcha } |
| 23 | options={ captchaItems } |
| 24 | onChange={ captcha => { |
| 25 | setArgs( ( prevArgs ) => ( |
| 26 | { |
| 27 | ...prevArgs, |
| 28 | captcha, |
| 29 | } |
| 30 | ) ); |
| 31 | } } |
| 32 | /> |
| 33 | { Boolean( args.captcha ) && ( |
| 34 | <CaptchaOptions.Slot fillProps={ { args, setArgs } }/> |
| 35 | ) } |
| 36 | </>; |
| 37 | } |
| 38 | |
| 39 | export default PluginCaptcha; |
| 40 |