PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / form / fields / date / edit.js

edit.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/form/fields/date/edit.js

81 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import classnames from 'classnames/dedupe';
2
3 import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
4 import { PanelBody, TextControl } from '@wordpress/components';
5 import { applyFilters } from '@wordpress/hooks';
6 import { __ } from '@wordpress/i18n';
7
8 import {
9 FieldDefaultSettings,
10 getFieldAttributes,
11 } from '../../field-attributes';
12 import FieldDescription from '../../field-description';
13 import FieldLabel from '../../field-label';
14
15 /**
16 * Block Edit Class.
17 *
18 * @param props
19 */
20 export default function BlockEdit(props) {
21 const { attributes, setAttributes } = props;
22
23 const { min, max, default: defaultVal } = attributes;
24
25 let { className = '' } = props;
26
27 className = classnames(
28 'ghostkit-form-field ghostkit-form-field-date',
29 className
30 );
31
32 className = applyFilters('ghostkit.editor.className', className, props);
33
34 const defaultCustom = (
35 <TextControl
36 type="date"
37 label={__('Default', 'ghostkit')}
38 value={defaultVal}
39 onChange={(val) => setAttributes({ default: val })}
40 max={max}
41 min={min}
42 />
43 );
44
45 const blockProps = useBlockProps({ className });
46
47 return (
48 <>
49 <InspectorControls>
50 <PanelBody>
51 <FieldDefaultSettings
52 {...props}
53 defaultCustom={defaultCustom}
54 />
55 </PanelBody>
56 <PanelBody title={__('Date Settings', 'ghostkit')}>
57 <TextControl
58 type="date"
59 label={__('Min', 'ghostkit')}
60 value={min}
61 onChange={(val) => setAttributes({ min: val })}
62 max={max}
63 />
64 <TextControl
65 type="date"
66 label={__('Max', 'ghostkit')}
67 value={max}
68 onChange={(val) => setAttributes({ max: val })}
69 min={min}
70 />
71 </PanelBody>
72 </InspectorControls>
73 <div {...blockProps}>
74 <FieldLabel {...props} />
75 <TextControl type="date" {...getFieldAttributes(attributes)} />
76 <FieldDescription {...props} />
77 </div>
78 </>
79 );
80 }
81