@aglyn/plugins-commerce 1.31.0 → 1.33.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 (123) hide show
  1. package/README.md +4 -0
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +35 -15
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/commerce-console-page.js +6 -0
  6. package/src/lib/components/commerce-console-page.js.map +1 -1
  7. package/src/lib/components/console/currencies-card.component.d.ts +21 -0
  8. package/src/lib/components/console/currencies-card.component.js +408 -0
  9. package/src/lib/components/console/currencies-card.component.js.map +1 -0
  10. package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
  11. package/src/lib/components/console/product-add-ons-fields.component.js +74 -2
  12. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  13. package/src/lib/components/console/product-editor-dialog.component.js +42 -1
  14. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  15. package/src/lib/components/console/product-fixed-prices-fields.component.d.ts +25 -0
  16. package/src/lib/components/console/product-fixed-prices-fields.component.js +112 -0
  17. package/src/lib/components/console/product-fixed-prices-fields.component.js.map +1 -0
  18. package/src/lib/components/console/reservations-card.component.js +32 -15
  19. package/src/lib/components/console/reservations-card.component.js.map +1 -1
  20. package/src/lib/components/console/shipping-settings-card.component.js +337 -10
  21. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  22. package/src/lib/components/console/store-settings-card.component.js +1 -1
  23. package/src/lib/components/console/store-settings-card.component.js.map +1 -1
  24. package/src/lib/components/console/use-currency-setup.d.ts +20 -0
  25. package/src/lib/components/console/use-currency-setup.js +61 -0
  26. package/src/lib/components/console/use-currency-setup.js.map +1 -0
  27. package/src/lib/components/currency-selector.d.ts +36 -0
  28. package/src/lib/components/currency-selector.js +157 -0
  29. package/src/lib/components/currency-selector.js.map +1 -0
  30. package/src/lib/components/product-add-ons.d.ts +9 -1
  31. package/src/lib/components/product-add-ons.js +8 -4
  32. package/src/lib/components/product-add-ons.js.map +1 -1
  33. package/src/lib/components/product-choice-cards.d.ts +13 -1
  34. package/src/lib/components/product-choice-cards.js +5 -4
  35. package/src/lib/components/product-choice-cards.js.map +1 -1
  36. package/src/lib/components/product-detail.d.ts +8 -0
  37. package/src/lib/components/product-detail.js +38 -11
  38. package/src/lib/components/product-detail.js.map +1 -1
  39. package/src/lib/components/product-grid.d.ts +2 -0
  40. package/src/lib/components/product-grid.js +22 -9
  41. package/src/lib/components/product-grid.js.map +1 -1
  42. package/src/lib/components/related-products.js +6 -2
  43. package/src/lib/components/related-products.js.map +1 -1
  44. package/src/lib/components/shopper-currency.d.ts +108 -0
  45. package/src/lib/components/shopper-currency.js +262 -0
  46. package/src/lib/components/shopper-currency.js.map +1 -0
  47. package/src/lib/components/wishlist.js +7 -1
  48. package/src/lib/components/wishlist.js.map +1 -1
  49. package/src/lib/declarations.server.js +39 -0
  50. package/src/lib/declarations.server.js.map +1 -1
  51. package/src/lib/model/commerce-currency-setup.d.ts +79 -0
  52. package/src/lib/model/commerce-currency-setup.js +124 -0
  53. package/src/lib/model/commerce-currency-setup.js.map +1 -0
  54. package/src/lib/model/commerce-currency.d.ts +215 -0
  55. package/src/lib/model/commerce-currency.js +511 -0
  56. package/src/lib/model/commerce-currency.js.map +1 -0
  57. package/src/lib/model/commerce-orders.d.ts +17 -0
  58. package/src/lib/model/commerce-orders.js +10 -5
  59. package/src/lib/model/commerce-orders.js.map +1 -1
  60. package/src/lib/model/commerce-record-routes.js +26 -1
  61. package/src/lib/model/commerce-record-routes.js.map +1 -1
  62. package/src/lib/model/commerce-reservations.d.ts +6 -0
  63. package/src/lib/model/commerce-reservations.js.map +1 -1
  64. package/src/lib/model/commerce-shipping.d.ts +66 -11
  65. package/src/lib/model/commerce-shipping.js +91 -7
  66. package/src/lib/model/commerce-shipping.js.map +1 -1
  67. package/src/lib/model/commerce.d.ts +6 -0
  68. package/src/lib/model/commerce.js.map +1 -1
  69. package/src/lib/model/index.d.ts +2 -0
  70. package/src/lib/model/index.js +2 -0
  71. package/src/lib/model/index.js.map +1 -1
  72. package/src/lib/model/order-figures.js +9 -2
  73. package/src/lib/model/order-figures.js.map +1 -1
  74. package/src/lib/model/product-modifiers.d.ts +5 -0
  75. package/src/lib/model/product-modifiers.js.map +1 -1
  76. package/src/lib/model/store-setup-content.js +23 -2
  77. package/src/lib/model/store-setup-content.js.map +1 -1
  78. package/src/lib/server/billing-webhook.js +37 -24
  79. package/src/lib/server/billing-webhook.js.map +1 -1
  80. package/src/lib/server/carrier-shipping.d.ts +2 -0
  81. package/src/lib/server/carrier-shipping.js +8 -4
  82. package/src/lib/server/carrier-shipping.js.map +1 -1
  83. package/src/lib/server/cart-checkout.js +74 -13
  84. package/src/lib/server/cart-checkout.js.map +1 -1
  85. package/src/lib/server/cart.d.ts +12 -0
  86. package/src/lib/server/cart.js +50 -4
  87. package/src/lib/server/cart.js.map +1 -1
  88. package/src/lib/server/catalog.d.ts +5 -0
  89. package/src/lib/server/catalog.js +7 -0
  90. package/src/lib/server/catalog.js.map +1 -1
  91. package/src/lib/server/checkout.js +53 -12
  92. package/src/lib/server/checkout.js.map +1 -1
  93. package/src/lib/server/currency.d.ts +93 -0
  94. package/src/lib/server/currency.js +182 -0
  95. package/src/lib/server/currency.js.map +1 -0
  96. package/src/lib/server/order-notifications.js +4 -2
  97. package/src/lib/server/order-notifications.js.map +1 -1
  98. package/src/lib/server/product.d.ts +9 -0
  99. package/src/lib/server/product.js +12 -0
  100. package/src/lib/server/product.js.map +1 -1
  101. package/src/lib/server/refund.js +3 -3
  102. package/src/lib/server/refund.js.map +1 -1
  103. package/src/lib/server/site-chat-tools.d.ts +22 -0
  104. package/src/lib/server/site-chat-tools.js +369 -0
  105. package/src/lib/server/site-chat-tools.js.map +1 -0
  106. package/src/lib/server/site-chat-visitor.d.ts +24 -0
  107. package/src/lib/server/site-chat-visitor.js +39 -0
  108. package/src/lib/server/site-chat-visitor.js.map +1 -0
  109. package/src/lib/server/site-offers.d.ts +31 -0
  110. package/src/lib/server/site-offers.js +91 -0
  111. package/src/lib/server/site-offers.js.map +1 -0
  112. package/src/lib/server/stays-site-search.d.ts +20 -0
  113. package/src/lib/server/stays-site-search.js +78 -0
  114. package/src/lib/server/stays-site-search.js.map +1 -0
  115. package/src/lib/server.js +20 -0
  116. package/src/lib/server.js.map +1 -1
  117. package/src/lib/site-chat-tool-definitions.d.ts +26 -0
  118. package/src/lib/site-chat-tool-definitions.js +141 -0
  119. package/src/lib/site-chat-tool-definitions.js.map +1 -0
  120. package/src/lib/site.js +8 -0
  121. package/src/lib/site.js.map +1 -1
  122. package/src/lib/subprocessors.js +7 -0
  123. package/src/lib/subprocessors.js.map +1 -1
@@ -0,0 +1,157 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ /**
5
+ * @license
6
+ * Copyright 2026 Aglyn LLC
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */ import * as Aglyn from "@aglyn/aglyn";
20
+ import { mdiCurrencyUsd } from "@aglyn/shared-data-mdi";
21
+ import Box from "@mui/material/Box";
22
+ import MenuItem from "@mui/material/MenuItem";
23
+ import TextField from "@mui/material/TextField";
24
+ import { forwardRef } from "react";
25
+ import { BUNDLE_ID } from "../constants/bundle-common.js";
26
+ import { generatePresetId } from "../utils/generate-preset-id.js";
27
+ import { useShopperCurrency } from "./shopper-currency.js";
28
+ // Component ids are persisted in screen documents; never rename.
29
+ export const ID = 'currency-selector';
30
+ /** The sign a currency prints with, narrow: `$` for every dollar, `€`, `£`. */ function currencySign(code) {
31
+ try {
32
+ var _ref;
33
+ var _formatToParts_find;
34
+ return (_ref = (_formatToParts_find = new Intl.NumberFormat('en', {
35
+ style: 'currency',
36
+ currency: code,
37
+ currencyDisplay: 'narrowSymbol'
38
+ }).formatToParts(0).find((part)=>part.type === 'currency')) == null ? void 0 : _formatToParts_find.value) != null ? _ref : '';
39
+ } catch (unused) {
40
+ return '';
41
+ }
42
+ }
43
+ /** One currency as the selector lists it: `NZD $ · New Zealand dollar`. */ export function currencyOptionLabel(code, name) {
44
+ const sign = currencySign(code);
45
+ const head = sign && sign !== code ? `${code} ${sign}` : code;
46
+ return name ? `${head} · ${name}` : head;
47
+ }
48
+ /**
49
+ * Currency selector (AGL-4248): the shopper picks which of the store's
50
+ * currencies prices show and checkout charges in, remembered on this device.
51
+ * Renders nothing on a store that sells in one currency, or until the store
52
+ * says what it sells in; on the canvas it shows a sample to design with.
53
+ */ const CurrencySelector = /*#__PURE__*/ forwardRef((props, ref)=>{
54
+ const { label, showName = true } = props, rest = _object_without_properties_loose(props, [
55
+ "label",
56
+ "showName"
57
+ ]);
58
+ // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).
59
+ const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [
60
+ props['sx']
61
+ ];
62
+ const { hostId } = Aglyn.useSite();
63
+ const shopper = useShopperCurrency();
64
+ const codes = hostId ? shopper.currencies.map((entry)=>entry.code) : [
65
+ 'USD',
66
+ 'EUR',
67
+ 'GBP'
68
+ ];
69
+ if (hostId && (!shopper.ready || codes.length < 2)) return null;
70
+ return /*#__PURE__*/ _jsx(Box, _extends({
71
+ ref: ref
72
+ }, rest, {
73
+ sx: [
74
+ {
75
+ display: 'inline-flex',
76
+ minWidth: 120
77
+ },
78
+ ...nodeSx
79
+ ],
80
+ children: /*#__PURE__*/ _jsx(TextField, {
81
+ select: true,
82
+ size: "small",
83
+ label: label || undefined,
84
+ value: hostId ? shopper.code : 'USD',
85
+ disabled: !hostId,
86
+ onChange: (event)=>shopper.setCurrency(String(event.target.value)),
87
+ slotProps: {
88
+ htmlInput: {
89
+ 'aria-label': label || 'Currency'
90
+ }
91
+ },
92
+ fullWidth: true,
93
+ children: codes.map((code)=>/*#__PURE__*/ _jsx(MenuItem, {
94
+ value: code,
95
+ children: currencyOptionLabel(code, showName ? shopper.currencyName(code) : undefined)
96
+ }, code))
97
+ })
98
+ }));
99
+ });
100
+ CurrencySelector.displayName = 'AglynCurrencySelector';
101
+ export const schema = {
102
+ $id: ID,
103
+ pluginId: BUNDLE_ID,
104
+ displayName: 'Currency selector',
105
+ description: 'Lets shoppers pick the currency prices show in, from the currencies the store sells in. ' + 'Hidden when the store sells in one currency.',
106
+ category: Aglyn.ComponentCategory.COMMERCE,
107
+ icon: {
108
+ path: mdiCurrencyUsd.path,
109
+ sx: {
110
+ color: 'success.main'
111
+ }
112
+ },
113
+ flags: {
114
+ selfClosing: Aglyn.FEATURE_FLAG.ENABLED
115
+ },
116
+ attributes: [
117
+ {
118
+ name: 'label',
119
+ label: 'Label',
120
+ description: 'Shown above the list. Leave empty for a compact header.',
121
+ component: Aglyn.FieldComponentType.TEXT_FIELD
122
+ },
123
+ {
124
+ name: 'showName',
125
+ label: 'Show currency names',
126
+ description: 'List "NZD $ · New Zealand dollar" rather than "NZD $".',
127
+ component: Aglyn.FieldComponentType.CHECKBOX
128
+ }
129
+ ]
130
+ };
131
+ export const presets = [
132
+ {
133
+ $id: generatePresetId(ID),
134
+ type: Aglyn.NodeType.PRESET,
135
+ displayName: 'Currency selector',
136
+ pluginId: BUNDLE_ID,
137
+ description: 'Shoppers pick the currency prices show in',
138
+ category: Aglyn.ComponentCategory.COMMERCE,
139
+ icon: {
140
+ path: mdiCurrencyUsd.path,
141
+ sx: {
142
+ color: 'success.main'
143
+ }
144
+ },
145
+ data: {
146
+ $id: null,
147
+ componentId: ID,
148
+ pluginId: BUNDLE_ID,
149
+ props: {
150
+ showName: true
151
+ }
152
+ }
153
+ }
154
+ ];
155
+ export default CurrencySelector;
156
+
157
+ //# sourceMappingURL=currency-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/currency-selector.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 { mdiCurrencyUsd } from '@aglyn/shared-data-mdi'\nimport Box from '@mui/material/Box'\nimport MenuItem from '@mui/material/MenuItem'\nimport TextField from '@mui/material/TextField'\nimport { forwardRef } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { useShopperCurrency } from './shopper-currency'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'currency-selector'\n\nexport interface CurrencySelectorProps {\n /** Shown above the select; none by default, for a compact header. */\n label?: string\n /** Each currency's name after its code and sign (\"New Zealand dollar\"). */\n showName?: boolean\n}\n\n/** The sign a currency prints with, narrow: `$` for every dollar, `€`, `£`. */\nfunction currencySign(code: string): string {\n try {\n return (\n new Intl.NumberFormat('en', { style: 'currency', currency: code, currencyDisplay: 'narrowSymbol' })\n .formatToParts(0)\n .find((part) => part.type === 'currency')?.value ?? ''\n )\n } catch {\n return ''\n }\n}\n\n/** One currency as the selector lists it: `NZD $ · New Zealand dollar`. */\nexport function currencyOptionLabel(code: string, name?: string): string {\n const sign = currencySign(code)\n const head = sign && sign !== code ? `${code} ${sign}` : code\n return name ? `${head} · ${name}` : head\n}\n\n/**\n * Currency selector (AGL-4248): the shopper picks which of the store's\n * currencies prices show and checkout charges in, remembered on this device.\n * Renders nothing on a store that sells in one currency, or until the store\n * says what it sells in; on the canvas it shows a sample to design with.\n */\nconst CurrencySelector = forwardRef<HTMLDivElement, CurrencySelectorProps>((props, ref) => {\n const { label, showName = true, ...rest } = props\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const shopper = useShopperCurrency()\n\n const codes = hostId ? shopper.currencies.map((entry) => entry.code) : ['USD', 'EUR', 'GBP']\n if (hostId && (!shopper.ready || codes.length < 2)) return null\n\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'inline-flex', minWidth: 120 }, ...nodeSx]}>\n <TextField\n select\n size=\"small\"\n label={label || undefined}\n value={hostId ? shopper.code : 'USD'}\n disabled={!hostId}\n onChange={(event) => shopper.setCurrency(String(event.target.value))}\n slotProps={{ htmlInput: { 'aria-label': label || 'Currency' } }}\n fullWidth\n >\n {codes.map((code) => (\n <MenuItem key={code} value={code}>\n {currencyOptionLabel(code, showName ? shopper.currencyName(code) : undefined)}\n </MenuItem>\n ))}\n </TextField>\n </Box>\n )\n})\nCurrencySelector.displayName = 'AglynCurrencySelector'\n\nexport const schema: Aglyn.ComponentSchema<CurrencySelectorProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Currency selector',\n description:\n 'Lets shoppers pick the currency prices show in, from the currencies the store sells in. ' +\n 'Hidden when the store sells in one currency.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCurrencyUsd.path, sx: { color: 'success.main' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'label',\n label: 'Label',\n description: 'Shown above the list. Leave empty for a compact header.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'showName',\n label: 'Show currency names',\n description: 'List \"NZD $ · New Zealand dollar\" rather than \"NZD $\".',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Currency selector',\n pluginId: BUNDLE_ID,\n description: 'Shoppers pick the currency prices show in',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCurrencyUsd.path, sx: { color: 'success.main' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { showName: true },\n },\n },\n]\n\nexport default CurrencySelector\n"],"names":["Aglyn","mdiCurrencyUsd","Box","MenuItem","TextField","forwardRef","BUNDLE_ID","generatePresetId","useShopperCurrency","ID","currencySign","code","Intl","NumberFormat","style","currency","currencyDisplay","formatToParts","find","part","type","value","currencyOptionLabel","name","sign","head","CurrencySelector","props","ref","label","showName","rest","nodeSx","Array","isArray","hostId","useSite","shopper","codes","currencies","map","entry","ready","length","sx","display","minWidth","select","size","undefined","disabled","onChange","event","setCurrency","String","target","slotProps","htmlInput","fullWidth","currencyName","displayName","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","path","color","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","component","FieldComponentType","TEXT_FIELD","CHECKBOX","presets","NodeType","PRESET","data","componentId"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,cAAc,QAAQ,yBAAwB;AACvD,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,eAAe,0BAAyB;AAC/C,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,kBAAkB,QAAQ,wBAAoB;AAEvD,iEAAiE;AACjE,OAAO,MAAMC,KAAwB,oBAAmB;AASxD,6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K;YACLsB,aAAa3E;YACbsD,UAAUzD;YACVqB,OAAO;gBAAEG,UAAU;YAAK;QAC1B;IACF;CACD,CAAA;AAED,eAAeJ,iBAAgB"}
@@ -1,4 +1,4 @@
1
- import { type ModifierSelection, type ProductModifierGroup } from '../model/product-modifiers';
1
+ import { type ModifierSelection, type ProductModifierGroup, type ProductModifierOption } from '../model/product-modifiers';
2
2
  export interface ProductAddOnsProps {
3
3
  /** The groups the website shows, as the product's page received them. */
4
4
  groups: readonly ProductModifierGroup[];
@@ -8,6 +8,11 @@ export interface ProductAddOnsProps {
8
8
  onChange: (next: ModifierSelection[]) => void;
9
9
  /** The store's money, e.g. `$1,250.00`. */
10
10
  formatCents: (cents: number) => string;
11
+ /**
12
+ * What a choice adds, in the shopper's currency (AGL-4248): its fixed
13
+ * amount there when it has one. Absent: `formatCents` of its store price.
14
+ */
15
+ formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string;
11
16
  disabled?: boolean;
12
17
  }
13
18
  /** The picks with one group's answer replaced, in the groups' own order. */
@@ -25,8 +30,11 @@ export interface ProductWriteInFieldProps {
25
30
  value: readonly ModifierSelection[];
26
31
  onChange: (next: ModifierSelection[]) => void;
27
32
  formatCents: (cents: number) => string;
33
+ formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string;
28
34
  disabled?: boolean;
29
35
  }
36
+ /** What a choice adds, as money: the shopper's formatter when given, else the store's. */
37
+ export declare function addOnMoney(option: ProductModifierOption, variantId: string | null | undefined, formatCents: (cents: number) => string, formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string): string;
30
38
  /**
31
39
  * One write-in on a product's page: a text field named after the group, with
32
40
  * the merchant's note, what a filled answer adds and a count of characters
@@ -70,6 +70,9 @@ import { modifierGroupIsWriteIn, modifierGroupRequired, modifierOptionPriceCents
70
70
  return ((_order_get = order.get(x.groupId)) != null ? _order_get : 0) - ((_order_get1 = order.get(y.groupId)) != null ? _order_get1 : 0);
71
71
  });
72
72
  }
73
+ /** What a choice adds, as money: the shopper's formatter when given, else the store's. */ export function addOnMoney(option, variantId, formatCents, formatAddOn) {
74
+ return formatAddOn ? formatAddOn(option, variantId) : formatCents(modifierOptionPriceCents(option, variantId));
75
+ }
73
76
  /**
74
77
  * One write-in on a product's page: a text field named after the group, with
75
78
  * the merchant's note, what a filled answer adds and a count of characters
@@ -77,7 +80,7 @@ import { modifierGroupIsWriteIn, modifierGroupRequired, modifierOptionPriceCents
77
80
  */ export function ProductWriteInField(props) {
78
81
  var _ref;
79
82
  var _value_find;
80
- const { group, groups, variantId, value, onChange, formatCents, disabled } = props;
83
+ const { group, groups, variantId, value, onChange, formatCents, formatAddOn, disabled } = props;
81
84
  const option = group.options[0];
82
85
  const text = (_ref = (_value_find = value.find((pick)=>pick.groupId === group.id)) == null ? void 0 : _value_find.text) != null ? _ref : '';
83
86
  const limit = writeInMaxLength(group);
@@ -85,7 +88,7 @@ import { modifierGroupIsWriteIn, modifierGroupRequired, modifierOptionPriceCents
85
88
  const cents = option ? modifierOptionPriceCents(option, variantId) : 0;
86
89
  const hint = [
87
90
  option == null ? void 0 : option.note,
88
- cents > 0 ? `Adds ${formatCents(cents)}` : null,
91
+ cents > 0 && option ? `Adds ${addOnMoney(option, variantId, formatCents, formatAddOn)}` : null,
89
92
  `${Array.from(text).length}/${limit}`
90
93
  ].filter(Boolean).join(' · ');
91
94
  return /*#__PURE__*/ _jsx(TextField, {
@@ -121,10 +124,10 @@ import { modifierGroupIsWriteIn, modifierGroupRequired, modifierOptionPriceCents
121
124
  * as the form builder marks a required field. Its own chunk, loaded only by a
122
125
  * product that has add-ons on the website.
123
126
  */ export function ProductAddOns(props) {
124
- const { groups, variantId, value, onChange, formatCents, disabled } = props;
127
+ const { groups, variantId, value, onChange, formatCents, formatAddOn, disabled } = props;
125
128
  const priceLabel = (option)=>{
126
129
  const cents = modifierOptionPriceCents(option, variantId);
127
- return cents > 0 ? `${option.name} (+${formatCents(cents)})` : option.name;
130
+ return cents > 0 ? `${option.name} (+${addOnMoney(option, variantId, formatCents, formatAddOn)})` : option.name;
128
131
  };
129
132
  return /*#__PURE__*/ _jsx(Stack, {
130
133
  spacing: 1.5,
@@ -140,6 +143,7 @@ import { modifierGroupIsWriteIn, modifierGroupRequired, modifierOptionPriceCents
140
143
  value: value,
141
144
  onChange: onChange,
142
145
  formatCents: formatCents,
146
+ formatAddOn: formatAddOn,
143
147
  disabled: disabled
144
148
  }, group.id);
145
149
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-add-ons.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 Checkbox from '@mui/material/Checkbox'\nimport FormControl from '@mui/material/FormControl'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport FormGroup from '@mui/material/FormGroup'\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 {\n modifierGroupIsWriteIn,\n modifierGroupRequired,\n modifierOptionPriceCents,\n writeInMaxLength,\n writeInProblem,\n type ModifierSelection,\n type ProductModifierGroup,\n type ProductModifierOption,\n} from '../model/product-modifiers'\n\nexport interface ProductAddOnsProps {\n /** The groups the website shows, as the product's page received them. */\n groups: readonly ProductModifierGroup[]\n /** The variant picked: a choice priced by variant shows its price on it. */\n variantId?: string\n value: readonly ModifierSelection[]\n onChange: (next: ModifierSelection[]) => void\n /** The store's money, e.g. `$1,250.00`. */\n formatCents: (cents: number) => string\n disabled?: boolean\n}\n\n/** The picks with one group's answer replaced, in the groups' own order. */\nexport function withGroupAnswer(\n groups: readonly ProductModifierGroup[],\n value: readonly ModifierSelection[],\n groupId: string,\n optionIds: readonly string[],\n): ModifierSelection[] {\n const others = value.filter((pick) => pick.groupId !== groupId)\n const answer = optionIds.map((optionId) => ({ groupId, optionId }))\n const order = new Map(groups.map((group, index) => [group.id, index]))\n return [...others, ...answer].sort(\n (a, b) => (order.get(a.groupId) ?? 0) - (order.get(b.groupId) ?? 0),\n )\n}\n\n/**\n * The picks with a write-in's answer replaced (write-ins): the\n * text as typed so far, kept while it is being typed; an empty answer leaves\n * the group unanswered. The server cleans and checks it.\n */\nexport function withWriteInAnswer(\n groups: readonly ProductModifierGroup[],\n value: readonly ModifierSelection[],\n group: ProductModifierGroup,\n text: string,\n): ModifierSelection[] {\n const option = group.options[0]\n const others = value.filter((pick) => pick.groupId !== group.id)\n const answer = option && text.trim() ? [{ groupId: group.id, optionId: option.id, text }] : []\n const order = new Map(groups.map((entry, index) => [entry.id, index]))\n return [...others, ...answer].sort((x, y) => (order.get(x.groupId) ?? 0) - (order.get(y.groupId) ?? 0))\n}\n\nexport interface ProductWriteInFieldProps {\n group: ProductModifierGroup\n groups: readonly ProductModifierGroup[]\n variantId?: string\n value: readonly ModifierSelection[]\n onChange: (next: ModifierSelection[]) => void\n formatCents: (cents: number) => string\n disabled?: boolean\n}\n\n/**\n * One write-in on a product's page: a text field named after the group, with\n * the merchant's note, what a filled answer adds and a count of characters\n * under it, or what is wrong with what was typed.\n */\nexport function ProductWriteInField(props: ProductWriteInFieldProps) {\n const { group, groups, variantId, value, onChange, formatCents, disabled } = props\n const option = group.options[0]\n const text = value.find((pick) => pick.groupId === group.id)?.text ?? ''\n const limit = writeInMaxLength(group)\n const problem = writeInProblem(group, text)\n const cents = option ? modifierOptionPriceCents(option, variantId) : 0\n const hint = [option?.note, cents > 0 ? `Adds ${formatCents(cents)}` : null, `${Array.from(text).length}/${limit}`]\n .filter(Boolean)\n .join(' · ')\n return (\n <TextField\n size=\"small\"\n fullWidth\n required={modifierGroupRequired(group)}\n disabled={disabled}\n label={group.name}\n value={text}\n error={Boolean(problem)}\n onChange={(event) => onChange(withWriteInAnswer(groups, value, group, event.target.value))}\n helperText={problem ?? hint}\n slotProps={{\n htmlInput: {\n maxLength: limit,\n ...(group.digitsOnly ? { inputMode: 'numeric', pattern: '[0-9]*' } : {}),\n },\n }}\n />\n )\n}\n\n/** What a group asks for, said under it. */\nexport function addOnGroupHint(group: Pick<ProductModifierGroup, 'min' | 'max'>): string {\n if (group.max === 1) return group.min > 0 ? 'Choose one' : 'Optional'\n if (group.min > 0 && group.min === group.max) return `Choose ${group.min}`\n if (group.min > 0) return `Choose ${group.min} to ${group.max}`\n return `Choose up to ${group.max}`\n}\n\n/**\n * The add-ons a product's page offers (AGL-4100): a group that takes one\n * choice is a select, one that takes several is a set of checkboxes, each\n * choice with what it adds on the picked variant. A required group is marked\n * as the form builder marks a required field. Its own chunk, loaded only by a\n * product that has add-ons on the website.\n */\nexport function ProductAddOns(props: ProductAddOnsProps) {\n const { groups, variantId, value, onChange, formatCents, disabled } = props\n const priceLabel = (option: ProductModifierOption) => {\n const cents = modifierOptionPriceCents(option, variantId)\n return cents > 0 ? `${option.name} (+${formatCents(cents)})` : option.name\n }\n return (\n <Stack spacing={1.5} sx={{ mb: 1.5 }}>\n {groups.map((group) => {\n if (modifierGroupIsWriteIn(group)) {\n return (\n <ProductWriteInField\n key={group.id}\n group={group}\n groups={groups}\n variantId={variantId}\n value={value}\n onChange={onChange}\n formatCents={formatCents}\n disabled={disabled}\n />\n )\n }\n const chosen = value\n .filter((pick) => pick.groupId === group.id)\n .map((pick) => pick.optionId)\n const required = modifierGroupRequired(group)\n if (group.max === 1) {\n return (\n <TextField\n key={group.id}\n select\n size=\"small\"\n fullWidth\n required={required}\n disabled={disabled}\n label={group.name}\n value={chosen[0] ?? ''}\n onChange={(event) =>\n onChange(\n withGroupAnswer(\n groups,\n value,\n group.id,\n event.target.value ? [String(event.target.value)] : [],\n ),\n )\n }\n helperText={addOnGroupHint(group)}\n >\n {required ? null : (\n <MenuItem value=\"\">\n <em>{'None'}</em>\n </MenuItem>\n )}\n {group.options.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {priceLabel(option)}\n </MenuItem>\n ))}\n </TextField>\n )\n }\n const full = chosen.length >= group.max\n return (\n <FormControl\n key={group.id}\n component=\"fieldset\"\n required={required}\n disabled={disabled}\n variant=\"standard\"\n >\n <FormLabel component=\"legend\">{group.name}</FormLabel>\n <FormGroup>\n {group.options.map((option) => {\n const checked = chosen.includes(option.id)\n return (\n <FormControlLabel\n key={option.id}\n control={\n <Checkbox\n size=\"small\"\n checked={checked}\n disabled={disabled || (!checked && full)}\n onChange={(event) =>\n onChange(\n withGroupAnswer(\n groups,\n value,\n group.id,\n event.target.checked\n ? group.options\n .map((entry) => entry.id)\n .filter((id) => id === option.id || chosen.includes(id))\n : chosen.filter((id) => id !== option.id),\n ),\n )\n }\n />\n }\n label={priceLabel(option)}\n />\n )\n })}\n </FormGroup>\n <FormHelperText>{addOnGroupHint(group)}</FormHelperText>\n </FormControl>\n )\n })}\n </Stack>\n )\n}\n\nProductAddOns.displayName = 'ProductAddOns'\n\nexport default ProductAddOns\n"],"names":["Checkbox","FormControl","FormControlLabel","FormGroup","FormHelperText","FormLabel","MenuItem","Stack","TextField","modifierGroupIsWriteIn","modifierGroupRequired","modifierOptionPriceCents","writeInMaxLength","writeInProblem","withGroupAnswer","groups","value","groupId","optionIds","others","filter","pick","answer","map","optionId","order","Map","group","index","id","sort","a","b","get","withWriteInAnswer","text","option","options","trim","entry","x","y","ProductWriteInField","props","variantId","onChange","formatCents","disabled","find","limit","problem","cents","hint","note","Array","from","length","Boolean","join","size","fullWidth","required","label","name","error","event","target","helperText","slotProps","htmlInput","maxLength","digitsOnly","inputMode","pattern","addOnGroupHint","max","min","ProductAddOns","priceLabel","spacing","sx","mb","chosen","select","String","em","full","component","variant","checked","includes","control","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,OAAOA,cAAc,yBAAwB;AAC7C,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,eAAe,0BAAyB;AAC/C,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,wBAAwB,EACxBC,gBAAgB,EAChBC,cAAc,QAIT,gCAA4B;AAcnC,0EAA0E,GAC1E,OAAO,SAASC,gBACdC,MAAuC,EACvCC,KAAmC,EACnCC,OAAe,EACfC,SAA4B;IAE5B,MAAMC,SAASH,MAAMI,MAAM,CAAC,CAACC,OAASA,KAAKJ,OAAO,KAAKA;IACvD,MAAMK,SAASJ,UAAUK,GAAG,CAAC,CAACC,WAAc,CAAA;YAAEP;YAASO;QAAS,CAAA;IAChE,MAAMC,QAAQ,IAAIC,IAAIX,OAAOQ,GAAG,CAAC,CAACI,OAAOC,QAAU;YAACD,MAAME,EAAE;YAAED;SAAM;IACpE,OAAO;WAAIT;WAAWG;KAAO,CAACQ,IAAI,CAChC,CAACC,GAAGC;YAAOP,YAA8BA;eAA/B,EAACA,aAAAA,MAAMQ,GAAG,CAACF,EAAEd,OAAO,aAAnBQ,aAAwB,OAAMA,cAAAA,MAAMQ,GAAG,CAACD,EAAEf,OAAO,aAAnBQ,cAAwB;;AAErE;AAEA;;;;CAIC,GACD,OAAO,SAASS,kBACdnB,MAAuC,EACvCC,KAAmC,EACnCW,KAA2B,EAC3BQ,IAAY;IAEZ,MAAMC,SAAST,MAAMU,OAAO,CAAC,EAAE;IAC/B,MAAMlB,SAASH,MAAMI,MAAM,CAAC,CAACC,OAASA,KAAKJ,OAAO,KAAKU,MAAME,EAA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WAAU;kCAAU5D,MAAMoC,IAAI;;kCACzC,KAAC5D;kCACEwB,MAAMU,OAAO,CAACd,GAAG,CAAC,CAACa;4BAClB,MAAMqD,UAAUP,OAAOQ,QAAQ,CAACtD,OAAOP,EAAE;4BACzC,qBACE,KAAC3B;gCAECyF,uBACE,KAAC3F;oCACC2D,MAAK;oCACL8B,SAASA;oCACT1C,UAAUA,YAAa,CAAC0C,WAAWH;oCACnCzC,UAAU,CAACoB,QACTpB,SACE/B,gBACEC,QACAC,OACAW,MAAME,EAAE,EACRoC,MAAMC,MAAM,CAACuB,OAAO,GAChB9D,MAAMU,OAAO,CACVd,GAAG,CAAC,CAACgB,QAAUA,MAAMV,EAAE,EACvBT,MAAM,CAAC,CAACS,KAAOA,OAAOO,OAAOP,EAAE,IAAIqD,OAAOQ,QAAQ,CAAC7D,OACtDqD,OAAO9D,MAAM,CAAC,CAACS,KAAOA,OAAOO,OAAOP,EAAE;;gCAMpDiC,OAAOgB,WAAW1C;+BAtBbA,OAAOP,EAAE;wBAyBpB;;kCAEF,KAACzB;kCAAgBsE,eAAe/C;;;eAvC3BA,MAAME,EAAE;QA0CnB;;AAGN;AAEAgD,cAAce,WAAW,GAAG;AAE5B,eAAef,cAAa"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-add-ons.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 Checkbox from '@mui/material/Checkbox'\nimport FormControl from '@mui/material/FormControl'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport FormGroup from '@mui/material/FormGroup'\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 {\n modifierGroupIsWriteIn,\n modifierGroupRequired,\n modifierOptionPriceCents,\n writeInMaxLength,\n writeInProblem,\n type ModifierSelection,\n type ProductModifierGroup,\n type ProductModifierOption,\n} from '../model/product-modifiers'\n\nexport interface ProductAddOnsProps {\n /** The groups the website shows, as the product's page received them. */\n groups: readonly ProductModifierGroup[]\n /** The variant picked: a choice priced by variant shows its price on it. */\n variantId?: string\n value: readonly ModifierSelection[]\n onChange: (next: ModifierSelection[]) => void\n /** The store's money, e.g. `$1,250.00`. */\n formatCents: (cents: number) => string\n /**\n * What a choice adds, in the shopper's currency (AGL-4248): its fixed\n * amount there when it has one. Absent: `formatCents` of its store price.\n */\n formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string\n disabled?: boolean\n}\n\n/** The picks with one group's answer replaced, in the groups' own order. */\nexport function withGroupAnswer(\n groups: readonly ProductModifierGroup[],\n value: readonly ModifierSelection[],\n groupId: string,\n optionIds: readonly string[],\n): ModifierSelection[] {\n const others = value.filter((pick) => pick.groupId !== groupId)\n const answer = optionIds.map((optionId) => ({ groupId, optionId }))\n const order = new Map(groups.map((group, index) => [group.id, index]))\n return [...others, ...answer].sort(\n (a, b) => (order.get(a.groupId) ?? 0) - (order.get(b.groupId) ?? 0),\n )\n}\n\n/**\n * The picks with a write-in's answer replaced (write-ins): the\n * text as typed so far, kept while it is being typed; an empty answer leaves\n * the group unanswered. The server cleans and checks it.\n */\nexport function withWriteInAnswer(\n groups: readonly ProductModifierGroup[],\n value: readonly ModifierSelection[],\n group: ProductModifierGroup,\n text: string,\n): ModifierSelection[] {\n const option = group.options[0]\n const others = value.filter((pick) => pick.groupId !== group.id)\n const answer = option && text.trim() ? [{ groupId: group.id, optionId: option.id, text }] : []\n const order = new Map(groups.map((entry, index) => [entry.id, index]))\n return [...others, ...answer].sort((x, y) => (order.get(x.groupId) ?? 0) - (order.get(y.groupId) ?? 0))\n}\n\nexport interface ProductWriteInFieldProps {\n group: ProductModifierGroup\n groups: readonly ProductModifierGroup[]\n variantId?: string\n value: readonly ModifierSelection[]\n onChange: (next: ModifierSelection[]) => void\n formatCents: (cents: number) => string\n formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string\n disabled?: boolean\n}\n\n/** What a choice adds, as money: the shopper's formatter when given, else the store's. */\nexport function addOnMoney(\n option: ProductModifierOption,\n variantId: string | null | undefined,\n formatCents: (cents: number) => string,\n formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string,\n): string {\n return formatAddOn ? formatAddOn(option, variantId) : formatCents(modifierOptionPriceCents(option, variantId))\n}\n\n/**\n * One write-in on a product's page: a text field named after the group, with\n * the merchant's note, what a filled answer adds and a count of characters\n * under it, or what is wrong with what was typed.\n */\nexport function ProductWriteInField(props: ProductWriteInFieldProps) {\n const { group, groups, variantId, value, onChange, formatCents, formatAddOn, disabled } = props\n const option = group.options[0]\n const text = value.find((pick) => pick.groupId === group.id)?.text ?? ''\n const limit = writeInMaxLength(group)\n const problem = writeInProblem(group, text)\n const cents = option ? modifierOptionPriceCents(option, variantId) : 0\n const hint = [option?.note, cents > 0 && option ? `Adds ${addOnMoney(option, variantId, formatCents, formatAddOn)}` : null, `${Array.from(text).length}/${limit}`]\n .filter(Boolean)\n .join(' · ')\n return (\n <TextField\n size=\"small\"\n fullWidth\n required={modifierGroupRequired(group)}\n disabled={disabled}\n label={group.name}\n value={text}\n error={Boolean(problem)}\n onChange={(event) => onChange(withWriteInAnswer(groups, value, group, event.target.value))}\n helperText={problem ?? hint}\n slotProps={{\n htmlInput: {\n maxLength: limit,\n ...(group.digitsOnly ? { inputMode: 'numeric', pattern: '[0-9]*' } : {}),\n },\n }}\n />\n )\n}\n\n/** What a group asks for, said under it. */\nexport function addOnGroupHint(group: Pick<ProductModifierGroup, 'min' | 'max'>): string {\n if (group.max === 1) return group.min > 0 ? 'Choose one' : 'Optional'\n if (group.min > 0 && group.min === group.max) return `Choose ${group.min}`\n if (group.min > 0) return `Choose ${group.min} to ${group.max}`\n return `Choose up to ${group.max}`\n}\n\n/**\n * The add-ons a product's page offers (AGL-4100): a group that takes one\n * choice is a select, one that takes several is a set of checkboxes, each\n * choice with what it adds on the picked variant. A required group is marked\n * as the form builder marks a required field. Its own chunk, loaded only by a\n * product that has add-ons on the website.\n */\nexport function ProductAddOns(props: ProductAddOnsProps) {\n const { groups, variantId, value, onChange, formatCents, formatAddOn, disabled } = props\n const priceLabel = (option: ProductModifierOption) => {\n const cents = modifierOptionPriceCents(option, variantId)\n return cents > 0\n ? `${option.name} (+${addOnMoney(option, variantId, formatCents, formatAddOn)})`\n : option.name\n }\n return (\n <Stack spacing={1.5} sx={{ mb: 1.5 }}>\n {groups.map((group) => {\n if (modifierGroupIsWriteIn(group)) {\n return (\n <ProductWriteInField\n key={group.id}\n group={group}\n groups={groups}\n variantId={variantId}\n value={value}\n onChange={onChange}\n formatCents={formatCents}\n formatAddOn={formatAddOn}\n disabled={disabled}\n />\n )\n }\n const chosen = value\n .filter((pick) => pick.groupId === group.id)\n .map((pick) => pick.optionId)\n const required = modifierGroupRequired(group)\n if (group.max === 1) {\n return (\n <TextField\n key={group.id}\n select\n size=\"small\"\n fullWidth\n required={required}\n disabled={disabled}\n label={group.name}\n value={chosen[0] ?? ''}\n onChange={(event) =>\n onChange(\n withGroupAnswer(\n groups,\n value,\n group.id,\n event.target.value ? [String(event.target.value)] : [],\n ),\n )\n }\n helperText={addOnGroupHint(group)}\n >\n {required ? null : (\n <MenuItem value=\"\">\n <em>{'None'}</em>\n </MenuItem>\n )}\n {group.options.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {priceLabel(option)}\n </MenuItem>\n ))}\n </TextField>\n )\n }\n const full = chosen.length >= group.max\n return (\n <FormControl\n key={group.id}\n component=\"fieldset\"\n required={required}\n disabled={disabled}\n variant=\"standard\"\n >\n <FormLabel component=\"legend\">{group.name}</FormLabel>\n <FormGroup>\n {group.options.map((option) => {\n const checked = chosen.includes(option.id)\n return (\n <FormControlLabel\n key={option.id}\n control={\n <Checkbox\n size=\"small\"\n checked={checked}\n disabled={disabled || (!checked && full)}\n onChange={(event) =>\n onChange(\n withGroupAnswer(\n groups,\n value,\n group.id,\n event.target.checked\n ? group.options\n .map((entry) => entry.id)\n .filter((id) => id === option.id || chosen.includes(id))\n : chosen.filter((id) => id !== option.id),\n ),\n )\n }\n />\n }\n label={priceLabel(option)}\n />\n )\n })}\n </FormGroup>\n <FormHelperText>{addOnGroupHint(group)}</FormHelperText>\n </FormControl>\n )\n })}\n </Stack>\n )\n}\n\nProductAddOns.displayName = 'ProductAddOns'\n\nexport default ProductAddOns\n"],"names":["Checkbox","FormControl","FormControlLabel","FormGroup","FormHelperText","FormLabel","MenuItem","Stack","TextField","modifierGroupIsWriteIn","modifierGroupRequired","modifierOptionPriceCents","writeInMaxLength","writeInProblem","withGroupAnswer","groups","value","groupId","optionIds","others","filter","pick","answer","map","optionId","order","Map","group","index","id","sort","a","b","get","withWriteInAnswer","text","option","options","trim","entry","x","y","addOnMoney","variantId","formatCents","formatAddOn","ProductWriteInField","props","onChange","disabled","find","limit","problem","cents","hint","note","Array","from","length","Boolean","join","size","fullWidth","required","label","name","error","event","target","helperText","slotProps","htmlInput","maxLength","digitsOnly","inputMode","pattern","addOnGroupHint","max","min","ProductAddOns","priceLabel","spacing","sx","mb","chosen","select","String","em","full","component","variant","checked","includes","control","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,OAAOA,cAAc,yBAAwB;AAC7C,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,cAAc,yBAAwB;AAC7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;kCACzC,KAAC9D;kCACEwB,MAAMU,OAAO,CAACd,GAAG,CAAC,CAACa;4BAClB,MAAMuD,UAAUP,OAAOQ,QAAQ,CAACxD,OAAOP,EAAE;4BACzC,qBACE,KAAC3B;gCAEC2F,uBACE,KAAC7F;oCACC6D,MAAK;oCACL8B,SAASA;oCACT1C,UAAUA,YAAa,CAAC0C,WAAWH;oCACnCxC,UAAU,CAACmB,QACTnB,SACElC,gBACEC,QACAC,OACAW,MAAME,EAAE,EACRsC,MAAMC,MAAM,CAACuB,OAAO,GAChBhE,MAAMU,OAAO,CACVd,GAAG,CAAC,CAACgB,QAAUA,MAAMV,EAAE,EACvBT,MAAM,CAAC,CAACS,KAAOA,OAAOO,OAAOP,EAAE,IAAIuD,OAAOQ,QAAQ,CAAC/D,OACtDuD,OAAOhE,MAAM,CAAC,CAACS,KAAOA,OAAOO,OAAOP,EAAE;;gCAMpDmC,OAAOgB,WAAW5C;+BAtBbA,OAAOP,EAAE;wBAyBpB;;kCAEF,KAACzB;kCAAgBwE,eAAejD;;;eAvC3BA,MAAME,EAAE;QA0CnB;;AAGN;AAEAkD,cAAce,WAAW,GAAG;AAE5B,eAAef,cAAa"}
@@ -1,9 +1,11 @@
1
- import { type ModifierSelection, type ProductModifierGroup } from '../model/product-modifiers';
1
+ import { type ModifierSelection, type ProductModifierGroup, type ProductModifierOption } from '../model/product-modifiers';
2
2
  /** A variant as the cards read it. */
3
3
  export interface CardVariant {
4
4
  id: string;
5
5
  options?: Record<string, string>;
6
6
  priceUsd: number | null;
7
+ /** The merchant's own price per currency (AGL-4248). */
8
+ fixedPrices?: Record<string, number>;
7
9
  soldOut?: boolean;
8
10
  imageUrl?: string;
9
11
  note?: string;
@@ -39,6 +41,16 @@ export interface ProductChoiceCardsProps {
39
41
  onChange: (next: ModifierSelection[]) => void;
40
42
  /** The store's money, e.g. `$1,250.00`. */
41
43
  formatCents: (cents: number) => string;
44
+ /**
45
+ * What a choice adds, in the shopper's currency (AGL-4248): its fixed
46
+ * amount there when it has one. Absent: `formatCents` of its store price.
47
+ */
48
+ formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string;
49
+ /** A variant's price in the shopper's currency (AGL-4248); absent: `formatCents`. */
50
+ formatVariant?: (variant: {
51
+ priceUsd?: number | null;
52
+ fixedPrices?: Record<string, number>;
53
+ }) => string;
42
54
  /** What a card says where a variant has no price yet. */
43
55
  unpricedLabel: string;
44
56
  disabled?: boolean;
@@ -32,7 +32,7 @@ import Stack from "@mui/material/Stack";
32
32
  import Typography from "@mui/material/Typography";
33
33
  import { useId, useState } from "react";
34
34
  import { modifierGroupIsWriteIn, modifierGroupRequired, modifierOptionIsCombo, modifierOptionPriceCents } from "../model/product-modifiers.js";
35
- import { addOnGroupHint, ProductWriteInField, withGroupAnswer } from "./product-add-ons.js";
35
+ import { addOnGroupHint, addOnMoney, ProductWriteInField, withGroupAnswer } from "./product-add-ons.js";
36
36
  /**
37
37
  * The variant a card for one option value stands for: the one the shopper's
38
38
  * other picks make with this value, else the first that carries the value.
@@ -242,13 +242,13 @@ import { addOnGroupHint, ProductWriteInField, withGroupAnswer } from "./product-
242
242
  });
243
243
  }
244
244
  /** The product's options and add-ons as picture cards (AGL-4205). */ export function ProductChoiceCards(props) {
245
- const { options, variants, selections, onSelect, groups, variantId, value, onChange, formatCents, unpricedLabel, disabled } = props;
245
+ const { options, variants, selections, onSelect, groups, variantId, value, onChange, formatCents, formatAddOn, formatVariant, unpricedLabel, disabled } = props;
246
246
  const addOnCard = (group, option, chosen)=>{
247
247
  const selected = chosen.includes(option.id);
248
248
  const full = group.max > 1 && chosen.length >= group.max;
249
249
  return /*#__PURE__*/ _jsx(ChoiceCard, {
250
250
  name: option.name,
251
- price: addOnPriceLabel(modifierOptionPriceCents(option, variantId), formatCents),
251
+ price: addOnPriceLabel(modifierOptionPriceCents(option, variantId), ()=>addOnMoney(option, variantId, formatCents, formatAddOn)),
252
252
  note: option.note,
253
253
  imageUrl: option.imageUrl,
254
254
  selected: selected,
@@ -278,7 +278,7 @@ import { addOnGroupHint, ProductWriteInField, withGroupAnswer } from "./product-
278
278
  const variant = variantForOptionValue(variants, selections, option.name, choice);
279
279
  return /*#__PURE__*/ _jsx(ChoiceCard, {
280
280
  name: choice,
281
- price: typeof (variant == null ? void 0 : variant.priceUsd) === 'number' ? formatCents(Math.round(variant.priceUsd * 100)) : unpricedLabel,
281
+ price: typeof (variant == null ? void 0 : variant.priceUsd) === 'number' ? formatVariant ? formatVariant(variant) : formatCents(Math.round(variant.priceUsd * 100)) : unpricedLabel,
282
282
  note: variant == null ? void 0 : variant.note,
283
283
  imageUrl: variant == null ? void 0 : variant.imageUrl,
284
284
  selected: selections[option.name] === choice,
@@ -302,6 +302,7 @@ import { addOnGroupHint, ProductWriteInField, withGroupAnswer } from "./product-
302
302
  value: value,
303
303
  onChange: onChange,
304
304
  formatCents: formatCents,
305
+ formatAddOn: formatAddOn,
305
306
  disabled: disabled
306
307
  }, group.id);
307
308
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-choice-cards.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 * as Aglyn from '@aglyn/aglyn'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport CardActionArea from '@mui/material/CardActionArea'\nimport CardContent from '@mui/material/CardContent'\nimport CardMedia from '@mui/material/CardMedia'\nimport Chip from '@mui/material/Chip'\nimport Collapse from '@mui/material/Collapse'\nimport List from '@mui/material/List'\nimport ListItem from '@mui/material/ListItem'\nimport ListItemText from '@mui/material/ListItemText'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport { useId, useState, type ReactNode } from 'react'\nimport {\n modifierGroupIsWriteIn,\n modifierGroupRequired,\n modifierOptionIsCombo,\n modifierOptionPriceCents,\n type ModifierSelection,\n type ProductModifierGroup,\n type ProductModifierOption,\n} from '../model/product-modifiers'\nimport { addOnGroupHint, ProductWriteInField, withGroupAnswer } from './product-add-ons'\n\n/*\n * THE PRODUCT BUILDER'S PICTURE CARDS (AGL-4205).\n *\n * A Product detail block set to show its choices as picture cards draws each\n * of the product's options (size, style) and each of its add-on groups as a\n * row of cards: the choice's picture, its name, what it costs, and the\n * owner's short note. A combo's card folds out what it includes. A group\n * that takes one choice behaves as radio buttons, one that takes several as\n * check boxes up to its maximum, and a required group is marked and cannot\n * be emptied. Its own chunk: only a page that shows cards downloads it.\n */\n\n/** A variant as the cards read it. */\nexport interface CardVariant {\n id: string\n options?: Record<string, string>\n priceUsd: number | null\n soldOut?: boolean\n imageUrl?: string\n note?: string\n}\n\n/**\n * The variant a card for one option value stands for: the one the shopper's\n * other picks make with this value, else the first that carries the value.\n */\nexport function variantForOptionValue<V extends CardVariant>(\n variants: readonly V[],\n selections: Readonly<Record<string, string>>,\n optionName: string,\n value: string,\n): V | undefined {\n const wanted = { ...selections, [optionName]: value }\n return (\n variants.find((variant) =>\n Object.entries(wanted).every(([name, picked]) => (variant.options?.[name] ?? picked) === picked),\n ) ?? variants.find((variant) => variant.options?.[optionName] === value)\n )\n}\n\n/**\n * A group's answer after a card is pressed. One-choice groups act as radio\n * buttons (an optional one can be cleared by pressing its pick again); a\n * several-choice group adds or removes the choice, never past its maximum.\n * The answer keeps the group's own order.\n */\nexport function pressChoice(\n group: Pick<ProductModifierGroup, 'min' | 'max' | 'options'>,\n chosen: readonly string[],\n optionId: string,\n): string[] {\n const picked = chosen.includes(optionId)\n if (group.max === 1) {\n if (picked) return group.min > 0 ? [...chosen] : []\n return [optionId]\n }\n if (picked) return chosen.filter((id) => id !== optionId)\n if (chosen.length >= group.max) return [...chosen]\n return group.options.map((option) => option.id).filter((id) => id === optionId || chosen.includes(id))\n}\n\n/** What a card says a choice adds: its price, or that it adds nothing. */\nexport function addOnPriceLabel(cents: number, formatCents: (cents: number) => string): string {\n return cents > 0 ? `+${formatCents(cents)}` : 'No extra charge'\n}\n\ninterface ChoiceCardProps {\n name: string\n price: string\n note?: string\n imageUrl?: string\n selected: boolean\n disabled?: boolean\n role: 'radio' | 'checkbox'\n onPress: () => void\n badge?: ReactNode\n includes?: readonly string[]\n}\n\n/** One card: picture, name, price and note, pressed to pick; a combo's contents fold out below. */\nfunction ChoiceCard(props: ChoiceCardProps) {\n const { name, price, note, imageUrl, selected, disabled, role, onPress, badge, includes } = props\n const { hostId } = Aglyn.useSite()\n const [open, setOpen] = useState(false)\n const contentsId = useId()\n const src = imageUrl ? Aglyn.siteRelativeMediaSrc(imageUrl, { hostId }) : undefined\n return (\n <Card\n variant=\"outlined\"\n sx={{\n display: 'flex',\n flexDirection: 'column',\n borderWidth: 2,\n borderColor: selected ? 'primary.main' : 'divider',\n bgcolor: selected ? 'action.selected' : 'background.paper',\n opacity: disabled && !selected ? 0.6 : 1,\n }}\n >\n <CardActionArea\n role={role}\n aria-checked={selected}\n disabled={disabled}\n onClick={onPress}\n sx={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'stretch' }}\n >\n {src ? (\n <CardMedia\n component=\"img\"\n image={src}\n alt=\"\"\n sx={{ aspectRatio: '4 / 3', objectFit: 'cover' }}\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ) : null}\n <CardContent sx={{ flex: 1, p: 1.5, '&:last-child': { pb: 1.5 } }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', justifyContent: 'space-between' }}>\n <Typography variant=\"subtitle2\" component=\"span\">\n {name}\n </Typography>\n {badge}\n </Stack>\n <Typography variant=\"body2\" color={selected ? 'primary' : 'text.primary'} sx={{ fontWeight: 600 }}>\n {price}\n </Typography>\n {note ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {note}\n </Typography>\n ) : null}\n </CardContent>\n </CardActionArea>\n {includes?.length ? (\n <Box sx={{ px: 1, pb: 1 }}>\n <Button\n size=\"small\"\n aria-expanded={open}\n aria-controls={contentsId}\n onClick={() => setOpen((was) => !was)}\n >\n {open ? 'Hide what’s included' : 'What’s included'}\n </Button>\n <Collapse in={open} id={contentsId}>\n <List dense disablePadding aria-label={`${name} includes`}>\n {includes.map((item) => (\n <ListItem key={item} disableGutters sx={{ py: 0 }}>\n <ListItemText primary={item} slotProps={{ primary: { variant: 'body2' } }} />\n </ListItem>\n ))}\n </List>\n </Collapse>\n </Box>\n ) : null}\n </Card>\n )\n}\n\n/** A heading, its hint, and the grid of cards under it. */\nfunction CardGroup(props: {\n label: string\n hint: string\n required: boolean\n role: 'radiogroup' | 'group'\n children: ReactNode\n}) {\n const { label, hint, required, role, children } = props\n const labelId = useId()\n return (\n <Box component=\"section\" aria-labelledby={labelId}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', mb: 1 }}>\n <Typography id={labelId} variant=\"subtitle1\" component=\"h2\">\n {label}\n </Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color={required ? 'primary' : 'default'}\n label={hint}\n />\n </Stack>\n <Box\n role={role}\n aria-labelledby={labelId}\n aria-required={required || undefined}\n sx={{\n display: 'grid',\n gridTemplateColumns: (theme) => `repeat(auto-fill, minmax(${theme.spacing(19)}, 1fr))`,\n gap: 1.5,\n }}\n >\n {children}\n </Box>\n </Box>\n )\n}\n\nexport interface ProductChoiceCardsProps {\n /** The options the shopper chooses among (size, style), with their values. */\n options: ReadonlyArray<{ name: string; values: readonly string[] }>\n variants: readonly CardVariant[]\n selections: Readonly<Record<string, string>>\n onSelect: (optionName: string, value: string) => void\n /** The add-on groups the website offers; empty draws none. */\n groups: readonly ProductModifierGroup[]\n /** The variant picked: a choice priced by variant shows its price on it. */\n variantId?: string\n value: readonly ModifierSelection[]\n onChange: (next: ModifierSelection[]) => void\n /** The store's money, e.g. `$1,250.00`. */\n formatCents: (cents: number) => string\n /** What a card says where a variant has no price yet. */\n unpricedLabel: string\n disabled?: boolean\n}\n\n/** The product's options and add-ons as picture cards (AGL-4205). */\nexport function ProductChoiceCards(props: ProductChoiceCardsProps) {\n const {\n options,\n variants,\n selections,\n onSelect,\n groups,\n variantId,\n value,\n onChange,\n formatCents,\n unpricedLabel,\n disabled,\n } = props\n const addOnCard = (group: ProductModifierGroup, option: ProductModifierOption, chosen: string[]) => {\n const selected = chosen.includes(option.id)\n const full = group.max > 1 && chosen.length >= group.max\n return (\n <ChoiceCard\n key={option.id}\n name={option.name}\n price={addOnPriceLabel(modifierOptionPriceCents(option, variantId), formatCents)}\n note={option.note}\n imageUrl={option.imageUrl}\n selected={selected}\n disabled={disabled || (!selected && full)}\n role={group.max === 1 ? 'radio' : 'checkbox'}\n badge={modifierOptionIsCombo(option) ? <Chip size=\"small\" color=\"secondary\" label=\"Combo\" /> : null}\n includes={modifierOptionIsCombo(option) ? option.includes : undefined}\n onPress={() => onChange(withGroupAnswer(groups, value, group.id, pressChoice(group, chosen, option.id)))}\n />\n )\n }\n return (\n <Stack spacing={3} sx={{ mb: 2 }}>\n {options.map((option) => (\n <CardGroup key={option.name} label={option.name} hint=\"Choose one\" required role=\"radiogroup\">\n {option.values.map((choice) => {\n const variant = variantForOptionValue(variants, selections, option.name, choice)\n return (\n <ChoiceCard\n key={choice}\n name={choice}\n price={\n typeof variant?.priceUsd === 'number'\n ? formatCents(Math.round(variant.priceUsd * 100))\n : unpricedLabel\n }\n note={variant?.note}\n imageUrl={variant?.imageUrl}\n selected={selections[option.name] === choice}\n role=\"radio\"\n badge={variant?.soldOut ? <Chip size=\"small\" variant=\"outlined\" label=\"Sold out\" /> : null}\n onPress={() => onSelect(option.name, choice)}\n />\n )\n })}\n </CardGroup>\n ))}\n {groups.map((group) => {\n // A write-in (write-ins) is a text field among the cards: there is nothing to picture.\n if (modifierGroupIsWriteIn(group)) {\n return (\n <ProductWriteInField\n key={group.id}\n group={group}\n groups={groups}\n variantId={variantId}\n value={value}\n onChange={onChange}\n formatCents={formatCents}\n disabled={disabled}\n />\n )\n }\n const chosen = value.filter((pick) => pick.groupId === group.id).map((pick) => pick.optionId)\n return (\n <CardGroup\n key={group.id}\n label={group.name}\n hint={addOnGroupHint(group)}\n required={modifierGroupRequired(group)}\n role={group.max === 1 ? 'radiogroup' : 'group'}\n >\n {group.options.map((option) => addOnCard(group, option, chosen))}\n </CardGroup>\n )\n })}\n </Stack>\n )\n}\n\nProductChoiceCards.displayName = 'ProductChoiceCards'\n\nexport default ProductChoiceCards\n"],"names":["Aglyn","Box","Button","Card","CardActionArea","CardContent","CardMedia","Chip","Collapse","List","ListItem","ListItemText","Stack","Typography","useId","useState","modifierGroupIsWriteIn","modifierGroupRequired","modifierOptionIsCombo","modifierOptionPriceCents","addOnGroupHint","ProductWriteInField","withGroupAnswer","variantForOptionValue","variants","selections","optionName","value","wanted","find","variant","Object","entries","every","name","picked","options","pressChoice","group","chosen","optionId","includes","max","min","filter","id","length","map","option","addOnPriceLabel","cents","formatCents","ChoiceCard","props","price","note","imageUrl","selected","disabled","role","onPress","badge","hostId","useSite","open","setOpen","contentsId","src","siteRelativeMediaSrc","undefined","sx","display","flexDirection","borderWidth","borderColor","bgcolor","opacity","aria-checked","onClick","flex","alignItems","component","image","alt","aspectRatio","objectFit","DEFERRED_IMAGE_ATTRIBUTES","p","pb","direction","spacing","justifyContent","color","fontWeight","px","size","aria-expanded","aria-controls","was","in","dense","disablePadding","aria-label","item","disableGutters","py","primary","slotProps","CardGroup","label","hint","required","children","labelId","aria-labelledby","mb","aria-required","gridTemplateColumns","theme","gap","ProductChoiceCards","onSelect","groups","variantId","onChange","unpricedLabel","addOnCard","full","values","choice","priceUsd","Math","round","soldOut","pick","groupId","displayName"],"mappings":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AG,KAAC9H;gCAAKwF,MAAK;gCAAQjE,SAAQ;gCAAW+E,OAAM;iCAAgB;4BACtFjD,SAAS,IAAM6D,SAASzE,OAAOd,IAAI,EAAE+F;2BAZhCA;oBAeX;mBApBcjF,OAAOd,IAAI;YAuB5BwF,OAAO3E,GAAG,CAAC,CAACT;gBACX,uFAAuF;gBACvF,IAAItB,uBAAuBsB,QAAQ;oBACjC,qBACE,KAACjB;wBAECiB,OAAOA;wBACPoF,QAAQA;wBACRC,WAAWA;wBACXhG,OAAOA;wBACPiG,UAAUA;wBACVzE,aAAaA;wBACbO,UAAUA;uBAPLpB,MAAMO,EAAE;gBAUnB;gBACA,MAAMN,SAASZ,MAAMiB,MAAM,CAAC,CAAC0F,OAASA,KAAKC,OAAO,KAAKjG,MAAMO,EAAE,EAAEE,GAAG,CAAC,CAACuF,OAASA,KAAK9F,QAAQ;gBAC5F,qBACE,KAACoE;oBAECC,OAAOvE,MAAMJ,IAAI;oBACjB4E,MAAM1F,eAAekB;oBACrByE,UAAU9F,sBAAsBqB;oBAChCqB,MAAMrB,MAAMI,GAAG,KAAK,IAAI,eAAe;8BAEtCJ,MAAMF,OAAO,CAACW,GAAG,CAAC,CAACC,SAAW8E,UAAUxF,OAAOU,QAAQT;mBANnDD,MAAMO,EAAE;YASnB;;;AAGN;AAEA2E,mBAAmBgB,WAAW,GAAG;AAEjC,eAAehB,mBAAkB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-choice-cards.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 * as Aglyn from '@aglyn/aglyn'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport CardActionArea from '@mui/material/CardActionArea'\nimport CardContent from '@mui/material/CardContent'\nimport CardMedia from '@mui/material/CardMedia'\nimport Chip from '@mui/material/Chip'\nimport Collapse from '@mui/material/Collapse'\nimport List from '@mui/material/List'\nimport ListItem from '@mui/material/ListItem'\nimport ListItemText from '@mui/material/ListItemText'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport { useId, useState, type ReactNode } from 'react'\nimport {\n modifierGroupIsWriteIn,\n modifierGroupRequired,\n modifierOptionIsCombo,\n modifierOptionPriceCents,\n type ModifierSelection,\n type ProductModifierGroup,\n type ProductModifierOption,\n} from '../model/product-modifiers'\nimport { addOnGroupHint, addOnMoney, ProductWriteInField, withGroupAnswer } from './product-add-ons'\n\n/*\n * THE PRODUCT BUILDER'S PICTURE CARDS (AGL-4205).\n *\n * A Product detail block set to show its choices as picture cards draws each\n * of the product's options (size, style) and each of its add-on groups as a\n * row of cards: the choice's picture, its name, what it costs, and the\n * owner's short note. A combo's card folds out what it includes. A group\n * that takes one choice behaves as radio buttons, one that takes several as\n * check boxes up to its maximum, and a required group is marked and cannot\n * be emptied. Its own chunk: only a page that shows cards downloads it.\n */\n\n/** A variant as the cards read it. */\nexport interface CardVariant {\n id: string\n options?: Record<string, string>\n priceUsd: number | null\n /** The merchant's own price per currency (AGL-4248). */\n fixedPrices?: Record<string, number>\n soldOut?: boolean\n imageUrl?: string\n note?: string\n}\n\n/**\n * The variant a card for one option value stands for: the one the shopper's\n * other picks make with this value, else the first that carries the value.\n */\nexport function variantForOptionValue<V extends CardVariant>(\n variants: readonly V[],\n selections: Readonly<Record<string, string>>,\n optionName: string,\n value: string,\n): V | undefined {\n const wanted = { ...selections, [optionName]: value }\n return (\n variants.find((variant) =>\n Object.entries(wanted).every(([name, picked]) => (variant.options?.[name] ?? picked) === picked),\n ) ?? variants.find((variant) => variant.options?.[optionName] === value)\n )\n}\n\n/**\n * A group's answer after a card is pressed. One-choice groups act as radio\n * buttons (an optional one can be cleared by pressing its pick again); a\n * several-choice group adds or removes the choice, never past its maximum.\n * The answer keeps the group's own order.\n */\nexport function pressChoice(\n group: Pick<ProductModifierGroup, 'min' | 'max' | 'options'>,\n chosen: readonly string[],\n optionId: string,\n): string[] {\n const picked = chosen.includes(optionId)\n if (group.max === 1) {\n if (picked) return group.min > 0 ? [...chosen] : []\n return [optionId]\n }\n if (picked) return chosen.filter((id) => id !== optionId)\n if (chosen.length >= group.max) return [...chosen]\n return group.options.map((option) => option.id).filter((id) => id === optionId || chosen.includes(id))\n}\n\n/** What a card says a choice adds: its price, or that it adds nothing. */\nexport function addOnPriceLabel(cents: number, formatCents: (cents: number) => string): string {\n return cents > 0 ? `+${formatCents(cents)}` : 'No extra charge'\n}\n\ninterface ChoiceCardProps {\n name: string\n price: string\n note?: string\n imageUrl?: string\n selected: boolean\n disabled?: boolean\n role: 'radio' | 'checkbox'\n onPress: () => void\n badge?: ReactNode\n includes?: readonly string[]\n}\n\n/** One card: picture, name, price and note, pressed to pick; a combo's contents fold out below. */\nfunction ChoiceCard(props: ChoiceCardProps) {\n const { name, price, note, imageUrl, selected, disabled, role, onPress, badge, includes } = props\n const { hostId } = Aglyn.useSite()\n const [open, setOpen] = useState(false)\n const contentsId = useId()\n const src = imageUrl ? Aglyn.siteRelativeMediaSrc(imageUrl, { hostId }) : undefined\n return (\n <Card\n variant=\"outlined\"\n sx={{\n display: 'flex',\n flexDirection: 'column',\n borderWidth: 2,\n borderColor: selected ? 'primary.main' : 'divider',\n bgcolor: selected ? 'action.selected' : 'background.paper',\n opacity: disabled && !selected ? 0.6 : 1,\n }}\n >\n <CardActionArea\n role={role}\n aria-checked={selected}\n disabled={disabled}\n onClick={onPress}\n sx={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'stretch' }}\n >\n {src ? (\n <CardMedia\n component=\"img\"\n image={src}\n alt=\"\"\n sx={{ aspectRatio: '4 / 3', objectFit: 'cover' }}\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ) : null}\n <CardContent sx={{ flex: 1, p: 1.5, '&:last-child': { pb: 1.5 } }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', justifyContent: 'space-between' }}>\n <Typography variant=\"subtitle2\" component=\"span\">\n {name}\n </Typography>\n {badge}\n </Stack>\n <Typography variant=\"body2\" color={selected ? 'primary' : 'text.primary'} sx={{ fontWeight: 600 }}>\n {price}\n </Typography>\n {note ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {note}\n </Typography>\n ) : null}\n </CardContent>\n </CardActionArea>\n {includes?.length ? (\n <Box sx={{ px: 1, pb: 1 }}>\n <Button\n size=\"small\"\n aria-expanded={open}\n aria-controls={contentsId}\n onClick={() => setOpen((was) => !was)}\n >\n {open ? 'Hide what’s included' : 'What’s included'}\n </Button>\n <Collapse in={open} id={contentsId}>\n <List dense disablePadding aria-label={`${name} includes`}>\n {includes.map((item) => (\n <ListItem key={item} disableGutters sx={{ py: 0 }}>\n <ListItemText primary={item} slotProps={{ primary: { variant: 'body2' } }} />\n </ListItem>\n ))}\n </List>\n </Collapse>\n </Box>\n ) : null}\n </Card>\n )\n}\n\n/** A heading, its hint, and the grid of cards under it. */\nfunction CardGroup(props: {\n label: string\n hint: string\n required: boolean\n role: 'radiogroup' | 'group'\n children: ReactNode\n}) {\n const { label, hint, required, role, children } = props\n const labelId = useId()\n return (\n <Box component=\"section\" aria-labelledby={labelId}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', mb: 1 }}>\n <Typography id={labelId} variant=\"subtitle1\" component=\"h2\">\n {label}\n </Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color={required ? 'primary' : 'default'}\n label={hint}\n />\n </Stack>\n <Box\n role={role}\n aria-labelledby={labelId}\n aria-required={required || undefined}\n sx={{\n display: 'grid',\n gridTemplateColumns: (theme) => `repeat(auto-fill, minmax(${theme.spacing(19)}, 1fr))`,\n gap: 1.5,\n }}\n >\n {children}\n </Box>\n </Box>\n )\n}\n\nexport interface ProductChoiceCardsProps {\n /** The options the shopper chooses among (size, style), with their values. */\n options: ReadonlyArray<{ name: string; values: readonly string[] }>\n variants: readonly CardVariant[]\n selections: Readonly<Record<string, string>>\n onSelect: (optionName: string, value: string) => void\n /** The add-on groups the website offers; empty draws none. */\n groups: readonly ProductModifierGroup[]\n /** The variant picked: a choice priced by variant shows its price on it. */\n variantId?: string\n value: readonly ModifierSelection[]\n onChange: (next: ModifierSelection[]) => void\n /** The store's money, e.g. `$1,250.00`. */\n formatCents: (cents: number) => string\n /**\n * What a choice adds, in the shopper's currency (AGL-4248): its fixed\n * amount there when it has one. Absent: `formatCents` of its store price.\n */\n formatAddOn?: (option: ProductModifierOption, variantId?: string | null) => string\n /** A variant's price in the shopper's currency (AGL-4248); absent: `formatCents`. */\n formatVariant?: (variant: { priceUsd?: number | null; fixedPrices?: Record<string, number> }) => string\n /** What a card says where a variant has no price yet. */\n unpricedLabel: string\n disabled?: boolean\n}\n\n/** The product's options and add-ons as picture cards (AGL-4205). */\nexport function ProductChoiceCards(props: ProductChoiceCardsProps) {\n const {\n options,\n variants,\n selections,\n onSelect,\n groups,\n variantId,\n value,\n onChange,\n formatCents,\n formatAddOn,\n formatVariant,\n unpricedLabel,\n disabled,\n } = props\n const addOnCard = (group: ProductModifierGroup, option: ProductModifierOption, chosen: string[]) => {\n const selected = chosen.includes(option.id)\n const full = group.max > 1 && chosen.length >= group.max\n return (\n <ChoiceCard\n key={option.id}\n name={option.name}\n price={addOnPriceLabel(modifierOptionPriceCents(option, variantId), () =>\n addOnMoney(option, variantId, formatCents, formatAddOn),\n )}\n note={option.note}\n imageUrl={option.imageUrl}\n selected={selected}\n disabled={disabled || (!selected && full)}\n role={group.max === 1 ? 'radio' : 'checkbox'}\n badge={modifierOptionIsCombo(option) ? <Chip size=\"small\" color=\"secondary\" label=\"Combo\" /> : null}\n includes={modifierOptionIsCombo(option) ? option.includes : undefined}\n onPress={() => onChange(withGroupAnswer(groups, value, group.id, pressChoice(group, chosen, option.id)))}\n />\n )\n }\n return (\n <Stack spacing={3} sx={{ mb: 2 }}>\n {options.map((option) => (\n <CardGroup key={option.name} label={option.name} hint=\"Choose one\" required role=\"radiogroup\">\n {option.values.map((choice) => {\n const variant = variantForOptionValue(variants, selections, option.name, choice)\n return (\n <ChoiceCard\n key={choice}\n name={choice}\n price={\n typeof variant?.priceUsd === 'number'\n ? formatVariant\n ? formatVariant(variant)\n : formatCents(Math.round(variant.priceUsd * 100))\n : unpricedLabel\n }\n note={variant?.note}\n imageUrl={variant?.imageUrl}\n selected={selections[option.name] === choice}\n role=\"radio\"\n badge={variant?.soldOut ? <Chip size=\"small\" variant=\"outlined\" label=\"Sold out\" /> : null}\n onPress={() => onSelect(option.name, choice)}\n />\n )\n })}\n </CardGroup>\n ))}\n {groups.map((group) => {\n // A write-in (write-ins) is a text field among the cards: there is nothing to picture.\n if (modifierGroupIsWriteIn(group)) {\n return (\n <ProductWriteInField\n key={group.id}\n group={group}\n groups={groups}\n variantId={variantId}\n value={value}\n onChange={onChange}\n formatCents={formatCents}\n formatAddOn={formatAddOn}\n disabled={disabled}\n />\n )\n }\n const chosen = value.filter((pick) => pick.groupId === group.id).map((pick) => pick.optionId)\n return (\n <CardGroup\n key={group.id}\n label={group.name}\n hint={addOnGroupHint(group)}\n required={modifierGroupRequired(group)}\n role={group.max === 1 ? 'radiogroup' : 'group'}\n >\n {group.options.map((option) => addOnCard(group, option, chosen))}\n </CardGroup>\n )\n })}\n </Stack>\n )\n}\n\nProductChoiceCards.displayName = 'ProductChoiceCards'\n\nexport default ProductChoiceCards\n"],"names":["Aglyn","Box","Button","Card","CardActionArea","CardContent","CardMedia","Chip","Collapse","List","ListItem","ListItemText","Stack","Typography","useId","useState","modifierGroupIsWriteIn","modifierGroupRequired","modifierOptionIsCombo","modifierOptionPriceCents","addOnGroupHint","addOnMoney","ProductWriteInField","withGroupAnswer","variantForOptionValue","variants","selections","optionName","value","wanted","find","variant","Object","entries","every","name","picked","options","pressChoice","group","chosen","optionId","includes","max","min","filter","id","length","map","option","addOnPriceLabel","cents","formatCents","ChoiceCard","props","price","note","imageUrl","selected","disabled","role","onPress","badge","hostId","useSite","open","setOpen","contentsId","src","siteRelativeMediaSrc","undefined","sx","display","flexDirection","borderWidth","borderColor","bgcolor","opacity","aria-checked","onClick","flex","alignItems","component","image","alt","aspectRatio","objectFit","DEFERRED_IMAGE_ATTRIBUTES","p","pb","direction","spacing","justifyContent","color","fontWeight","px","size","aria-expanded","aria-controls","was","in","dense","disablePadding","aria-label","item","disableGutters","py","primary","slotProps","CardGroup","label","hint","required","children","labelId","aria-labelledby","mb","aria-required","gridTemplateColumns","theme","gap","ProductChoiceCards","onSelect","groups","variantId","onChange","formatAddOn","formatVariant","unpricedLabel","addOnCard","full","values","choice","priceUsd","Math","round","soldOut","pick","groupId","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,kBAAkB,6BAA4B;AACrD,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,KAAK,EAAEC,QAAQ,QAAwB,QAAO;AACvD,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,qBAAqB,EACrBC,wBAAwB,QAInB,gCAA4B;AACnC,SAASC,cAAc,EAAEC,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OAAO,KAAKnG,MAAMO,EAAE,EAAEE,GAAG,CAAC,CAACyF,OAASA,KAAKhG,QAAQ;gBAC5F,qBACE,KAACoE;oBAECC,OAAOvE,MAAMJ,IAAI;oBACjB4E,MAAM3F,eAAemB;oBACrByE,UAAU/F,sBAAsBsB;oBAChCqB,MAAMrB,MAAMI,GAAG,KAAK,IAAI,eAAe;8BAEtCJ,MAAMF,OAAO,CAACW,GAAG,CAAC,CAACC,SAAWgF,UAAU1F,OAAOU,QAAQT;mBANnDD,MAAMO,EAAE;YASnB;;;AAGN;AAEA2E,mBAAmBkB,WAAW,GAAG;AAEjC,eAAelB,mBAAkB"}
@@ -61,6 +61,8 @@ interface DetailVariant {
61
61
  /** `null` while the product is listed before it has a price (AGL-3676). */
62
62
  priceUsd: number | null;
63
63
  compareAtPriceUsd?: number;
64
+ /** The merchant's own price per currency (AGL-4248), major units. */
65
+ fixedPrices?: Record<string, number>;
64
66
  soldOut: boolean;
65
67
  imageUrl?: string;
66
68
  sku?: string;
@@ -107,6 +109,12 @@ export declare function productPageAddOns(product: Pick<Detail, 'name' | 'modifi
107
109
  extraCents: number;
108
110
  error?: string;
109
111
  };
112
+ /**
113
+ * What the picks add to one unit in the shopper's currency (AGL-4248): each
114
+ * add-on converted on its own, its fixed amount winning, as the cart and
115
+ * checkout price it.
116
+ */
117
+ export declare function productPageAddOnsMinor(product: Pick<Detail, 'name' | 'modifierGroups'>, picks: readonly CommerceModel.ModifierSelection[], variantId: string | undefined, amountMinor: (baseCents: number, fixedMinor?: Record<string, number>) => number): number;
110
118
  /** How one option is offered on the page. */
111
119
  export interface OptionPresentation {
112
120
  name: string;