PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.2
JetFormBuilder — Dynamic Blocks Form Builder v3.1.2
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / editor / blocks / hidden-field / edit.js
jetformbuilder / assets / src / editor / blocks / hidden-field Last commit date
FieldSettings.js 2 years ago FooterControls.js 2 years ago HeaderControls.js 2 years ago edit.js 2 years ago index.js 2 years ago preview.js 2 years ago
edit.js
129 lines
1 import FieldSettings from './FieldSettings';
2 import preview from './preview';
3
4 const { __ } = wp.i18n;
5
6 const {
7 AdvancedFields,
8 FieldSettingsWrapper,
9 BlockLabel,
10 BlockDescription,
11 BlockAdvancedValue,
12 BlockName,
13 } = JetFBComponents;
14
15 const {
16 useBlockAttributes,
17 useUniqueNameOnDuplicate,
18 } = JetFBHooks;
19
20 const {
21 InspectorControls,
22 useBlockProps,
23 RichText,
24 } = wp.blockEditor;
25
26 const {
27 Card,
28 CardHeader,
29 CardBody,
30 PanelBody,
31 } = wp.components;
32
33 const {
34 useEffect,
35 } = wp.element;
36
37 export default function HiddenEdit( props ) {
38
39 const {
40 attributes,
41 setAttributes,
42 isSelected,
43 editProps: { uniqKey },
44 } = props;
45
46 const blockProps = useBlockProps();
47 useUniqueNameOnDuplicate();
48
49 const [ , setAttrs ] = useBlockAttributes();
50
51 const resetRender = () => {
52 if ( 'referer_url' === attributes.field_value ) {
53 setAttributes( { render: true } );
54 }
55 };
56
57 useEffect( resetRender, [] );
58 useEffect( resetRender, [ attributes.field_value ] );
59
60 if ( attributes.isPreview ) {
61 return <div style={ {
62 width: '100%',
63 display: 'flex',
64 justifyContent: 'center',
65 } }>
66 { preview }
67 </div>;
68 }
69
70 const { label = 'Please set `Field Value`' } = JetFormHiddenField.sources.find(
71 option => option.value === attributes.field_value,
72 );
73
74 const resultLabel = [ label ];
75
76 switch ( attributes.field_value ) {
77 case 'post_meta':
78 case 'user_meta':
79 resultLabel.push( attributes.hidden_value_field );
80 break;
81 case 'query_var':
82 resultLabel.push( attributes.query_var_key );
83 break;
84 case 'current_date':
85 resultLabel.push( attributes.date_format );
86 break;
87 case 'manual_input':
88 resultLabel.push( attributes.hidden_value );
89 break;
90 }
91
92 return [
93 isSelected && (
94 <InspectorControls
95 key={ uniqKey( 'InspectorControls' ) }
96 >
97 <PanelBody title={ __( 'General', 'jet-form-builder' ) }>
98 <BlockLabel/>
99 <BlockName/>
100 <BlockDescription/>
101 </PanelBody>
102 <PanelBody title={ __( 'Value', 'jet-form-builder' ) }>
103 <BlockAdvancedValue/>
104 </PanelBody>
105 <FieldSettingsWrapper { ...props }>
106 <FieldSettings/>
107 </FieldSettingsWrapper>
108 <AdvancedFields/>
109 </InspectorControls>
110 ),
111 <div { ...blockProps } key={ uniqKey( 'viewBlock' ) }>
112 <Card elevation={ 2 }>
113 <CardHeader>
114 <RichText
115 placeholder="hidden_field_name..."
116 allowedFormats={ [] }
117 value={ attributes.name }
118 onChange={ name => setAttrs( { name } ) }
119 />
120 </CardHeader>
121 <CardBody>
122 { isSelected && <FieldSettings/> }
123 { !isSelected && resultLabel.join( ': ' ) }
124 </CardBody>
125 </Card>
126 </div>,
127 ];
128 };
129