PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.3
JetFormBuilder — Dynamic Blocks Form Builder v3.1.3
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 / package / preset / components / DynamicPreset.js
jetformbuilder / assets / src / package / preset / components Last commit date
AvailableMapFieldPreset.js 2 years ago DynamicPreset.js 2 years ago FieldWithPreset.js 2 years ago GlobalFieldPreset.js 2 years ago MapFieldPreset.js 2 years ago PresetButton.js 2 years ago withPreset.js 2 years ago
DynamicPreset.js
83 lines
1 import withPreset from './withPreset';
2 import GlobalFieldPreset from './GlobalFieldPreset';
3 import MapFieldPreset from './MapFieldPreset';
4 import ActionModalContext from '../../action-modal/context/ActionModalContext';
5
6 const {
7 useState,
8 useEffect,
9 useContext,
10 } = wp.element;
11
12 let DynamicPreset = function ( {
13 value,
14 isSaveAction,
15 onSavePreset,
16 onUnMount,
17 parseValue,
18 excludeOptions,
19 isCurrentFieldVisible,
20 isVisible,
21 } ) {
22
23 const position = 'dynamic';
24 const [ stateValue, setValue ] = useState(
25 () => parseValue( value ),
26 );
27
28 const { actionClick, onRequestClose } = useContext( ActionModalContext );
29
30 if ( 'undefined' === typeof isSaveAction ) {
31 isSaveAction = actionClick;
32 }
33 if ( 'undefined' === typeof onUnMount ) {
34 onUnMount = onRequestClose;
35 }
36
37 const onChangeValue = ( newValue, name ) => {
38 setValue( prev => (
39 { ...prev, [ name ]: newValue }
40 ) );
41 };
42
43 useEffect( () => {
44 // update field attributes
45 if ( isSaveAction && onSavePreset ) {
46 onSavePreset( JSON.stringify( stateValue ) );
47 }
48
49 if ( null !== isSaveAction ) {
50 onUnMount();
51 }
52 }, [ isSaveAction ] );
53
54 return <>
55 { window.JetFormEditorData.presetConfig.global_fields.map(
56 ( data, index ) => <GlobalFieldPreset
57 key={ `current_field_${ data.name }_${ index }` }
58 value={ stateValue }
59 index={ index }
60 data={ data }
61 excludeOptions={ excludeOptions }
62 onChangeValue={ onChangeValue }
63 isVisible={ isVisible }
64 position={ position }
65 /> ) }
66
67 { window.JetFormEditorData.presetConfig.map_fields.map(
68 ( data, index ) => <MapFieldPreset
69 key={ `current_field_${ data.name }_${ index }` }
70 currentState={ stateValue }
71 value={ stateValue[ 'current_field_' + data.name ] }
72 index={ index }
73 data={ data }
74 onChangeValue={ onChangeValue }
75 isCurrentFieldVisible={ isCurrentFieldVisible }
76 position={ position }
77 /> ) }
78 </>;
79 };
80
81 DynamicPreset = withPreset( DynamicPreset );
82
83 export default DynamicPreset;