Commit Graph

73 Commits

Author SHA1 Message Date
Mike Jolley 2b5f115d41 Remove custom `Icon` component in favour of `@wordpress/icons` where possible (https://github.com/woocommerce/woocommerce-blocks/pull/5599)
* 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>
2022-02-01 16:54:38 +00:00
Tung Du 4b159f0fcd Allow inserting blocks to filled mini cart (https://github.com/woocommerce/woocommerce-blocks/pull/5527) 2022-01-08 07:51:20 +07:00
Lucio Giannotta 35adae3fa4 Add Storybook documentation and remove deprecated knobs (https://github.com/woocommerce/woocommerce-blocks/pull/5407)
* 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
2021-12-21 18:08:57 +01:00
Tung Du 50066455c0 Fix: Mini Cart block: divide contents into three inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5386)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-12-20 14:57:55 +07:00
Luigi Teschio 13deb1b09e Mini Cart Block: render the empty state set on template parts (https://github.com/woocommerce/woocommerce-blocks/pull/5338)
* add view switcher for mini cart contents block

* editor view switcher

* update mini cart template file

* render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

* update selector

* allow empty mini cart block to add all blocks

* fix tests; improve code style

* install @wordpress/block-editor package

* fix warning on frontend side

* block-editor package is not necessary

* merge attributes object

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2021-12-10 12:11:59 +01:00
Tung Du 90a54b6cf0 Mini Cart Contents block: implement view switcher in editor (https://github.com/woocommerce/woocommerce-blocks/pull/5304) 2021-12-07 21:07:53 +07:00
Luigi Teschio c2ebf26c1c Enable stylelint for the entire project woocommerce/woocommerce-blocks#5262 (https://github.com/woocommerce/woocommerce-blocks/pull/5298)
Enable stylelint for the entire project
2021-12-03 10:07:51 +01:00
Alex Florisca d9bf1ba94c Convert components to Typescript (https://github.com/woocommerce/woocommerce-blocks/pull/5241)
* 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
2021-11-26 17:03:12 +00:00
M. L. Giannotta 57fcb28720 Checkbox Control: Fix squished checkboxes when label text wraps (https://github.com/woocommerce/woocommerce-blocks/pull/5192) (https://github.com/woocommerce/woocommerce-blocks/pull/5206)
On the front-end, checkboxes with labels would look squished when the labels wrapped
on a second line. That was due to the flex container taking too much space for the label
as the checkbox minimum dimensions was set in `px` rather than `em`, making it work
differently depending on the relative font size.
2021-11-25 15:31:47 +01:00
Mike Jolley 3b1bedd15f Checkbox Component Styling Fix (https://github.com/woocommerce/woocommerce-blocks/pull/5164)
* Wrap label in div to prevent clickable area growing too large

* Prevent pointer events on svg

* Double gap in editor
2021-11-22 09:52:43 +01:00
Darren Ethier 620cf8aebc In `@woocommerce/blocks-checkout` package documentation - reference WCDEWP instead of WPDEWP (https://github.com/woocommerce/woocommerce-blocks/pull/5154)
* Reference the WooCommerce DEWP instead of WPDEWP

* Apply suggestions from code review

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2021-11-20 07:08:58 -05:00
Thomas Roberts c35819272d Switch variables round in mustContain error (https://github.com/woocommerce/woocommerce-blocks/pull/5155)
This is because the error messaged printed to the user  was incorrect.
2021-11-19 12:31:16 +00:00
Mike Jolley a76e00bd83 Move checkbox control to checkout package (https://github.com/woocommerce/woocommerce-blocks/pull/5045)
* Move checkbox control to checkout package

* Revert import change in editor
2021-11-09 16:47:46 +00:00
Raluca Stan 43a235fb36 Update README.md 2021-10-29 15:12:11 +01:00
Seghir Nadir 2408e34faa Migrate Cart i1 to Cart i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4973)
* 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 align options to filled cart and empty cart

* append instead of replcae

* import style.scss in frontend

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2021-10-25 15:46:34 +01:00
Mike Jolley c4be7ca307 Styling (margin and padding) tweaks (https://github.com/woocommerce/woocommerce-blocks/pull/4974) 2021-10-20 17:02:05 +01:00
Seghir Nadir 91296b09cc Update blocks-registry docs (https://github.com/woocommerce/woocommerce-blocks/pull/4946)
* add handleMap

* remove useValidation from cart blocks

* add namespace options to docs

* Update packages/checkout/blocks-registry/README.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* expand on the docblock

* Update packages/checkout/blocks-registry/README.md

Co-authored-by: Mike Jolley <mike.jolley@me.com>

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2021-10-19 14:05:26 +01:00
Mike Jolley 61e5a4c55e Add Checkout Package and Checkout i2 Documentation (https://github.com/woocommerce/woocommerce-blocks/pull/4892)
* Move components

* Main index for docs

* Block registry documentation

* filter registry docs

* Utility docs

* Doc for components

* Link to package docs

* fix import
2021-10-12 15:23:52 +01:00
Ovidiu Liuta ae603f3e82 WordPress Coding Standards fix for .scss files (https://github.com/woocommerce/woocommerce-blocks/pull/4918)
* adding timerange limit

* woocommerce/woocommerce-blocks#3739 fixing scss coding standard and removing spaces from parantheses values

* removing unrelated changes

* fixing further instances for parantheses
2021-10-11 14:18:32 +01:00
Seghir Nadir b6167bc179 Cart i2: Render filled and empty Carts on frontend (https://github.com/woocommerce/woocommerce-blocks/pull/4802)
* WIP getting to work on frontend

* restore frontend.tsx

* fix layout

* remove unit tests living where they shouldn't be living

* remove skeleton

* support emtpy cart in frontend

* remove extra todo

* use fragment instead of div

* Add empty cart event

* Remove extra fragment
2021-09-23 16:38:30 +01:00
Mike Jolley 2af90f301c Add/empty and fillted cart wrapper (https://github.com/woocommerce/woocommerce-blocks/pull/4803)
* Update area/types

* Add empty and filled block wrappers

* Add missing useBlockProps

* Add templates and inner block structure
2021-09-21 16:41:09 +01:00
Seghir Nadir 56551347a6 Setup basic column blocks for Cart i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4780)
* setup basic column blocks

* fix classnames

* fix broken block.json in cart items block

* move hacks back

* dubplciate columns
2021-09-21 11:18:27 +01:00
Mike Jolley 5c08c75612 Update Checkout to Checkout i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4745)
* Remove i2 from build

* Remove i2 php registration

* Rename old checkout dir

* Rename i2 dir

* Migrate i1 to i2 code

* Register block metadata to fix frontend rendering when migrating to i2

* Register in correct order

* Missing styles

* add register-components to side effectful list

* wrong block class in e2e test

* wp prefix missing on selector

* Fix top level block test

* Reselect labels to work around rerendering

* missing empty cart styles

* Consolodate duplicate styles

* remove init code

* update selectBlockByName

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2021-09-16 13:16:21 +01:00
Mike Jolley c891beab82 Update checkout block registration API to consume Block Metadata (https://github.com/woocommerce/woocommerce-blocks/pull/4684)
* Update registry to register components with block JSON metadata

* Use updated registration API in sample block

* remove editorScript

* Rename area and allow forced blocks to do it's thing without defining a template manually

* More naming consistency

* Validate a registered checkout block has at least one valid parent
2021-09-07 17:01:14 +01:00
Mike Jolley b385d4005c Refactor Checkout Inner Block Registration and Render frontend forced blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4671)
* Append forced blocks

* Fix child detection

* Improve render logic to remove clone element

* Areas instead of block names

* Revert "Areas instead of block names"

This reverts commit c8d68e6424313ed15ca1eb1f91a3edfc24d06a8d.

* revert area change

* Registration system

* Refactor block registration to handle components + forcing

* Remove need for atomic block registration

* add attributes to namespaced blocks only

* Update area names to new format

* Avoid passing custom props to DOM

* Put back usage of cloneelement for DOM elements

* correct case of innerBlockAreas

* Inline documentation for renderParentBlock

* Play nice with other attributes when registering forced blocks
2021-09-03 14:25:09 +01:00
Mike Jolley 64fffd7051 Experimental newsletter subscription checkbox block POC and Store API supporting changes (https://github.com/woocommerce/woocommerce-blocks/pull/4607)
* remove todo from sample block

* Add newsletter block

* Block registration

* Move provider/processor so separate them from context providers

* customData implementation for setting customData for requests

* Make data and schema callbacks optional in extendrestapi class

* schema_type should be data_type

* Allow checkout endpoint to be extended

* Support validation, sanitization, and defaults on nested REST properties

* Experimental endpoint data for newsletter field

* Add extension data to requests

* SET_EXTENSION_DATA

* Update types

* Add todo

* move check within hook function

* Remove newsletter block

This is because we're testing with the integration being done in a separate extension

* Delete newsletter subscription block

* Pass the result of hooks down to the children blocks

We need to do this to allow extension blocks to modify the extensionData (so they can send custom input to the REST api when submitting the checkout form).

* Remove newsletter signup block

* remove checkoutSubmitData

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2021-08-30 15:35:20 +01:00
Mike Jolley a9e403c0be Define parent in registerCheckoutBlock (https://github.com/woocommerce/woocommerce-blocks/pull/4591) 2021-08-18 11:41:18 +01:00
Albert Juhé Lluveras 70ec1f8b31 Add optimizations around checkout filter calls (https://github.com/woocommerce/woocommerce-blocks/pull/4570)
* Extract productPriceValidation out of the component

* Extract checkout filter args outside of component

* Remove unnecessary default fallback

* Mark ProductName optional props as not required

* Use an empty array constant for the filteredNotices default value when there are no notices

* Refactor Panel component so hidden contents are not rendered

* Prevent extensions changing on each call of __experimentalApplyCheckoutFilter if it was an empty object

* Add missing line break

* Update tests
2021-08-13 15:42:09 +02:00
Thomas Roberts fb846c5b78 Update `snackbarNotices` filter to `snackbarNoticeVisibility` (https://github.com/woocommerce/woocommerce-blocks/pull/4417)
* Change snackbarNotices filter to snackbarNoticeVisibility

* Add deprecation notice to snackbarNotices

* Rename noticesToDisplay to visibleNotices

* Update link in deprecated message
2021-07-26 09:13:54 +01:00
Mike Jolley f78da3c355 WIP - Checkout i2 Feature Branch Tracking (https://github.com/woocommerce/woocommerce-blocks/pull/4268)
* Duplicate checkout block

* Contact information block

* form step block

* shipping address block

* Setup atomic blocks

* Container structure

* More formal steps rather than generic form step

* Add billing and shipping forms

* add checkout actions block

* add order note block

* Add order summary

* add payment block

* Add inspector controls for address fields

* frontend WIP

* move attributes

* wrap shipping with form step

* PhoneNumber to typescript

* Remove column block

* form steps

* move payment logic to frontend

* Express block

* inline payment block

* Add shipping method block

* Render inner blocks (not standalone blocks) and add classes to Atomic Block list on php side

* lazy again

* Add more wrappers from old frontend file

* add layout

* Checkout wrappers were missing

* Enqueue payment methods for new block

* Add missing classnames

* Move shipping as billing state to context provider

* express payments rendering

* try/block-registry

* Remove atomic components (unused)

* Fix attribute persistance due to template locking

* Fix shipping display when not needed

* Set correct parent blocks for inner blocks

* pass data to blocks

* demo/newsletter

* Skeleton styling

* only apply styles to loading state for now

* shipping method block frontend

* rename express block

* lock template

* fix ts warning for __webpack_public_path__

* Refactor to avoid duplicating atomic block logic

* remove changes in save method

* Add zones and shipping methods to the sidebar for the shipping inner block

Closes woocommerce/woocommerce-blocks#4320

* Fix script handles

* Fix method display when there are none

* Add shipping phone

* Add phone to api and sync with billing correctly

* Clear hidden fields on load

* fix requirePhoneField property

* Enable shipping and billing phone fields

* readonly field support

* Handle context attributes

* Fix createInterpolateElement usage

* add totalswrapper

* Implement Terms and Conditions block for Checkout i2  (https://github.com/woocommerce/woocommerce-blocks/pull/4436)

* Setup atomic blocks

* frontend WIP

* Express block

* try/block-registry

* Set correct parent blocks for inner blocks

* Skeleton styling

* Refactor to avoid duplicating atomic block logic

* add block locking

* add terms and conditions block

* hardcore settings image

* lock blocks from being deleted

* hide original checkout block

* mark blocks as side effectful

* move variations to block register function

* prevent core checkout blocks from needlessly showing in the inserter

* enable checkout i1

* fix broken rebase

* move save back

* Localise default text

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Add add-hoc Block locking from WooCommerce Blocks side. (https://github.com/woocommerce/woocommerce-blocks/pull/4454)

* add locking

* use subscribe instead

* fix condition

* add locking to blocks

* check if the item is not a text field

* Tidy up hacks CSS class handling

* Fix error if node is undefined

* Hide menu when move is disabled

* update package lock

* Add todo and fix issue where selector returns null

* split todos

* move todo

* edit comment

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Un-disable the billing checkbox in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/4457)

* Add missing Slot fill provider on frontend

Fixes woocommerce/woocommerce-blocks#4441 by adding the slot fill provider to the checkout-i2 block.

* Use column style appender

* Add padding/styles to actions

* Add/update icon library

* Multiline checkbox alignment

* Icons and copy changes for i2 blocks

* Add terms by default

* Add notice if text is missing links (https://github.com/woocommerce/woocommerce-blocks/pull/4466)

* Swap variations for toggle

* Add payment settings to inspector

* Update package lock

* Add inline docs to block registry

* Add inner block areas below each form step.

This does not include the form step contents, just adds inner blocks after existing content. Moving content within the inner block area is a separate discussion.

This closes woocommerce/woocommerce-blocks#4306

* Sample block registration + docs

* Add tests for registerCheckoutBlock

* Fix lazy component detection in tests

* Add basic transform between i1 and i2

* remove template lock todo

* Update scroll to top hoc

* Move shared settings to new context providers

Closes woocommerce/woocommerce-blocks#4472

* Remove readonly field support (unused)

* Remove context code

* Experimental

* remove invalid typedef

* FIx scrolling on validation due to misplaced context provider

* Update assets/js/base/context/providers/cart-checkout/checkout-state/index.tsx

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Update comment to remove reference to phone

* Update packages/checkout/blocks-registry/README.md

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Rename ScrollToTopComponent

* Add explicit list of expectedType in TypeScript definition

* Add todo to remove custom shipping phone handling

* Remove dangerouslySetInnerHTML in External Link Card Component

* Add ExternalLinkCard to storybook

* update todo wording

* Refactor withScrollToTop to remove useCallback and use typescript

* Support children on CheckboxControl, with added Typescript

* Spread getRegisteredBlocks return value

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2021-07-22 12:03:00 +01:00
Thomas Roberts f735f698e0 Add camelcase rule to eslint config (https://github.com/woocommerce/woocommerce-blocks/pull/4382)
* Add rules to allow camelCase variables as object properties

* Remove disable camelcase comments

* remove disable camelcase comments

* Remove space from eslint ignore rule
2021-07-09 17:53:45 +01:00
Thomas Roberts c3f4310fe2 Add `TotalsWrapper` component (https://github.com/woocommerce/woocommerce-blocks/pull/4415)
* Add TotalsWrapper component and associated styling

* Add TotalsWrapper around the subtotal, fees and discount

* Remove margins/paddings/borders from sidebar elements

This is to allow TotalsWrapper to be the component responsible for handling spacing and borders.

* Update styles to allow components to be wrapped in TotalsWrapper

* Move TotalsWrapper to checkout package

* Wrap all parts of Cart sidebar in TotalsWrapper

* Remove border from coupon panel

* Add has-bottom-border option to TotalsWrapper

* Wrap checkout sidebar components in TotalsWrapper

* Remove border/padding from order summary

* Add hasValidFills function

This will be used to check if a Slot has any fills that return truthy values.

* Remove borderSize and hasBottomBorder props from TotalsWrapper

* Wrap Slots in TotalsWrapper

* Update hasValidFills to check length of array

* Update tests and snapshots

* Only render tax totals if tax is more than 0
2021-07-02 15:56:39 +01:00
Thomas Roberts 589f6923d6 Export `Button` and `Label` from `wc-blocks-checkout` package (https://github.com/woocommerce/woocommerce-blocks/pull/4406)
* Remove snackbar filtering

* Revert "Move Button and Label components to `@woocommerce/blocks-checkout` package (https://github.com/woocommerce/woocommerce-blocks/pull/4222)"

This reverts commit 983ce48cad.

* Export Label and Button from the wc-blocks-checkout package

* Reorder exports

This is so the diff is smaller in the PR

* Revert "Remove snackbar filtering"

This reverts commit 8e598436e871aa56f89740fbe6fbe522fd02db1d.
2021-07-02 10:24:07 +01:00
Thomas Roberts 93b750ee19 Change `couponName` filter to `coupons` and update documentation (https://github.com/woocommerce/woocommerce-blocks/pull/4312)
* Rework coupon filters to not be applied individually

* Add a `text` property to the coupons in the cart

This is needed to allow extensions to change the text without affecting the code.

* Output coupon text instead of code

* Add coupons filter documentation

* Add deprecation warning when extension uses couponName filter

* Change couponName filter to coupons

* Add label to Cart item definition

* Change coupon.text to coupon.label

* Update coupon.label in coupon aria-label

* Update image and coupon.text in docs

* Add filter registration example
2021-07-01 14:12:46 +01:00
Thomas Roberts 60b95041ff Fix error about duplicate keys in TotalsFees (https://github.com/woocommerce/woocommerce-blocks/pull/4360) 2021-06-17 08:49:45 +01:00
Mike Jolley 84718840d6 Update Express Payments Loading UI (https://github.com/woocommerce/woocommerce-blocks/pull/4228)
* Separate button spinner to separate component for reuse

* Use block checkout spinner in loading mask

* Block pointer events within loading mask

* Give the useRef within useShallowEqual a default value

This prevents the potential of having an undefined value returned.

* State setter and dispatch are stable

These do not need to be used as dependencies.

* Prevent re-renders of children when using loading mask.

This prevents children being rerendered and losing state. Loading styles are applied instead using a classname, but leaving the divs in place.

* Use memoization to to prevent excessive express payment rerenders

* Wrap express payment in loading mask

* Show loading state after submission

* remove eslint exclusion

* Move spinner to base components so it's available outside of the checkout package

* Avoid extra is-loading classname

* Update snaps/fix tests

* Remove memorization of payment method content due to stale data

* Express payment error handling

* Split up payment method context to make it more manageable

* Add blocking logic to cart

* Update snap

* Restore useRef

* Fix missing function removed by accident

* Fix setActivePaymentMethod and started status (so saved methods still allow express to be initialized)

* Loading Mask Todo

* Remove boolean shallow equals

* Missing dep

* Memoize typo

* Document changes in useStoreEvents

* Replace expressPaymentMethodActive

* setExpressPaymentError deprecation

* Only change status if an error is passed

* Track disabled state via useCheckoutSubmit

* useCallback on error message functions

* Fix mocks in test
2021-06-16 13:44:40 +01:00
Thomas Roberts a20f3425b1 Add cart/extensions endpoint to allow third party extensions to process server-side and get a new cart (https://github.com/woocommerce/woocommerce-blocks/pull/4298)
* Move text-input to checkout package

* Add support to TextInput for inputs with type number

* Add ExperimentalDiscountsMeta.Slot to Cart sidebar

* Add extra styles for Button and Panel components

* Add updateCartFromApi util to @woocommerce/blocks-checkout

* Change updateCartFromApi to TypeScript

* Stop passing contexts through the discounts slot fill

* Add CartExtensionsSchema class

* Add CartExtensions Route

* Add register_update_callback and get_update_callback fns

* Add extensionCartUpdate function

* Add applyExtensionCartUpdate action

* Make extensionCartUpdate use batching

* Add ExtensionCartUpdateArgs type definition

* Execute a success/error function after request in extensionCartUpdate

* Remove success and error functions

* Avoid including all schemas in CartExtensionsSchema instantiation

This is achieved by inheriting AbstractSchema and slightly modifying the way in which the latest cart data is returned from this endpoint.

* Update docs for extensionCartUpdate

* Handle errors from extension callbacks

* Throw better errors when incorrect namespace/functions are used

* Add tests for CartExtensions route,  ExtendRestApi update callback registration

* Add dummy get_properties method to CartExtensionsSchema
2021-06-07 12:16:47 +03:00
Thomas Roberts bafa5c2827 Add snackbar filter (https://github.com/woocommerce/woocommerce-blocks/pull/4313) 2021-06-07 11:41:33 +03:00
Thomas Roberts ffa77f26f7 Add Slot/Fill to discounts area in cart sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/4248)
* Move text-input to checkout package

* Pass validation props directly to ValidatedTextInput

* Import label relatively instead of from package

* Pass validation functions to ValidatedTextInput

This is so it doesn't need to get them from useValidationContext.

* Add InputProps to ValidatedTextInput

This will be used to control additional props on the input element of TextInput

* Spread inputProps onto <input> element of TextInput

* Export TextInput from @woocommerce/blocks-checkout

* Add @woocommerce/blocks-checkout package to tsconfig

* Allow styling to be applied to number inputs and when value is 0

* Make style order consistent

* Remove inputProps to rely on rest in TextInput

* Add specific prop for the inputErrorComponent

* Only disallow active state if value is 0 AND type is number

* Change all uses of ValidatedTextInput to also pass inputErrorComponent

* Revert "Change all uses of ValidatedTextInput to also pass inputErrorComponent"

This reverts commit ec734b99c20c4d29fcf778714246fc406ee37eaf.

* Revert "Remove inputProps to rely on rest in TextInput"

This reverts commit 1fc64cca4002206423d1fa443ff2d60130ba1ea0.

* Revert "Revert "Change all uses of ValidatedTextInput to also pass inputErrorComponent""

This reverts commit 110e3606a996668be5a32698b634b7706d16cddc.

* Revert "Revert "Remove inputProps to rely on rest in TextInput""

This reverts commit aeb03526c44b3fcc97a719a18930d08157a80baf.

* Don't pass errorMessage to ValidatedTextInput

* Add DiscountsMetaSlot

* Add ExperimentalDiscountsMeta.Slot to Cart sidebar

* Add extra styles for Button and Panel components

* Export ExperimentalDiscountsMeta from checkout package

* Add updateCartFromApi util to @woocommerce/blocks-checkout

* Add comment to updateCartFromApi

* Change updateCartFromApi to TypeScript

* Revert "Move `TextInput` to checkout package and allow it to be used for input type=number (https://github.com/woocommerce/woocommerce-blocks/pull/4238)"

This reverts commit ee9b2d20e0.

* Stop passing contexts through the discounts slot fill

* Allow ValidatedTextInput to be used for type=number

* Remove contexts from Discounts slot fill

* Update snapshots

* Stop `errorMessage` being spread onto input fields in checkout

* Add paths to tsconfig

* Remove contexts from Discounts slot

* Accept step min and max on ValidatedTextInput

* Remove "no-margin" option on buttons

* Remove spinners from input type number

* Remove `no-top-border` style from panel

* Prevent text in buttons from breaking in the middle of words

* Add checkout package to tsconfig file list

* Stop passing components through DiscountsMetaSlot
2021-06-04 09:44:26 +01:00
Thomas Roberts 1702a6c0c3 Check if there are tax lines before rendering the container for them (https://github.com/woocommerce/woocommerce-blocks/pull/4284) 2021-06-02 11:14:42 +01:00
Seghir Nadir 1b87589f82 remove usage of mustBeString (https://github.com/woocommerce/woocommerce-blocks/pull/4294) 2021-06-01 09:46:02 +01:00
Thomas Roberts 61755f0f01 Fix display of itemised taxes (https://github.com/woocommerce/woocommerce-blocks/pull/4279)
* Add price to itemised tax rates & hide Total when itemised taxes are on

* Update snapshots for taxes in sidebar
2021-05-26 14:04:42 +01:00
Thomas Roberts b187f9f466 Revert "Move `TextInput` to checkout package and allow it to be used for input type=number (https://github.com/woocommerce/woocommerce-blocks/pull/4238)"
This reverts commit ee9b2d20e0.
2021-05-25 14:13:29 +01:00
Thomas Roberts ee9b2d20e0 Move `TextInput` to checkout package and allow it to be used for input type=number (https://github.com/woocommerce/woocommerce-blocks/pull/4238)
* Move text-input to checkout package

* Pass validation props directly to ValidatedTextInput

* Import label relatively instead of from package

* Pass validation functions to ValidatedTextInput

This is so it doesn't need to get them from useValidationContext.

* Add InputProps to ValidatedTextInput

This will be used to control additional props on the input element of TextInput

* Spread inputProps onto <input> element of TextInput

* Export TextInput from @woocommerce/blocks-checkout

* Add @woocommerce/blocks-checkout package to tsconfig

* Allow styling to be applied to number inputs and when value is 0

* Make style order consistent

* Remove inputProps to rely on rest in TextInput

* Add specific prop for the inputErrorComponent

* Only disallow active state if value is 0 AND type is number

* Change all uses of ValidatedTextInput to also pass inputErrorComponent

* Revert "Change all uses of ValidatedTextInput to also pass inputErrorComponent"

This reverts commit ec734b99c20c4d29fcf778714246fc406ee37eaf.

* Revert "Remove inputProps to rely on rest in TextInput"

This reverts commit 1fc64cca4002206423d1fa443ff2d60130ba1ea0.

* Revert "Revert "Change all uses of ValidatedTextInput to also pass inputErrorComponent""

This reverts commit 110e3606a996668be5a32698b634b7706d16cddc.

* Revert "Revert "Remove inputProps to rely on rest in TextInput""

This reverts commit aeb03526c44b3fcc97a719a18930d08157a80baf.

* Don't pass errorMessage to ValidatedTextInput
2021-05-20 17:56:56 +01:00
Thomas Roberts 26a84cedde Convert TextInput and ValidatedTextInput to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/4226)
* Change index file from base/context to .ts

This is to stop TS complaining when importing things from here.

* Convert ValidatedTextInput to TypeScript

* Convert TextInput to TypeScript

* Ensure Label accepts correct HTML Attributes Props

* Remove PropTypes from TextInput and ValidatedTextInput

No longer needed because of TypeScript

* Use correct error id to show validation message

* Use HTMLElement instead of a specific element type for LabelProps

* Update assets/js/base/components/text-input/validated-text-input.tsx

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/base/components/text-input/validated-text-input.tsx

* Use correct formatting in ValidatedTextInput

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-05-19 10:55:15 +01:00
Thomas Roberts 983ce48cad Move Button and Label components to `@woocommerce/blocks-checkout` package (https://github.com/woocommerce/woocommerce-blocks/pull/4222)
* Move Button to checkout package

* Move Label to Components Package
2021-05-18 09:10:31 +01:00
Thomas Roberts 57c5b0c532 Update design of cart and checkout sidebars (https://github.com/woocommerce/woocommerce-blocks/pull/4180)
* Update cart/coupon/shipping design

* Add order summary heading

* Move and style discounts on checkout sidebar

* Add rate to tax lines

* Ensure the option to display taxes itemised is available to Cart block

* Output individual tax items below the total & add styles for this

* Add success notice under coupon input on successful coupon addition

* Add border to bottom of Totals footer

* Show success message when adding coupon

* Add padding to cart item rows

* Add preview data to cart for when taxes are enabled

* Add rate to cart response type

* Add showRateAfterTaxName attribute to Cart block

* Add control to cart block to show rate percentage after rate name

* Add rate % in cart totals only if option is toggled on

* Pass showRateAfterTaxName attribute down to TotalsTaxes

* Add showRateAfterTaxName to Checkout block

* Add control to block editor for showRateAfterTaxName on Checkout

* Pass showRateAfterTaxName down to TotalsTaxes in Checkout

* Change label for showing tax rates in cart and checkout blocks

* Add test to ensure Taxes section shows in Cart block

* Add tests for cart sidebar and rate percentages

* Remove order summary title from checkout sidebar

* Check if taxes are enabled before rendering the option to show rate %s

* Add ShippingVia component to show the selected rate in sidebar

* Remove value from individual tax rates

* Remove bold from Shipping via label

* Remove coupon added successfully message

* Ensure panel headings that are h2s are the same colour as others

* Clean up eslint warnings

* Show rate %s by default

* Update snapshots following design changes

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2021-05-17 15:00:57 +01:00
Thomas Roberts 1dcbddc0bd Add checkout filter for coupon names (https://github.com/woocommerce/woocommerce-blocks/pull/4166)
* Make extensions optional, not all filters will need to pass this through

For example the CartCouponSchema has no option for extensibility (and I don't think it's needed at any rate) so extensions will always be an empty object. Rather than explicitly specifying this when running the filter, we can let it default to an empty object.

* Add filter for coupon code
2021-05-11 13:57:02 +01:00
Thomas Roberts 57b4215bce Add documentation for filters (https://github.com/woocommerce/woocommerce-blocks/pull/4167)
* Rename the argument in the CheckoutFilterFunction type

This only exists as an extra descriptive hint to anyone using this type, the value `label` was never used by anything so it does not need to be changed anywhere else.

* Create Available Filters document

* Add available filters to the extensibility README

* Update docs/extensibility/available-filters.md to fix typographical error

Co-authored-by: Mike Jolley <mike.jolley@me.com>

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2021-05-05 10:41:48 +01:00
Thomas Roberts bc750438c2 Convert Cart Table to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/4088)
* Convert CartLineItemsTitle to TypeScript

* Add type guards

* Change CartLineItemRow extension to .tsx

* Remove parseInt from price precision

This is because the API sends it as a number, so it will never be a string, so no need to parse it.

* Add dinero.js types

* Type QuantitySelector and add types for @wordpress/keycodes

* Make __experimentalApplyCheckoutFilter use generic types

* Add catalog_visibility type & change types of CartItem

* Add isNumber and isString to type guards

* Type ProductLowStockBadge

* Ensure type returned by a filter function is the same it received

* Include type guards and hooks in tsconfig

* Add more type safety to useStoreCartItemQuantity

* Make className optional on QuantitySelector

* Type CartLineItemRow

* Type CartLineItemsTable

* Type Cart

* Add extra keys to CartResponseItem

* Clean aria-hidden logic

* Export type-guards from module

* Use aliases to import types in CartLineItemRow

* Remove unused prop types and specify return type of function

* Specify return type of component

* Use JSX.Element instead of ReactNode

* Remove unused variables & set return type of components

* Remove PropTypes
2021-04-23 10:15:17 +01:00