* Fix typo in HTML markup of ProductImage block placeholder
Typo caused rendering of incorrect HTML attributes: width and height of Product Image placeholder that were anyway ignored by the browser
* Remove inline styles (width and height) from ImagePlaceholder in ProductElements > Image block
Inline height took precedence over the inherited styles which made the placeholder image skewed (in loading and loaded state). Removal of those styles allows the ImagePlaceholder to adapt the height to the available space keeping the ratio or inherit the styles from the parent
* Remove inline styles (width and height) from placeholder image in ProductImage.php block
Inline styles applied to the placeholder image of ProductImage block were overriden by other styles with higher specificity, which made them redundant. Additionally, corresponding styles were removed from the placeholder image from Editor code as they caused UI glitches. Additional proof that it's safe to remove them is in the first commit in this branch, the purpose of which was to fix those styles as there was a typo which corrupted them and eventually inline width and height were ignored by the browser and not applied to the element
* Add test to check placeholder image renders without width and height inline attributes
This is to prevent adding inline width and height attributes so the sizing of the placeholder image is controlled by the inherited styles or element styles, in the same way as a regular product image
* Fix TypeScript errors in the block test file of Product Image
* Add generic alt text to placeholder image
Alt text added in this commit is a generic text, not description of the actual image. That's because the image itself is set externally through the settings and may change over time
* Revert adding placeholder image alt text and add comments to make the empty alt explicit
After a Github discussion: https://github.com/woocommerce/woocommerce-blocks/pull/7651\#discussion_r1019560494 it was decided the placeholder should NOT have alt text as it serves the purpose of decorative image. According to the guidelines decorative images should not have alt text: https://www.w3.org/WAI/tutorials/images/decorative/. Comments were added also to other places where it happens
* bot: update checkstyle.xml
Co-authored-by: Karol Manijak <karolm@Karols-MacBook-Pro.local>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Make loading placeholder colors match the current font color
Currently, the loading placeholder effect has a default gray color. However, since users can modify their themes with the Site Editor and choose a different set of colors for their websites, it would be interesting to make those placeholders match the color palette.
In this commit, the idea was to modify the `placeholder` mixin to replace the transparent font color with the current color and also modify the background-color and the linear-gradient to match the current font color. Furthermore, transparency was added to the middle color of the linear-gradient so we can keep the loading animation close to what it currently is.
* Add opacity to placeholder mixin
Before our changes, when the font color was dark, we had a lighter placeholder background color. After the changes the color is currently darker than before so the idea for this commit is to change the opacity of the placeholder in a way that the current color blends with the background color set for the theme.
* Change placeholder mixin opacity
After testing different combinations of colors, we decided to change the opacity to 0.15 so when the font color is darker the placeholder will have a lighter background color.
* bot: update checkstyle.xml
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add actions and selectors for new paymemt status
* Remove set_complete from reducer
* Replace all usages of getCurrentStatus with specific sepectors
* Replace all `setCurrentStatus` with individual actions
* Update docs
* Removed currentStatus
* bot: update checkstyle.xml
* Update docs/third-party-developers/extensibility/data-store/payment.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Address Thomas feedback
* Add link to deprecated message
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Remove isExpressPaymentMethodActive and paymentStatus.isDoingExpressPayment from the payment store
* Remove uneccessary paymentStatuses key from the payments store
* Move ValidatedTextInput and ValidationInputError to checkout package
* Include checkout package in tsconfig file
* Remove unnecessary index file
We export these components from packages/checkout/index.js instead
* Import ValidatedTextInput & ValidationInput error from checkout package
* Only add validationError.message when validationError is an object
* Explicitly add undefined to optional props
* Import isObject to test validationError
* Extend the HTML Input element attributes
* Use more performant useDispatch instead of dispatch
* Export component without withInstanceId hoc for testing
* Add tests for ValidatedTextInput
* bot: update checkstyle.xml
* Rename export of unwrapped component to have __
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add type to imports that need it
* Add type to imports that need it
* Fix the sanitize lint error
* Include missing dep
* Remove check from deps
* bot: update checkstyle.xml
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Product Query: Fix pagination issue
* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790
Product Query - Add support for the Filter By Price Block
* fix query relation
* fix on sale query
* Product Query - Add support for the Filter By Attributes block woocommerce/woocommerce-blocks#6790
Product Query - Add support for the Filter By Attributes block
* fix bugged pagination and on-sale filter after refactor
* address feedback
* Product Query - Add support for the Filter By Stock Block woocommerce/woocommerce-blocks#6790
Product Query - Add support for the Filter By Stock Block
* Fix filter blocks: the data (e.g: max price or stock-status) match the variation woocommerce/woocommerce-blocks#7245
fix filter blocks: the data (e.g: max price or stock-status) match the variation
* disable phcs rules on top of the file
* replace parameter name
* fix eslint error
* Fix storybook build failing issues
Storybook build was failing because of 2 issues:
1. Can't import the named export 'Fragment' from non EcmaScript module (only default export is available)
I used solution provided in following comment:
https://github.com/storybookjs/storybook/issues/16690#issuecomment-971579785
This issue comes from the framer-motion library.
2. SassError: Can't find stylesheet to import.
To fixe this issue I have updated the path in import statements.
**Before**
```
@import "@wordpress/base-styles/breakpoints";
@import "@wordpress/base-styles/mixins";
@import "wordpress-components/src/popover/style";
@import "wordpress-components/src/tooltip/style";
```
**After**
```
@import "node_modules/@wordpress/base-styles/breakpoints";
@import "node_modules/@wordpress/base-styles/mixins";
@import "node_modules/wordpress-components/src/popover/style";
@import "node_modules/wordpress-components/src/tooltip/style";
```
* Add a comment to explain why webpackFinal block was added
* Fixed Price Slider Issue
Located where the price slider was hard coded and replaced it.
* fix CSS lint
* use currentColor instead of hard-coded color for the slider of the Filter By Price block woocommerce/woocommerce-blocks#7130
use currentColor instead of hard-coded color for the slider of the Filte By Price block
* use currentColor instead of hard-coded color for the slider of the Filter By Price block woocommerce/woocommerce-blocks#7130
use currentColor instead of hard-coded color for the slider of the Filte By Price block
* remove background-color
Co-authored-by: EmptySet-Exe <46509186+EmptySet-Exe@users.noreply.github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
* Construct args for canMakePayment with correct keys
* When the CheckoutEventsContext mounts, initialize payment store
* Destructure useSelect correctly
* Dispatch __internalInitializePaymentStore in selector tests
* Update selector name to __internalUpdateAvailablePaymentMethods
* Remove check for editor when registering checkout store
* Add check for when express payment methods have updated too
* Ensure billingAddress key exists in canMakePayment arg
* Use editor context to know if we're in editor
* Products by Rating: Add display options
* Products by Rating: Add support for the Apply button display option
* Products by Rating: Reset button display fix
* Products by Rating: Reset button dependency fix
* Products by Rating: Fix Active filters rating removal and Rating Reset button
* Products by Rating: Tweak preview checklist options
* Products by Rating: Remove stock status mentions
* Products by Rating: Remove redundant color option and fix loading check logic
* Products by Rating: Fix Reset button styling
* Products by Rating: Code cleanup and standardization
* Set default style to link-button mixin
It was identified that we currently have 3 different behaviors for links used in the application. In issue woocommerce/woocommerce-blocks#1778, it was discussed a set of good practices that we should follow in order to obtain consistency between links.
Currently, the link-button mixin is already used by the 'Clear all' button in the Active Filters block, so the idea was to increment it with a common pattern (font size small, font-weight normal, underlined by default and not underlined when on hover) that can be reused by other components (for example FilterResetButton).
* Change link-button mixin to make it attend the expected default style for links
* Replace text-button with link-button mixin in FilterResetButton component
* Add new mixin for links in filter blocks
* Revert change to link-button mixin to prevent it to affect link buttons on Checkout page
* Add filter-link-button mixin that can be used in filter blocks
* Remove link-button styles that were moved to filter-link-button mixin
By default, link-button mixin styles should have only styles from the text-button mixin and also be underlined.
The styles for link button in filter blocks should reside in filter-link-button mixin.
It was identified that we currently have 3 different behaviors for links used in the application. In issue woocommerce/woocommerce-blocks#1778, it was discussed a set of good practices that we should follow in order to obtain consistency between links.
Currently, the link-button mixin is already used by the 'Clear all' button in the Active Filters block, so the idea was to increment it with a common pattern (font size small, font-weight normal, underlined by default and not underlined when on hover) that can be reused by other components (for example FilterResetButton).
* Change link-button mixin to make it attend the expected default style for links
* Replace text-button with link-button mixin in FilterResetButton component
* Rename payment-method-data-context to payment-event-context and tidy up types and things
* Rename uses of PAYMENT_METHOD_DATA_STORE_KEY to PAYMENT_STORE_KEY
* Rename __internalInitializePaymentMethodDataStore and unsubscribeInitializePaymentMethodDataStore
* Rename unsubscribeInitializePaymentMethodDataStore
* Rename setProcessingResponse to setPaymentResult and remove setOrderId from the checkout data store actions
* Fix accidentally changing data exposed to the observers
* Rename all checkout actions with the __internal prefix
* Prefix all payment method data store actions with __internal
* Pedantic spacing
* Fix ts error
* Remove object from sanitizeHTML return value
* Import sanitizeHTML from utils
* Fix dangerously set inner HTML format
* Update package-lock
* Update package-lock
* Update package-lock
* Update @types/dompurify version
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Remove setPristine as it's not used
* Comment checkout actions
* Rename setProcessingResponse to setPaymentResult and remove setOrderId from the checkout data store actions
* Add comments to payment actions
* Update documentation with data stores
* Fix accidentally changing data exposed to the observers
* Document missing parameters for actions
* WIP add filter for place order button label
* Solve TS issue
* Add display priority
* Refactor display priority
* WIP Implement useMemo()
* Try using a global cache
* Add docs for placeOrderLabel filter
* Update docs/third-party-developers/extensibility/checkout-block/available-filters.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Adjust docs
* Rename “placeOrderLabel” to “placeOrderButtonLabel”
* Update assets/js/types/type-defs/payments.ts
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
* Add interactivity to the Product by Rating filter block
* Fix block with the latest repo changes
* Product by Rating: Code tidying up
* Add an experimental build gate and update block title and description
* Remove redundant title and description
* Add support for the CheckboxList component in the Products by Rating block
* Products by Rating: Minor code clean-up
* Active Filters: Fix the Clear All button for Ratings. Closes #woocommerce/woocommerce-blocks#7172
* Products by Rating: Add misc TS fixes
* Convert checkout context to data store - part 1 (https://github.com/woocommerce/woocommerce-blocks/pull/6232)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Delete empty types.ts file
* remove merge conflict from docs
* Correct linting in docs
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Move checkout state code into thunks and rename `CheckoutState` context to `CheckoutEvents` (https://github.com/woocommerce/woocommerce-blocks/pull/6455)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* validate event emitter button
* Added thunks in a separate file
* Call thunks from checkout-state
* Checkout logic tested and working
* Remove dependency injection as much as poss, tidy up and fix some TS errors
* Fix types in thunks.ts
* Fixed some ts errors
* WIP
* Fixed bug
* Shift side effects from checkout-state to checkout-processor
* Revert "Shift side effects from checkout-state to checkout-processor"
This reverts commit 059533da4eb34f9982f66cd4adacc7b2c24f939f.
* Rename CheckoutState to CheckoutEvents
* Move status check outside the thunk
* remove duplicate EVENTS constant
* remove temp buttons
* Remove console logs
* Augment @wordpress/data package with our new store types
* Add correct type for CheckoutAction
* Remove createErrorNotice arg from runCheckoutAfterProcessingWithErrorObservers
* Remove createErrorNotice from emit event types
* Use type keyword when importing types
* Add correct types for dispatch and select in thunks
* Update wordpress/data types
* Replace store creation with new preferred method
* Set correct action type on reducer
* Remove unnecessary async from thunk
* add CHECKOUT_ prefix to checkout events again
* export EVENTS with eveything else in checkout0-events/event-emit
* Remove duplicate SelectFromMap and TailParameters
* Updated type for paymentStatus
* TODO remove wp/data experimental thunks
* Remove `setCustomerId` from events and `processCheckoutResponseHeaders` (https://github.com/woocommerce/woocommerce-blocks/pull/6586)
* Prevent passing dispatch, instead get actions direct from store
* Get setCustomerId from the store instead of passing it to processCheckoutResponseHeaders
* Revert "Prevent passing dispatch, instead get actions direct from store"
This reverts commit 4479a2ef5599d9c8d99c3629616b3d662210fc08.
* Auto stash before revert of "Prevent passing dispatch, instead get actions direct from store"
* Remove duplicate dispatch
* Fix unit tests
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Refactor selectors to not return functions anymore
This is a poor DevEx and naming did not reflect what the selector was returning.
* Update combobox to be more explicit when selecting validation error
* Update useValidation to use the new getValidationError selector
* Include @woocommerce/base-hooks in tsconfig
* Update ValidationInputError to use new selector
* Update ValidatedTextInput to use new selectors
* Prevent reference errors when getting validation errors in ComboBox
* Defend against case where message prop of error object is undefined
* Fix totals/coupon to use new validation selector
* Use validation data store in CheckoutTerms block
* Update AddressForm to use new validation selector
* Update AttributeSelectControl to use new validation selector
* Fix syntax error in ValidatedTextInput
* Fix multiple import error from rebase
* Fix lint issue in useStoreCartItemQantity
* Fix tests to reflect new selector API
* Remove unused validation prop from CheckoutTermsBlock
* Change CheckoutTermsBlock unit tests to use validation data store
* Fix JSDOC syntax
* fix merge conflict in checkout-api.md
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Niels Lange <info@nielslange.de>
* Mock getCartTotals
* Change test to use data store instead of context
* Move payment method context test to data store selectors
* Change description of test suite
* Bump commit to trigger tests
* Fix path in test
* update package lock
* Set correct state payment method reducer tests/use correct actions
* Get saved payment methods from store not context
* Mock stores and update tests to allow switching payment methods
* Update tests to get onSubmit from checkoutEventsContext
* Remove cartTotalsLoaded check from payment method initialize check
* Make PaymentMethods test wait until payments initialized
* initialize payment method data store when cart is loaded
* Remove unneeded actions and add initializePaymentMethodDataStore
* Remove check for cart totals loaded in checkPaymentMethods
* Remove updateAvilablePaymentMethods from registry
* Remove unneeded mock
* Remove unused import
* Rename imports to fix eslint errors
* Remove unused imports
* Remove return false from checkPaymentMethods
* Remove unnecessary setPaymentMethodsInitialized call
* Add todo comment to track refactoring opportunity
* Remove savedpayment methods from payment method context and rename it
* Rename payment method data context to payment method events context
* Add tests for setDefaultPaymentMethods
* Optimize the availablePaymentMethods state data
Store only the "name" attribute for now.
* Get list of payment methods from the registry instead of the store
We are using this hook to get some React elements in the payment method
object. So, we are getting the raw data directly from the registry instead
of the store.
* Fix payment state not loading on the Checkout edit page
* Handle checkout edit page case
* Fix infinite loop error on C&C Blocks
* Include @wordpress/redux-routine in transformIgnorePatterns jest config
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Move paymentMethodDataProvider into a data store (https://github.com/woocommerce/woocommerce-blocks/pull/6208)
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Use correct key in payment method data context
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Fix linting issues
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
* Rebase on the update/checkout-data-store branch & Fix failed payments (https://github.com/woocommerce/woocommerce-blocks/pull/6587)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Fix merge conflict error
* Set & get the provider's state from our data store instead of React's useReducer (https://github.com/woocommerce/woocommerce-blocks/pull/6588)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Get payment method data directly from the data store instead of the usePaymentMethodDataContext hook (https://github.com/woocommerce/woocommerce-blocks/pull/6589)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
* Get payment method state from data store in the checkout submit hook
* Copy types.ts file into the payment data store folder
* Fix isExpressPaymentMethodActive selector
* Move the entire currentStatus into the data store
* Replace the payment context state with the data store
* Fix getActiveSavedToken & clean up the context file
* Use the accutrate name of the "createErrorNotice"
* Update the payment method data store key import
* Diable unused state from the context
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Refactor the payment method data store & context (https://github.com/woocommerce/woocommerce-blocks/pull/6607)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
* Get payment method state from data store in the checkout submit hook
* Copy types.ts file into the payment data store folder
* Fix isExpressPaymentMethodActive selector
* Move the entire currentStatus into the data store
* Replace the payment context state with the data store
* Fix getActiveSavedToken & clean up the context file
* Use the accutrate name of the "createErrorNotice"
* Update the payment method data store key import
* Diable unused state from the context
* Get enabled customer payment methods using data store selector
* Remove remaining useReducer action from the dispatchers file
* Update types and remove unused vars
* Remove the payment method dispatchers hook
* Refactor & clean up (remove unused files)
* Remove commented line from payment methods types
* Move event emitter into thunks
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Remove checkout-state after merge conflicts
* Fix linting errors
* Move types to types.ts
* Move default states into respective store folders
* Fix types and add comment
* Move setExpressPaymentError to payment-methods store
* fix express payment methods not showing up
* Check if payment method is active from the state
* Add comments
* Remove commented out code in payment method data context
* Display an error in the check-payment-methods directly from data store
* Remove use-emit-response hook and move utils in event-emit/utils.ts
* Use correct action property to remove payment methods
* Fix formatting
* Only try to initialize payment methods when cart is done loading
* Add function to order payment methods from server
* Add payment methods in the correct order
* Prevent adding registered payment methods before cart is ready
* Ensure payment methods get removed from state when deregistered
* Reorder setting default payment methods to add customer methods first
* Get customer methods from store not context
* Remove error from payment-method state and associated selectors
* Remove use-payment-method-registration and update the payment method state to remove the duplicated registeredPaymentMethods
* Remove errorMessage from payment-methods store
* Rename customerPaymentMethods -> savedPaymentMethods
* Order payment methods when validating
* Refactor payment-methods.js
* Fix "Payment methods not set in editor" woocommerce/woocommerce-blocks#6655 bug
We never get to load the payment methods object in the editor mode
because there are no cart totals to load.
* Initialize payment methods when available payments are loaded
* Remove duplicate code
* Fix data store state mutation anti-pattern
A Redux rule is to never mutate the state in a reducer to avoid any unexpected results
* Set availablePaymentMethods to the paymentMethods object
Instead of its keys. We can get the keys using "Object.keys".
* Use the available ordered payment methods
The `getPaymentMethods` & `getExpressPaymentMethods` may include unordored
& unavailable payment methods.
* Get the correct value from the emit event response
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Add validation reducers, actions, and action types
* Add selector for getValidationErrors
* Export store key and register store
* Export validation store key
* Move TextInput files to checkout package
* Export ValidatedTextInput from blocks-checkout package
* Update imports of ValidatedTextInput to reflect new location
* Use the validation wp-data store for showing error messages
* Export getValidationError in checkout package
* Move validation store to checkout package
* Move ValidationInputError to blocks-checkout package
* Only export "exposedSelectors" from validation
* Convert validation context to data store
* Fixed linting error
* Fixed linting error
* Change the validation selectors to return a function
* Convert reducer and selectors to TS
* Remove superfluous comments and improve test titles
* Test to ensure visible errors remain visible
* Make test for hasValidationErrors more robust
* Augment the wp-data module to include our selectors and actions
* Removed unused `exposedSelectors` variable
* Remove TS error because of `instanceId` on props
* Remove unnecessary as const
* Use function returned by getValidationError
* Use correct selector/action names now context has been decoupled
* hide validation error when input value changes
* Add correct aria-describedBy now we can get error id from store
* Clear validation error from store when component unmounts
* Clear validation error if input is valid
* convert ValidationInputError to TS and get correct id/error from store
* Ensure checkout block doesn't break when there are no errors
* Get validation data from the store instead of context
* Update country input to remove validation context
* Move validation store out of checkout package
* Move TextInput and ValidationInputError back out of the checkout package
* Remove duplicate internal styles comment
* Remove exports that no longer exist
* Get validation store key from block-data
* Make attribute-select-control use validation data store
* Export FieldValidationStatus type
* Make combobox use validation store not context
* Make Address use validation store not context
* Make Address use validation store not context
* Use hasValidationErrors selector as a function in shipping calculator
* Remove validation context from coupon story
* Import VALIDATION_STORE_KEY from correct location
* Stop coupon story from erroring
* Update useStoreCartCoupons to use validation store not context
* Make TotalsCoupon use validation store instead of context
* Make AddToCartFormContext use validation store not context
* Remove ValidationContext
* Import FieldValidationStatus from correct location
* Import ValidatedTextInput and ValidatedTextInput from correct location
* Remove ValidationContextProvider
* Update components to use validation store not context
* Update useValidation to use the data store
* Replace the validation context in checkout-events file
* Use the re-mapped path for the store key import
* Use "register" instead of the deprecated "registerStore"
* Fix import error of the "FieldValidationStatus" type
* Use TS instead of React's "PropTypes"
* Fix the type of "ValidationInputError" in the "payment-method-interface"
* Fix error not showing on the first place order click bug
We were mutating the state in the reducer, which prevented re-rendering
on state change
* Fix state mutation issue in the Validation reducer
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* validate event emitter button
* Added thunks in a separate file
* Call thunks from checkout-state
* Checkout logic tested and working
* Remove dependency injection as much as poss, tidy up and fix some TS errors
* Fix types in thunks.ts
* Fixed some ts errors
* WIP
* Fixed bug
* Shift side effects from checkout-state to checkout-processor
* Revert "Shift side effects from checkout-state to checkout-processor"
This reverts commit 059533da4eb34f9982f66cd4adacc7b2c24f939f.
* Rename CheckoutState to CheckoutEvents
* Move status check outside the thunk
* remove duplicate EVENTS constant
* remove temp buttons
* Remove console logs
* Augment @wordpress/data package with our new store types
* Add correct type for CheckoutAction
* Remove createErrorNotice arg from runCheckoutAfterProcessingWithErrorObservers
* Remove createErrorNotice from emit event types
* Use type keyword when importing types
* Add correct types for dispatch and select in thunks
* Update wordpress/data types
* Replace store creation with new preferred method
* Set correct action type on reducer
* Remove unnecessary async from thunk
* add CHECKOUT_ prefix to checkout events again
* export EVENTS with eveything else in checkout0-events/event-emit
* Remove duplicate SelectFromMap and TailParameters
* Updated type for paymentStatus
* TODO remove wp/data experimental thunks
* Remove `setCustomerId` from events and `processCheckoutResponseHeaders` (https://github.com/woocommerce/woocommerce-blocks/pull/6586)
* Prevent passing dispatch, instead get actions direct from store
* Get setCustomerId from the store instead of passing it to processCheckoutResponseHeaders
* Revert "Prevent passing dispatch, instead get actions direct from store"
This reverts commit 4479a2ef5599d9c8d99c3629616b3d662210fc08.
* Auto stash before revert of "Prevent passing dispatch, instead get actions direct from store"
* Remove duplicate dispatch
* Fix unit tests
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Delete empty types.ts file
* remove merge conflict from docs
* Correct linting in docs
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Sanitizing the merchant store link in the error message added in WooPay when in some
cases the customer could run into an issue where we need to tell them an error occurred
and they have to go back to the merchant store and re-initialize WooPay to fix it.
Because previously we were only expecting strings, the text was not sanitized.
* Enabled __unstableHTML hidden option for HTML rendering within notices.
* Fixed margin-bottom for HTML notice content
* Fixed margin-top for HTML notice content
* Attempt to fix a broken e2e test
We noticed that oftentimes our labels and text tend to be overly
technical or unclear. We decided to do a bulk pass to improve
the readability to non-technical users.
* Adjust filter titles margins
* Show the Apply button placeholder and adjust title margins
* Add placeholder for the Apply button on filter by price
* Add placeholder for the Apply button on filter by attr
* Update stock filter snapshot
* Move the apply button placeholder to inside the FilterSubmitButton component
* Fix the placeholder button height
* Fix apply button on editor
* Change loading class to be is-loading
* Active Filters Loading Placeholders
* Use flexbox for active filters loading placeholders
* Clear all placeholder loading styles
* Ensure active filters which arent attribute filters render null when in a loading state
* Refactor loading placeholders and state setting
* Add useIsMounted to shared hooks and check productAttributes only when mounted
* Add componentHasMounted to useMemo deps
* Check URL for attribute filter hint
* Check URL for attribute filter hint
* Remove border-radius from placeholder for clear all button
* Fix filter loading when no filters are active on shop page
* Update filter by attribute skeleton design
* Update filter by attribute skeleton design
* Start using the FilterTitlePlaceholder
* Fix title animation
* Show two placeholder lines on checkboxes
* Fix dropdown border
* Fix gap
* Fix border radius for dropdown
* Don't show placeholder when changing other filters
* Improve filter title margins
* Update filter by price skeleton design
* Improve skeleton colors
* Update skeleton when no apply button
* Update skeleton with apply button
* Avoid showing a very wide placeholder when the filter title is very long
* Start using the FilterTitlePlaceholder component for the placeholder
* Add comment to isUpdating
* Remove unneeded styles
* Fix title animation
* Set max-height to avoid showing a big placeholder on longer titles
* Avoid showing placeholder when no there are no products
* Extract the placeholder to a separate component
* Adjust width
* Adjust border radius
* Pass the title to adjust the placeholder width/height
* Rename component
* Add a static class name for the product details item instead of the translatable string
* Update Jest snapshot
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Reverse ordter of filter item name and close btn.
* Update layout & typography styles for block items
* Update chip ui view styles.
Additionally, add editor styles to have the editor match the rendered
frontend.
* Update additional remove button styles.
- Add hover state to remove button on chip layout.
- Update disabled styles to remove button in both layouts (mainly relevant
to the editor view).
* Adjust remove button colors.
Set hover states to shades of grey. Also set chip color and text to
match selected text color of the block.
* Update e2e test to account for new element order.
Since we're moving the remove button in the list view from the last
child node to the first child node, we need to adjust the expected order
of the active filter item text.
* Design and copy updates on the block settings
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
* Update Filter by Stock controls and UI to include custom checkbox and settings.
* Include and style Filter by Stock reset button
* Make checkbox accessible via keyboard
* Update snapshot tests for Filter Products by Stock component
* Update E2E tests with new label value
* Update label test for Apply Filters in E2E tests
* Specify checkbox type so styles are not overridden in the editor
* Update E2E test label for filter button
* Update label selector to search for containing text rather than exact match
* Escape quotation marks for label query in E2E shopper tests for Filter by Stock
* Correct typo on Filter by Stock controls
* Replace custom checkbox with CheckboxControl component from the checkout package.
* Remove opacity on product count for checkbox label so its the same color as the label.
* Update snapshot tests with new component usage for filter by stock
* Update block title from Filter Products by Stock to Filter by Stock
* Update reset button behaviour to clear selections immediately regardless of whether the Apply Filters button is active or not.
* Pass option value as ID to satisfy E2E tests
* Update snapshot tests for stock filter
* Reset checked state on reset for when they have filters checked but not applied.
* make toggle control full width
* add inlineInput attribute
* add inlineInput sidebar setting
* add inlineInput help text
* style the filter button
* style price input
* wip: reset button
* clicking on reset button will reset the price query
* support inline input fields
* price text styling update
* fix reset button font size
* add loading placeholder to all elements
* fix filter button style
* update range slider thumb and track style
* fix loading placeholder for non empty query
* move reset button into FilterSubmitButton component
* try: render placeholder serverside
* update filter button label
* Revert "try: render placeholder serverside"
This reverts commit 98f08efdb8048b8f78c7476b774d1128c1d31295.
* remove LoadingPlaceholder component
* remove Price: prefix from the current displayed price range
* update labels
* extract reset button as a dedicated component
* update price text section
* update reset button behavior
* avoid breaking filter submit button style for other filter blocks
* rename block to Filter by Price
* fix e2e test
* remove border support
* adjust padding for elments
* rename panel title
* Make the inline option enabled by default and fix frontend rendering
* Make the `Price Range Selector` uppercase
* Show `Reset` button only when a selection has been made
* Revert the `save` change to avoid the 'Block Recovery Prompt'
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
* Add default page notice
* show notice all inner blocks
* support flow when page isnt saved
* switch from where we get the current post id
* update lock
* fix types
* Remove old compatibility notices from Cart and Checkout
* Move useCompatibilityNotice to sidebar-compatibility-notice directory
* Remove old CartCheckoutCompatibilityNotice
* Create sidebar compatibility notice hoc
* Add isCartOrCheckoutOrInnerBlock function
* Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func
* Remove BlockSettings from checkout edit and export from checkout-shared
* Change so component still renders, it is just hidden with display: none
This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time.
* Set the priorities of the hoc filters so compat notice renders first
* Make isCartOrCheckoutInnerBlock a hook
* Remove old compatibility notice related tests
* Remove BlockSettings from Cart
* Remove withDefaultNotice hoc
* Include DefaultNotice in compatibility notice
* Remove DefaultNotice from Checkout
* Rename withSidebarCompatibilityNotice to withSidebarNotices
This is because it includes the sidebar compatibility notice and the default notices
* Remove useIsCartOrCheckoutOrInnerBlock hook
* Remove compatibility notice code from tests
* Revert DefaultNotice back to the old one
* Remove unused components
* Remove withBlockSettings HOC and fix TS types
This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks
* Remove CartCheckoutFeedbackPrompt from BlockSettings
It will be included in sidebar-notices instead
* Fix TS Types in DefaultNotice
* Add BlockSettings to cart and checkout edit
* Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)
* Show "Feedback prompt" for all inner blocks
* Fix the "feedback" notice position for these blocks
The "checkout fields", "checkout billing address" and
"checkout shipping address" have the addressFields option which
gets rerendered and placed at the bottom of the inspector controls.
* Tidy up the address-fields hoc
* Use correct block name to check for billing or shipping address
* Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)"
This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f.
* Add hack to get feedback prompt to render last
* Fix TS errors for context and attributes
* Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols
* Do not include feedback prompt if on an address block or contact info
* Remove unused hoc for address fields
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Copy style-attributes file to desired directory.
Add a copy of the style-attributes file in blocks/hooks to the desired
base/hooks directory with the other hooks.
* Remove relative imports in favor of global aliases
Utilizes the custom global project aliases in place of using relative
imports.
Note: seeing some linting issues with the aliases. This seems to be the
case elsewhere so it is likely not a blocker for this effort, however,
it may be worth looking into as a follow-up.
* Adjust all imports to use @woocommerce/base-hooks.
Replace all instances of relative file paths to hooks/style-attributes
to use the custom global alias.
* Remove the hooks dir in `assets/js/blocks/`.
Now that everything is using the `@woocommerce/base-hooks` custom global
alias and we have the `style-attributes` hooks file in the base/hooks
directory, we no longer need the `style-attributes` hooks file in the
aforementioned `assets/js/blocks` directory.
* Split style-attributes.ts out into separate files.
Moved the four hooks in style-attributes.ts out into their own, separate
hook file to be consistent with the rest of our custom hooks.
Additionally, moved the helper function (parseStyle) out into a separate
export in base/utils.
* Check package length >= 1 to show package name
* Check shipping rates length in order shipping packages slot
* Fix TS error where boolean value could be undefined
* Show items if there is more than one shipping rate
* Get shipping rates from preview cart in editor
* Set showItems in ShippingRatesControl to true if multiple packages
* Move dependency in useShippingData to correct section
* Ensure getting packageData.shipping_rates.length won't error
* update billing address when shipping address gets change in Cart block
* Add a new line to test linting error
* Remove a new line to test linting error
* Fix linting error
* Fix linting error
* Fix linting error by adding a space and removing a comma
* Fix linting error by replacing a space with tab
Co-authored-by: Niels Lange <info@nielslange.de>
* wip: convert attribute filter to ts
* change query to optional
* update SearchListControlProps and SearchListItemType
* get default attribute from metadata
* update types
* convert attributes utils to ts
* convert attribute query utils to ts
* fix type error, remove type casting
* revert type change for SearchListItemType
* apply new format
* Rename billingData to billingAddress
* Add unit test to ensure billingData remains accessible
* add integration tests for slots
* Keep billingData in usePaymentMethodRegistration for backwards compatibility
* Gate `billingData` in deprecation gate
* Replace deprecation call
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Use wp store directly instead of React Context
We are using now actions directly from wp store in 'useStoreCartCoupons'
hook to apply and remove coupon.
* Remove unused "useStoreSnackbarNotices" related
files
* Add NoticeContext TS definition
* Remove the Provider references and refactor code
* Fix snackbar notice creation bug
* Fix "clear out snackbar coupon notice" bug
* Update "notices" API documentation
Remove snackbar hooks mentions since it's not used anymore
* Add requireExactMatch prop to ComboBox & only run onChange if value matches
* Set requireExactMatch to true for Country and State inputs
* Add unit tests for ComboBox
* Update expected value for onChange call
* Re-add autocomplete option to country input
* Use correct case for autoComplete in country input
* Parse categories coming from the back-end as a json array
The category ids that come from php are in json array format (e.g. '[40,41]'),
so it's necessary to parse them and convert them into a js array before
processing them. Otherwise the api request will fail.
* Only parse category ids if not undefined
* Add correct context to checkout and cart errors from API
* Correct typo in add-to-cart context
* Add correct context in add to cart form
* Add correct context in add to cart form
* Add correct context in Checkout State
* Enable Attribute Filter block to work with the PHP rendered Classic Template block
* Check for presence of option before rendering it
* improve filter product by attribute
* fix pagination problem
* fix check when two filter block with same attribute are used
Co-authored-by: Luigi <gigitux@gmail.com>
* Make useStoreNotices interact directly with the store
* Get/set error notices directly in store in paymentMethodDataContext
* Add hasNoticesOfType util
* Remove useStoreNotices and interact directly with data store
* Create/remove notices directly in store
* Remove tests for useStoreNotices
* Add tests for notices util
* Use setIsSuppressed from useStoreNoticesContext
* remove useStoreNotices hook
* Update context typedef to define only isSuppressed and setIsSuppressed
* Remove all values from StoreNoticesContext besides setIsSuppressed
* Wrap Cart and Checkout blocks in StoreNoticesProvider (for isSuppressed)
* Make StoreNoticesContainer a named export
This is required so we can import it from @wooommerce/base-context
* Change addErrorNotice to createErrorNotice to match store action
* Remove unnecessary StoreNoticeProviders and pass only context to container
* Accept a context in StoreNoticesContainer
* Pass relevant context to StoreNoticesContainer
* Add function to remove notices by status
* Prevent checkout from breaking when removing notices during processing
* Prevent TS error about not included path
* Add StoreNoticesContainer to single product block
* Add StoreNoticesContainer to All Products Block
* Ensure errors are shown when using All Products & Single Product Blocks
* Add a context arg to removeNoticesByStatus
* Use correct contexts for all products and single product block
* Update tests to reflect new context argument
* Re-add missing block file for order-summary
* Remove block file for order-summary
* Send context to useStoreCartCoupons to show errors correctly
* Rename `Product Title` `Content` panel to `Link settings`
* Rename toggle `Link to Product Page` to `Make title a link`
* Remove help text
* Add `rel` and `linkTarget` to the `Product Title` settings
* Add `rel` and `linkTarget` to the `Product Title` block
* Only add the `target` attribute if the title is rendered as a link
* Keep the `nofollow` in rel as it was before
* Make `linkTarget` and `rel` optional
To not change the html generated for other components also using `ProductName`
* Add tests fotr the `Title` component
* Improve rel condition
* Extract `linkRel` variable
* Remove unnecessary undefined
* Remove the default value for `linkTarget`
Since it is the default behavior of the browsers, we don't need it.
* Remove the `nofollow` rel value
It was decided to remove it since it's a link to internal pages.
See the PR discussion for more context.
* Remove the `rel` option
It does not have much sense to have it since it's always an internal link.
See the PR discussion for more context.
* Clean-up `rel` related code
* Sub/Total/Fee inner blocks
* Row blocks within the inner block
* Update icons
* Resolve stying issues
* Remove old block
* Pin totals row
* Locking logic update
* Heading inner block
* Refactor where inner blocks are defined
* Add todos
* Todo for Consider deprecating OrderMetaSlotFill and DiscountSlotFill in favour of inner block areas.
* Improve frontend registration of components using new entrypoint
* Experiment- external block context
* Revert "Experiment- external block context"
This reverts commit 4b75668ec7eb62f065c6a488cd942a666e26204f.
* Duplicate inner blocks to avoid conflicts with context
* Remove todo
* Rename block dir
* Some test fixes
* Fix import
* fix import
* linting
* Remove unused attributes
* Optional classname
* fix coupons import
* fix shipping mocks
* Styling
* Fix selectors in e2e tests
* Add back the wc-block-components-totals-wrapper class that was used for each segment in the totals Order summary
Because, removing them was:
- a breaking change for the old structure
- was making it harder to target the inner blocks. Before the class was used to target each segment
- it was making the wc-block-components-totals-item behave as a child or parent depending on the inner block, inconsitency
* Reuse the TotalsWrapper component for C& C blocks inner blocks
This component was removed in this PR, but we wrap components in the Cart and Checkout sidebar in a TotalsWrapper. This will ensure consistent spacing and borders are applied to items in the sidebar.
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
* upgrade wordpress/scripts to 22.3
* update jest config/setup
* add explicit-exports-references plugin
to handle payment-method-config.tsx spying on external methods
the way code is output now changed and tests like this would not
work anymore as transpilet files were no longer using exports but
local references to methods.
* missing snapshot
* make cart-products E2E test more stable
* surppress eslint error in test file
* fix css stylelint issues
* update eslint-plugin-woocommerce eslint package
* remove temp test:e2e:start script
* re-run
* add stylelint as recommended extension
* remove redundant types (provided by packages now)
* patch update @testing-library/jest-dom
* Filter Products by Attribute: Fix dropdown search case sensitivity handling
* Refactor the dropdown search logic and add an isCaseSensitive option
* Dropdown search: Match against the name rather than value
* Clean up and refactor the search dropdown code
* Create the CurrencyCode and use it for the currency `code` instead of the type `string`
Using the CurrencyCode type, the allowed values for the `code` property are restricted
to the ISO 4217 codes and not any string.
* Add and remove some currency codes to match the ones on WooCommerce
The WooCommerce supported list can be found here: https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/wc-core-functions.php#L475
* Use CurrencyCode type on CurrencyInfo and CurrencyResponse instead of string
* Make shipping address field optional on checkout routes
* Make update_customer_from_request use billing for shipping if omitted
* making shipping optional when needed
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Change `shippingRatesLoading` to `isLoadingRates`
* Revert isLoadingRates back to old name in payment method interface
* Update docs with correct names returned by usePaymentMethodInterface
* Update TS to name the selectShippingRate method correctly
* Change method name on usePaymentMethodInterface back
* Remove X- Prefixes from custom headers
* Fix docs
* Handle deprecated X-WC-Store-API-Nonce header if received
* Send old nonce until future version removes this
* Add todo and cut off date
* wc_deprecated_argument
* Update todo name
* typo
* Back compat in batch
* Flip Nonce logic to make it easier to support both in client bw compat logic
* Remove expected warnings from test suite
* Switch dispatch and select usage to `controls`, from `@wordpress/data`
* Wrap render with act
* resolveSelect to wait for resolution
* resolveSelect
* Add address-related items to wc/store/cart data store
* Add useUpdateCustomerData hook
This allows us to have a single hook responsible for updating the customer information on the server.
* Add useUpdateCustomerData hook in Checkout block
* Remove shippingAsBilling from previousCustomerData ref type
* Add useShippingAsBillingCheckbox hook
* Remove checkbox handling from useCheckoutAddress
* Merge with woocommerce/woocommerce-blocks#5810 changes
* Move shipping as billing to checkout state context provider
* Subscribe to changes
* Cache customerDataToUpdate
* Combine customerDataType and customerDataContextType
* Fix notice context
* Clean up inline docs for push changes
* Add useShippingData hook
* Add shipping related selectors to cart store
* Update useShippingDataContext to useCustomerData hook
* Update uses of useShippingDataContext to get data from hook instead
* Remove rogue linebreak
* Re-add linebreak
* Re-add linebreak, remove shippingAsBilling
* Re-add linebreak
* Use useShippingData and useCustomerData instead of context
* Fix fromEntriesPolyfill to use number or undefined as an index option
* Convert derive-selected-shipping-rates to TS
* Add SelectShippingRateType
* Get needsShipping from new hook and not context
* Get address data from useCustomerData instead of useShippingDataContext
* Move selectedRates, selectShippingRate and isSelectingRate
* Remove items from ShippingDatacontext that are available in data stores
* Get shipping data from stores, not context in payment method interface
* Consider shipping rates to be loading if customer data is updating
* Get rates from useShippingData hook instead of context
* Fix incorrect TypeScript types and incorrectly named destructure
* Move useShippingData into shipping folder
* Update tests to mock useShippingData instead of context
* Remove empty string fallback from shipping phone
* Get types from Cart declaration instead of Picking them
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Add address-related items to wc/store/cart data store
* include shippingAsBilling in return value of useCustomerData
* Add useUpdateCustomerData hook
This allows us to have a single hook responsible for updating the customer information on the server.
* Add useUpdateCustomerData hook in Checkout block
* Remove the updating customer data work from the useCustomerData hook
* Remove shippingAsBilling from previousCustomerData ref type
* Add useShippingAsBillingCheckbox hook
* Control shippingAsBilling from single hook
* Remove checkbox handling from useCheckoutAddress
* Remove CustomerDataContext typedef
* Merge with woocommerce/woocommerce-blocks#5810 changes
* Move shipping as billing to checkout state context provider
* Unused import
* Subscribe to changes
* Only receiveCartContents when updating customer data via checkout
* Cache customerDataToUpdate
* rename debounced function
* Combine customerDataType and customerDataContextType
* Change case of CustomerDataType
* debouncedUpdateCustomerData typo
* Fix notice context
* Clean up inline docs for push changes
* Comment on dirty state
* Phone is always set
* shippingAddress is never undefined
* setBillingPhone
* receiveCartContents explanation
* Tweak customerData to avoid null
* useShippingAsBilling
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Pass context information about containing block to the existing Slots
* Fix images added to the Slots docs
* Use the parent's block name for the context prop passed to Slot fills
* Convert radio component to TS and support uncontrolled components
* Further radio control to typescript changes
* Combine useSelectShippingRate and useSelectShippingRates
* Remove useSelectShippingRate hook
* Move local radio checked state to PackageRates
* This is a Controlled component - update inline docs
* useSelectShippingRates -> useSelectShippingRate rename
* Remove api hydration for the Mini Cart Block woocommerce/woocommerce-blocks#5729
Remove api hydration for the Mini Cart Block
* fix PHP error
* send event when the button is clicked
* fix import order
* Add hover & focus styles for component buttons
We are using an old version of the "@wordpress/component" package,
that's why we are not getting the latest style fixes from Gutenberg.
The reason to not using the latest version is that we had some issues
with the bundle size.
The current solution is to set our own focus & hover styles
* Replace raw value with Sass variable
* Fix hover style for the mini cart block
We don't have the outlined button yet. This styles is unique for the
mini cart button.
To refactor this code, maybe we should create a reusable outlined button
* Add variant to the Woo Block Button component
To refactor our code, adding a "variant" prop looks logical since we are
have already "contained" & "outlined" buttons. So, for future need for an
outlined button, no need to manually apply the same style again.
The "contained" variant is set by default for legacy reasons. Our Button
component was first built as a contained one.
* Fix height difference: oulined & contained buttons
The outlined buttons have more height because of the added border value.
To fix it we can replace the border with the inner shadow.
Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
* Add stories for Button component woocommerce/woocommerce-blocks#5250
Add stories for Button component
Co-authored-by: gigitux <gigitux@gmail.com>
* Button: Change With Spinner story title to Loading
* Product title: add support global style woocommerce/woocommerce-blocks#4965
* add specific type
* add custom save function
* move hooks in a specific folder
* fix crash on WP 5.8
* Featured Category block: Add support for global style woocommerce/woocommerce-blocks#4965
Featured Category block: Add support for global style
* fix border color
* Attribute Filter block: enable global style woocommerce/woocommerce-blocks#4965
Attribute Filter block: enable global style woocommerce/woocommerce-blocks#4965
* fix eslint error
* fix test
* add comments about !important
* Remove atom icon
* Swap icon usage to WordPress package
* remove unused icons from library
* Use @wordpress/primitives
* Product cats block to listView
* On-sale to use percent instead of tag icon
* add to cart button use button icon
* on sale products block icon
* Handpicked products use stack icon
* Products by stock box icon
* Make sparkles woo purple
* Fix icon name
* Correct more tag name
* fix path to icons
* Update snaps
* Update readme to explain updated usage
* Import SVG and path from primitives
* Missing isFeaturePluginBuild
* Update assets/js/icons/README.md
Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
* Update assets/js/icons/README.md
Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
* Update assets/js/icons/README.md
Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
* update lock
Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
* Update payment-method-data-context tests to use userEvent
* Update mini cart block tests to use userEvent
* Update payment methods tests to use userEvent
* Prevent third party blocks from breaking the entire checkout block
* Fixed types and block error boundary around forced blocks
* Move InnerBlocksComponentWrapper and remove extra }
* Allow HTML nodes to be rendered in the component tree, not just eleents
* Reset redirectUrl to blank if not included in response.
* Force redirect URL for successful responses
* Revert "Force redirect URL for successful responses"
This reverts commit 61aae8b459843237b5428be8fa0cdb9500cd0485.
* Product title: add support global style woocommerce/woocommerce-blocks#4965
* add specific type
* add custom save function
* Summary Product block: add support for global style woocommerce/woocommerce-blocks#4965
Summary Product block: add support for global style
* add color global style under feature flag
* fix import after merge
* fix typo
* add min and step to Store API
* add min and step support
* typo
* Update assets/js/base/components/quantity-selector/index.tsx
* Update assets/js/base/components/quantity-selector/index.tsx
* Fix debounce callback
* Style qty input to show steps
* Implement quantity_limits in API
* Quantity validation
* Update product API
* Normalize on + -
* Separate add to cart events from cart item events in regards to limits
* Prevent qty change for editable line items
* Unify filters
* Remove step number indicator from buttons ¯\_(ツ)_/¯
* Normalize on mount
* Update docs
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Don't allow to insert negative values on input for Filter Products By Price block woocommerce/woocommerce-blocks#2695
Don't allow to insert negative values on input for Filter Products By Price block
* renaming util functions and add comments
* Add isCheckout prop to NoShippingPlaceholder and TotalsShipping
* Pass isCheckout to TotalsShipping in Checkout sidebar
* Show the NoShippingPlaceholder if no rates are found
* Show better error message when no shipping is available in checkout
* Remove Storybook knobs
They are now fully replaced by controls
* Update Storybook to 6.4.9
* Add Storybook documentation and VSCode snippets
* Add VSCode snippets
* Convert stories from checkout packages and include them in Storybook
* Add full documentation to the component props in Storybook
* Fix `FormattedMonetaryAmount` TypeScript errors
Since this component is passing on props to `NumberFormat`,
it needs to extend all of its original props, except for `onValueChange`
which we wrap in order to accept only `number`s.
* Convert `constrainRangeSliderValues` to TypeScript
* Add docs to `Currency` types
* Convert `PriceSlider` to TypeScript
*Note:* All TypeScript errors were fixed during the conversion,
except for the IE workaround which wasn't clear to me at this time.
Opened an issue: woocommerce/woocommerce-blocks#5276
* Fix Price Slider story (https://github.com/woocommerce/woocommerce-blocks/pull/5253)
* Migrate stories for `ProductName` to latest Storybook
Also add props documentation and add named export.
* Migrate stories for `ProductName` to latest Storybook. Also add props
documentation and add named export.
* Migrate `TotalsFooterItem` to TypeScript and latest Storybook
* Add a `LooselyMustHave` utility type.
* Export `allSettings` so that they can be manipulated in stories and tests
* Implement a way to easily define and reuse Storybook controls
Implement a currency control for a common use-case of selecting currencies.
It currently implements EUR and USD as they have different properties.
* Migrate `TotalsDiscount` to TypeScript and implement stories
* Migrate `TotalsCoupon` to TypeScript and fix stories
* Change Coupon name within Storybook
* Nicer handling of removal of a coupon from Storybook
It now dynamically calculates the discount from the actual coupons.
* Clarify docs for STARTED
* Clarify docs for setActivePaymentMethod
* Remove useActivePaymentMethod hook (this held state for active methods and tokens)
* Update type defs
* Enhance setActivePaymentMethod action to accept method data
* SET_ACTIVE_PAYMENT_METHOD action
* Add setActivePaymentMethod dispatcher and make "started" status only
* Update setActivePaymentMethod usage in express methods
* Set radio control defaults
* Consolodate tokens and methods
* Update assets/js/base/context/providers/cart-checkout/payment-methods/reducer.ts
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Spacing
* Split saved cards tests from regular, since saved cards are checked by default
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* ship component stories for storybook
* Refactor RemovableChip for Storybook
* Implement lucio feedback changes
* RemovableChip is part of the Chip story
* Typedefs and cartData for the payment interface
* fix case on noticeContexts
* typeof for enums
* immutable note
* Add cartData to docs table
* Rebase docs
* Update packages to latest Storybook deps
* Migrate `ReadMore` component and its utils to TypeScript
* Add type definitions for `trim-html` package
* Migrate `ReadMore` stories to newest Storybook
Fixeswoocommerce/woocommerce-blocks#5254
* WIP
* Converted block-error-boundary to TS
* Convert CheckboxList to TS
* Converted Chip and Removable Chip components to TS
* Change type to React.FC<T>
* Fix tests
* Implement Lucio feedback
* Product details metadata now accepts as a default prop, with as an optional alternative
* Updated product details test snapshot
* Don't overwrite key prop
* One of key or value must be entered in ProductItemResponseData type
* Convert ReturnToCartButton component to TS
* Convert FormStep component to TS
* Remoe proptypes from FormStep and AddressFormn components
* Converted order-summary component to TS
* Convert product-price component to TS
* alias path to type-defs
* Fix errors
* Changes from Thomas feedback
* Change minPrice maxPrice logic to be more robust
* Changed types from inline to interface in ReturnToCartButton component
* Check for string type in order-summary-item
* add missing isString check
* Fix wrong event prefix in doc comment
* Make className prop in CartLineItemsTableProps optional
* Mini Cart as template part
* Remove BlockTemplatePartsController and instead use BlockTemplatesController
* Remove old code
* Clean up frontend rendering
* Update tests
* Improve if clause
* Fix wrong tests title
* Fix wrong variable name
* Make sure Mini Cart contents block is unmounted whem mini cart closes or unmounts
* Remove unnecessary waitFor
* Fix PaymentMethodDataProvider wrong children type
* TypeScript fixes
* Make comment shorter
* Remove test code
* Fix contant unmounts of Mini Cart contents block
* Fix wrong template_type passed
* Set Template part area to 'uncategorized'
* Set Template part area to the correct value
* Move template dir check outside loop
* Fix error on the Cart block
* Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook
* Fix the country is required error on the Cart page using refs
* Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls
* Remove redundant check for customerDataToUpdate
* remove use of refs in initial values
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Add cartItemClass filter for cart line items
* Add cartItemClass, originally implemented in 96f18443bc
* add filter to order summary items
Co-authored-by: Manos Psychogyiopoulos <psyx@somewherewarm.net>
* Remove withRestApiHydration
* Preload checkout data via setting - server data is required for this block
* Handle cart hydration using createPreloadingMiddleware which removes the need for HOCs
* Rename variable
* Remove withStoreCartApiHydration and timestamp checking
* Empty test file
* Make Mini Cart block react to removed_from_cart events
* Move listening to add to cart and remove from cart events to the useStoreCart hook
* Add tests
* move empty cart
* remove Cart and rename Cart i2 to Cart
* graduate blocks
* setup template migration from Cart i1 to Cart i2
* back to js so we have a good diff
* add migration
* fix bug in empty cart template
* add useForceLayout hook to edit
* migrate from old block to new block
* migrate styles
* respect align
* add tests
* Include latest cart line item improvements from cart-i1
* Missing changes from cart-i1
* Line items table should be disabled
* Fix e2e tests for cart i2
* update tests to adapt for inner blocks
* update select to resolveSelect to remove warning checker
* rename test/block to test/index
* move blocks to their own file
* undo rename to keep diff clean
* remove .tsx and update jest config
* Revert "update select to resolveSelect to remove warning checker"
This reverts commit 79d55de30edcfe36bbdfe7506df7a09460824f03.
* revert resolveControl
* Fix empty cart editor E2E test by scrolling to the view switch
* parse attributes for order summary block
* migrate attributes when resaving
* Update documentation
Automatic update after running npm run build:docs
* add classname support to accepted payment methods block
* add classname support to express payment methods block
* add classname support to cart items block
* add classname support to cart line items block
* add classname support to order summary block
* add classname support to totals block
* add classname support to empty cart block
* add classname support to filled cart block
* add classname support to proceed to checkout block
* type edit
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
* Convert sharedConfig and Title blockConfig to TS
* Convert constants.tsx to TS
* Convert attributes.js to TS
* Amend attributes.ts record type
* Convert title component edit.js to TS
* Convert title component block.js to TS
* Amend product name index.tsx to prevent TS errors in product title block.tsx
* Amend product-name and base tsconfig
* Add rel to ProductName component element
* Replace ReactElement with JSX.Element
* Move TagName component to outside of the main component
* Add HTMLAttributes import
* WIP: Add props to TagName component
* Fix TagName typing
* Update TagName interface
* Replace ReactElement typing with JSX.Element
* Code review feedback amends
* Replace return type undefined to void
Co-authored-by: Michael P. Pfeiffer <michael@cssconf.eu>
* Pass classname from DOM to react components
* Actions Block ClassName support
* Form step field classname support
* Payment block className support
* Classname support for fields and totals
* Order summary classname support
* Classname support for order note block
* Express payment classname support
* Terms block custom class
* Let useBlockProps handle class in actions block
* Add dark mode inputs toggle to top level block
* Remove top level attributes which moved to inner blocks
* Remove unused components
* Pass down hasDarkControls and currentView via context props