Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'core/trunk' into add/stock-filter
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
  • Loading branch information
diazoxide committed Jun 2, 2021
2 parents 92a0da3 + 413a4e0 commit 5311584
Show file tree
Hide file tree
Showing 200 changed files with 8,673 additions and 4,668 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ module.exports = {
'jsdoc/require-param': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': [ 'error' ],
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
],
},
},
{
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
/globals.d.ts export-ignore
/tsconfig.json export-ignore
/tsconfig.base.json export-ignore
/tsconfig.base export-ignore
/webpack.config.js export-ignore
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/css/abstracts/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$no-stock-color: $alert-red;
$low-stock-color: $alert-yellow;
$in-stock-color: $alert-green;
$discount-color: $alert-green;

$placeholder-color: var(--global--color-primary, $gray-200);
$input-border-gray: #50575e;
Expand Down
16 changes: 11 additions & 5 deletions assets/css/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@
}
}

// This border has been upstreamed to WooCommerce Admin, so it can be removed
// from here once @woocommerce/components gets updated.
// https://github.com/woocommerce/woocommerce-admin/pull/5901
.woocommerce-search-list__list {
border: 1px solid $gray-200;
// Selectors with extra specificity to override some editor styles.
.woocommerce-search-list__list.woocommerce-search-list__list {
box-sizing: border-box;
margin: 0;
padding: 0;
}

.woocommerce-search-list__selected.woocommerce-search-list__selected > ul {
list-style: none;
margin: 0;
padding: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { __, _n, sprintf } from '@wordpress/i18n';
import Button from '@woocommerce/base-components/button';
import { Button } from '@woocommerce/blocks-checkout';
import { Icon, done as doneIcon } from '@woocommerce/icons';
import { useState, useEffect } from '@wordpress/element';
import { useAddToCartFormContext } from '@woocommerce/base-context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PropTypes from 'prop-types';
import { __ } from '@wordpress/i18n';
import classnames from 'classnames';
import Label from '@woocommerce/base-components/label';
import { Label } from '@woocommerce/blocks-checkout';
import {
useInnerBlockLayoutContext,
useProductDataContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
* External dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import Label from '@woocommerce/base-components/label';
import ProductPrice from '@woocommerce/base-components/product-price';
import ProductName from '@woocommerce/base-components/product-name';
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
import {
__experimentalApplyCheckoutFilter,
mustBeString,
mustContain,
Label,
} from '@woocommerce/blocks-checkout';
import PropTypes from 'prop-types';
import Dinero from 'dinero.js';
import { getSetting } from '@woocommerce/settings';
import { useCallback, useMemo } from '@wordpress/element';
import { useStoreCart } from '@woocommerce/base-context/hooks';

/**
* Internal dependencies
Expand All @@ -41,17 +41,23 @@ const OrderSummaryItem = ( { cartItem } ) => {
extensions = {},
} = cartItem;

// Prepare props to pass to the __experimentalApplyCheckoutFilter filter.
// We need to pluck out receiveCart.
// eslint-disable-next-line no-unused-vars
const { receiveCart, ...cart } = useStoreCart();

const productPriceValidation = useCallback(
( value ) => mustBeString( value ) && mustContain( value, '<price/>' ),
( value ) => mustContain( value, '<price/>' ),
[]
);

const arg = useMemo(
() => ( {
context: 'summary',
cartItem,
cart,
} ),
[ cartItem ]
[ cartItem, cart ]
);

const priceCurrency = getCurrencyFromPriceResponse( prices );
Expand All @@ -61,7 +67,6 @@ const OrderSummaryItem = ( { cartItem } ) => {
defaultValue: initialName,
extensions,
arg,
validation: mustBeString,
} );

const regularPriceSingle = Dinero( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { __ } from '@wordpress/i18n';
import { useCheckoutSubmit } from '@woocommerce/base-context/hooks';
import { Icon, done } from '@woocommerce/icons';
import Button from '@woocommerce/base-components/button';
import { Button } from '@woocommerce/blocks-checkout';

const PlaceOrderButton = () => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ProductDetails = ( {
: '';
return (
<li
key={ detail.name + ( detail.display || detail.name ) }
key={ detail.name + ( detail.display || detail.value ) }
className={ className }
>
{ detail.name && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import Summary from '@woocommerce/base-components/summary';
import { blocksConfig } from '@woocommerce/block-settings';

interface ProductSummaryProps {
className?: string;
shortDescription?: string;
fullDescription?: string;
}
/**
* Returns an element containing a summary of the product.
*
Expand All @@ -17,7 +21,7 @@ const ProductSummary = ( {
className,
shortDescription = '',
fullDescription = '',
} ) => {
}: ProductSummaryProps ): JSX.Element | null => {
const source = shortDescription ? shortDescription : fullDescription;

if ( ! source ) {
Expand All @@ -34,10 +38,4 @@ const ProductSummary = ( {
);
};

ProductSummary.propTypes = {
className: PropTypes.string,
shortDescription: PropTypes.string,
fullDescription: PropTypes.string,
};

export default ProductSummary;
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import { __ } from '@wordpress/i18n';
import Button from '@woocommerce/base-components/button';
import { Button } from '@woocommerce/blocks-checkout';
import { useState } from '@wordpress/element';
import isShallowEqual from '@wordpress/is-shallow-equal';
import { useValidationContext } from '@woocommerce/base-context';
import type { EnteredAddress, AddressFields } from '@woocommerce/settings';

/**
* Internal dependencies
*/
import './style.scss';
import { AddressForm } from '../address-form';

interface ShippingCalculatorAddressProps {
address: EnteredAddress;
onUpdate: ( address: EnteredAddress ) => void;
addressFields: Partial< keyof AddressFields >[];
}
const ShippingCalculatorAddress = ( {
address: initialAddress,
onUpdate,
addressFields,
} ) => {
}: ShippingCalculatorAddressProps ): JSX.Element => {
const [ address, setAddress ] = useState( initialAddress );
const {
hasValidationErrors,
Expand Down Expand Up @@ -55,10 +60,4 @@ const ShippingCalculatorAddress = ( {
);
};

ShippingCalculatorAddress.propTypes = {
address: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
addressFields: PropTypes.array.isRequired,
};

export default ShippingCalculatorAddress;
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import { useShippingDataContext } from '@woocommerce/base-context';
import type { EnteredAddress } from '@woocommerce/settings';

/**
* Internal dependencies
*/
import ShippingCalculatorAddress from './address';
import './style.scss';

interface ShippingCalculatorProps {
onUpdate?: ( newAddress: EnteredAddress ) => void;
addressFields?: Partial< keyof EnteredAddress >[];
}

const ShippingCalculator = ( {
onUpdate = () => {},
onUpdate = () => {
/* Do nothing */
},
addressFields = [ 'country', 'state', 'city', 'postcode' ],
} ) => {
}: ShippingCalculatorProps ): JSX.Element => {
const { shippingAddress, setShippingAddress } = useShippingDataContext();
return (
<div className="wc-block-components-shipping-calculator">
Expand All @@ -29,9 +36,4 @@ const ShippingCalculator = ( {
);
};

ShippingCalculator.propTypes = {
onUpdate: PropTypes.func,
addressFields: PropTypes.array,
};

export default ShippingCalculator;
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import { __, sprintf } from '@wordpress/i18n';
import { getSetting } from '@woocommerce/settings';
import { EnteredAddress, getSetting } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';

interface ShippingLocationProps {
address: EnteredAddress;
}

/**
* 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,
}: ShippingLocationProps ): JSX.Element | null => {
// we bail early if we don't have an address.
if ( Object.values( address ).length === 0 ) {
return null;
}
const shippingCountries = getSetting( 'shippingCountries', {} );
const shippingStates = getSetting( 'shippingStates', {} );
const shippingCountries = getSetting( 'shippingCountries', {} ) as Record<
string,
string
>;
const shippingStates = getSetting( 'shippingStates', {} ) as Record<
string,
Record< string, string >
>;
const formattedCountry =
typeof shippingCountries[ address.country ] === 'string'
? decodeEntities( shippingCountries[ address.country ] )
Expand Down Expand Up @@ -56,13 +67,4 @@ const ShippingLocation = ( { address } ) => {
);
};

ShippingLocation.propTypes = {
address: PropTypes.shape( {
city: PropTypes.string,
state: PropTypes.string,
postcode: PropTypes.string,
country: PropTypes.string,
} ),
};

export default ShippingLocation;
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import classNames from 'classnames';
import { _n, sprintf } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import Label from '@woocommerce/base-components/label';
import Title from '@woocommerce/base-components/title';
import type { ReactElement } from 'react';
import type { Rate, PackageRateOption } from '@woocommerce/type-defs/shipping';
import { Panel } from '@woocommerce/blocks-checkout';
import type { PackageRateOption } from '@woocommerce/type-defs/shipping';
import { Panel, Label } from '@woocommerce/blocks-checkout';
import { useSelectShippingRate } from '@woocommerce/base-context/hooks';
import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/cart';

/**
* Internal dependencies
Expand All @@ -34,21 +33,28 @@ interface Destination {
country: string;
}

export interface PackageData {
destination: Destination;
name: string;
// eslint-disable-next-line camelcase
shipping_rates: CartShippingPackageShippingRate[];
items: PackageItem[];
}

export type PackageRateRenderOption = (
option: CartShippingPackageShippingRate
) => PackageRateOption;

interface PackageProps {
packageId: string;
renderOption: ( option: Rate ) => PackageRateOption;
collapse: boolean;
packageData: {
destination: Destination;
name: string;
// eslint-disable-next-line camelcase
shipping_rates: Rate[];
items: PackageItem[];
};
/* PackageId can be a string, WooCommerce Subscriptions uses strings for example, but WooCommerce core uses numbers */
packageId: string | number;
renderOption: PackageRateRenderOption;
collapse?: boolean;
packageData: PackageData;
className?: string;
collapsible?: boolean;
noResultsMessage: ReactElement;
showItems: boolean;
showItems?: boolean;
}

export const ShippingRatesControlPackage = ( {
Expand All @@ -69,12 +75,9 @@ export const ShippingRatesControlPackage = ( {
const header = (
<>
{ ( showItems || collapsible ) && (
<Title
className="wc-block-components-shipping-rates-control__package-title"
headingLevel="3"
>
<div className="wc-block-components-shipping-rates-control__package-title">
{ packageData.name }
</Title>
</div>
) }
{ showItems && (
<ul className="wc-block-components-shipping-rates-control__package-items">
Expand Down
Loading

0 comments on commit 5311584

Please sign in to comment.