wordpress-blocks-sft / combined_val.jsonl
mattPearce's picture
Upload combined_val.jsonl with huggingface_hub
c24d8d4 verified
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a custom Gutenberg block that renders taxonomy terms comprehensively, featuring a dropdown interface, hierarchical organization, and extensible display settings."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/categories/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/categories\",\n\t\"title\": \"Terms List\",\n\t\"category\": \"widgets\",\n\t\"description\": \"Display a list of all terms of a given taxonomy.\",\n\t\"keywords\": [ \"categories\" ],\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"taxonomy\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"category\"\n\t\t},\n\t\t\"displayAsDropdown\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showHierarchy\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showPostCounts\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showOnlyTopLevel\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showEmpty\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"label\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"showLabel\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t}\n\t},\n\t\"usesContext\": [ \"enhancedPagination\" ],\n\t\"supports\": {\n\t\t\"align\": true,\n\t\t\"html\": false,\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"margin\": false,\n\t\t\t\t\"padding\": false\n\t\t\t}\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true,\n\t\t\t\t\"link\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-categories-editor\",\n\t\"style\": \"wp-block-categories\"\n}\n\n\n// File: packages/block-library/src/categories/index.js\n/**\n * WordPress dependencies\n */\nimport { category as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Design a theme block enabling users to easily adjust and customize text alignment settings within the block."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/term-description/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/term-description\",\n\t\"title\": \"Term Description\",\n\t\"category\": \"theme\",\n\t\"description\": \"Display the description of categories, tags and custom taxonomies when viewing an archive.\",\n\t\"textdomain\": \"default\",\n\t\"usesContext\": [ \"termId\", \"taxonomy\" ],\n\t\"attributes\": {\n\t\t\"textAlign\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"padding\": true,\n\t\t\t\"margin\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// File: packages/block-library/src/term-description/index.js\n/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\texample: {},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a block that Display an input field customers can use to select the number of products to add to their cart. "}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/quantity-selector/block.json\n{\n\t\"name\": \"woocommerce/add-to-cart-with-options-quantity-selector\",\n\t\"title\": \"Product Quantity (Beta)\",\n\t\"description\": \"Display an input field customers can use to select the number of products to add to their cart. \",\n\t\"category\": \"woocommerce-product-elements\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"usesContext\": [ \"postId\" ],\n\t\"ancestor\": [ \"woocommerce/add-to-cart-with-options\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"supports\": {\n\t\t\"interactivity\": true\n\t},\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"style\": \"file:../woocommerce/add-to-cart-with-options-quantity-selector-style.css\",\n\t\"viewScriptModule\": \"woocommerce/add-to-cart-with-options-quantity-selector\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/quantity-selector/edit.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { Disabled } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport QuantityStepper from '../components/quantity-stepper';\n\nconst AddToCartWithOptionsQuantitySelectorEdit = () => {\n\tconst blockProps = useBlockProps( {\n\t\tclassName: 'wc-block-add-to-cart-with-options__quantity-selector',\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Disabled>\n\t\t\t\t<QuantityStepper />\n\t\t\t</Disabled>\n\t\t</div>\n\t);\n};\n\nexport default AddToCartWithOptionsQuantitySelectorEdit;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Craft a customizable WordPress block enabling merchants to present order summaries with adjustable lock mechanisms for enhanced user management."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/block.json\n{\n\t\"name\": \"woocommerce/checkout-order-summary-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Order Summary\",\n\t\"description\": \"Show customers a summary of their order.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"inserter\": false,\n\t\t\"lock\": false\n\t},\n\t\"attributes\": {\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [\n\t\t\"woocommerce/checkout-totals-block\"\n\t],\n\t\"textdomain\": \"woocommerce\",\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3\n}\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps, InnerBlocks } from '@wordpress/block-editor';\nimport type { TemplateArray } from '@wordpress/blocks';\nimport { innerBlockAreas } from '@woocommerce/blocks-checkout';\nimport { TotalsFooterItem } from '@woocommerce/base-components/cart-checkout';\nimport { getCurrencyFromPriceResponse } from '@woocommerce/price-format';\nimport { useStoreCart } from '@woocommerce/base-context/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { useId, useState } from '@wordpress/element';\nimport { Icon } from '@wordpress/components';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\nimport clsx from 'clsx';\nimport { FormattedMonetaryAmount } from '@woocommerce/blocks-components';\nimport { useContainerWidthContext } from '@woocommerce/base-context';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseForcedLayout,\n\tgetAllowedBlocks,\n} from '../../../cart-checkout-shared';\nimport { OrderMetaSlotFill } from './slotfills';\n\nexport const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {\n\tconst blockProps = useBlockProps();\n\tconst { cartTotals } = useStoreCart();\n\tconst totalsCurrency = getCurrencyFromPriceResponse( cartTotals );\n\tconst totalPrice = parseInt( cartTotals.total_price, 10 );\n\tconst allowedBlocks = getAllowedBlocks(\n\t\tinnerBlockAreas.CHECKOUT_ORDER_SUMMARY\n\t);\n\tconst { isLarge } = useContainerWidthContext();\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst ariaControlsId = useId();\n\n\tconst orderSummaryProps = ! isLarge\n\t\t? {\n\t\t\t\trole: 'button',\n\t\t\t\tonClick: () => setIsOpen( ! isOpen ),\n\t\t\t\t'aria-expanded': isOpen,\n\t\t\t\t'aria-controls': ariaControlsId,\n\t\t\t\ttabIndex: 0,\n\t\t\t\tonKeyDown: ( event: React.KeyboardEvent ) => {\n\t\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\t\tsetIsOpen( ! isOpen );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t }\n\t\t: {};\n\n\tconst defaultTemplate = [\n\t\t[ 'woocommerce/checkout-order-summary-cart-items-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-order-summary-coupon-form-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-order-summary-totals-block', {}, [] ],\n\t] as TemplateArray;\n\n\tuseForcedLayout( {\n\t\tclientId,\n\t\tregisteredBlocks: allowedBlocks,\n\t\tdefaultTemplate,\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<div\n\t\t\t\tclassName=\"wc-block-components-checkout-order-summary__title\"\n\t\t\t\t{ ...orderSummaryProps }\n\t\t\t>\n\t\t\t\t<p\n\t\t\t\t\tclassName=\"wc-block-components-checkout-order-summary__title-text\"\n\t\t\t\t\trole=\"heading\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Order summary', 'woocommerce' ) }\n\t\t\t\t</p>\n\t\t\t\t<FormattedMonetaryAmount\n\t\t\t\t\tcurrency={ totalsCurrency }\n\t\t\t\t\tvalue={ totalPrice }\n\t\t\t\t\tclassName=\"wc-block-components-checkout-order-summary__title-price\"\n\t\t\t\t/>\n\t\t\t\t<span className=\"wc-block-components-checkout-order-summary__title-icon\">\n\t\t\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wc-block-components-checkout-order-summary__content',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-open': isOpen,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tid={ ariaControlsId }\n\t\t\t>\n\t\t\t\t<InnerBlocks\n\t\t\t\t\tallowedBlocks={ allowedBlocks }\n\t\t\t\t\ttemplate={ defaultTemplate }\n\t\t\t\t/>\n\t\t\t\t<div className=\"wc-block-components-totals-wrapper\">\n\t\t\t\t\t<TotalsFooterItem\n\t\t\t\t\t\tcurrency={ totalsCurrency }\n\t\t\t\t\t\tvalues={ cartTotals }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<OrderMetaSlotFill />\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn (\n\t\t<div { ...useBlockProps.save() }>\n\t\t\t<InnerBlocks.Content />\n\t\t</div>\n\t);\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a design block with customizable tabs id, orientation, active tab index, and 12 more options"}, {"role": "assistant", "content": "// File: packages/block-library/src/tabs/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"__experimental\": true,\n\t\"apiVersion\": 3,\n\t\"name\": \"core/tabs\",\n\t\"title\": \"Tabs\",\n\t\"description\": \"Display content in a tabbed interface to help users navigate detailed content with ease.\",\n\t\"version\": \"1.0.0\",\n\t\"category\": \"design\",\n\t\"textdomain\": \"default\",\n\t\"allowedBlocks\": [ \"core/tab\" ],\n\t\"attributes\": {\n\t\t\"tabsId\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"orientation\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"horizontal\",\n\t\t\t\"enum\": [ \"horizontal\", \"vertical\" ]\n\t\t},\n\t\t\"activeTabIndex\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 0\n\t\t},\n\t\t\"tabInactiveColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customTabInactiveColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"tabHoverColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customTabHoverColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"tabActiveColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customTabActiveColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"tabTextColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customTabTextColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"tabActiveTextColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customTabActiveTextColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"tabHoverTextColor\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customTabHoverTextColor\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t},\n\t\"styles\": [\n\t\t{\n\t\t\t\"name\": \"tab\",\n\t\t\t\"label\": \"Tabs\",\n\t\t\t\"isDefault\": true\n\t\t},\n\t\t{\n\t\t\t\"name\": \"links\",\n\t\t\t\"label\": \"Links\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"button\",\n\t\t\t\"label\": \"Button\"\n\t\t}\n\t],\n\t\"supports\": {\n\t\t\"align\": true,\n\t\t\"color\": {\n\t\t\t\"text\": false,\n\t\t\t\"background\": false\n\t\t},\n\t\t\"html\": false,\n\t\t\"interactivity\": true,\n\t\t\"spacing\": {\n\t\t\t\"blockGap\": [ \"horizontal\", \"vertical\" ],\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": false\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"__experimentalFontFamily\": true\n\t\t}\n\t},\n\t\"example\": {\n\t\t\"attributes\": {\n\t\t\t\"className\": \"is-example\"\n\t\t},\n\t\t\"innerBlocks\": [\n\t\t\t{\n\t\t\t\t\"name\": \"core/tab\",\n\t\t\t\t\"attributes\": {\n\t\t\t\t\t\"label\": \"Tab 1\"\n\t\t\t\t},\n\t\t\t\t\"innerBlocks\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"core/paragraph\",\n\t\t\t\t\t\t\"attributes\": {\n\t\t\t\t\t\t\t\"content\": \"Pariatur commodo sint mollit. Veniam Lorem labore voluptate fugiat. Ad nulla est labore cillum cillum qui nostrud do incididunt eiusmod. Aliqua aliqua sunt consequat consequat in duis deserunt.\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\": \"core/paragraph\",\n\t\t\t\t\t\t\"attributes\": {\n\t\t\t\t\t\t\t\"content\": \"Adipisicing ullamco nisi in eu laborum adipisicing aliquip aliqua. Fugiat labore officia consequat nisi veniam velit commodo cillum enim duis quis ad.\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"core/tab\",\n\t\t\t\t\"attributes\": {\n\t\t\t\t\t\"label\": \"Tab 2\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"core/tab\",\n\t\t\t\t\"attributes\": {\n\t\t\t\t\t\"label\": \"Tab 3\"\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t},\n\t\"providesContext\": {\n\t\t\"core/tabs-id\": \"tabsId\"\n\t},\n\t\"editorScript\": \"file:./index.js\",\n\t\"editorStyle\": \"file:./index.css\",\n\t\"style\": \"file:./style-index.css\",\n\t\"viewScriptModule\": \"@wordpress/block-library/tabs/view\"\n}\n\n\n// File: packages/block-library/src/tabs/index.js\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport save from './save';\nimport icon from './icon';\n\nimport metadata from './block.json';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/tabs/save.js\n/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\nexport default function Save( { attributes } ) {\n\t// eslint-disable-next-line react-compiler/react-compiler\n\tconst blockProps = useBlockProps.save();\n\n\t// eslint-disable-next-line react-compiler/react-compiler\n\tconst innerBlocksProps = useInnerBlocksProps.save( {} );\n\n\tconst title = attributes?.metadata?.name || 'Tab Contents';\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<h3 className=\"tabs__title\">{ title }</h3>\n\t\t\t<ul className=\"tabs__list\"></ul>\n\t\t\t{ innerBlocksProps.children }\n\t\t</div>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a Gutenberg block that Display a list of filter options. with these attributes: option element border, custom option element border, option element selected, and 5 more options"}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/checkbox-list/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"name\": \"woocommerce/product-filter-checkbox-list\",\n\t\"title\": \"List\",\n\t\"description\": \"Display a list of filter options.\",\n\t\"category\": \"woocommerce\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"ancestor\": [\n\t\t\"woocommerce/product-filter-attribute\",\n\t\t\"woocommerce/product-filter-status\",\n\t\t\"woocommerce/product-filter-taxonomy\",\n\t\t\"woocommerce/product-filter-rating\"\n\t],\n\t\"supports\": {\n\t\t\"interactivity\": true\n\t},\n\t\"usesContext\": [ \"filterData\" ],\n\t\"attributes\": {\n\t\t\"optionElementBorder\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customOptionElementBorder\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"optionElementSelected\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customOptionElementSelected\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"optionElement\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customOptionElement\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"labelElement\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customLabelElement\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t}\n\t},\n\t\"viewScriptModule\": \"woocommerce/product-filter-checkbox-list\",\n\t\"style\": \"file:../woocommerce/product-filter-checkbox-list-style.css\",\n\t\"editorStyle\": \"file:../woocommerce/product-filter-checkbox-list-editor.css\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/checkbox-list/edit.tsx\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, Disabled } from '@wordpress/components';\nimport { checkMark } from '@woocommerce/icons';\nimport { useMemo } from '@wordpress/element';\nimport { decodeHtmlEntities } from '@woocommerce/utils';\nimport {\n\tuseBlockProps,\n\twithColors,\n\tInspectorControls,\n\t// @ts-expect-error - no types.\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t// @ts-expect-error - no types.\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport './style.scss';\nimport './editor.scss';\nimport { EditProps } from './types';\nimport { getColorClasses, getColorVars } from './utils';\n\nconst CheckboxListEdit = ( props: EditProps ): JSX.Element => {\n\tconst {\n\t\tclientId,\n\t\tcontext,\n\t\tattributes,\n\t\tsetAttributes,\n\t\toptionElementBorder,\n\t\tsetOptionElementBorder,\n\t\toptionElementSelected,\n\t\tsetOptionElementSelected,\n\t\toptionElement,\n\t\tsetOptionElement,\n\t\tlabelElement,\n\t\tsetLabelElement,\n\t} = props;\n\n\tconst {\n\t\tcustomOptionElementBorder,\n\t\tcustomOptionElementSelected,\n\t\tcustomOptionElement,\n\t\tcustomLabelElement,\n\t} = attributes;\n\tconst { filterData } = context;\n\tconst { isLoading, items, showCounts } = filterData;\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wc-block-product-filter-checkbox-list', {\n\t\t\t'is-loading': isLoading,\n\t\t\t...getColorClasses( attributes ),\n\t\t} ),\n\t\tstyle: getColorVars( attributes ),\n\t} );\n\n\tconst loadingState = useMemo( () => {\n\t\treturn [ ...Array( 5 ) ].map( ( x, i ) => (\n\t\t\t<div\n\t\t\t\tclassName=\"wc-block-product-filter-checkbox-list__item\"\n\t\t\t\tkey={ i }\n\t\t\t\tstyle={ {\n\t\t\t\t\t/* stylelint-disable */\n\t\t\t\t\twidth: Math.floor( Math.random() * 75 ) + '%',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t&nbsp;\n\t\t\t</div>\n\t\t) );\n\t}, [] );\n\n\tif ( ! items ) {\n\t\treturn <></>;\n\t}\n\n\tconst threshold = 15;\n\tconst isLongList = items.length > threshold;\n\n\treturn (\n\t\t<>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Disabled>\n\t\t\t\t\t<div className=\"wc-block-product-filter-checkbox-list__items\">\n\t\t\t\t\t\t{ isLoading && loadingState }\n\t\t\t\t\t\t{ ! isLoading &&\n\t\t\t\t\t\t\t( isLongList\n\t\t\t\t\t\t\t\t? items.slice( 0, threshold )\n\t\t\t\t\t\t\t\t: items\n\t\t\t\t\t\t\t).map( ( item, index ) => (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'wc-block-product-filter-checkbox-list__item',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t[ `has-depth-${ item?.depth }` ]:\n\t\t\t\t\t\t\t\t\t\t\t\titem?.depth,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\thtmlFor={ `interactive-checkbox-${ index }` }\n\t\t\t\t\t\t\t\t\t\tclassName=\" wc-block-product-filter-checkbox-list__label\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span className=\"wc-block-product-filter-checkbox-list__input-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\t\tname={ `interactive-checkbox-${ index }` }\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"wc-block-product-filter-checkbox-list__input\"\n\t\t\t\t\t\t\t\t\t\t\t\tdefaultChecked={\n\t\t\t\t\t\t\t\t\t\t\t\t\t!! item.selected\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"wc-block-product-filter-checkbox-list__mark\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ checkMark }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t<span className=\"wc-block-product-filter-checkbox-list__text-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wc-block-product-filter-checkbox-list__text\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ typeof item.label === 'string'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? decodeHtmlEntities(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titem.label\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: item.label }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t{ showCounts && (\n\t\t\t\t\t\t\t\t\t\t\t\t<span className=\"wc-block-product-filter-checkbox-list__count\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ ` (${ item.count })` }\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ ! isLoading && isLongList && (\n\t\t\t\t\t\t<button className=\"wc-block-product-filter-checkbox-list__show-more\">\n\t\t\t\t\t\t\t{ __( 'Show more…', 'woocommerce' ) }\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) }\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t{ colorGradientSettings.hasColorsOrGradients && (\n\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Label', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\tlabelElement.color || customLabelElement,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetLabelElement( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomLabelElement: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetLabelElement( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomLabelElement: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __(\n\t\t\t\t\t\t\t\t\t'Option Element Border',\n\t\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\toptionElementBorder.color ||\n\t\t\t\t\t\t\t\t\tcustomOptionElementBorder,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetOptionElementBorder( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomOptionElementBorder: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetOptionElementBorder( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomOptionElementBorder: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __(\n\t\t\t\t\t\t\t\t\t'Option Element (Selected)',\n\t\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\toptionElementSelected.color ||\n\t\t\t\t\t\t\t\t\tcustomOptionElementSelected,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetOptionElementSelected( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomOptionElementSelected: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetOptionElementSelected( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomOptionElementSelected: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Option Element', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\toptionElement.color || customOptionElement,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetOptionElement( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomOptionElement: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetOptionElement( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomOptionElement: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n};\n\nexport default withColors( {\n\toptionElementBorder: 'option-element-border',\n\toptionElementSelected: 'option-element-border',\n\toptionElement: 'option-element',\n\tlabelElement: 'label-element',\n} )( CheckboxListEdit );\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/checkbox-list/save.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport { BlockAttributes } from './types';\nimport { getColorClasses, getColorVars } from './utils';\n\nconst Save = ( { attributes }: { attributes: BlockAttributes } ) => {\n\tconst blockProps = useBlockProps.save( {\n\t\tclassName: clsx(\n\t\t\t'wc-block-product-filter-checkbox-list',\n\t\t\tattributes.className,\n\t\t\tgetColorClasses( attributes )\n\t\t),\n\t\tstyle: {\n\t\t\t...getColorVars( attributes ),\n\t\t},\n\t} );\n\n\treturn <div { ...blockProps } />;\n};\n\nexport default Save;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a block that Format the name of an attribute associated with a variable product."}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute-name/block.json\n{\n\t\"name\": \"woocommerce/add-to-cart-with-options-variation-selector-attribute-name\",\n\t\"title\": \"Variation Selector: Attribute Name (Beta)\",\n\t\"description\": \"Format the name of an attribute associated with a variable product.\",\n\t\"category\": \"woocommerce-product-elements\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"ancestor\": [\n\t\t\"woocommerce/add-to-cart-with-options-variation-selector-attribute\"\n\t],\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"supports\": {\n\t\t\"inserter\": false,\n\t\t\"interactivity\": true,\n\t\t\"align\": false,\n\t\t\"alignWide\": false,\n\t\t\"color\": {\n\t\t\t\"__experimentalSkipSerialization\": true,\n\t\t\t\"gradients\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true\n\t\t\t}\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"__experimentalSkipSerialization\": [\n\t\t\t\t\"fontSize\",\n\t\t\t\t\"lineHeight\",\n\t\t\t\t\"fontFamily\",\n\t\t\t\t\"fontWeight\",\n\t\t\t\t\"fontStyle\",\n\t\t\t\t\"textTransform\",\n\t\t\t\t\"textDecoration\",\n\t\t\t\t\"letterSpacing\"\n\t\t\t],\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalWritingMode\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"__experimentalSkipSerialization\": true,\n\t\t\t\"padding\": [ \"horizontal\", \"vertical\" ],\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"padding\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"usesContext\": [\n\t\t\"woocommerce/attributeId\",\n\t\t\"woocommerce/attributeName\",\n\t\t\"woocommerce/attributeTerms\"\n\t],\n\t\"style\": \"file:../woocommerce/add-to-cart-with-options-variation-selector-attribute-name-style.css\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute-name/edit.tsx\n/**\n * External dependencies\n */\nimport { type BlockEditProps } from '@wordpress/blocks';\nimport {\n\tuseBlockProps,\n\t__experimentalUseColorProps as useColorProps,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\tuseSettings,\n} from '@wordpress/block-editor';\nimport { useCustomDataContext } from '@woocommerce/shared-context';\nimport type { ProductResponseAttributeItem } from '@woocommerce/types';\nimport clsx from 'clsx';\n\ninterface Attributes {\n\tclassName?: string;\n}\n\nexport default function AttributeNameEdit(\n\tprops: BlockEditProps< Attributes >\n) {\n\tconst { attributes } = props;\n\tconst { className } = attributes;\n\n\tconst colorProps = useColorProps( attributes );\n\n\tconst [ fluidTypographySettings, layout ] = useSettings(\n\t\t'typography.fluid',\n\t\t'layout'\n\t);\n\tconst typographyProps = useTypographyProps( attributes, {\n\t\ttypography: {\n\t\t\tfluid: fluidTypographySettings,\n\t\t},\n\t\tlayout: {\n\t\t\twideSize: layout?.wideSize,\n\t\t},\n\t} );\n\n\tconst spacingProps = useSpacingProps( attributes );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx(\n\t\t\tclassName,\n\t\t\tcolorProps.className,\n\t\t\ttypographyProps.className,\n\t\t\tspacingProps.className\n\t\t),\n\t\tstyle: {\n\t\t\t...colorProps.stye,\n\t\t\t...typographyProps.style,\n\t\t\t...spacingProps.style,\n\t\t},\n\t} );\n\n\tconst { data: attribute } =\n\t\tuseCustomDataContext< ProductResponseAttributeItem >( 'attribute' );\n\n\tif ( ! attribute ) return;\n\n\treturn (\n\t\t<label { ...blockProps } htmlFor={ attribute.taxonomy }>\n\t\t\t{ attribute.name }\n\t\t</label>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for A single accordion that displays a header and expandable content. that allows users to configure: open by default"}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/accordion/inner-blocks/accordion-item/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"woocommerce/accordion-item\",\n\t\"title\": \"Accordion\",\n\t\"category\": \"woocommerce\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"description\": \"A single accordion that displays a header and expandable content.\",\n\t\"example\": {},\n\t\"__experimental\": true,\n\t\"parent\": [ \"woocommerce/accordion-group\" ],\n\t\"allowedBlocks\": [\n\t\t\"woocommerce/accordion-header\",\n\t\t\"woocommerce/accordion-panel\"\n\t],\n\t\"supports\": {\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"color\": {\n\t\t\t\"background\": true,\n\t\t\t\"gradient\": true\n\t\t},\n\t\t\"interactivity\": true,\n\t\t\"spacing\": {\n\t\t\t\"margin\": [ \"top\", \"bottom\" ],\n\t\t\t\"blockGap\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"color\": true,\n\t\t\t\"radius\": true,\n\t\t\t\"style\": true,\n\t\t\t\"width\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"color\": true,\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"style\": true,\n\t\t\t\t\"width\": true\n\t\t\t}\n\t\t},\n\t\t\"shadow\": true,\n\t\t\"layout\": true\n\t},\n\t\"attributes\": {\n\t\t\"openByDefault\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t}\n\t},\n\t\"textdomain\": \"woocommerce\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/accordion/inner-blocks/accordion-item/index.js\n/**\n * External dependencies\n */\nimport { SVG, Path } from '@wordpress/components';\nimport { registerBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport save from './save';\nimport metadata from './block.json';\n\nconst icon = (\n\t<SVG\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t\tfill=\"none\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t>\n\t\t<Path\n\t\t\tfillRule=\"evenodd\"\n\t\t\tclipRule=\"evenodd\"\n\t\t\td=\"M19.5 9.5L9.5 9.5L9.5 8L19.5 8L19.5 9.5Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<Path\n\t\t\tfillRule=\"evenodd\"\n\t\t\tclipRule=\"evenodd\"\n\t\t\td=\"M19.5 13L9.5 13L9.5 11.5L19.5 11.5L19.5 13Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<Path\n\t\t\tfillRule=\"evenodd\"\n\t\t\tclipRule=\"evenodd\"\n\t\t\td=\"M19.5 16.3999L9.5 16.3999L9.5 14.8999L19.5 14.8999L19.5 16.3999Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<Path d=\"M4.5 6.25L8.5 8.75L4.5 11.25L4.5 6.25Z\" fill=\"currentColor\" />\n\t</SVG>\n);\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\tapiVersion: 3,\n\ticon,\n\texample: {},\n\tedit,\n\tsave,\n};\n\nregisterBlockType( metadata, settings );\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/accordion/inner-blocks/accordion-item/save.js\n/**\n * External dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\nimport clsx from 'clsx';\n\nexport default function save( { attributes } ) {\n\tconst { openByDefault } = attributes;\n\tconst blockProps = useBlockProps.save();\n\tconst className = clsx(\n\t\t{\n\t\t\t'is-open': openByDefault,\n\t\t},\n\t\tblockProps.className\n\t);\n\tconst innerBlocksProps = useInnerBlocksProps.save( {\n\t\t...blockProps,\n\t\tclassName,\n\t} );\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Embed a Pinterest pin, board, or user. that allows users to configure: url"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/pinterest/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/pinterest\",\n\t\"title\": \"Pinterest\",\n\t\"description\": \"Embed a Pinterest pin, board, or user.\",\n\t\"keywords\": [ \"social\", \"pinboard\", \"pins\" ],\n\t\"version\": \"12.5.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"embed\",\n\t\"icon\": \"<svg viewBox='0 0 24 24' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><path d='M12,2C6.477,2,2,6.477,2,12c0,4.236,2.636,7.855,6.356,9.312c-0.087-0.791-0.166-2.005,0.035-2.869c0.182-0.78,1.173-4.971,1.173-4.971s-0.299-0.599-0.299-1.484c0-1.39,0.806-2.429,1.809-2.429c0.853,0,1.265,0.641,1.265,1.409c0,0.858-0.546,2.141-0.828,3.329c-0.236,0.996,0.499,1.807,1.481,1.807c1.777,0,3.144-1.874,3.144-4.579c0-2.394-1.72-4.068-4.177-4.068c-2.845,0-4.515,2.134-4.515,4.34c0,0.859,0.331,1.781,0.744,2.282c0.082,0.099,0.094,0.186,0.069,0.287C8.18,14.682,8.011,15.361,7.978,15.5c-0.044,0.183-0.145,0.222-0.334,0.134c-1.249-0.581-2.03-2.407-2.03-3.874c0-3.154,2.292-6.051,6.607-6.051c3.469,0,6.165,2.472,6.165,5.775c0,3.446-2.173,6.22-5.189,6.22c-1.013,0-1.966-0.526-2.292-1.148c0,0-0.501,1.909-0.623,2.377c-0.226,0.869-0.835,1.957-1.243,2.622C9.975,21.844,10.969,22,12,22c5.523,0,10-4.477,10-10C22,6.477,17.523,2,12,2z'/></svg>\",\n\t\"supports\": {\n\t\t\"html\": false,\n\t\t\"align\": false,\n\t\t\"inserter\": false\n\t},\n\t\"attributes\": {\n\t\t\"url\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t},\n\t\"example\": {\n\t\t\"attributes\": {\n\t\t\t\"url\": \"https://pinterest.com/anapinskywalker/\"\n\t\t}\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/pinterest/edit.js\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { SandBox, withNotices } from '@wordpress/components';\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport EditUrlForm from './components/edit-url-form';\nimport ErrorNotice from './components/error-notice';\nimport LoadingContainer from './components/loading-container';\nimport useTestPinterestEmbedUrl from './hooks/use-test-pinterest-embed-url';\nimport { pinType } from './utils';\n\nexport function PinterestEdit( {\n\tattributes,\n\tisSelected,\n\tnoticeOperations,\n\tnoticeUI,\n\tsetAttributes,\n\tonReplace,\n} ) {\n\tconst { url } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst { isFetching, pinterestUrl, testUrl, hasTestUrlError } = useTestPinterestEmbedUrl();\n\tconst [ isInteractive, setIsInteractive ] = useState( false );\n\tconst [ editedUrl, setEditedUrl ] = useState( '' );\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\n\t/**\n\t * Sets an error notice using noticeOperations.\n\t */\n\tconst getErrorNotice = useCallback( () => {\n\t\treturn <ErrorNotice fallbackUrl={ editedUrl } onClick={ onReplace } />;\n\t\t// Disabling for onReplace and editedUrl as they are not requirements for creating a new function.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ hasTestUrlError ] );\n\n\t/**\n\t * Submit handler for the url editing form.\n\t */\n\tconst onSubmitForm = () => {\n\t\tif ( isFetching ) {\n\t\t\treturn;\n\t\t}\n\t\ttestUrl( editedUrl );\n\t\tsetIsEditing( false );\n\t};\n\n\t/**\n\t * This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop\n\t * changing, because that happens on mouse down, and the overlay immediately disappears,\n\t * and the mouse event can end up in the preview content. We can't use onClick on\n\t * the overlay to hide it either, because then the editor misses the mouseup event, and\n\t * thinks we're multi-selecting blocks.\n\t */\n\tconst hideOverlay = () => {\n\t\tsetIsInteractive( true );\n\t};\n\n\t/*\n\t\tSet the URL when the component mounts.\n\t\tWe disable missing dependencies warning in the linter\n\t\tbecause we want this to run once on mount.\n\t */\n\tuseEffect( () => {\n\t\tif ( url ) {\n\t\t\ttestUrl( url );\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\t/*\n\t\tWe only want to change `isInteractive` when the block is not selected, because changing it when\n\t\tthe block becomes selected makes the overlap disappear too early. Hiding the overlay\n\t\thappens on mouseup when the overlay is clicked.\n\t*/\n\tuseEffect( () => {\n\t\tif ( ! isSelected && isInteractive ) {\n\t\t\tsetIsInteractive( false );\n\t\t}\n\t}, [ isSelected, isInteractive ] );\n\n\t// Listen out for changes to after we've tested the url via `testUrl()`.\n\tuseEffect( () => {\n\t\tsetAttributes( { url: pinterestUrl } );\n\t\tnoticeOperations.removeAllNotices();\n\t\t// Set the input value of the edited URL.\n\t\tif ( pinterestUrl ) {\n\t\t\tsetEditedUrl( pinterestUrl );\n\t\t}\n\t\tif ( hasTestUrlError ) {\n\t\t\tnoticeOperations.createErrorNotice( getErrorNotice() );\n\t\t}\n\t\t// Disabling for noticeOperations as it is a prop and not a requirement for re-rendering.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ pinterestUrl, hasTestUrlError, setAttributes, getErrorNotice ] );\n\n\tif ( isFetching ) {\n\t\treturn <LoadingContainer />;\n\t}\n\n\tconst pinterestEmbedType = pinType( url );\n\n\tlet content;\n\n\tif ( isEditing || ! url || ( url && ! pinterestEmbedType ) ) {\n\t\tcontent = (\n\t\t\t<EditUrlForm\n\t\t\t\tonSubmit={ onSubmitForm }\n\t\t\t\tnoticeUI={ noticeUI }\n\t\t\t\turl={ editedUrl }\n\t\t\t\tsetUrl={ setEditedUrl }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\tconst sandBoxHTML = `<a data-pin-do='${ pinterestEmbedType }' href='${ url }'></a>`;\n\t\t/*\n\t\tDisabled because the overlay div doesn't actually have a role or functionality\n\t\tas far as the user is concerned. We're just catching the first click so that\n\t\tthe block can be selected without interacting with the embed preview that the overlay covers.\n\t */\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\tcontent = (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<div>\n\t\t\t\t\t<SandBox\n\t\t\t\t\t\thtml={ sandBoxHTML }\n\t\t\t\t\t\tscripts={ [ 'https://assets.pinterest.com/js/pinit.js' ] }\n\t\t\t\t\t\tonFocus={ hideOverlay }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isInteractive && (\n\t\t\t\t\t\t<div className=\"block-library-embed__interactive-overlay\" onMouseUp={ hideOverlay } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...blockProps }>{ content }</div>;\n}\n\nexport default withNotices( PinterestEdit );\n\n\n// File: projects/plugins/jetpack/extensions/blocks/pinterest/save.js\nimport { useBlockProps } from '@wordpress/block-editor';\n\nexport default function Save( { attributes } ) {\n\tconst blockProps = useBlockProps.save();\n\tconst { url } = attributes;\n\n\treturn (\n\t\t<a { ...blockProps } href={ url }>\n\t\t\t{ url }\n\t\t</a>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a Gutenberg block that Contains the products table and other custom blocks of filled mini-cart. with these attributes: lock"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/block.json\n{\n\t\"name\": \"woocommerce/mini-cart-items-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Mini-Cart Items\",\n\t\"description\": \"Contains the products table and other custom blocks of filled mini-cart.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"inserter\": false,\n\t\t\"lock\": false,\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t}\n\t},\n\t\"attributes\": {\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [ \"woocommerce/filled-mini-cart-contents-block\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps, InnerBlocks } from '@wordpress/block-editor';\nimport type { TemplateArray } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getMiniCartAllowedBlocks } from '../allowed-blocks';\n\nexport const Edit = (): JSX.Element => {\n\tconst blockProps = useBlockProps( {\n\t\tclassName: 'wc-block-mini-cart__items',\n\t} );\n\n\tconst defaultTemplate = [\n\t\t[ 'woocommerce/mini-cart-products-table-block', {} ],\n\t].filter( Boolean ) as unknown as TemplateArray;\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<InnerBlocks\n\t\t\t\ttemplate={ defaultTemplate }\n\t\t\t\trenderAppender={ InnerBlocks.ButtonBlockAppender }\n\t\t\t\ttemplateLock={ false }\n\t\t\t\tallowedBlocks={ getMiniCartAllowedBlocks() }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn (\n\t\t<div { ...useBlockProps.save() }>\n\t\t\t<InnerBlocks.Content />\n\t\t</div>\n\t);\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a theme block with customizable format, is link"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/comment-date/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/comment-date\",\n\t\"title\": \"Comment Date\",\n\t\"category\": \"theme\",\n\t\"ancestor\": [ \"core/comment-template\" ],\n\t\"description\": \"Displays the date on which the comment was posted.\",\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"format\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"isLink\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t}\n\t},\n\t\"usesContext\": [ \"commentId\" ],\n\t\"supports\": {\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true,\n\t\t\t\t\"link\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"style\": \"wp-block-comment-date\"\n}\n\n\n// File: packages/block-library/src/comment-date/index.js\n/**\n * WordPress dependencies\n */\nimport { postDate as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tdeprecated,\n\texample: {},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a WordPress block that enables users to input a custom label and configurable statistics, with flexible display options for presenting data."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/blog-stats/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/blog-stats\",\n\t\"title\": \"Blog Stats\",\n\t\"description\": \"Show a stats counter for your blog.\",\n\t\"keywords\": [ \"views\", \"hits\", \"analytics\", \"counter\", \"visitors\" ],\n\t\"version\": \"1.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"grow\",\n\t\"icon\": \"<svg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24'><path d='M160-200h160v-320H160v320Zm240 0h160v-560H400v560Zm240 0h160v-240H640v240ZM80-120v-480h240v-240h320v320h240v400H80Z'/></svg>\",\n\t\"supports\": {\n\t\t\"align\": true,\n\t\t\"alignWide\": true,\n\t\t\"html\": false,\n\t\t\"multiple\": true,\n\t\t\"reusable\": true,\n\t\t\"color\": {\n\t\t\t\"gradients\": true\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"fontSize\": true\n\t\t}\n\t},\n\t\"attributes\": {\n\t\t\"label\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"statsData\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"views\"\n\t\t},\n\t\t\"statsOption\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"site\"\n\t\t}\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/blog-stats/edit.js\nimport { useModuleStatus } from '@automattic/jetpack-shared-extension-utils';\nimport { formatNumber } from '@automattic/number-formatters';\nimport apiFetch from '@wordpress/api-fetch';\nimport { InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __, _n } from '@wordpress/i18n';\nimport { BlogStatsInspectorControls } from './controls';\nimport { InactiveStatsPlaceholder } from './inactive-placeholder';\n\nfunction BlogStatsEdit( { attributes, className, setAttributes } ) {\n\tconst { isLoadingModules, isChangingStatus, isModuleActive, changeStatus } =\n\t\tuseModuleStatus( 'stats' );\n\tconst { label, statsData, statsOption } = attributes;\n\tconst [ blogViews, setBlogViews ] = useState( null );\n\tconst [ blogVisitors, setBlogVisitors ] = useState();\n\tconst [ postViews, setPostViews ] = useState();\n\tconst blockProps = useBlockProps();\n\n\tconst blogStats = statsData === 'views' ? blogViews : blogVisitors;\n\tconst stats = statsOption === 'post' ? postViews : blogStats;\n\n\tconst postId = useSelect( select => select( 'core/editor' ).getCurrentPostId(), [] );\n\n\tuseEffect( () => {\n\t\tif ( isModuleActive ) {\n\t\t\tapiFetch( {\n\t\t\t\tpath: Number.isInteger( postId )\n\t\t\t\t\t? `/wpcom/v2/blog-stats?post_id=${ postId }`\n\t\t\t\t\t: '/wpcom/v2/blog-stats',\n\t\t\t} ).then( response => {\n\t\t\t\tsetBlogViews( response[ 'blog-views' ] );\n\t\t\t\tsetBlogVisitors( response[ 'blog-visitors' ] );\n\n\t\t\t\t// Display \"12,345\" as an obvious placeholder when we have no Post ID.\n\t\t\t\t// Applies to widgets, FSE templates etc.\n\t\t\t\tsetPostViews( Number.isInteger( postId ) ? response[ 'post-views' ] : '12345' );\n\t\t\t} );\n\t\t}\n\t}, [ postId, isModuleActive ] );\n\n\t// We don't collect visitor data for individual posts.\n\tuseEffect( () => {\n\t\tif ( statsData === 'visitors' ) {\n\t\t\tsetAttributes( { statsOption: 'site' } );\n\t\t}\n\t}, [ statsData, setAttributes ] );\n\n\tif ( ! isModuleActive && ! isLoadingModules ) {\n\t\treturn (\n\t\t\t<InactiveStatsPlaceholder\n\t\t\t\tclassName={ className }\n\t\t\t\tchangeStatus={ changeStatus }\n\t\t\t\tisLoading={ isChangingStatus }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst visitorsPlaceholder =\n\t\t/* Translators: Number of visitors */\n\t\t_n( 'visitor', 'visitors', parseInt( stats ), 'jetpack', 0 );\n\n\tconst viewsPlaceholder =\n\t\t/* Translators: Number of views */\n\t\t_n( 'hit', 'hits', parseInt( stats ), 'jetpack', 0 );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<InspectorControls>\n\t\t\t\t<BlogStatsInspectorControls attributes={ attributes } setAttributes={ setAttributes } />\n\t\t\t</InspectorControls>\n\n\t\t\t<div className={ className }>\n\t\t\t\t{ isLoadingModules || blogViews === null ? (\n\t\t\t\t\t<p className=\"jetpack-blog-stats__loading\">{ __( 'Loading stats…', 'jetpack' ) }</p>\n\t\t\t\t) : (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<span>{ formatNumber( stats ) } </span>\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\tplaceholder={ statsData === 'visitors' ? visitorsPlaceholder : viewsPlaceholder }\n\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\tallowedFormats={ [ 'core/bold', 'core/italic', 'core/link' ] }\n\t\t\t\t\t\t\tonChange={ newLabel => setAttributes( { label: newLabel } ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default BlogStatsEdit;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Display removable active filters as chips. that allows users to configure: chip text, custom chip text, chip background, and 3 more options"}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/removable-chips/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"name\": \"woocommerce/product-filter-removable-chips\",\n\t\"title\": \"Chips\",\n\t\"description\": \"Display removable active filters as chips.\",\n\t\"category\": \"woocommerce\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"ancestor\": [ \"woocommerce/product-filter-active\" ],\n\t\"supports\": {\n\t\t\"layout\": {\n\t\t\t\"allowSwitching\": false,\n\t\t\t\"allowInheriting\": false,\n\t\t\t\"allowVerticalAlignment\": false,\n\t\t\t\"default\": {\n\t\t\t\t\"type\": \"flex\"\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": true\n\t},\n\t\"usesContext\": [ \"queryId\", \"filterData\" ],\n\t\"attributes\": {\n\t\t\"chipText\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customChipText\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"chipBackground\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customChipBackground\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"chipBorder\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"customChipBorder\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t},\n\t\"style\": \"file:../woocommerce/product-filter-removable-chips-style.css\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/removable-chips/edit.tsx\n/**\n * External dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport clsx from 'clsx';\nimport { Icon, closeSmall, arrowRight, arrowDown } from '@wordpress/icons';\nimport { Label } from '@woocommerce/blocks-components';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockControls,\n\twithColors,\n\t// @ts-expect-error - no types.\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t// @ts-expect-error - no types.\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { EditProps } from './types';\nimport { getColorClasses, getColorVars } from './utils';\n\nconst Edit = ( props: EditProps ): JSX.Element => {\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst {\n\t\tname,\n\t\tcontext,\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tchipText,\n\t\tsetChipText,\n\t\tchipBackground,\n\t\tsetChipBackground,\n\t\tchipBorder,\n\t\tsetChipBorder,\n\t} = props;\n\tconst { customChipText, customChipBackground, customChipBorder, layout } =\n\t\tattributes;\n\tconst { filterData } = context;\n\tconst { items } = filterData;\n\n\t// Extract attributes from block layout\n\tconst layoutBlockSupport = getBlockSupport( name, 'layout' );\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wc-block-product-filter-removable-chips', {\n\t\t\t...getColorClasses( attributes ),\n\t\t} ),\n\t\tstyle: getColorVars( attributes ),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {} );\n\tconst removeText = ( label: string ): string => {\n\t\treturn sprintf(\n\t\t\t/* translators: %s attribute value used in the filter. For example: yellow, green, small, large. */\n\t\t\t__( 'Remove %s filter', 'woocommerce' ),\n\t\t\tlabel\n\t\t);\n\t};\n\n\treturn (\n\t\t<div { ...innerBlocksProps }>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ arrowRight }\n\t\t\t\t\t\tlabel={ __( 'Horizontal', 'woocommerce' ) }\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...usedLayout,\n\t\t\t\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisPressed={\n\t\t\t\t\t\t\tusedLayout.orientation === 'horizontal' ||\n\t\t\t\t\t\t\t! usedLayout.orientation\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ arrowDown }\n\t\t\t\t\t\tlabel={ __( 'Vertical', 'woocommerce' ) }\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...usedLayout,\n\t\t\t\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisPressed={ usedLayout.orientation === 'vertical' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<ul className=\"wc-block-product-filter-removable-chips__items\">\n\t\t\t\t{ items?.map( ( item, index ) => (\n\t\t\t\t\t<li\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"wc-block-product-filter-removable-chips__item\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"wc-block-product-filter-removable-chips__label\">\n\t\t\t\t\t\t\t{ item.type + ': ' + item.label }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<button className=\"wc-block-product-filter-removable-chips__remove\">\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\tclassName=\"wc-block-product-filter-removable-chips__remove-icon\"\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tsize={ 25 }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Label\n\t\t\t\t\t\t\t\tscreenReaderLabel={ removeText(\n\t\t\t\t\t\t\t\t\titem.type + ': ' + item.label\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t{ colorGradientSettings.hasColorsOrGradients && (\n\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Chip Text', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue: chipText.color || customChipText,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetChipText( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomChipText: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetChipText( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomChipText: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Chip Border', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\tchipBorder.color || customChipBorder,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetChipBorder( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomChipBorder: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetChipBorder( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomChipBorder: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Chip Background', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\tchipBackground.color ||\n\t\t\t\t\t\t\t\t\tcustomChipBackground,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetChipBackground( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomChipBackground: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetChipBackground( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomChipBackground: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t</div>\n\t);\n};\n\nexport default withColors( {\n\tchipText: 'chip-text',\n\tchipBorder: 'chip-border',\n\tchipBackground: 'chip-background',\n} )( Edit );\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/removable-chips/save.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport { BlockAttributes } from './types';\nimport { getColorClasses, getColorVars } from './utils';\n\nconst Save = ( {\n\tattributes,\n\tstyle,\n}: {\n\tattributes: BlockAttributes;\n\tstyle: Record< string, string >;\n} ) => {\n\tconst blockProps = useBlockProps.save( {\n\t\tclassName: clsx(\n\t\t\t'wc-block-product-filter-removable-chips',\n\t\t\tattributes.className,\n\t\t\tgetColorClasses( attributes )\n\t\t),\n\t\tstyle: {\n\t\t\t...style,\n\t\t\t...getColorVars( attributes ),\n\t\t},\n\t} );\n\n\treturn <div { ...blockProps } />;\n};\n\nexport default Save;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a WordPress block enabling dynamic comment display with customizable tag and legacy settings for enhanced visual presentation."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/comments/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/comments\",\n\t\"title\": \"Comments\",\n\t\"category\": \"theme\",\n\t\"description\": \"An advanced block that allows displaying post comments using different visual configurations.\",\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"tagName\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"div\"\n\t\t},\n\t\t\"legacy\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"heading\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true,\n\t\t\t\t\"link\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-comments-editor\",\n\t\"usesContext\": [ \"postId\", \"postType\" ]\n}\n\n\n// File: packages/block-library/src/comments/index.js\n/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/comments/save.js\n/**\n * WordPress dependencies\n */\nimport { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes: { tagName: Tag, legacy } } ) {\n\tconst blockProps = useBlockProps.save();\n\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\n\t// The legacy version is dynamic (i.e. PHP rendered) and doesn't allow inner\n\t// blocks, so nothing is saved in that case.\n\treturn legacy ? null : <Tag { ...innerBlocksProps } />;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Display content in multiple columns, with blocks added to each column. that allows users to configure: vertical alignment, is stacked on mobile, template lock"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/columns/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/columns\",\n\t\"title\": \"Columns\",\n\t\"category\": \"design\",\n\t\"allowedBlocks\": [ \"core/column\" ],\n\t\"description\": \"Display content in multiple columns, with blocks added to each column.\",\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"verticalAlignment\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"isStackedOnMobile\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"templateLock\": {\n\t\t\t\"type\": [ \"string\", \"boolean\" ],\n\t\t\t\"enum\": [ \"all\", \"insert\", \"contentOnly\", false ]\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"anchor\": true,\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"link\": true,\n\t\t\t\"heading\": true,\n\t\t\t\"button\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"blockGap\": {\n\t\t\t\t\"__experimentalDefault\": \"2em\",\n\t\t\t\t\"sides\": [ \"horizontal\", \"vertical\" ]\n\t\t\t},\n\t\t\t\"margin\": [ \"top\", \"bottom\" ],\n\t\t\t\"padding\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"padding\": true,\n\t\t\t\t\"blockGap\": true\n\t\t\t}\n\t\t},\n\t\t\"layout\": {\n\t\t\t\"allowSwitching\": false,\n\t\t\t\"allowInheriting\": false,\n\t\t\t\"allowEditing\": false,\n\t\t\t\"default\": {\n\t\t\t\t\"type\": \"flex\",\n\t\t\t\t\"flexWrap\": \"nowrap\"\n\t\t\t}\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"color\": true,\n\t\t\t\"radius\": true,\n\t\t\t\"style\": true,\n\t\t\t\"width\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"color\": true,\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"style\": true,\n\t\t\t\t\"width\": true\n\t\t\t}\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"shadow\": true\n\t},\n\t\"editorStyle\": \"wp-block-columns-editor\",\n\t\"style\": \"wp-block-columns\"\n}\n\n\n// File: packages/block-library/src/columns/index.js\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { columns as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport variations from './variations';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tvariations,\n\texample: {\n\t\tviewportWidth: 782, // Columns collapse \"@media (max-width: 781px)\".\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et eros eu felis.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/image',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Suspendisse commodo neque lacus, a dictum orci interdum et.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Etiam et egestas lorem. Vivamus sagittis sit amet dolor quis lobortis. Integer sed fermentum arcu, id vulputate lacus. Etiam fermentum sem eu quam hendrerit.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Nam risus massa, ullamcorper consectetur eros fermentum, porta aliquet ligula. Sed vel mauris nec enim.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n\tdeprecated,\n\tedit,\n\tsave,\n\ttransforms,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/columns/save.js\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { isStackedOnMobile, verticalAlignment } = attributes;\n\n\tconst className = clsx( {\n\t\t[ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,\n\t\t[ `is-not-stacked-on-mobile` ]: ! isStackedOnMobile,\n\t} );\n\n\tconst blockProps = useBlockProps.save( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a woocommerce block with customizable is preview, lock, width"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/block.json\n{\n\t\"name\": \"woocommerce/mini-cart-contents\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Mini-Cart Contents\",\n\t\"description\": \"Display a Mini-Cart widget.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"inserter\": false,\n\t\t\"color\": {\n\t\t\t\"text\": true,\n\t\t\t\"background\": true,\n\t\t\t\"link\": true\n\t\t},\n\t\t\"lock\": false,\n\t\t\"__experimentalBorder\": {\n\t\t\t\"color\": true,\n\t\t\t\"width\": true\n\t\t}\n\t},\n\t\"attributes\": {\n\t\t\"isPreview\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": true\n\t\t\t}\n\t\t},\n\t\t\"width\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"480px\"\n\t\t}\n\t},\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/edit.tsx\n/* eslint-disable jsdoc/check-alignment */\n/**\n * External dependencies\n */\nimport {\n\tuseBlockProps,\n\tInnerBlocks,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { EditorProvider } from '@woocommerce/base-context';\nimport type { TemplateArray } from '@wordpress/blocks';\nimport type { FocusEvent, ReactElement } from 'react';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useForcedLayout } from '../../cart-checkout-shared';\nimport { MiniCartInnerBlocksStyle } from './inner-blocks-style';\nimport './editor.scss';\nimport { attributes as defaultAttributes } from './attributes';\nimport { useThemeColors } from '../../../shared/hooks/use-theme-colors';\n\n// Array of allowed block names.\nconst ALLOWED_BLOCKS = [\n\t'woocommerce/filled-mini-cart-contents-block',\n\t'woocommerce/empty-mini-cart-contents-block',\n];\nconst MIN_WIDTH = 300;\n\ninterface Props {\n\tclientId: string;\n\tattributes: Record< string, unknown >;\n\tsetAttributes: ( attributes: Record< string, unknown > ) => void;\n}\n\nconst Edit = ( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n}: Props ): ReactElement => {\n\tconst { currentView, width } = attributes;\n\n\tconst blockProps = useBlockProps();\n\n\tconst defaultTemplate = [\n\t\t[ 'woocommerce/filled-mini-cart-contents-block', {}, [] ],\n\t\t[ 'woocommerce/empty-mini-cart-contents-block', {}, [] ],\n\t] as TemplateArray;\n\n\tuseForcedLayout( {\n\t\tclientId,\n\t\tregisteredBlocks: ALLOWED_BLOCKS,\n\t\tdefaultTemplate,\n\t} );\n\n\t// Apply the Mini-Cart Contents block base styles based on Site Editor's background and text colors.\n\t// We need to set `div` in the selector so it has more specificity than the CSS.\n\tuseThemeColors(\n\t\t'mini-cart-contents',\n\t\t( { editorBackgroundColor, editorColor } ) => `\n\t\t\t\tdiv:where(.wp-block-woocommerce-mini-cart-contents) {\n\t\t\t\t\tbackground-color: ${ editorBackgroundColor };\n\t\t\t\t\tcolor: ${ editorColor };\n\t\t\t\t}\n\t\t\t`\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls key=\"inspector\">\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Dimensions', 'woocommerce' ) }\n\t\t\t\t\tinitialOpen\n\t\t\t\t>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetAttributes( { width: value } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonBlur={ ( e: FocusEvent< HTMLInputElement > ) => {\n\t\t\t\t\t\t\tif ( e.target.value === '' ) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\twidth: defaultAttributes.width.default,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else if ( Number( e.target.value ) < MIN_WIDTH ) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\twidth: MIN_WIDTH + 'px',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tunits={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'px',\n\t\t\t\t\t\t\t\tlabel: 'px',\n\t\t\t\t\t\t\t\tdefault: defaultAttributes.width.default,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div\n\t\t\t\tclassName=\"wc-block-components-drawer__screen-overlay\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t></div>\n\t\t\t<div className=\"wc-block-editor-mini-cart-contents__wrapper\">\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<EditorProvider currentView={ currentView }>\n\t\t\t\t\t\t<InnerBlocks\n\t\t\t\t\t\t\tallowedBlocks={ ALLOWED_BLOCKS }\n\t\t\t\t\t\t\ttemplate={ defaultTemplate }\n\t\t\t\t\t\t\ttemplateLock={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t\t<MiniCartInnerBlocksStyle style={ blockProps.style } />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default Edit;\n\nexport const Save = (): JSX.Element => {\n\treturn (\n\t\t<div { ...useBlockProps.save() }>\n\t\t\t<InnerBlocks.Content />\n\t\t</div>\n\t);\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Craft a configurable block for displaying taxonomy term names, offering users control over text positioning, heading hierarchy, and link integration."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/term-name/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/term-name\",\n\t\"title\": \"Term Name\",\n\t\"category\": \"theme\",\n\t\"description\": \"Displays the name of a taxonomy term.\",\n\t\"keywords\": [ \"term title\" ],\n\t\"textdomain\": \"default\",\n\t\"usesContext\": [ \"termId\", \"taxonomy\" ],\n\t\"attributes\": {\n\t\t\"textAlign\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"level\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 0\n\t\t},\n\t\t\"isLink\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"levelOptions\": {\n\t\t\t\"type\": \"array\"\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true,\n\t\t\t\t\"link\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"style\": \"wp-block-term-name\"\n}\n\n\n// File: packages/block-library/src/term-name/index.js\n/**\n * WordPress dependencies\n */\nimport { termName as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Craft a Gutenberg block to showcase taxonomy terms, incorporating a dropdown view, hierarchical display, and additional configurable options for comprehensive term representation."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/categories/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/categories\",\n\t\"title\": \"Terms List\",\n\t\"category\": \"widgets\",\n\t\"description\": \"Display a list of all terms of a given taxonomy.\",\n\t\"keywords\": [ \"categories\" ],\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"taxonomy\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"category\"\n\t\t},\n\t\t\"displayAsDropdown\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showHierarchy\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showPostCounts\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showOnlyTopLevel\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"showEmpty\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"label\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"showLabel\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t}\n\t},\n\t\"usesContext\": [ \"enhancedPagination\" ],\n\t\"supports\": {\n\t\t\"align\": true,\n\t\t\"html\": false,\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"margin\": false,\n\t\t\t\t\"padding\": false\n\t\t\t}\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true,\n\t\t\t\t\"link\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-categories-editor\",\n\t\"style\": \"wp-block-categories\"\n}\n\n\n// File: packages/block-library/src/categories/index.js\n/**\n * WordPress dependencies\n */\nimport { category as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a Gutenberg block that Your site doesn’t include support for this block. with these attributes: original name, original undelimited content, original content"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/missing/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/missing\",\n\t\"title\": \"Unsupported\",\n\t\"category\": \"text\",\n\t\"description\": \"Your site doesn’t include support for this block.\",\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"originalName\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"originalUndelimitedContent\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"originalContent\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"raw\"\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"className\": false,\n\t\t\"customClassName\": false,\n\t\t\"inserter\": false,\n\t\t\"html\": false,\n\t\t\"lock\": false,\n\t\t\"reusable\": false,\n\t\t\"renaming\": false,\n\t\t\"visibility\": false,\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t}\n\t}\n}\n\n\n// File: packages/block-library/src/missing/index.js\n/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\tname,\n\t__experimentalLabel( attributes, { context } ) {\n\t\tif ( context === 'accessibility' ) {\n\t\t\tconst { originalName } = attributes;\n\n\t\t\tconst originalBlockType = originalName\n\t\t\t\t? getBlockType( originalName )\n\t\t\t\t: undefined;\n\n\t\t\tif ( originalBlockType ) {\n\t\t\t\treturn originalBlockType.settings.title || originalName;\n\t\t\t}\n\n\t\t\treturn '';\n\t\t}\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/missing/save.js\n/**\n * WordPress dependencies\n */\nimport { RawHTML } from '@wordpress/element';\n\nexport default function save( { attributes } ) {\n\t// Preserve the missing block's content.\n\treturn <RawHTML>{ attributes.originalContent }</RawHTML>;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a custom Gutenberg block enabling users to choose between shipping and local pickup, incorporating a locking mechanism for the selection process."}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.json\n{\n\t\"name\": \"woocommerce/checkout-shipping-method-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Delivery\",\n\t\"description\": \"Select between shipping or local pickup.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"inserter\": false,\n\t\t\"lock\": false\n\t},\n\t\"attributes\": {\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [\n\t\t\"woocommerce/checkout-fields-block\"\n\t],\n\t\"textdomain\": \"woocommerce\",\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3\n}\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/edit.tsx\n/* eslint-disable @wordpress/no-unsafe-wp-apis */\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { Icon, store, shipping } from '@wordpress/icons';\nimport { ADMIN_URL, getSetting } from '@woocommerce/settings';\nimport { LOCAL_PICKUP_ENABLED } from '@woocommerce/block-settings';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tRichText,\n} from '@wordpress/block-editor';\nimport { Button } from '@ariakit/react';\nimport { useShippingData } from '@woocommerce/base-context/hooks';\nimport { innerBlockAreas } from '@woocommerce/blocks-checkout';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { checkoutStore as checkoutStoreDescriptor } from '@woocommerce/block-data';\nimport ExternalLinkCard from '@woocommerce/editor-components/external-link-card';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tFormStepBlock,\n\tAdditionalFields,\n\tAdditionalFieldsContent,\n} from '../../form-step';\nimport { RatePrice, getLocalPickupPrices, getShippingPrices } from './shared';\nimport type { minMaxPrices } from './shared';\nimport './style.scss';\nimport { defaultShippingText, defaultLocalPickupText } from './constants';\n\nconst LocalPickupSelector = ( {\n\tchecked,\n\trate,\n\tshowPrice,\n\tshowIcon,\n\ttoggleText,\n\tsetAttributes,\n\tonClick,\n}: {\n\tchecked: string;\n\trate: minMaxPrices;\n\tshowPrice: boolean;\n\tshowIcon: boolean;\n\ttoggleText: string;\n\tonClick: () => void;\n\tsetAttributes: ( attributes: Record< string, unknown > ) => void;\n} ) => {\n\treturn (\n\t\t<Button\n\t\t\trender={ <div /> }\n\t\t\tclassName={ clsx( 'wc-block-checkout__shipping-method-option', {\n\t\t\t\t'wc-block-checkout__shipping-method-option--selected':\n\t\t\t\t\tchecked === 'pickup',\n\t\t\t} ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ showIcon === true && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ store }\n\t\t\t\t\tsize={ 28 }\n\t\t\t\t\tclassName=\"wc-block-checkout__shipping-method-option-icon\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tvalue={ toggleText }\n\t\t\t\tplaceholder={ defaultLocalPickupText }\n\t\t\t\ttagName=\"span\"\n\t\t\t\tclassName=\"wc-block-checkout__shipping-method-option-title\"\n\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\tsetAttributes( { localPickupText: value } )\n\t\t\t\t}\n\t\t\t\t__unstableDisableFormats\n\t\t\t\tpreserveWhiteSpace\n\t\t\t/>\n\t\t\t{ showPrice === true && (\n\t\t\t\t<RatePrice minRate={ rate.min } maxRate={ rate.max } />\n\t\t\t) }\n\t\t</Button>\n\t);\n};\n\nconst ShippingSelector = ( {\n\tchecked,\n\trate,\n\tshowPrice,\n\tshowIcon,\n\ttoggleText,\n\tsetAttributes,\n\tonClick,\n}: {\n\tchecked: string;\n\trate: minMaxPrices;\n\tshowPrice: boolean;\n\tshowIcon: boolean;\n\ttoggleText: string;\n\tsetAttributes: ( attributes: Record< string, unknown > ) => void;\n\tonClick: () => void;\n} ) => {\n\tconst Price =\n\t\trate.min === undefined ? (\n\t\t\t<span className=\"wc-block-checkout__shipping-method-option-price\">\n\t\t\t\t{ __( 'calculated with an address', 'woocommerce' ) }\n\t\t\t</span>\n\t\t) : (\n\t\t\t<RatePrice minRate={ rate.min } maxRate={ rate.max } />\n\t\t);\n\n\treturn (\n\t\t<Button\n\t\t\trender={ <div /> }\n\t\t\tclassName={ clsx( 'wc-block-checkout__shipping-method-option', {\n\t\t\t\t'wc-block-checkout__shipping-method-option--selected':\n\t\t\t\t\tchecked === 'shipping',\n\t\t\t} ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ showIcon === true && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ shipping }\n\t\t\t\t\tsize={ 28 }\n\t\t\t\t\tclassName=\"wc-block-checkout__shipping-method-option-icon\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tvalue={ toggleText }\n\t\t\t\tplaceholder={ defaultShippingText }\n\t\t\t\ttagName=\"span\"\n\t\t\t\tclassName=\"wc-block-checkout__shipping-method-option-title\"\n\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\tsetAttributes( { shippingText: value } )\n\t\t\t\t}\n\t\t\t\t__unstableDisableFormats\n\t\t\t\tpreserveWhiteSpace\n\t\t\t/>\n\t\t\t{ showPrice === true && Price }\n\t\t</Button>\n\t);\n};\n\nexport const Edit = ( {\n\tattributes,\n\tsetAttributes,\n}: {\n\tattributes: {\n\t\ttitle: string;\n\t\tdescription: string;\n\t\tshowStepNumber: boolean;\n\t\tallowCreateAccount: boolean;\n\t\tlocalPickupText: string;\n\t\tshippingText: string;\n\t\tshowPrice: boolean;\n\t\tshowIcon: boolean;\n\t\tclassName: string;\n\t};\n\tsetAttributes: ( attributes: Record< string, unknown > ) => void;\n} ): JSX.Element | null => {\n\tuseEffect( () => {\n\t\tconst localPickupTitle = getSetting< string >(\n\t\t\t'localPickupText',\n\t\t\tattributes.localPickupText\n\t\t);\n\t\tsetAttributes( { localPickupText: localPickupTitle } );\n\t\t// Disable the exhaustive deps rule because we only want to run this on first mount to set the attribute, not\n\t\t// each time the attribute changes.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ setAttributes ] );\n\tconst { setPrefersCollection } = useDispatch( checkoutStoreDescriptor );\n\tconst { prefersCollection } = useSelect( ( select ) => {\n\t\tconst checkoutStore = select( checkoutStoreDescriptor );\n\t\treturn {\n\t\t\tprefersCollection: checkoutStore.prefersCollection(),\n\t\t};\n\t} );\n\tconst { showPrice, showIcon, className, localPickupText, shippingText } =\n\t\tattributes;\n\tconst {\n\t\tshippingRates,\n\t\tneedsShipping,\n\t\thasCalculatedShipping,\n\t\tisCollectable,\n\t} = useShippingData();\n\n\tif (\n\t\t! needsShipping ||\n\t\t! hasCalculatedShipping ||\n\t\t! shippingRates ||\n\t\t! isCollectable ||\n\t\t! LOCAL_PICKUP_ENABLED\n\t) {\n\t\treturn null;\n\t}\n\n\tconst changeView = ( method: string ) => {\n\t\tif ( method === 'pickup' ) {\n\t\t\tsetPrefersCollection( true );\n\t\t} else {\n\t\t\tsetPrefersCollection( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t<FormStepBlock\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wc-block-checkout__shipping-method',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Appearance', 'woocommerce' ) }>\n\t\t\t\t\t<p className=\"wc-block-checkout__controls-text\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Choose how this block is displayed to your customers.',\n\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Show icon', 'woocommerce' ) }\n\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowIcon: ! showIcon,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Show costs', 'woocommerce' ) }\n\t\t\t\t\t\tchecked={ showPrice }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPrice: ! showPrice,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody title={ __( 'Shipping Methods', 'woocommerce' ) }>\n\t\t\t\t\t<p className=\"wc-block-checkout__controls-text\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Methods can be made managed in your store settings.',\n\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ExternalLinkCard\n\t\t\t\t\t\tkey={ 'shipping_methods' }\n\t\t\t\t\t\thref={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping` }\n\t\t\t\t\t\ttitle={ __( 'Shipping', 'woocommerce' ) }\n\t\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t\t'Manage your shipping zones, methods, and rates.',\n\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ExternalLinkCard\n\t\t\t\t\t\tkey={ 'pickup_location' }\n\t\t\t\t\t\thref={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping&section=pickup_location` }\n\t\t\t\t\t\ttitle={ __( 'Pickup', 'woocommerce' ) }\n\t\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t\t'Allow customers to choose a local pickup location during checkout.',\n\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div\n\t\t\t\tid=\"shipping-method\"\n\t\t\t\tclassName=\"wc-block-checkout__shipping-method-container\"\n\t\t\t\trole=\"radiogroup\"\n\t\t\t>\n\t\t\t\t<ShippingSelector\n\t\t\t\t\tchecked={ prefersCollection ? 'pickup' : 'shipping' }\n\t\t\t\t\trate={ getShippingPrices(\n\t\t\t\t\t\tshippingRates[ 0 ]?.shipping_rates\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tchangeView( 'shipping' );\n\t\t\t\t\t} }\n\t\t\t\t\tshowPrice={ showPrice }\n\t\t\t\t\tshowIcon={ showIcon }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\ttoggleText={ shippingText }\n\t\t\t\t/>\n\t\t\t\t<LocalPickupSelector\n\t\t\t\t\tchecked={ prefersCollection ? 'pickup' : 'shipping' }\n\t\t\t\t\trate={ getLocalPickupPrices(\n\t\t\t\t\t\tshippingRates[ 0 ]?.shipping_rates\n\t\t\t\t\t) }\n\t\t\t\t\tshowPrice={ showPrice }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tchangeView( 'pickup' );\n\t\t\t\t\t} }\n\t\t\t\t\tshowIcon={ showIcon }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\ttoggleText={ localPickupText }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<AdditionalFields block={ innerBlockAreas.SHIPPING_METHOD } />\n\t\t</FormStepBlock>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn (\n\t\t<div { ...useBlockProps.save() }>\n\t\t\t<AdditionalFieldsContent />\n\t\t</div>\n\t);\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a tailored Gutenberg block to enable seamless e-commerce and fundraising functionality directly within your WordPress site."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/payments-intro/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/payments-intro\",\n\t\"title\": \"Payments\",\n\t\"description\": \"Sell products and services or receive donations on your website.\",\n\t\"keywords\": [ \"earn\", \"monetize\", \"paid\", \"pay\", \"money\", \"checkout\" ],\n\t\"version\": \"12.5.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"monetize\",\n\t\"icon\": \"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'><path d='M3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zm-1.338 4.877c-.314.22-.412.452-.412.623 0 .171.098.403.412.623.312.218.783.377 1.338.377.825 0 1.605.233 2.198.648.59.414 1.052 1.057 1.052 1.852 0 .795-.461 1.438-1.052 1.852-.41.286-.907.486-1.448.582v.316a.75.75 0 01-1.5 0v-.316a3.64 3.64 0 01-1.448-.582c-.59-.414-1.052-1.057-1.052-1.852a.75.75 0 011.5 0c0 .171.098.403.412.623.312.218.783.377 1.338.377s1.026-.159 1.338-.377c.314-.22.412-.452.412-.623 0-.171-.098-.403-.412-.623-.312-.218-.783-.377-1.338-.377-.825 0-1.605-.233-2.198-.648-.59-.414-1.052-1.057-1.052-1.852 0-.795.461-1.438 1.052-1.852a3.64 3.64 0 011.448-.582V7.5a.75.75 0 011.5 0v.316c.54.096 1.039.296 1.448.582.59.414 1.052 1.057 1.052 1.852a.75.75 0 01-1.5 0c0-.171-.098-.403-.412-.623-.312-.218-.783-.377-1.338-.377s-1.026.159-1.338.377z'></path></svg>\",\n\t\"supports\": {\n\t\t\"alignWide\": false,\n\t\t\"className\": true,\n\t\t\"customClassName\": false,\n\t\t\"html\": false,\n\t\t\"reusable\": false\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/payments-intro/edit.js\nimport { InnerBlocks, store as blockEditorStore, useBlockProps } from '@wordpress/block-editor';\nimport { cloneBlock, createBlock, getBlockType, registerBlockVariation } from '@wordpress/blocks';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport ConnectBanner from '../../shared/components/connect-banner';\nimport useIsUserConnected from '../../shared/use-is-user-connected';\nimport PaymentsIntroBlockPicker from './block-picker';\nimport PaymentsIntroPatternPicker from './pattern-picker';\nimport defaultVariations from './variations';\n\nexport default function JetpackPaymentsIntroEdit( { name, clientId } ) {\n\tconst patternFilter = pattern => pattern.categories?.includes( 'shop' );\n\n\tconst blockProps = useBlockProps();\n\tconst { blockType, hasInnerBlocks, hasPatterns, settings } = useSelect( select => {\n\t\tconst { getBlocks, __experimentalGetAllowedPatterns, getSettings } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tsettings: getSettings(),\n\t\t\tblockType: getBlockType( name ),\n\t\t\thasInnerBlocks: getBlocks( clientId )?.length > 0,\n\t\t\thasPatterns: __experimentalGetAllowedPatterns?.().filter( patternFilter ).length > 0,\n\t\t};\n\t} );\n\n\tconst isUserConnected = useIsUserConnected();\n\n\tconst { replaceBlock, selectBlock, updateSettings } = useDispatch( blockEditorStore );\n\n\tconst maybeMakeBlockVisible = useCallback(\n\t\tblockName => {\n\t\t\tconst isBlockAllowed =\n\t\t\t\tsettings?.allowedBlockTypes === true || settings?.allowedBlockTypes?.includes( blockName );\n\t\t\tif ( ! isBlockAllowed ) {\n\t\t\t\t// Add the block to the allowed block list before rendering\n\t\t\t\tupdateSettings( {\n\t\t\t\t\t...settings,\n\t\t\t\t\tallowedBlockTypes: [ ...settings.allowedBlockTypes, blockName ],\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ settings, updateSettings ]\n\t);\n\n\tconst setVariation = variation => {\n\t\tconst blockName = variation.name;\n\n\t\tmaybeMakeBlockVisible( blockName );\n\t\treplaceBlock( clientId, createBlock( blockName ) );\n\t\tselectBlock( clientId );\n\t};\n\n\tconst usableVariations = defaultVariations.filter( variation => getBlockType( variation.name ) );\n\n\tuseEffect( () => {\n\t\t// Populate default variation on older versions of WP or GB that don't support variations.\n\t\tif ( ! hasInnerBlocks && ! registerBlockVariation ) {\n\t\t\tsetVariation( usableVariations[ 0 ] );\n\t\t}\n\t} );\n\n\tconst displayVariations = usableVariations.length && registerBlockVariation;\n\n\tlet instructions = __( \"Please select which kind of payment you'd like to add.\", 'jetpack' );\n\tif ( hasPatterns ) {\n\t\tinstructions = __( 'Start by choosing one of our suggested layout patterns.', 'jetpack' );\n\t}\n\n\tlet content;\n\n\tif ( ! isUserConnected ) {\n\t\tcontent = (\n\t\t\t<ConnectBanner\n\t\t\t\tblock=\"Payments\"\n\t\t\t\texplanation={ __(\n\t\t\t\t\t'Connect your WordPress.com account to start using payments blocks.',\n\t\t\t\t\t'jetpack'\n\t\t\t\t) }\n\t\t\t/>\n\t\t);\n\t} else if ( ! hasInnerBlocks && displayVariations ) {\n\t\tcontent = (\n\t\t\t<Placeholder\n\t\t\t\ticon={ blockType?.icon?.src }\n\t\t\t\tlabel={ blockType?.title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t>\n\t\t\t\t{ hasPatterns && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PaymentsIntroPatternPicker\n\t\t\t\t\t\t\tonBlockPatternSelect={ blocks => replaceBlock( clientId, blocks.map( cloneBlock ) ) }\n\t\t\t\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<p>{ __( 'Or use one of our blocks to create your own.', 'jetpack' ) }</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<PaymentsIntroBlockPicker\n\t\t\t\t\tlabel={ __( 'Payment Block list', 'jetpack' ) }\n\t\t\t\t\tvariations={ usableVariations }\n\t\t\t\t\tonSelect={ ( nextVariation = usableVariations[ 0 ] ) => {\n\t\t\t\t\t\tsetVariation( nextVariation );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</Placeholder>\n\t\t);\n\t} else {\n\t\tcontent = <InnerBlocks />;\n\t}\n\n\treturn <div { ...blockProps }>{ content }</div>;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a widgets block with customizable id, label, title, and 2 more options"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/page-list-item/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/page-list-item\",\n\t\"title\": \"Page List Item\",\n\t\"category\": \"widgets\",\n\t\"parent\": [ \"core/page-list\" ],\n\t\"description\": \"Displays a page inside a list of all pages.\",\n\t\"keywords\": [ \"page\", \"menu\", \"navigation\" ],\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"id\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"label\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"title\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"link\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"hasChildren\": {\n\t\t\t\"type\": \"boolean\"\n\t\t}\n\t},\n\t\"usesContext\": [\n\t\t\"textColor\",\n\t\t\"customTextColor\",\n\t\t\"backgroundColor\",\n\t\t\"customBackgroundColor\",\n\t\t\"overlayTextColor\",\n\t\t\"customOverlayTextColor\",\n\t\t\"overlayBackgroundColor\",\n\t\t\"customOverlayBackgroundColor\",\n\t\t\"fontSize\",\n\t\t\"customFontSize\",\n\t\t\"showSubmenuIcon\",\n\t\t\"style\",\n\t\t\"openSubmenusOnClick\"\n\t],\n\t\"supports\": {\n\t\t\"reusable\": false,\n\t\t\"html\": false,\n\t\t\"lock\": false,\n\t\t\"inserter\": false,\n\t\t\"__experimentalToolbar\": false,\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-page-list-editor\",\n\t\"style\": \"wp-block-page-list\"\n}\n\n\n// File: packages/block-library/src/page-list-item/index.js\n/**\n * WordPress dependencies\n */\nimport { page as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit.js';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\t__experimentalLabel: ( { label } ) => label,\n\ticon,\n\texample: {},\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Design a WooCommerce block for product components featuring intuitive, adaptable styling settings to enhance visual presentation and user interaction."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute-options/block.json\n{\n\t\"name\": \"woocommerce/add-to-cart-with-options-variation-selector-attribute-options\",\n\t\"title\": \"Variation Selector: Attribute Options (Beta)\",\n\t\"description\": \"Display the attribute options associated with a variable product.\",\n\t\"category\": \"woocommerce-product-elements\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"ancestor\": [\n\t\t\"woocommerce/add-to-cart-with-options-variation-selector-attribute\"\n\t],\n\t\"attributes\": {\n\t\t\"optionStyle\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"enum\": [ \"pills\", \"dropdown\" ]\n\t\t}\n\t},\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"supports\": {\n\t\t\"inserter\": false,\n\t\t\"interactivity\": true\n\t},\n\t\"usesContext\": [\n\t\t\"woocommerce/attributeId\",\n\t\t\"woocommerce/attributeName\",\n\t\t\"woocommerce/attributeTerms\"\n\t],\n\t\"style\": \"file:../woocommerce/add-to-cart-with-options-variation-selector-attribute-options-style.css\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute-options/edit.tsx\n/**\n * External dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport { type BlockEditProps } from '@wordpress/blocks';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useCustomDataContext } from '@woocommerce/shared-context';\nimport type { ProductResponseAttributeItem } from '@woocommerce/types';\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport { useThemeColors } from '../../../../shared/hooks/use-theme-colors';\n\ninterface Attributes {\n\tclassName?: string;\n\toptionStyle?: 'pills' | 'dropdown';\n}\n\nfunction Pills( {\n\tid,\n\toptions,\n}: {\n\tid: string;\n\toptions: SelectControl.Option[];\n} ) {\n\treturn (\n\t\t<ul\n\t\t\tid={ id }\n\t\t\tclassName=\"wc-block-add-to-cart-with-options-variation-selector-attribute-options__pills\"\n\t\t>\n\t\t\t{ options.map( ( option, index ) => (\n\t\t\t\t<li\n\t\t\t\t\tkey={ option.value }\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill--selected':\n\t\t\t\t\t\t\t\tindex === 0,\n\t\t\t\t\t\t\t'wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill--disabled':\n\t\t\t\t\t\t\t\toption.disabled,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ option.label }\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n\nexport default function AttributeOptionsEdit(\n\tprops: BlockEditProps< Attributes >\n) {\n\tconst { attributes, setAttributes } = props;\n\tconst { className, optionStyle } = attributes;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName,\n\t} );\n\n\t// Apply selected variation pill styles based on Site Editor's background and text colors.\n\tuseThemeColors(\n\t\t'add-to-cart-with-options-variation-selector-attribute-options',\n\t\t( { editorBackgroundColor, editorColor } ) => `\n\t\t\t:where(.wc-block-add-to-cart-with-options-variation-selector-attribute-options__pill--selected) {\n\t\t\t\t--pill-color: ${ editorBackgroundColor };\n\t\t\t\t--pill-background-color: ${ editorColor };\n\t\t\t}\n\t\t`\n\t);\n\n\tconst { data: attribute } =\n\t\tuseCustomDataContext< ProductResponseAttributeItem >( 'attribute' );\n\n\tif ( ! attribute ) return null;\n\n\tconst options = attribute.terms.map( ( term, index ) => ( {\n\t\tvalue: term.slug,\n\t\tlabel: term.name,\n\t\tdisabled: index > 1 && index === attribute.terms.length - 1,\n\t} ) );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Style', 'woocommerce' ) }>\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tlabel={ __( 'Style', 'woocommerce' ) }\n\t\t\t\t\t\tvalue={ optionStyle ?? 'pills' }\n\t\t\t\t\t\tonChange={ ( newOptionStyle ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnewOptionStyle === 'pills' ||\n\t\t\t\t\t\t\t\tnewOptionStyle === 'dropdown'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\toptionStyle: newOptionStyle,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"pills\"\n\t\t\t\t\t\t\tlabel={ __( 'Pills', 'woocommerce' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"dropdown\"\n\t\t\t\t\t\t\tlabel={ __( 'Dropdown', 'woocommerce' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<Disabled>\n\t\t\t\t{ optionStyle === 'dropdown' ? (\n\t\t\t\t\t<select\n\t\t\t\t\t\tid={ attribute.taxonomy }\n\t\t\t\t\t\tclassName=\"wc-block-add-to-cart-with-options-variation-selector-attribute-options__dropdown\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ options.map( ( option ) => (\n\t\t\t\t\t\t\t<option key={ option.value } value={ option.value }>\n\t\t\t\t\t\t\t\t{ option.label }\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</select>\n\t\t\t\t) : (\n\t\t\t\t\t<Pills id={ attribute.taxonomy } options={ options } />\n\t\t\t\t) }\n\t\t\t</Disabled>\n\t\t</div>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Design a dynamic tag visualization block that enables users to modify the keyword cloud's display, including tag count, taxonomy type, visibility settings, and two supplementary configuration choices."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/tag-cloud/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/tag-cloud\",\n\t\"title\": \"Tag Cloud\",\n\t\"category\": \"widgets\",\n\t\"description\": \"A cloud of popular keywords, each sized by how often it appears.\",\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"numberOfTags\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 45,\n\t\t\t\"minimum\": 1,\n\t\t\t\"maximum\": 100\n\t\t},\n\t\t\"taxonomy\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"post_tag\"\n\t\t},\n\t\t\"showTagCounts\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"smallestFontSize\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"8pt\"\n\t\t},\n\t\t\"largestFontSize\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"22pt\"\n\t\t}\n\t},\n\t\"styles\": [\n\t\t{ \"name\": \"default\", \"label\": \"Default\", \"isDefault\": true },\n\t\t{ \"name\": \"outline\", \"label\": \"Outline\" }\n\t],\n\t\"supports\": {\n\t\t\"html\": false,\n\t\t\"align\": true,\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalLetterSpacing\": true\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"__experimentalBorder\": {\n\t\t\t\"radius\": true,\n\t\t\t\"color\": true,\n\t\t\t\"width\": true,\n\t\t\t\"style\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"color\": true,\n\t\t\t\t\"width\": true,\n\t\t\t\t\"style\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-tag-cloud-editor\"\n}\n\n\n// File: packages/block-library/src/tag-cloud/index.js\n/**\n * WordPress dependencies\n */\nimport { tag as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport transforms from './transforms';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n\ttransforms,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a WordPress block specifically designed to display the cart shipping row, enabling users to implement customizable locking functionality."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-shipping/block.json\n{\n\t\"name\": \"woocommerce/checkout-order-summary-shipping-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Shipping\",\n\t\"description\": \"Shows the cart shipping row.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"lock\": false\n\t},\n\t\"attributes\": {\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [\n\t\t\"woocommerce/checkout-order-summary-totals-block\"\n\t],\n\t\"textdomain\": \"woocommerce\",\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3\n}\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-shipping/edit.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport Noninteractive from '@woocommerce/base-components/noninteractive';\n\n/**\n * Internal dependencies\n */\nimport Block from './block';\n\nexport const Edit = ( {\n\tattributes,\n}: {\n\tattributes: {\n\t\tclassName: string;\n\t};\n} ): JSX.Element => {\n\tconst { className } = attributes;\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Noninteractive>\n\t\t\t\t<Block className={ className } />\n\t\t\t</Noninteractive>\n\t\t</div>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn <div { ...useBlockProps.save() } />;\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a woocommerce block with customizable customer email, nonce token, align, and 3 more options"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/order-confirmation/create-account/block.json\n{\n\t\"name\": \"woocommerce/order-confirmation-create-account\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Account Creation\",\n\t\"description\": \"Allow customers to create an account after their purchase.\",\n\t\"category\": \"woocommerce\",\n\t\"keywords\": [\n\t\t\"WooCommerce\"\n\t],\n\t\"attributes\": {\n\t\t\"customerEmail\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"nonceToken\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"align\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"wide\"\n\t\t},\n\t\t\"className\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"hasDarkControls\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"multiple\": false,\n\t\t\"inserter\": false,\n\t\t\"html\": false,\n\t\t\"lock\": false,\n\t\t\"align\": [\n\t\t\t\"wide\",\n\t\t\t\"full\"\n\t\t],\n\t\t\"color\": {\n\t\t\t\"background\": true,\n\t\t\t\"text\": true,\n\t\t\t\"button\": true\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"padding\": true,\n\t\t\t\"margin\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"margin\": false,\n\t\t\t\t\"padding\": false\n\t\t\t}\n\t\t}\n\t},\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/order-confirmation/create-account/edit.tsx\n/**\n * External dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport clsx from 'clsx';\nimport type { TemplateArray, BlockAttributes } from '@wordpress/blocks';\nimport {\n\tDisabled,\n\tPanelBody,\n\tToggleControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { getSetting, ADMIN_URL } from '@woocommerce/settings';\n\n/**\n * Internal dependencies\n */\nimport './style.scss';\nimport { SITE_TITLE } from '../../../settings/shared/default-constants';\nimport Form from './form';\n\nconst defaultTemplate = [\n\t[\n\t\t'core/heading',\n\t\t{\n\t\t\tlevel: 3,\n\t\t\tcontent: sprintf(\n\t\t\t\t/* translators: %s: site name */\n\t\t\t\t__( 'Create an account with %s', 'woocommerce' ),\n\t\t\t\tSITE_TITLE\n\t\t\t),\n\t\t},\n\t],\n\t[\n\t\t'core/list',\n\t\t{\n\t\t\tclassName: 'is-style-checkmark-list',\n\t\t},\n\t\t[\n\t\t\t[\n\t\t\t\t'core/list-item',\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Faster future purchases', 'woocommerce' ),\n\t\t\t\t},\n\t\t\t],\n\t\t\t[\n\t\t\t\t'core/list-item',\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Securely save payment info', 'woocommerce' ),\n\t\t\t\t},\n\t\t\t],\n\t\t\t[\n\t\t\t\t'core/list-item',\n\t\t\t\t{\n\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t'Track orders & view shopping history',\n\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t],\n\t],\n] as TemplateArray;\n\ntype EditProps = {\n\tattributes: {\n\t\thasDarkControls: boolean;\n\t};\n\tsetAttributes: ( attrs: BlockAttributes ) => void;\n};\n\nexport const Edit = ( {\n\tattributes,\n\tsetAttributes,\n}: EditProps ): JSX.Element | null => {\n\tconst className = clsx( 'wc-block-order-confirmation-create-account', {\n\t\t'has-dark-controls': attributes.hasDarkControls,\n\t} );\n\tconst blockProps = useBlockProps( {\n\t\tclassName,\n\t} );\n\tconst isEnabled = getSetting( 'delayedAccountCreationEnabled', true );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst generatePassword = getSetting( 'registrationGeneratePassword', true );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<InnerBlocks\n\t\t\t\tallowedBlocks={ [\n\t\t\t\t\t'core/heading',\n\t\t\t\t\t'core/paragraph',\n\t\t\t\t\t'core/list',\n\t\t\t\t\t'core/list-item',\n\t\t\t\t\t'core/image',\n\t\t\t\t] }\n\t\t\t\ttemplate={ defaultTemplate }\n\t\t\t\ttemplateLock={ false }\n\t\t\t/>\n\t\t\t<Disabled>\n\t\t\t\t<Form isEditor={ true } />\n\t\t\t</Disabled>\n\t\t\t{ ! generatePassword && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Style', 'woocommerce' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Dark mode inputs', 'woocommerce' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Inputs styled specifically for use on dark background colors.',\n\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tchecked={ attributes.hasDarkControls }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\thasDarkControls:\n\t\t\t\t\t\t\t\t\t\t! attributes.hasDarkControls,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Configure this feature in your store settings.',\n\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=account` }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Manage account settings', 'woocommerce' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</div>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn (\n\t\t<div { ...useBlockProps.save() }>\n\t\t\t<InnerBlocks.Content />\n\t\t</div>\n\t);\n};\n\nexport default Edit;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a media block with customizable align, media alt, media position, and 16 more options"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/media-text/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/media-text\",\n\t\"title\": \"Media & Text\",\n\t\"category\": \"media\",\n\t\"description\": \"Set media and words side-by-side for a richer layout.\",\n\t\"keywords\": [ \"image\", \"video\" ],\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"align\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"none\"\n\t\t},\n\t\t\"mediaAlt\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"figure img\",\n\t\t\t\"attribute\": \"alt\",\n\t\t\t\"default\": \"\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"mediaPosition\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"left\"\n\t\t},\n\t\t\"mediaId\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"mediaUrl\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"figure video,figure img\",\n\t\t\t\"attribute\": \"src\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"mediaLink\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"linkDestination\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"linkTarget\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"figure a\",\n\t\t\t\"attribute\": \"target\"\n\t\t},\n\t\t\"href\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"figure a\",\n\t\t\t\"attribute\": \"href\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"rel\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"figure a\",\n\t\t\t\"attribute\": \"rel\"\n\t\t},\n\t\t\"linkClass\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"figure a\",\n\t\t\t\"attribute\": \"class\"\n\t\t},\n\t\t\"mediaType\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"mediaWidth\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 50\n\t\t},\n\t\t\"mediaSizeSlug\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"isStackedOnMobile\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"verticalAlignment\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"imageFill\": {\n\t\t\t\"type\": \"boolean\"\n\t\t},\n\t\t\"focalPoint\": {\n\t\t\t\"type\": \"object\"\n\t\t},\n\t\t\"useFeaturedImage\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t}\n\t},\n\t\"usesContext\": [ \"postId\", \"postType\" ],\n\t\"supports\": {\n\t\t\"anchor\": true,\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"html\": false,\n\t\t\"__experimentalBorder\": {\n\t\t\t\"color\": true,\n\t\t\t\"radius\": true,\n\t\t\t\"style\": true,\n\t\t\t\"width\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"color\": true,\n\t\t\t\t\"radius\": true,\n\t\t\t\t\"style\": true,\n\t\t\t\t\"width\": true\n\t\t\t}\n\t\t},\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"heading\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true\n\t\t\t}\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t},\n\t\t\"allowedBlocks\": true\n\t},\n\t\"editorStyle\": \"wp-block-media-text-editor\",\n\t\"style\": \"wp-block-media-text\"\n}\n\n\n// File: packages/block-library/src/media-text/index.js\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { mediaAndText as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tviewportWidth: 601, // Columns collapse \"@media (max-width: 600px)\".\n\t\tattributes: {\n\t\t\tmediaType: 'image',\n\t\t\tmediaUrl:\n\t\t\t\t'https://s.w.org/images/core/5.3/Biologia_Centrali-Americana_-_Cantorchilus_semibadius_1902.jpg',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t'The wren<br>Earns his living<br>Noiselessly.'\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( '— Kobayashi Issa (一茶)' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nif ( window.__experimentalContentOnlyInspectorFields ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'media',\n\t\t\tlabel: __( 'Media' ),\n\t\t\ttype: 'media',\n\t\t\tmapping: {\n\t\t\t\tid: 'mediaId',\n\t\t\t\ttype: 'mediaType',\n\t\t\t\turl: 'mediaUrl',\n\t\t\t\tlink: 'mediaLink',\n\t\t\t},\n\t\t\targs: {\n\t\t\t\tallowedTypes: [ 'image', 'video' ],\n\t\t\t\tmultiple: false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'link',\n\t\t\tlabel: __( 'Link' ),\n\t\t\ttype: 'link',\n\t\t\tmapping: {\n\t\t\t\turl: 'href',\n\t\t\t\trel: 'rel',\n\t\t\t\tlinkTarget: 'linkTarget',\n\t\t\t},\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'media' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/media-text/save.js\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { imageFillStyles } from './image-fill';\nimport { DEFAULT_MEDIA_SIZE_SLUG } from './constants';\n\nconst DEFAULT_MEDIA_WIDTH = 50;\nconst noop = () => {};\n\nexport default function save( { attributes } ) {\n\tconst {\n\t\tisStackedOnMobile,\n\t\tmediaAlt,\n\t\tmediaPosition,\n\t\tmediaType,\n\t\tmediaUrl,\n\t\tmediaWidth,\n\t\tmediaId,\n\t\tverticalAlignment,\n\t\timageFill,\n\t\tfocalPoint,\n\t\tlinkClass,\n\t\thref,\n\t\tlinkTarget,\n\t\trel,\n\t} = attributes;\n\tconst mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;\n\tconst newRel = ! rel ? undefined : rel;\n\n\tconst imageClasses = clsx( {\n\t\t[ `wp-image-${ mediaId }` ]: mediaId && mediaType === 'image',\n\t\t[ `size-${ mediaSizeSlug }` ]: mediaId && mediaType === 'image',\n\t} );\n\n\tconst positionStyles = imageFill\n\t\t? imageFillStyles( mediaUrl, focalPoint )\n\t\t: {};\n\n\tlet image = mediaUrl ? (\n\t\t<img\n\t\t\tsrc={ mediaUrl }\n\t\t\talt={ mediaAlt }\n\t\t\tclassName={ imageClasses || null }\n\t\t\tstyle={ positionStyles }\n\t\t/>\n\t) : null;\n\n\tif ( href ) {\n\t\timage = (\n\t\t\t<a\n\t\t\t\tclassName={ linkClass }\n\t\t\t\thref={ href }\n\t\t\t\ttarget={ linkTarget }\n\t\t\t\trel={ newRel }\n\t\t\t>\n\t\t\t\t{ image }\n\t\t\t</a>\n\t\t);\n\t}\n\n\tconst mediaTypeRenders = {\n\t\timage: () => image,\n\t\tvideo: () => <video controls src={ mediaUrl } />,\n\t};\n\tconst className = clsx( {\n\t\t'has-media-on-the-right': 'right' === mediaPosition,\n\t\t'is-stacked-on-mobile': isStackedOnMobile,\n\t\t[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,\n\t\t'is-image-fill-element': imageFill,\n\t} );\n\n\tlet gridTemplateColumns;\n\tif ( mediaWidth !== DEFAULT_MEDIA_WIDTH ) {\n\t\tgridTemplateColumns =\n\t\t\t'right' === mediaPosition\n\t\t\t\t? `auto ${ mediaWidth }%`\n\t\t\t\t: `${ mediaWidth }% auto`;\n\t}\n\tconst style = {\n\t\tgridTemplateColumns,\n\t};\n\n\tif ( 'right' === mediaPosition ) {\n\t\treturn (\n\t\t\t<div { ...useBlockProps.save( { className, style } ) }>\n\t\t\t\t<div\n\t\t\t\t\t{ ...useInnerBlocksProps.save( {\n\t\t\t\t\t\tclassName: 'wp-block-media-text__content',\n\t\t\t\t\t} ) }\n\t\t\t\t/>\n\t\t\t\t<figure className=\"wp-block-media-text__media\">\n\t\t\t\t\t{ ( mediaTypeRenders[ mediaType ] || noop )() }\n\t\t\t\t</figure>\n\t\t\t</div>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...useBlockProps.save( { className, style } ) }>\n\t\t\t<figure className=\"wp-block-media-text__media\">\n\t\t\t\t{ ( mediaTypeRenders[ mediaType ] || noop )() }\n\t\t\t</figure>\n\t\t\t<div\n\t\t\t\t{ ...useInnerBlocksProps.save( {\n\t\t\t\t\tclassName: 'wp-block-media-text__content',\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a Gutenberg block that Display a button that lets customers add a product to their cart. Use the added options to optimize for different product types. with these attributes: quantity selector style"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-elements/add-to-cart-form/block.json\n{\n\t\"name\": \"woocommerce/add-to-cart-form\",\n\t\"title\": \"Add to Cart with Options\",\n\t\"description\": \"Display a button that lets customers add a product to their cart. Use the added options to optimize for different product types.\",\n\t\"category\": \"woocommerce-product-elements\",\n\t\"attributes\": {\n\t\t\"quantitySelectorStyle\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"enum\": [ \"input\", \"stepper\" ],\n\t\t\t\"default\": \"input\"\n\t\t}\n\t},\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"usesContext\": [ \"postId\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"interactivity\": true\n\t},\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"viewScriptModule\": \"woocommerce/add-to-cart-form\",\n\t\"style\": \"file:../woocommerce/add-to-cart-form-style.css\",\n\t\"editorStyle\": \"file:../woocommerce/add-to-cart-form-editor.css\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-elements/add-to-cart-form/edit.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps, InspectorControls } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { MultiLineTextSkeleton } from '@woocommerce/base-components/skeleton/patterns/multi-line-text-skeleton';\nimport { BlockEditProps } from '@wordpress/blocks';\nimport { Disabled, Tooltip } from '@wordpress/components';\nimport { isSiteEditorPage } from '@woocommerce/utils';\nimport { getSetting } from '@woocommerce/settings';\n\n/**\n * Internal dependencies\n */\nimport { QuantitySelectorStyle, AddToCartFormSettings } from './settings';\nimport { UpgradeNotice } from './components/upgrade-notice';\nimport type { Attributes } from './';\n\nconst AddToCartFormEdit = ( props: BlockEditProps< Attributes > ) => {\n\tconst { setAttributes } = props;\n\n\tconst quantitySelectorStyleClass =\n\t\tprops.attributes.quantitySelectorStyle === QuantitySelectorStyle.Input\n\t\t\t? 'wc-block-add-to-cart-form--input'\n\t\t\t: 'wc-block-add-to-cart-form--stepper';\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: `wc-block-add-to-cart-form ${ quantitySelectorStyleClass }`,\n\t} );\n\n\tconst isSiteEditor = isSiteEditorPage();\n\n\tconst isBlockTheme = getSetting( 'isBlockTheme', false );\n\tconst buttonBlockClass = ! isBlockTheme ? 'wp-block-button' : '';\n\tconst buttonLinkClass = ! isBlockTheme\n\t\t? 'wp-block-button__link wc-block-components-button'\n\t\t: '';\n\n\treturn (\n\t\t<>\n\t\t\t{ isBlockTheme && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<UpgradeNotice blockClientId={ props.clientId } />\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<AddToCartFormSettings\n\t\t\t\tquantitySelectorStyle={ props.attributes.quantitySelectorStyle }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Tooltip\n\t\t\t\t\ttext={ __(\n\t\t\t\t\t\t'Customer will see product add-to-cart options in this space, dependent on the product type.',\n\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t) }\n\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wc-block-editor-add-to-cart-form-container\">\n\t\t\t\t\t\t<MultiLineTextSkeleton isStatic={ true } />\n\t\t\t\t\t\t<Disabled>\n\t\t\t\t\t\t\t{ props.attributes.quantitySelectorStyle ===\n\t\t\t\t\t\t\t\tQuantitySelectorStyle.Input && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<div className=\"quantity\">\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t// In the post editor, the editor isn't in an iframe, so WordPress styles are applied. We need to remove them.\n\t\t\t\t\t\t\t\t\t\t\t\t! isSiteEditor\n\t\t\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'#ffffff',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlineHeight:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'normal',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tminHeight: 'unset',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tboxSizing: 'unset',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'unset',\n\t\t\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: {}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\t\t\tvalue=\"1\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"input-text qty text\"\n\t\t\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div className={ buttonBlockClass }>\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\tclassName={ `single_add_to_cart_button alt wp-element-button ${ buttonLinkClass }` }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Add to cart',\n\t\t\t\t\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ props.attributes.quantitySelectorStyle ===\n\t\t\t\t\t\t\t\tQuantitySelectorStyle.Stepper && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<div className=\"quantity wc-block-components-quantity-selector\">\n\t\t\t\t\t\t\t\t\t\t<button className=\"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus\">\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t// In the post editor, the editor isn't in an iframe, so WordPress styles are applied. We need to remove them.\n\t\t\t\t\t\t\t\t\t\t\t\t! isSiteEditor\n\t\t\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'#ffffff',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlineHeight:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'normal',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tminHeight: 'unset',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tboxSizing: 'unset',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'unset',\n\t\t\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: {}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\t\t\tvalue=\"1\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"input-text qty text\"\n\t\t\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<button className=\"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus\">\n\t\t\t\t\t\t\t\t\t\t\t+\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div className={ buttonBlockClass }>\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\tclassName={ `single_add_to_cart_button alt wp-element-button ${ buttonLinkClass }` }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Add to cart',\n\t\t\t\t\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Disabled>\n\t\t\t\t\t</div>\n\t\t\t\t</Tooltip>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default AddToCartFormEdit;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Display a grid of products currently on sale. that allows users to configure: columns, rows, align buttons, and 6 more options"}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-on-sale/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"woocommerce/product-on-sale\",\n\t\"title\": \"On Sale Products\",\n\t\"category\": \"woocommerce\",\n\t\"description\": \"Display a grid of products currently on sale.\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"supports\": {\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": false\n\t\t},\n\t\t\"align\": [ \"wide\", \"full\" ],\n\t\t\"html\": false,\n\t\t\"inserter\": false\n\t},\n\t\"textdomain\": \"woocommerce\",\n\t\"attributes\": {\n\t\t\"columns\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 3\n\t\t},\n\t\t\"rows\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 3\n\t\t},\n\t\t\"alignButtons\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"categories\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"default\": []\n\t\t},\n\t\t\"catOperator\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"any\"\n\t\t},\n\t\t\"contentVisibility\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"image\": true,\n\t\t\t\t\"title\": true,\n\t\t\t\t\"price\": true,\n\t\t\t\t\"rating\": true,\n\t\t\t\t\"button\": true\n\t\t\t},\n\t\t\t\"properties\": {\n\t\t\t\t\"image\": {\n\t\t\t\t\t\"type\": \"boolean\",\n\t\t\t\t\t\"default\": true\n\t\t\t\t},\n\t\t\t\t\"title\": {\n\t\t\t\t\t\"type\": \"boolean\",\n\t\t\t\t\t\"default\": true\n\t\t\t\t},\n\t\t\t\t\"price\": {\n\t\t\t\t\t\"type\": \"boolean\",\n\t\t\t\t\t\"default\": true\n\t\t\t\t},\n\t\t\t\t\"rating\": {\n\t\t\t\t\t\"type\": \"boolean\",\n\t\t\t\t\t\"default\": true\n\t\t\t\t},\n\t\t\t\t\"button\": {\n\t\t\t\t\t\"type\": \"boolean\",\n\t\t\t\t\t\"default\": true\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"isPreview\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"stockStatus\": {\n\t\t\t\"type\": \"array\"\n\t\t},\n\t\t\"orderby\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"date\"\n\t\t}\n\t}\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-on-sale/index.tsx\n/**\n * External dependencies\n */\nimport { createBlock, registerBlockType } from '@wordpress/blocks';\nimport { Icon, percent } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport Block from './block';\nimport './editor.scss';\nimport sharedAttributes, {\n\tsharedAttributeBlockTypes,\n} from '../../utils/shared-attributes';\nimport metadata from './block.json';\n\nregisterBlockType( metadata, {\n\ticon: {\n\t\tsrc: (\n\t\t\t<Icon\n\t\t\t\ticon={ percent }\n\t\t\t\tclassName=\"wc-block-editor-components-block-icon\"\n\t\t\t/>\n\t\t),\n\t},\n\tattributes: {\n\t\t...sharedAttributes,\n\t\t...metadata.attributes,\n\t},\n\ttransforms: {\n\t\tfrom: [\n\t\t\t{\n\t\t\t\ttype: 'block',\n\t\t\t\tblocks: sharedAttributeBlockTypes.filter(\n\t\t\t\t\t( value ) => value !== 'woocommerce/product-on-sale'\n\t\t\t\t),\n\t\t\t\ttransform: ( attributes ) =>\n\t\t\t\t\tcreateBlock( 'woocommerce/product-on-sale', attributes ),\n\t\t\t},\n\t\t],\n\t},\n\n\t/**\n\t * Renders and manages the block.\n\t *\n\t * @param {Object} props Props to pass to block.\n\t */\n\tedit( props ) {\n\t\treturn <Block { ...props } />;\n\t},\n\n\tsave() {\n\t\treturn null;\n\t},\n} );\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Implement a Gutenberg block for Separate your content into a multi-page experience."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: packages/block-library/src/nextpage/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/nextpage\",\n\t\"title\": \"Page Break\",\n\t\"category\": \"design\",\n\t\"description\": \"Separate your content into a multi-page experience.\",\n\t\"keywords\": [ \"next page\", \"pagination\" ],\n\t\"parent\": [ \"core/post-content\" ],\n\t\"textdomain\": \"default\",\n\t\"supports\": {\n\t\t\"customClassName\": false,\n\t\t\"className\": false,\n\t\t\"html\": false,\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-nextpage-editor\"\n}\n\n\n// File: packages/block-library/src/nextpage/index.js\n/**\n * WordPress dependencies\n */\nimport { pageBreak as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/nextpage/save.js\n/**\n * WordPress dependencies\n */\nimport { RawHTML } from '@wordpress/element';\n\nexport default function save() {\n\treturn <RawHTML>{ '<!--nextpage-->' }</RawHTML>;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Display multiple images in an elegantly organized tiled layout. that allows users to configure: align, class name, columns, and 7 more options"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/tiled-gallery/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/tiled-gallery\",\n\t\"title\": \"Tiled Gallery\",\n\t\"description\": \"Display multiple images in an elegantly organized tiled layout.\",\n\t\"keywords\": [ \"columns\", \"images\", \"photos\", \"pictures\", \"square\", \"circle\", \"mosaic\" ],\n\t\"version\": \"12.5.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"media\",\n\t\"icon\": \"<svg viewBox='0 0 24 24' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><path d='M19 5v2h-4V5h4M9 5v6H5V5h4m10 8v6h-4v-6h4M9 17v2H5v-2h4M21 3h-8v6h8V3zM11 3H3v10h8V3zm10 8h-8v10h8V11zm-10 4H3v6h8v-6z'/></svg>\",\n\t\"supports\": {\n\t\t\"align\": [ \"center\", \"wide\", \"full\" ],\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"text\": false\n\t\t},\n\t\t\"customClassName\": false,\n\t\t\"html\": false,\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"__experimentalHideChildBlockControls\": true\n\t},\n\t\"providesContext\": {\n\t\t\"imageCrop\": \"imageCrop\"\n\t},\n\t\"styles\": [\n\t\t{ \"name\": \"rectangular\", \"label\": \"Tiled mosaic\", \"isDefault\": true },\n\t\t{ \"name\": \"circle\", \"label\": \"Circles\" },\n\t\t{ \"name\": \"square\", \"label\": \"Square tiles\" },\n\t\t{ \"name\": \"columns\", \"label\": \"Tiled columns\" }\n\t],\n\t\"attributes\": {\n\t\t\"align\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"center\"\n\t\t},\n\t\t\"className\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"is-style-rectangular\"\n\t\t},\n\t\t\"columns\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"columnWidths\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"default\": []\n\t\t},\n\t\t\"ids\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"default\": []\n\t\t},\n\t\t\"imageFilter\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"images\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"default\": [],\n\t\t\t\"source\": \"query\",\n\t\t\t\"selector\": \".tiled-gallery__item\",\n\t\t\t\"query\": {\n\t\t\t\t\"alt\": {\n\t\t\t\t\t\"attribute\": \"alt\",\n\t\t\t\t\t\"default\": \"\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"source\": \"attribute\"\n\t\t\t\t},\n\t\t\t\t\"height\": {\n\t\t\t\t\t\"attribute\": \"data-height\",\n\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"source\": \"attribute\"\n\t\t\t\t},\n\t\t\t\t\"id\": {\n\t\t\t\t\t\"attribute\": \"data-id\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"source\": \"attribute\"\n\t\t\t\t},\n\t\t\t\t\"link\": {\n\t\t\t\t\t\"attribute\": \"data-link\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"source\": \"attribute\"\n\t\t\t\t},\n\t\t\t\t\"customLink\": {\n\t\t\t\t\t\"attribute\": \"href\",\n\t\t\t\t\t\"selector\": \"a\",\n\t\t\t\t\t\"source\": \"attribute\"\n\t\t\t\t},\n\t\t\t\t\"url\": {\n\t\t\t\t\t\"attribute\": \"data-url\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"source\": \"attribute\"\n\t\t\t\t},\n\t\t\t\t\"width\": {\n\t\t\t\t\t\"attribute\": \"data-width\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"source\": \"attribute\",\n\t\t\t\t\t\"type\": \"number\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"imageCrop\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"linkTo\": {\n\t\t\t\"default\": \"none\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"roundedCorners\": {\n\t\t\t\"type\": \"integer\",\n\t\t\t\"default\": 0\n\t\t}\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/tiled-gallery/edit.js\nimport { getBlockIconComponent } from '@automattic/jetpack-shared-extension-utils';\nimport { MediaPlaceholder, useBlockProps } from '@wordpress/block-editor';\nimport { DropZone, FormFileUpload, withNotices } from '@wordpress/components';\nimport { mediaUpload } from '@wordpress/editor';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { pick } from 'lodash';\nimport { getActiveStyleName } from '../../shared/block-styles';\nimport metadata from './block.json';\nimport { ALLOWED_MEDIA_TYPES, LAYOUT_STYLES } from './constants';\nimport { TiledGalleryBlockControls, TiledGalleryInspectorControls } from './controls';\nimport Layout from './layout';\n\nconst DEFAULT_COLUMNS_COUNT = 3;\n\nexport function defaultColumnsNumber( attributes ) {\n\treturn attributes.images.length > 0\n\t\t? Math.min( DEFAULT_COLUMNS_COUNT, attributes.images.length )\n\t\t: DEFAULT_COLUMNS_COUNT;\n}\n\nexport const pickRelevantMediaFiles = image => {\n\tconst imageProps = pick( image, [ [ 'alt' ], [ 'id' ], [ 'link' ] ] );\n\timageProps.url =\n\t\timage?.sizes?.large?.url || image?.media_details?.sizes?.large?.source_url || image.url;\n\treturn imageProps;\n};\n\nconst TiledGalleryEdit = ( {\n\tattributes,\n\tisSelected,\n\tnoticeOperations,\n\tnoticeUI,\n\tsetAttributes,\n} ) => {\n\tconst {\n\t\talign,\n\t\tcolumns = defaultColumnsNumber( attributes ),\n\t\timageFilter,\n\t\timages,\n\t\tlinkTo,\n\t\troundedCorners,\n\t\tcolumnWidths,\n\t} = attributes;\n\tconst layoutStyle = getActiveStyleName( LAYOUT_STYLES, attributes.className );\n\n\tconst blockProps = useBlockProps();\n\tconst [ selectedImage, setSelectedImage ] = useState( null );\n\tconst [ changed, setChanged ] = useState(\n\t\t'undefined' === typeof columnWidths || columnWidths?.length === 0 ? true : false\n\t);\n\n\tconst setImages = imgs => {\n\t\tsetAttributes( {\n\t\t\timages: imgs,\n\t\t\tids: imgs.map( ( { id } ) => parseInt( id, 10 ) ),\n\t\t} );\n\t};\n\n\tconst addFiles = files => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: value =>\n\t\t\t\tsetImages( ( images || [] ).concat( value.map( pickRelevantMediaFiles ) ) ),\n\t\t\tonError: noticeOperations.createErrorNotice,\n\t\t} );\n\n\t\tsetChanged( true );\n\t};\n\n\tconst onRemoveImage = index => () => {\n\t\tconst filteredImages = images.filter( ( img, i ) => index !== i );\n\n\t\tsetSelectedImage( null );\n\t\tsetChanged( true );\n\n\t\tsetImages( filteredImages );\n\t\tsetAttributes( { columns: columns ? Math.min( filteredImages.length, columns ) : columns } );\n\t};\n\n\tconst onSelectImage = index => () => {\n\t\tif ( selectedImage !== index ) {\n\t\t\tsetSelectedImage( index );\n\t\t}\n\t};\n\n\tconst onSelectImages = files => {\n\t\tconst newImages = files.map( file => {\n\t\t\tconst existingImage = images.find(\n\t\t\t\timg => parseInt( img.id, 10 ) === parseInt( file.id, 10 )\n\t\t\t);\n\n\t\t\tif ( existingImage?.customLink ) {\n\t\t\t\treturn {\n\t\t\t\t\t...pickRelevantMediaFiles( file ),\n\t\t\t\t\tcustomLink: existingImage.customLink,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn pickRelevantMediaFiles( file );\n\t\t} );\n\n\t\tsetImages( newImages );\n\t\tsetAttributes( { columns: columns ? Math.min( files.length, columns ) : columns } );\n\n\t\tsetChanged( true );\n\t};\n\n\tconst onMove = ( oldIndex, newIndex ) => {\n\t\tconst copy = [ ...images ];\n\n\t\tcopy.splice( newIndex, 1, images[ oldIndex ] );\n\t\tcopy.splice( oldIndex, 1, images[ newIndex ] );\n\n\t\tsetSelectedImage( newIndex );\n\t\tsetChanged( true );\n\n\t\tsetImages( copy );\n\t};\n\n\tconst onMoveForward = oldIndex => {\n\t\treturn () => {\n\t\t\tif ( oldIndex === images.length - 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonMove( oldIndex, oldIndex + 1 );\n\t\t};\n\t};\n\n\tconst onMoveBackward = oldIndex => {\n\t\treturn () => {\n\t\t\tif ( oldIndex === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonMove( oldIndex, oldIndex - 1 );\n\t\t};\n\t};\n\n\tconst onResize = value => {\n\t\tif ( changed ) {\n\t\t\tsetAttributes( { columnWidths: value } );\n\t\t}\n\t};\n\n\tconst uploadFromFiles = event => addFiles( event.target.files );\n\n\tconst setImageAttributes = index => attrs => {\n\t\tif ( ! images[ index ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetImages( [\n\t\t\t...images.slice( 0, index ),\n\t\t\t{ ...images[ index ], ...attrs },\n\t\t\t...images.slice( index + 1 ),\n\t\t] );\n\t};\n\n\t// Deselect images when deselecting the block\n\tuseEffect( () => {\n\t\tif ( ! isSelected && null !== selectedImage ) {\n\t\t\tsetSelectedImage( null );\n\t\t}\n\t}, [ isSelected, selectedImage, setSelectedImage ] );\n\n\tlet content;\n\n\tif ( images.length === 0 ) {\n\t\tcontent = (\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ getBlockIconComponent( metadata ) }\n\t\t\t\tlabels={ {\n\t\t\t\t\ttitle: __( 'Tiled Gallery', 'jetpack' ),\n\t\t\t\t\tname: __( 'images', 'jetpack' ),\n\t\t\t\t} }\n\t\t\t\tonSelect={ onSelectImages }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tmultiple\n\t\t\t\tnotices={ noticeUI }\n\t\t\t\tonError={ noticeOperations.createErrorNotice }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\tcontent = (\n\t\t\t<>\n\t\t\t\t<TiledGalleryInspectorControls\n\t\t\t\t\tlayoutStyle={ layoutStyle }\n\t\t\t\t\timages={ images }\n\t\t\t\t\tcolumns={ columns }\n\t\t\t\t\tselectedImage={ selectedImage }\n\t\t\t\t\tsetImageAttributes={ setImageAttributes }\n\t\t\t\t\tonColumnsChange={ value => setAttributes( { columns: value } ) }\n\t\t\t\t\troundedCorners={ roundedCorners }\n\t\t\t\t\tonRoundedCornersChange={ value => setAttributes( { roundedCorners: value } ) }\n\t\t\t\t\tlinkTo={ linkTo }\n\t\t\t\t\tonLinkToChange={ value => setAttributes( { linkTo: value } ) }\n\t\t\t\t/>\n\n\t\t\t\t{ noticeUI }\n\n\t\t\t\t<Layout\n\t\t\t\t\tclassName=\"tiled-gallery__wrapper\"\n\t\t\t\t\talign={ align }\n\t\t\t\t\tcolumns={ columns }\n\t\t\t\t\timageFilter={ imageFilter }\n\t\t\t\t\timages={ images }\n\t\t\t\t\tlayoutStyle={ layoutStyle }\n\t\t\t\t\tlinkTo={ linkTo }\n\t\t\t\t\tonMoveBackward={ onMoveBackward }\n\t\t\t\t\tonMoveForward={ onMoveForward }\n\t\t\t\t\tonRemoveImage={ onRemoveImage }\n\t\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\t\tonResize={ onResize }\n\t\t\t\t\troundedCorners={ roundedCorners }\n\t\t\t\t\tselectedImage={ isSelected ? selectedImage : null }\n\t\t\t\t\tsetImageAttributes={ setImageAttributes }\n\t\t\t\t>\n\t\t\t\t\t<DropZone onFilesDrop={ addFiles } />\n\t\t\t\t\t{ isSelected && (\n\t\t\t\t\t\t<div className=\"tiled-gallery__add-item\">\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tmultiple\n\t\t\t\t\t\t\t\tclassName=\"tiled-gallery__add-item-button\"\n\t\t\t\t\t\t\t\tonChange={ uploadFromFiles }\n\t\t\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\t\t\ticon=\"insert\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize={ true }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Upload an image', 'jetpack' ) }\n\t\t\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</Layout>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<TiledGalleryBlockControls\n\t\t\t\timages={ images }\n\t\t\t\tonSelectImages={ onSelectImages }\n\t\t\t\timageFilter={ imageFilter }\n\t\t\t\tonFilterChange={ value => {\n\t\t\t\t\tsetAttributes( { imageFilter: value } );\n\t\t\t\t\tsetSelectedImage( null );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ content }\n\t\t</div>\n\t);\n};\n\nexport default withNotices( TiledGalleryEdit );\n\n\n// File: projects/plugins/jetpack/extensions/blocks/tiled-gallery/save.js\nimport { useBlockProps } from '@wordpress/block-editor';\nimport clsx from 'clsx';\nimport { getActiveStyleName } from '../../shared/block-styles';\nimport { LAYOUT_STYLES } from './constants';\nimport { defaultColumnsNumber } from './edit';\nimport Layout from './layout';\n\nexport default function TiledGallerySave( { attributes } ) {\n\tconst { imageFilter, images } = attributes;\n\n\tif ( ! images.length ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\talign,\n\t\tclassName,\n\t\tcolumns = defaultColumnsNumber( attributes ),\n\t\tlinkTo,\n\t\troundedCorners,\n\t\tcolumnWidths,\n\t} = attributes;\n\tconst blockProps = useBlockProps.save();\n\n\treturn (\n\t\t<div { ...blockProps } className={ clsx( blockProps.className, className ) }>\n\t\t\t<Layout\n\t\t\t\talign={ align }\n\t\t\t\tcolumns={ columns }\n\t\t\t\timageFilter={ imageFilter }\n\t\t\t\timages={ images }\n\t\t\t\tisSave\n\t\t\t\tlayoutStyle={ getActiveStyleName( LAYOUT_STYLES, className ) }\n\t\t\t\tlinkTo={ linkTo }\n\t\t\t\troundedCorners={ roundedCorners }\n\t\t\t\tcolumnWidths={ columnWidths }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a text input component featuring configurable button text, input placeholder, copy functionality toggle, and two additional customization settings."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/ai-chat/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/ai-chat\",\n\t\"title\": \"Jetpack AI Search\",\n\t\"description\": \"Provide a summarized answer to questions, trained on the sites content. Powered by AI.\",\n\t\"keywords\": [ \"AI\", \"GPT\", \"Chat\", \"Search\" ],\n\t\"version\": \"12.5.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"text\",\n\t\"icon\": \"<svg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M6.96774 8C6.96774 9.1402 6.04343 10.0645 4.90323 10.0645C3.76303 10.0645 2.83871 9.1402 2.83871 8C2.83871 6.8598 3.76303 5.93548 4.90323 5.93548C6.04343 5.93548 6.96774 6.8598 6.96774 8ZM5.41935 8C5.41935 8.28505 5.18828 8.51613 4.90323 8.51613C4.61818 8.51613 4.3871 8.28505 4.3871 8C4.3871 7.71495 4.61818 7.48387 4.90323 7.48387C5.18828 7.48387 5.41935 7.71495 5.41935 8Z'/><path fill-rule='evenodd' clip-rule='evenodd' d='M11.0968 10.0645C12.237 10.0645 13.1613 9.1402 13.1613 8C13.1613 6.8598 12.237 5.93548 11.0968 5.93548C9.95657 5.93548 9.03226 6.8598 9.03226 8C9.03226 9.1402 9.95657 10.0645 11.0968 10.0645ZM11.0968 8.51613C11.3818 8.51613 11.6129 8.28505 11.6129 8C11.6129 7.71495 11.3818 7.48387 11.0968 7.48387C10.8117 7.48387 10.5806 7.71495 10.5806 8C10.5806 8.28505 10.8117 8.51613 11.0968 8.51613Z'/><path d='M5.93548 11.3548C5.50791 11.3548 5.16129 11.7015 5.16129 12.129C5.16129 12.5566 5.50791 12.9032 5.93548 12.9032H10.0645C10.4921 12.9032 10.8387 12.5566 10.8387 12.129C10.8387 11.7015 10.4921 11.3548 10.0645 11.3548H5.93548Z'/><path fill-rule='evenodd' clip-rule='evenodd' d='M8.77419 0.774194C8.77419 0.346618 8.42758 0 8 0C7.57242 0 7.22581 0.346618 7.22581 0.774194V3.09677H4.90323C2.19525 3.09677 0 5.29202 0 8V11.0968C0 13.8048 2.19525 16 4.90323 16H11.0968C13.8048 16 16 13.8048 16 11.0968V8C16 5.29202 13.8048 3.09677 11.0968 3.09677H8.77419V0.774194ZM1.54839 8C1.54839 6.14717 3.0504 4.64516 4.90323 4.64516H11.0968C12.9496 4.64516 14.4516 6.14717 14.4516 8V11.0968C14.4516 12.9496 12.9496 14.4516 11.0968 14.4516H4.90323C3.0504 14.4516 1.54839 12.9496 1.54839 11.0968V8Z'/></svg>\",\n\t\"supports\": {\n\t\t\"align\": true,\n\t\t\"alignWide\": true,\n\t\t\"customClassName\": true,\n\t\t\"className\": true,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false\n\t},\n\t\"attributes\": {\n\t\t\"askButtonLabel\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"placeholder\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"showCopy\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"showFeedback\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"showSources\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t}\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/ai-chat/edit.js\n/**\n * External dependencies\n */\nimport { GuidelineMessage } from '@automattic/jetpack-ai-client';\n/**\n * WordPress dependencies\n */\nimport { InspectorControls, useBlockProps, RichText } from '@wordpress/block-editor';\nimport { TextControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport './editor.scss';\nimport ConnectBanner from '../../shared/components/connect-banner';\nimport useIsUserConnected from '../../shared/use-is-user-connected';\nimport EnableJetpackSearchPrompt from './components/nudge-enable-search';\nimport { DEFAULT_ASK_BUTTON_LABEL, DEFAULT_PLACEHOLDER } from './constants';\nimport { AiChatControls } from './controls';\n\nexport default function Edit( { attributes, setAttributes, clientId } ) {\n\tconst {\n\t\taskButtonLabel = DEFAULT_ASK_BUTTON_LABEL,\n\t\tplaceholder = DEFAULT_PLACEHOLDER,\n\t\tshowCopy,\n\t\tshowFeedback,\n\t\tshowSources,\n\t} = attributes;\n\tconst blockProps = useBlockProps();\n\tconst isBlockSelected = useSelect(\n\t\tselect => {\n\t\t\treturn select( 'core/block-editor' ).isBlockSelected( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isUserConnected = useIsUserConnected();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ ! isUserConnected && <ConnectBanner block=\"Jetpack AI Search\" /> }\n\t\t\t<EnableJetpackSearchPrompt />\n\t\t\t<div className=\"jetpack-ai-chat-question-wrapper\">\n\t\t\t\t<TextControl\n\t\t\t\t\tclassName=\"jetpack-ai-chat-question-input\"\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\tdisabled={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\t__next40pxDefaultSize={ true }\n\t\t\t\t/>\n\t\t\t\t<RichText\n\t\t\t\t\tclassName=\"wp-block-button__link jetpack-ai-chat-question-button\"\n\t\t\t\t\tonChange={ value => setAttributes( { askButtonLabel: value } ) }\n\t\t\t\t\tvalue={ askButtonLabel }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tallowedFormats={ [ 'core/bold', 'core/italic', 'core/strikethrough' ] }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{ isBlockSelected && <GuidelineMessage /> }\n\t\t\t<InspectorControls>\n\t\t\t\t<AiChatControls\n\t\t\t\t\taskButtonLabel={ askButtonLabel }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tshowCopy={ showCopy }\n\t\t\t\t\tshowFeedback={ showFeedback }\n\t\t\t\t\tshowSources={ showSources }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</div>\n\t);\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/ai-chat/save.js\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { DEFAULT_ASK_BUTTON_LABEL } from './constants';\n\nexport default function ( { attributes } ) {\n\tconst blockProps = useBlockProps.save( {\n\t\t'data-ask-button-label': attributes.askButtonLabel || DEFAULT_ASK_BUTTON_LABEL,\n\t} );\n\treturn <div { ...blockProps } />;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Create a Gutenberg block for Block: jetpack/layout-grid"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: blocks/layout-grid/src/index.js\n/**\n * WordPress dependencies\n */\n\nimport { registerBlockType } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport editGrid from './grid/edit';\nimport saveGrid from './grid/save';\nimport editColumn from './grid-column/edit';\nimport saveColumn from './grid-column/save';\nimport { GridIcon, GridColumnIcon } from './icons';\nimport {\n\tgetSpanForDevice,\n\tgetOffsetForDevice,\n\tDEVICE_BREAKPOINTS,\n\tMAX_COLUMNS,\n} from './constants';\nimport deprecated from './grid-column/deprecated';\n\nfunction getColumnAttributes( total, breakpoints ) {\n\tconst attributes = {};\n\n\tfor ( let index = 0; index < total; index++ ) {\n\t\tbreakpoints.map( ( breakpoint ) => {\n\t\t\tattributes[ getSpanForDevice( index, breakpoint ) ] = {\n\t\t\t\ttype: 'number',\n\t\t\t};\n\t\t\tattributes[ getOffsetForDevice( index, breakpoint ) ] = {\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 0,\n\t\t\t};\n\t\t} );\n\t}\n\n\treturn attributes;\n}\n\nexport function registerBlock() {\n\tregisterBlockType( 'jetpack/layout-grid', {\n\t\ttitle: __( 'Layout Grid', 'layout-grid' ),\n\t\tdescription: __(\n\t\t\t'Align blocks to a global grid, with support for responsive breakpoints.',\n\t\t\t'layout-grid'\n\t\t),\n\t\ticon: GridIcon,\n\t\tcategory: 'design',\n\t\tsupports: {\n\t\t\talign: [ 'full' ],\n\t\t\thtml: false,\n\t\t},\n\t\texample: {\n\t\t\tattributes: {\n\t\t\t\tcolumns: 2,\n\t\t\t},\n\t\t\tinnerBlocks: [\n\t\t\t\t{\n\t\t\t\t\tname: 'jetpack/layout-grid-column',\n\t\t\t\t\tinnerBlocks: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\tcustomFontSize: 32,\n\t\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t\t'<strong>Snow Patrol</strong>',\n\t\t\t\t\t\t\t\t\t'layout-grid'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\talign: 'center',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'jetpack/layout-grid-column',\n\t\t\t\t\tinnerBlocks: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'core/image',\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\turl:\n\t\t\t\t\t\t\t\t\t'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tattributes: {\n\t\t\tgutterSize: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'large',\n\t\t\t},\n\t\t\taddGutterEnds: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t},\n\t\t\tverticalAlignment: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\t...getColumnAttributes( MAX_COLUMNS, DEVICE_BREAKPOINTS ),\n\t\t},\n\t\tedit: editGrid,\n\t\tsave: saveGrid,\n\t} );\n\n\tregisterBlockType( 'jetpack/layout-grid-column', {\n\t\tdescription: __(\n\t\t\t'A column used inside a Layout Grid block.',\n\t\t\t'layout-grid'\n\t\t),\n\t\ttitle: __( 'Column', 'layout-grid' ),\n\t\ticon: GridColumnIcon,\n\t\tcategory: 'design',\n\t\tparent: [ 'jetpack/layout-grid' ],\n\t\tsupports: {\n\t\t\tinserter: false,\n\t\t\treusable: false,\n\t\t\thtml: false,\n\t\t},\n\t\tattributes: {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tpadding: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'none',\n\t\t\t},\n\t\t\tverticalAlignment: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t\tedit: editColumn,\n\t\tsave: saveColumn,\n\t\tdeprecated,\n\t} );\n}\n\n\n// File: blocks/layout-grid/src/grid-column/save.js\n/**\n * External dependencies\n */\n\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\n\nimport { InnerBlocks, getColorClassName } from '@wordpress/block-editor';\n\nconst save = ( { attributes = {} } ) => {\n\tconst {\n\t\tclassName,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\tpadding,\n\t\tverticalAlignment,\n\t} = attributes;\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst classes = classnames( className, {\n\t\t[ 'wp-block-jetpack-layout-grid__padding-' + padding ]: true,\n\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t[ backgroundClass ]: backgroundClass,\n\t\t[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,\n\t} );\n\tconst style = {\n\t\tbackgroundColor: backgroundClass ? undefined : customBackgroundColor,\n\t};\n\n\treturn (\n\t\t<div className={ classes } style={ style }>\n\t\t\t<InnerBlocks.Content />\n\t\t</div>\n\t);\n};\n\nexport default save;\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a Gutenberg block that A slider helps shopper choose a price range. with these attributes: show input fields, inline input, slider handle, and 5 more options"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/price-slider/block.json\n{\n\t\"name\": \"woocommerce/product-filter-price-slider\",\n\t\"title\": \"Price Slider\",\n\t\"description\": \"A slider helps shopper choose a price range.\",\n\t\"category\": \"woocommerce\",\n\t\"keywords\": [ \"WooCommerce\" ],\n\t\"supports\": {\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"enableContrastChecker\": false,\n\t\t\t\"background\": false,\n\t\t\t\"text\": false\n\t\t},\n\t\t\"interactivity\": true\n\t},\n\t\"attributes\": {\n\t\t\"showInputFields\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"inlineInput\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\n\t\t\"sliderHandle\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customSliderHandle\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"sliderHandleBorder\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customSliderHandleBorder\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"slider\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"customSlider\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t}\n\t},\n\t\"ancestor\": [ \"woocommerce/product-filter-price\" ],\n\t\"usesContext\": [ \"filterData\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"apiVersion\": 3,\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"viewScriptModule\": \"woocommerce/product-filter-price-slider\",\n\t\"style\": \"file:../woocommerce/product-filter-price-slider-style.css\"\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/price-slider/edit.tsx\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, ToggleControl, Disabled } from '@wordpress/components';\nimport { formatPrice, getCurrency } from '@woocommerce/price-format';\nimport {\n\tuseBlockProps,\n\tInspectorControls,\n\twithColors,\n\n\t// @ts-expect-error - no types.\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t// @ts-expect-error - no types.\n\t// eslint-disable-next-line @wordpress/no-unsafe-wp-apis\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { colorNames } from './constants';\nimport { getHasColorClasses, getStyleColorVars } from '../../utils/colors';\nimport type { EditProps } from './types';\n\nconst PriceSliderEdit = ( {\n\tclientId,\n\tcontext,\n\n\tattributes,\n\tsetAttributes,\n\n\t// Custom colors\n\tsliderHandle,\n\tsetSliderHandle,\n\tsliderHandleBorder,\n\tsetSliderHandleBorder,\n\tslider,\n\tsetSlider,\n}: EditProps ): JSX.Element | null => {\n\tconst {\n\t\tshowInputFields,\n\t\tinlineInput,\n\n\t\tcustomSliderHandle,\n\t\tcustomSliderHandleBorder,\n\t\tcustomSlider,\n\t} = attributes;\n\n\tconst { isLoading, price } = context.filterData;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wc-block-product-filter-price-slider', {\n\t\t\t'is-loading': isLoading,\n\t\t\t...getHasColorClasses( attributes, colorNames ),\n\t\t} ),\n\t\tstyle: getStyleColorVars(\n\t\t\t'wc-product-filter-price',\n\t\t\tattributes,\n\t\t\tcolorNames\n\t\t),\n\t} );\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\tif ( isLoading ) {\n\t\treturn <>{ __( 'Loading…', 'woocommerce' ) }</>;\n\t}\n\n\tif ( ! price ) {\n\t\treturn null;\n\t}\n\n\tconst { minPrice, maxPrice, minRange, maxRange } = price;\n\tconst formattedMinPrice = formatPrice(\n\t\tminPrice,\n\t\tgetCurrency( { minorUnit: 0 } )\n\t);\n\n\tconst formattedMaxPrice = formatPrice(\n\t\tmaxPrice,\n\t\tgetCurrency( { minorUnit: 0 } )\n\t);\n\n\tconst priceMin = showInputFields ? (\n\t\t<input className=\"min\" type=\"text\" defaultValue={ formattedMinPrice } />\n\t) : (\n\t\t<span>{ formattedMinPrice }</span>\n\t);\n\n\tconst priceMax = showInputFields ? (\n\t\t<input className=\"max\" type=\"text\" defaultValue={ formattedMaxPrice } />\n\t) : (\n\t\t<span>{ formattedMaxPrice }</span>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings', 'woocommerce' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show input fields', 'woocommerce' ) }\n\t\t\t\t\t\tchecked={ showInputFields }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowInputFields: ! showInputFields,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ showInputFields && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Inline input fields', 'woocommerce' ) }\n\t\t\t\t\t\t\tchecked={ inlineInput }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { inlineInput: ! inlineInput } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t{ colorGradientSettings.hasColorsOrGradients && (\n\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Slider Handle', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\tsliderHandle.color || customSliderHandle,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetSliderHandle( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomSliderHandle: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetSliderHandle( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomSliderHandle: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __(\n\t\t\t\t\t\t\t\t\t'Slider Handle Border',\n\t\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tcolorValue:\n\t\t\t\t\t\t\t\t\tsliderHandleBorder.color ||\n\t\t\t\t\t\t\t\t\tcustomSliderHandleBorder,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetSliderHandleBorder( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomSliderHandleBorder: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetSliderHandleBorder( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomSliderHandleBorder: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Slider', 'woocommerce' ),\n\t\t\t\t\t\t\t\tcolorValue: slider.color || customSlider,\n\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\tonColorChange: ( colorValue: string ) => {\n\t\t\t\t\t\t\t\t\tsetSlider( colorValue );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomSlider: colorValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresetAllFilter: () => {\n\t\t\t\t\t\t\t\t\tsetSlider( '' );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tcustomSlider: '',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Disabled>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'wc-block-product-filter-price-slider__content',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'wc-block-product-filter-price-slider__content--inline':\n\t\t\t\t\t\t\t\t\tinlineInput && showInputFields,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"wc-block-product-filter-price-slider__left text\">\n\t\t\t\t\t\t\t{ priceMin }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"wc-block-product-filter-price-slider__range\">\n\t\t\t\t\t\t\t<div className=\"range-bar\"></div>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\ttype=\"range\"\n\t\t\t\t\t\t\t\tclassName=\"min\"\n\t\t\t\t\t\t\t\tmin={ minRange }\n\t\t\t\t\t\t\t\tmax={ maxRange }\n\t\t\t\t\t\t\t\tdefaultValue={ minPrice }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\ttype=\"range\"\n\t\t\t\t\t\t\t\tclassName=\"max\"\n\t\t\t\t\t\t\t\tmin={ minRange }\n\t\t\t\t\t\t\t\tmax={ maxRange }\n\t\t\t\t\t\t\t\tdefaultValue={ maxPrice }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"wc-block-product-filter-price-slider__right text\">\n\t\t\t\t\t\t\t{ priceMax }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default withColors( ...colorNames )( PriceSliderEdit );\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/price-slider/save.tsx\n/**\n * External dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport { getHasColorClasses, getStyleColorVars } from '../../utils/colors';\nimport { colorNames } from './constants';\nimport type { BlockAttributes } from './types';\n\nexport default function save( {\n\tattributes,\n}: {\n\tattributes: BlockAttributes;\n} ) {\n\tconst blockProps = useBlockProps.save( {\n\t\tclassName: clsx(\n\t\t\t'wc-block-product-filter-price-slider',\n\t\t\tgetHasColorClasses( attributes, colorNames )\n\t\t),\n\t\tstyle: getStyleColorVars(\n\t\t\t'wc-product-filter-price',\n\t\t\tattributes,\n\t\t\tcolorNames\n\t\t),\n\t} );\n\n\treturn <div { ...blockProps } />;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a Shows cart block that provides configurable settings for styling, description suppression, and content locking to enhance user interface flexibility."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-cart-items/block.json\n{\n\t\"name\": \"woocommerce/checkout-order-summary-cart-items-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Cart Items\",\n\t\"description\": \"Shows cart items.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"lock\": false\n\t},\n\t\"attributes\": {\n\t\t\"className\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"disableProductDescriptions\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": false\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [ \"woocommerce/checkout-order-summary-block\" ],\n\t\"textdomain\": \"woocommerce\",\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-cart-items/edit.tsx\n/**\n * External dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useBlockProps, InspectorControls } from '@wordpress/block-editor';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { isExperimentalBlocksEnabled } from '@woocommerce/block-settings';\n\n/**\n * Internal dependencies\n */\nimport Block from './block';\n\nexport type BlockAttributes = {\n\tclassName?: string;\n\tdisableProductDescriptions?: boolean;\n};\n\nexport const Edit = ( {\n\tattributes,\n\tsetAttributes,\n}: {\n\tattributes: BlockAttributes;\n\tsetAttributes: ( attributes: Record< string, unknown > ) => void;\n} ): JSX.Element => {\n\tconst { className = '', disableProductDescriptions = false } = attributes;\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ /* For now this setting can only be enabled if you have experimental features enabled. */ }\n\t\t\t{ isExperimentalBlocksEnabled() && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings', 'woocommerce' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t'Disable product descriptions',\n\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Disable display of product descriptions.',\n\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tchecked={ disableProductDescriptions }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdisableProductDescriptions:\n\t\t\t\t\t\t\t\t\t\t! disableProductDescriptions,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<Block\n\t\t\t\tdisableProductDescriptions={ disableProductDescriptions }\n\t\t\t\tclassName={ className }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn <div { ...useBlockProps.save() } />;\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Build a WooCommerce block with adaptable lock parameters, enabling flexible control over block visibility and user permissions."}, {"role": "assistant", "content": "// File: plugins/woocommerce/client/blocks/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/block.json\n{\n\t\"name\": \"woocommerce/proceed-to-checkout-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Proceed to Checkout\",\n\t\"description\": \"Allow customers proceed to Checkout.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"inserter\": false,\n\t\t\"lock\": false\n\t},\n\t\"attributes\": {\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [\n\t\t\"woocommerce/cart-totals-block\"\n\t],\n\t\"textdomain\": \"woocommerce\",\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3\n}\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/edit.tsx\n/**\n * External dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport EditableButton from '@woocommerce/editor-components/editable-button';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport PageSelector from '@woocommerce/editor-components/page-selector';\nimport { CART_PAGE_ID } from '@woocommerce/block-settings';\n\n/**\n * Internal dependencies\n */\nimport { defaultButtonLabel } from './constants';\n\nexport const Edit = ( {\n\tattributes,\n\tsetAttributes,\n}: {\n\tattributes: {\n\t\tcheckoutPageId: number;\n\t\tclassName: string;\n\t\tbuttonLabel: string;\n\t};\n\tsetAttributes: ( attributes: Record< string, unknown > ) => void;\n} ): JSX.Element => {\n\tconst blockProps = useBlockProps();\n\tconst { checkoutPageId = 0, buttonLabel } = attributes;\n\tconst { current: savedCheckoutPageId } = useRef( checkoutPageId );\n\n\tconst currentPostId = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! savedCheckoutPageId ) {\n\t\t\t\tconst store = select( 'core/editor' );\n\t\t\t\treturn store.getCurrentPostId();\n\t\t\t}\n\t\t\treturn savedCheckoutPageId;\n\t\t},\n\t\t[ savedCheckoutPageId ]\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<InspectorControls>\n\t\t\t\t{ ! (\n\t\t\t\t\tcurrentPostId === CART_PAGE_ID && savedCheckoutPageId === 0\n\t\t\t\t) && (\n\t\t\t\t\t<PageSelector\n\t\t\t\t\t\tpageId={ checkoutPageId }\n\t\t\t\t\t\tsetPageId={ ( id: number ) =>\n\t\t\t\t\t\t\tsetAttributes( { checkoutPageId: id } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\ttitle: __(\n\t\t\t\t\t\t\t\t'Proceed to Checkout button',\n\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tdefault: __(\n\t\t\t\t\t\t\t\t'WooCommerce Checkout Page',\n\t\t\t\t\t\t\t\t'woocommerce'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t<EditableButton\n\t\t\t\tclassName=\"wc-block-cart__submit-button\"\n\t\t\t\tvalue={ buttonLabel }\n\t\t\t\tplaceholder={ defaultButtonLabel }\n\t\t\t\tonChange={ ( content ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tbuttonLabel: content,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn <div { ...useBlockProps.save() } />;\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Design a custom Gutenberg block for address checkout fields, incorporating configurable class name and lock attributes for enhanced functionality."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/block.json\n{\n\t\"name\": \"woocommerce/checkout-fields-block\",\n\t\"version\": \"1.0.0\",\n\t\"title\": \"Checkout Fields\",\n\t\"description\": \"Column containing checkout address fields.\",\n\t\"category\": \"woocommerce\",\n\t\"supports\": {\n\t\t\"align\": false,\n\t\t\"html\": false,\n\t\t\"multiple\": false,\n\t\t\"reusable\": false,\n\t\t\"inserter\": false,\n\t\t\"lock\": false\n\t},\n\t\"attributes\": {\n\t\t\"className\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"\"\n\t\t},\n\t\t\"lock\": {\n\t\t\t\"type\": \"object\",\n\t\t\t\"default\": {\n\t\t\t\t\"remove\": true,\n\t\t\t\t\"move\": true\n\t\t\t}\n\t\t}\n\t},\n\t\"parent\": [\n\t\t\"woocommerce/checkout\"\n\t],\n\t\"textdomain\": \"woocommerce\",\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3\n}\n\n// File: plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/edit.tsx\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { useBlockProps, InnerBlocks } from '@wordpress/block-editor';\nimport { Main } from '@woocommerce/base-components/sidebar-layout';\nimport { innerBlockAreas } from '@woocommerce/blocks-checkout';\nimport type { TemplateArray } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useCheckoutBlockContext } from '../../context';\nimport {\n\tuseForcedLayout,\n\tgetAllowedBlocks,\n} from '../../../cart-checkout-shared';\nimport './style.scss';\nimport { AddressFieldControls } from '../../address-field-controls';\n\nexport const Edit = ( {\n\tclientId,\n\tattributes,\n}: {\n\tclientId: string;\n\tattributes: {\n\t\tclassName?: string;\n\t\tisPreview?: boolean;\n\t};\n} ): JSX.Element => {\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wc-block-checkout__main', attributes?.className ),\n\t} );\n\tconst allowedBlocks = getAllowedBlocks( innerBlockAreas.CHECKOUT_FIELDS );\n\n\tconst { showFormStepNumbers } = useCheckoutBlockContext();\n\n\tconst defaultTemplate = [\n\t\t[ 'woocommerce/checkout-express-payment-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-contact-information-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-shipping-method-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-pickup-options-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-shipping-address-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-billing-address-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-shipping-methods-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-payment-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-additional-information-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-order-note-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-terms-block', {}, [] ],\n\t\t[ 'woocommerce/checkout-actions-block', {}, [] ],\n\t].filter( Boolean ) as unknown as TemplateArray;\n\n\tuseForcedLayout( {\n\t\tclientId,\n\t\tregisteredBlocks: allowedBlocks,\n\t\tdefaultTemplate,\n\t} );\n\n\treturn (\n\t\t<Main { ...blockProps }>\n\t\t\t<AddressFieldControls />\n\t\t\t<form\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wc-block-components-form wc-block-checkout__form',\n\t\t\t\t\t{\n\t\t\t\t\t\t'wc-block-checkout__form--with-step-numbers':\n\t\t\t\t\t\t\tshowFormStepNumbers,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t<InnerBlocks\n\t\t\t\t\tallowedBlocks={ allowedBlocks }\n\t\t\t\t\ttemplateLock={ false }\n\t\t\t\t\ttemplate={ defaultTemplate }\n\t\t\t\t\trenderAppender={ InnerBlocks.ButtonBlockAppender }\n\t\t\t\t/>\n\t\t\t</form>\n\t\t</Main>\n\t);\n};\n\nexport const Save = (): JSX.Element => {\n\treturn (\n\t\t<div { ...useBlockProps.save() }>\n\t\t\t<InnerBlocks.Content />\n\t\t</div>\n\t);\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Displays a paginated navigation to next/previous set of posts, when applicable. that allows users to configure: pagination arrow, show label"}, {"role": "assistant", "content": "// File: packages/block-library/src/query-pagination/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/query-pagination\",\n\t\"title\": \"Pagination\",\n\t\"category\": \"theme\",\n\t\"ancestor\": [ \"core/query\" ],\n\t\"allowedBlocks\": [\n\t\t\"core/query-pagination-previous\",\n\t\t\"core/query-pagination-numbers\",\n\t\t\"core/query-pagination-next\"\n\t],\n\t\"description\": \"Displays a paginated navigation to next/previous set of posts, when applicable.\",\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"paginationArrow\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"none\"\n\t\t},\n\t\t\"showLabel\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": true\n\t\t}\n\t},\n\t\"usesContext\": [ \"queryId\", \"query\" ],\n\t\"providesContext\": {\n\t\t\"paginationArrow\": \"paginationArrow\",\n\t\t\"showLabel\": \"showLabel\"\n\t},\n\t\"supports\": {\n\t\t\"align\": true,\n\t\t\"reusable\": false,\n\t\t\"html\": false,\n\t\t\"color\": {\n\t\t\t\"gradients\": true,\n\t\t\t\"link\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"background\": true,\n\t\t\t\t\"text\": true,\n\t\t\t\t\"link\": true\n\t\t\t}\n\t\t},\n\t\t\"layout\": {\n\t\t\t\"allowSwitching\": false,\n\t\t\t\"allowInheriting\": false,\n\t\t\t\"default\": {\n\t\t\t\t\"type\": \"flex\"\n\t\t\t}\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true,\n\t\t\t\"__experimentalFontFamily\": true,\n\t\t\t\"__experimentalFontWeight\": true,\n\t\t\t\"__experimentalFontStyle\": true,\n\t\t\t\"__experimentalTextTransform\": true,\n\t\t\t\"__experimentalTextDecoration\": true,\n\t\t\t\"__experimentalLetterSpacing\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"fontSize\": true\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-query-pagination-editor\",\n\t\"style\": \"wp-block-query-pagination\"\n}\n\n\n// File: packages/block-library/src/query-pagination/index.js\n/**\n * WordPress dependencies\n */\nimport { queryPagination as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/query-pagination/save.js\n/**\n * WordPress dependencies\n */\nimport { InnerBlocks } from '@wordpress/block-editor';\n\nexport default function save() {\n\treturn <InnerBlocks.Content />;\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a block for Display multiple images in sequential order. that allows users to configure: align, autoplay, delay, and 4 more options"}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/slideshow/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/slideshow\",\n\t\"title\": \"Slideshow\",\n\t\"description\": \"Display multiple images in sequential order.\",\n\t\"keywords\": [ \"story\", \"image\", \"video\", \"gallery\" ],\n\t\"version\": \"12.5.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"media\",\n\t\"icon\": \"<svg viewBox='0 0 24 24' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><path d='m19,21.5H6v-1h13c.83,0,1.5-.67,1.5-1.5v-11h1v11c0,1.38-1.12,2.5-2.5,2.5Z'/><path d='m16.38,3.25H4.62c-.75,0-1.37.62-1.37,1.37v11.76c0,.75.62,1.37,1.37,1.37h11.76c.75,0,1.37-.62,1.37-1.37V4.62c0-.75-.62-1.37-1.37-1.37Zm.37,13.13c0,.2-.17.37-.37.37H4.62c-.2,0-.37-.17-.37-.37V4.62c0-.2.17-.37.37-.37h11.76c.2,0,.37.17.37.37v11.76Z'/><path d='M9.39 7.51 12.73 11.04 9.31 14.32 8.61 13.6 11.34 10.99 8.67 8.2 9.39 7.51z'/></svg>\",\n\t\"supports\": {\n\t\t\"html\": false,\n\t\t\"align\": [ \"center\", \"wide\", \"full\" ]\n\t},\n\t\"attributes\": {\n\t\t\"align\": {\n\t\t\t\"default\": \"center\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"autoplay\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"default\": false\n\t\t},\n\t\t\"delay\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"default\": 3\n\t\t},\n\t\t\"ids\": {\n\t\t\t\"default\": [],\n\t\t\t\"type\": \"array\"\n\t\t},\n\t\t\"images\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"default\": [],\n\t\t\t\"source\": \"query\",\n\t\t\t\"selector\": \".swiper-slide\",\n\t\t\t\"query\": {\n\t\t\t\t\"alt\": {\n\t\t\t\t\t\"source\": \"attribute\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"attribute\": \"alt\",\n\t\t\t\t\t\"default\": \"\"\n\t\t\t\t},\n\t\t\t\t\"caption\": {\n\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\"source\": \"html\",\n\t\t\t\t\t\"selector\": \"figcaption\"\n\t\t\t\t},\n\t\t\t\t\"id\": {\n\t\t\t\t\t\"source\": \"attribute\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"attribute\": \"data-id\"\n\t\t\t\t},\n\t\t\t\t\"url\": {\n\t\t\t\t\t\"source\": \"attribute\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"attribute\": \"src\"\n\t\t\t\t},\n\t\t\t\t\"aspectRatio\": {\n\t\t\t\t\t\"source\": \"attribute\",\n\t\t\t\t\t\"selector\": \"img\",\n\t\t\t\t\t\"attribute\": \"data-aspect-ratio\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"effect\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"default\": \"slide\"\n\t\t},\n\t\t\"sizeSlug\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t},\n\t\"example\": {\n\t\t\"align\": \"center\",\n\t\t\"autoplay\": true,\n\t\t\"ids\": [ 22, 23, 24 ],\n\t\t\"images\": [\n\t\t\t{\n\t\t\t\t\"alt\": \"\",\n\t\t\t\t\"caption\": \"\",\n\t\t\t\t\"id\": 22,\n\t\t\t\t\"url\": \"./slideshowExample1.png\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"alt\": \"\",\n\t\t\t\t\"caption\": \"\",\n\t\t\t\t\"id\": 23,\n\t\t\t\t\"url\": \"./slideshowExample2.png\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"alt\": \"\",\n\t\t\t\t\"caption\": \"\",\n\t\t\t\t\"id\": 24,\n\t\t\t\t\"url\": \"./slideshowExample3.png\"\n\t\t\t}\n\t\t],\n\t\t\"effect\": \"slide\"\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/slideshow/edit.js\nimport { getBlockIconComponent } from '@automattic/jetpack-shared-extension-utils';\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tMediaPlaceholder,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { DropZone, FormFileUpload, withNotices } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport domReady from '@wordpress/dom-ready';\nimport { mediaUpload } from '@wordpress/editor';\nimport { useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { pick } from 'lodash';\nimport metadata from './block.json';\nimport { PanelControls, ToolbarControls } from './controls';\nimport Slideshow from './slideshow';\nimport applyPaddingForStackBlock from './utils';\n\nimport './editor.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nexport const pickRelevantMediaFiles = ( image, sizeSlug ) => {\n\tconst imageProps = pick( image, [ 'alt', 'id', 'link', 'caption' ] );\n\t// Prefer the requested size, fallback to 'full' if missing\n\tconst chosenSize =\n\t\timage?.sizes?.[ sizeSlug ] ||\n\t\timage?.media_details?.sizes?.[ sizeSlug ] ||\n\t\timage?.sizes?.full ||\n\t\timage?.media_details?.sizes?.full ||\n\t\timage;\n\n\timageProps.url = chosenSize?.url || chosenSize?.source_url || image.url;\n\n\timageProps.width = chosenSize?.width || null;\n\timageProps.height = chosenSize?.height || null;\n\timageProps.aspectRatio =\n\t\tchosenSize?.width && chosenSize?.height\n\t\t\t? `${ chosenSize.width } / ${ chosenSize.height }`\n\t\t\t: null;\n\n\treturn imageProps;\n};\n\nexport const SlideshowEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tclassName,\n\tisSelected,\n\tnoticeOperations,\n\tnoticeUI,\n\tlockPostSaving,\n\tunlockPostSaving,\n\timageSizes,\n\tresizedImages,\n} ) => {\n\tconst { align, autoplay, delay, effect, images, sizeSlug, ids } = attributes;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: className,\n\t} );\n\n\tconst setImages = imgs => {\n\t\tsetAttributes( {\n\t\t\timages: imgs,\n\t\t\tids: imgs.map( ( { id } ) => parseInt( id, 10 ) ),\n\t\t} );\n\t};\n\tuseEffect( () => {\n\t\tif ( typeof window !== 'undefined' ) {\n\t\t\tdomReady( function () {\n\t\t\t\tapplyPaddingForStackBlock();\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tconst onSelectImages = imgs =>\n\t\tsetImages( imgs.map( image => pickRelevantMediaFiles( image, sizeSlug ) ) );\n\n\tconst addFiles = files => {\n\t\tconst lockName = 'slideshowBlockLock';\n\n\t\tlockPostSaving( lockName );\n\t\tmediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: imgs => {\n\t\t\t\tconst imagesNormalized = imgs.map( image => pickRelevantMediaFiles( image, sizeSlug ) );\n\n\t\t\t\tsetImages( [ ...( images || [] ), ...imagesNormalized ] );\n\n\t\t\t\tif ( ! imagesNormalized.every( image => isBlobURL( image.url ) ) ) {\n\t\t\t\t\tunlockPostSaving( lockName );\n\t\t\t\t}\n\t\t\t},\n\t\t\tonError: noticeOperations.createErrorNotice,\n\t\t} );\n\t};\n\n\tconst uploadFromFiles = event => addFiles( event.target.files );\n\n\tconst getImageSizeOptions = () =>\n\t\timageSizes?.map( ( { name, slug } ) => ( { value: slug, label: name } ) ) ?? [];\n\n\tconst updateImagesSize = slug => {\n\t\tconst updatedImages = images.map( image => {\n\t\t\tconst resizedImage = resizedImages.find(\n\t\t\t\t( { id } ) => parseInt( id, 10 ) === parseInt( image.id, 10 )\n\t\t\t);\n\t\t\tconst sizeObj =\n\t\t\t\tresizedImage?.sizes?.[ slug ] ||\n\t\t\t\tresizedImage?.media_details?.sizes?.[ slug ] ||\n\t\t\t\tresizedImage?.sizes?.full ||\n\t\t\t\tresizedImage?.media_details?.sizes?.full;\n\n\t\t\tconst url = sizeObj?.source_url || sizeObj?.url || image.url;\n\t\t\treturn {\n\t\t\t\t...image,\n\t\t\t\t...( url && { url } ),\n\t\t\t};\n\t\t} );\n\n\t\tsetImages( updatedImages );\n\t\tsetAttributes( { sizeSlug: slug } );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! sizeSlug ) {\n\t\t\t// To improve the performance, we use large size images by default except for blocks inserted before the\n\t\t\t// image size attribute was added, since they were loading full size images. The presence or lack of images\n\t\t\t// in a block determines when it has been inserted (before or after we added the image size attribute),\n\t\t\t// given that now it is not possible to have a block with images and no size.\n\t\t\tsetAttributes( { sizeSlug: ids.length ? 'full' : 'large' } );\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tlet content;\n\n\tif ( images.length === 0 ) {\n\t\tcontent = (\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ getBlockIconComponent( metadata ) }\n\t\t\t\tlabels={ {\n\t\t\t\t\ttitle: __( 'Slideshow', 'jetpack' ),\n\t\t\t\t\tinstructions: __(\n\t\t\t\t\t\t'Drag images, upload new ones or select files from your library.',\n\t\t\t\t\t\t'jetpack'\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t\tonSelect={ onSelectImages }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tmultiple\n\t\t\t\tnotices={ noticeUI }\n\t\t\t\tonError={ noticeOperations.createErrorNotice }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\tcontent = (\n\t\t\t<>\n\t\t\t\t{ noticeUI }\n\t\t\t\t<Slideshow\n\t\t\t\t\talign={ align }\n\t\t\t\t\tautoplay={ autoplay }\n\t\t\t\t\tdelay={ delay }\n\t\t\t\t\teffect={ effect }\n\t\t\t\t\timages={ images }\n\t\t\t\t\tonError={ noticeOperations.createErrorNotice }\n\t\t\t\t/>\n\t\t\t\t<DropZone onFilesDrop={ addFiles } />\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<div className=\"wp-block-jetpack-slideshow__add-item\">\n\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\tmultiple\n\t\t\t\t\t\t\tclassName=\"wp-block-jetpack-slideshow__add-item-button\"\n\t\t\t\t\t\t\tonChange={ uploadFromFiles }\n\t\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\t\ticon=\"insert\"\n\t\t\t\t\t\t\t__next40pxDefaultSize={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Upload an image', 'jetpack' ) }\n\t\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelControls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\timageSizeOptions={ getImageSizeOptions() }\n\t\t\t\t\tonChangeImageSize={ updateImagesSize }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarControls\n\t\t\t\t\tallowedMediaTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tonSelectImages={ onSelectImages }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t{ content }\n\t\t</div>\n\t);\n};\n\nexport default compose(\n\twithSelect( ( select, props ) => {\n\t\tconst { ids } = props.attributes;\n\t\tconst { getEntityRecord } = select( 'core' );\n\t\tconst imageSizes = select( 'core/editor' ).getEditorSettings().imageSizes;\n\n\t\tconst resizedImages = ids.map( id => {\n\t\t\tconst media = getEntityRecord( 'postType', 'attachment', id );\n\t\t\treturn { id, sizes: media?.media_details?.sizes };\n\t\t} );\n\n\t\treturn { imageSizes, resizedImages };\n\t} ),\n\twithDispatch( dispatch => {\n\t\tconst { lockPostSaving, unlockPostSaving } = dispatch( 'core/editor' );\n\t\treturn {\n\t\t\tlockPostSaving,\n\t\t\tunlockPostSaving,\n\t\t};\n\t} ),\n\twithNotices\n)( SlideshowEdit );\n\n\n// File: projects/plugins/jetpack/extensions/blocks/slideshow/save.js\nimport { useBlockProps } from '@wordpress/block-editor';\nimport Slideshow from './slideshow';\n\nexport default ( { attributes: { align, autoplay, delay, effect, images }, className } ) => {\n\tconst blockProps = useBlockProps.save( {\n\t\tclassName: className,\n\t} );\n\n\treturn (\n\t\t<Slideshow\n\t\t\talign={ align }\n\t\t\tautoplay={ autoplay }\n\t\t\tclassName={ blockProps.className }\n\t\t\tdelay={ delay }\n\t\t\teffect={ effect }\n\t\t\timages={ images }\n\t\t/>\n\t);\n};\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Develop a Gutenberg block featuring comprehensive video integration capabilities, allowing media library selection or fresh uploads with extensive customization options including autoplay, captions, and playback controls."}, {"role": "assistant", "content": "// File: packages/block-library/src/video/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"core/video\",\n\t\"title\": \"Video\",\n\t\"category\": \"media\",\n\t\"description\": \"Embed a video from your media library or upload a new one.\",\n\t\"keywords\": [ \"movie\" ],\n\t\"textdomain\": \"default\",\n\t\"attributes\": {\n\t\t\"autoplay\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"autoplay\"\n\t\t},\n\t\t\"caption\": {\n\t\t\t\"type\": \"rich-text\",\n\t\t\t\"source\": \"rich-text\",\n\t\t\t\"selector\": \"figcaption\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"controls\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"controls\",\n\t\t\t\"default\": true\n\t\t},\n\t\t\"id\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"loop\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"loop\"\n\t\t},\n\t\t\"muted\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"muted\"\n\t\t},\n\t\t\"poster\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"poster\"\n\t\t},\n\t\t\"preload\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"preload\",\n\t\t\t\"default\": \"metadata\"\n\t\t},\n\t\t\"blob\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"role\": \"local\"\n\t\t},\n\t\t\"src\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"src\",\n\t\t\t\"role\": \"content\"\n\t\t},\n\t\t\"playsInline\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"source\": \"attribute\",\n\t\t\t\"selector\": \"video\",\n\t\t\t\"attribute\": \"playsinline\"\n\t\t},\n\t\t\"tracks\": {\n\t\t\t\"role\": \"content\",\n\t\t\t\"type\": \"array\",\n\t\t\t\"items\": {\n\t\t\t\t\"type\": \"object\"\n\t\t\t},\n\t\t\t\"default\": []\n\t\t}\n\t},\n\t\"supports\": {\n\t\t\"anchor\": true,\n\t\t\"align\": true,\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true,\n\t\t\t\"__experimentalDefaultControls\": {\n\t\t\t\t\"margin\": false,\n\t\t\t\t\"padding\": false\n\t\t\t}\n\t\t},\n\t\t\"interactivity\": {\n\t\t\t\"clientNavigation\": true\n\t\t}\n\t},\n\t\"editorStyle\": \"wp-block-video-editor\",\n\t\"style\": \"wp-block-video\"\n}\n\n\n// File: packages/block-library/src/video/index.js\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { video as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tsrc: 'https://upload.wikimedia.org/wikipedia/commons/c/ca/Wood_thrush_in_Central_Park_switch_sides_%2816510%29.webm',\n\t\t\t// translators: Caption accompanying a video of the wood thrush singing, which serves as an example for the Video block.\n\t\t\tcaption: __( 'Wood thrush singing in Central Park, NYC.' ),\n\t\t},\n\t},\n\ttransforms,\n\tdeprecated,\n\tedit,\n\tsave,\n};\n\nif ( window.__experimentalContentOnlyInspectorFields ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'video',\n\t\t\tlabel: __( 'Video' ),\n\t\t\ttype: 'media',\n\t\t\tmapping: {\n\t\t\t\tid: 'id',\n\t\t\t\turl: 'src',\n\t\t\t\tcaption: 'caption',\n\t\t\t\tposter: 'poster',\n\t\t\t},\n\t\t\targs: {\n\t\t\t\tallowedTypes: [ 'video' ],\n\t\t\t\tmultiple: false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'caption',\n\t\t\tlabel: __( 'Caption' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'video' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n\n\n// File: packages/block-library/src/video/save.js\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport Tracks from './tracks';\n\nexport default function save( { attributes } ) {\n\tconst {\n\t\tautoplay,\n\t\tcaption,\n\t\tcontrols,\n\t\tloop,\n\t\tmuted,\n\t\tposter,\n\t\tpreload,\n\t\tsrc,\n\t\tplaysInline,\n\t\ttracks,\n\t} = attributes;\n\treturn (\n\t\t<figure { ...useBlockProps.save() }>\n\t\t\t{ src && (\n\t\t\t\t<video\n\t\t\t\t\tautoPlay={ autoplay }\n\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\tloop={ loop }\n\t\t\t\t\tmuted={ muted }\n\t\t\t\t\tposter={ poster }\n\t\t\t\t\tpreload={ preload !== 'metadata' ? preload : undefined }\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tplaysInline={ playsInline }\n\t\t\t\t>\n\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t</video>\n\t\t\t) }\n\t\t\t{ ! RichText.isEmpty( caption ) && (\n\t\t\t\t<RichText.Content\n\t\t\t\t\tclassName={ __experimentalGetElementClassName( 'caption' ) }\n\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\tvalue={ caption }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</figure>\n\t);\n}\n"}]}
{"messages": [{"role": "system", "content": "You are an expert WordPress developer specializing in creating high-quality plugins and Gutenberg blocks.\nYou write clean, well-documented code following WordPress coding standards and best practices.\nYour code is secure, performant, and maintainable.\n"}, {"role": "user", "content": "Craft a WordPress block enabling users to specify and display your business's operating hours with customizable day settings."}, {"role": "assistant", "content": "<|thinking|>\nTo create this {type}, I need to:\n- Create the block.json configuration file\n- Register the block type\n- Define block attributes and their types\n- Implement the Edit component for the editor\n- Implement the Save component for frontend rendering\n- Add necessary controls in the inspector panel\n- Style the block for both editor and frontend\n<|im_end|>\n\n\n// File: projects/plugins/jetpack/extensions/blocks/business-hours/block.json\n{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"jetpack/business-hours\",\n\t\"title\": \"Business Hours\",\n\t\"description\": \"Display opening hours for your business.\",\n\t\"keywords\": [ \"opening hours\", \"closing time\", \"schedule\", \"working day\" ],\n\t\"version\": \"12.5.0\",\n\t\"textdomain\": \"jetpack\",\n\t\"category\": \"grow\",\n\t\"icon\": \"<svg viewBox='0 0 24 24' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><path d='M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'/></svg>\",\n\t\"supports\": {\n\t\t\"html\": true,\n\t\t\"color\": {\n\t\t\t\"gradients\": true\n\t\t},\n\t\t\"spacing\": {\n\t\t\t\"margin\": true,\n\t\t\t\"padding\": true\n\t\t},\n\t\t\"typography\": {\n\t\t\t\"fontSize\": true,\n\t\t\t\"lineHeight\": true\n\t\t},\n\t\t\"align\": [ \"wide\", \"full\" ]\n\t},\n\t\"attributes\": {\n\t\t\"days\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"default\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Sun\",\n\t\t\t\t\t\"hours\": []\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Mon\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Tue\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Wed\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Thu\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Fri\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Sat\",\n\t\t\t\t\t\"hours\": []\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t},\n\t\"example\": {\n\t\t\"attributes\": {\n\t\t\t\"days\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Sun\",\n\t\t\t\t\t\"hours\": []\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Mon\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Tue\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Wed\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Thu\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Fri\",\n\t\t\t\t\t\"hours\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"opening\": \"09:00\",\n\t\t\t\t\t\t\t\"closing\": \"17:00\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Sat\",\n\t\t\t\t\t\"hours\": []\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t}\n}\n\n\n// File: projects/plugins/jetpack/extensions/blocks/business-hours/edit.js\nimport { getBlockIconComponent } from '@automattic/jetpack-shared-extension-utils';\nimport apiFetch from '@wordpress/api-fetch';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { Placeholder } from '@wordpress/components';\nimport { getSettings } from '@wordpress/date';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport metadata from './block.json';\nimport DayEdit from './components/day-edit';\nimport DayPreview from './components/day-preview';\n\nconst icon = getBlockIconComponent( metadata );\n\nexport const defaultLocalization = {\n\tdays: {\n\t\tSun: __( 'Sunday', 'jetpack' ),\n\t\tMon: __( 'Monday', 'jetpack' ),\n\t\tTue: __( 'Tuesday', 'jetpack' ),\n\t\tWed: __( 'Wednesday', 'jetpack' ),\n\t\tThu: __( 'Thursday', 'jetpack' ),\n\t\tFri: __( 'Friday', 'jetpack' ),\n\t\tSat: __( 'Saturday', 'jetpack' ),\n\t},\n\tstartOfWeek: 0,\n};\n\nconst BusinessHours = props => {\n\tconst { attributes, isSelected } = props;\n\tconst blockProps = useBlockProps();\n\tconst [ localization, setLocalization ] = useState( defaultLocalization );\n\tconst [ hasFetched, setHasFetched ] = useState( false );\n\n\tconst { days } = attributes;\n\tconst { startOfWeek } = localization;\n\tconst localizedWeek = days.concat( days.slice( 0, startOfWeek ) ).slice( startOfWeek );\n\n\tuseEffect( () => {\n\t\tapiFetch( { path: '/wpcom/v2/business-hours/localized-week' } ).then(\n\t\t\tdata => {\n\t\t\t\tsetLocalization( data );\n\t\t\t\tsetHasFetched( true );\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tsetLocalization( defaultLocalization );\n\t\t\t\tsetHasFetched( true );\n\t\t\t}\n\t\t);\n\t}, [] );\n\n\tlet content;\n\n\tif ( ! hasFetched ) {\n\t\tcontent = <Placeholder icon={ icon } label={ __( 'Loading business hours', 'jetpack' ) } />;\n\t} else if ( ! isSelected ) {\n\t\tconst settings = getSettings();\n\t\tconst {\n\t\t\tformats: { time },\n\t\t} = settings;\n\n\t\tcontent = (\n\t\t\t<dl className=\"jetpack-business-hours\">\n\t\t\t\t{ localizedWeek.map( ( day, key ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DayPreview key={ key } day={ day } localization={ localization } timeFormat={ time } />\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</dl>\n\t\t);\n\t} else {\n\t\tcontent = (\n\t\t\t<div className=\"is-edit\">\n\t\t\t\t{ localizedWeek.map( ( day, key ) => {\n\t\t\t\t\treturn <DayEdit key={ key } day={ day } localization={ localization } { ...props } />;\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...blockProps }>{ content }</div>;\n};\n\nexport default BusinessHours;\n"}]}