PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
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 / textarea-field / edit.js
jetformbuilder / assets / src / editor / blocks / textarea-field Last commit date
edit.js 2 years ago index.js 2 years ago preview.js 2 years ago
edit.js
149 lines
1 import preview from './preview';
2
3 const {
4 ToolBarFields,
5 AdvancedFields,
6 FieldWrapper,
7 FieldSettingsWrapper,
8 ValidationToggleGroup,
9 ValidationBlockMessage,
10 BlockLabel,
11 BlockDescription,
12 BlockName,
13 BlockAdvancedValue,
14 EditAdvancedRulesButton,
15 AdvancedInspectorControl,
16 AttributeHelp,
17 } = JetFBComponents;
18
19 const {
20 useIsAdvancedValidation,
21 useUniqueNameOnDuplicate,
22 } = JetFBHooks;
23
24 const {
25 __,
26 } = wp.i18n;
27
28 const {
29 InspectorControls,
30 useBlockProps,
31 } = wp.blockEditor;
32
33 const {
34 TextareaControl,
35 TextControl,
36 PanelBody,
37 __experimentalNumberControl,
38 } = wp.components;
39
40 let { NumberControl } = wp.components;
41
42 if ( typeof NumberControl === 'undefined' ) {
43 NumberControl = __experimentalNumberControl;
44 }
45
46 export default function TextareaEdit( props ) {
47
48 const {
49 attributes,
50 setAttributes,
51 isSelected,
52 editProps: { uniqKey, attrHelp },
53 } = props;
54
55 const blockProps = useBlockProps();
56 const isAdvancedValidation = useIsAdvancedValidation();
57
58 useUniqueNameOnDuplicate();
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 return [
71 <ToolBarFields
72 key={ uniqKey( 'ToolBarFields' ) }
73 { ...props }
74 />,
75 isSelected && <InspectorControls key={ uniqKey( 'InspectorControls' ) }>
76 <PanelBody title={ __( 'General', 'jet-form-builder' ) }>
77 <BlockLabel/>
78 <BlockName/>
79 <BlockDescription/>
80 </PanelBody>
81 <PanelBody title={ __( 'Value', 'jet-form-builder' ) }>
82 <BlockAdvancedValue/>
83 </PanelBody>
84 <FieldSettingsWrapper { ...props }>
85 <AdvancedInspectorControl
86 value={ attributes.minlength }
87 label={ __( 'Min length (symbols)', 'jet-form-builder' ) }
88 onChangePreset={ minlength => setAttributes(
89 { minlength } ) }
90 >
91 { ( { instanceId } ) => <TextControl
92 id={ instanceId }
93 className="jet-fb m-unset"
94 value={ attributes.minlength }
95 onChange={ minlength => setAttributes( { minlength } ) }
96 /> }
97 </AdvancedInspectorControl>
98 <AttributeHelp name="minlength"/>
99 <AdvancedInspectorControl
100 value={ attributes.maxlength }
101 label={ __( 'Max length (symbols)', 'jet-form-builder' ) }
102 onChangePreset={ maxlength => setAttributes(
103 { maxlength } ) }
104 >
105 { ( { instanceId } ) => <TextControl
106 id={ instanceId }
107 className="jet-fb m-unset"
108 value={ attributes.maxlength }
109 onChange={ maxlength => setAttributes( { maxlength } ) }
110 /> }
111 </AdvancedInspectorControl>
112 <AttributeHelp name="maxlength"/>
113 </FieldSettingsWrapper>
114 <PanelBody
115 title={ __( 'Validation', 'jet-form-builder' ) }
116 >
117 <ValidationToggleGroup/>
118 { isAdvancedValidation && <>
119 <EditAdvancedRulesButton/>
120 { Boolean( attributes.minlength ) && <>
121 <ValidationBlockMessage name="char_min"/>
122 </> }
123 { Boolean( attributes.maxlength ) && <>
124 <ValidationBlockMessage name="char_max"/>
125 </> }
126 <ValidationBlockMessage name="empty"/>
127 </> }
128 </PanelBody>
129 <AdvancedFields
130 key={ uniqKey( 'AdvancedFields' ) }
131 { ...props }
132 />
133 </InspectorControls>,
134 <div key={ uniqKey( 'viewBlock' ) } { ...blockProps }>
135 <FieldWrapper
136 key={ uniqKey( 'FieldWrapper' ) }
137 { ...props }
138 >
139 <TextareaControl
140 key={ uniqKey( 'place_holder_block' ) }
141 placeholder={ attributes.placeholder }
142 onChange={ () => {
143 } }
144 />
145 </FieldWrapper>
146 </div>,
147 ];
148 }
149