@drawbridge/components 0.1.48 → 0.1.49

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 (125) hide show
  1. package/dist/bridge/fields.js +0 -278
  2. package/dist/bridge/fields.mjs +1 -276
  3. package/dist/bridge/form-subdomain-shop-modal.js +274 -234
  4. package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
  5. package/dist/bridge/form-subdomain.js +0 -7
  6. package/dist/bridge/form-subdomain.mjs +2 -9
  7. package/dist/bridge/lib/age-gate.js +0 -12
  8. package/dist/bridge/lib/age-gate.mjs +0 -11
  9. package/dist/bridge/lib/checkout-kit.js +32 -2
  10. package/dist/bridge/lib/checkout-kit.mjs +32 -2
  11. package/dist/bridge/lib/entry.js +0 -3
  12. package/dist/bridge/lib/entry.mjs +0 -2
  13. package/dist/bridge/product-tile.js +6 -9
  14. package/dist/bridge/product-tile.mjs +6 -9
  15. package/dist/bridge/template-layout.js +122 -237
  16. package/dist/bridge/template-layout.mjs +122 -237
  17. package/dist/bridge/template-modal.js +73 -28
  18. package/dist/bridge/template-modal.mjs +74 -29
  19. package/dist/dashboard/buttons-subscription.js +1 -1
  20. package/dist/dashboard/buttons-subscription.mjs +1 -1
  21. package/dist/dashboard/campaign-form.js +2 -7
  22. package/dist/dashboard/campaign-form.mjs +2 -7
  23. package/dist/dashboard/card-order.js +4 -22
  24. package/dist/dashboard/card-order.mjs +4 -22
  25. package/dist/dashboard/document-blocks.js +17 -4
  26. package/dist/dashboard/document-blocks.mjs +17 -4
  27. package/dist/dashboard/form-admin-provider.js +17 -71
  28. package/dist/dashboard/form-admin-provider.mjs +17 -71
  29. package/dist/dashboard/form-file-upload.js +2 -3
  30. package/dist/dashboard/form-file-upload.mjs +3 -4
  31. package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
  32. package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
  33. package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
  34. package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
  35. package/dist/dashboard/form-organization-campaign.js +0 -82
  36. package/dist/dashboard/form-organization-campaign.mjs +0 -81
  37. package/dist/dashboard/form-organization-connection.js +6 -48
  38. package/dist/dashboard/form-organization-connection.mjs +7 -48
  39. package/dist/dashboard/form-organization-workflow.js +1 -72
  40. package/dist/dashboard/form-organization-workflow.mjs +1 -69
  41. package/dist/dashboard/form-otc.js +5 -4
  42. package/dist/dashboard/form-otc.mjs +5 -4
  43. package/dist/dashboard/form-stripe.js +5 -12
  44. package/dist/dashboard/form-stripe.mjs +5 -12
  45. package/dist/dashboard/input-fields.js +158 -11
  46. package/dist/dashboard/input-fields.mjs +158 -11
  47. package/dist/dashboard/input-file.js +4 -21
  48. package/dist/dashboard/input-file.mjs +4 -21
  49. package/dist/dashboard/lib/connection-controls.js +2 -5
  50. package/dist/dashboard/lib/connection-controls.mjs +1 -3
  51. package/dist/dashboard/lib/form-page.js +1 -1
  52. package/dist/dashboard/lib/form-page.mjs +1 -1
  53. package/dist/dashboard/lib/uppy.js +1 -10
  54. package/dist/dashboard/lib/uppy.mjs +2 -11
  55. package/dist/dashboard/order-sections.js +6 -456
  56. package/dist/dashboard/order-sections.mjs +7 -453
  57. package/dist/dashboard/provider-ui.js +7 -9
  58. package/dist/dashboard/provider-ui.mjs +7 -9
  59. package/dist/dashboard/template-ui.js +12 -4
  60. package/dist/dashboard/template-ui.mjs +12 -4
  61. package/dist/input-checkbox.js +10 -28
  62. package/dist/input-checkbox.mjs +10 -28
  63. package/dist/product.js +24 -96
  64. package/dist/product.mjs +25 -97
  65. package/dist/shared/lib/helpers.js +6 -54
  66. package/dist/shared/lib/helpers.mjs +8 -53
  67. package/package.json +4 -74
  68. package/types/bridge/fields.d.ts +2 -14
  69. package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
  70. package/types/bridge/lib/age-gate.d.ts +0 -5
  71. package/types/bridge/lib/checkout-kit.d.ts +10 -2
  72. package/types/bridge/lib/entry.d.ts +0 -3
  73. package/types/dashboard/card-order.d.ts +0 -6
  74. package/types/dashboard/document-blocks.d.ts +3 -2
  75. package/types/dashboard/form-admin-provider.d.ts +2 -9
  76. package/types/dashboard/form-file-upload.d.ts +1 -2
  77. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
  78. package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
  79. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  80. package/types/dashboard/form-organization-connection.d.ts +0 -11
  81. package/types/dashboard/form-otc.d.ts +1 -5
  82. package/types/dashboard/form-stripe.d.ts +2 -3
  83. package/types/dashboard/input-file.d.ts +0 -2
  84. package/types/dashboard/order-sections.d.ts +1 -24
  85. package/types/input-checkbox.d.ts +0 -2
  86. package/types/shared/lib/helpers.d.ts +0 -4
  87. package/dist/bridge/cart-drawer.js +0 -152
  88. package/dist/bridge/cart-drawer.mjs +0 -123
  89. package/dist/bridge/form-subdomain-checkout.js +0 -687
  90. package/dist/bridge/form-subdomain-checkout.mjs +0 -665
  91. package/dist/bridge/lib/cart.js +0 -79
  92. package/dist/bridge/lib/cart.mjs +0 -48
  93. package/dist/dashboard/embed-stripe.js +0 -145
  94. package/dist/dashboard/embed-stripe.mjs +0 -116
  95. package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
  96. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
  97. package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
  98. package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
  99. package/dist/dashboard/form-organization-product.js +0 -1461
  100. package/dist/dashboard/form-organization-product.mjs +0 -1425
  101. package/dist/dashboard/input-gallery.js +0 -201
  102. package/dist/dashboard/input-gallery.mjs +0 -172
  103. package/dist/dashboard/lib/products.js +0 -169
  104. package/dist/dashboard/lib/products.mjs +0 -135
  105. package/dist/dashboard/lib/settings-paths.js +0 -35
  106. package/dist/dashboard/lib/settings-paths.mjs +0 -11
  107. package/dist/dashboard/shipping-rates.js +0 -404
  108. package/dist/dashboard/shipping-rates.mjs +0 -371
  109. package/dist/dashboard/template-buyer.js +0 -301
  110. package/dist/dashboard/template-buyer.mjs +0 -267
  111. package/dist/shared/order-summary.js +0 -139
  112. package/dist/shared/order-summary.mjs +0 -110
  113. package/types/bridge/cart-drawer.d.ts +0 -31
  114. package/types/bridge/form-subdomain-checkout.d.ts +0 -20
  115. package/types/bridge/lib/cart.d.ts +0 -44
  116. package/types/dashboard/embed-stripe.d.ts +0 -25
  117. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
  118. package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
  119. package/types/dashboard/form-organization-product.d.ts +0 -24
  120. package/types/dashboard/input-gallery.d.ts +0 -14
  121. package/types/dashboard/lib/products.d.ts +0 -14
  122. package/types/dashboard/lib/settings-paths.d.ts +0 -5
  123. package/types/dashboard/shipping-rates.d.ts +0 -26
  124. package/types/dashboard/template-buyer.d.ts +0 -50
  125. package/types/shared/order-summary.d.ts +0 -19
@@ -41,9 +41,6 @@ const InputCheckbox = ({
41
41
  label,
42
42
  labelId,
43
43
  onChange,
44
- // @story fields/multiple-choice
45
- // A round button for one choice among several: role radio, a dot for its tick.
46
- round = false,
47
44
  style,
48
45
  value,
49
46
  ...rest
@@ -72,40 +69,25 @@ const InputCheckbox = ({
72
69
  id: boxId,
73
70
  inline: true,
74
71
  onClick: () => onChange(value ? false : true),
75
- role: round ? "radio" : "checkbox",
72
+ role: "checkbox",
76
73
  variant: "link",
77
74
  ...rest
78
75
  },
79
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
76
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
77
  "span",
81
78
  {
82
79
  ...{
83
80
  className: "relative flex items-center justify-center w-5 h-5 rounded-xs text-inherit bg-inherit border border-inherit",
84
- style: {
85
- ...(0, import_styles.inputCheckboxStyle)(style),
86
- ...round && {
87
- borderRadius: "9999px"
88
- }
89
- }
81
+ style: (0, import_styles.inputCheckboxStyle)(style)
90
82
  },
91
- children: [
92
- Boolean(value) && round && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
- "span",
94
- {
95
- ...{
96
- className: "w-2.5 h-2.5 rounded-full bg-current pointer-events-none"
97
- }
83
+ children: Boolean(value) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
+ import_check.default,
85
+ {
86
+ ...{
87
+ className: "absolute top-0 w-3.5 h-full pointer-events-none"
98
88
  }
99
- ),
100
- Boolean(value) && !round && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
- import_check.default,
102
- {
103
- ...{
104
- className: "absolute top-0 w-3.5 h-full pointer-events-none"
105
- }
106
- }
107
- )
108
- ]
89
+ }
90
+ )
109
91
  }
110
92
  )
111
93
  }
@@ -9,9 +9,6 @@ const InputCheckbox = ({
9
9
  label,
10
10
  labelId,
11
11
  onChange,
12
- // @story fields/multiple-choice
13
- // A round button for one choice among several: role radio, a dot for its tick.
14
- round = false,
15
12
  style,
16
13
  value,
17
14
  ...rest
@@ -40,40 +37,25 @@ const InputCheckbox = ({
40
37
  id: boxId,
41
38
  inline: true,
42
39
  onClick: () => onChange(value ? false : true),
43
- role: round ? "radio" : "checkbox",
40
+ role: "checkbox",
44
41
  variant: "link",
45
42
  ...rest
46
43
  },
47
- children: /* @__PURE__ */ jsxs(
44
+ children: /* @__PURE__ */ jsx(
48
45
  "span",
49
46
  {
50
47
  ...{
51
48
  className: "relative flex items-center justify-center w-5 h-5 rounded-xs text-inherit bg-inherit border border-inherit",
52
- style: {
53
- ...inputCheckboxStyle(style),
54
- ...round && {
55
- borderRadius: "9999px"
56
- }
57
- }
49
+ style: inputCheckboxStyle(style)
58
50
  },
59
- children: [
60
- Boolean(value) && round && /* @__PURE__ */ jsx(
61
- "span",
62
- {
63
- ...{
64
- className: "w-2.5 h-2.5 rounded-full bg-current pointer-events-none"
65
- }
51
+ children: Boolean(value) && /* @__PURE__ */ jsx(
52
+ Check,
53
+ {
54
+ ...{
55
+ className: "absolute top-0 w-3.5 h-full pointer-events-none"
66
56
  }
67
- ),
68
- Boolean(value) && !round && /* @__PURE__ */ jsx(
69
- Check,
70
- {
71
- ...{
72
- className: "absolute top-0 w-3.5 h-full pointer-events-none"
73
- }
74
- }
75
- )
76
- ]
57
+ }
58
+ )
77
59
  }
78
60
  )
79
61
  }
package/dist/product.js CHANGED
@@ -35,7 +35,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var import_react = require("react");
36
36
  var import_embla_carousel_react = __toESM(require("embla-carousel-react"));
37
37
  var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
38
- var import_helpers = require("./shared/lib/helpers");
38
+ var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
39
39
  var import_input_group = __toESM(require("./input-group"));
40
40
  var import_input_select = __toESM(require("./input-select"));
41
41
  var import_wrapper_gradient = __toESM(require("./wrapper-gradient"));
@@ -90,43 +90,26 @@ const Product = ({
90
90
  );
91
91
  const [activeImage, setActiveImage] = (0, import_react.useState)(0);
92
92
  const [emblaRef, emblaApi] = (0, import_embla_carousel_react.default)();
93
- const chosen = available.find((v) => v.id === variant) || null;
94
- const selectedVariant = chosen || available[0] || null;
95
- const [picked, setPicked] = (0, import_react.useState)([]);
93
+ const selectedVariant = available.find((v) => v.id === variant) || available[0] || null;
96
94
  const images = (0, import_react.useMemo)(
97
95
  () => {
98
- var _a2;
99
96
  const variants = ((product == null ? void 0 : product.variants) || []).filter((v) => v.availableForSale);
100
97
  const result = [];
101
98
  const seen = /* @__PURE__ */ new Set();
102
- const remote = (url, variant2 = null) => ({
103
- src: (0, import_cdn.cdnShopify)(url, "400x400", product == null ? void 0 : product.updatedAt) || url,
104
- thumb: (0, import_cdn.cdnShopify)(url, "100x100", product == null ? void 0 : product.updatedAt) || url,
105
- url,
106
- variant: variant2
107
- });
108
- for (const item of (product == null ? void 0 : product.images) || []) {
109
- if ((item == null ? void 0 : item.url) && !seen.has(item.url)) {
110
- seen.add(item.url);
111
- result.push(remote(item.url));
112
- } else if ((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.sizes) {
113
- const src = (0, import_cdn.cdnSrc)(item.file, "400x400", item.file.updatedAt) || (0, import_cdn.cdnSrc)(item.file, "original", item.file.updatedAt);
114
- if (src) result.push({
115
- src,
116
- thumb: (0, import_cdn.cdnSrc)(item.file, "100x100", item.file.updatedAt) || src,
117
- url: item.file.id,
118
- variant: null
119
- });
120
- }
121
- }
122
- if (!result.length && (product == null ? void 0 : product.image)) {
99
+ if (product == null ? void 0 : product.image) {
123
100
  seen.add(product.image);
124
- result.push(remote(product.image));
101
+ result.push({
102
+ src: product.image,
103
+ variant: null
104
+ });
125
105
  }
126
106
  for (const v of variants) {
127
107
  if (v.image && !seen.has(v.image)) {
128
108
  seen.add(v.image);
129
- result.push(remote(v.image, v));
109
+ result.push({
110
+ src: v.image,
111
+ variant: v
112
+ });
130
113
  }
131
114
  }
132
115
  return result;
@@ -151,25 +134,13 @@ const Product = ({
151
134
  onVariantChange(value);
152
135
  const v = available.find((x) => x.id === value);
153
136
  if (!(v == null ? void 0 : v.image)) return;
154
- const idx = images.findIndex((img) => img.url === v.image);
137
+ const idx = images.findIndex((img) => img.src === v.image);
155
138
  if (idx >= 0) {
156
139
  setActiveImage(idx);
157
140
  emblaApi == null ? void 0 : emblaApi.scrollTo(idx);
158
141
  }
159
142
  ;
160
143
  };
161
- const options = ((product == null ? void 0 : product.options) || []).filter(() => available.every((v) => (v.selectedOptions || []).length));
162
- const values = chosen ? (chosen.selectedOptions || []).map((item) => item == null ? void 0 : item.value) : picked;
163
- const pickOption = (index, value) => {
164
- const wanted = options.map((item, key) => key === index ? value : values[key]);
165
- setPicked(wanted);
166
- if (wanted.some((item) => !item)) return onVariantChange("");
167
- const match = available.find((v) => (v.selectedOptions || []).every((item, key) => (item == null ? void 0 : item.value) === wanted[key])) || available.find((v) => {
168
- var _a2, _b2;
169
- return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
170
- });
171
- if (match) handleVariant(match.id);
172
- };
173
144
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
174
145
  "div",
175
146
  {
@@ -199,7 +170,7 @@ const Product = ({
199
170
  classNameScroll: "flex flex-col w-12 h-48 space-y-3",
200
171
  color: resolved.background.color.rgb
201
172
  },
202
- children: images.map(({ thumb }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ children: images.map(({ src }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
203
174
  import_button.default,
204
175
  {
205
176
  ...{
@@ -228,7 +199,7 @@ const Product = ({
228
199
  className: "object-cover",
229
200
  fill: true,
230
201
  sizes: "48px",
231
- src: thumb,
202
+ src: (0, import_cdn.cdnShopify)(src, "100x100", product == null ? void 0 : product.updatedAt) || src,
232
203
  // Always set opacity + transition so switching the active
233
204
  // thumbnail animates the fade in both directions.
234
205
  style: {
@@ -289,7 +260,7 @@ const Product = ({
289
260
  className: "object-cover",
290
261
  fill: true,
291
262
  sizes: "192px",
292
- src,
263
+ src: (0, import_cdn.cdnShopify)(src, "400x400", product == null ? void 0 : product.updatedAt) || src,
293
264
  unoptimized: true
294
265
  }
295
266
  }
@@ -321,24 +292,11 @@ const Product = ({
321
292
  children: product == null ? void 0 : product.title
322
293
  }
323
294
  ),
324
- !available.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
325
- (0, import_helpers.money)({
326
- code: selectedVariant.currency,
327
- value: selectedVariant.price
328
- }),
329
- selectedVariant.sale > selectedVariant.price && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
- "s",
331
- {
332
- ...{
333
- className: "ml-2 opacity-60"
334
- },
335
- children: (0, import_helpers.money)({
336
- code: selectedVariant.currency,
337
- value: selectedVariant.sale
338
- })
339
- }
340
- )
341
- ] }),
295
+ !available.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_drawbridge_utils.formatCurrency)({
296
+ code: selectedVariant.currency,
297
+ display: "parts",
298
+ value: selectedVariant.price
299
+ }) }),
342
300
  (product == null ? void 0 : product.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
343
301
  import_wrapper_gradient.default,
344
302
  {
@@ -352,37 +310,7 @@ const Product = ({
352
310
  ]
353
311
  }
354
312
  ),
355
- options.length > 0 && available.length > 0 && options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
356
- import_input_group.default,
357
- {
358
- ...{
359
- error: index === options.length - 1 ? errors == null ? void 0 : errors.variant : null,
360
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
361
- import_input_select.default,
362
- {
363
- ...{
364
- "aria-label": option.name,
365
- disabled,
366
- onChange: (value) => pickOption(index, value),
367
- options: option.values.filter((value) => available.some((v) => {
368
- var _a2, _b2;
369
- return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
370
- })).map((value) => ({
371
- label: value,
372
- value
373
- })),
374
- style: resolved,
375
- value: values[index] || ""
376
- }
377
- }
378
- ),
379
- label: option.name,
380
- style: resolved
381
- }
382
- },
383
- "option-" + option.name
384
- )),
385
- !options.length && available.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
313
+ available.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
386
314
  import_input_group.default,
387
315
  {
388
316
  ...{
@@ -406,7 +334,7 @@ const Product = ({
406
334
  }
407
335
  }
408
336
  ),
409
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
337
+ available.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
410
338
  import_input_group.default,
411
339
  {
412
340
  ...{
@@ -428,7 +356,7 @@ const Product = ({
428
356
  import_button.default,
429
357
  {
430
358
  ...{
431
- disabled: disabled || Boolean(action) || !available.length,
359
+ disabled: disabled || Boolean(action),
432
360
  onClick: onAdd,
433
361
  variant: "link"
434
362
  },
@@ -458,7 +386,7 @@ const Product = ({
458
386
  import_button.default,
459
387
  {
460
388
  ...{
461
- disabled: disabled || Boolean(action) || !available.length,
389
+ disabled: disabled || Boolean(action),
462
390
  loading: action === "buy",
463
391
  onClick: onBuy,
464
392
  style: resolved
package/dist/product.mjs CHANGED
@@ -2,8 +2,8 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useMemo, useState } from "react";
4
4
  import useEmblaCarousel from "embla-carousel-react";
5
- import { cdnShopify, cdnSrc } from "@drawbridge/drawbridge-utils/cdn";
6
- import { money } from "./shared/lib/helpers.mjs";
5
+ import { cdnShopify } from "@drawbridge/drawbridge-utils/cdn";
6
+ import { formatCurrency } from "@drawbridge/drawbridge-utils";
7
7
  import InputGroup from "./input-group.mjs";
8
8
  import InputSelect from "./input-select.mjs";
9
9
  import WrapperGradient from "./wrapper-gradient.mjs";
@@ -58,43 +58,26 @@ const Product = ({
58
58
  );
59
59
  const [activeImage, setActiveImage] = useState(0);
60
60
  const [emblaRef, emblaApi] = useEmblaCarousel();
61
- const chosen = available.find((v) => v.id === variant) || null;
62
- const selectedVariant = chosen || available[0] || null;
63
- const [picked, setPicked] = useState([]);
61
+ const selectedVariant = available.find((v) => v.id === variant) || available[0] || null;
64
62
  const images = useMemo(
65
63
  () => {
66
- var _a2;
67
64
  const variants = ((product == null ? void 0 : product.variants) || []).filter((v) => v.availableForSale);
68
65
  const result = [];
69
66
  const seen = /* @__PURE__ */ new Set();
70
- const remote = (url, variant2 = null) => ({
71
- src: cdnShopify(url, "400x400", product == null ? void 0 : product.updatedAt) || url,
72
- thumb: cdnShopify(url, "100x100", product == null ? void 0 : product.updatedAt) || url,
73
- url,
74
- variant: variant2
75
- });
76
- for (const item of (product == null ? void 0 : product.images) || []) {
77
- if ((item == null ? void 0 : item.url) && !seen.has(item.url)) {
78
- seen.add(item.url);
79
- result.push(remote(item.url));
80
- } else if ((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.sizes) {
81
- const src = cdnSrc(item.file, "400x400", item.file.updatedAt) || cdnSrc(item.file, "original", item.file.updatedAt);
82
- if (src) result.push({
83
- src,
84
- thumb: cdnSrc(item.file, "100x100", item.file.updatedAt) || src,
85
- url: item.file.id,
86
- variant: null
87
- });
88
- }
89
- }
90
- if (!result.length && (product == null ? void 0 : product.image)) {
67
+ if (product == null ? void 0 : product.image) {
91
68
  seen.add(product.image);
92
- result.push(remote(product.image));
69
+ result.push({
70
+ src: product.image,
71
+ variant: null
72
+ });
93
73
  }
94
74
  for (const v of variants) {
95
75
  if (v.image && !seen.has(v.image)) {
96
76
  seen.add(v.image);
97
- result.push(remote(v.image, v));
77
+ result.push({
78
+ src: v.image,
79
+ variant: v
80
+ });
98
81
  }
99
82
  }
100
83
  return result;
@@ -119,25 +102,13 @@ const Product = ({
119
102
  onVariantChange(value);
120
103
  const v = available.find((x) => x.id === value);
121
104
  if (!(v == null ? void 0 : v.image)) return;
122
- const idx = images.findIndex((img) => img.url === v.image);
105
+ const idx = images.findIndex((img) => img.src === v.image);
123
106
  if (idx >= 0) {
124
107
  setActiveImage(idx);
125
108
  emblaApi == null ? void 0 : emblaApi.scrollTo(idx);
126
109
  }
127
110
  ;
128
111
  };
129
- const options = ((product == null ? void 0 : product.options) || []).filter(() => available.every((v) => (v.selectedOptions || []).length));
130
- const values = chosen ? (chosen.selectedOptions || []).map((item) => item == null ? void 0 : item.value) : picked;
131
- const pickOption = (index, value) => {
132
- const wanted = options.map((item, key) => key === index ? value : values[key]);
133
- setPicked(wanted);
134
- if (wanted.some((item) => !item)) return onVariantChange("");
135
- const match = available.find((v) => (v.selectedOptions || []).every((item, key) => (item == null ? void 0 : item.value) === wanted[key])) || available.find((v) => {
136
- var _a2, _b2;
137
- return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
138
- });
139
- if (match) handleVariant(match.id);
140
- };
141
112
  return /* @__PURE__ */ jsxs(
142
113
  "div",
143
114
  {
@@ -167,7 +138,7 @@ const Product = ({
167
138
  classNameScroll: "flex flex-col w-12 h-48 space-y-3",
168
139
  color: resolved.background.color.rgb
169
140
  },
170
- children: images.map(({ thumb }, key) => /* @__PURE__ */ jsx(
141
+ children: images.map(({ src }, key) => /* @__PURE__ */ jsx(
171
142
  Button,
172
143
  {
173
144
  ...{
@@ -196,7 +167,7 @@ const Product = ({
196
167
  className: "object-cover",
197
168
  fill: true,
198
169
  sizes: "48px",
199
- src: thumb,
170
+ src: cdnShopify(src, "100x100", product == null ? void 0 : product.updatedAt) || src,
200
171
  // Always set opacity + transition so switching the active
201
172
  // thumbnail animates the fade in both directions.
202
173
  style: {
@@ -257,7 +228,7 @@ const Product = ({
257
228
  className: "object-cover",
258
229
  fill: true,
259
230
  sizes: "192px",
260
- src,
231
+ src: cdnShopify(src, "400x400", product == null ? void 0 : product.updatedAt) || src,
261
232
  unoptimized: true
262
233
  }
263
234
  }
@@ -289,24 +260,11 @@ const Product = ({
289
260
  children: product == null ? void 0 : product.title
290
261
  }
291
262
  ),
292
- !available.length ? /* @__PURE__ */ jsx("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ jsxs("p", { children: [
293
- money({
294
- code: selectedVariant.currency,
295
- value: selectedVariant.price
296
- }),
297
- selectedVariant.sale > selectedVariant.price && /* @__PURE__ */ jsx(
298
- "s",
299
- {
300
- ...{
301
- className: "ml-2 opacity-60"
302
- },
303
- children: money({
304
- code: selectedVariant.currency,
305
- value: selectedVariant.sale
306
- })
307
- }
308
- )
309
- ] }),
263
+ !available.length ? /* @__PURE__ */ jsx("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ jsx("p", { children: formatCurrency({
264
+ code: selectedVariant.currency,
265
+ display: "parts",
266
+ value: selectedVariant.price
267
+ }) }),
310
268
  (product == null ? void 0 : product.description) && /* @__PURE__ */ jsx(
311
269
  WrapperGradient,
312
270
  {
@@ -320,37 +278,7 @@ const Product = ({
320
278
  ]
321
279
  }
322
280
  ),
323
- options.length > 0 && available.length > 0 && options.map((option, index) => /* @__PURE__ */ jsx(
324
- InputGroup,
325
- {
326
- ...{
327
- error: index === options.length - 1 ? errors == null ? void 0 : errors.variant : null,
328
- input: /* @__PURE__ */ jsx(
329
- InputSelect,
330
- {
331
- ...{
332
- "aria-label": option.name,
333
- disabled,
334
- onChange: (value) => pickOption(index, value),
335
- options: option.values.filter((value) => available.some((v) => {
336
- var _a2, _b2;
337
- return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
338
- })).map((value) => ({
339
- label: value,
340
- value
341
- })),
342
- style: resolved,
343
- value: values[index] || ""
344
- }
345
- }
346
- ),
347
- label: option.name,
348
- style: resolved
349
- }
350
- },
351
- "option-" + option.name
352
- )),
353
- !options.length && available.length > 1 && /* @__PURE__ */ jsx(
281
+ available.length > 1 && /* @__PURE__ */ jsx(
354
282
  InputGroup,
355
283
  {
356
284
  ...{
@@ -374,7 +302,7 @@ const Product = ({
374
302
  }
375
303
  }
376
304
  ),
377
- /* @__PURE__ */ jsx(
305
+ available.length > 0 && /* @__PURE__ */ jsx(
378
306
  InputGroup,
379
307
  {
380
308
  ...{
@@ -396,7 +324,7 @@ const Product = ({
396
324
  Button,
397
325
  {
398
326
  ...{
399
- disabled: disabled || Boolean(action) || !available.length,
327
+ disabled: disabled || Boolean(action),
400
328
  onClick: onAdd,
401
329
  variant: "link"
402
330
  },
@@ -426,7 +354,7 @@ const Product = ({
426
354
  Button,
427
355
  {
428
356
  ...{
429
- disabled: disabled || Boolean(action) || !available.length,
357
+ disabled: disabled || Boolean(action),
430
358
  loading: action === "buy",
431
359
  onClick: onBuy,
432
360
  style: resolved