@plasmicpkgs/commerce 0.0.6 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,17 @@
1
1
  import { Product } from "./types/product";
2
2
  import React from "react";
3
+ import { Category } from "./types/site";
3
4
  export declare const ProductContext: React.Context<Product | undefined>;
4
5
  export declare const ProductFormContext: React.Context<any>;
6
+ export declare const CategoryContext: React.Context<Category | undefined>;
5
7
  export declare function ProductProvider({ product, children }: {
6
8
  product: Product;
7
9
  children: React.ReactNode;
8
10
  }): JSX.Element;
9
- export declare function useProduct(): Product | undefined;
10
- export declare function useProductForm(): any;
11
+ export declare const useProduct: () => Product;
12
+ export declare const useProductForm: () => any;
13
+ export declare function CategoryProvider({ category, children }: {
14
+ category: Category;
15
+ children: React.ReactNode;
16
+ }): JSX.Element;
17
+ export declare const useCategoryContext: () => Category | undefined;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./utils/types";
5
5
  export * from "./utils/errors";
6
6
  export * from "./types/product";
7
7
  export * from "./product/use-search";
8
+ export * from "./product/use-product";
8
9
  export * from "./site/use-categories";
9
10
  export * from "./site/use-brands";
10
11
  export * from "./cart/use-cart";
@@ -12,6 +13,7 @@ export * from "./cart/use-add-item";
12
13
  export * from "./cart/use-remove-item";
13
14
  export * from "./cart/use-update-item";
14
15
  export { default as useSearch } from "./product/use-search";
16
+ export { default as useProduct } from "./product/use-product";
15
17
  export { default as useCategories } from "./site/use-categories";
16
18
  export { default as useBrands } from "./site/use-brands";
17
19
  export { default as useCart } from "./cart/use-cart";
@@ -22,4 +24,16 @@ export * as CartType from "./types/cart";
22
24
  export * as ProductTypes from "./types/product";
23
25
  export * as SiteTypes from "./types/site";
24
26
  export { CommerceAPIConfig } from "./api/index";
27
+ export * from "./registerAddToCartButton";
28
+ export * from "./registerCart";
29
+ export * from "./registerProductBox";
30
+ export * from "./registerProductCollection";
31
+ export * from "./registerProductLink";
32
+ export * from "./registerProductMedia";
33
+ export * from "./registerProductPrice";
34
+ export * from "./registerProductQuantity";
35
+ export * from "./registerProductTextField";
36
+ export * from "./registerProductVariantPicker";
37
+ export * from "./registerCategoryCollection";
38
+ export * from "./registerCategoryField";
25
39
  export declare function registerAll(loader?: Registerable): void;
@@ -0,0 +1,5 @@
1
+ import type { SWRHook } from '../utils/types';
2
+ import type { GetProductHook } from '../types/product';
3
+ export declare type UseProduct<H extends SWRHook<GetProductHook<any>> = SWRHook<GetProductHook>> = ReturnType<H['useHook']>;
4
+ declare const useProduct: UseProduct;
5
+ export default useProduct;
@@ -5,5 +5,6 @@ interface AddToCartButtonProps {
5
5
  children?: React.ReactNode;
6
6
  }
7
7
  export declare const addToCartButtonMeta: ComponentMeta<AddToCartButtonProps>;
8
+ export declare function AddToCartButton(props: AddToCartButtonProps): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
8
9
  export declare function registerAddToCartButton(loader?: Registerable, customAddToCartButtonMeta?: ComponentMeta<AddToCartButtonProps>): void;
9
10
  export {};
@@ -0,0 +1,11 @@
1
+ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
+ import { Registerable } from "./registerable";
3
+ interface CartProps {
4
+ className?: string;
5
+ field: string;
6
+ hideIfIsEmpty?: boolean;
7
+ }
8
+ export declare const cartMeta: ComponentMeta<CartProps>;
9
+ export declare function CartComponent(props: CartProps): JSX.Element | null;
10
+ export declare function registerCart(loader?: Registerable, customCartMeta?: ComponentMeta<CartProps>): void;
11
+ export {};
@@ -0,0 +1,19 @@
1
+ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
+ import React from "react";
3
+ import { Registerable } from "./registerable";
4
+ import { Category } from "./types/site";
5
+ interface CategoryCollectionProps {
6
+ className?: string;
7
+ children?: React.ReactNode;
8
+ emptyMessage?: React.ReactNode;
9
+ loadingMessage?: React.ReactNode;
10
+ noLayout?: boolean;
11
+ category?: string;
12
+ setControlContextData?: (data: {
13
+ categories: Category[];
14
+ }) => void;
15
+ }
16
+ export declare const categoryCollectionMeta: ComponentMeta<CategoryCollectionProps>;
17
+ export declare function CategoryCollection(props: CategoryCollectionProps): JSX.Element | null;
18
+ export declare function registerCategoryCollection(loader?: Registerable, customCategoryCollectionMeta?: ComponentMeta<CategoryCollectionProps>): void;
19
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
+ import { Registerable } from "./registerable";
3
+ interface CategoryFieldProps {
4
+ className?: string;
5
+ field?: string;
6
+ }
7
+ export declare const categoryFieldMeta: ComponentMeta<CategoryFieldProps>;
8
+ export declare function CategoryField(props: CategoryFieldProps): JSX.Element;
9
+ export declare function registerCategoryField(loader?: Registerable, customCategoryFieldMeta?: ComponentMeta<CategoryFieldProps>): void;
10
+ export {};
@@ -0,0 +1,13 @@
1
+ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
+ import { Registerable } from "./registerable";
3
+ import React from "react";
4
+ interface ProductBoxProps {
5
+ className?: string;
6
+ children?: React.ReactNode;
7
+ id?: string;
8
+ noLayout?: boolean;
9
+ }
10
+ export declare const productBoxMeta: ComponentMeta<ProductBoxProps>;
11
+ export declare function ProductBox(props: ProductBoxProps): JSX.Element;
12
+ export declare function registerProductBox(loader?: Registerable, customProductBoxMeta?: ComponentMeta<ProductBoxProps>): void;
13
+ export {};
@@ -2,18 +2,25 @@ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
2
  import { Registerable } from "./registerable";
3
3
  import React from "react";
4
4
  import { Brand, Category } from "./types/site";
5
+ import { CommerceExtraFeatures } from "./utils/types";
5
6
  interface ProductCollectionProps {
6
7
  className?: string;
7
8
  children?: React.ReactNode;
9
+ emptyMessage?: React.ReactNode;
10
+ loadingMessage?: React.ReactNode;
8
11
  count?: number;
9
12
  category?: string;
13
+ includeSubCategories?: boolean;
10
14
  brand?: string;
11
15
  noLayout?: boolean;
12
16
  setControlContextData?: (data: {
13
17
  categories: Category[];
14
18
  brands: Brand[];
19
+ features?: CommerceExtraFeatures;
20
+ hasCategoryCtx?: boolean;
15
21
  }) => void;
16
22
  }
17
23
  export declare const productCollectionMeta: ComponentMeta<ProductCollectionProps>;
24
+ export declare function ProductCollection(props: ProductCollectionProps): JSX.Element | null;
18
25
  export declare function registerProductCollection(loader?: Registerable, customProductCollectionMeta?: ComponentMeta<ProductCollectionProps>): void;
19
26
  export {};
@@ -0,0 +1,12 @@
1
+ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
+ import { Registerable } from "./registerable";
3
+ import React from "react";
4
+ interface ProductLinkProps {
5
+ className?: string;
6
+ children?: React.ReactNode;
7
+ linkDest?: string;
8
+ }
9
+ export declare const productLinkMeta: ComponentMeta<ProductLinkProps>;
10
+ export declare function ProductLink(props: ProductLinkProps): JSX.Element;
11
+ export declare function registerProductLink(loader?: Registerable, customProductLinkMeta?: ComponentMeta<ProductLinkProps>): void;
12
+ export {};
@@ -4,6 +4,6 @@ interface ProductPriceProps {
4
4
  className: string;
5
5
  }
6
6
  export declare const productPriceMeta: ComponentMeta<ProductPriceProps>;
7
- export declare function ProductPrice(props: ProductPriceProps): JSX.Element;
7
+ export declare function ProductPriceComponent(props: ProductPriceProps): JSX.Element;
8
8
  export declare function registerProductPrice(loader?: Registerable, customProductPriceMeta?: ComponentMeta<ProductPriceProps>): void;
9
9
  export {};
@@ -1,3 +1,4 @@
1
+ import { Category } from "./site";
1
2
  export declare type ProductImage = {
2
3
  url: string;
3
4
  alt?: string;
@@ -48,10 +49,16 @@ export declare type SearchProductsBody = {
48
49
  sort?: string;
49
50
  locale?: string;
50
51
  count?: number;
52
+ includeSubCategories?: boolean;
53
+ categories?: Category[];
54
+ };
55
+ export declare type GetProductBody = {
56
+ id?: string;
51
57
  };
52
58
  export declare type ProductTypes = {
53
59
  product: Product;
54
60
  searchBody: SearchProductsBody;
61
+ getProductBody: GetProductBody;
55
62
  };
56
63
  export declare type SearchProductsHook<T extends ProductTypes = ProductTypes> = {
57
64
  data: {
@@ -62,6 +69,12 @@ export declare type SearchProductsHook<T extends ProductTypes = ProductTypes> =
62
69
  input: T['searchBody'];
63
70
  fetcherInput: T['searchBody'];
64
71
  };
72
+ export declare type GetProductHook<T extends ProductTypes = ProductTypes> = {
73
+ data: T['product'] | null;
74
+ body: T['getProductBody'];
75
+ input: T['getProductBody'];
76
+ fetcherInput: T['getProductBody'];
77
+ };
65
78
  export declare type ProductsSchema<T extends ProductTypes = ProductTypes> = {
66
79
  endpoint: {
67
80
  options: {};
@@ -3,6 +3,7 @@ export declare type Category = {
3
3
  name: string;
4
4
  slug: string;
5
5
  path: string;
6
+ isEmpty?: boolean;
6
7
  };
7
8
  export declare type Brand = {
8
9
  name: string;
@@ -16,6 +17,7 @@ export declare type SiteTypes = {
16
17
  category: Category;
17
18
  brand: Brand;
18
19
  searchBody: SearchSiteInfoBody;
20
+ getCategoriesBody: GetCategoriesBody;
19
21
  };
20
22
  export declare type GetSiteInfoOperation<T extends SiteTypes = SiteTypes> = {
21
23
  data: {
@@ -23,10 +25,15 @@ export declare type GetSiteInfoOperation<T extends SiteTypes = SiteTypes> = {
23
25
  brands: T['brand'][];
24
26
  };
25
27
  };
28
+ export declare type GetCategoriesBody = {
29
+ topologicalSort?: boolean;
30
+ addIsEmptyField?: boolean;
31
+ categoryId?: string;
32
+ };
26
33
  export declare type GetCategoriesHook<T extends SiteTypes = SiteTypes> = {
27
- data: T['category'][] | null;
28
- input: {};
29
- fetcherInput: {};
34
+ data: T['category'][];
35
+ input: T['getCategoriesBody'];
36
+ fetcherInput: T['getCategoriesBody'];
30
37
  swrState: {
31
38
  isEmpty: boolean;
32
39
  };
@@ -0,0 +1,2 @@
1
+ import { Product } from "../types/product";
2
+ export declare const defaultProduct: Product;
@@ -92,4 +92,6 @@ export declare type MutationHookContext<H extends MutationSchemaBase> = {
92
92
  }) => H['data'] | Promise<H['data']>;
93
93
  };
94
94
  export declare type SwrOptions<Data, Input = null, Result = any> = SWRConfiguration<Data, CommerceError, HookFetcher<Data, Input, Result>>;
95
- export declare const x: () => number;
95
+ export declare type CommerceExtraFeatures = {
96
+ includeSubCategories?: boolean;
97
+ };
@@ -0,0 +1 @@
1
+ export declare const useCommerceExtraFeatures: () => import("./types").CommerceExtraFeatures | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicpkgs/commerce",
3
- "version": "0.0.6",
3
+ "version": "0.0.9",
4
4
  "description": "Plasmic registration calls for commerce components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "analyze": "size-limit --why"
19
19
  },
20
20
  "devDependencies": {
21
- "@plasmicapp/host": "1.0.21",
21
+ "@plasmicapp/host": "^1.0.38",
22
22
  "@size-limit/preset-small-lib": "^4.11.0",
23
23
  "@types/js-cookie": "^3.0.1",
24
24
  "@types/node": "^14.0.26",
@@ -39,5 +39,5 @@
39
39
  "react-hook-form": "^7.28.0",
40
40
  "swr": "^1.2.2"
41
41
  },
42
- "gitHead": "f73c954b181396cce9310f47a9c8def5ba317b86"
42
+ "gitHead": "262f227330daf125c84c8a4b5a64891c3c4981be"
43
43
  }
@@ -1,9 +0,0 @@
1
- import { ComponentMeta } from "@plasmicapp/host/registerComponent";
2
- import { Registerable } from "./registerable";
3
- interface UseCartProps {
4
- className?: string;
5
- field: string;
6
- }
7
- export declare const useCartMeta: ComponentMeta<UseCartProps>;
8
- export declare function registerUseCart(loader?: Registerable, customUseCartMeta?: ComponentMeta<UseCartProps>): void;
9
- export {};