@base44/app-plugin-commerce 0.2.1 → 0.2.2

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 (55) hide show
  1. package/README.md +6 -6
  2. package/base44/agents/commerce/StoreAdmin.jsonc +1 -1
  3. package/base44/entities/commerce.OrderRefund.jsonc +1 -1
  4. package/base44/entities/commerce.PaymentGateway.jsonc +1 -1
  5. package/base44/entities/commerce.Webhook.jsonc +1 -1
  6. package/base44/functions/commerce/admin-products/entry.ts +1 -1
  7. package/base44/functions/commerce/admin-reports/entry.ts +1 -1
  8. package/base44/functions/commerce/payments/entry.ts +2 -2
  9. package/base44/functions/commerce/seed-store/defaults.ts +1 -1
  10. package/base44/functions/commerce/storefront-catalog/entry.ts +1 -1
  11. package/base44/functions/commerce/storefront-checkout/entry.ts +1 -1
  12. package/base44/shared/commerce/card-payment.stripe.ts +29 -9
  13. package/base44/shared/commerce/card-payment.ts +1 -1
  14. package/base44/shared/commerce/payments.ts +2 -2
  15. package/base44/shared/commerce/scan.ts +1 -1
  16. package/base44/shared/commerce/sequence.ts +2 -2
  17. package/package.json +1 -1
  18. package/scripts/install.js +1 -1
  19. package/skills/commerce/SKILL.md +36 -26
  20. package/skills/commerce/docs/api-storefront.md +6 -6
  21. package/skills/commerce/install/01-install.md +2 -2
  22. package/skills/commerce/install/02-storefront.md +355 -99
  23. package/skills/commerce/install/03-data.md +5 -5
  24. package/skills/commerce/references/catalog-rendering.md +6 -6
  25. package/skills/commerce/references/online-payments.md +5 -6
  26. package/skills/commerce/references/reviews.md +5 -5
  27. package/src/commerce/admin/README.md +6 -3
  28. package/src/commerce/admin/layout/AuthGuard.jsx +1 -1
  29. package/src/commerce/admin/pages/products/Reviews.jsx +1 -1
  30. package/src/commerce/admin/pages/settings/InventorySettings.jsx +1 -1
  31. package/src/commerce/admin/pages/settings/PaymentsSettings.jsx +1 -1
  32. package/src/commerce/storefront/index.js +45 -33
  33. package/src/commerce/storefront/useCartLine.js +37 -0
  34. package/src/commerce/storefront/useCheckout.jsx +18 -6
  35. package/src/commerce/storefront/useOrderReturn.js +36 -10
  36. package/src/commerce/storefront/useProduct.js +68 -0
  37. package/src/commerce/utils/index.js +9 -6
  38. package/src/commerce/utils/shipping-promos.js +2 -2
  39. package/src/commerce/utils/specs.js +26 -0
  40. package/src/commerce/utils/variants.js +49 -2
  41. package/src/commerce/storefront/blocks/AddToCartBlock.jsx +0 -86
  42. package/src/commerce/storefront/blocks/AddressFieldsBlock.jsx +0 -96
  43. package/src/commerce/storefront/blocks/BreadcrumbsBlock.jsx +0 -52
  44. package/src/commerce/storefront/blocks/CartLinesBlock.jsx +0 -98
  45. package/src/commerce/storefront/blocks/CheckoutBlock.jsx +0 -247
  46. package/src/commerce/storefront/blocks/CouponFieldBlock.jsx +0 -84
  47. package/src/commerce/storefront/blocks/OrderReceivedBlock.jsx +0 -129
  48. package/src/commerce/storefront/blocks/ProductGalleryBlock.jsx +0 -66
  49. package/src/commerce/storefront/blocks/ProductSpecsBlock.jsx +0 -33
  50. package/src/commerce/storefront/blocks/ProductStripBlock.jsx +0 -55
  51. package/src/commerce/storefront/blocks/QuantityStepper.jsx +0 -62
  52. package/src/commerce/storefront/blocks/ReviewsBlock.jsx +0 -191
  53. package/src/commerce/storefront/blocks/TotalsBlock.jsx +0 -42
  54. package/src/commerce/storefront/blocks/VariantSelectorBlock.jsx +0 -81
  55. package/src/commerce/storefront/blocks/index.js +0 -44
@@ -1,81 +0,0 @@
1
- import React from "react";
2
- import { OPTION_OUT_OF_STOCK, OPTION_UNAVAILABLE } from "@/commerce/utils";
3
-
4
- /**
5
- * One control per attribute axis — Size, Color — with availability shown rather
6
- * than hidden.
7
- *
8
- * const { view, pick } = useProduct(slug);
9
- * <VariantSelectorBlock view={view} onPick={pick} />
10
- *
11
- * The rule it encodes: **a selector per axis, never a list of variations**, and
12
- * an option that isn't buyable is rendered *disabled*, not removed — a customer
13
- * who can't see that a size exists assumes the store doesn't carry it. Pass
14
- * `renderOption` for swatches or any other option UI.
15
- *
16
- * @param {{view: object, onPick: (axisKey: string, option: string) => void,
17
- * className?: string,
18
- * renderOption?: (o: {axis: object, option: string, selected: boolean,
19
- * state: string, disabled: boolean, pick: () => void}) => React.ReactNode}} props
20
- */
21
- export function VariantSelectorBlock({ view, onPick, className = "", renderOption }) {
22
- if (!view?.isVariable || !view.axes?.length) return null;
23
-
24
- return (
25
- <div data-commerce="variant-selector" className={`space-y-4 ${className}`}>
26
- {view.axes.map((axis) => (
27
- <fieldset key={axis.key} data-commerce="variant-axis" data-commerce-axis={axis.name}>
28
- <legend className="mb-2 text-xs uppercase tracking-wide text-muted-foreground">
29
- {axis.name}
30
- {view.selection?.[axis.key] ? `: ${view.selection[axis.key]}` : ""}
31
- </legend>
32
- <div className="flex flex-wrap gap-2">
33
- {axis.options.map((option) => {
34
- const state = view.availability?.[axis.key]?.[option] ?? "available";
35
- const selected = view.selection?.[axis.key] === option;
36
- const disabled = state === OPTION_UNAVAILABLE;
37
- const pick = () => onPick?.(axis.key, option);
38
-
39
- if (renderOption) {
40
- return (
41
- <React.Fragment key={option}>
42
- {renderOption({ axis, option, selected, state, disabled, pick })}
43
- </React.Fragment>
44
- );
45
- }
46
- return (
47
- <button
48
- key={option}
49
- type="button"
50
- data-commerce="variant-option"
51
- data-commerce-state={state}
52
- aria-pressed={selected}
53
- disabled={disabled}
54
- onClick={pick}
55
- title={
56
- state === OPTION_OUT_OF_STOCK
57
- ? "Out of stock"
58
- : disabled
59
- ? "Not available with your other choices"
60
- : undefined
61
- }
62
- className={`border px-3 py-1.5 text-sm ${
63
- selected ? "border-foreground" : "border-border"
64
- } ${state === OPTION_OUT_OF_STOCK ? "line-through opacity-60" : ""} disabled:opacity-40`}
65
- >
66
- {option}
67
- </button>
68
- );
69
- })}
70
- </div>
71
- </fieldset>
72
- ))}
73
-
74
- {view.missingAxes?.length > 0 && (
75
- <p data-commerce="variant-hint" className="text-xs text-muted-foreground">
76
- Choose {view.missingAxes.map((a) => a.name.toLowerCase()).join(" and ")} to continue.
77
- </p>
78
- )}
79
- </div>
80
- );
81
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * Storefront blocks — working default markup for the parts of a shopfront that
3
- * are the same in every store.
4
- *
5
- * The split is deliberate:
6
- *
7
- * - **Identity surfaces are yours**: home, collection/grid, the product page's
8
- * layout, the product card, the theme. That is where "make it look like X"
9
- * lives, and no markup ships for it.
10
- * - **Commodity surfaces ship as blocks**: checkout, cart lines, totals, the
11
- * coupon field, reviews, order-received, and the product page's internals
12
- * (variant selector, gallery, specs, breadcrumbs, strips). Every store's
13
- * version of these is functionally identical, and hand-writing them is where
14
- * storefront bugs cluster.
15
- *
16
- * Blocks are thin compositions of the hooks in this package, styled by
17
- * inheritance: semantic markup, theme tokens (`border-border`, `text-muted-
18
- * foreground`, `bg-primary`), and a stable `data-commerce="…"` attribute on
19
- * every meaningful element — so your CSS can restyle any part of them, and
20
- * tests can target them. Each takes `className` and, where there is more than
21
- * one region, `slots`. When a design needs different *structure*, drop to the
22
- * hooks the block uses and rewrite that one region.
23
- *
24
- * A whole checkout page:
25
- *
26
- * import { CheckoutBlock } from "@/commerce/storefront";
27
- * export default function Checkout() {
28
- * return <main className="mx-auto max-w-3xl px-6 py-16"><CheckoutBlock /></main>;
29
- * }
30
- */
31
- export { CartLinesBlock } from "./CartLinesBlock";
32
- export { CheckoutBlock } from "./CheckoutBlock";
33
- export { AddressFieldsBlock } from "./AddressFieldsBlock";
34
- export { CouponFieldBlock } from "./CouponFieldBlock";
35
- export { TotalsBlock } from "./TotalsBlock";
36
- export { QuantityStepper } from "./QuantityStepper";
37
- export { OrderReceivedBlock } from "./OrderReceivedBlock";
38
- export { ReviewsBlock } from "./ReviewsBlock";
39
- export { VariantSelectorBlock } from "./VariantSelectorBlock";
40
- export { AddToCartBlock } from "./AddToCartBlock";
41
- export { ProductGalleryBlock } from "./ProductGalleryBlock";
42
- export { ProductSpecsBlock } from "./ProductSpecsBlock";
43
- export { BreadcrumbsBlock } from "./BreadcrumbsBlock";
44
- export { ProductStripBlock } from "./ProductStripBlock";