Server IP : 172.67.158.161 / Your IP : 3.144.19.224 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/blocks/checkout/ |
Upload File : |
/** * External dependencies */ import { Children, cloneElement, isValidElement } from '@wordpress/element'; import { getValidBlockAttributes } from '@woocommerce/base-utils'; import { useStoreCart } from '@woocommerce/base-context'; import { useCheckoutExtensionData, useValidation, } from '@woocommerce/base-context/hooks'; import { getRegisteredBlockComponents } from '@woocommerce/blocks-registry'; import { renderParentBlock } from '@woocommerce/atomic-utils'; /** * Internal dependencies */ import './inner-blocks/register-components'; import Block from './block'; import { blockName, blockAttributes } from './attributes'; import metadata from './block.json'; const getProps = ( el: Element ) => { return { attributes: getValidBlockAttributes( { ...metadata.attributes, ...blockAttributes }, /* eslint-disable @typescript-eslint/no-explicit-any */ ( el instanceof HTMLElement ? el.dataset : {} ) as any ), }; }; const Wrapper = ( { children, }: { children: React.ReactChildren; } ): React.ReactNode => { // we need to pluck out receiveCart. // eslint-disable-next-line no-unused-vars const { extensions, receiveCart, ...cart } = useStoreCart(); const checkoutExtensionData = useCheckoutExtensionData(); const validation = useValidation(); return Children.map( children, ( child ) => { if ( isValidElement( child ) ) { const componentProps = { extensions, cart, checkoutExtensionData, validation, }; return cloneElement( child, componentProps ); } return child; } ); }; renderParentBlock( { Block, blockName, selector: '.wp-block-woocommerce-checkout', getProps, blockMap: getRegisteredBlockComponents( blockName ) as Record< string, React.ReactNode >, blockWrapper: Wrapper, } );