@aglyn/plugins-commerce 1.15.2 → 1.17.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 (220) 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/pos-cellular-control.component.d.ts +5 -0
  15. package/src/lib/components/console/pos-cellular-control.component.js +29 -15
  16. package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
  17. package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
  18. package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
  19. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  20. package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
  21. package/src/lib/components/console/product-builder-fields.component.js +195 -0
  22. package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
  23. package/src/lib/components/console/product-editor-dialog.component.js +35 -2
  24. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  25. package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
  26. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  27. package/src/lib/components/console/quote-messages.component.d.ts +21 -0
  28. package/src/lib/components/console/quote-messages.component.js +185 -0
  29. package/src/lib/components/console/quote-messages.component.js.map +1 -0
  30. package/src/lib/components/console/quote-pay-link.component.js +1 -1
  31. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  32. package/src/lib/components/console/quote-proofs.component.js +30 -3
  33. package/src/lib/components/console/quote-proofs.component.js.map +1 -1
  34. package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
  35. package/src/lib/components/console/quote-settings-card.component.js +154 -24
  36. package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
  37. package/src/lib/components/product-builder-context.d.ts +22 -0
  38. package/src/lib/components/product-builder-context.js +21 -0
  39. package/src/lib/components/product-builder-context.js.map +1 -0
  40. package/src/lib/components/product-builder-mockup.d.ts +42 -0
  41. package/src/lib/components/product-builder-mockup.js +120 -0
  42. package/src/lib/components/product-builder-mockup.js.map +1 -0
  43. package/src/lib/components/product-builder-sample.d.ts +63 -0
  44. package/src/lib/components/product-builder-sample.js +96 -0
  45. package/src/lib/components/product-builder-sample.js.map +1 -0
  46. package/src/lib/components/product-choice-cards.d.ts +51 -0
  47. package/src/lib/components/product-choice-cards.js +311 -0
  48. package/src/lib/components/product-choice-cards.js.map +1 -0
  49. package/src/lib/components/product-detail-panels.d.ts +42 -0
  50. package/src/lib/components/product-detail-panels.js +185 -0
  51. package/src/lib/components/product-detail-panels.js.map +1 -0
  52. package/src/lib/components/product-detail.d.ts +20 -12
  53. package/src/lib/components/product-detail.js +136 -221
  54. package/src/lib/components/product-detail.js.map +1 -1
  55. package/src/lib/components/product-grid.d.ts +7 -0
  56. package/src/lib/components/product-grid.js +13 -9
  57. package/src/lib/components/product-grid.js.map +1 -1
  58. package/src/lib/components/product-name-lines.d.ts +37 -0
  59. package/src/lib/components/product-name-lines.js +36 -0
  60. package/src/lib/components/product-name-lines.js.map +1 -0
  61. package/src/lib/components/product-options-field-body.d.ts +9 -8
  62. package/src/lib/components/product-options-field-body.js +152 -3
  63. package/src/lib/components/product-options-field-body.js.map +1 -1
  64. package/src/lib/components/product-options-field.js +1 -1
  65. package/src/lib/components/product-options-field.js.map +1 -1
  66. package/src/lib/components/product-photo-fit.d.ts +49 -0
  67. package/src/lib/components/product-photo-fit.js +58 -0
  68. package/src/lib/components/product-photo-fit.js.map +1 -0
  69. package/src/lib/components/product-restock-notify.d.ts +12 -0
  70. package/src/lib/components/product-restock-notify.js +86 -0
  71. package/src/lib/components/product-restock-notify.js.map +1 -0
  72. package/src/lib/components/quote-messages-panel.d.ts +21 -0
  73. package/src/lib/components/quote-messages-panel.js +191 -0
  74. package/src/lib/components/quote-messages-panel.js.map +1 -0
  75. package/src/lib/components/quote-page-body.js +15 -1
  76. package/src/lib/components/quote-page-body.js.map +1 -1
  77. package/src/lib/components/quote-proof-panel.d.ts +6 -3
  78. package/src/lib/components/quote-proof-panel.js +139 -14
  79. package/src/lib/components/quote-proof-panel.js.map +1 -1
  80. package/src/lib/components/related-products.d.ts +7 -0
  81. package/src/lib/components/related-products.js +10 -7
  82. package/src/lib/components/related-products.js.map +1 -1
  83. package/src/lib/constants/quote-page.d.ts +8 -0
  84. package/src/lib/constants/quote-page.js +11 -0
  85. package/src/lib/constants/quote-page.js.map +1 -1
  86. package/src/lib/model/commerce-cart.d.ts +6 -1
  87. package/src/lib/model/commerce-cart.js +5 -1
  88. package/src/lib/model/commerce-cart.js.map +1 -1
  89. package/src/lib/model/commerce-invoices.js +5 -1
  90. package/src/lib/model/commerce-invoices.js.map +1 -1
  91. package/src/lib/model/commerce-pos-ops.d.ts +3 -0
  92. package/src/lib/model/commerce-pos-ops.js +3 -0
  93. package/src/lib/model/commerce-pos-ops.js.map +1 -1
  94. package/src/lib/model/commerce-pos.d.ts +8 -0
  95. package/src/lib/model/commerce-pos.js.map +1 -1
  96. package/src/lib/model/commerce-quote-messages.d.ts +106 -0
  97. package/src/lib/model/commerce-quote-messages.js +146 -0
  98. package/src/lib/model/commerce-quote-messages.js.map +1 -0
  99. package/src/lib/model/commerce-quote-pay.d.ts +31 -2
  100. package/src/lib/model/commerce-quote-pay.js +31 -7
  101. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  102. package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
  103. package/src/lib/model/commerce-quote-proofs.js +73 -18
  104. package/src/lib/model/commerce-quote-proofs.js.map +1 -1
  105. package/src/lib/model/commerce-quote-request.d.ts +14 -4
  106. package/src/lib/model/commerce-quote-request.js +25 -2
  107. package/src/lib/model/commerce-quote-request.js.map +1 -1
  108. package/src/lib/model/commerce-quotes.d.ts +56 -3
  109. package/src/lib/model/commerce-quotes.js +47 -2
  110. package/src/lib/model/commerce-quotes.js.map +1 -1
  111. package/src/lib/model/commerce.d.ts +12 -1
  112. package/src/lib/model/commerce.js.map +1 -1
  113. package/src/lib/model/index.d.ts +1 -0
  114. package/src/lib/model/index.js +1 -0
  115. package/src/lib/model/index.js.map +1 -1
  116. package/src/lib/model/pos-cellular.d.ts +36 -4
  117. package/src/lib/model/pos-cellular.js +39 -4
  118. package/src/lib/model/pos-cellular.js.map +1 -1
  119. package/src/lib/model/product-card-rules.d.ts +41 -0
  120. package/src/lib/model/product-card-rules.js +90 -0
  121. package/src/lib/model/product-card-rules.js.map +1 -0
  122. package/src/lib/model/product-modifiers.d.ts +11 -0
  123. package/src/lib/model/product-modifiers.js +10 -0
  124. package/src/lib/model/product-modifiers.js.map +1 -1
  125. package/src/lib/model/product-write.d.ts +3 -0
  126. package/src/lib/server/billing-webhook.js +6 -2
  127. package/src/lib/server/billing-webhook.js.map +1 -1
  128. package/src/lib/server/cancel-order.js +15 -0
  129. package/src/lib/server/cancel-order.js.map +1 -1
  130. package/src/lib/server/channel-order-updates.js +15 -1
  131. package/src/lib/server/channel-order-updates.js.map +1 -1
  132. package/src/lib/server/channel-orders.js +20 -0
  133. package/src/lib/server/channel-orders.js.map +1 -1
  134. package/src/lib/server/checkout.js +1 -1
  135. package/src/lib/server/checkout.js.map +1 -1
  136. package/src/lib/server/local-fulfillment.js +1 -1
  137. package/src/lib/server/local-fulfillment.js.map +1 -1
  138. package/src/lib/server/pos-cellular-billing.d.ts +5 -4
  139. package/src/lib/server/pos-cellular-billing.js +24 -12
  140. package/src/lib/server/pos-cellular-billing.js.map +1 -1
  141. package/src/lib/server/pos-cellular.d.ts +3 -1
  142. package/src/lib/server/pos-cellular.js +55 -33
  143. package/src/lib/server/pos-cellular.js.map +1 -1
  144. package/src/lib/server/pos-offline-sync.d.ts +3 -3
  145. package/src/lib/server/pos-offline-sync.js +17 -4
  146. package/src/lib/server/pos-offline-sync.js.map +1 -1
  147. package/src/lib/server/pos-order.js +17 -6
  148. package/src/lib/server/pos-order.js.map +1 -1
  149. package/src/lib/server/pos-payment.js +27 -11
  150. package/src/lib/server/pos-payment.js.map +1 -1
  151. package/src/lib/server/pos-reader-splash.js +10 -5
  152. package/src/lib/server/pos-reader-splash.js.map +1 -1
  153. package/src/lib/server/pos-readers.js +42 -12
  154. package/src/lib/server/pos-readers.js.map +1 -1
  155. package/src/lib/server/pos-return.js +19 -3
  156. package/src/lib/server/pos-return.js.map +1 -1
  157. package/src/lib/server/pos-stripe.d.ts +14 -0
  158. package/src/lib/server/pos-stripe.js +6 -2
  159. package/src/lib/server/pos-stripe.js.map +1 -1
  160. package/src/lib/server/pos-terminal-connection-token.js +23 -9
  161. package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
  162. package/src/lib/server/pos-terminal.d.ts +80 -14
  163. package/src/lib/server/pos-terminal.js +393 -123
  164. package/src/lib/server/pos-terminal.js.map +1 -1
  165. package/src/lib/server/product-drafts.d.ts +1 -1
  166. package/src/lib/server/product-drafts.js +4 -3
  167. package/src/lib/server/product-drafts.js.map +1 -1
  168. package/src/lib/server/product-writer.js +5 -4
  169. package/src/lib/server/product-writer.js.map +1 -1
  170. package/src/lib/server/product.d.ts +11 -0
  171. package/src/lib/server/product.js +18 -3
  172. package/src/lib/server/product.js.map +1 -1
  173. package/src/lib/server/products-write.js +4 -3
  174. package/src/lib/server/products-write.js.map +1 -1
  175. package/src/lib/server/quote-email.d.ts +26 -0
  176. package/src/lib/server/quote-email.js +73 -7
  177. package/src/lib/server/quote-email.js.map +1 -1
  178. package/src/lib/server/quote-messages.d.ts +72 -0
  179. package/src/lib/server/quote-messages.js +356 -0
  180. package/src/lib/server/quote-messages.js.map +1 -0
  181. package/src/lib/server/quote-pay.d.ts +42 -0
  182. package/src/lib/server/quote-pay.js +81 -4
  183. package/src/lib/server/quote-pay.js.map +1 -1
  184. package/src/lib/server/quote-proofs.d.ts +1 -1
  185. package/src/lib/server/quote-proofs.js +63 -19
  186. package/src/lib/server/quote-proofs.js.map +1 -1
  187. package/src/lib/server/quote.d.ts +12 -0
  188. package/src/lib/server/quote.js +69 -16
  189. package/src/lib/server/quote.js.map +1 -1
  190. package/src/lib/server/refund.js +3 -1
  191. package/src/lib/server/refund.js.map +1 -1
  192. package/src/lib/server/reserve-stock.js +9 -0
  193. package/src/lib/server/reserve-stock.js.map +1 -1
  194. package/src/lib/server/returns.js +15 -1
  195. package/src/lib/server/returns.js.map +1 -1
  196. package/src/lib/server/reviews.js +15 -0
  197. package/src/lib/server/reviews.js.map +1 -1
  198. package/src/lib/server/sold-out-drop.d.ts +58 -0
  199. package/src/lib/server/sold-out-drop.js +81 -0
  200. package/src/lib/server/sold-out-drop.js.map +1 -0
  201. package/src/lib/server/stock-levels.js +9 -0
  202. package/src/lib/server/stock-levels.js.map +1 -1
  203. package/src/lib/server/stripe-refund.d.ts +7 -0
  204. package/src/lib/server/stripe-refund.js +26 -7
  205. package/src/lib/server/stripe-refund.js.map +1 -1
  206. package/src/lib/server.d.ts +15 -0
  207. package/src/lib/server.js +30 -1
  208. package/src/lib/server.js.map +1 -1
  209. package/src/lib/tenant-emails.js +85 -2
  210. package/src/lib/tenant-emails.js.map +1 -1
  211. package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
  212. package/src/lib/testing/fake-seller-payment-account.js +40 -0
  213. package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
  214. package/src/lib/transfer/product-transfer.js +6 -5
  215. package/src/lib/transfer/product-transfer.js.map +1 -1
  216. package/src/lib/transfer/products.server.js +4 -3
  217. package/src/lib/transfer/products.server.js.map +1 -1
  218. package/src/lib/utils/quote-email-content.d.ts +6 -0
  219. package/src/lib/utils/quote-email-content.js +6 -3
  220. package/src/lib/utils/quote-email-content.js.map +1 -1
@@ -18,7 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  * limitations under the License.
19
19
  */ import * as Aglyn from "@aglyn/aglyn";
20
20
  import { formFieldDataKey } from "../model/commerce-product-field.js";
21
- import { encodeProductFieldValue, productFieldLabel } from "../model/commerce-quote-request.js";
21
+ import { builderPicksLabel, encodeProductFieldValue, productFieldLabel } from "../model/commerce-quote-request.js";
22
22
  import Box from "@mui/material/Box";
23
23
  import FormControl from "@mui/material/FormControl";
24
24
  import FormHelperText from "@mui/material/FormHelperText";
@@ -26,7 +26,9 @@ import FormLabel from "@mui/material/FormLabel";
26
26
  import MenuItem from "@mui/material/MenuItem";
27
27
  import Stack from "@mui/material/Stack";
28
28
  import TextField from "@mui/material/TextField";
29
- import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
29
+ import Typography from "@mui/material/Typography";
30
+ import { forwardRef, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
31
+ import { ProductBuilderContext } from "./product-builder-context.js";
30
32
  /** The most products the picker lists. */ const PICKER_LIMIT = 100;
31
33
  /** The variant whose options are exactly the ones picked, else none. */ export function variantForOptions(detail, picked) {
32
34
  var _ref, _ref1;
@@ -48,7 +50,7 @@ import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
48
50
  *
49
51
  * On the canvas and in Preview it draws with the store's products but sends
50
52
  * nothing, like every form field there.
51
- */ const ProductOptionsFieldBody = /*#__PURE__*/ forwardRef((props, ref)=>{
53
+ */ const StoreProductPicker = /*#__PURE__*/ forwardRef((props, ref)=>{
52
54
  var _ref, _ref1;
53
55
  var _products_find;
54
56
  const { name: rawName, label, productId: fixedProductId, required } = props, rest = _object_without_properties_loose(props, [
@@ -254,6 +256,153 @@ import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
254
256
  ]
255
257
  }));
256
258
  });
259
+ StoreProductPicker.displayName = 'AglynStoreProductPicker';
260
+ /** What the field posts for a product page's picks (AGL-4205): the line in words, and the exact choice. */ export function builderFieldValue(picks) {
261
+ if (!picks.ready) return {
262
+ answer: '',
263
+ value: ''
264
+ };
265
+ return {
266
+ answer: builderPicksLabel(picks.productName, picks.options, picks.addOnNames, picks.quantity),
267
+ value: encodeProductFieldValue(_extends({
268
+ productId: picks.productId
269
+ }, picks.variantId ? {
270
+ variantId: picks.variantId
271
+ } : {}, Object.keys(picks.options).length ? {
272
+ options: picks.options
273
+ } : {}, picks.modifiers.length ? {
274
+ modifiers: picks.modifiers
275
+ } : {}, picks.quantity > 1 ? {
276
+ quantity: picks.quantity
277
+ } : {}))
278
+ };
279
+ }
280
+ /**
281
+ * The field inside a Product detail block (AGL-4205): the shopper already
282
+ * picked on the page, so it lists those picks and posts them, and changes as
283
+ * they do. Until every required choice is answered it posts nothing, so a
284
+ * required field stops the form and says what is left to choose.
285
+ */ const ProductBuilderAnswer = /*#__PURE__*/ forwardRef((props, ref)=>{
286
+ const { name: rawName, label, productId: _fixed, required, picks } = props, rest = _object_without_properties_loose(props, [
287
+ "name",
288
+ "label",
289
+ "productId",
290
+ "required",
291
+ "picks"
292
+ ]);
293
+ const name = String(rawName != null ? rawName : '').trim() || 'product';
294
+ const labelId = useId();
295
+ const answerRef = useRef(null);
296
+ const { answer, value } = builderFieldValue(picks);
297
+ const announced = useRef(answer);
298
+ useEffect(()=>{
299
+ var _answerRef_current;
300
+ if (announced.current === answer) return;
301
+ announced.current = answer;
302
+ (_answerRef_current = answerRef.current) == null ? void 0 : _answerRef_current.dispatchEvent(new Event('change', {
303
+ bubbles: true
304
+ }));
305
+ }, [
306
+ answer
307
+ ]);
308
+ const chosen = [
309
+ ...Object.entries(picks.options).map(([option, picked])=>`${option}: ${picked}`),
310
+ ...picks.addOnNames,
311
+ ...picks.quantity > 1 ? [
312
+ `Quantity: ${picks.quantity}`
313
+ ] : []
314
+ ];
315
+ return /*#__PURE__*/ _jsxs(FormControl, _extends({
316
+ ref: ref,
317
+ fullWidth: true,
318
+ required: Boolean(required)
319
+ }, rest, {
320
+ children: [
321
+ /*#__PURE__*/ _jsx(FormLabel, {
322
+ id: labelId,
323
+ children: label || 'Product'
324
+ }),
325
+ /*#__PURE__*/ _jsxs(Stack, {
326
+ spacing: 0.5,
327
+ sx: {
328
+ mt: 1,
329
+ position: 'relative'
330
+ },
331
+ "aria-labelledby": labelId,
332
+ children: [
333
+ /*#__PURE__*/ _jsx(Typography, {
334
+ variant: "subtitle2",
335
+ component: "p",
336
+ children: picks.productName
337
+ }),
338
+ chosen.map((line)=>/*#__PURE__*/ _jsx(Typography, {
339
+ variant: "body2",
340
+ color: "text.secondary",
341
+ children: line
342
+ }, line)),
343
+ picks.total ? /*#__PURE__*/ _jsx(Typography, {
344
+ variant: "body2",
345
+ children: `Total: ${picks.total}`
346
+ }) : null,
347
+ /*#__PURE__*/ _jsx(FormHelperText, {
348
+ error: !picks.ready,
349
+ sx: {
350
+ mx: 0
351
+ },
352
+ children: picks.ready ? 'Change your picks above and this follows.' : picks.problem || 'Finish your picks above.'
353
+ }),
354
+ /*#__PURE__*/ _jsx(Box, {
355
+ component: "input",
356
+ ref: answerRef,
357
+ type: "text",
358
+ name: name,
359
+ value: answer,
360
+ required: Boolean(required),
361
+ onChange: ()=>undefined,
362
+ tabIndex: -1,
363
+ "aria-hidden": "true",
364
+ autoComplete: "off",
365
+ sx: {
366
+ position: 'absolute',
367
+ left: 0,
368
+ bottom: 0,
369
+ width: 1,
370
+ height: '1px',
371
+ p: 0,
372
+ border: 0,
373
+ opacity: 0,
374
+ pointerEvents: 'none'
375
+ }
376
+ }),
377
+ value ? /*#__PURE__*/ _jsx("input", {
378
+ type: "hidden",
379
+ name: formFieldDataKey(name),
380
+ value: value,
381
+ readOnly: true
382
+ }) : null
383
+ ]
384
+ })
385
+ ]
386
+ }));
387
+ });
388
+ ProductBuilderAnswer.displayName = 'AglynProductBuilderAnswer';
389
+ /**
390
+ * The Product and options field's body: inside a Product detail block it
391
+ * posts the shopper's picks there (AGL-4205), unless the author pinned it to
392
+ * another product; anywhere else it asks for a product and its options.
393
+ */ const ProductOptionsFieldBody = /*#__PURE__*/ forwardRef((props, ref)=>{
394
+ const picks = useContext(ProductBuilderContext);
395
+ if (picks && (!props.productId || props.productId === picks.productId)) {
396
+ return /*#__PURE__*/ _jsx(ProductBuilderAnswer, _extends({
397
+ ref: ref
398
+ }, props, {
399
+ picks: picks
400
+ }));
401
+ }
402
+ return /*#__PURE__*/ _jsx(StoreProductPicker, _extends({
403
+ ref: ref
404
+ }, props));
405
+ });
257
406
  ProductOptionsFieldBody.displayName = 'AglynProductOptionsFieldBody';
258
407
  export default ProductOptionsFieldBody;
259
408
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-options-field-body.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { formFieldDataKey } from '../model/commerce-product-field'\nimport { encodeProductFieldValue, productFieldLabel } from '../model/commerce-quote-request'\nimport Box from '@mui/material/Box'\nimport FormControl from '@mui/material/FormControl'\nimport FormHelperText from '@mui/material/FormHelperText'\nimport FormLabel from '@mui/material/FormLabel'\nimport MenuItem from '@mui/material/MenuItem'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport { forwardRef, useEffect, useId, useMemo, useRef, useState } from 'react'\nimport type { ProductOptionsFieldProps } from './product-options-field'\n\n/** A product as the store's public catalog lists it. */\ninterface ListedProduct {\n id: string\n name: string\n slug: string\n}\n\n/** A product as its public page reads it: its options and the variants they make. */\ninterface ProductDetail {\n id: string\n name: string\n options: Array<{ name: string; values: string[] }>\n variants: Array<{ id: string; options?: Record<string, string> }>\n}\n\n/** The most products the picker lists. */\nconst PICKER_LIMIT = 100\n\n/** The variant whose options are exactly the ones picked, else none. */\nexport function variantForOptions(\n detail: Pick<ProductDetail, 'variants' | 'options'>,\n picked: Readonly<Record<string, string>>,\n): string | null {\n if (!detail.options.length) return detail.variants[0]?.id ?? null\n if (detail.options.some((option) => !picked[option.name])) return null\n const match = detail.variants.find((variant) =>\n detail.options.every((option) => variant.options?.[option.name] === picked[option.name]),\n )\n return match?.id ?? null\n}\n\n/**\n * The Product and options field's body (AGL-4098): a picker of the store's\n * products (or the one the author chose), then one picker per option. It\n * posts the readable line under its name and the exact choice beside it; a\n * real, invisible input carries the line, so a required field with nothing\n * picked stops the form like any required field.\n *\n * On the canvas and in Preview it draws with the store's products but sends\n * nothing, like every form field there.\n */\nconst ProductOptionsFieldBody = forwardRef<HTMLDivElement, ProductOptionsFieldProps>((props, ref) => {\n const { name: rawName, label, productId: fixedProductId, required, ...rest } = props\n const name = String(rawName ?? '').trim() || 'product'\n const { hostId } = Aglyn.useSite()\n const inputId = useId()\n const answerRef = useRef<HTMLInputElement>(null)\n const [products, setProducts] = useState<ListedProduct[] | null>(null)\n const [productId, setProductId] = useState(fixedProductId ?? '')\n const [detail, setDetail] = useState<ProductDetail | null>(null)\n const [picked, setPicked] = useState<Record<string, string>>({})\n\n // The store's products, or the one the author chose.\n useEffect(() => {\n if (!hostId) return\n let active = true\n const query = new URLSearchParams({\n hostId,\n ...(fixedProductId ? { ids: fixedProductId } : { sort: 'name', limit: String(PICKER_LIMIT) }),\n })\n void fetch(`/api/commerce/catalog?${query.toString()}`)\n .then((response) => (response.ok ? response.json() : { items: [] }))\n .then((payload) => {\n if (!active) return\n const items = Array.isArray(payload?.items) ? (payload.items as ListedProduct[]) : []\n setProducts(items)\n if (fixedProductId) setProductId(items[0]?.id ?? '')\n })\n .catch(() => active && setProducts([]))\n return () => {\n active = false\n }\n }, [hostId, fixedProductId])\n\n // The chosen product's options.\n const slug = products?.find((product) => product.id === productId)?.slug ?? ''\n useEffect(() => {\n setDetail(null)\n setPicked({})\n if (!hostId || !slug) return\n let active = true\n void fetch(`/api/commerce/product?hostId=${encodeURIComponent(hostId)}&slug=${encodeURIComponent(slug)}`)\n .then((response) => (response.ok ? response.json() : null))\n .then((payload) => {\n if (!active || !payload?.product) return\n const product = payload.product as ProductDetail\n setDetail({ ...product, options: product.options ?? [], variants: product.variants ?? [] })\n })\n .catch(() => undefined)\n return () => {\n active = false\n }\n }, [hostId, slug])\n\n const variantId = detail ? variantForOptions(detail, picked) : null\n const complete = Boolean(detail && variantId)\n const answer = complete && detail ? productFieldLabel(detail.name, picked) : ''\n const value = complete && detail\n ? encodeProductFieldValue({\n productId: detail.id,\n ...(variantId && variantId !== 'default' ? { variantId } : {}),\n ...(Object.keys(picked).length ? { options: picked } : {}),\n // Add-ons are chosen on the storefront from slice 8 on: they ride here as `modifiers`.\n })\n : ''\n\n // Every change is announced, as a typed answer is, to anything listening on the form.\n const announced = useRef(answer)\n useEffect(() => {\n if (announced.current === answer) return\n announced.current = answer\n answerRef.current?.dispatchEvent(new Event('change', { bubbles: true }))\n }, [answer])\n\n const listed = useMemo(() => products ?? [], [products])\n // On the canvas there is no site to list from: it says what the visitor will pick from.\n const placeholder = !hostId\n ? 'Your store’s products'\n : products === null\n ? 'Loading products…'\n : listed.length\n ? 'Choose a product'\n : 'No products to choose from yet'\n\n return (\n <FormControl ref={ref} fullWidth required={Boolean(required)} {...rest}>\n <FormLabel htmlFor={inputId}>{label || 'Product'}</FormLabel>\n <Stack spacing={1.5} sx={{ mt: 1, position: 'relative' }}>\n {fixedProductId ? null : (\n <TextField\n id={inputId}\n select\n size=\"small\"\n fullWidth\n value={productId}\n onChange={(event) => setProductId(event.target.value)}\n disabled={!listed.length}\n slotProps={{\n select: {\n displayEmpty: true,\n renderValue: (selected: unknown) =>\n listed.find((product) => product.id === selected)?.name ?? (\n <Box component=\"span\" sx={{ color: 'text.secondary' }}>\n {placeholder}\n </Box>\n ),\n },\n }}\n >\n {listed.map((product) => (\n <MenuItem key={product.id} value={product.id}>\n {product.name}\n </MenuItem>\n ))}\n </TextField>\n )}\n {fixedProductId && detail ? <FormHelperText sx={{ mx: 0 }}>{detail.name}</FormHelperText> : null}\n {(detail?.options ?? []).map((option) => (\n <TextField\n key={option.name}\n select\n size=\"small\"\n fullWidth\n label={option.name}\n value={picked[option.name] ?? ''}\n onChange={(event) => setPicked((current) => ({ ...current, [option.name]: event.target.value }))}\n >\n {option.values.map((choice) => (\n <MenuItem key={choice} value={choice}>\n {choice}\n </MenuItem>\n ))}\n </TextField>\n ))}\n {detail && Object.keys(picked).length === detail.options.length && detail.options.length && !variantId ? (\n <FormHelperText error sx={{ mx: 0 }}>\n {'That combination isn’t one we offer. Pick another.'}\n </FormHelperText>\n ) : null}\n {/* The answer the form sends and the browser checks, and the exact choice beside it. */}\n <Box\n component=\"input\"\n ref={answerRef}\n type=\"text\"\n name={name}\n value={answer}\n required={Boolean(required)}\n onChange={() => undefined}\n tabIndex={-1}\n aria-hidden=\"true\"\n autoComplete=\"off\"\n sx={{ position: 'absolute', left: 0, bottom: 0, width: 1, height: '1px', p: 0, border: 0, opacity: 0, pointerEvents: 'none' }}\n />\n {value ? <input type=\"hidden\" name={formFieldDataKey(name)} value={value} readOnly /> : null}\n </Stack>\n </FormControl>\n )\n})\nProductOptionsFieldBody.displayName = 'AglynProductOptionsFieldBody'\n\nexport default ProductOptionsFieldBody\n"],"names":["Aglyn","formFieldDataKey","encodeProductFieldValue","productFieldLabel","Box","FormControl","FormHelperText","FormLabel","MenuItem","Stack","TextField","forwardRef","useEffect","useId","useMemo","useRef","useState","PICKER_LIMIT","variantForOptions","detail","picked","options","length","variants","id","some","option","name","match","find","variant","every","ProductOptionsFieldBody","props","ref","products","rawName","label","productId","fixedProductId","required","rest","String","trim","hostId","useSite","inputId","answerRef","setProducts","setProductId","setDetail","setPicked","active","query","URLSearchParams","ids","sort","limit","fetch","toString","then","response","ok","json","items","payload","Array","isArray","catch","slug","product","encodeURIComponent","undefined","variantId","complete","Boolean","answer","value","Object","keys","announced","current","dispatchEvent","Event","bubbles","listed","placeholder","fullWidth","htmlFor","spacing","sx","mt","position","select","size","onChange","event","target","disabled","slotProps","displayEmpty","renderValue","selected","component","color","map","mx","values","choice","error","type","tabIndex","aria-hidden","autoComplete","left","bottom","width","height","p","border","opacity","pointerEvents","input","readOnly","displayName"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,gBAAgB,QAAQ,qCAAiC;AAClE,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,qCAAiC;AAC5F,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,eAAe,0BAAyB;AAC/C,SAASC,UAAU,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAkB/E,wCAAwC,GACxC,MAAMC,eAAe;AAErB,sEAAsE,GACtE,OAAO,SAASC,kBACdC,MAAmD,EACnDC,MAAwC;;QAELD;IAAnC,IAAI,CAACA,OAAOE,OAAO,CAACC,MAAM,EAAE,gBAAOH,oBAAAA,OAAOI,QAAQ,CAAC,EAAE,qBAAlBJ,kBAAoBK,EAAE,mBAAI;IAC7D,IAAIL,OAAOE,OAAO,CAACI,IAAI,CAAC,CAACC,SAAW,CAACN,MAAM,C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WAAU;wBACVrE,KAAKa;wBACL+D,MAAK;wBACLnF,MAAMA;wBACNkD,OAAOD;wBACPpC,UAAUmC,QAAQnC;wBAClBuD,UAAU,IAAMvB;wBAChBuC,UAAU,CAAC;wBACXC,eAAY;wBACZC,cAAa;wBACbvB,IAAI;4BAAEE,UAAU;4BAAYsB,MAAM;4BAAGC,QAAQ;4BAAGC,OAAO;4BAAGC,QAAQ;4BAAOC,GAAG;4BAAGC,QAAQ;4BAAGC,SAAS;4BAAGC,eAAe;wBAAO;;oBAE7H5C,sBAAQ,KAAC6C;wBAAMZ,MAAK;wBAASnF,MAAM1B,iBAAiB0B;wBAAOkD,OAAOA;wBAAO8C,QAAQ;yBAAM;;;;;AAIhG;AACA3F,wBAAwB4F,WAAW,GAAG;AAEtC,eAAe5F,wBAAuB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-options-field-body.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { formFieldDataKey } from '../model/commerce-product-field'\nimport { builderPicksLabel, encodeProductFieldValue, productFieldLabel } from '../model/commerce-quote-request'\nimport Box from '@mui/material/Box'\nimport FormControl from '@mui/material/FormControl'\nimport FormHelperText from '@mui/material/FormHelperText'\nimport FormLabel from '@mui/material/FormLabel'\nimport MenuItem from '@mui/material/MenuItem'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { forwardRef, useContext, useEffect, useId, useMemo, useRef, useState } from 'react'\nimport { ProductBuilderContext, type ProductBuilderPicks } from './product-builder-context'\nimport type { ProductOptionsFieldProps } from './product-options-field'\n\n/** A product as the store's public catalog lists it. */\ninterface ListedProduct {\n id: string\n name: string\n slug: string\n}\n\n/** A product as its public page reads it: its options and the variants they make. */\ninterface ProductDetail {\n id: string\n name: string\n options: Array<{ name: string; values: string[] }>\n variants: Array<{ id: string; options?: Record<string, string> }>\n}\n\n/** The most products the picker lists. */\nconst PICKER_LIMIT = 100\n\n/** The variant whose options are exactly the ones picked, else none. */\nexport function variantForOptions(\n detail: Pick<ProductDetail, 'variants' | 'options'>,\n picked: Readonly<Record<string, string>>,\n): string | null {\n if (!detail.options.length) return detail.variants[0]?.id ?? null\n if (detail.options.some((option) => !picked[option.name])) return null\n const match = detail.variants.find((variant) =>\n detail.options.every((option) => variant.options?.[option.name] === picked[option.name]),\n )\n return match?.id ?? null\n}\n\n/**\n * The Product and options field's body (AGL-4098): a picker of the store's\n * products (or the one the author chose), then one picker per option. It\n * posts the readable line under its name and the exact choice beside it; a\n * real, invisible input carries the line, so a required field with nothing\n * picked stops the form like any required field.\n *\n * On the canvas and in Preview it draws with the store's products but sends\n * nothing, like every form field there.\n */\nconst StoreProductPicker = forwardRef<HTMLDivElement, ProductOptionsFieldProps>((props, ref) => {\n const { name: rawName, label, productId: fixedProductId, required, ...rest } = props\n const name = String(rawName ?? '').trim() || 'product'\n const { hostId } = Aglyn.useSite()\n const inputId = useId()\n const answerRef = useRef<HTMLInputElement>(null)\n const [products, setProducts] = useState<ListedProduct[] | null>(null)\n const [productId, setProductId] = useState(fixedProductId ?? '')\n const [detail, setDetail] = useState<ProductDetail | null>(null)\n const [picked, setPicked] = useState<Record<string, string>>({})\n\n // The store's products, or the one the author chose.\n useEffect(() => {\n if (!hostId) return\n let active = true\n const query = new URLSearchParams({\n hostId,\n ...(fixedProductId ? { ids: fixedProductId } : { sort: 'name', limit: String(PICKER_LIMIT) }),\n })\n void fetch(`/api/commerce/catalog?${query.toString()}`)\n .then((response) => (response.ok ? response.json() : { items: [] }))\n .then((payload) => {\n if (!active) return\n const items = Array.isArray(payload?.items) ? (payload.items as ListedProduct[]) : []\n setProducts(items)\n if (fixedProductId) setProductId(items[0]?.id ?? '')\n })\n .catch(() => active && setProducts([]))\n return () => {\n active = false\n }\n }, [hostId, fixedProductId])\n\n // The chosen product's options.\n const slug = products?.find((product) => product.id === productId)?.slug ?? ''\n useEffect(() => {\n setDetail(null)\n setPicked({})\n if (!hostId || !slug) return\n let active = true\n void fetch(`/api/commerce/product?hostId=${encodeURIComponent(hostId)}&slug=${encodeURIComponent(slug)}`)\n .then((response) => (response.ok ? response.json() : null))\n .then((payload) => {\n if (!active || !payload?.product) return\n const product = payload.product as ProductDetail\n setDetail({ ...product, options: product.options ?? [], variants: product.variants ?? [] })\n })\n .catch(() => undefined)\n return () => {\n active = false\n }\n }, [hostId, slug])\n\n const variantId = detail ? variantForOptions(detail, picked) : null\n const complete = Boolean(detail && variantId)\n const answer = complete && detail ? productFieldLabel(detail.name, picked) : ''\n const value = complete && detail\n ? encodeProductFieldValue({\n productId: detail.id,\n ...(variantId && variantId !== 'default' ? { variantId } : {}),\n ...(Object.keys(picked).length ? { options: picked } : {}),\n // Add-ons ride here as `modifiers` when the field sits in a product page's builder (AGL-4205).\n })\n : ''\n\n // Every change is announced, as a typed answer is, to anything listening on the form.\n const announced = useRef(answer)\n useEffect(() => {\n if (announced.current === answer) return\n announced.current = answer\n answerRef.current?.dispatchEvent(new Event('change', { bubbles: true }))\n }, [answer])\n\n const listed = useMemo(() => products ?? [], [products])\n // On the canvas there is no site to list from: it says what the visitor will pick from.\n const placeholder = !hostId\n ? 'Your store’s products'\n : products === null\n ? 'Loading products…'\n : listed.length\n ? 'Choose a product'\n : 'No products to choose from yet'\n\n return (\n <FormControl ref={ref} fullWidth required={Boolean(required)} {...rest}>\n <FormLabel htmlFor={inputId}>{label || 'Product'}</FormLabel>\n <Stack spacing={1.5} sx={{ mt: 1, position: 'relative' }}>\n {fixedProductId ? null : (\n <TextField\n id={inputId}\n select\n size=\"small\"\n fullWidth\n value={productId}\n onChange={(event) => setProductId(event.target.value)}\n disabled={!listed.length}\n slotProps={{\n select: {\n displayEmpty: true,\n renderValue: (selected: unknown) =>\n listed.find((product) => product.id === selected)?.name ?? (\n <Box component=\"span\" sx={{ color: 'text.secondary' }}>\n {placeholder}\n </Box>\n ),\n },\n }}\n >\n {listed.map((product) => (\n <MenuItem key={product.id} value={product.id}>\n {product.name}\n </MenuItem>\n ))}\n </TextField>\n )}\n {fixedProductId && detail ? <FormHelperText sx={{ mx: 0 }}>{detail.name}</FormHelperText> : null}\n {(detail?.options ?? []).map((option) => (\n <TextField\n key={option.name}\n select\n size=\"small\"\n fullWidth\n label={option.name}\n value={picked[option.name] ?? ''}\n onChange={(event) => setPicked((current) => ({ ...current, [option.name]: event.target.value }))}\n >\n {option.values.map((choice) => (\n <MenuItem key={choice} value={choice}>\n {choice}\n </MenuItem>\n ))}\n </TextField>\n ))}\n {detail && Object.keys(picked).length === detail.options.length && detail.options.length && !variantId ? (\n <FormHelperText error sx={{ mx: 0 }}>\n {'That combination isn’t one we offer. Pick another.'}\n </FormHelperText>\n ) : null}\n {/* The answer the form sends and the browser checks, and the exact choice beside it. */}\n <Box\n component=\"input\"\n ref={answerRef}\n type=\"text\"\n name={name}\n value={answer}\n required={Boolean(required)}\n onChange={() => undefined}\n tabIndex={-1}\n aria-hidden=\"true\"\n autoComplete=\"off\"\n sx={{ position: 'absolute', left: 0, bottom: 0, width: 1, height: '1px', p: 0, border: 0, opacity: 0, pointerEvents: 'none' }}\n />\n {value ? <input type=\"hidden\" name={formFieldDataKey(name)} value={value} readOnly /> : null}\n </Stack>\n </FormControl>\n )\n})\nStoreProductPicker.displayName = 'AglynStoreProductPicker'\n\n/** What the field posts for a product page's picks (AGL-4205): the line in words, and the exact choice. */\nexport function builderFieldValue(picks: ProductBuilderPicks): { answer: string; value: string } {\n if (!picks.ready) return { answer: '', value: '' }\n return {\n answer: builderPicksLabel(picks.productName, picks.options, picks.addOnNames, picks.quantity),\n value: encodeProductFieldValue({\n productId: picks.productId,\n ...(picks.variantId ? { variantId: picks.variantId } : {}),\n ...(Object.keys(picks.options).length ? { options: picks.options } : {}),\n ...(picks.modifiers.length ? { modifiers: picks.modifiers } : {}),\n ...(picks.quantity > 1 ? { quantity: picks.quantity } : {}),\n }),\n }\n}\n\n/**\n * The field inside a Product detail block (AGL-4205): the shopper already\n * picked on the page, so it lists those picks and posts them, and changes as\n * they do. Until every required choice is answered it posts nothing, so a\n * required field stops the form and says what is left to choose.\n */\nconst ProductBuilderAnswer = forwardRef<HTMLDivElement, ProductOptionsFieldProps & { picks: ProductBuilderPicks }>(\n (props, ref) => {\n const { name: rawName, label, productId: _fixed, required, picks, ...rest } = props\n const name = String(rawName ?? '').trim() || 'product'\n const labelId = useId()\n const answerRef = useRef<HTMLInputElement>(null)\n const { answer, value } = builderFieldValue(picks)\n const announced = useRef(answer)\n useEffect(() => {\n if (announced.current === answer) return\n announced.current = answer\n answerRef.current?.dispatchEvent(new Event('change', { bubbles: true }))\n }, [answer])\n const chosen = [\n ...Object.entries(picks.options).map(([option, picked]) => `${option}: ${picked}`),\n ...picks.addOnNames,\n ...(picks.quantity > 1 ? [`Quantity: ${picks.quantity}`] : []),\n ]\n return (\n <FormControl ref={ref} fullWidth required={Boolean(required)} {...rest}>\n <FormLabel id={labelId}>{label || 'Product'}</FormLabel>\n <Stack spacing={0.5} sx={{ mt: 1, position: 'relative' }} aria-labelledby={labelId}>\n <Typography variant=\"subtitle2\" component=\"p\">\n {picks.productName}\n </Typography>\n {chosen.map((line) => (\n <Typography key={line} variant=\"body2\" color=\"text.secondary\">\n {line}\n </Typography>\n ))}\n {picks.total ? (\n <Typography variant=\"body2\">{`Total: ${picks.total}`}</Typography>\n ) : null}\n <FormHelperText error={!picks.ready} sx={{ mx: 0 }}>\n {picks.ready ? 'Change your picks above and this follows.' : picks.problem || 'Finish your picks above.'}\n </FormHelperText>\n <Box\n component=\"input\"\n ref={answerRef}\n type=\"text\"\n name={name}\n value={answer}\n required={Boolean(required)}\n onChange={() => undefined}\n tabIndex={-1}\n aria-hidden=\"true\"\n autoComplete=\"off\"\n sx={{ position: 'absolute', left: 0, bottom: 0, width: 1, height: '1px', p: 0, border: 0, opacity: 0, pointerEvents: 'none' }}\n />\n {value ? <input type=\"hidden\" name={formFieldDataKey(name)} value={value} readOnly /> : null}\n </Stack>\n </FormControl>\n )\n },\n)\nProductBuilderAnswer.displayName = 'AglynProductBuilderAnswer'\n\n/**\n * The Product and options field's body: inside a Product detail block it\n * posts the shopper's picks there (AGL-4205), unless the author pinned it to\n * another product; anywhere else it asks for a product and its options.\n */\nconst ProductOptionsFieldBody = forwardRef<HTMLDivElement, ProductOptionsFieldProps>((props, ref) => {\n const picks = useContext(ProductBuilderContext)\n if (picks && (!props.productId || props.productId === picks.productId)) {\n return <ProductBuilderAnswer ref={ref} {...props} picks={picks} />\n }\n return <StoreProductPicker ref={ref} {...props} />\n})\nProductOptionsFieldBody.displayName = 'AglynProductOptionsFieldBody'\n\nexport default ProductOptionsFieldBody\n"],"names":["Aglyn","formFieldDataKey","builderPicksLabel","encodeProductFieldValue","productFieldLabel","Box","FormControl","FormHelperText","FormLabel","MenuItem","Stack","TextField","Typography","forwardRef","useContext","useEffect","useId","useMemo","useRef","useState","ProductBuilderContext","PICKER_LIMIT","variantForOptions","detail","picked","options","length","variants","id","some","option","name","match","find","variant","every","StoreProductPicker","props","ref","products","rawName","label","productId","fixedProductId","required","rest","String","trim","hostId","useSite","inputId","answerRef","setProducts","setProductId","setDetail","setPicked","active","query","URLSearchParams","ids","sort","limit","fetch","toString","then","response","ok","json","items","payload","Array","isArray","catch","slug","product","encodeURIComponent","undefined","variantId","complete","Boolean","answer","value","Object","keys","announced","current","dispatchEvent","Event","bubbles","listed","placeholder","fullWidth","htmlFor","spacing","sx","mt","position","select","size","onChange","event","target","disabled","slotProps","displayEmpty","renderValue","selected","component","color","map","mx","values","choice","error","type","tabIndex","aria-hidden","autoComplete","left","bottom","width","height","p","border","opacity","pointerEvents","input","readOnly","displayName","builderFieldValue","picks","ready","productName","addOnNames","quantity","modifiers","ProductBuilderAnswer","_fixed","labelId","chosen","entries","aria-labelledby","line","total","problem","ProductOptionsFieldBody"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,gBAAgB,QAAQ,qCAAiC;AAClE,SAASC,iBAAiB,EAAEC,uBAAuB,EAAEC,iBAAiB,QAAQ,qCAAiC;AAC/G,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,UAAU,EAAEC,UAAU,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAC3F,SAASC,qBAAqB,QAAkC,+BAA2B;AAkB3F,wCAAwC,GACxC,MAAMC,eAAe;AAErB,sEAAsE,GACtE,OAAO,SAASC,kBACdC,MAAmD,EACnDC,MAAwC;;QAELD;IAAnC,IAAI,CAACA,OAAOE,OAAO,CAACC,MAAM,EAAE,gBAAOH,oBAAAA,OAAOI,QAAQ,CAAC,EAAE,qBAAlBJ,kBAAoBK,EAAE,mBAAI;IAC7D,IAAIL,OAAOE,OAAO,CAACI,IAAI,CAAC,CAACC,SAAW,CAACN,MAAM,CAACM,OAAOC,IAAI,CAAC,GAAG,OAAO;IAClE,MAAMC,QAAQT,OAAOI,QAAQ,CAACM,IAAI,CAAC,CAACC,UAClCX,OAAOE,OAAO,CAACU,KAAK,CAAC,CAACL;gBAAWI;mBAAAA,EAAAA,mBAAAA,QAAQT,OAAO,qBAAfS,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;kCAC9CoB,MAAMC,KAAK,GAAG,8CAA8CD,MAAMc,OAAO,IAAI;;kCAEhF,KAAC3I;wBACCsG,WAAU;wBACVrE,KAAKa;wBACL+D,MAAK;wBACLnF,MAAMA;wBACNkD,OAAOD;wBACPpC,UAAUmC,QAAQnC;wBAClBuD,UAAU,IAAMvB;wBAChBuC,UAAU,CAAC;wBACXC,eAAY;wBACZC,cAAa;wBACbvB,IAAI;4BAAEE,UAAU;4BAAYsB,MAAM;4BAAGC,QAAQ;4BAAGC,OAAO;4BAAGC,QAAQ;4BAAOC,GAAG;4BAAGC,QAAQ;4BAAGC,SAAS;4BAAGC,eAAe;wBAAO;;oBAE7H5C,sBAAQ,KAAC6C;wBAAMZ,MAAK;wBAASnF,MAAM9B,iBAAiB8B;wBAAOkD,OAAOA;wBAAO8C,QAAQ;yBAAM;;;;;AAIhG;AAEFS,qBAAqBR,WAAW,GAAG;AAEnC;;;;CAIC,GACD,MAAMiB,wCAA0BpI,WAAqD,CAACwB,OAAOC;IAC3F,MAAM4F,QAAQpH,WAAWM;IACzB,IAAI8G,SAAU,CAAA,CAAC7F,MAAMK,SAAS,IAAIL,MAAMK,SAAS,KAAKwF,MAAMxF,SAAS,AAAD,GAAI;QACtE,qBAAO,KAAC8F;YAAqBlG,KAAKA;WAASD;YAAO6F,OAAOA;;IAC3D;IACA,qBAAO,KAAC9F;QAAmBE,KAAKA;OAASD;AAC3C;AACA4G,wBAAwBjB,WAAW,GAAG;AAEtC,eAAeiB,wBAAuB"}
@@ -86,7 +86,7 @@ export const schema = {
86
86
  {
87
87
  name: 'productId',
88
88
  label: 'Product',
89
- description: 'Ask about one product only: the person picks its options. Leave it empty to let them pick from your store.',
89
+ description: 'Ask about one product only: the person picks its options. Leave it empty to let them pick from your store, or in a Product detail block to use the page’s picks.',
90
90
  component: Aglyn.FieldComponentType.PRODUCT_SELECT
91
91
  },
92
92
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-options-field.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiPackageVariantClosed } from '@aglyn/shared-data-mdi'\nimport Box from '@mui/material/Box'\nimport CircularProgress from '@mui/material/CircularProgress'\nimport { forwardRef, lazy, Suspense } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n/*\n * THE PRODUCT AND OPTIONS FIELD (AGL-4098): a form field that asks which of\n * the store's products, and which of its options, a person wants — on a\n * \"Request a quote\" form, say.\n *\n * It lives in Commerce because the products are Commerce's, and it is a form\n * field like any other: it knows nothing about the form around it and posts\n * plain strings under its name. Its answer is the product and options in\n * words (`Vinyl banner — 3 × 6 ft / Matte`); beside it, under `{name}__data`,\n * it posts the exact product, variant and options for this plugin to read\n * back when a quote is started from the request (`parseProductFieldValue`).\n * The forms plugin keeps that value apart from the answers a person reads.\n *\n * This shell is what a page loads until the field draws; the picker is a\n * chunk of its own. The component id is persisted in documents; never rename\n * it. The core's form reader restates it (`FORM_PLUGIN_ANSWER_ELEMENTS`).\n */\nexport const PRODUCT_OPTIONS_FIELD_ID: Aglyn.ComponentId = 'product-options-field'\n\nexport interface ProductOptionsFieldProps {\n /** What the product and options are sent as. */\n name?: string\n /** The question, above the picker. */\n label?: string\n /** One product to ask about; empty lets the person pick from the store. */\n productId?: string\n required?: boolean\n}\n\nconst ProductOptionsFieldBody = lazy(() => import('./product-options-field-body'))\n\n/** A product and its options, picked from the store; sent in words. */\nconst ProductOptionsField = forwardRef<HTMLDivElement, ProductOptionsFieldProps>((props, ref) => (\n <Suspense\n fallback={\n <Box sx={{ py: 1 }}>\n <CircularProgress size={20} aria-label=\"Loading the product field\" />\n </Box>\n }\n >\n <ProductOptionsFieldBody ref={ref} {...props} />\n </Suspense>\n))\nProductOptionsField.displayName = 'AglynProductOptionsField'\n\nexport const schema: Aglyn.ComponentSchema<ProductOptionsFieldProps> = {\n $id: PRODUCT_OPTIONS_FIELD_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Product and options',\n description:\n 'A form field: the person picks one of your products and its options, such as size and finish. It arrives with the submission, and a quote started from it begins with that product.',\n category: Aglyn.ComponentCategory.FORMS,\n icon: { path: mdiPackageVariantClosed.path, sx: { color: 'info.main' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'label',\n label: 'Label',\n description: 'The question above the picker, such as “What would you like priced?”.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'name',\n label: 'Field name',\n description: 'The name the choice is listed under in the Inbox and exports.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'productId',\n label: 'Product',\n description: 'Ask about one product only: the person picks its options. Leave it empty to let them pick from your store.',\n component: Aglyn.FieldComponentType.PRODUCT_SELECT,\n },\n {\n name: 'required',\n label: 'Required?',\n description: 'The form can’t be sent until a product (and each of its options) is picked.',\n component: Aglyn.FieldComponentType.SWITCH,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(PRODUCT_OPTIONS_FIELD_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Product and options',\n pluginId: BUNDLE_ID,\n description: 'A product from your store and its options, for a quote request',\n category: Aglyn.ComponentCategory.FORMS,\n icon: { path: mdiPackageVariantClosed.path, sx: { color: 'info.main' } },\n data: {\n $id: null,\n componentId: PRODUCT_OPTIONS_FIELD_ID,\n pluginId: BUNDLE_ID,\n props: { name: 'product', label: 'Product', required: true },\n },\n },\n]\n\nexport default ProductOptionsField\n"],"names":["Aglyn","mdiPackageVariantClosed","Box","CircularProgress","forwardRef","lazy","Suspense","BUNDLE_ID","generatePresetId","PRODUCT_OPTIONS_FIELD_ID","ProductOptionsFieldBody","ProductOptionsField","props","ref","fallback","sx","py","size","aria-label","displayName","schema","$id","pluginId","description","category","ComponentCategory","FORMS","icon","path","color","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","name","label","component","FieldComponentType","TEXT_FIELD","PRODUCT_SELECT","SWITCH","presets","type","NodeType","PRESET","data","componentId","required"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,uBAAuB,QAAQ,yBAAwB;AAChE,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,sBAAsB,iCAAgC;AAC7D,SAASC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,QAAO;AAClD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,gBAAgB,QAAQ,iCAA6B;AAE9D;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,2BAA8C,wBAAuB;AAYlF,MAAMC,wCAA0BL,KAAK,IAAM,MAAM,CAAC;AAElD,qEAAqE,GACrE,MAAMM,oCAAsBP,WAAqD,CAACQ,OAAOC,oBACvF,KAACP;QACCQ,wBACE,KAACZ;YAAIa,IAAI;gBAAEC,IAAI;YAAE;sBACf,cAAA,KAACb;gBAAiBc,MAAM;gBAAIC,cAAW;;;kBAI3C,cAAA,KAACR;YAAwBG,KAAKA;WAASD;;AAG3CD,oBAAoBQ,WAAW,GAAG;AAElC,OAAO,MAAMC,SAA0D;IACrEC,KAAKZ;IACLa,UAAUf;IACVY,aAAa;IACbI,aACE;IACFC,UAAUxB,MAAMyB,iBAAiB,CAACC,KAAK;IACvCC,MAAM;QAAEC,MAAM3B,wBAAwB2B,IAAI;QAAEb,IAAI;YAAEc,OAAO;QAAY;IAAE;IACvEC,OAAO;QAAEC,aAAa/B,MAAMgC,YAAY,CAACC,OAAO;IAAC;IACjDC,YAAY;QACV;YACEC,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACC,UAAU;QAChD;QACA;YACEJ,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACC,UAAU;QAChD;QACA;YACEJ,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACE,cAAc;QACpD;QACA;YACEL,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACG,MAAM;QAC5C;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACErB,KAAKb,iBAAiBC;QACtBkC,MAAM3C,MAAM4C,QAAQ,CAACC,MAAM;QAC3B1B,aAAa;QACbG,UAAUf;QACVgB,aAAa;QACbC,UAAUxB,MAAMyB,iBAAiB,CAACC,KAAK;QACvCC,MAAM;YAAEC,MAAM3B,wBAAwB2B,IAAI;YAAEb,IAAI;gBAAEc,OAAO;YAAY;QAAE;QACvEiB,MAAM;YACJzB,KAAK;YACL0B,aAAatC;YACba,UAAUf;YACVK,OAAO;gBAAEuB,MAAM;gBAAWC,OAAO;gBAAWY,UAAU;YAAK;QAC7D;IACF;CACD,CAAA;AAED,eAAerC,oBAAmB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-options-field.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiPackageVariantClosed } from '@aglyn/shared-data-mdi'\nimport Box from '@mui/material/Box'\nimport CircularProgress from '@mui/material/CircularProgress'\nimport { forwardRef, lazy, Suspense } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n/*\n * THE PRODUCT AND OPTIONS FIELD (AGL-4098): a form field that asks which of\n * the store's products, and which of its options, a person wants — on a\n * \"Request a quote\" form, say.\n *\n * It lives in Commerce because the products are Commerce's, and it is a form\n * field like any other: it knows nothing about the form around it and posts\n * plain strings under its name. Its answer is the product and options in\n * words (`Vinyl banner — 3 × 6 ft / Matte`); beside it, under `{name}__data`,\n * it posts the exact product, variant and options for this plugin to read\n * back when a quote is started from the request (`parseProductFieldValue`).\n * The forms plugin keeps that value apart from the answers a person reads.\n *\n * This shell is what a page loads until the field draws; the picker is a\n * chunk of its own. The component id is persisted in documents; never rename\n * it. The core's form reader restates it (`FORM_PLUGIN_ANSWER_ELEMENTS`).\n */\nexport const PRODUCT_OPTIONS_FIELD_ID: Aglyn.ComponentId = 'product-options-field'\n\nexport interface ProductOptionsFieldProps {\n /** What the product and options are sent as. */\n name?: string\n /** The question, above the picker. */\n label?: string\n /** One product to ask about; empty lets the person pick from the store. */\n productId?: string\n required?: boolean\n}\n\nconst ProductOptionsFieldBody = lazy(() => import('./product-options-field-body'))\n\n/** A product and its options, picked from the store; sent in words. */\nconst ProductOptionsField = forwardRef<HTMLDivElement, ProductOptionsFieldProps>((props, ref) => (\n <Suspense\n fallback={\n <Box sx={{ py: 1 }}>\n <CircularProgress size={20} aria-label=\"Loading the product field\" />\n </Box>\n }\n >\n <ProductOptionsFieldBody ref={ref} {...props} />\n </Suspense>\n))\nProductOptionsField.displayName = 'AglynProductOptionsField'\n\nexport const schema: Aglyn.ComponentSchema<ProductOptionsFieldProps> = {\n $id: PRODUCT_OPTIONS_FIELD_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Product and options',\n description:\n 'A form field: the person picks one of your products and its options, such as size and finish. It arrives with the submission, and a quote started from it begins with that product.',\n category: Aglyn.ComponentCategory.FORMS,\n icon: { path: mdiPackageVariantClosed.path, sx: { color: 'info.main' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'label',\n label: 'Label',\n description: 'The question above the picker, such as “What would you like priced?”.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'name',\n label: 'Field name',\n description: 'The name the choice is listed under in the Inbox and exports.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'productId',\n label: 'Product',\n description: 'Ask about one product only: the person picks its options. Leave it empty to let them pick from your store, or in a Product detail block to use the page’s picks.',\n component: Aglyn.FieldComponentType.PRODUCT_SELECT,\n },\n {\n name: 'required',\n label: 'Required?',\n description: 'The form can’t be sent until a product (and each of its options) is picked.',\n component: Aglyn.FieldComponentType.SWITCH,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(PRODUCT_OPTIONS_FIELD_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Product and options',\n pluginId: BUNDLE_ID,\n description: 'A product from your store and its options, for a quote request',\n category: Aglyn.ComponentCategory.FORMS,\n icon: { path: mdiPackageVariantClosed.path, sx: { color: 'info.main' } },\n data: {\n $id: null,\n componentId: PRODUCT_OPTIONS_FIELD_ID,\n pluginId: BUNDLE_ID,\n props: { name: 'product', label: 'Product', required: true },\n },\n },\n]\n\nexport default ProductOptionsField\n"],"names":["Aglyn","mdiPackageVariantClosed","Box","CircularProgress","forwardRef","lazy","Suspense","BUNDLE_ID","generatePresetId","PRODUCT_OPTIONS_FIELD_ID","ProductOptionsFieldBody","ProductOptionsField","props","ref","fallback","sx","py","size","aria-label","displayName","schema","$id","pluginId","description","category","ComponentCategory","FORMS","icon","path","color","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","name","label","component","FieldComponentType","TEXT_FIELD","PRODUCT_SELECT","SWITCH","presets","type","NodeType","PRESET","data","componentId","required"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,uBAAuB,QAAQ,yBAAwB;AAChE,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,sBAAsB,iCAAgC;AAC7D,SAASC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,QAAO;AAClD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,gBAAgB,QAAQ,iCAA6B;AAE9D;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,2BAA8C,wBAAuB;AAYlF,MAAMC,wCAA0BL,KAAK,IAAM,MAAM,CAAC;AAElD,qEAAqE,GACrE,MAAMM,oCAAsBP,WAAqD,CAACQ,OAAOC,oBACvF,KAACP;QACCQ,wBACE,KAACZ;YAAIa,IAAI;gBAAEC,IAAI;YAAE;sBACf,cAAA,KAACb;gBAAiBc,MAAM;gBAAIC,cAAW;;;kBAI3C,cAAA,KAACR;YAAwBG,KAAKA;WAASD;;AAG3CD,oBAAoBQ,WAAW,GAAG;AAElC,OAAO,MAAMC,SAA0D;IACrEC,KAAKZ;IACLa,UAAUf;IACVY,aAAa;IACbI,aACE;IACFC,UAAUxB,MAAMyB,iBAAiB,CAACC,KAAK;IACvCC,MAAM;QAAEC,MAAM3B,wBAAwB2B,IAAI;QAAEb,IAAI;YAAEc,OAAO;QAAY;IAAE;IACvEC,OAAO;QAAEC,aAAa/B,MAAMgC,YAAY,CAACC,OAAO;IAAC;IACjDC,YAAY;QACV;YACEC,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACC,UAAU;QAChD;QACA;YACEJ,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACC,UAAU;QAChD;QACA;YACEJ,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACE,cAAc;QACpD;QACA;YACEL,MAAM;YACNC,OAAO;YACPb,aAAa;YACbc,WAAWrC,MAAMsC,kBAAkB,CAACG,MAAM;QAC5C;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACErB,KAAKb,iBAAiBC;QACtBkC,MAAM3C,MAAM4C,QAAQ,CAACC,MAAM;QAC3B1B,aAAa;QACbG,UAAUf;QACVgB,aAAa;QACbC,UAAUxB,MAAMyB,iBAAiB,CAACC,KAAK;QACvCC,MAAM;YAAEC,MAAM3B,wBAAwB2B,IAAI;YAAEb,IAAI;gBAAEc,OAAO;YAAY;QAAE;QACvEiB,MAAM;YACJzB,KAAK;YACL0B,aAAatC;YACba,UAAUf;YACVK,OAAO;gBAAEuB,MAAM;gBAAWC,OAAO;gBAAWY,UAAU;YAAK;QAC7D;IACF;CACD,CAAA;AAED,eAAerC,oBAAmB"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as Aglyn from '@aglyn/aglyn';
18
+ /**
19
+ * How a product card draws its photo: `cover` fills the card's frame and
20
+ * crops what does not fit; `contain` shows the whole photo inside the same
21
+ * frame, so a wide or tall shot keeps its ends.
22
+ */
23
+ export type ProductPhotoFit = 'cover' | 'contain';
24
+ /**
25
+ * The fit a stored value asks for. Anything but `contain` — no value, an
26
+ * older page, a value this build does not know — is `cover`, the way every
27
+ * card was drawn before the setting existed, so no existing site changes.
28
+ */
29
+ export declare function productPhotoFit(value: unknown): ProductPhotoFit;
30
+ /**
31
+ * The photo's own styles for a fit. `contain` keeps the frame's size (the
32
+ * caller's aspect ratio or height), so the cards in a row stay aligned, and
33
+ * sits the photo on the theme's quiet neutral (the no-photo tile's colour)
34
+ * with a little room, so a transparent cut-out and a full shot both read as
35
+ * framed on purpose.
36
+ */
37
+ export declare function productPhotoFitSx(fit: ProductPhotoFit): {
38
+ readonly objectFit: "contain";
39
+ readonly boxSizing: "border-box";
40
+ readonly p: 1.5;
41
+ readonly bgcolor: "action.hover";
42
+ } | {
43
+ readonly objectFit: "cover";
44
+ readonly boxSizing?: undefined;
45
+ readonly p?: undefined;
46
+ readonly bgcolor?: undefined;
47
+ };
48
+ /** The element setting both storefront card blocks carry. */
49
+ export declare const PRODUCT_PHOTO_FIT_ATTRIBUTE: Aglyn.AttributeSchema;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import * as Aglyn from "@aglyn/aglyn";
17
+ /**
18
+ * The fit a stored value asks for. Anything but `contain` — no value, an
19
+ * older page, a value this build does not know — is `cover`, the way every
20
+ * card was drawn before the setting existed, so no existing site changes.
21
+ */ export function productPhotoFit(value) {
22
+ return value === 'contain' ? 'contain' : 'cover';
23
+ }
24
+ /**
25
+ * The photo's own styles for a fit. `contain` keeps the frame's size (the
26
+ * caller's aspect ratio or height), so the cards in a row stay aligned, and
27
+ * sits the photo on the theme's quiet neutral (the no-photo tile's colour)
28
+ * with a little room, so a transparent cut-out and a full shot both read as
29
+ * framed on purpose.
30
+ */ export function productPhotoFitSx(fit) {
31
+ return fit === 'contain' ? {
32
+ objectFit: 'contain',
33
+ boxSizing: 'border-box',
34
+ p: 1.5,
35
+ bgcolor: 'action.hover'
36
+ } : {
37
+ objectFit: 'cover'
38
+ };
39
+ }
40
+ /** The element setting both storefront card blocks carry. */ export const PRODUCT_PHOTO_FIT_ATTRIBUTE = {
41
+ // Blank is `cover`, so a page that already places the block keeps its look.
42
+ name: 'photoFit',
43
+ label: 'Photo fit',
44
+ description: 'Fill the frame crops each photo to the card’s shape. Show the whole ' + 'photo fits it inside the card without cutting anything off.',
45
+ component: Aglyn.FieldComponentType.SELECT,
46
+ options: [
47
+ {
48
+ label: 'Fill the frame (crops to fit)',
49
+ value: 'cover'
50
+ },
51
+ {
52
+ label: 'Show the whole photo',
53
+ value: 'contain'
54
+ }
55
+ ]
56
+ };
57
+
58
+ //# sourceMappingURL=product-photo-fit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-photo-fit.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\n\n/**\n * How a product card draws its photo: `cover` fills the card's frame and\n * crops what does not fit; `contain` shows the whole photo inside the same\n * frame, so a wide or tall shot keeps its ends.\n */\nexport type ProductPhotoFit = 'cover' | 'contain'\n\n/**\n * The fit a stored value asks for. Anything but `contain` — no value, an\n * older page, a value this build does not know — is `cover`, the way every\n * card was drawn before the setting existed, so no existing site changes.\n */\nexport function productPhotoFit(value: unknown): ProductPhotoFit {\n return value === 'contain' ? 'contain' : 'cover'\n}\n\n/**\n * The photo's own styles for a fit. `contain` keeps the frame's size (the\n * caller's aspect ratio or height), so the cards in a row stay aligned, and\n * sits the photo on the theme's quiet neutral (the no-photo tile's colour)\n * with a little room, so a transparent cut-out and a full shot both read as\n * framed on purpose.\n */\nexport function productPhotoFitSx(fit: ProductPhotoFit) {\n return fit === 'contain'\n ? ({ objectFit: 'contain', boxSizing: 'border-box', p: 1.5, bgcolor: 'action.hover' } as const)\n : ({ objectFit: 'cover' } as const)\n}\n\n/** The element setting both storefront card blocks carry. */\nexport const PRODUCT_PHOTO_FIT_ATTRIBUTE: Aglyn.AttributeSchema = {\n // Blank is `cover`, so a page that already places the block keeps its look.\n name: 'photoFit',\n label: 'Photo fit',\n description:\n 'Fill the frame crops each photo to the card’s shape. Show the whole ' +\n 'photo fits it inside the card without cutting anything off.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { label: 'Fill the frame (crops to fit)', value: 'cover' },\n { label: 'Show the whole photo', value: 'contain' },\n ],\n}\n"],"names":["Aglyn","productPhotoFit","value","productPhotoFitSx","fit","objectFit","boxSizing","p","bgcolor","PRODUCT_PHOTO_FIT_ATTRIBUTE","name","label","description","component","FieldComponentType","SELECT","options"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AASrC;;;;CAIC,GACD,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,OAAOA,UAAU,YAAY,YAAY;AAC3C;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,kBAAkBC,GAAoB;IACpD,OAAOA,QAAQ,YACV;QAAEC,WAAW;QAAWC,WAAW;QAAcC,GAAG;QAAKC,SAAS;IAAe,IACjF;QAAEH,WAAW;IAAQ;AAC5B;AAEA,2DAA2D,GAC3D,OAAO,MAAMI,8BAAqD;IAChE,4EAA4E;IAC5EC,MAAM;IACNC,OAAO;IACPC,aACE,yEACA;IACFC,WAAWb,MAAMc,kBAAkB,CAACC,MAAM;IAC1CC,SAAS;QACP;YAAEL,OAAO;YAAiCT,OAAO;QAAQ;QACzD;YAAES,OAAO;YAAwBT,OAAO;QAAU;KACnD;AACH,EAAC"}
@@ -0,0 +1,12 @@
1
+ export interface ProductRestockNotifyProps {
2
+ hostId: string;
3
+ productId: string;
4
+ /** The site's fetch, which carries its App Check and session. */
5
+ siteFetch: (input: string, init?: RequestInit) => Promise<Response>;
6
+ }
7
+ /** An email field and "Notify me": the store emails the shopper when it is back. */
8
+ export declare function ProductRestockNotify(props: ProductRestockNotifyProps): import("react").JSX.Element;
9
+ export declare namespace ProductRestockNotify {
10
+ var displayName: string;
11
+ }
12
+ export default ProductRestockNotify;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ import Alert from "@mui/material/Alert";
19
+ import Box from "@mui/material/Box";
20
+ import Button from "@mui/material/Button";
21
+ import TextField from "@mui/material/TextField";
22
+ import { useState } from "react";
23
+ /** An email field and "Notify me": the store emails the shopper when it is back. */ export function ProductRestockNotify(props) {
24
+ const { hostId, productId, siteFetch } = props;
25
+ const [notifyEmail, setNotifyEmail] = useState('');
26
+ const [notifyState, setNotifyState] = useState('idle');
27
+ return notifyState === 'done' ? /*#__PURE__*/ _jsx(Alert, {
28
+ severity: "success",
29
+ sx: {
30
+ mb: 2
31
+ },
32
+ children: 'We will email you when it is back.'
33
+ }) : /*#__PURE__*/ _jsxs(Box, {
34
+ sx: {
35
+ display: 'flex',
36
+ gap: 1,
37
+ mb: 2
38
+ },
39
+ children: [
40
+ /*#__PURE__*/ _jsx(TextField, {
41
+ placeholder: "you@example.com",
42
+ type: "email",
43
+ // Third instance of the nameless-input defect (AGL-2392).
44
+ // Named for its job rather than "Email address": this row
45
+ // appears inside a product page that may also carry the
46
+ // newsletter block, and two fields both announced as
47
+ // "Email address" is barely better than none.
48
+ slotProps: {
49
+ htmlInput: {
50
+ 'aria-label': 'Email address for back-in-stock alert'
51
+ }
52
+ },
53
+ value: notifyEmail,
54
+ onChange: (event)=>setNotifyEmail(event.target.value),
55
+ size: "small",
56
+ sx: {
57
+ flex: 1
58
+ }
59
+ }),
60
+ /*#__PURE__*/ _jsx(Button, {
61
+ size: "small",
62
+ variant: "outlined",
63
+ disabled: !notifyEmail.trim(),
64
+ onClick: async ()=>{
65
+ const response = await siteFetch('/api/commerce/notify-restock', {
66
+ method: 'POST',
67
+ headers: {
68
+ 'Content-Type': 'application/json'
69
+ },
70
+ body: JSON.stringify({
71
+ hostId,
72
+ productId: productId,
73
+ email: notifyEmail
74
+ })
75
+ }).catch(()=>null);
76
+ if (response == null ? void 0 : response.ok) setNotifyState('done');
77
+ },
78
+ children: 'Notify me'
79
+ })
80
+ ]
81
+ });
82
+ }
83
+ ProductRestockNotify.displayName = 'ProductRestockNotify';
84
+ export default ProductRestockNotify;
85
+
86
+ //# sourceMappingURL=product-restock-notify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-restock-notify.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport TextField from '@mui/material/TextField'\nimport { useState } from 'react'\n\n/*\n * THE BACK-IN-STOCK ALERT on a product page, in its own chunk (split out of\n * the Product detail block for AGL-4205): only a page showing a sold-out\n * variant downloads it.\n */\n\nexport interface ProductRestockNotifyProps {\n hostId: string\n productId: string\n /** The site's fetch, which carries its App Check and session. */\n siteFetch: (input: string, init?: RequestInit) => Promise<Response>\n}\n\n/** An email field and \"Notify me\": the store emails the shopper when it is back. */\nexport function ProductRestockNotify(props: ProductRestockNotifyProps) {\n const { hostId, productId, siteFetch } = props\n const [notifyEmail, setNotifyEmail] = useState('')\n const [notifyState, setNotifyState] = useState<'idle' | 'done'>('idle')\n return notifyState === 'done' ? (\n <Alert severity=\"success\" sx={{ mb: 2 }}>\n {'We will email you when it is back.'}\n </Alert>\n ) : (\n <Box sx={{ display: 'flex', gap: 1, mb: 2 }}>\n <TextField\n placeholder=\"you@example.com\"\n type=\"email\"\n // Third instance of the nameless-input defect (AGL-2392).\n // Named for its job rather than \"Email address\": this row\n // appears inside a product page that may also carry the\n // newsletter block, and two fields both announced as\n // \"Email address\" is barely better than none.\n slotProps={{\n htmlInput: {\n 'aria-label': 'Email address for back-in-stock alert',\n },\n }}\n value={notifyEmail}\n onChange={(event) => setNotifyEmail(event.target.value)}\n size=\"small\"\n sx={{ flex: 1 }}\n />\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!notifyEmail.trim()}\n onClick={async () => {\n const response = await siteFetch('/api/commerce/notify-restock', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n productId: productId,\n email: notifyEmail,\n }),\n }).catch(() => null)\n if (response?.ok) setNotifyState('done')\n }}\n >\n {'Notify me'}\n </Button>\n </Box>\n )\n}\n\nProductRestockNotify.displayName = 'ProductRestockNotify'\n\nexport default ProductRestockNotify\n"],"names":["Alert","Box","Button","TextField","useState","ProductRestockNotify","props","hostId","productId","siteFetch","notifyEmail","setNotifyEmail","notifyState","setNotifyState","severity","sx","mb","display","gap","placeholder","type","slotProps","htmlInput","value","onChange","event","target","size","flex","variant","disabled","trim","onClick","response","method","headers","body","JSON","stringify","email","catch","ok","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,OAAOA,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,eAAe,0BAAyB;AAC/C,SAASC,QAAQ,QAAQ,QAAO;AAehC,kFAAkF,GAClF,OAAO,SAASC,qBAAqBC,KAAgC;IACnE,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH;IACzC,MAAM,CAACI,aAAaC,eAAe,GAAGP,SAAS;IAC/C,MAAM,CAACQ,aAAaC,eAAe,GAAGT,SAA0B;IAChE,OAAOQ,gBAAgB,uBACrB,KAACZ;QAAMc,UAAS;QAAUC,IAAI;YAAEC,IAAI;QAAE;kBACnC;uBAGH,MAACf;QAAIc,IAAI;YAAEE,SAAS;YAAQC,KAAK;YAAGF,IAAI;QAAE;;0BACxC,KAACb;gBACCgB,aAAY;gBACZC,MAAK;gBACL,0DAA0D;gBAC1D,0DAA0D;gBAC1D,wDAAwD;gBACxD,qDAAqD;gBACrD,8CAA8C;gBAC9CC,WAAW;oBACTC,WAAW;wBACT,cAAc;oBAChB;gBACF;gBACAC,OAAOb;gBACPc,UAAU,CAACC,QAAUd,eAAec,MAAMC,MAAM,CAACH,KAAK;gBACtDI,MAAK;gBACLZ,IAAI;oBAAEa,MAAM;gBAAE;;0BAEhB,KAAC1B;gBACCyB,MAAK;gBACLE,SAAQ;gBACRC,UAAU,CAACpB,YAAYqB,IAAI;gBAC3BC,SAAS;oBACP,MAAMC,WAAW,MAAMxB,UAAU,gCAAgC;wBAC/DyB,QAAQ;wBACRC,SAAS;4BAAE,gBAAgB;wBAAmB;wBAC9CC,MAAMC,KAAKC,SAAS,CAAC;4BACnB/B;4BACAC,WAAWA;4BACX+B,OAAO7B;wBACT;oBACF,GAAG8B,KAAK,CAAC,IAAM;oBACf,IAAIP,4BAAAA,SAAUQ,EAAE,EAAE5B,eAAe;gBACnC;0BAEC;;;;AAIT;AAEAR,qBAAqBqC,WAAW,GAAG;AAEnC,eAAerC,qBAAoB"}
@@ -0,0 +1,21 @@
1
+ import { type QuotePageView } from '../model';
2
+ /** The page's own fetch: the site's API, with the site's preview rules. */
3
+ type SiteFetch = (input: string, init?: RequestInit) => Promise<Response>;
4
+ export interface QuoteMessagesPanelProps {
5
+ view: QuotePageView;
6
+ hostId: string;
7
+ quoteId: string;
8
+ token: string;
9
+ siteFetch: SiteFetch;
10
+ /** The link was replaced. */
11
+ onReplaced: () => void;
12
+ }
13
+ /**
14
+ * The customer's conversation with the business about the quote (AGL-4207),
15
+ * on the quote page: what the business replied from the quote, what the
16
+ * customer wrote here, and a box to write more. The business is told in
17
+ * Aglyn and by email, and answers by email, in the same conversation as the
18
+ * quote. The same composer as the Inbox's reply (`ReplyComposer`).
19
+ */
20
+ export declare function QuoteMessagesPanel(props: QuoteMessagesPanelProps): import("react").JSX.Element;
21
+ export default QuoteMessagesPanel;