PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.4.1
Block Animations, Motion & Scroll Effects – Ghost Kit v3.4.1
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.4.1, at gutenberg/blocks/form/fields/date/edit.js

92 lines 2.1 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 __next40pxDefaultSize
43 __nextHasNoMarginBottom
44 />
45 );
46
47 const blockProps = useBlockProps({ className });
48
49 return (
50 <>
51 <InspectorControls>
52 <PanelBody>
53 <FieldDefaultSettings
54 {...props}
55 defaultCustom={defaultCustom}
56 />
57 </PanelBody>
58 <PanelBody title={__('Date Settings', 'ghostkit')}>
59 <TextControl
60 type="date"
61 label={__('Min', 'ghostkit')}
62 value={min}
63 onChange={(val) => setAttributes({ min: val })}
64 max={max}
65 __next40pxDefaultSize
66 __nextHasNoMarginBottom
67 />
68 <TextControl
69 type="date"
70 label={__('Max', 'ghostkit')}
71 value={max}
72 onChange={(val) => setAttributes({ max: val })}
73 min={min}
74 __next40pxDefaultSize
75 __nextHasNoMarginBottom
76 />
77 </PanelBody>
78 </InspectorControls>
79 <div {...blockProps}>
80 <FieldLabel {...props} />
81 <TextControl
82 type="date"
83 __next40pxDefaultSize
84 __nextHasNoMarginBottom
85 {...getFieldAttributes(attributes)}
86 />
87 <FieldDescription {...props} />
88 </div>
89 </>
90 );
91 }
92