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 / package / action-modal / components / ActionModal.js
jetformbuilder / assets / src / package / action-modal / components Last commit date
ActionModal.js 2 years ago
ActionModal.js
92 lines
1 import ActionModalContext from '../context/ActionModalContext';
2
3 const {
4 Button,
5 ButtonGroup,
6 Modal,
7 } = wp.components;
8
9 const {
10 useState,
11 } = wp.element;
12
13 function ActionModal( {
14 onRequestClose,
15 children,
16 title = '',
17 classNames = [],
18 onUpdateClick,
19 onCancelClick,
20 updateBtnLabel = 'Update',
21 updateBtnProps = {},
22 cancelBtnProps = {},
23 cancelBtnLabel = 'Cancel',
24 fixedHeight = '',
25 isUseActions = true
26 } ) {
27
28 const modalClasses = [ 'jet-form-edit-modal', ...classNames ];
29
30 const [ actionClick, setActionClick ] = useState( null );
31
32 const updateClick = () => {
33 if ( onUpdateClick ) {
34 onUpdateClick();
35 }
36 setActionClick( true );
37 };
38 const cancelClick = () => {
39 if ( onCancelClick ) {
40 onCancelClick();
41 }
42 setActionClick( false );
43 };
44
45 let style = {};
46 if ( fixedHeight ) {
47 style = { height: fixedHeight };
48 modalClasses.push( 'jet-modal-fixed-height' );
49 }
50
51 return <Modal
52 onRequestClose={ onRequestClose }
53 className={ modalClasses.join( ' ' ) }
54 title={ title }
55 style={ style }
56 >
57 { ! children && <div
58 className="jet-form-edit-modal__content"
59 >
60 { 'Action callback is not found.' }
61 </div> }
62 { children && <>
63 <div className='jet-form-edit-modal__wrapper'>
64 <ActionModalContext.Provider value={ { actionClick, onRequestClose } }>
65 <div className="jet-form-edit-modal__content">
66 { 'function' === typeof children && children( { actionClick, onRequestClose } ) }
67 { 'function' !== typeof children && children }
68 </div>
69 </ActionModalContext.Provider>
70 </div>
71 { isUseActions && <ButtonGroup
72 className="jet-form-edit-modal__actions"
73 >
74 <Button
75 isPrimary
76 onClick={ updateClick }
77 { ...updateBtnProps }
78 >{ updateBtnLabel }</Button>
79 <Button
80 isSecondary
81 style={ {
82 margin: '0 0 0 10px',
83 } }
84 onClick={ cancelClick }
85 { ...cancelBtnProps }
86 >{ cancelBtnLabel }</Button>
87 </ButtonGroup> }
88 </> }
89 </Modal>;
90 }
91
92 export default ActionModal;