* 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
* 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>
* Refactor Product Query to use the latest Gutenberg APIs
As we worked with Gutenberg folks in WordPress/gutenbergwoocommerce/woocommerce-blocks#43590,
WordPress/gutenbergwoocommerce/woocommerce-blocks#43632 and WordPress/gutenbergwoocommerce/woocommerce-blocks#44093 we have
created a standard API that could be used for our use-case. This
PR refactors our WIP experimental work to use that standardized API.
* Remove experimental flag from Cross-Sells block
* Remove experimental flag from Cross-Sells block
* Remove experimental flag from woocommerce/cart-cross-sells-products-block
* 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.
* Remove inline style defaults for color options.
This replaces the inline style with an added editor-specific styling
with slightly more specificity - but not too much to where it overrides
the Site Editor.
* Remove additional styles from editor stylesheet.
These styles are meant to apply to both the frontend and the editor. The
ruleset was originally added to the editor stylesheet to add an
additional layer of specificity but it was decided that this is
unnecessary.
* Update "remove filter" icon to use Icon component.
To be consistent with the button icon used on the Chips view, this
replaces the native svg element used in the List view with the same
Icon component from core.
* Add proper margin to active filters by price list.
There is currently no top margin when the active filters contain a price
filter in the list view. This is because the filters only contain a
range and do not render a child list.
This update will target that price filter item and add a top margin that
is consistent with the other active filters.
* 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
* If user has created a template for a specific product, find the closest matching template details
* Move Classic Template functions into Utils file and refactor function for specific template names
* Classic Template utils refactor and unit tests
* 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
* Adds to the Product Image Block the support for the Product Query Block
Adds to the Product Image Block the support for the Product Query Block woocommerce/woocommerce-blocks#6911
* Add to the Product Image Block the support for the Product Query Block
* address feedback
* set grid view and font-size L as default
* 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
* Update filter by stock skeleton design
* Show skeleton only when is loading, otherwise it will show the loading state also after clicking on an option
* 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
* update logic to support cart as well
* fix package.json
* update design and move away from wc.data
* restore notice
* handle older versions of WooCommerce
* fix package lock
* fix typo
* 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>
* Add and style Reset and Apply buttons
* Style the dropdown option
* Fix class and label
* Fix checkbox margin in editor
* Fix alignment
* Fix the reset button
* Disable Apply button when no changes have been made to the filter to improve UX
* Reduce vertical spacing between list items
* Style chips
* Don't reload on reset if filters have not been applied
* Fix heading styles on the front end
* Add chevron down to filter by attribute dropdown ui component
* Force FormTokenField to remount on reset
* Fix dropdown z-index
* Reduce apply button margin
* Fix styles for single token selection
Co-authored-by: tjcafferkey <tjcafferkey@gmail.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.
* Move `EditorBlock` to general `type-defs`
`EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references.
* Define types for the Product Query block
Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern.
* Add Product Query utils
Add two utility functions:
1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type.
2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute.
* Refactor and cleanup the JS demo code
Specifically:
1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes.
2. Move the variations to their own directory. One file per variation.
3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings.
* Update webpack config
* Add ProductQuery class
* Fix `QueryVariation` enum
We had changed the Products on Sale variation slug to something else,
but we had forgotten to update the proper enum.
* Remove unused params from `update_query`
The filter we added to Gutenberg will pass the block and the page,
as we might need them in the future and we want to minimize the
amount of changes we'll have to do upstream.
However, we currently do not use those, so I removed
them from our own inner function.
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
* 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>
* Remove all inbox notifications about cart and checkout blocks
* Remove feature flag check from CreateAccount class
* Remove feature plugin check to register PaymentsApi class
* Comment out is_feature_plugin_build function
We might need this later, so keeping it around seems useful.
* Remove feature plugin check when adding resource hints
* Import registerBlockType and use it over registerFeaturePLuginBlockType
* Ensure Cart and Checkout inner blocks register even if not feature plugin
* Comment out registerFeaturePluginBlockType
* Remove duplicate import
* Revert "Comment out registerFeaturePluginBlockType"
This reverts commit bec6ed899b68e26e836bde1c573d6066fb2bcc47.
* Align PHPDoc correctly
* Update feature flag doc to remove Cart and Checkout blocks + PaymentApi
* 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.
* Add font-weight option to Mini Cart button text.
Need to repeat steps for icon SVG and cart item count.
* Add font-weight controls to mini-cart item count.
* Add better error handling to PHP style output.
Ensure style value is set for style item in the
get_font_weight_class_and_style attributes array before rendering it to
the output.
* Revert font-weight option for quantity badge.
Per conversation with @vivialice, it looks better for now to keep the
font weight adjustment capabilities to just the price and leave the cart
icon and count as-is.
* Move $typography_styles variable into markup fn.
To resolve merge conflicts and get everything in it's proper place, this
commit will move the $typography_styles variable into the
get_cart_price_markup() function from woocommerce/woocommerce-blocks#6796.