/* tslint:disable */ /** * External dependencies */ import classnames from 'classnames'; import { __ } from '@wordpress/i18n'; import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt'; import { InnerBlocks, useBlockProps, InspectorControls, } from '@wordpress/block-editor'; import { PanelBody, ToggleControl, Notice } from '@wordpress/components'; import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices'; import { CART_PAGE_ID } from '@woocommerce/block-settings'; import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; import { EditorProvider, useEditorContext, CartProvider, } from '@woocommerce/base-context'; import { createInterpolateElement } from '@wordpress/element'; import { getAdminLink, getSetting } from '@woocommerce/settings'; import { previewCart } from '@woocommerce/resource-previews'; /** * Internal dependencies */ import './editor.scss'; import { addClassToBody } from './hacks'; import type { Attributes } from './types'; // This is adds a class to body to signal if the selected block is locked addClassToBody(); // Array of allowed block names. const ALLOWED_BLOCKS: string[] = [ 'woocommerce/filled-cart-block', 'woocommerce/empty-cart-block', ]; const BlockSettings = ( { attributes, setAttributes, }: { attributes: Attributes; setAttributes: ( attributes: Record< string, unknown > ) => undefined; } ): JSX.Element => { const { isShippingCalculatorEnabled, showRateAfterTaxName } = attributes; const { currentPostId } = useEditorContext(); return ( { currentPostId !== CART_PAGE_ID && ( { createInterpolateElement( __( 'If you would like to use this block as your default cart you must update your page settings in WooCommerce.', 'woo-gutenberg-products-block' ), { a: ( // eslint-disable-next-line jsx-a11y/anchor-has-content ), } ) } ) } { getSetting( 'shippingEnabled', true ) && ( setAttributes( { isShippingCalculatorEnabled: ! isShippingCalculatorEnabled, } ) } /> ) } { getSetting( 'taxesEnabled' ) && getSetting( 'displayItemizedTaxes', false ) && ! getSetting( 'displayCartPricesIncludingTax', false ) && ( setAttributes( { showRateAfterTaxName: ! showRateAfterTaxName, } ) } /> ) } ); }; /** * Component to handle edit mode of "Cart Block". */ export const Edit = ( { className, attributes, setAttributes, }: { className: string; attributes: Attributes; setAttributes: ( attributes: Record< string, unknown > ) => undefined; } ): JSX.Element => { const cartClassName = classnames( { 'has-dark-controls': attributes.hasDarkControls, } ); const defaultInnerBlocksTemplate = [ [ 'woocommerce/filled-cart-block', {}, [ [ 'woocommerce/cart-items-block', {}, [ [ 'woocommerce/cart-line-items-block', {}, [] ] ], ], [ 'woocommerce/cart-totals-block', {}, [ [ 'woocommerce/cart-order-summary-block', {}, [] ], [ 'woocommerce/cart-express-payment-block', {}, [] ], [ 'woocommerce/proceed-to-checkout-block', {}, [] ], ], ], ], ], [ 'woocommerce/empty-cart-block', {}, [] ], ]; return (
); }; export const Save = (): JSX.Element => { return (
); };