@aglyn/plugins-commerce 1.15.2 → 1.16.0

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 (212) hide show
  1. package/README.md +1 -1
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +2 -1
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/console/payments-settings-card.component.js +6 -1
  6. package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
  7. package/src/lib/components/console/pos/pos-api.d.ts +5 -0
  8. package/src/lib/components/console/pos/pos-api.js.map +1 -1
  9. package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +2 -0
  10. package/src/lib/components/console/pos/pos-tender-dialogs.component.js +13 -6
  11. package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
  12. package/src/lib/components/console/pos/pos-tender-panel.component.js +7 -4
  13. package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
  14. package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
  15. package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
  16. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  17. package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
  18. package/src/lib/components/console/product-builder-fields.component.js +195 -0
  19. package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
  20. package/src/lib/components/console/product-editor-dialog.component.js +35 -2
  21. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  22. package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
  23. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  24. package/src/lib/components/console/quote-messages.component.d.ts +21 -0
  25. package/src/lib/components/console/quote-messages.component.js +185 -0
  26. package/src/lib/components/console/quote-messages.component.js.map +1 -0
  27. package/src/lib/components/console/quote-pay-link.component.js +1 -1
  28. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  29. package/src/lib/components/console/quote-proofs.component.js +30 -3
  30. package/src/lib/components/console/quote-proofs.component.js.map +1 -1
  31. package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
  32. package/src/lib/components/console/quote-settings-card.component.js +154 -24
  33. package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
  34. package/src/lib/components/product-builder-context.d.ts +22 -0
  35. package/src/lib/components/product-builder-context.js +21 -0
  36. package/src/lib/components/product-builder-context.js.map +1 -0
  37. package/src/lib/components/product-builder-mockup.d.ts +42 -0
  38. package/src/lib/components/product-builder-mockup.js +120 -0
  39. package/src/lib/components/product-builder-mockup.js.map +1 -0
  40. package/src/lib/components/product-builder-sample.d.ts +63 -0
  41. package/src/lib/components/product-builder-sample.js +96 -0
  42. package/src/lib/components/product-builder-sample.js.map +1 -0
  43. package/src/lib/components/product-choice-cards.d.ts +51 -0
  44. package/src/lib/components/product-choice-cards.js +311 -0
  45. package/src/lib/components/product-choice-cards.js.map +1 -0
  46. package/src/lib/components/product-detail-panels.d.ts +42 -0
  47. package/src/lib/components/product-detail-panels.js +185 -0
  48. package/src/lib/components/product-detail-panels.js.map +1 -0
  49. package/src/lib/components/product-detail.d.ts +20 -12
  50. package/src/lib/components/product-detail.js +136 -221
  51. package/src/lib/components/product-detail.js.map +1 -1
  52. package/src/lib/components/product-grid.d.ts +7 -0
  53. package/src/lib/components/product-grid.js +11 -8
  54. package/src/lib/components/product-grid.js.map +1 -1
  55. package/src/lib/components/product-options-field-body.d.ts +9 -8
  56. package/src/lib/components/product-options-field-body.js +152 -3
  57. package/src/lib/components/product-options-field-body.js.map +1 -1
  58. package/src/lib/components/product-options-field.js +1 -1
  59. package/src/lib/components/product-options-field.js.map +1 -1
  60. package/src/lib/components/product-photo-fit.d.ts +49 -0
  61. package/src/lib/components/product-photo-fit.js +58 -0
  62. package/src/lib/components/product-photo-fit.js.map +1 -0
  63. package/src/lib/components/product-restock-notify.d.ts +12 -0
  64. package/src/lib/components/product-restock-notify.js +86 -0
  65. package/src/lib/components/product-restock-notify.js.map +1 -0
  66. package/src/lib/components/quote-messages-panel.d.ts +21 -0
  67. package/src/lib/components/quote-messages-panel.js +191 -0
  68. package/src/lib/components/quote-messages-panel.js.map +1 -0
  69. package/src/lib/components/quote-page-body.js +15 -1
  70. package/src/lib/components/quote-page-body.js.map +1 -1
  71. package/src/lib/components/quote-proof-panel.d.ts +6 -3
  72. package/src/lib/components/quote-proof-panel.js +139 -14
  73. package/src/lib/components/quote-proof-panel.js.map +1 -1
  74. package/src/lib/components/related-products.d.ts +7 -0
  75. package/src/lib/components/related-products.js +8 -6
  76. package/src/lib/components/related-products.js.map +1 -1
  77. package/src/lib/constants/quote-page.d.ts +8 -0
  78. package/src/lib/constants/quote-page.js +11 -0
  79. package/src/lib/constants/quote-page.js.map +1 -1
  80. package/src/lib/model/commerce-cart.d.ts +6 -1
  81. package/src/lib/model/commerce-cart.js +5 -1
  82. package/src/lib/model/commerce-cart.js.map +1 -1
  83. package/src/lib/model/commerce-invoices.js +5 -1
  84. package/src/lib/model/commerce-invoices.js.map +1 -1
  85. package/src/lib/model/commerce-pos-ops.d.ts +3 -0
  86. package/src/lib/model/commerce-pos-ops.js +3 -0
  87. package/src/lib/model/commerce-pos-ops.js.map +1 -1
  88. package/src/lib/model/commerce-pos.d.ts +8 -0
  89. package/src/lib/model/commerce-pos.js.map +1 -1
  90. package/src/lib/model/commerce-quote-messages.d.ts +106 -0
  91. package/src/lib/model/commerce-quote-messages.js +146 -0
  92. package/src/lib/model/commerce-quote-messages.js.map +1 -0
  93. package/src/lib/model/commerce-quote-pay.d.ts +31 -2
  94. package/src/lib/model/commerce-quote-pay.js +31 -7
  95. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  96. package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
  97. package/src/lib/model/commerce-quote-proofs.js +73 -18
  98. package/src/lib/model/commerce-quote-proofs.js.map +1 -1
  99. package/src/lib/model/commerce-quote-request.d.ts +14 -4
  100. package/src/lib/model/commerce-quote-request.js +25 -2
  101. package/src/lib/model/commerce-quote-request.js.map +1 -1
  102. package/src/lib/model/commerce-quotes.d.ts +56 -3
  103. package/src/lib/model/commerce-quotes.js +47 -2
  104. package/src/lib/model/commerce-quotes.js.map +1 -1
  105. package/src/lib/model/commerce.d.ts +12 -1
  106. package/src/lib/model/commerce.js.map +1 -1
  107. package/src/lib/model/index.d.ts +1 -0
  108. package/src/lib/model/index.js +1 -0
  109. package/src/lib/model/index.js.map +1 -1
  110. package/src/lib/model/pos-cellular.d.ts +5 -0
  111. package/src/lib/model/pos-cellular.js.map +1 -1
  112. package/src/lib/model/product-card-rules.d.ts +41 -0
  113. package/src/lib/model/product-card-rules.js +90 -0
  114. package/src/lib/model/product-card-rules.js.map +1 -0
  115. package/src/lib/model/product-modifiers.d.ts +11 -0
  116. package/src/lib/model/product-modifiers.js +10 -0
  117. package/src/lib/model/product-modifiers.js.map +1 -1
  118. package/src/lib/model/product-write.d.ts +3 -0
  119. package/src/lib/server/billing-webhook.js +6 -2
  120. package/src/lib/server/billing-webhook.js.map +1 -1
  121. package/src/lib/server/cancel-order.js +15 -0
  122. package/src/lib/server/cancel-order.js.map +1 -1
  123. package/src/lib/server/channel-order-updates.js +15 -1
  124. package/src/lib/server/channel-order-updates.js.map +1 -1
  125. package/src/lib/server/channel-orders.js +20 -0
  126. package/src/lib/server/channel-orders.js.map +1 -1
  127. package/src/lib/server/checkout.js +1 -1
  128. package/src/lib/server/checkout.js.map +1 -1
  129. package/src/lib/server/local-fulfillment.js +1 -1
  130. package/src/lib/server/local-fulfillment.js.map +1 -1
  131. package/src/lib/server/pos-cellular-billing.d.ts +1 -1
  132. package/src/lib/server/pos-cellular-billing.js +2 -1
  133. package/src/lib/server/pos-cellular-billing.js.map +1 -1
  134. package/src/lib/server/pos-cellular.d.ts +3 -1
  135. package/src/lib/server/pos-cellular.js +15 -8
  136. package/src/lib/server/pos-cellular.js.map +1 -1
  137. package/src/lib/server/pos-offline-sync.d.ts +3 -3
  138. package/src/lib/server/pos-offline-sync.js +17 -4
  139. package/src/lib/server/pos-offline-sync.js.map +1 -1
  140. package/src/lib/server/pos-order.js +17 -6
  141. package/src/lib/server/pos-order.js.map +1 -1
  142. package/src/lib/server/pos-payment.js +27 -11
  143. package/src/lib/server/pos-payment.js.map +1 -1
  144. package/src/lib/server/pos-reader-splash.js +10 -5
  145. package/src/lib/server/pos-reader-splash.js.map +1 -1
  146. package/src/lib/server/pos-readers.js +34 -10
  147. package/src/lib/server/pos-readers.js.map +1 -1
  148. package/src/lib/server/pos-return.js +19 -3
  149. package/src/lib/server/pos-return.js.map +1 -1
  150. package/src/lib/server/pos-stripe.d.ts +14 -0
  151. package/src/lib/server/pos-stripe.js +6 -2
  152. package/src/lib/server/pos-stripe.js.map +1 -1
  153. package/src/lib/server/pos-terminal-connection-token.js +23 -9
  154. package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
  155. package/src/lib/server/pos-terminal.d.ts +80 -14
  156. package/src/lib/server/pos-terminal.js +393 -123
  157. package/src/lib/server/pos-terminal.js.map +1 -1
  158. package/src/lib/server/product-drafts.d.ts +1 -1
  159. package/src/lib/server/product-drafts.js +4 -3
  160. package/src/lib/server/product-drafts.js.map +1 -1
  161. package/src/lib/server/product-writer.js +5 -4
  162. package/src/lib/server/product-writer.js.map +1 -1
  163. package/src/lib/server/product.d.ts +11 -0
  164. package/src/lib/server/product.js +18 -3
  165. package/src/lib/server/product.js.map +1 -1
  166. package/src/lib/server/products-write.js +4 -3
  167. package/src/lib/server/products-write.js.map +1 -1
  168. package/src/lib/server/quote-email.d.ts +26 -0
  169. package/src/lib/server/quote-email.js +73 -7
  170. package/src/lib/server/quote-email.js.map +1 -1
  171. package/src/lib/server/quote-messages.d.ts +72 -0
  172. package/src/lib/server/quote-messages.js +356 -0
  173. package/src/lib/server/quote-messages.js.map +1 -0
  174. package/src/lib/server/quote-pay.d.ts +42 -0
  175. package/src/lib/server/quote-pay.js +81 -4
  176. package/src/lib/server/quote-pay.js.map +1 -1
  177. package/src/lib/server/quote-proofs.d.ts +1 -1
  178. package/src/lib/server/quote-proofs.js +63 -19
  179. package/src/lib/server/quote-proofs.js.map +1 -1
  180. package/src/lib/server/quote.d.ts +12 -0
  181. package/src/lib/server/quote.js +44 -14
  182. package/src/lib/server/quote.js.map +1 -1
  183. package/src/lib/server/refund.js +3 -1
  184. package/src/lib/server/refund.js.map +1 -1
  185. package/src/lib/server/reserve-stock.js +9 -0
  186. package/src/lib/server/reserve-stock.js.map +1 -1
  187. package/src/lib/server/returns.js +15 -1
  188. package/src/lib/server/returns.js.map +1 -1
  189. package/src/lib/server/reviews.js +15 -0
  190. package/src/lib/server/reviews.js.map +1 -1
  191. package/src/lib/server/sold-out-drop.d.ts +58 -0
  192. package/src/lib/server/sold-out-drop.js +81 -0
  193. package/src/lib/server/sold-out-drop.js.map +1 -0
  194. package/src/lib/server/stock-levels.js +9 -0
  195. package/src/lib/server/stock-levels.js.map +1 -1
  196. package/src/lib/server/stripe-refund.d.ts +7 -0
  197. package/src/lib/server/stripe-refund.js +26 -7
  198. package/src/lib/server/stripe-refund.js.map +1 -1
  199. package/src/lib/server.js +2 -0
  200. package/src/lib/server.js.map +1 -1
  201. package/src/lib/tenant-emails.js +85 -2
  202. package/src/lib/tenant-emails.js.map +1 -1
  203. package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
  204. package/src/lib/testing/fake-seller-payment-account.js +40 -0
  205. package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
  206. package/src/lib/transfer/product-transfer.js +6 -5
  207. package/src/lib/transfer/product-transfer.js.map +1 -1
  208. package/src/lib/transfer/products.server.js +4 -3
  209. package/src/lib/transfer/products.server.js.map +1 -1
  210. package/src/lib/utils/quote-email-content.d.ts +6 -0
  211. package/src/lib/utils/quote-email-content.js +6 -3
  212. package/src/lib/utils/quote-email-content.js.map +1 -1
@@ -22,22 +22,18 @@ import { buildBeginCheckoutParams, trackEvent, trackEventBeforeNavigation } from
22
22
  import { isPaymentsNotConfigured } from "@aglyn/aglyn/app-utils/payments-configured";
23
23
  import { storefrontPaymentsNotConfiguredText } from "../constants/storefront-payments.js";
24
24
  import * as CommerceModel from "../model/index.js";
25
- import { mdiChevronDown, mdiTagOutline } from "@aglyn/shared-data-mdi";
26
- import Accordion from "@mui/material/Accordion";
27
- import AccordionDetails from "@mui/material/AccordionDetails";
28
- import AccordionSummary from "@mui/material/AccordionSummary";
25
+ import { mdiTagOutline } from "@aglyn/shared-data-mdi";
29
26
  import Alert from "@mui/material/Alert";
30
27
  import Box from "@mui/material/Box";
31
28
  import Button from "@mui/material/Button";
32
29
  import Chip from "@mui/material/Chip";
33
30
  import MenuItem from "@mui/material/MenuItem";
34
31
  import Skeleton from "@mui/material/Skeleton";
35
- import SvgIcon from "@mui/material/SvgIcon";
36
32
  import TextField from "@mui/material/TextField";
37
33
  import ToggleButton from "@mui/material/ToggleButton";
38
34
  import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
39
35
  import Typography from "@mui/material/Typography";
40
- import { Suspense, forwardRef, lazy, useEffect, useMemo, useRef, useState } from "react";
36
+ import { Children, Suspense, forwardRef, lazy, useEffect, useMemo, useRef, useState } from "react";
41
37
  import { BUNDLE_ID } from "../constants/bundle-common.js";
42
38
  import { generatePresetId } from "../utils/generate-preset-id.js";
43
39
  import { useStorefrontPurchaseEvent } from "../utils/use-storefront-purchase-event.js";
@@ -70,6 +66,16 @@ export const ID = 'product-detail';
70
66
  * The add-on pickers (AGL-4100), in their own chunk: only a product with
71
67
  * add-ons on the website downloads them.
72
68
  */ const ProductAddOns = /*#__PURE__*/ lazy(()=>import("./product-add-ons.js"));
69
+ /**
70
+ * The picture cards (AGL-4205), in their own chunk: only a page set to show
71
+ * its choices as cards downloads them.
72
+ */ const ProductChoiceCards = /*#__PURE__*/ lazy(()=>import("./product-choice-cards.js"));
73
+ /**
74
+ * The free mockup's button and the request form it opens (AGL-4205), in their
75
+ * own chunk: only a product that offers one, or the canvas, downloads it.
76
+ */ const ProductBuilderMockup = /*#__PURE__*/ lazy(()=>import("./product-builder-mockup.js"));
77
+ /** The back-in-stock alert, only on a sold-out variant (split out for AGL-4205). */ const ProductRestockNotify = /*#__PURE__*/ lazy(()=>import("./product-restock-notify.js"));
78
+ /** The Details and Shipping & returns folds (AGL-4205: split out), only where switched on. */ const ProductDetailPanels = /*#__PURE__*/ lazy(()=>import("./product-detail-panels.js"));
73
79
  /** Money on the product page, in the store's currency: `$1,250.00`, never `$1250`. */ const money = (cents)=>CommerceModel.formatOrderMoney(cents);
74
80
  /** A price in dollars as the page prints it. */ const moneyFromUsd = (priceUsd)=>money(Math.round(priceUsd * 100));
75
81
  const SAMPLE = {
@@ -199,48 +205,6 @@ const SAMPLE = {
199
205
  const first = (_ref = product == null ? void 0 : product.variants.find((variant)=>!variant.soldOut)) != null ? _ref : product == null ? void 0 : product.variants[0];
200
206
  return _extends({}, (_ref1 = first == null ? void 0 : first.options) != null ? _ref1 : {});
201
207
  }
202
- /** What the Details panel lists: only facts the product record holds. */ export function productDetailFacts(product, variant, presented) {
203
- var _product_tags;
204
- const facts = [];
205
- if (product.type === 'digital') facts.push({
206
- label: 'Format',
207
- value: 'Digital product'
208
- });
209
- if (product.type === 'service') facts.push({
210
- label: 'Format',
211
- value: 'Service'
212
- });
213
- for (const option of presented){
214
- if (option.mode !== 'hidden') {
215
- facts.push({
216
- label: option.name,
217
- value: option.values.join(', ')
218
- });
219
- }
220
- }
221
- if (variant == null ? void 0 : variant.sku) facts.push({
222
- label: 'SKU',
223
- value: variant.sku
224
- });
225
- if ((_product_tags = product.tags) == null ? void 0 : _product_tags.length) facts.push({
226
- label: 'Tags',
227
- value: product.tags.join(', ')
228
- });
229
- return facts;
230
- }
231
- /**
232
- * What the Shipping & returns panel says, from the product's kind and the
233
- * store's own return settings — never a policy the store has not set.
234
- */ export function productShippingLines(product, returns) {
235
- const lines = [];
236
- if (product.type === 'digital') lines.push('Delivered digitally after purchase — nothing ships.');
237
- else if (product.type === 'service') lines.push('A service — nothing ships.');
238
- else lines.push('Shipping is calculated at checkout.');
239
- if (returns && returns.windowDays > 0) {
240
- lines.push(`Returns accepted within ${returns.windowDays} ` + `${returns.windowDays === 1 ? 'day' : 'days'} of shipping — ` + 'request one from your order status page.');
241
- }
242
- return lines;
243
- }
244
208
  function slugFromLocation() {
245
209
  if (typeof window === 'undefined') return '';
246
210
  const match = window.location.pathname.match(/\/products\/([^/?#]+)/);
@@ -253,16 +217,20 @@ function slugFromLocation() {
253
217
  * variant. Resolves its product from the /products/{slug} URL unless a
254
218
  * slug prop pins it; sample data on the inert canvas.
255
219
  */ const ProductDetail = /*#__PURE__*/ forwardRef((props, ref)=>{
256
- var _ref, _ref1, _ref2, _ref3;
220
+ var _ref, _ref1, _ref2, _ref3, _ref4;
257
221
  var _site_pageData;
258
- const { slug: slugProp, buyLabel, hideDescription, showCoupon, showDetails, showShipping } = props, rest = _object_without_properties_loose(props, [
222
+ const { slug: slugProp, buyLabel, hideDescription, showCoupon, showDetails, showShipping, choiceStyle, mockupLabel, children } = props, rest = _object_without_properties_loose(props, [
259
223
  "slug",
260
224
  "buyLabel",
261
225
  "hideDescription",
262
226
  "showCoupon",
263
227
  "showDetails",
264
- "showShipping"
228
+ "showShipping",
229
+ "choiceStyle",
230
+ "mockupLabel",
231
+ "children"
265
232
  ]);
233
+ /** The product builder (AGL-4205): choices as picture cards. */ const cards = choiceStyle === 'cards';
266
234
  // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).
267
235
  const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [
268
236
  props['sx']
@@ -299,6 +267,21 @@ function slugFromLocation() {
299
267
  /** A discount or coupon code typed on the product page. */ const [coupon, setCoupon] = useState('');
300
268
  // A thumbnail the shopper picked; null follows the variant's own photo.
301
269
  const [activeImage, setActiveImage] = useState(null);
270
+ /** The canvas's builder sample (AGL-4205), loaded only there, only for picture cards. */ const [sampleBuilder, setSampleBuilder] = useState(null);
271
+ useEffect(()=>{
272
+ if (hostId || !cards || sampleBuilder) return;
273
+ let active = true;
274
+ void import("./product-builder-sample.js").then((module)=>{
275
+ if (active) setSampleBuilder(module.SAMPLE_BUILDER);
276
+ });
277
+ return ()=>{
278
+ active = false;
279
+ };
280
+ }, [
281
+ hostId,
282
+ cards,
283
+ sampleBuilder
284
+ ]);
302
285
  // `unconfigured` is not an `error` with softer words (AGL-2019). A store
303
286
  // with no Stripe key answers 501, and rendering that at `severity="error"`
304
287
  // tells a shopper their payment failed when nothing was ever attempted —
@@ -323,8 +306,6 @@ function slugFromLocation() {
323
306
  const [askPostal, setAskPostal] = useState(false);
324
307
  const [added, setAdded] = useState(false);
325
308
  const [wishlisted, setWishlisted] = useState(false);
326
- const [notifyEmail, setNotifyEmail] = useState('');
327
- const [notifyState, setNotifyState] = useState('idle');
328
309
  // Buyer-chosen billing (AGL-545): only meaningful when the product
329
310
  // is subscriptionOptional; defaults to a one-time purchase.
330
311
  const [billing, setBilling] = useState('once');
@@ -380,7 +361,7 @@ function slugFromLocation() {
380
361
  slug
381
362
  ]);
382
363
  const resolvedId = hostId && detail && detail !== 'missing' ? detail.id : null;
383
- const resolved = hostId ? detail === 'missing' ? null : detail : SAMPLE;
364
+ const resolved = hostId ? detail === 'missing' ? null : detail : cards ? sampleBuilder != null ? sampleBuilder : SAMPLE : SAMPLE;
384
365
  const variant = useMemo(()=>{
385
366
  var _CommerceModel_findVariant;
386
367
  if (!resolved) return undefined;
@@ -672,8 +653,6 @@ function slugFromLocation() {
672
653
  hostId
673
654
  });
674
655
  const presentedOptions = optionPresentation(resolved.options, resolved.variants);
675
- const detailFacts = showDetails ? productDetailFacts(resolved, variant, presentedOptions) : [];
676
- const shippingLines = showShipping ? productShippingLines(resolved, (seededProduct == null ? void 0 : seededProduct.id) === resolved.id ? seededReturns : undefined) : [];
677
656
  // Subscription framing (AGL-545): subscription-only products price as
678
657
  // $X/mo|/yr with a "Subscribe" button; subscriptionOptional products
679
658
  // surface the one-time/subscribe toggle instead. Same price either way
@@ -684,6 +663,13 @@ function slugFromLocation() {
684
663
  // Listed before it has a price (AGL-3676): no price to show and nothing
685
664
  // to buy; every sale door would refuse it anyway.
686
665
  const priced = typeof (variant == null ? void 0 : variant.priceUsd) === 'number';
666
+ // The add-ons are offered where they can be priced, and on a product that
667
+ // offers a free mockup, whose request carries them (AGL-4205).
668
+ // Live, the button shows only where the block holds a request form to
669
+ // open; on the canvas the block shows the space to drop one in.
670
+ const hasRequestForm = Children.toArray(children).length > 0;
671
+ const offersMockup = hostId ? resolved.mockupRequests === true && hasRequestForm : resolved.mockupRequests === true || hasRequestForm;
672
+ const showAddOns = addOnGroups.length > 0 && (priced || offersMockup);
687
673
  // schema.org Product/Offer (AGL-299). Kept ONLY for the case where this
688
674
  // block renders without server-seeded page data — the besigner preview,
689
675
  // or a page whose resolver didn't supply it. When the tenant page seeds
@@ -881,9 +867,34 @@ function slugFromLocation() {
881
867
  })
882
868
  ]
883
869
  }) : null,
870
+ cards ? // The product builder (AGL-4205): every choice a picture card.
871
+ /*#__PURE__*/ _jsx(Suspense, {
872
+ fallback: null,
873
+ children: /*#__PURE__*/ _jsx(ProductChoiceCards, {
874
+ options: presentedOptions.filter((option)=>option.mode === 'select'),
875
+ variants: resolved.variants,
876
+ selections: (_ref4 = variant == null ? void 0 : variant.options) != null ? _ref4 : selections,
877
+ onSelect: (name, value)=>{
878
+ setActiveImage(null);
879
+ setSelections((prev)=>{
880
+ var _ref;
881
+ return _extends({}, (_ref = variant == null ? void 0 : variant.options) != null ? _ref : {}, prev, {
882
+ [name]: value
883
+ });
884
+ });
885
+ },
886
+ groups: showAddOns ? addOnGroups : [],
887
+ variantId: variant == null ? void 0 : variant.id,
888
+ value: addOns,
889
+ onChange: setAddOns,
890
+ formatCents: money,
891
+ unpricedLabel: PRICE_COMING_SOON_LABEL,
892
+ disabled: Boolean(variant == null ? void 0 : variant.soldOut)
893
+ })
894
+ }) : null,
884
895
  presentedOptions.map((option)=>{
885
896
  var _selections_option_name;
886
- return option.mode === 'hidden' ? null : option.mode === 'text' ? /*#__PURE__*/ _jsx(Typography, {
897
+ return cards && option.mode === 'select' ? null : option.mode === 'hidden' ? null : option.mode === 'text' ? /*#__PURE__*/ _jsx(Typography, {
887
898
  variant: "body2",
888
899
  color: "text.secondary",
889
900
  sx: {
@@ -912,7 +923,7 @@ function slugFromLocation() {
912
923
  }, value))
913
924
  }, option.name);
914
925
  }),
915
- addOnGroups.length && priced ? /*#__PURE__*/ _jsx(Suspense, {
926
+ showAddOns && !cards ? /*#__PURE__*/ _jsx(Suspense, {
916
927
  fallback: null,
917
928
  children: /*#__PURE__*/ _jsx(ProductAddOns, {
918
929
  groups: addOnGroups,
@@ -967,10 +978,11 @@ function slugFromLocation() {
967
978
  /*#__PURE__*/ _jsx(TextField, {
968
979
  label: "Qty",
969
980
  value: quantity,
970
- onChange: (event)=>setQuantity(Math.max(1, Math.min(99, Math.round(Number(event.target.value)) || 1))),
981
+ onChange: (event)=>setQuantity(Math.max(1, Math.min(CommerceModel.CART_MAX_QUANTITY, Math.round(Number(event.target.value)) || 1))),
971
982
  size: "small",
983
+ // Four digits fit (AGL-4205): a line goes up to 9,999.
972
984
  sx: {
973
- width: 80
985
+ width: (theme)=>theme.spacing(12)
974
986
  },
975
987
  slotProps: {
976
988
  htmlInput: {
@@ -1007,10 +1019,11 @@ function slugFromLocation() {
1007
1019
  })
1008
1020
  ]
1009
1021
  }),
1010
- addOnGroups.length && priced ? /*#__PURE__*/ _jsxs(Box, {
1022
+ (addOnGroups.length || cards) && priced ? /*#__PURE__*/ _jsxs(Box, {
1011
1023
  sx: {
1012
1024
  mb: 2
1013
1025
  },
1026
+ "aria-live": "polite",
1014
1027
  children: [
1015
1028
  /*#__PURE__*/ _jsx(Typography, {
1016
1029
  variant: "subtitle1",
@@ -1024,6 +1037,25 @@ function slugFromLocation() {
1024
1037
  }) : null
1025
1038
  ]
1026
1039
  }) : null,
1040
+ offersMockup ? /*#__PURE__*/ _jsx(Suspense, {
1041
+ fallback: null,
1042
+ children: /*#__PURE__*/ _jsx(ProductBuilderMockup, {
1043
+ picks: {
1044
+ product: resolved,
1045
+ variant,
1046
+ addOns,
1047
+ quantity,
1048
+ ready: pageAddOns.ready,
1049
+ problem: pageAddOns.ready ? undefined : pageAddOns.error,
1050
+ total: priced ? money(unitCents * quantity) : undefined
1051
+ },
1052
+ label: mockupLabel,
1053
+ priced: priced,
1054
+ canvas: !hostId,
1055
+ hasRequestForm: hasRequestForm,
1056
+ children: children
1057
+ })
1058
+ }) : null,
1027
1059
  addRefusal ? /*#__PURE__*/ _jsx(Alert, {
1028
1060
  severity: "warning",
1029
1061
  sx: {
@@ -1117,60 +1149,14 @@ function slugFromLocation() {
1117
1149
  },
1118
1150
  children: message || 'Checkout is unavailable right now.'
1119
1151
  }) : null,
1120
- (variant == null ? void 0 : variant.soldOut) && hostId ? notifyState === 'done' ? /*#__PURE__*/ _jsx(Alert, {
1121
- severity: "success",
1122
- sx: {
1123
- mb: 2
1124
- },
1125
- children: 'We will email you when it is back.'
1126
- }) : /*#__PURE__*/ _jsxs(Box, {
1127
- sx: {
1128
- display: 'flex',
1129
- gap: 1,
1130
- mb: 2
1131
- },
1132
- children: [
1133
- /*#__PURE__*/ _jsx(TextField, {
1134
- placeholder: "you@example.com",
1135
- type: "email",
1136
- // Third instance of the nameless-input defect (AGL-2392).
1137
- // Named for its job rather than "Email address": this row
1138
- // appears inside a product page that may also carry the
1139
- // newsletter block, and two fields both announced as
1140
- // "Email address" is barely better than none.
1141
- slotProps: {
1142
- htmlInput: {
1143
- 'aria-label': 'Email address for back-in-stock alert'
1144
- }
1145
- },
1146
- value: notifyEmail,
1147
- onChange: (event)=>setNotifyEmail(event.target.value),
1148
- size: "small",
1149
- sx: {
1150
- flex: 1
1151
- }
1152
- }),
1153
- /*#__PURE__*/ _jsx(Button, {
1154
- size: "small",
1155
- variant: "outlined",
1156
- disabled: !notifyEmail.trim(),
1157
- onClick: async ()=>{
1158
- const response = await siteFetch('/api/commerce/notify-restock', {
1159
- method: 'POST',
1160
- headers: {
1161
- 'Content-Type': 'application/json'
1162
- },
1163
- body: JSON.stringify({
1164
- hostId,
1165
- productId: resolved.id,
1166
- email: notifyEmail
1167
- })
1168
- }).catch(()=>null);
1169
- if (response == null ? void 0 : response.ok) setNotifyState('done');
1170
- },
1171
- children: 'Notify me'
1172
- })
1173
- ]
1152
+ (variant == null ? void 0 : variant.soldOut) && hostId ? // The back-in-stock alert, only on a sold-out variant (its own chunk, AGL-4205).
1153
+ /*#__PURE__*/ _jsx(Suspense, {
1154
+ fallback: null,
1155
+ children: /*#__PURE__*/ _jsx(ProductRestockNotify, {
1156
+ hostId: hostId,
1157
+ productId: resolved.id,
1158
+ siteFetch: siteFetch
1159
+ })
1174
1160
  }) : null,
1175
1161
  !hideDescription && resolved.description ? /*#__PURE__*/ _jsx(Typography, {
1176
1162
  variant: "body1",
@@ -1180,60 +1166,16 @@ function slugFromLocation() {
1180
1166
  },
1181
1167
  children: resolved.description
1182
1168
  }) : null,
1183
- detailFacts.length || shippingLines.length ? /*#__PURE__*/ _jsxs(Box, {
1184
- sx: {
1185
- mt: 3
1186
- },
1187
- children: [
1188
- detailFacts.length ? /*#__PURE__*/ _jsx(ProductDetailPanel, {
1189
- title: "Details",
1190
- children: /*#__PURE__*/ _jsx(Box, {
1191
- component: "dl",
1192
- sx: {
1193
- m: 0,
1194
- display: 'grid',
1195
- gridTemplateColumns: 'auto 1fr',
1196
- columnGap: 2,
1197
- rowGap: 0.75
1198
- },
1199
- children: detailFacts.map((fact)=>/*#__PURE__*/ _jsxs(Box, {
1200
- sx: {
1201
- display: 'contents'
1202
- },
1203
- children: [
1204
- /*#__PURE__*/ _jsx(Typography, {
1205
- component: "dt",
1206
- variant: "body2",
1207
- sx: {
1208
- fontWeight: 600
1209
- },
1210
- children: fact.label
1211
- }),
1212
- /*#__PURE__*/ _jsx(Typography, {
1213
- component: "dd",
1214
- variant: "body2",
1215
- color: "text.secondary",
1216
- sx: {
1217
- m: 0
1218
- },
1219
- children: fact.value
1220
- })
1221
- ]
1222
- }, fact.label))
1223
- })
1224
- }) : null,
1225
- shippingLines.length ? /*#__PURE__*/ _jsx(ProductDetailPanel, {
1226
- title: "Shipping & returns",
1227
- children: shippingLines.map((line)=>/*#__PURE__*/ _jsx(Typography, {
1228
- variant: "body2",
1229
- color: "text.secondary",
1230
- sx: {
1231
- mb: 0.75
1232
- },
1233
- children: line
1234
- }, line))
1235
- }) : null
1236
- ]
1169
+ showDetails || showShipping ? /*#__PURE__*/ _jsx(Suspense, {
1170
+ fallback: null,
1171
+ children: /*#__PURE__*/ _jsx(ProductDetailPanels, {
1172
+ product: resolved,
1173
+ variant: variant,
1174
+ presented: presentedOptions,
1175
+ returns: (seededProduct == null ? void 0 : seededProduct.id) === resolved.id ? seededReturns : undefined,
1176
+ showDetails: Boolean(showDetails),
1177
+ showShipping: Boolean(showShipping)
1178
+ })
1237
1179
  }) : null
1238
1180
  ]
1239
1181
  })
@@ -1241,55 +1183,6 @@ function slugFromLocation() {
1241
1183
  }));
1242
1184
  });
1243
1185
  ProductDetail.displayName = 'AglynProductDetail';
1244
- /**
1245
- * One fold of the panels under the buy box: a flat, divided accordion in the
1246
- * theme's own colours — the way a designer storefront stacks Details and
1247
- * Shipping under the description.
1248
- */ function ProductDetailPanel({ title, children }) {
1249
- return /*#__PURE__*/ _jsxs(Accordion, {
1250
- disableGutters: true,
1251
- elevation: 0,
1252
- square: true,
1253
- sx: {
1254
- bgcolor: 'transparent',
1255
- borderTop: 1,
1256
- borderColor: 'divider',
1257
- '&:last-of-type': {
1258
- borderBottom: 1,
1259
- borderColor: 'divider'
1260
- },
1261
- '&::before': {
1262
- display: 'none'
1263
- }
1264
- },
1265
- children: [
1266
- /*#__PURE__*/ _jsx(AccordionSummary, {
1267
- expandIcon: /*#__PURE__*/ _jsx(SvgIcon, {
1268
- fontSize: "small",
1269
- children: /*#__PURE__*/ _jsx("path", {
1270
- d: mdiChevronDown.path
1271
- })
1272
- }),
1273
- sx: {
1274
- px: 0
1275
- },
1276
- children: /*#__PURE__*/ _jsx(Typography, {
1277
- variant: "subtitle1",
1278
- component: "h2",
1279
- children: title
1280
- })
1281
- }),
1282
- /*#__PURE__*/ _jsx(AccordionDetails, {
1283
- sx: {
1284
- px: 0,
1285
- pt: 0,
1286
- pb: 2
1287
- },
1288
- children: children
1289
- })
1290
- ]
1291
- });
1292
- }
1293
1186
  export const schema = {
1294
1187
  $id: ID,
1295
1188
  pluginId: BUNDLE_ID,
@@ -1302,9 +1195,8 @@ export const schema = {
1302
1195
  color: '#2e7d32'
1303
1196
  }
1304
1197
  },
1305
- flags: {
1306
- selfClosing: Aglyn.FEATURE_FLAG.ENABLED
1307
- },
1198
+ // Not self-closing since AGL-4205: what is dropped in is the request form
1199
+ // "Get a free mockup" opens, shown only for a product that offers one.
1308
1200
  attributes: [
1309
1201
  {
1310
1202
  name: 'slug',
@@ -1346,6 +1238,29 @@ export const schema = {
1346
1238
  label: 'Show shipping & returns panel',
1347
1239
  description: 'A Shipping & returns fold: shipping priced at checkout (or digital ' + 'delivery), and your return window when your store takes returns.',
1348
1240
  component: Aglyn.FieldComponentType.CHECKBOX
1241
+ },
1242
+ {
1243
+ // AGL-4205. Absent reads as menus, so no existing page changes shape.
1244
+ name: 'choiceStyle',
1245
+ label: 'Show choices as',
1246
+ description: 'Menus, or picture cards: a card per choice with its picture, price and note, and a running total.',
1247
+ component: Aglyn.FieldComponentType.SELECT,
1248
+ options: [
1249
+ {
1250
+ label: 'Menus',
1251
+ value: 'menus'
1252
+ },
1253
+ {
1254
+ label: 'Picture cards',
1255
+ value: 'cards'
1256
+ }
1257
+ ]
1258
+ },
1259
+ {
1260
+ name: 'mockupLabel',
1261
+ label: 'Free mockup button label',
1262
+ description: 'Shown when the product offers a free mockup and this block holds a request form.',
1263
+ component: Aglyn.FieldComponentType.TEXT_FIELD
1349
1264
  }
1350
1265
  ]
1351
1266
  };