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