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 / datetime-field / edit.js
jetformbuilder / assets / src / editor / blocks / datetime-field Last commit date
edit.js 2 years ago index.js 2 years ago preview.js 2 years ago
edit.js
179 lines
1 import preview from './preview';
2
3 const {
4 ToolBarFields,
5 BlockName,
6 BlockLabel,
7 BlockDescription,
8 BlockAdvancedValue,
9 AdvancedFields,
10 FieldWrapper,
11 FieldSettingsWrapper,
12 AdvancedInspectorControl,
13 ValidationToggleGroup,
14 ValidationBlockMessage,
15 ClientSideMacros,
16 AttributeHelp,
17 } = JetFBComponents;
18 const {
19 useInsertMacro,
20 useIsAdvancedValidation,
21 useUniqueNameOnDuplicate,
22 } = JetFBHooks;
23 const {
24 __,
25 } = wp.i18n;
26 const {
27 InspectorControls,
28 useBlockProps,
29 } = wp.blockEditor;
30
31 const {
32 TextControl,
33 ToggleControl,
34 PanelBody,
35 ExternalLink,
36 } = wp.components;
37
38 export default function DateTimeEdit( props ) {
39 const blockProps = useBlockProps();
40
41 const [ minInput, updateMin ] = useInsertMacro( 'min' );
42 const [ maxInput, updateMax ] = useInsertMacro( 'max' );
43
44 const {
45 attributes,
46 setAttributes,
47 isSelected,
48 editProps: { uniqKey, attrHelp },
49 } = props;
50
51 const isAdvancedValidation = useIsAdvancedValidation();
52 useUniqueNameOnDuplicate();
53
54 if ( attributes.isPreview ) {
55 return <div style={ {
56 width: '100%',
57 display: 'flex',
58 justifyContent: 'center',
59 } }>
60 { preview }
61 </div>;
62 }
63
64 const help = <>
65 { __(
66 'Plain date should be in yyyy-MM-ddThh:mm format.',
67 'jet-form-builder',
68 ) }
69 &nbsp;
70 { __( 'Or you can use', 'jet-form-builder' ) }
71 &nbsp;
72 <ExternalLink
73 href="https://github.com/Crocoblock/jetformbuilder/wiki/Frontend-Macros---External-Macros#ctcurrentdate"
74 >
75 { __( 'macros', 'jet-form-builder' ) }
76 </ExternalLink>.
77 </>;
78
79 return [
80 <ToolBarFields
81 key={ uniqKey( 'ToolBarFields' ) }
82 { ...props }
83 />,
84 isSelected && (
85 <InspectorControls
86 key={ uniqKey( 'InspectorControls' ) }
87 >
88 <PanelBody title={ __( 'General', 'jet-form-builder' ) }>
89 <BlockLabel/>
90 <BlockName/>
91 <BlockDescription/>
92 </PanelBody>
93 <PanelBody title={ __( 'Value', 'jet-form-builder' ) }>
94 <BlockAdvancedValue
95 help={ help }
96 style={ { marginBottom: '1em' } }
97 />
98 <ClientSideMacros>
99 <AdvancedInspectorControl
100 value={ attributes.min }
101 label={ __( 'Starting from date',
102 'jet-form-builder' ) }
103 onChangePreset={ min => setAttributes( { min } ) }
104 onChangeMacros={ updateMin }
105 >
106 { ( { instanceId } ) => <>
107 <TextControl
108 id={ instanceId }
109 ref={ minInput }
110 className="jet-fb m-unset"
111 value={ attributes.min }
112 onChange={ min => setAttributes( { min } ) }
113 />
114 <AttributeHelp>{ help }</AttributeHelp>
115 </> }
116 </AdvancedInspectorControl>
117 <AdvancedInspectorControl
118 value={ attributes.max }
119 label={ __( 'Limit dates to', 'jet-form-builder' ) }
120 onChangePreset={ max => setAttributes( { max } ) }
121 onChangeMacros={ updateMax }
122 >
123 { ( { instanceId } ) => <>
124 <TextControl
125 id={ instanceId }
126 ref={ maxInput }
127 className="jet-fb m-unset"
128 value={ attributes.max }
129 onChange={ max => setAttributes( { max } ) }
130 />
131 <AttributeHelp>{ help }</AttributeHelp>
132 </> }
133 </AdvancedInspectorControl>
134 </ClientSideMacros>
135 </PanelBody>
136 <FieldSettingsWrapper { ...props }>
137 <ToggleControl
138 key={ uniqKey( 'is_timestamp' ) }
139 label={ __( 'Is Timestamp', 'jet-form-builder' ) }
140 checked={ attributes.is_timestamp }
141 help={ attrHelp( 'is_timestamp' ) }
142 onChange={ newValue => {
143 setAttributes(
144 { is_timestamp: Boolean( newValue ) } );
145 } }
146 />
147 </FieldSettingsWrapper>
148 <PanelBody
149 title={ __( 'Validation', 'jet-form-builder' ) }
150 >
151 <ValidationToggleGroup/>
152 { isAdvancedValidation && <>
153 { Boolean( attributes.min ) && <>
154 <ValidationBlockMessage name="date_min"/>
155 </> }
156 { Boolean( attributes.max ) && <>
157 <ValidationBlockMessage name="date_max"/>
158 </> }
159 <ValidationBlockMessage name="empty"/>
160 </> }
161 </PanelBody>
162 <AdvancedFields/>
163 </InspectorControls>
164 ),
165 <div { ...blockProps } key={ uniqKey( 'viewBlock' ) }>
166 <FieldWrapper
167 key={ uniqKey( 'FieldWrapper' ) }
168 { ...props }
169 >
170 <TextControl
171 onChange={ () => {
172 } }
173 key={ uniqKey( 'place_holder_block' ) }
174 placeholder={ 'Input type="datetime-local"' }
175 />
176 </FieldWrapper>
177 </div>,
178 ];
179 }