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 / number / edit.js

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

93 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, step, default: defaultVal } = attributes;
24
25 let { className = '' } = props;
26
27 className = classnames(
28 'ghostkit-form-field ghostkit-form-field-number',
29 className
30 );
31
32 className = applyFilters('ghostkit.editor.className', className, props);
33
34 const defaultCustom = (
35 <TextControl
36 type="number"
37 label={__('Default', 'ghostkit')}
38 value={defaultVal}
39 onChange={(val) => setAttributes({ default: val })}
40 step={step}
41 max={max}
42 min={min}
43 />
44 );
45
46 const blockProps = useBlockProps({ className });
47
48 return (
49 <>
50 <InspectorControls>
51 <PanelBody>
52 <FieldDefaultSettings
53 {...props}
54 defaultCustom={defaultCustom}
55 />
56 </PanelBody>
57 <PanelBody title={__('Number Settings', 'ghostkit')}>
58 <TextControl
59 type="number"
60 label={__('Min', 'ghostkit')}
61 value={min}
62 onChange={(val) => setAttributes({ min: val })}
63 step={step}
64 max={max}
65 />
66 <TextControl
67 type="number"
68 label={__('Max', 'ghostkit')}
69 value={max}
70 onChange={(val) => setAttributes({ max: val })}
71 step={step}
72 min={min}
73 />
74 <TextControl
75 type="number"
76 label={__('Step', 'ghostkit')}
77 value={step}
78 onChange={(val) => setAttributes({ step: val })}
79 />
80 </PanelBody>
81 </InspectorControls>
82 <div {...blockProps}>
83 <FieldLabel {...props} />
84 <TextControl
85 type="number"
86 {...getFieldAttributes(attributes)}
87 />
88 <FieldDescription {...props} />
89 </div>
90 </>
91 );
92 }
93