Enable and fix all jsdoc rule violations (https://github.com/woocommerce/woocommerce-blocks/pull/3168)
* add param jsdocs to satisfy jsdoc require-param rule * Fix jsdoc-checktypes rule violations * fix jsdoc/require-param-type rule violations * fix jsdoc/check-param-names violations * fix jsdoc/require-property-description rule violations * fix rule violations for jsdoc/valid-types rule * fix rule violations for jsdoc/require-property rule * fix jsdoc/no-undefined-types rule violations * fix jsdoc/check-types rule violations * fix jsdoc/require-returns-description rule violation * enable jsdoc/require-returns-type rule * fix jsdoc/newline-after-description rule violations
This commit is contained in:
parent
f5b18f6fe1
commit
9115160c2f
|
@ -14,6 +14,9 @@ module.exports = {
|
||||||
context: 'readonly',
|
context: 'readonly',
|
||||||
jestPuppeteer: 'readonly',
|
jestPuppeteer: 'readonly',
|
||||||
},
|
},
|
||||||
|
settings: {
|
||||||
|
jsdoc: { mode: 'typescript' },
|
||||||
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'woocommerce/feature-flag': 'off',
|
'woocommerce/feature-flag': 'off',
|
||||||
// @todo Remove temporary disabling of various eslint rules.
|
// @todo Remove temporary disabling of various eslint rules.
|
||||||
|
@ -38,18 +41,6 @@ module.exports = {
|
||||||
// - @worpdress/no-unused-vars-before-return
|
// - @worpdress/no-unused-vars-before-return
|
||||||
// - testing-library/no-await-sync-query
|
// - testing-library/no-await-sync-query
|
||||||
// - @woocommerce/dependency-group
|
// - @woocommerce/dependency-group
|
||||||
'jsdoc/require-param': 'off',
|
|
||||||
'jsdoc/check-tag-names': 'off',
|
|
||||||
'jsdoc/check-param-names': 'off',
|
|
||||||
'jsdoc/require-property-description': 'off',
|
|
||||||
'jsdoc/valid-types': 'off',
|
|
||||||
'jsdoc/require-property': 'off',
|
|
||||||
'jsdoc/no-undefined-types': 'off',
|
|
||||||
'jsdoc/check-types': 'off',
|
|
||||||
'jsdoc/require-returns-description': 'off',
|
|
||||||
'jsdoc/require-param-type': 'off',
|
|
||||||
'jsdoc/require-returns-type': 'off',
|
|
||||||
'jsdoc/newline-after-description': 'off',
|
|
||||||
'@wordpress/i18n-translator-comments': 'off',
|
'@wordpress/i18n-translator-comments': 'off',
|
||||||
'@wordpress/valid-sprintf': 'off',
|
'@wordpress/valid-sprintf': 'off',
|
||||||
'@wordpress/no-unused-vars-before-return': 'off',
|
'@wordpress/no-unused-vars-before-return': 'off',
|
||||||
|
|
|
@ -7,6 +7,10 @@ import { getAttributes, getVariationAttributes } from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VariationAttributes component.
|
* VariationAttributes component.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props
|
||||||
|
* @param {Object} props.product Product
|
||||||
|
* @param {Object} props.dispatchers An object where values are dispatching functions.
|
||||||
*/
|
*/
|
||||||
const VariationAttributes = ( { product, dispatchers } ) => {
|
const VariationAttributes = ( { product, dispatchers } ) => {
|
||||||
const attributes = getAttributes( product.attributes );
|
const attributes = getAttributes( product.attributes );
|
||||||
|
|
|
@ -84,7 +84,12 @@ const AddToCartButton = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Button for non-purchasable products.
|
* Button component for non-purchasable products.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props.
|
||||||
|
* @param {string} props.className Css classnames.
|
||||||
|
* @param {string} props.href Link for button.
|
||||||
|
* @param {string} props.text Text content for button.
|
||||||
*/
|
*/
|
||||||
const LinkComponent = ( { className, href, text } ) => {
|
const LinkComponent = ( { className, href, text } ) => {
|
||||||
return (
|
return (
|
||||||
|
@ -96,6 +101,14 @@ const LinkComponent = ( { className, href, text } ) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Button for purchasable products.
|
* Button for purchasable products.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for component
|
||||||
|
* @param {string} props.className Incoming css class name.
|
||||||
|
* @param {number} props.quantityInCart Quantity of item in cart.
|
||||||
|
* @param {boolean} props.isProcessing Whether processing action is occurring.
|
||||||
|
* @param {boolean} props.isDisabled Whether the button is disabled or not.
|
||||||
|
* @param {boolean} props.isDone Whether processing is done.
|
||||||
|
* @param {function():any} props.onClick Callback to execute when button is clicked.
|
||||||
*/
|
*/
|
||||||
const ButtonComponent = ( {
|
const ButtonComponent = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* Quantity Input Component.
|
* Quantity Input Component.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for component
|
||||||
|
* @param {boolean} props.disabled Whether input is disabled or not.
|
||||||
|
* @param {number} props.min Minimum value for input.
|
||||||
|
* @param {number} props.max Maximum value for input.
|
||||||
|
* @param {number} props.value Value for input.
|
||||||
|
* @param {function():any} props.onChange Function to call on input change event.
|
||||||
*/
|
*/
|
||||||
const QuantityInput = ( { disabled, min, max, value, onChange } ) => {
|
const QuantityInput = ( { disabled, min, max, value, onChange } ) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -27,7 +27,6 @@ import { withProductDataContext } from '@woocommerce/shared-hocs';
|
||||||
* @param {string} [props.customColor] Normal Price custom text color.
|
* @param {string} [props.customColor] Normal Price custom text color.
|
||||||
* @param {string} [props.saleColor] Original Price text color.
|
* @param {string} [props.saleColor] Original Price text color.
|
||||||
* @param {string} [props.customSaleColor] Original Price custom text color.
|
* @param {string} [props.customSaleColor] Original Price custom text color.
|
||||||
* @param {Object} [props.product] Optional product object. Product from
|
|
||||||
* context will be used if this is not provided.
|
* context will be used if this is not provided.
|
||||||
* @return {*} The component.
|
* @return {*} The component.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,6 @@ import './style.scss';
|
||||||
* @param {string} [props.customColor] Custom title color value.
|
* @param {string} [props.customColor] Custom title color value.
|
||||||
* @param {string} [props.fontSize] Title font size name.
|
* @param {string} [props.fontSize] Title font size name.
|
||||||
* @param {number } [props.customFontSize] Custom font size value.
|
* @param {number } [props.customFontSize] Custom font size value.
|
||||||
* @param {Object} [props.product] Optional product object. Product from context
|
|
||||||
* will be used if this is not provided.
|
* will be used if this is not provided.
|
||||||
* @return {*} The component.
|
* @return {*} The component.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,8 +10,17 @@ import classNames from 'classnames';
|
||||||
*/
|
*/
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that visually renders a button but semantically might be `<button>` or `<a>` depending on the props.
|
* Component that visually renders a button but semantically might be `<button>` or `<a>` depending
|
||||||
|
* on the props.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS classname used.
|
||||||
|
* @param {boolean} props.showSpinner Whether to show spinner or not.
|
||||||
|
* @param {React.ReactChildren} props.children Child components passed in.
|
||||||
|
* @param {Object} props.props Rest of incoming props.
|
||||||
*/
|
*/
|
||||||
const Button = ( { className, showSpinner = false, children, ...props } ) => {
|
const Button = ( { className, showSpinner = false, children, ...props } ) => {
|
||||||
const buttonClassName = classNames(
|
const buttonClassName = classNames(
|
||||||
|
|
|
@ -52,6 +52,15 @@ const validateShippingCountry = (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkout address form.
|
* Checkout address form.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for component.
|
||||||
|
* @param {string} props.id Id for component.
|
||||||
|
* @param {Array} props.fields Array of fields in form.
|
||||||
|
* @param {Object} props.fieldConfig Field configuration for fields in form.
|
||||||
|
* @param {string} props.instanceId Unique id for form.
|
||||||
|
* @param {function(any):any} props.onChange Function to all for an form onChange event.
|
||||||
|
* @param {string} props.type Type of form.
|
||||||
|
* @param {Object} props.values Values for fields.
|
||||||
*/
|
*/
|
||||||
const AddressForm = ( {
|
const AddressForm = ( {
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -15,8 +15,9 @@ import './style.scss';
|
||||||
* For a given list of icons, render each as a list item, using common icons
|
* For a given list of icons, render each as a list item, using common icons
|
||||||
* where available.
|
* where available.
|
||||||
*
|
*
|
||||||
* @param {Object} props Component props.
|
* @param {Object} props Component props.
|
||||||
* @param {Array} props.icons Array of icons object configs or ids as strings.
|
* @param {Array} props.icons Array of icons object configs or ids as strings.
|
||||||
|
* @param {string} props.align How to align the icon.
|
||||||
*/
|
*/
|
||||||
export const PaymentMethodIcons = ( { icons = [], align = 'center' } ) => {
|
export const PaymentMethodIcons = ( { icons = [], align = 'center' } ) => {
|
||||||
const iconConfigs = normalizeIconConfig( icons );
|
const iconConfigs = normalizeIconConfig( icons );
|
||||||
|
|
|
@ -9,6 +9,11 @@ const getIconClassName = ( id ) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an element for an icon.
|
* Return an element for an icon.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for component.
|
||||||
|
* @param {string} props.id Id for component.
|
||||||
|
* @param {string|null} props.src Optional src value for icon.
|
||||||
|
* @param {string} props.alt Optional alt value for icon.
|
||||||
*/
|
*/
|
||||||
const PaymentMethodIcon = ( { id, src = null, alt = '' } ) => {
|
const PaymentMethodIcon = ( { id, src = null, alt = '' } ) => {
|
||||||
if ( ! src ) {
|
if ( ! src ) {
|
||||||
|
|
|
@ -7,6 +7,9 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats and returns an image element.
|
* Formats and returns an image element.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.image Image properties.
|
||||||
*/
|
*/
|
||||||
const ProductImage = ( { image = {} } ) => {
|
const ProductImage = ( { image = {} } ) => {
|
||||||
const imageProps = {
|
const imageProps = {
|
||||||
|
|
|
@ -11,6 +11,9 @@ import ProductBadge from '../product-badge';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a low stock badge.
|
* Returns a low stock badge.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {boolean} props.lowStockRemaining Whether or not there is low stock remaining.
|
||||||
*/
|
*/
|
||||||
const ProductLowStockBadge = ( { lowStockRemaining } ) => {
|
const ProductLowStockBadge = ( { lowStockRemaining } ) => {
|
||||||
if ( ! lowStockRemaining ) {
|
if ( ! lowStockRemaining ) {
|
||||||
|
|
|
@ -7,6 +7,11 @@ import { getSetting } from '@woocommerce/settings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element containing a summary of the product.
|
* Returns an element containing a summary of the product.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS class name used.
|
||||||
|
* @param {string} props.shortDescription Short description for the product.
|
||||||
|
* @param {string} props.fullDescription Full description for the product.
|
||||||
*/
|
*/
|
||||||
const ProductSummary = ( {
|
const ProductSummary = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -7,6 +7,10 @@ import classNames from 'classnames';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a formatted element containing variation details.
|
* Returns a formatted element containing variation details.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {Array<Object>} props.variation Variations in use.
|
||||||
*/
|
*/
|
||||||
const ProductVariationData = ( { className, variation = [] } ) => {
|
const ProductVariationData = ( { className, variation = [] } ) => {
|
||||||
if ( ! variation || variation.length === 0 ) {
|
if ( ! variation || variation.length === 0 ) {
|
||||||
|
|
|
@ -11,6 +11,9 @@ import { decodeEntities } from '@wordpress/html-entities';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a formatted shipping location.
|
* Shows a formatted shipping location.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.address Incoming address information.
|
||||||
*/
|
*/
|
||||||
const ShippingLocation = ( { address } ) => {
|
const ShippingLocation = ( { address } ) => {
|
||||||
// we bail early if we don't have an address.
|
// we bail early if we don't have an address.
|
||||||
|
|
|
@ -21,6 +21,13 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the shipping totals row, rates, and calculator if enabled.
|
* Renders the shipping totals row, rates, and calculator if enabled.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.currency Currency information.
|
||||||
|
* @param {Object} props.values Values in use.
|
||||||
|
* @param {boolean} props.isCheckout Whether in checkout or not.
|
||||||
|
* @param {boolean} props.showCalculator Whether to show shipping calculator or not.
|
||||||
|
* @param {boolean} props.showRatesWithoutAddress Whether to show rates without address or not.
|
||||||
*/
|
*/
|
||||||
const TotalsShippingItem = ( {
|
const TotalsShippingItem = ( {
|
||||||
currency,
|
currency,
|
||||||
|
|
|
@ -12,6 +12,14 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component used to show a checkbox control with styles.
|
* Component used to show a checkbox control with styles.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {string} props.label Label for component.
|
||||||
|
* @param {string} props.id Id for component.
|
||||||
|
* @param {string} props.instanceId Unique id for instance of component.
|
||||||
|
* @param {function():any} props.onChange Function called when input changes.
|
||||||
|
* @param {Object} props.rest Rest of properties spread.
|
||||||
*/
|
*/
|
||||||
const CheckboxControl = ( {
|
const CheckboxControl = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -13,6 +13,15 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component used to show a list of checkboxes in a group.
|
* Component used to show a list of checkboxes in a group.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {function():any} props.onChange Function called when inputs change.
|
||||||
|
* @param {Array} props.options Options for list.
|
||||||
|
* @param {Array} props.checked Which items are checked.
|
||||||
|
* @param {boolean} props.isLoading If loading or not.
|
||||||
|
* @param {boolean} props.isDisabled If inputs are disabled or not.
|
||||||
|
* @param {number} props.limit Whether to limit the number of inputs showing.
|
||||||
*/
|
*/
|
||||||
const CheckboxList = ( {
|
const CheckboxList = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -9,11 +9,22 @@ import classNames from 'classnames';
|
||||||
*/
|
*/
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component used to render a "chip" -- a list item containing some text.
|
* Component used to render a "chip" -- a list item containing some text.
|
||||||
*
|
*
|
||||||
* Each chip defaults to a list element but this can be customized by providing
|
* Each chip defaults to a list element but this can be customized by providing
|
||||||
* a wrapperElement.
|
* a wrapperElement.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.text Text for chip content.
|
||||||
|
* @param {string} props.screenReaderText Screenreader text for the content.
|
||||||
|
* @param {string} props.element The element type for the chip.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {string} props.radius Radius size.
|
||||||
|
* @param {React.ReactChildren|null} props.children React children.
|
||||||
|
* @param {Object} props.props Rest of props passed through to component.
|
||||||
*/
|
*/
|
||||||
const Chip = ( {
|
const Chip = ( {
|
||||||
text,
|
text,
|
||||||
|
|
|
@ -14,6 +14,16 @@ import { Chip } from './index.js';
|
||||||
/**
|
/**
|
||||||
* Component used to render a "chip" -- an item containing some text with
|
* Component used to render a "chip" -- an item containing some text with
|
||||||
* an X button to remove/dismiss each chip.
|
* an X button to remove/dismiss each chip.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.ariaLabel Aria label content.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {boolean} props.disabled Whether action is disabled or not.
|
||||||
|
* @param {function():any} props.onRemove Function to call when remove event is fired.
|
||||||
|
* @param {boolean} props.removeOnAnyClick Whether to expand click area for remove event.
|
||||||
|
* @param {string} props.text The text for the chip.
|
||||||
|
* @param {string} props.screenReaderText The screen reader text for the chip.
|
||||||
|
* @param {Object} props.props Rest of props passed into component.
|
||||||
*/
|
*/
|
||||||
const RemovableChip = ( {
|
const RemovableChip = ( {
|
||||||
ariaLabel = '',
|
ariaLabel = '',
|
||||||
|
|
|
@ -19,6 +19,17 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component used to show an input box with a dropdown with suggestions.
|
* Component used to show an input box with a dropdown with suggestions.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.attributeLabel Label for the attributes.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {Array} props.checked Which items are checked.
|
||||||
|
* @param {string} props.inputLabel Label used for the input.
|
||||||
|
* @param {boolean} props.isDisabled Whether the input is disabled or not.
|
||||||
|
* @param {boolean} props.isLoading Whether the input is loading.
|
||||||
|
* @param {boolean} props.multiple Whether multi-select is allowed.
|
||||||
|
* @param {function():any} props.onChange Function to be called when onChange event fires.
|
||||||
|
* @param {Array} props.options The option values to show in the select.
|
||||||
*/
|
*/
|
||||||
const DropdownSelector = ( {
|
const DropdownSelector = ( {
|
||||||
attributeLabel = '',
|
attributeLabel = '',
|
||||||
|
|
|
@ -33,6 +33,11 @@ const currencyToNumberFormat = ( currency ) => {
|
||||||
* Takes a price and returns a formatted price using the NumberFormat component.
|
* Takes a price and returns a formatted price using the NumberFormat component.
|
||||||
*
|
*
|
||||||
* @param {Object} props Component props.
|
* @param {Object} props Component props.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {number} props.value Value of money amount.
|
||||||
|
* @param {Object} props.currency Currency configuration object.
|
||||||
|
* @param {function():any} props.onValueChange Function to call when value changes.
|
||||||
|
* @param {Object} props.props Rest of props passed into component.
|
||||||
*/
|
*/
|
||||||
const FormattedMonetaryAmount = ( {
|
const FormattedMonetaryAmount = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -9,6 +9,12 @@ import classNames from 'classnames';
|
||||||
* Component used to render an accessible text given a label and/or a
|
* Component used to render an accessible text given a label and/or a
|
||||||
* screenReaderLabel. The wrapper element and wrapper props can also be
|
* screenReaderLabel. The wrapper element and wrapper props can also be
|
||||||
* specified via props.
|
* specified via props.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.label Label content.
|
||||||
|
* @param {string} props.screenReaderLabel Content for screen readers.
|
||||||
|
* @param {string} props.wrapperElement What element is used to wrap the label.
|
||||||
|
* @param {Object} props.wrapperProps Props passed into wrapper element.
|
||||||
*/
|
*/
|
||||||
const Label = ( {
|
const Label = ( {
|
||||||
label,
|
label,
|
||||||
|
|
|
@ -25,6 +25,17 @@ import FilterSubmitButton from '../filter-submit-button';
|
||||||
* Price slider component.
|
* Price slider component.
|
||||||
*
|
*
|
||||||
* @param {Object} props Component props.
|
* @param {Object} props Component props.
|
||||||
|
* @param {number} props.minPrice Minimum price for slider.
|
||||||
|
* @param {number} props.maxPrice Maximum price for slider.
|
||||||
|
* @param {number} props.minConstraint Minimum constraint.
|
||||||
|
* @param {number} props.maxConstraint Maximum constraint.
|
||||||
|
* @param {function(any):any} props.onChange Function to call on the change event.
|
||||||
|
* @param {number} props.step What step values the slider uses.
|
||||||
|
* @param {Object} props.currency Currency configuration object.
|
||||||
|
* @param {boolean} props.showInputFields Whether to show input fields for the values or not.
|
||||||
|
* @param {boolean} props.showFilterButton Whether to show the filter button for the slider.
|
||||||
|
* @param {boolean} props.isLoading Whether values are loading or not.
|
||||||
|
* @param {function():any} props.onSubmit Function to call when submit event fires.
|
||||||
*/
|
*/
|
||||||
const PriceSlider = ( {
|
const PriceSlider = ( {
|
||||||
minPrice,
|
minPrice,
|
||||||
|
|
|
@ -14,6 +14,17 @@ import './style.scss';
|
||||||
/**
|
/**
|
||||||
* Component used for 'Order by' selectors, which renders a label
|
* Component used for 'Order by' selectors, which renders a label
|
||||||
* and a <select> with the options provided in the props.
|
* and a <select> with the options provided in the props.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {string} props.instanceId Unique id for component instance.
|
||||||
|
* @param {string} props.defaultValue Default value for the select.
|
||||||
|
* @param {string} props.label Label for the select.
|
||||||
|
* @param {function():any} props.onChange Function to call on the change event.
|
||||||
|
* @param {Array} props.options Option values for the select.
|
||||||
|
* @param {string} props.screenReaderLabel Screen reader label.
|
||||||
|
* @param {boolean} props.readOnly Whether the select is read only or not.
|
||||||
|
* @param {string} props.value The selected value.
|
||||||
*/
|
*/
|
||||||
const SortSelect = ( {
|
const SortSelect = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { autop } from '@wordpress/autop';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the summary text from a string of text.
|
* Generates the summary text from a string of text.
|
||||||
*a
|
*
|
||||||
* @param {string} source Source text.
|
* @param {string} source Source text.
|
||||||
* @param {number} maxLength Limit number of countType returned if text has multiple paragraphs.
|
* @param {number} maxLength Limit number of countType returned if text has multiple paragraphs.
|
||||||
* @param {string} countType What is being counted. One of words, characters_excluding_spaces, or characters_including_spaces.
|
* @param {string} countType What is being counted. One of words, characters_excluding_spaces, or characters_including_spaces.
|
||||||
|
|
|
@ -9,8 +9,16 @@ import PropTypes from 'prop-types';
|
||||||
*/
|
*/
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that renders a block title.
|
* Component that renders a block title.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {React.ReactChildren} props.children Children elements this component wraps.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {string} props.headingLevel Heading level for title.
|
||||||
|
* @param {Object} props.props Rest of props passed through to component.
|
||||||
*/
|
*/
|
||||||
const Title = ( { children, className, headingLevel, ...props } ) => {
|
const Title = ( { children, className, headingLevel, ...props } ) => {
|
||||||
const buttonClassName = classNames(
|
const buttonClassName = classNames(
|
||||||
|
|
|
@ -31,6 +31,9 @@ const {
|
||||||
*
|
*
|
||||||
* @param {Object} state Current state.
|
* @param {Object} state Current state.
|
||||||
* @param {Object} action Incoming action object.
|
* @param {Object} action Incoming action object.
|
||||||
|
* @param {number} action.quantity Incoming quantity.
|
||||||
|
* @param {string} action.type Type of action.
|
||||||
|
* @param {Object} action.data Incoming payload for action.
|
||||||
*/
|
*/
|
||||||
export const reducer = ( state = DEFAULT_STATE, { quantity, type, data } ) => {
|
export const reducer = ( state = DEFAULT_STATE, { quantity, type, data } ) => {
|
||||||
let newState;
|
let newState;
|
||||||
|
|
|
@ -64,6 +64,11 @@ export const prepareResponseData = ( data ) => {
|
||||||
*
|
*
|
||||||
* @param {Object} state Current state.
|
* @param {Object} state Current state.
|
||||||
* @param {Object} action Incoming action object.
|
* @param {Object} action Incoming action object.
|
||||||
|
* @param {string} action.url URL passed in.
|
||||||
|
* @param {string} action.type Type of action.
|
||||||
|
* @param {string} action.orderId Order ID.
|
||||||
|
* @param {Array} action.orderNotes Order notes.
|
||||||
|
* @param {Object} action.data Other action payload.
|
||||||
*/
|
*/
|
||||||
export const reducer = (
|
export const reducer = (
|
||||||
state = DEFAULT_STATE,
|
state = DEFAULT_STATE,
|
||||||
|
|
|
@ -26,6 +26,11 @@ const hasSavedPaymentToken = ( paymentMethodData ) => {
|
||||||
*
|
*
|
||||||
* @param {Object} state Current state.
|
* @param {Object} state Current state.
|
||||||
* @param {Object} action Current action.
|
* @param {Object} action Current action.
|
||||||
|
* @param {string} action.type Action type.
|
||||||
|
* @param {Object} action.paymentMethodData Payment method data payload.
|
||||||
|
* @param {boolean} action.shouldSavePaymentMethod Should save payment method flag.
|
||||||
|
* @param {string} action.errorMessage Error message to store in state.
|
||||||
|
* @param {Object} action.paymentMethods Registered payment methods.
|
||||||
*/
|
*/
|
||||||
const reducer = (
|
const reducer = (
|
||||||
state = DEFAULT_PAYMENT_DATA,
|
state = DEFAULT_PAYMENT_DATA,
|
||||||
|
|
|
@ -33,6 +33,7 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('@woocommerce/type-defs/contexts').ShippingDataContext} ShippingDataContext
|
* @typedef {import('@woocommerce/type-defs/contexts').ShippingDataContext} ShippingDataContext
|
||||||
|
* @typedef {import('react')} React
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { NONE, INVALID_ADDRESS, UNKNOWN } = ERROR_TYPES;
|
const { NONE, INVALID_ADDRESS, UNKNOWN } = ERROR_TYPES;
|
||||||
|
@ -42,6 +43,7 @@ const { NONE, INVALID_ADDRESS, UNKNOWN } = ERROR_TYPES;
|
||||||
*
|
*
|
||||||
* @param {string} state The current status.
|
* @param {string} state The current status.
|
||||||
* @param {Object} action The incoming action.
|
* @param {Object} action The incoming action.
|
||||||
|
* @param {string} action.type The type of action.
|
||||||
*/
|
*/
|
||||||
const errorStatusReducer = ( state, { type } ) => {
|
const errorStatusReducer = ( state, { type } ) => {
|
||||||
if ( Object.values( ERROR_TYPES ).includes( type ) ) {
|
if ( Object.values( ERROR_TYPES ).includes( type ) ) {
|
||||||
|
@ -77,6 +79,7 @@ const hasInvalidShippingAddress = ( errors ) => {
|
||||||
* checkout/cart.
|
* checkout/cart.
|
||||||
*
|
*
|
||||||
* @param {Object} props Incoming props for provider
|
* @param {Object} props Incoming props for provider
|
||||||
|
* @param {React.ReactElement} props.children
|
||||||
*/
|
*/
|
||||||
export const ShippingDataProvider = ( { children } ) => {
|
export const ShippingDataProvider = ( { children } ) => {
|
||||||
const { dispatchActions } = useCheckoutContext();
|
const { dispatchActions } = useCheckoutContext();
|
||||||
|
|
|
@ -8,6 +8,7 @@ import classNames from 'classnames';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('@woocommerce/type-defs/contexts').ContainerWidthContext} ContainerWidthContext
|
* @typedef {import('@woocommerce/type-defs/contexts').ContainerWidthContext} ContainerWidthContext
|
||||||
|
* @typedef {import('react')} React
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ContainerWidthContext = createContext( {
|
const ContainerWidthContext = createContext( {
|
||||||
|
@ -29,6 +30,10 @@ export const useContainerWidthContext = () => {
|
||||||
/**
|
/**
|
||||||
* Provides an interface to useContainerQueries so children can see what size is being used by the
|
* Provides an interface to useContainerQueries so children can see what size is being used by the
|
||||||
* container.
|
* container.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {React.ReactChildren} props.children React elements wrapped by the component.
|
||||||
|
* @param {string} props.className CSS class in use.
|
||||||
*/
|
*/
|
||||||
export const ContainerWidthContextProvider = ( {
|
export const ContainerWidthContextProvider = ( {
|
||||||
children,
|
children,
|
||||||
|
|
|
@ -32,6 +32,11 @@ export const actions = {
|
||||||
*
|
*
|
||||||
* @param {Object} state Current state.
|
* @param {Object} state Current state.
|
||||||
* @param {Object} action Incoming action object
|
* @param {Object} action Incoming action object
|
||||||
|
* @param {string} action.type The type of action.
|
||||||
|
* @param {string} action.eventType What type of event is emitted.
|
||||||
|
* @param {string} action.id The id for the event.
|
||||||
|
* @param {function(any):any} action.callback The registered callback for the event.
|
||||||
|
* @param {number} action.priority The priority for the event.
|
||||||
*/
|
*/
|
||||||
export const reducer = (
|
export const reducer = (
|
||||||
state = {},
|
state = {},
|
||||||
|
|
|
@ -12,6 +12,7 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef { import('@woocommerce/type-defs/contexts').ValidationContext } ValidationContext
|
* @typedef { import('@woocommerce/type-defs/contexts').ValidationContext } ValidationContext
|
||||||
|
* @typedef {import('react')} React
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ValidationContext = createContext( {
|
const ValidationContext = createContext( {
|
||||||
|
@ -38,6 +39,9 @@ export const useValidationContext = () => {
|
||||||
*
|
*
|
||||||
* Any children of this context will be exposed to validation state and helpers
|
* Any children of this context will be exposed to validation state and helpers
|
||||||
* for tracking validation.
|
* for tracking validation.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {React.ReactChildren} props.children What react elements are wrapped by this component.
|
||||||
*/
|
*/
|
||||||
export const ValidationContextProvider = ( { children } ) => {
|
export const ValidationContextProvider = ( { children } ) => {
|
||||||
const [ validationErrors, updateValidationErrors ] = useState( {} );
|
const [ validationErrors, updateValidationErrors ] = useState( {} );
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('@woocommerce/type-defs/contexts').NoticeContext} NoticeContext
|
* @typedef {import('@woocommerce/type-defs/contexts').NoticeContext} NoticeContext
|
||||||
|
* @typedef {import('react')} React
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const StoreNoticesContext = createContext( {
|
const StoreNoticesContext = createContext( {
|
||||||
|
@ -45,6 +46,12 @@ export const useStoreNoticesContext = () => {
|
||||||
* - Warning
|
* - Warning
|
||||||
* - Info
|
* - Info
|
||||||
* - Success
|
* - Success
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {React.ReactChildren} props.children The Elements wrapped by this component.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {boolean} props.createNoticeContainer Whether to create a notice container or not.
|
||||||
|
* @param {string} props.context The notice context for notices being rendered.
|
||||||
*/
|
*/
|
||||||
export const StoreNoticesProvider = ( {
|
export const StoreNoticesProvider = ( {
|
||||||
children,
|
children,
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
import { useRef, useLayoutEffect, useState } from '@wordpress/element';
|
import { useRef, useLayoutEffect, useState } from '@wordpress/element';
|
||||||
import { getIntersectionObserver } from '@woocommerce/base-utils';
|
import { getIntersectionObserver } from '@woocommerce/base-utils';
|
||||||
|
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
/** @type {React.CSSProperties} */
|
/** @type {React.CSSProperties} */
|
||||||
const style = {
|
const style = {
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
* shipping, so we can track when one of them change to update rates.
|
* shipping, so we can track when one of them change to update rates.
|
||||||
*
|
*
|
||||||
* @param {Object} address An object containing all address information
|
* @param {Object} address An object containing all address information
|
||||||
|
* @param {string} address.country The country.
|
||||||
|
* @param {string} address.state The state.
|
||||||
|
* @param {string} address.city The city.
|
||||||
|
* @param {string} address.postcode The postal code.
|
||||||
*
|
*
|
||||||
* @return {Object} pluckedAddress An object containing shipping address that are needed to fetch an address.
|
* @return {Object} pluckedAddress An object containing shipping address that are needed to fetch an address.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/** @typedef {import('window').IntersectionObserverCallback} IntersectionObserverCallback */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Util that returns an IntersectionObserver if supported by the browser. If
|
* Util that returns an IntersectionObserver if supported by the browser. If
|
||||||
* it's not supported, it returns a shim object with the methods to prevent JS
|
* it's not supported, it returns a shim object with the methods to prevent JS
|
||||||
|
@ -6,8 +8,8 @@
|
||||||
*
|
*
|
||||||
* @param {IntersectionObserverCallback} callback Callback function for the
|
* @param {IntersectionObserverCallback} callback Callback function for the
|
||||||
* Intersection Observer.
|
* Intersection Observer.
|
||||||
* @param {object} options Intersection Observer options.
|
* @param {Object} options Intersection Observer options.
|
||||||
* @return {object|IntersectionObserver} Intersection Observer if available,
|
* @return {Object|IntersectionObserver} Intersection Observer if available,
|
||||||
* otherwise a shim object.
|
* otherwise a shim object.
|
||||||
*
|
*
|
||||||
* @todo Remove IntersectionObserver shim when we drop IE11 support.
|
* @todo Remove IntersectionObserver shim when we drop IE11 support.
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
const Event = window.Event || null;
|
const Event = window.Event || null;
|
||||||
|
|
||||||
|
/** @typedef {import('window').HTMLNode} HTMLNode */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper function to dispatch an event so it's compatible with IE11.
|
* Wrapper function to dispatch an event so it's compatible with IE11.
|
||||||
*
|
*
|
||||||
|
@ -48,7 +50,7 @@ export const triggerFragmentRefresh = () => {
|
||||||
* @param {boolean} bubbles Whether the event bubbles.
|
* @param {boolean} bubbles Whether the event bubbles.
|
||||||
* @param {boolean} cancelable Whether the event is cancelable.
|
* @param {boolean} cancelable Whether the event is cancelable.
|
||||||
*
|
*
|
||||||
* @returns {Function} Function to remove the jQuery event handler. Ideally it
|
* @return {Function} Function to remove the jQuery event handler. Ideally it
|
||||||
* should be used when the component is unmounted.
|
* should be used when the component is unmounted.
|
||||||
*/
|
*/
|
||||||
export const translateJQueryEventToNative = (
|
export const translateJQueryEventToNative = (
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { registeredBlockComponents } from './registered-block-components-init';
|
||||||
*
|
*
|
||||||
* This gets all registered Block Components so we know which Blocks map to which React Components.
|
* This gets all registered Block Components so we know which Blocks map to which React Components.
|
||||||
*
|
*
|
||||||
* @export
|
|
||||||
* @param {string} context Current context (a named parent Block). If Block Components were only
|
* @param {string} context Current context (a named parent Block). If Block Components were only
|
||||||
* registered under a certain context, those Components will be returned,
|
* registered under a certain context, those Components will be returned,
|
||||||
* as well as any Components registered under all contexts.
|
* as well as any Components registered under all contexts.
|
||||||
|
@ -38,7 +37,6 @@ export function getRegisteredBlockComponents( context ) {
|
||||||
/**
|
/**
|
||||||
* Alias of getRegisteredBlockComponents kept for backwards compatibility.
|
* Alias of getRegisteredBlockComponents kept for backwards compatibility.
|
||||||
*
|
*
|
||||||
* @export
|
|
||||||
* @param {string} main Name of the parent block to retrieve children of.
|
* @param {string} main Name of the parent block to retrieve children of.
|
||||||
* @return {Object} List of registered inner blocks.
|
* @return {Object} List of registered inner blocks.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,7 +17,6 @@ import { registeredBlockComponents } from './registered-block-components-init';
|
||||||
* Registering a Block Component allows you to define which React Component should be used in place
|
* Registering a Block Component allows you to define which React Component should be used in place
|
||||||
* of a registered Block. The Component, when rendered, will be passed all Block Attributes.
|
* of a registered Block. The Component, when rendered, will be passed all Block Attributes.
|
||||||
*
|
*
|
||||||
* @export
|
|
||||||
* @param {Object} options Options to use when registering the block.
|
* @param {Object} options Options to use when registering the block.
|
||||||
* @param {Function} options.component React component that will be rendered, or the return value from React.lazy if
|
* @param {Function} options.component React component that will be rendered, or the return value from React.lazy if
|
||||||
* dynamically imported.
|
* dynamically imported.
|
||||||
|
@ -87,7 +86,6 @@ const assertOption = ( options, optionName, expectedType ) => {
|
||||||
/**
|
/**
|
||||||
* Alias of registerBlockComponent kept for backwards compatibility.
|
* Alias of registerBlockComponent kept for backwards compatibility.
|
||||||
*
|
*
|
||||||
* @export
|
|
||||||
* @param {Object} options Options to use when registering the block.
|
* @param {Object} options Options to use when registering the block.
|
||||||
* @param {string} options.main Name of the parent block.
|
* @param {string} options.main Name of the parent block.
|
||||||
* @param {string} options.blockName Name of the child block being registered.
|
* @param {string} options.blockName Name of the child block being registered.
|
||||||
|
|
|
@ -13,6 +13,12 @@ import { removeAttributeFilterBySlug } from '../../utils/attributes-query';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that renders active attribute (terms) filters.
|
* Component that renders active attribute (terms) filters.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributeObject The attribute object.
|
||||||
|
* @param {Array} props.slugs The slugs for attributes.
|
||||||
|
* @param {string} props.operator The operator for the filter.
|
||||||
|
* @param {string} props.displayStyle The style used for displaying the filters.
|
||||||
*/
|
*/
|
||||||
const ActiveAttributeFilters = ( {
|
const ActiveAttributeFilters = ( {
|
||||||
attributeObject = {},
|
attributeObject = {},
|
||||||
|
|
|
@ -18,6 +18,10 @@ import ActiveAttributeFilters from './active-attribute-filters';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component displaying active filters.
|
* Component displaying active filters.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming attributes for the block.
|
||||||
|
* @param {boolean} props.isEditor Whether or not in the editor context.
|
||||||
*/
|
*/
|
||||||
const ActiveFiltersBlock = ( {
|
const ActiveFiltersBlock = ( {
|
||||||
attributes: blockAttributes,
|
attributes: blockAttributes,
|
||||||
|
|
|
@ -45,9 +45,7 @@ registerBlockType( 'woocommerce/active-filters', {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
edit,
|
edit,
|
||||||
/**
|
// Save the props to post content.
|
||||||
* Save the props to post content.
|
|
||||||
*/
|
|
||||||
save( { attributes } ) {
|
save( { attributes } ) {
|
||||||
const { className, displayStyle, heading, headingLevel } = attributes;
|
const { className, displayStyle, heading, headingLevel } = attributes;
|
||||||
const data = {
|
const data = {
|
||||||
|
|
|
@ -34,6 +34,10 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component displaying an attribute filter.
|
* Component displaying an attribute filter.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {boolean} props.isEditor
|
||||||
*/
|
*/
|
||||||
const AttributeFilterBlock = ( {
|
const AttributeFilterBlock = ( {
|
||||||
attributes: blockAttributes,
|
attributes: blockAttributes,
|
||||||
|
|
|
@ -72,9 +72,7 @@ registerBlockType( 'woocommerce/attribute-filter', {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
edit,
|
edit,
|
||||||
/**
|
// Save the props to post content.
|
||||||
* Save the props to post content.
|
|
||||||
*/
|
|
||||||
save( { attributes } ) {
|
save( { attributes } ) {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -7,6 +7,10 @@ import Label from '@woocommerce/base-components/label';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The label for an attribute term filter.
|
* The label for an attribute term filter.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.name The name for the label.
|
||||||
|
* @param {number} props.count The count of products this attribute is attached to.
|
||||||
*/
|
*/
|
||||||
const AttributeFilterLabel = ( { name, count } ) => {
|
const AttributeFilterLabel = ( { name, count } ) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -28,6 +28,9 @@ const getIconsFromPaymentMethods = ( paymentMethods ) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkout button rendered in the full cart page.
|
* Checkout button rendered in the full cart page.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.link What the button is linked to.
|
||||||
*/
|
*/
|
||||||
const CheckoutButton = ( { link } ) => {
|
const CheckoutButton = ( { link } ) => {
|
||||||
const { isCalculating } = useCheckoutContext();
|
const { isCalculating } = useCheckoutContext();
|
||||||
|
|
|
@ -161,6 +161,11 @@ const BlockSettings = ( { attributes, setAttributes } ) => {
|
||||||
* if the user saves the page without having triggered the 'Empty Cart'
|
* if the user saves the page without having triggered the 'Empty Cart'
|
||||||
* view, inner blocks would not be saved and they wouldn't be visible
|
* view, inner blocks would not be saved and they wouldn't be visible
|
||||||
* in the frontend.
|
* in the frontend.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className CSS class used.
|
||||||
|
* @param {Object} props.attributes Attributes available.
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for attributes.
|
||||||
*/
|
*/
|
||||||
const CartEditor = ( { className, attributes, setAttributes } ) => {
|
const CartEditor = ( { className, attributes, setAttributes } ) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -14,6 +14,9 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode for the Cart block when cart is empty.
|
* Component to handle edit mode for the Cart block when cart is empty.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {boolean} props.hidden Whether this component is hidden or not.
|
||||||
*/
|
*/
|
||||||
const EmptyCartEdit = ( { hidden = false } ) => {
|
const EmptyCartEdit = ( { hidden = false } ) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -46,6 +46,9 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that renders the Cart block when user has something in cart aka "full".
|
* Component that renders the Cart block when user has something in cart aka "full".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming attributes for block.
|
||||||
*/
|
*/
|
||||||
const Cart = ( { attributes } ) => {
|
const Cart = ( { attributes } ) => {
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -38,9 +38,7 @@ const settings = {
|
||||||
attributes: blockAttributes,
|
attributes: blockAttributes,
|
||||||
edit,
|
edit,
|
||||||
|
|
||||||
/**
|
// Save the props to post content.
|
||||||
* Save the props to post content.
|
|
||||||
*/
|
|
||||||
save( { attributes } ) {
|
save( { attributes } ) {
|
||||||
return (
|
return (
|
||||||
<div className={ classnames( 'is-loading', attributes.className ) }>
|
<div className={ classnames( 'is-loading', attributes.className ) }>
|
||||||
|
|
|
@ -53,7 +53,8 @@ const Block = ( props ) => {
|
||||||
* Main Checkout Component.
|
* Main Checkout Component.
|
||||||
*
|
*
|
||||||
* @param {Object} props Component props.
|
* @param {Object} props Component props.
|
||||||
* @return {*} The component.
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.scrollToTop Function for scrolling to top.
|
||||||
*/
|
*/
|
||||||
const Checkout = ( { attributes, scrollToTop } ) => {
|
const Checkout = ( { attributes, scrollToTop } ) => {
|
||||||
const { isEditor } = useEditorContext();
|
const { isEditor } = useEditorContext();
|
||||||
|
|
|
@ -63,7 +63,8 @@ const CheckoutOrderError = () => {
|
||||||
/**
|
/**
|
||||||
* Get the error message to display.
|
* Get the error message to display.
|
||||||
*
|
*
|
||||||
* @param {Object} errorData Object containing code and message.
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.errorData Object containing code and message.
|
||||||
*/
|
*/
|
||||||
const ErrorTitle = ( { errorData } ) => {
|
const ErrorTitle = ( { errorData } ) => {
|
||||||
let heading = __( 'Checkout error', 'woo-gutenberg-products-block' );
|
let heading = __( 'Checkout error', 'woo-gutenberg-products-block' );
|
||||||
|
@ -83,7 +84,8 @@ const ErrorTitle = ( { errorData } ) => {
|
||||||
/**
|
/**
|
||||||
* Get the error message to display.
|
* Get the error message to display.
|
||||||
*
|
*
|
||||||
* @param {Object} errorData Object containing code and message.
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.errorData Object containing code and message.
|
||||||
*/
|
*/
|
||||||
const ErrorMessage = ( { errorData } ) => {
|
const ErrorMessage = ( { errorData } ) => {
|
||||||
let message = errorData.message;
|
let message = errorData.message;
|
||||||
|
@ -104,7 +106,8 @@ const ErrorMessage = ( { errorData } ) => {
|
||||||
/**
|
/**
|
||||||
* Get the CTA button to display.
|
* Get the CTA button to display.
|
||||||
*
|
*
|
||||||
* @param {Object} errorData Object containing code and message.
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.errorData Object containing code and message.
|
||||||
*/
|
*/
|
||||||
const ErrorButton = ( { errorData } ) => {
|
const ErrorButton = ( { errorData } ) => {
|
||||||
let buttonText = __( 'Retry', 'woo-gutenberg-products-block' );
|
let buttonText = __( 'Retry', 'woo-gutenberg-products-block' );
|
||||||
|
|
|
@ -37,9 +37,8 @@ const settings = {
|
||||||
},
|
},
|
||||||
attributes: blockAttributes,
|
attributes: blockAttributes,
|
||||||
edit,
|
edit,
|
||||||
/**
|
|
||||||
* Save the props to post content.
|
//Save the props to post content.
|
||||||
*/
|
|
||||||
save( { attributes } ) {
|
save( { attributes } ) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -48,6 +48,18 @@ import { withCategory } from '../../hocs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of "Featured Category".
|
* Component to handle edit mode of "Featured Category".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {boolean} props.isSelected Whether block is selected or not.
|
||||||
|
* @param {function(any):any} props.setAttributes Function for setting new attributes.
|
||||||
|
* @param {string} props.error Error message
|
||||||
|
* @param {function(any):any} props.getCategory Function for getting category details.
|
||||||
|
* @param {boolean} props.isLoading Whether loading or not.
|
||||||
|
* @param {Object} props.category The product category object.
|
||||||
|
* @param {Object} props.overlayColor Overlay color object for content.
|
||||||
|
* @param {function(any):any} props.setOverlayColor Setter for overlay color.
|
||||||
|
* @param {function(any):any} props.debouncedSpeak Function for delayed speak.
|
||||||
*/
|
*/
|
||||||
const FeaturedCategory = ( {
|
const FeaturedCategory = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -49,6 +49,19 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of "Featured Product".
|
* Component to handle edit mode of "Featured Product".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.debouncedSpeak Function for delayed speak.
|
||||||
|
* @param {string} props.error Error message.
|
||||||
|
* @param {function(any):any} props.getProduct Function for getting the product.
|
||||||
|
* @param {boolean} props.isLoading Whether product is loading or not.
|
||||||
|
* @param {boolean} props.isSelected Whether block is selected or not.
|
||||||
|
* @param {Object} props.overlayColor Overlay color object.
|
||||||
|
* @param {Object} props.product Product object.
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for attributes.
|
||||||
|
* @param {function(any):any} props.setOverlayColor Setter for overlay color.
|
||||||
|
* @param {function(any):any} props.triggerUrlUpdate Function for triggering a url update for product.
|
||||||
*/
|
*/
|
||||||
const FeaturedProduct = ( {
|
const FeaturedProduct = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -21,6 +21,8 @@ import usePriceConstraints from './use-price-constraints.js';
|
||||||
* Component displaying a price filter.
|
* Component displaying a price filter.
|
||||||
*
|
*
|
||||||
* @param {Object} props Component props.
|
* @param {Object} props Component props.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {boolean} props.isEditor Whether in editor context or not.
|
||||||
*/
|
*/
|
||||||
const PriceFilterBlock = ( { attributes, isEditor = false } ) => {
|
const PriceFilterBlock = ( { attributes, isEditor = false } ) => {
|
||||||
const [ minPriceQuery, setMinPriceQuery ] = useQueryStateByKey(
|
const [ minPriceQuery, setMinPriceQuery ] = useQueryStateByKey(
|
||||||
|
|
|
@ -49,9 +49,7 @@ registerBlockType( 'woocommerce/price-filter', {
|
||||||
|
|
||||||
edit,
|
edit,
|
||||||
|
|
||||||
/**
|
// Save the props to post content.
|
||||||
* Save the props to post content.
|
|
||||||
*/
|
|
||||||
save( { attributes } ) {
|
save( { attributes } ) {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -28,6 +28,11 @@ const EmptyPlaceholder = () => (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component displaying the categories as dropdown or list.
|
* Component displaying the categories as dropdown or list.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
|
* @param {string} props.name Name for block.
|
||||||
*/
|
*/
|
||||||
const ProductCategoriesBlock = ( { attributes, setAttributes, name } ) => {
|
const ProductCategoriesBlock = ( { attributes, setAttributes, name } ) => {
|
||||||
const getInspectorControls = () => {
|
const getInspectorControls = () => {
|
||||||
|
|
|
@ -14,6 +14,15 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component displaying a product search form.
|
* Component displaying a product search form.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {string} props.attributes.label
|
||||||
|
* @param {string} props.attributes.placeholder
|
||||||
|
* @param {string} props.attributes.formId
|
||||||
|
* @param {string} props.attributes.className
|
||||||
|
* @param {boolean} props.attributes.hasLabel
|
||||||
|
* @param {string} props.attributes.align
|
||||||
*/
|
*/
|
||||||
const ProductSearchBlock = ( {
|
const ProductSearchBlock = ( {
|
||||||
attributes: { label, placeholder, formId, className, hasLabel, align },
|
attributes: { label, placeholder, formId, className, hasLabel, align },
|
||||||
|
|
|
@ -16,6 +16,17 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component displaying a product search form.
|
* Component displaying a product search form.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {string} props.attributes.label
|
||||||
|
* @param {string} props.attributes.placeholder
|
||||||
|
* @param {string} props.attributes.formId
|
||||||
|
* @param {string} props.attributes.className
|
||||||
|
* @param {boolean} props.attributes.hasLabel
|
||||||
|
* @param {string} props.attributes.align
|
||||||
|
* @param {string} props.instanceId
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
*/
|
*/
|
||||||
const Edit = ( {
|
const Edit = ( {
|
||||||
attributes: { label, placeholder, formId, className, hasLabel, align },
|
attributes: { label, placeholder, formId, className, hasLabel, align },
|
||||||
|
|
|
@ -46,11 +46,7 @@ const blockSettings = {
|
||||||
edit( props ) {
|
edit( props ) {
|
||||||
return <Editor { ...props } />;
|
return <Editor { ...props } />;
|
||||||
},
|
},
|
||||||
/**
|
// Save the props to post content.
|
||||||
* Save the props to post content.
|
|
||||||
*
|
|
||||||
* @param {Object} attributes Attributes to save.
|
|
||||||
*/
|
|
||||||
save( { attributes } ) {
|
save( { attributes } ) {
|
||||||
const dataAttributes = {};
|
const dataAttributes = {};
|
||||||
Object.keys( attributes )
|
Object.keys( attributes )
|
||||||
|
|
|
@ -20,6 +20,10 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of "All Reviews".
|
* Component to handle edit mode of "All Reviews".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
*/
|
*/
|
||||||
const AllReviewsEditor = ( { attributes, setAttributes } ) => {
|
const AllReviewsEditor = ( { attributes, setAttributes } ) => {
|
||||||
const getInspectorControls = () => {
|
const getInspectorControls = () => {
|
||||||
|
|
|
@ -14,6 +14,13 @@ import withReviews from '@woocommerce/base-hocs/with-reviews';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block rendered in the frontend.
|
* Block rendered in the frontend.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.onAppendReviews Function called when appending review.
|
||||||
|
* @param {function(any):any} props.onChangeOrderby
|
||||||
|
* @param {Array} props.reviews
|
||||||
|
* @param {number} props.totalReviews
|
||||||
*/
|
*/
|
||||||
const FrontendBlock = ( {
|
const FrontendBlock = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -29,6 +29,11 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of "Reviews by Category".
|
* Component to handle edit mode of "Reviews by Category".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.debouncedSpeak
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
*/
|
*/
|
||||||
const ReviewsByCategoryEditor = ( {
|
const ReviewsByCategoryEditor = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -28,6 +28,11 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of "Reviews by Product".
|
* Component to handle edit mode of "Reviews by Product".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.debouncedSpeak
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
*/
|
*/
|
||||||
const ReviewsByProductEditor = ( {
|
const ReviewsByProductEditor = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -13,8 +13,15 @@ import { StoreNoticesProvider } from '@woocommerce/base-context';
|
||||||
*/
|
*/
|
||||||
import { BLOCK_NAME } from './constants';
|
import { BLOCK_NAME } from './constants';
|
||||||
|
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Single Product Block.
|
* The Single Product Block.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {boolean} props.isLoading
|
||||||
|
* @param {Object} props.product
|
||||||
|
* @param {React.ReactChildren} props.children
|
||||||
*/
|
*/
|
||||||
const Block = ( { isLoading, product, children } ) => {
|
const Block = ( { isLoading, product, children } ) => {
|
||||||
const className = 'wc-block-single-product wc-block-layout';
|
const className = 'wc-block-single-product wc-block-layout';
|
||||||
|
|
|
@ -5,6 +5,11 @@ import ErrorPlaceholder from '@woocommerce/editor-components/error-placeholder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shown when there is an API error getting a product.
|
* Shown when there is an API error getting a product.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.error
|
||||||
|
* @param {boolean} props.isLoading
|
||||||
|
* @param {function(any):any} props.getProduct
|
||||||
*/
|
*/
|
||||||
const ApiError = ( { error, isLoading, getProduct } ) => (
|
const ApiError = ( { error, isLoading, getProduct } ) => (
|
||||||
<ErrorPlaceholder
|
<ErrorPlaceholder
|
||||||
|
|
|
@ -7,6 +7,10 @@ import { Toolbar } from '@wordpress/components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds controls to the editor toolbar.
|
* Adds controls to the editor toolbar.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {boolean} props.isEditing
|
||||||
|
* @param {function(boolean):any} props.setIsEditing
|
||||||
*/
|
*/
|
||||||
const EditorBlockControls = ( { isEditing, setIsEditing } ) => {
|
const EditorBlockControls = ( { isEditing, setIsEditing } ) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -22,6 +22,16 @@ import { BLOCK_TITLE, BLOCK_ICON, BLOCK_DESCRIPTION } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of the "Single Product Block".
|
* Component to handle edit mode of the "Single Product Block".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.className
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
|
* @param {string} props.error
|
||||||
|
* @param {function(any):any} props.getProduct
|
||||||
|
* @param {Object} props.product
|
||||||
|
* @param {boolean} props.isLoading
|
||||||
|
* @param {string} props.clientId
|
||||||
*/
|
*/
|
||||||
const Editor = ( {
|
const Editor = ( {
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -24,6 +24,11 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle edit mode of the "Single Product Block".
|
* Component to handle edit mode of the "Single Product Block".
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {boolean} props.isLoading
|
||||||
|
* @param {Object} props.product
|
||||||
|
* @param {string} props.clientId
|
||||||
*/
|
*/
|
||||||
const LayoutEditor = ( { isLoading, product, clientId } ) => {
|
const LayoutEditor = ( { isLoading, product, clientId } ) => {
|
||||||
const baseClassName = 'wc-block-single-product wc-block-layout';
|
const baseClassName = 'wc-block-single-product wc-block-layout';
|
||||||
|
|
|
@ -5,6 +5,10 @@ import ProductControl from '@woocommerce/editor-components/product-control';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows a product to be selected for display.
|
* Allows a product to be selected for display.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {Object} props.attributes Incoming block attributes.
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
*/
|
*/
|
||||||
const SharedProductControl = ( { attributes, setAttributes } ) => (
|
const SharedProductControl = ( { attributes, setAttributes } ) => (
|
||||||
<ProductControl
|
<ProductControl
|
||||||
|
|
|
@ -12,6 +12,10 @@ import './style.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to render a Feedback prompt in the sidebar.
|
* Component to render a Feedback prompt in the sidebar.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.text
|
||||||
|
* @param {string} props.url
|
||||||
*/
|
*/
|
||||||
const FeedbackPrompt = ( {
|
const FeedbackPrompt = ( {
|
||||||
text,
|
text,
|
||||||
|
|
|
@ -8,6 +8,10 @@ import { ToggleControl } from '@wordpress/components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A combination of toggle controls for content visibility in product grids.
|
* A combination of toggle controls for content visibility in product grids.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {function(any):any} props.onChange
|
||||||
|
* @param {Object} props.settings
|
||||||
*/
|
*/
|
||||||
const GridContentControl = ( { onChange, settings } ) => {
|
const GridContentControl = ( { onChange, settings } ) => {
|
||||||
const { button, price, rating, title } = settings;
|
const { button, price, rating, title } = settings;
|
||||||
|
|
|
@ -15,6 +15,12 @@ import {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A combination of range controls for product grid layout settings.
|
* A combination of range controls for product grid layout settings.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {number} props.columns
|
||||||
|
* @param {number} props.rows
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
|
* @param {string} props.alignButtons
|
||||||
*/
|
*/
|
||||||
const GridLayoutControl = ( {
|
const GridLayoutControl = ( {
|
||||||
columns,
|
columns,
|
||||||
|
|
|
@ -7,6 +7,10 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pre-configured SelectControl for product orderby settings.
|
* A pre-configured SelectControl for product orderby settings.
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {string} props.value
|
||||||
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||||
*/
|
*/
|
||||||
const ProductOrderbyControl = ( { value, setAttributes } ) => {
|
const ProductOrderbyControl = ( { value, setAttributes } ) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -12,6 +12,7 @@ import ErrorMessage from '@woocommerce/editor-components/error-placeholder/error
|
||||||
* products.
|
* products.
|
||||||
*
|
*
|
||||||
* @param {Object} props Component props.
|
* @param {Object} props Component props.
|
||||||
|
* @param {string} props.error
|
||||||
* @param {Function} props.onChange Callback fired when the selected item changes
|
* @param {Function} props.onChange Callback fired when the selected item changes
|
||||||
* @param {Function} props.onSearch Callback fired when a search is triggered
|
* @param {Function} props.onSearch Callback fired when a search is triggered
|
||||||
* @param {Array} props.selected An array of selected products.
|
* @param {Array} props.selected An array of selected products.
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { IS_LARGE_CATALOG, LIMIT_TAGS } from '@woocommerce/block-settings';
|
||||||
* Get product query requests for the Store API.
|
* Get product query requests for the Store API.
|
||||||
*
|
*
|
||||||
* @param {Object} request A query object with the list of selected products and search term.
|
* @param {Object} request A query object with the list of selected products and search term.
|
||||||
* @param {string} request.selected Currently selected products.
|
* @param {Array} request.selected Currently selected products.
|
||||||
* @param {string} request.search Search string.
|
* @param {string} request.search Search string.
|
||||||
* @param {Array} request.queryArgs Query args to pass in.
|
* @param {Array} request.queryArgs Query args to pass in.
|
||||||
*/
|
*/
|
||||||
|
@ -47,7 +47,7 @@ const getProductsRequests = ( {
|
||||||
* Get a promise that resolves to a list of products from the Store API.
|
* Get a promise that resolves to a list of products from the Store API.
|
||||||
*
|
*
|
||||||
* @param {Object} request A query object with the list of selected products and search term.
|
* @param {Object} request A query object with the list of selected products and search term.
|
||||||
* @param {string} request.selected Currently selected products.
|
* @param {Array} request.selected Currently selected products.
|
||||||
* @param {string} request.search Search string.
|
* @param {string} request.search Search string.
|
||||||
* @param {Array} request.queryArgs Query args to pass in.
|
* @param {Array} request.queryArgs Query args to pass in.
|
||||||
*/
|
*/
|
||||||
|
@ -107,7 +107,7 @@ export const getTerms = ( attribute ) => {
|
||||||
* Get product tag query requests for the Store API.
|
* Get product tag query requests for the Store API.
|
||||||
*
|
*
|
||||||
* @param {Object} request A query object with the list of selected products and search term.
|
* @param {Object} request A query object with the list of selected products and search term.
|
||||||
* @param {string} request.selected Currently selected tags.
|
* @param {Array} request.selected Currently selected tags.
|
||||||
* @param {string} request.search Search string.
|
* @param {string} request.search Search string.
|
||||||
*/
|
*/
|
||||||
const getProductTagsRequests = ( { selected = [], search } ) => {
|
const getProductTagsRequests = ( { selected = [], search } ) => {
|
||||||
|
@ -135,7 +135,9 @@ const getProductTagsRequests = ( { selected = [], search } ) => {
|
||||||
/**
|
/**
|
||||||
* Get a promise that resolves to a list of tags from the Store API.
|
* Get a promise that resolves to a list of tags from the Store API.
|
||||||
*
|
*
|
||||||
* @param {Object} - A query object with the list of selected products and search term.
|
* @param {Object} props A query object with the list of selected products and search term.
|
||||||
|
* @param {Array} props.selected
|
||||||
|
* @param {string} props.search
|
||||||
*/
|
*/
|
||||||
export const getProductTags = ( { selected = [], search } ) => {
|
export const getProductTags = ( { selected = [], search } ) => {
|
||||||
const requests = getProductTagsRequests( { selected, search } );
|
const requests = getProductTagsRequests( { selected, search } );
|
||||||
|
|
|
@ -39,8 +39,11 @@ const Label = ( props ) => {
|
||||||
/**
|
/**
|
||||||
* Determine whether COD is available for this cart/order.
|
* Determine whether COD is available for this cart/order.
|
||||||
*
|
*
|
||||||
* @param boolean cartNeedsShipping True if the cart contains any physical/shippable products.
|
* @param {Object} props Incoming props for the component.
|
||||||
* @return boolean True if COD payment method should be displayed as a payment option.
|
* @param {boolean} props.cartNeedsShipping True if the cart contains any physical/shippable products.
|
||||||
|
* @param {boolean} props.selectedShippingMethods
|
||||||
|
*
|
||||||
|
* @return {boolean} True if COD payment method should be displayed as a payment option.
|
||||||
*/
|
*/
|
||||||
const canMakePayment = ( { cartNeedsShipping, selectedShippingMethods } ) => {
|
const canMakePayment = ( { cartNeedsShipping, selectedShippingMethods } ) => {
|
||||||
if ( ! settings.enableForVirtual && ! cartNeedsShipping ) {
|
if ( ! settings.enableForVirtual && ! cartNeedsShipping ) {
|
||||||
|
|
|
@ -15,10 +15,16 @@ import {
|
||||||
*/
|
*/
|
||||||
import { useElementOptions } from './use-element-options';
|
import { useElementOptions } from './use-element-options';
|
||||||
|
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
const baseTextInputStyles = 'wc-block-gateway-input';
|
const baseTextInputStyles = 'wc-block-gateway-input';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* InlineCard component
|
* InlineCard component
|
||||||
|
*
|
||||||
|
* @param {Object} props Incoming props for the component.
|
||||||
|
* @param {React.ReactElement} props.inputErrorComponent
|
||||||
|
* @param {function(any):any} props.onChange
|
||||||
*/
|
*/
|
||||||
export const InlineCard = ( {
|
export const InlineCard = ( {
|
||||||
inputErrorComponent: ValidationInputError,
|
inputErrorComponent: ValidationInputError,
|
||||||
|
@ -62,6 +68,10 @@ export const InlineCard = ( {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CardElements component.
|
* CardElements component.
|
||||||
|
*
|
||||||
|
* @param {Object} props
|
||||||
|
* @param {function(any):any} props.onChange
|
||||||
|
* @param {React.ReactElement} props.inputErrorComponent
|
||||||
*/
|
*/
|
||||||
export const CardElements = ( {
|
export const CardElements = ( {
|
||||||
onChange,
|
onChange,
|
||||||
|
|
|
@ -265,6 +265,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Stripe Stripe api object.
|
* @typedef {Object} Stripe Stripe api object.
|
||||||
|
* @property {any} api Various api properties
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,6 +275,8 @@
|
||||||
* @property {string} alt Alt text for icon.
|
* @property {string} alt Alt text for icon.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
// [k:string]:CreditCardIcon triggers the above rule even though VSCode interprets it fine.
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} StripeServerData
|
* @typedef {Object} StripeServerData
|
||||||
*
|
*
|
||||||
|
@ -299,6 +302,7 @@
|
||||||
* @property {boolean} allowPaymentRequest True if merchant has enabled payment
|
* @property {boolean} allowPaymentRequest True if merchant has enabled payment
|
||||||
* request (Chrome/Apple Pay).
|
* request (Chrome/Apple Pay).
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable jsdoc/valid-types */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} StripeElementOptions
|
* @typedef {Object} StripeElementOptions
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { errorTypes, errorCodes } from './constants';
|
||||||
/**
|
/**
|
||||||
* Stripe data comes form the server passed on a global object.
|
* Stripe data comes form the server passed on a global object.
|
||||||
*
|
*
|
||||||
* @return {StripeServerData}
|
* @return {StripeServerData} Stripe server data.
|
||||||
*/
|
*/
|
||||||
const getStripeServerData = () => {
|
const getStripeServerData = () => {
|
||||||
const stripeServerData = getSetting( 'stripe_data', null );
|
const stripeServerData = getSetting( 'stripe_data', null );
|
||||||
|
@ -253,6 +253,10 @@ const getErrorMessageForTypeAndCode = ( type, code = '' ) => {
|
||||||
* shipping, so we can track when one of them change to update rates.
|
* shipping, so we can track when one of them change to update rates.
|
||||||
*
|
*
|
||||||
* @param {Object} address An object containing all address information
|
* @param {Object} address An object containing all address information
|
||||||
|
* @param {string} address.country
|
||||||
|
* @param {string} address.state
|
||||||
|
* @param {string} address.city
|
||||||
|
* @param {string} address.postcode
|
||||||
*
|
*
|
||||||
* @return {Object} pluckedAddress An object containing shipping address that are needed to fetch an address.
|
* @return {Object} pluckedAddress An object containing shipping address that are needed to fetch an address.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { allSettings } from './settings-init';
|
||||||
/**
|
/**
|
||||||
* Retrieves a setting value from the setting state.
|
* Retrieves a setting value from the setting state.
|
||||||
*
|
*
|
||||||
* @export
|
|
||||||
* @param {string} name The identifier for the setting.
|
* @param {string} name The identifier for the setting.
|
||||||
* @param {*} [fallback=false] The value to use as a fallback
|
* @param {*} [fallback=false] The value to use as a fallback
|
||||||
* if the setting is not in the
|
* if the setting is not in the
|
||||||
|
|
|
@ -11,7 +11,6 @@ import deprecated from '@wordpress/deprecated';
|
||||||
/**
|
/**
|
||||||
* Sets a value to a property on the settings state.
|
* Sets a value to a property on the settings state.
|
||||||
*
|
*
|
||||||
* @export
|
|
||||||
* @param {string} name The setting property key for the
|
* @param {string} name The setting property key for the
|
||||||
* setting being mutated.
|
* setting being mutated.
|
||||||
* @param {*} value The value to set.
|
* @param {*} value The value to set.
|
||||||
|
|
|
@ -115,17 +115,18 @@
|
||||||
* CustomerPaymentMethod objects.
|
* CustomerPaymentMethod objects.
|
||||||
*
|
*
|
||||||
* @typedef {Object} SavedCustomerPaymentMethods
|
* @typedef {Object} SavedCustomerPaymentMethods
|
||||||
|
* @property {any} any Various payment methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PaymentStatusDispatchers
|
* @typedef {Object} PaymentStatusDispatchers
|
||||||
*
|
*
|
||||||
* @property {function()} started
|
* @property {function()} started Sets started status.
|
||||||
* @property {function()} processing
|
* @property {function()} processing Sets processing status.
|
||||||
* @property {function()} completed
|
* @property {function()} completed Sets complete status.
|
||||||
* @property {function(string)} error
|
* @property {function(string)} error Sets error status.
|
||||||
* @property {function(string, Object, Object=)} failed
|
* @property {function(string, Object, Object=)} failed Sets failed status.
|
||||||
* @property {function(Object=,Object=,Object=)} success
|
* @property {function(Object=,Object=,Object=)} success Sets success status.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
* being loaded.
|
* being loaded.
|
||||||
* @property {boolean} hasShippingAddress Whether or not the cart
|
* @property {boolean} hasShippingAddress Whether or not the cart
|
||||||
* has a shipping address yet.
|
* has a shipping address yet.
|
||||||
* @property {function} receiveCart Dispatcher to receive
|
* @property {function(Object):any} receiveCart Dispatcher to receive
|
||||||
* updated cart.
|
* updated cart.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@
|
||||||
* @property {string} EXPRESS_PAYMENTS Notices for the express payments step.
|
* @property {string} EXPRESS_PAYMENTS Notices for the express payments step.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
// Enum format below triggers the above rule even though VSCode interprets it fine.
|
||||||
/**
|
/**
|
||||||
* @typedef {NoticeContexts['PAYMENTS']|NoticeContexts['EXPRESS_PAYMENTS']} NoticeContextsEnum
|
* @typedef {NoticeContexts['PAYMENTS']|NoticeContexts['EXPRESS_PAYMENTS']} NoticeContextsEnum
|
||||||
*/
|
*/
|
||||||
|
@ -137,6 +139,7 @@
|
||||||
* response. This varies between context
|
* response. This varies between context
|
||||||
* emitters.
|
* emitters.
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable jsdoc/valid-types */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} EmitResponseApi
|
* @typedef {Object} EmitResponseApi
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
*
|
*
|
||||||
* @typedef {Object} PaymentStatusActions
|
* @typedef {Object} PaymentStatusActions
|
||||||
*
|
*
|
||||||
* @property {Function} started
|
* @property {Function} started Set started status.
|
||||||
* @property {Function} processing
|
* @property {Function} processing Set processing status.
|
||||||
* @property {Function} completed
|
* @property {Function} completed Set completed status.
|
||||||
* @property {Function} error
|
* @property {Function} error Set error status.
|
||||||
* @property {Function} failed
|
* @property {Function} failed Set failed status.
|
||||||
* @property {Function} success
|
* @property {Function} success Set success status.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,7 @@ function findParent( sourceNode, predicate ) {
|
||||||
*
|
*
|
||||||
* @param {Object} node The WOOCOMMERCE_BLOCKS_PHASE identifier node.
|
* @param {Object} node The WOOCOMMERCE_BLOCKS_PHASE identifier node.
|
||||||
* @param {Object} context The eslint context object.
|
* @param {Object} context The eslint context object.
|
||||||
* @todo: update this rule to match the new flags.
|
* @todo update this rule to match the new flags.
|
||||||
*/
|
*/
|
||||||
function testIsAccessedViaProcessEnv( node, context ) {
|
function testIsAccessedViaProcessEnv( node, context ) {
|
||||||
let parent = node.parent;
|
let parent = node.parent;
|
||||||
|
|
|
@ -194,6 +194,8 @@ const Settings = () => [
|
||||||
/**
|
/**
|
||||||
* Page settings fixture data, using the update batch endpoint.
|
* Page settings fixture data, using the update batch endpoint.
|
||||||
*
|
*
|
||||||
|
* @param {Array} pages
|
||||||
|
*
|
||||||
* @see {@link https://woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-setting-options|Batch update setting options}
|
* @see {@link https://woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-setting-options|Batch update setting options}
|
||||||
*/
|
*/
|
||||||
const PageSettings = ( pages = [] ) => {
|
const PageSettings = ( pages = [] ) => {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
/** @typedef {import('react')} React */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the label of a toggle control.
|
* Finds the label of a toggle control.
|
||||||
*
|
*
|
||||||
* @param {string} label The label associated with a toggle control.
|
* @param {string} label The label associated with a toggle control.
|
||||||
*
|
*
|
||||||
* @return {?ElementHandle} Object that represents an in-page DOM element.
|
* @return {?React.ReactElementHandle} Object that represents an in-page DOM element.
|
||||||
*/
|
*/
|
||||||
export async function findLabelWithText( label ) {
|
export async function findLabelWithText( label ) {
|
||||||
const [ toggle ] = await page.$x(
|
const [ toggle ] = await page.$x(
|
||||||
|
|
Loading…
Reference in New Issue