@plasmicpkgs/commerce 0.0.1

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.
Files changed (93) hide show
  1. package/README.md +0 -0
  2. package/dist/auth/use-login.d.ts +6 -0
  3. package/dist/auth/use-login.js +9 -0
  4. package/dist/auth/use-logout.d.ts +6 -0
  5. package/dist/auth/use-logout.js +9 -0
  6. package/dist/auth/use-signup.d.ts +6 -0
  7. package/dist/auth/use-signup.js +9 -0
  8. package/dist/cart/use-add-item.d.ts +6 -0
  9. package/dist/cart/use-add-item.js +9 -0
  10. package/dist/cart/use-cart.d.ts +6 -0
  11. package/dist/cart/use-cart.js +18 -0
  12. package/dist/cart/use-remove-item.d.ts +6 -0
  13. package/dist/cart/use-remove-item.js +9 -0
  14. package/dist/cart/use-update-item.d.ts +6 -0
  15. package/dist/cart/use-update-item.js +9 -0
  16. package/dist/checkout/use-checkout.d.ts +6 -0
  17. package/dist/checkout/use-checkout.js +18 -0
  18. package/dist/checkout/use-submit-checkout.d.ts +6 -0
  19. package/dist/checkout/use-submit-checkout.js +9 -0
  20. package/dist/contexts.d.ts +7 -0
  21. package/dist/contexts.js +46 -0
  22. package/dist/customer/address/use-add-item.d.ts +6 -0
  23. package/dist/customer/address/use-add-item.js +9 -0
  24. package/dist/customer/address/use-addresses.d.ts +6 -0
  25. package/dist/customer/address/use-addresses.js +18 -0
  26. package/dist/customer/address/use-remove-item.d.ts +6 -0
  27. package/dist/customer/address/use-remove-item.js +9 -0
  28. package/dist/customer/address/use-update-item.d.ts +6 -0
  29. package/dist/customer/address/use-update-item.js +9 -0
  30. package/dist/customer/card/use-add-item.d.ts +6 -0
  31. package/dist/customer/card/use-add-item.js +9 -0
  32. package/dist/customer/card/use-cards.d.ts +6 -0
  33. package/dist/customer/card/use-cards.js +18 -0
  34. package/dist/customer/card/use-remove-item.d.ts +6 -0
  35. package/dist/customer/card/use-remove-item.js +9 -0
  36. package/dist/customer/card/use-update-item.d.ts +6 -0
  37. package/dist/customer/card/use-update-item.js +9 -0
  38. package/dist/customer/use-customer.d.ts +6 -0
  39. package/dist/customer/use-customer.js +9 -0
  40. package/dist/index.d.ts +71 -0
  41. package/dist/index.js +29 -0
  42. package/dist/product/use-price.d.ts +26 -0
  43. package/dist/product/use-price.js +33 -0
  44. package/dist/product/use-search.d.ts +6 -0
  45. package/dist/product/use-search.js +9 -0
  46. package/dist/registerProductCollection.d.ts +11 -0
  47. package/dist/registerProductCollection.js +42 -0
  48. package/dist/registerProductImage.d.ts +13 -0
  49. package/dist/registerProductImage.js +37 -0
  50. package/dist/registerable.d.ts +4 -0
  51. package/dist/registerable.js +0 -0
  52. package/dist/tsconfig.tsbuildinfo +2970 -0
  53. package/dist/types/cart.d.ts +157 -0
  54. package/dist/types/cart.js +0 -0
  55. package/dist/types/checkout.d.ts +57 -0
  56. package/dist/types/checkout.js +0 -0
  57. package/dist/types/common.d.ts +13 -0
  58. package/dist/types/common.js +0 -0
  59. package/dist/types/customer/address.d.ts +110 -0
  60. package/dist/types/customer/address.js +0 -0
  61. package/dist/types/customer/card.d.ts +113 -0
  62. package/dist/types/customer/card.js +0 -0
  63. package/dist/types/customer/index.d.ts +24 -0
  64. package/dist/types/customer/index.js +2 -0
  65. package/dist/types/index.d.ts +12 -0
  66. package/dist/types/index.js +11 -0
  67. package/dist/types/login.d.ts +27 -0
  68. package/dist/types/login.js +0 -0
  69. package/dist/types/logout.d.ts +17 -0
  70. package/dist/types/logout.js +0 -0
  71. package/dist/types/page.d.ts +24 -0
  72. package/dist/types/page.js +0 -0
  73. package/dist/types/product.d.ts +99 -0
  74. package/dist/types/product.js +0 -0
  75. package/dist/types/signup.d.ts +23 -0
  76. package/dist/types/signup.js +0 -0
  77. package/dist/types/site.d.ts +17 -0
  78. package/dist/types/site.js +0 -0
  79. package/dist/types/wishlist.d.ts +83 -0
  80. package/dist/types/wishlist.js +0 -0
  81. package/dist/utils/default-fetcher.d.ts +4 -0
  82. package/dist/utils/default-fetcher.js +3 -0
  83. package/dist/utils/define-property.d.ts +21 -0
  84. package/dist/utils/define-property.js +4 -0
  85. package/dist/utils/errors.d.ts +27 -0
  86. package/dist/utils/errors.js +24 -0
  87. package/dist/utils/types.d.ts +94 -0
  88. package/dist/utils/types.js +0 -0
  89. package/dist/utils/use-data.d.ts +12 -0
  90. package/dist/utils/use-data.js +43 -0
  91. package/dist/utils/use-hook.d.ts +6 -0
  92. package/dist/utils/use-hook.js +37 -0
  93. package/package.json +42 -0
@@ -0,0 +1,42 @@
1
+ import registerComponent from "@plasmicapp/host/registerComponent";
2
+ import React from "react";
3
+ import useSWR from "swr";
4
+ import { ProductCollectionContext } from "./contexts";
5
+ export const productCollectionMeta = {
6
+ name: "PlasmicCommercePkgs: ProductCollection",
7
+ displayName: "Product Collection",
8
+ props: {
9
+ count: {
10
+ type: "number",
11
+ description: "Set the number of products in the collection",
12
+ defaultValueHint: 6
13
+ },
14
+ children: {
15
+ type: "slot",
16
+ defaultValue: {
17
+ type: "text",
18
+ value: "Text"
19
+ }
20
+ },
21
+ },
22
+ importPath: "commerce-providers",
23
+ importName: "ProductCollection",
24
+ };
25
+ export function ProductCollection(props) {
26
+ const { children, count = 6 } = props;
27
+ const { data: products } = useSWR("/api/catalog/products", async () => {
28
+ if (typeof window !== "undefined") {
29
+ const response = await fetch(`/api/catalog/products`);
30
+ return await response.json();
31
+ }
32
+ });
33
+ if (products === undefined) {
34
+ return React.createElement("p", null, "Loading...");
35
+ }
36
+ console.log(count);
37
+ return (React.createElement(ProductCollectionContext.Provider, { value: products }, children));
38
+ }
39
+ export function registerProductCollection(loader, customProductCollection) {
40
+ const doRegisterComponent = (...args) => loader ? loader.registerComponent(...args) : registerComponent(...args);
41
+ doRegisterComponent(ProductCollection, customProductCollection ?? productCollectionMeta);
42
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { ComponentMeta } from "@plasmicapp/host/registerComponent";
3
+ import { Registerable } from "./registerable";
4
+ export declare const productImageMeta: ComponentMeta<ProductImageProps>;
5
+ interface ProductImageProps {
6
+ className: string;
7
+ customStyle?: object;
8
+ useProductPlaceholder?: boolean;
9
+ imageIndex?: number;
10
+ }
11
+ export declare function ProductImage(props: ProductImageProps): JSX.Element;
12
+ export declare function registerProductImage(loader?: Registerable, customProductImage?: ComponentMeta<ProductImageProps>): void;
13
+ export {};
@@ -0,0 +1,37 @@
1
+ import registerComponent from "@plasmicapp/host/registerComponent";
2
+ import React from "react";
3
+ import { useProduct } from "./contexts";
4
+ export const productImageMeta = {
5
+ name: "CommerceProviders_ProductImage",
6
+ displayName: "Product Image",
7
+ props: {
8
+ customStyle: {
9
+ type: "object",
10
+ description: "Set custom css",
11
+ },
12
+ useProductPlaceholder: {
13
+ type: "boolean",
14
+ description: "Use a product placeholder to design your components"
15
+ },
16
+ imageIndex: {
17
+ type: "number",
18
+ description: "Set the image index of your product",
19
+ defaultValueHint: 0,
20
+ }
21
+ },
22
+ importPath: "commerce-providers",
23
+ importName: "ProductImage",
24
+ };
25
+ export function ProductImage(props) {
26
+ const { className, customStyle, useProductPlaceholder, imageIndex = 0 } = props;
27
+ const product = useProduct(useProductPlaceholder);
28
+ if (!product) {
29
+ return React.createElement("p", null, "There isn't a product collection!");
30
+ }
31
+ const image = product.images[imageIndex];
32
+ return (React.createElement("img", { alt: product.name || 'Product Image', src: image?.url ?? "", loading: 'lazy', className: className, style: customStyle }));
33
+ }
34
+ export function registerProductImage(loader, customProductImage) {
35
+ const doRegisterComponent = (...args) => loader ? loader.registerComponent(...args) : registerComponent(...args);
36
+ doRegisterComponent(ProductImage, customProductImage ?? productImageMeta);
37
+ }
@@ -0,0 +1,4 @@
1
+ import registerComponent from "@plasmicapp/host/registerComponent";
2
+ export declare type Registerable = {
3
+ registerComponent: typeof registerComponent;
4
+ };
File without changes