-
Notifications
You must be signed in to change notification settings - Fork 33
/
save.js
55 lines (49 loc) · 1.05 KB
/
save.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import {
RichText,
useBlockProps
} from '@wordpress/block-editor';
const Save = ({
attributes
}) => {
const blockProps = useBlockProps.save({
id: attributes.id
});
return (
<div { ...blockProps }>
<label
htmlFor={ attributes.id ? attributes.id + '-input' : '' }
className="otter-form-input-label"
>
<RichText.Content
value={ attributes.label }
className="otter-form-input-label__label"
tagName="span"
/>
{ attributes.isRequired && (
<span className="required">*</span>
) }
</label>
<input
type={ attributes.type }
name={ attributes.mappedName }
id={ attributes.id ? attributes.id + '-input' : '' }
required={ attributes.isRequired }
placeholder={ attributes.placeholder }
className="otter-form-input"
value={ attributes?.defaultValue }
/>
{
attributes.helpText && (
<span className="o-form-help">
{ attributes.helpText }
</span>
)
}
</div>
);
};
export default Save;