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 / number-field / edit.js
jetformbuilder / assets / src / editor / blocks / number-field Last commit date
edit.js 2 years ago index.js 2 years ago preview.js 2 years ago
edit.js
157 lines
1 import preview from './preview';
2
3 const {
4 ToolBarFields,
5 BlockLabel,
6 BlockDescription,
7 BlockAdvancedValue,
8 BlockName,
9 AdvancedFields,
10 FieldWrapper,
11 FieldSettingsWrapper,
12 ValidationToggleGroup,
13 ValidationBlockMessage,
14 AdvancedInspectorControl,
15 AttributeHelp,
16 } = JetFBComponents;
17 const {
18 useIsAdvancedValidation,
19 useUniqueNameOnDuplicate,
20 } = JetFBHooks;
21 const {
22 __,
23 } = wp.i18n;
24 const {
25 InspectorControls,
26 useBlockProps,
27 } = wp.blockEditor;
28 const {
29 PanelBody,
30 TextControl,
31 __experimentalInputControl,
32 __experimentalNumberControl,
33 } = wp.components;
34
35 let { InputControl, NumberControl } = wp.components;
36
37 if ( typeof InputControl === 'undefined' ) {
38 InputControl = __experimentalInputControl;
39 }
40
41 if ( typeof NumberControl === 'undefined' ) {
42 NumberControl = __experimentalNumberControl;
43 }
44
45 export default function NumberEdit( props ) {
46 const blockProps = useBlockProps();
47 const isAdvancedValidation = useIsAdvancedValidation();
48 useUniqueNameOnDuplicate();
49
50 const {
51 attributes,
52 setAttributes,
53 isSelected,
54 editProps: { uniqKey },
55 } = props;
56
57 if ( attributes.isPreview ) {
58 return <div style={ {
59 width: '100%',
60 display: 'flex',
61 justifyContent: 'center',
62 } }>
63 { preview }
64 </div>;
65 }
66
67 return [
68 <ToolBarFields
69 key={ uniqKey( 'ToolBarFields' ) }
70 { ...props }
71 />,
72 isSelected && (
73 <InspectorControls
74 key={ uniqKey( 'InspectorControls' ) }
75 >
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.min }
87 label={ __( 'Min Value', 'jet-form-builder' ) }
88 onChangePreset={ min => setAttributes( { min } ) }
89 >
90 { ( { instanceId } ) => <TextControl
91 id={ instanceId }
92 className="jet-fb m-unset"
93 value={ attributes.min }
94 onChange={ min => setAttributes( { min } ) }
95 /> }
96 </AdvancedInspectorControl>
97 <AttributeHelp name="min"/>
98 <AdvancedInspectorControl
99 value={ attributes.max }
100 label={ __( 'Max Value', 'jet-form-builder' ) }
101 onChangePreset={ max => setAttributes( { max } ) }
102 >
103 { ( { instanceId } ) => <TextControl
104 id={ instanceId }
105 className="jet-fb m-unset"
106 value={ attributes.max }
107 onChange={ max => setAttributes( { max } ) }
108 /> }
109 </AdvancedInspectorControl>
110 <AttributeHelp name="max"/>
111 <AdvancedInspectorControl
112 value={ attributes.step }
113 label={ __( 'Step', 'jet-form-builder' ) }
114 onChangePreset={ step => setAttributes( { step } ) }
115 >
116 { ( { instanceId } ) => <TextControl
117 id={ instanceId }
118 className="jet-fb m-unset"
119 value={ attributes.step }
120 onChange={ step => setAttributes( { step } ) }
121 /> }
122 </AdvancedInspectorControl>
123 <AttributeHelp name="step"/>
124 </FieldSettingsWrapper>
125 <PanelBody
126 title={ __( 'Validation', 'jet-form-builder' ) }
127 >
128 <ValidationToggleGroup/>
129 { isAdvancedValidation && <>
130 { null !== attributes.min && (
131 <ValidationBlockMessage name="number_min"/>
132 ) }
133 { null !== attributes.max && (
134 <ValidationBlockMessage name="number_max"/>
135 ) }
136 <ValidationBlockMessage name="empty"/>
137 </> }
138 </PanelBody>
139 <AdvancedFields/>
140 </InspectorControls>
141 ),
142 <div { ...blockProps } key={ uniqKey( 'viewBlock' ) }>
143 <FieldWrapper
144 key={ uniqKey( 'FieldWrapper' ) }
145 { ...props }
146 >
147 <NumberControl
148 placeholder={ attributes.placeholder }
149 key={ uniqKey( 'place_holder_block' ) }
150 min={ attributes.min || 0 }
151 max={ attributes.max || 1000 }
152 step={ attributes.step || 1 }
153 />
154 </FieldWrapper>
155 </div>,
156 ];
157 }