/** * WordPress dependencies */ import { __ } from "@wordpress/i18n"; import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor"; import { useEffect, useState, useRef } from "@wordpress/element"; import { select, dispatch, useSelect } from "@wordpress/data"; /** * Internal dependencies */ const { duplicateBlockIdFix, filterBlocksByName, getBlockParentClientId, EBDisplayIcon, DynamicInputValueHandler, BlockProps } = EBControls; import classnames from "classnames"; import Inspector from "./inspector"; import Style from "./style"; export default function Edit(props) { const { attributes, setAttributes, isSelected, clientId, className, name, } = props; const { resOption, blockMeta, parentBlockId, blockId, classHook, showLabel, labelText, fieldName, defaultValue, placeholderText, isRequired, validationMessage, validationRules, numberValidationMessage, isIcon, icon, formStyle, parentBlockPaddingLeft, parentBlockPaddingUnit, parentBlockIconSize, parentIconColor, } = attributes; // you must declare this variable const enhancedProps = { ...props, blockPrefix: 'eb-number-field', rootClass: "eb-guten-block-main-parent-wrapper eb-form-field", style: }; //UseEffect for set Validation rules useEffect(() => { const rules = { [fieldName]: { isRequired: { status: isRequired, message: validationMessage, }, isNumber: { message: numberValidationMessage, }, }, }; setAttributes({ validationRules: rules }); }, [isRequired, fieldName, validationMessage]); return ( <> {isSelected && ( )} {showLabel && formStyle != "form-style-modern" && ( <> setAttributes({ labelText }) } readOnly={true} />{" "} {isRequired && ( * )} > )} {isIcon && icon && } {formStyle == "form-style-modern" && ( <> {labelText}{" "} {isRequired && ( * )} > )} {isRequired && ( <> {validationMessage} > )} > ); } {"id":163,"count":6,"description":"","link":"https:\/\/acessoriosparamoveis.com.br\/category\/mostbet-uz\/","name":"mostbet uz","slug":"mostbet-uz","taxonomy":"category","parent":0,"meta":[],"_links":{"self":[{"href":"https:\/\/acessoriosparamoveis.com.br\/wp-json\/wp\/v2\/categories\/163"}],"collection":[{"href":"https:\/\/acessoriosparamoveis.com.br\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"https:\/\/acessoriosparamoveis.com.br\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"https:\/\/acessoriosparamoveis.com.br\/wp-json\/wp\/v2\/posts?categories=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}