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

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

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