Commit Graph

15 Commits

Author SHA1 Message Date
dependabot[bot] 9a7f1e17e1 Bump @woocommerce/eslint-plugin from 2.0.0 to 2.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6837)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-12 02:14:18 +07:00
Daniel W. Robert fdc07e5a96 Add Product Query Support for Atomic Rating Block (https://github.com/woocommerce/woocommerce-blocks/pull/7352)
* Add PQ support for client-side.

Set up the block for PQ support and add necessary adjustments for the
editor. Will address dynamic save functionality in a following commit.

* Add dynamic render function for PQ support.

* Add dynamic render callback for SSR.

* Remove client-side Save function.

* Add PQ Context interface to shared type defs.

* Convert all block JS files to TS.

* Remove commented import from block file.

* Add typecasting to block function params.

As a workaround, added a general Record type but left a TODO to revisit
the proper object, as there is a mismatch in the shape of the default
object property types and the actual types.

* Update inserter behavior.

Allows for the ability to add the rating block from in the inserter
(as long as it's an inner block of the listed parents in the config).
Also disables the placeholder product selector from being rendered
unnecessarily (i.e., when the context ID is present).

* Update parent inner blocks config.

Reassign parent array to ancestor array which allows for blocks to be
included with more flexibility - i.e., added within groups that are
children of the ancestor block.

* Add productID to rating Attributes interface.

* TS type casting and import adustments.

Some adjustments to utilize types that we already have available, along
with some syntax adjustments and more sensible import tweaks.

* Update type-casting to use ProductResponseItem

Instead of using the generic Record, we can utilize the
ProductResponseItem interface and set an omission for the average_rating
property until that is corrected to properly reflect the API response.

* Add alias to blocks dir for imports.

Allows us to use exports from the blocks dir as "external" imports. This
way we do not need to write long, relative import paths (which can be
fragile in the long run).
2022-10-31 14:56:17 -04:00
Luigi Teschio 881c202717 Make Filter Products by Stock block compatible with PHP rendered Classic Template block (https://github.com/woocommerce/woocommerce-blocks/pull/6261)
* 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

* fix filter by stock for PHP templates

* fix naming and comment

* Update filter key in ClassicTemplate

* Update stock filter block for PHP templates when the filter button is enabled

* Remove unused useEffect and fix ESLint error

* Set active stock filter and track using local state

* ESLint fix

* Remove unncessary dependencies from useEffect

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2022-04-21 08:28:41 +01: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
M. L. Giannotta 703051b1bc Storybook and TS migration of some cart checkout components (https://github.com/woocommerce/woocommerce-blocks/pull/5324)
* 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.
2021-12-15 17:30:17 +01:00
M. L. Giannotta 77c237d6a2 Storybook migration of `CountryInput` component (https://github.com/woocommerce/woocommerce-blocks/pull/5312)
* Enable `exactOptionalPropertyTypes` in TS config

This option will create more strict types out of optional properties.
Read more: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-beta/#exact-optional-property-types

* Extract `ComboBoxProps` as own interface

This way we can export it to use it somewhere else. In this specific case,
I'll need to use it as a base to extend the `CountryInputProps`.

Also fixed some types to be optional, as the component requires.

* Fix stories and props for `CountryInput` (https://github.com/woocommerce/woocommerce-blocks/pull/5252)
2021-12-07 16:07:21 +01:00
Tom Cafferkey 0f4161aff9 Convert CategoryList to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/4909)
* Converted config files

* Converted constants file

* Converted attributes file

* Coverted edit file

* Convert block file

* Remove space from config
2021-10-12 09:21:00 +01:00
Albert Juhé Lluveras e17be06287 Add types to legacy-events.js (https://github.com/woocommerce/woocommerce-blocks/pull/4742) 2021-09-15 17:28:34 +01:00
Mike Jolley cf8ab9fa93 Add key to each `CartTotalItem` (https://github.com/woocommerce/woocommerce-blocks/pull/4240)
* Move type defs

* Move type guards

* Fix imports

* Extract prepareTotalItems to TS file

* usePaymentMethodInterface as TS file

* Fix TS props

* Fix currency type defs

* Add return type to usePaymentMethodInterface

* Add key prop to CartTotalItem

* Fixed up js tests

* Move SymbolPosition into type-defs package

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2021-05-25 12:49:13 +01:00
Thomas Roberts c8f6f5e372 Hide "including X in taxes" when the amount of tax is 0 (https://github.com/woocommerce/woocommerce-blocks/pull/4262)
* Hide "including x in taxes" if tax amount is 0

* Add jest types to tsconfig

* Move SHOW_TAXES into component body

This is to make the code more testable and allows us to change values. There's no significant performance impact because of this change.

* Add tests and snapshots for TotalsFooterItem
2021-05-25 08:43:46 +01:00
Thomas Roberts 583113e373 Remove woocommerce as a dependency and install @woocommerce/e2e-utils (https://github.com/woocommerce/woocommerce-blocks/pull/4078)
* Remove woocommerce as a dependency and install @woocommerce/e2e-utils

* Remove reference to woocommerce package from tsconfig and jest config
2021-04-26 16:31:30 +01:00
Mike Jolley 9bdcbe0b4d Fix Circular Dependencies During Builds (https://github.com/woocommerce/woocommerce-blocks/pull/4025)
* Fix circular dependencies in Icons package

* CircularDependencyPlugin

* Fix deriveSelectedShippingRates CD

* Move useStoreNotices to context/hooks

* Move useStoreCart to base/context/hooks

* Move useStoreEvents to base/context/hooks

* Move collection/product hooks

* Move useStoreAddToCart

* Move useCustomerData

* move shipping hooks

* Move checkout and payment hooks

* Context should import hooks with relative paths

* Prevent circular dependency in store notices container components

* Move address fields to settings so they are shared

* Import PaymentMethod components direct

* relative import

* Fix select CD

* Move ValidationInputError

* Move components consumed by context

* Fix up internal imports in context

* fix CD in checkout package

* Separate providers

* Fixing context exports

* Fix base context hook import

* fix mocks

* Pass hooks to Slot Fills as Fill Props to avoid imports from base-context

* Export components, not hooks

* Pass props to ExperimentalOrderMeta

* Run CD plugin when using `npm start` only

* Rename CIRCULAR_DEPS to CHECK_CIRCULAR_DEPS

* Remove duplicate key from rebase

* Move packages component back to main file

* Remove dashicon module replacement

* Restore SVG import from package not external

* Move core locale handling to avoid impact settings package size

* Remove deleted file from rebase
2021-04-08 13:31:12 +01:00
Albert Juhé Lluveras 29dd816e1d Fix storybook after TS changes (https://github.com/woocommerce/woocommerce-blocks/pull/3938) 2021-03-09 10:54:38 +01:00
Albert Juhé Lluveras 0e1b1e3579 Add types to packages directory (https://github.com/woocommerce/woocommerce-blocks/pull/3914)
* Add Typescript to Panel and Icon

* Fix Icon component import

* Convert packages/checkout/utils/validation/index to TypeScript

* Convert checkout registry to TypeScript

* Add return type to mustContain

* Add TypeScript to Totals components from @woocommerce/blocks-checkout

* Add TypeScript to @woocommerce/price-format

* Use types from @woocommerce/type-defs when possible

* Allow empty objects when loading

* Fix formatting in payment-method-data-context.js

* Add missing return types

* Fix up price warnings

* Fix more warnings in FormattedMonetaryAmount

Co-authored-by: Raluca Stan <ralucastn@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2021-03-05 14:03:48 +00:00
Darren Ethier af99c16931 Add TypeScript support and convert cart data store to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/3768)
* add typescript support

* Add type declarations for Cart and CartResponse interfaces

* make sure we’re resolving .ts files as well as .js files on imports

* add more types

* type the cart data store

* Apply suggestions from code review (implement .tsx in configs)

Co-authored-by: Jon Surrell <jon.surrell@automattic.com>

* remove global fetchMock declaration and directly import where used.

* rename type

* remove named action types and just infer by returning action creator values as const

* use interface instead of type

* rename

* renames

* create CartAction type as union of action creator returned types and implement in reducer

* remove unused imports

* refresh package-lock after rebase

* Add base TS config that projects will inherit from

* Add tsconfig for assets/js/data project

* Ignore TS error on cart store registration

We will address this in cooldown when we have time to investigate further

* Add tsc to build step to catch TypeScript errors

* add a separate command for tsc and tweak build command to use

* restore checkJs and allowJs values in config and remove ts check from build command

* Add ts:check-all command

* Add TypeScript checking workflows

* Change triggers for TypeScript workflow

* Use npm ci instead of npm install

* Remove ts:check-all from TypeScript workflow

* Remove TS Check GitHub workflow

* Remove type-defs dir from TS include, and remove ts:check-all script

We no longer need the ts:check-all script because ts:check will do this for us, the old ts:check did nothing and did not work.

* fix coupon loading issues

* include .ts files only from type-defs folder

Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2021-02-23 20:36:24 -05:00