bitsnap-react 1.12.0 → 1.12.1
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.
- package/README.md +27 -3
- package/dist/CartProvider-WPJWECBS.mjs +2 -0
- package/dist/CartProvider-YPZ3HD7W.js +2 -0
- package/dist/CartProvider-YPZ3HD7W.js.map +1 -0
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/{chunk-XTIY6PXH.js → chunk-3ITTSNWG.js} +2 -2
- package/dist/chunk-3ITTSNWG.js.map +1 -0
- package/dist/chunk-4BV5IUZH.js +2 -0
- package/dist/chunk-4BV5IUZH.js.map +1 -0
- package/dist/{chunk-6IACFTJR.js → chunk-4ZFIL5S7.js} +2 -2
- package/dist/chunk-4ZFIL5S7.js.map +1 -0
- package/dist/{chunk-E5DCEFI2.mjs → chunk-DRAKVCD7.mjs} +2 -2
- package/dist/{chunk-5R3WR22A.mjs → chunk-G3VVAVG7.mjs} +2 -2
- package/dist/chunk-GJNFDUJN.mjs +4 -0
- package/dist/chunk-GJNFDUJN.mjs.map +1 -0
- package/dist/{chunk-3QG7H2AI.mjs → chunk-HBPSSGYN.mjs} +2 -2
- package/dist/{chunk-DF2IK2GN.js → chunk-HDLCLZOK.js} +2 -2
- package/dist/chunk-HDLCLZOK.js.map +1 -0
- package/dist/{chunk-DGUIG334.js → chunk-I6BRDRPB.js} +2 -2
- package/dist/chunk-I6BRDRPB.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/{chunk-ICFYSZTV.js → chunk-MZSLLGFS.js} +2 -2
- package/dist/chunk-MZSLLGFS.js.map +1 -0
- package/dist/{chunk-MLSKHOA3.js → chunk-STVEBT6M.js} +2 -2
- package/dist/chunk-STVEBT6M.js.map +1 -0
- package/dist/{chunk-FF2ICGFQ.mjs → chunk-T2YSOHJM.mjs} +2 -2
- package/dist/{chunk-FF2ICGFQ.mjs.map → chunk-T2YSOHJM.mjs.map} +1 -1
- package/dist/chunk-T3PAOMHI.mjs +2 -0
- package/dist/chunk-T3PAOMHI.mjs.map +1 -0
- package/dist/{chunk-QSIKRVZL.mjs → chunk-VDLJW4JJ.mjs} +2 -2
- package/dist/{chunk-UCESDAEC.mjs → chunk-VF62KDNS.mjs} +2 -2
- package/dist/chunk-VRL3IF5J.js +4 -0
- package/dist/chunk-VRL3IF5J.js.map +1 -0
- package/dist/chunk-XIHGWNTS.js.map +1 -1
- package/dist/consent.js.map +1 -1
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-FVDH6Y57.mjs +2 -0
- package/dist/methods-ISVX5JQ7.js +2 -0
- package/dist/methods-ISVX5JQ7.js.map +1 -0
- package/dist/models.js.map +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/package.json +26 -51
- package/dist/CartProvider-XNFSUOCB.js +0 -2
- package/dist/CartProvider-XNFSUOCB.js.map +0 -1
- package/dist/CartProvider-YMJ7RFO4.mjs +0 -2
- package/dist/chunk-4BW6J7FP.js +0 -4
- package/dist/chunk-4BW6J7FP.js.map +0 -1
- package/dist/chunk-6IACFTJR.js.map +0 -1
- package/dist/chunk-DF2IK2GN.js.map +0 -1
- package/dist/chunk-DGUIG334.js.map +0 -1
- package/dist/chunk-ERL4Z7M7.js +0 -2
- package/dist/chunk-ERL4Z7M7.js.map +0 -1
- package/dist/chunk-ICFYSZTV.js.map +0 -1
- package/dist/chunk-MLSKHOA3.js.map +0 -1
- package/dist/chunk-P4Q5KXKS.mjs +0 -2
- package/dist/chunk-P4Q5KXKS.mjs.map +0 -1
- package/dist/chunk-PNTO3L2C.mjs +0 -4
- package/dist/chunk-PNTO3L2C.mjs.map +0 -1
- package/dist/chunk-XTIY6PXH.js.map +0 -1
- package/dist/methods-DDGOXLP6.mjs +0 -2
- package/dist/methods-RQPDIUUN.js +0 -2
- package/dist/methods-RQPDIUUN.js.map +0 -1
- /package/dist/{CartProvider-YMJ7RFO4.mjs.map → CartProvider-WPJWECBS.mjs.map} +0 -0
- /package/dist/{chunk-E5DCEFI2.mjs.map → chunk-DRAKVCD7.mjs.map} +0 -0
- /package/dist/{chunk-5R3WR22A.mjs.map → chunk-G3VVAVG7.mjs.map} +0 -0
- /package/dist/{chunk-3QG7H2AI.mjs.map → chunk-HBPSSGYN.mjs.map} +0 -0
- /package/dist/{chunk-QSIKRVZL.mjs.map → chunk-VDLJW4JJ.mjs.map} +0 -0
- /package/dist/{chunk-UCESDAEC.mjs.map → chunk-VF62KDNS.mjs.map} +0 -0
- /package/dist/{methods-DDGOXLP6.mjs.map → methods-FVDH6Y57.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -154,6 +154,8 @@ built-in styles):
|
|
|
154
154
|
| `countrySearch` | Country search field |
|
|
155
155
|
| `countryOption` | Single country option |
|
|
156
156
|
| `paymentButtons` | Apple Pay / Google Pay wrappers |
|
|
157
|
+
| `paymentMethods` | "How would you like to pay?" group (online or transfer / BLIK to a phone) |
|
|
158
|
+
| `paymentMethodOption`| Single payment method card |
|
|
157
159
|
| `checkoutButton` | "Next step" button |
|
|
158
160
|
| `emptyState` | Empty cart message |
|
|
159
161
|
| `error` | Checkout error message |
|
|
@@ -183,10 +185,10 @@ conflicting Tailwind utilities from the library are resolved in your favor.
|
|
|
183
185
|
| `fontFamily` | The whole checkout |
|
|
184
186
|
| `fontSize` | The whole checkout |
|
|
185
187
|
| `background` | Panel, country trigger |
|
|
186
|
-
| `surface` | Country dropdown, search bar, loading skeletons
|
|
188
|
+
| `surface` | Country dropdown, search bar, loading skeletons, selected payment method |
|
|
187
189
|
| `foreground` | Titles, prices, total |
|
|
188
190
|
| `mutedForeground` | Empty cart, delivery note, country label, search field |
|
|
189
|
-
| `border` | Country trigger, dropdown, product separators
|
|
191
|
+
| `border` | Country trigger, dropdown, product separators, payment method cards |
|
|
190
192
|
| `buttonBackground` | "Next step" button |
|
|
191
193
|
| `buttonForeground` | "Next step" button |
|
|
192
194
|
| `buttonHoverBackground` | "Next step" button on hover |
|
|
@@ -355,7 +357,29 @@ copy per language, pass a different object.
|
|
|
355
357
|
Checkout keys (`CheckoutTexts`): `cart`, `emptyCart`, `total`, `delivery`,
|
|
356
358
|
`chooseCountry`, `nextStep`, `unavailableProducts`, `checkoutFailed`,
|
|
357
359
|
`noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`,
|
|
358
|
-
`mixedRecurring`, `currencyUnsupported`, `priceChanged
|
|
360
|
+
`mixedRecurring`, `currencyUnsupported`, `priceChanged`, `paymentMethodLegend`,
|
|
361
|
+
`paymentMethodOnline`, `paymentMethodOnlineDescription`,
|
|
362
|
+
`paymentMethodManualTransfer`, `paymentMethodManualBlik`,
|
|
363
|
+
`paymentMethodManualBoth`, `paymentMethodManualDescription`,
|
|
364
|
+
`paymentMethodManualBlikNote`.
|
|
365
|
+
|
|
366
|
+
### Paying online or by transfer / BLIK to a phone
|
|
367
|
+
|
|
368
|
+
When the shop turned on manual payments with "show at checkout", the cart asks
|
|
369
|
+
the buyer how they want to pay before "Next step": online (card, BLIK code,
|
|
370
|
+
instant transfer through the shop's gateway) or by hand (bank transfer and/or
|
|
371
|
+
BLIK to the seller's phone number; the label follows the accounts the seller
|
|
372
|
+
has). The first option is the seller's preferred one and is selected. The
|
|
373
|
+
seller's account and phone number are shown only after the order is placed, on
|
|
374
|
+
the Bitsnap payment page the cart redirects to; the order waits for the payment
|
|
375
|
+
there and the cart is cleared.
|
|
376
|
+
|
|
377
|
+
The cart asks `POST /public-commerce/payment-methods` (same body as `/buy`) once
|
|
378
|
+
per cart content. `choice: null`, an error, a timeout (5 s) or an older
|
|
379
|
+
bitsnap.pl that does not have the endpoint leave the cart as before: no choice
|
|
380
|
+
and a plain `/buy`. `/buy` gets `paymentMethod: "online" | "manual"` only when
|
|
381
|
+
the choice was shown. Apple Pay and Google Pay are online payments and do not
|
|
382
|
+
change.
|
|
359
383
|
|
|
360
384
|
When "Next step" fails, the cart shows the text of the backend error code
|
|
361
385
|
(`noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{K as c,L as d,M as e,N as f,O as g,P as h,Q as i,R as j,S as k,T as l}from"./chunk-GJNFDUJN.mjs";import"./chunk-G3VVAVG7.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-HBPSSGYN.mjs";import"./chunk-VF62KDNS.mjs";import{l as a,m as b}from"./chunk-T3PAOMHI.mjs";import"./chunk-T2YSOHJM.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,k as default,h as getCartLines,l as getCheckoutMethods,g as getCheckoutSelection,b as getLocale,f as getProjectID,i as reconcileOrderOfLastPayment,a as setLocale,e as setProjectID,j as useCartProvider};
|
|
2
|
+
//# sourceMappingURL=CartProvider-WPJWECBS.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVRL3IF5Jjs = require('./chunk-VRL3IF5J.js');require('./chunk-STVEBT6M.js');require('./chunk-KOYBZORL.js');require('./chunk-I6BRDRPB.js');require('./chunk-4ZFIL5S7.js');var _chunk4BV5IUZHjs = require('./chunk-4BV5IUZH.js');require('./chunk-HDLCLZOK.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.MARKETING_AGREEMENT_ID = _chunkVRL3IF5Jjs.K; exports.bitsnapProjectID = _chunkVRL3IF5Jjs.L; exports.default = _chunkVRL3IF5Jjs.S; exports.getCartLines = _chunkVRL3IF5Jjs.P; exports.getCheckoutMethods = _chunkVRL3IF5Jjs.T; exports.getCheckoutSelection = _chunkVRL3IF5Jjs.O; exports.getLocale = _chunk4BV5IUZHjs.m; exports.getProjectID = _chunkVRL3IF5Jjs.N; exports.reconcileOrderOfLastPayment = _chunkVRL3IF5Jjs.Q; exports.setLocale = _chunk4BV5IUZHjs.l; exports.setProjectID = _chunkVRL3IF5Jjs.M; exports.useCartProvider = _chunkVRL3IF5Jjs.R;
|
|
2
|
+
//# sourceMappingURL=CartProvider-YPZ3HD7W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/CartProvider-YPZ3HD7W.js"],"names":[],"mappings":"AAAA,+HAAsG,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,+BAA4B,siBAAmQ","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/CartProvider-YPZ3HD7W.js"}
|
package/dist/analytics.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHDLCLZOKjs = require('./chunk-HDLCLZOK.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkHDLCLZOKjs.i; exports.DEFAULT_ENDPOINT = _chunkHDLCLZOKjs.c; exports.InstrumentProvider = _chunkHDLCLZOKjs.l; exports.createTracker = _chunkHDLCLZOKjs.d; exports.getTracker = _chunkHDLCLZOKjs.f; exports.initTracker = _chunkHDLCLZOKjs.e; exports.noopInstrument = _chunkHDLCLZOKjs.k; exports.resetTracker = _chunkHDLCLZOKjs.g; exports.scoreBucket = _chunkHDLCLZOKjs.r; exports.startAutoPageViews = _chunkHDLCLZOKjs.b; exports.useAnalytics = _chunkHDLCLZOKjs.j; exports.useInstrument = _chunkHDLCLZOKjs.n; exports.useInstrumentContext = _chunkHDLCLZOKjs.m;
|
|
2
2
|
//# sourceMappingURL=analytics.js.map
|
package/dist/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems/
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/analytics.js"],"names":[],"mappings":"AAAA,+HAAsH,+BAA4B,+BAA4B,klBAAsR","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/analytics.js"}
|
package/dist/analytics.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-
|
|
1
|
+
import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-T2YSOHJM.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
|
|
2
2
|
//# sourceMappingURL=analytics.mjs.map
|
package/dist/catalog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3ITTSNWGjs = require('./chunk-3ITTSNWG.js');require('./chunk-KOYBZORL.js');require('./chunk-4BV5IUZH.js');require('./chunk-HDLCLZOK.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunk3ITTSNWGjs.a; exports.ProductList = _chunk3ITTSNWGjs.d; exports.formatProductPrice = _chunk3ITTSNWGjs.b; exports.useProducts = _chunk3ITTSNWGjs.c;
|
|
2
2
|
//# sourceMappingURL=catalog.js.map
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems/
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/catalog.js"],"names":[],"mappings":"AAAA,+HAA4D,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,0LAA+F","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/catalog.js"}
|
package/dist/catalog.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f}from"./chunk-VDLJW4JJ.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-T3PAOMHI.mjs";import"./chunk-T2YSOHJM.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
|
|
2
2
|
//# sourceMappingURL=catalog.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkERL4Z7M7js = require('./chunk-ERL4Z7M7.js');var _chunkDF2IK2GNjs = require('./chunk-DF2IK2GN.js');var wt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Et={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},_t={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},Dt=[];function pt(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:_t,variables:Et,shadcnVariables:Dt});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return _chunkKOYBZORLjs.b.call(void 0, t.elements,e)}function mt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function H(t,e,r=_chunkERL4Z7M7js.k){let o=t/100,n=_nullishCoalesce(mt(r,e), () => (mt(_chunkERL4Z7M7js.k,e)));return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}var _react = require('react');var Ot=24,Nt=48,M=class extends Error{constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Ot:Math.min(Nt,Math.max(1,Math.floor(t)))}function ft(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Rt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=_optionalChain([t, 'access', _2 => _2.search, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Bt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function gt(t,e){let r=await fetch(_chunkERL4Z7M7js.c.call(void 0, Rt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new M(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Bt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[s]=_react.useState.call(void 0, ()=>_chunkERL4Z7M7js.f),i=_nullishCoalesce(t.host, () => (s)),d=O(t.pageSize),c=JSON.stringify([e,i,_nullishCoalesce(r, () => (null)),_nullishCoalesce(_optionalChain([o, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => (null)),d]),[m,u]=_react.useState.call(void 0, {queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=_react.useState.call(void 0, 0),[f,l]=_react.useState.call(void 0, ()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=_nullishCoalesce(_optionalChain([f, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.totalCount]), () => (0)),P=ft(g,d),h=m.queryKey===c?m.page:1,k=g>0?Math.min(h,P):h,C=`${c}|${k}|${b}`,T=f.requestKey===C;_react.useEffect.call(void 0, ()=>{if(T)return;let y=new AbortController;return gt({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(x=>{y.signal.aborted||l({requestKey:C,data:x,error:void 0})},x=>{y.signal.aborted||l(E=>({requestKey:C,data:E.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=_react.useCallback.call(void 0, y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=_react.useCallback.call(void 0, ()=>v(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([f, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.items]), () => ([])),totalCount:g,page:k,pageCount:P,setPage:I,isLoading:!T,error:T?f.error:void 0,refetch:A}),[f,g,k,P,I,T,A])}function bt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?N(e.host):"",n=N(t.host);if(o&&o!==n){if(n!==N(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function yt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./methods-RQPDIUUN.js"))),Promise.resolve().then(() => _interopRequireWildcard(require("./CartProvider-XNFSUOCB.js")))]),s=bt({projectID:o(),host:_chunkERL4Z7M7js.f,defaultHost:_chunkERL4Z7M7js.e},e);if(!s.ok)return Ut(s.reason);if(s.setProjectID!=null&&n(s.setProjectID),s.setHost!=null&&_chunkERL4Z7M7js.g.call(void 0, s.setHost),await r.addProductToCart(_nullishCoalesce(t.cartItemId, () => (t.id)),1,void 0,{url:e.url,name:t.name,price:t.price,currency:t.currency,analytics:_chunkDF2IK2GNjs.k})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ut(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var $=50,Ht=1e3;function Lt(t,e=Ht){let r=new Set,o=new Map,n=[],s=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=s.slice(0,$);n=n.slice($),s=s.slice($);try{t({productIds:l,positions:g})}catch (e3){}}}function u(){m();try{_optionalChain([_chunkDF2IK2GNjs.f.call(void 0, ), 'optionalAccess', _11 => _11.flush, 'call', _12 => _12()])}catch (e4){}}let b=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};function v(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",u,!0),document.addEventListener("visibilitychange",b,!0))}function f(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(l=>{for(let g of l){let P=o.get(g.target);!P||!g.isIntersecting||g.intersectionRatio<.5||(o.delete(g.target),_optionalChain([i, 'optionalAccess', _13 => _13.unobserve, 'call', _14 => _14(g.target)]),!r.has(P.id)&&(r.add(P.id),n.push(P.id),s.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),_optionalChain([d, 'access', _15 => _15.unref, 'optionalCall', _16 => _16()]))},{threshold:[.5]}),v(),i}return{observe(l,g,P){try{if(r.has(g))return()=>{};let h=f();return h?(o.set(l,{id:g,position:P}),h.observe(l),()=>{o.delete(l),h.unobserve(l)}):()=>{}}catch (e5){return()=>{}}},flush:m,destroy(){try{m(),_optionalChain([i, 'optionalAccess', _17 => _17.disconnect, 'call', _18 => _18()]),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch (e6){}i=void 0,o.clear()}}}var Mt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function ht(t,e){return _chunkERL4Z7M7js.i.call(void 0, Mt,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}var _jsxruntime = require('react/jsx-runtime');var vt=_react.createContext.call(void 0, void 0),$t={observe:()=>()=>{},clicked:()=>{}},Ct=_react.createContext.call(void 0, $t);function j(){let t=_react.useContext.call(void 0, vt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function p(t,e){let{appearance:r}=j(),o=q(r,t);return{"data-bitsnap-products-slot":t,className:_chunkERL4Z7M7js.d.call(void 0, e,_optionalChain([o, 'optionalAccess', _19 => _19.className])),style:_optionalChain([o, 'optionalAccess', _20 => _20.style])}}var Z="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",St=`${Z} w-full`,Kt=`${St} no-underline`;function Vt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=_react.useState.call(void 0, "idle"),s=p("addToCartButton",St),i=p("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=_react.useCallback.call(void 0, async()=>{n("adding");try{await e(),n("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),n("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...s,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?_jsxruntime.jsx.call(void 0, "p",{...i,role:"alert",children:r.addToCartError}):null]})}function qt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:s,locale:i}=j(),d=_react.useContext.call(void 0, Ct),c=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=_react.useCallback.call(void 0, ()=>d.clicked(t,e),[d,t,e]),u=p("card","relative flex flex-col overflow-hidden border transition-colors"),b=p("cardLink","flex flex-1 flex-col no-underline"),v=p("image","aspect-square w-full overflow-hidden"),f=p("imagePlaceholder","aspect-square w-full"),l=p("body","flex flex-1 flex-col gap-1 p-4"),g=p("name","text-base font-medium leading-snug"),P=p("description","line-clamp-2 text-sm"),h=p("price","mt-auto pt-2 text-base font-semibold"),k=p("comparePrice","ml-2 text-sm font-normal"),C=p("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=p("actions","p-4 pt-0"),I=p("selectButton",Kt),A=H(t.price,t.currency,i),y=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(n!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:s,locale:i,addToCart:o,trackClick:m})});let x=_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.image, 'optionalAccess', _22 => _22.thumbnailUrl]), () => (_optionalChain([t, 'access', _23 => _23.image, 'optionalAccess', _24 => _24.url]))),E=t.available?t.isRecurring?s.subscription:null:s.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...b,href:r,onClick:m,children:[x!=null?_jsxruntime.jsx.call(void 0, "div",{...v,children:_jsxruntime.jsx.call(void 0, "img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...f,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...l,children:[_jsxruntime.jsx.call(void 0, "h3",{...g,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...P,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...h,children:[t.priceFrom?X(s.priceFrom,{price:A}):A,y!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[s.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:y})]}):null]})]})]}),E!=null?_jsxruntime.jsx.call(void 0, "span",{...C,"data-kind":t.available?"subscription":"unavailable",children:E}):null,_jsxruntime.jsx.call(void 0, "div",{...T,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Vt,{product:t,onAdd:o}):_jsxruntime.jsx.call(void 0, "a",{...I,href:r,onClick:m,children:t.variantCount>1?s.chooseOptions:s.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...I,disabled:!0,children:s.unavailable})})]})}var At="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Gt({count:t,label:e}){let r=p("grid",At),o=p("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,s)=>_jsxruntime.jsx.call(void 0, "div",{...o,"aria-hidden":"true"},s))})}function Qt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),s=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...s,"aria-label":n.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Xt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:s}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=_chunkDF2IK2GNjs.m.call(void 0, ),l=_optionalChain([t, 'access', _25 => _25.search, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()])?"search":"catalog",g=O(t.pageSize),P=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{P.current||u||b!=null||(P.current=!0,f.track("product_list_viewed",{list_id:l,item_count:i.length}))},[f,u,b,l,i.length]);let h=_react.useMemo.call(void 0, ()=>Lt(({productIds:L,positions:w})=>f.track("product_impression",{list_id:l,product_ids:L,positions:w})),[f,l]);_react.useEffect.call(void 0, ()=>()=>h.destroy(),[h]);let k=_react.useMemo.call(void 0, ()=>({observe:h.observe,clicked:(L,w)=>f.track("product_clicked",{list_id:l,position:w},{product_id:L.id})}),[h,f,l]),C=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, !1),I=_react.useCallback.call(void 0, L=>{T.current=!0,m(L)},[m]);_react.useEffect.call(void 0, ()=>{u||!T.current||(T.current=!1,_optionalChain([C, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30({preventScroll:!0})]),_optionalChain([C, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.scrollIntoView, 'call', _33 => _33({block:"start"})]))},[u]);let A=p("grid",At),y=p("emptyState","py-12 text-center text-sm"),x=p("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=p("retryButton",Z),{projectID:J,host:W}=t,It=_react.useCallback.call(void 0, (L,w)=>async()=>{if(o!=null){await _chunkDF2IK2GNjs.p.call(void 0, ()=>o(L)),Q(f,L);return}await yt(L,{projectID:J,host:W,showCart:n,analytics:f,url:w})},[o,J,W,n,f]),_;return u&&i.length===0?_=_jsxruntime.jsx.call(void 0, Gt,{count:Math.min(O(t.pageSize),8),label:s.loading}):b!=null?_=_jsxruntime.jsxs.call(void 0, "div",{...x,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:s.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...E,onClick:v,children:s.retry})]}):i.length===0?_=_jsxruntime.jsx.call(void 0, "p",{...y,children:s.empty}):_=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":u||void 0,className:_chunkERL4Z7M7js.d.call(void 0, A.className,u&&"opacity-60"),children:i.map((L,w)=>{let Y=e(L);return _jsxruntime.jsx.call(void 0, qt,{product:L,position:(d-1)*g+w,href:Y,onAdd:It(L,Y),renderItem:r},L.id)})}),_jsxruntime.jsx.call(void 0, Ct.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[_,c>1&&b==null?_jsxruntime.jsx.call(void 0, Qt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Zt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Jt({productHref:t=Zt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:s=!0,className:i,analytics:d,...c}){let m=_chunkDF2IK2GNjs.n.call(void 0, c.projectID,d,"catalog"),u=_nullishCoalesce(c.locale, () => (_chunkERL4Z7M7js.k)),b=_react.useMemo.call(void 0, ()=>pt(e),[e]),v=_react.useMemo.call(void 0, ()=>ht(u,r),[u,r]),f=_react.useMemo.call(void 0, ()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return _jsxruntime.jsx.call(void 0, _chunkDF2IK2GNjs.l,{value:m,children:_jsxruntime.jsx.call(void 0, vt.Provider,{value:f,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunkERL4Z7M7js.d.call(void 0, "bitsnap-react",b.boundaryClassName,i,_optionalChain([l, 'optionalAccess', _34 => _34.className])),style:{...b.boundaryStyle,..._optionalChain([l, 'optionalAccess', _35 => _35.style])},children:_jsxruntime.jsx.call(void 0, Xt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:s})})})})}exports.a = wt; exports.b = H; exports.c = G; exports.d = Jt;
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunk4BV5IUZHjs = require('./chunk-4BV5IUZH.js');var _chunkHDLCLZOKjs = require('./chunk-HDLCLZOK.js');var wt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Et={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},_t={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},Dt=[];function pt(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:_t,variables:Et,shadcnVariables:Dt});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return _chunkKOYBZORLjs.b.call(void 0, t.elements,e)}function mt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function H(t,e,r=_chunk4BV5IUZHjs.k){let o=t/100,n=_nullishCoalesce(mt(r,e), () => (mt(_chunk4BV5IUZHjs.k,e)));return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}var _react = require('react');var Ot=24,Nt=48,M=class extends Error{constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Ot:Math.min(Nt,Math.max(1,Math.floor(t)))}function ft(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Rt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=_optionalChain([t, 'access', _2 => _2.search, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Bt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function gt(t,e){let r=await fetch(_chunk4BV5IUZHjs.c.call(void 0, Rt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new M(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Bt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[s]=_react.useState.call(void 0, ()=>_chunk4BV5IUZHjs.f),i=_nullishCoalesce(t.host, () => (s)),d=O(t.pageSize),c=JSON.stringify([e,i,_nullishCoalesce(r, () => (null)),_nullishCoalesce(_optionalChain([o, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => (null)),d]),[m,u]=_react.useState.call(void 0, {queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=_react.useState.call(void 0, 0),[f,l]=_react.useState.call(void 0, ()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=_nullishCoalesce(_optionalChain([f, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.totalCount]), () => (0)),P=ft(g,d),h=m.queryKey===c?m.page:1,k=g>0?Math.min(h,P):h,C=`${c}|${k}|${b}`,T=f.requestKey===C;_react.useEffect.call(void 0, ()=>{if(T)return;let y=new AbortController;return gt({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(x=>{y.signal.aborted||l({requestKey:C,data:x,error:void 0})},x=>{y.signal.aborted||l(E=>({requestKey:C,data:E.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=_react.useCallback.call(void 0, y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=_react.useCallback.call(void 0, ()=>v(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([f, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.items]), () => ([])),totalCount:g,page:k,pageCount:P,setPage:I,isLoading:!T,error:T?f.error:void 0,refetch:A}),[f,g,k,P,I,T,A])}function bt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?N(e.host):"",n=N(t.host);if(o&&o!==n){if(n!==N(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function yt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./methods-ISVX5JQ7.js"))),Promise.resolve().then(() => _interopRequireWildcard(require("./CartProvider-YPZ3HD7W.js")))]),s=bt({projectID:o(),host:_chunk4BV5IUZHjs.f,defaultHost:_chunk4BV5IUZHjs.e},e);if(!s.ok)return Ut(s.reason);if(s.setProjectID!=null&&n(s.setProjectID),s.setHost!=null&&_chunk4BV5IUZHjs.g.call(void 0, s.setHost),await r.addProductToCart(_nullishCoalesce(t.cartItemId, () => (t.id)),1,void 0,{url:e.url,name:t.name,price:t.price,currency:t.currency,analytics:_chunkHDLCLZOKjs.k})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ut(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var $=50,Ht=1e3;function Lt(t,e=Ht){let r=new Set,o=new Map,n=[],s=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=s.slice(0,$);n=n.slice($),s=s.slice($);try{t({productIds:l,positions:g})}catch (e3){}}}function u(){m();try{_optionalChain([_chunkHDLCLZOKjs.f.call(void 0, ), 'optionalAccess', _11 => _11.flush, 'call', _12 => _12()])}catch (e4){}}let b=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};function v(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",u,!0),document.addEventListener("visibilitychange",b,!0))}function f(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(l=>{for(let g of l){let P=o.get(g.target);!P||!g.isIntersecting||g.intersectionRatio<.5||(o.delete(g.target),_optionalChain([i, 'optionalAccess', _13 => _13.unobserve, 'call', _14 => _14(g.target)]),!r.has(P.id)&&(r.add(P.id),n.push(P.id),s.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),_optionalChain([d, 'access', _15 => _15.unref, 'optionalCall', _16 => _16()]))},{threshold:[.5]}),v(),i}return{observe(l,g,P){try{if(r.has(g))return()=>{};let h=f();return h?(o.set(l,{id:g,position:P}),h.observe(l),()=>{o.delete(l),h.unobserve(l)}):()=>{}}catch (e5){return()=>{}}},flush:m,destroy(){try{m(),_optionalChain([i, 'optionalAccess', _17 => _17.disconnect, 'call', _18 => _18()]),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch (e6){}i=void 0,o.clear()}}}var Mt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function ht(t,e){return _chunk4BV5IUZHjs.i.call(void 0, Mt,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}var _jsxruntime = require('react/jsx-runtime');var vt=_react.createContext.call(void 0, void 0),$t={observe:()=>()=>{},clicked:()=>{}},Ct=_react.createContext.call(void 0, $t);function j(){let t=_react.useContext.call(void 0, vt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function p(t,e){let{appearance:r}=j(),o=q(r,t);return{"data-bitsnap-products-slot":t,className:_chunk4BV5IUZHjs.d.call(void 0, e,_optionalChain([o, 'optionalAccess', _19 => _19.className])),style:_optionalChain([o, 'optionalAccess', _20 => _20.style])}}var Z="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",St=`${Z} w-full`,Kt=`${St} no-underline`;function Vt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=_react.useState.call(void 0, "idle"),s=p("addToCartButton",St),i=p("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=_react.useCallback.call(void 0, async()=>{n("adding");try{await e(),n("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),n("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...s,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?_jsxruntime.jsx.call(void 0, "p",{...i,role:"alert",children:r.addToCartError}):null]})}function qt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:s,locale:i}=j(),d=_react.useContext.call(void 0, Ct),c=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=_react.useCallback.call(void 0, ()=>d.clicked(t,e),[d,t,e]),u=p("card","relative flex flex-col overflow-hidden border transition-colors"),b=p("cardLink","flex flex-1 flex-col no-underline"),v=p("image","aspect-square w-full overflow-hidden"),f=p("imagePlaceholder","aspect-square w-full"),l=p("body","flex flex-1 flex-col gap-1 p-4"),g=p("name","text-base font-medium leading-snug"),P=p("description","line-clamp-2 text-sm"),h=p("price","mt-auto pt-2 text-base font-semibold"),k=p("comparePrice","ml-2 text-sm font-normal"),C=p("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=p("actions","p-4 pt-0"),I=p("selectButton",Kt),A=H(t.price,t.currency,i),y=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(n!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:s,locale:i,addToCart:o,trackClick:m})});let x=_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.image, 'optionalAccess', _22 => _22.thumbnailUrl]), () => (_optionalChain([t, 'access', _23 => _23.image, 'optionalAccess', _24 => _24.url]))),E=t.available?t.isRecurring?s.subscription:null:s.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...b,href:r,onClick:m,children:[x!=null?_jsxruntime.jsx.call(void 0, "div",{...v,children:_jsxruntime.jsx.call(void 0, "img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...f,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...l,children:[_jsxruntime.jsx.call(void 0, "h3",{...g,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...P,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...h,children:[t.priceFrom?X(s.priceFrom,{price:A}):A,y!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[s.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:y})]}):null]})]})]}),E!=null?_jsxruntime.jsx.call(void 0, "span",{...C,"data-kind":t.available?"subscription":"unavailable",children:E}):null,_jsxruntime.jsx.call(void 0, "div",{...T,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Vt,{product:t,onAdd:o}):_jsxruntime.jsx.call(void 0, "a",{...I,href:r,onClick:m,children:t.variantCount>1?s.chooseOptions:s.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...I,disabled:!0,children:s.unavailable})})]})}var At="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Gt({count:t,label:e}){let r=p("grid",At),o=p("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,s)=>_jsxruntime.jsx.call(void 0, "div",{...o,"aria-hidden":"true"},s))})}function Qt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),s=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...s,"aria-label":n.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Xt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:s}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=_chunkHDLCLZOKjs.m.call(void 0, ),l=_optionalChain([t, 'access', _25 => _25.search, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()])?"search":"catalog",g=O(t.pageSize),P=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{P.current||u||b!=null||(P.current=!0,f.track("product_list_viewed",{list_id:l,item_count:i.length}))},[f,u,b,l,i.length]);let h=_react.useMemo.call(void 0, ()=>Lt(({productIds:L,positions:w})=>f.track("product_impression",{list_id:l,product_ids:L,positions:w})),[f,l]);_react.useEffect.call(void 0, ()=>()=>h.destroy(),[h]);let k=_react.useMemo.call(void 0, ()=>({observe:h.observe,clicked:(L,w)=>f.track("product_clicked",{list_id:l,position:w},{product_id:L.id})}),[h,f,l]),C=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, !1),I=_react.useCallback.call(void 0, L=>{T.current=!0,m(L)},[m]);_react.useEffect.call(void 0, ()=>{u||!T.current||(T.current=!1,_optionalChain([C, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30({preventScroll:!0})]),_optionalChain([C, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.scrollIntoView, 'call', _33 => _33({block:"start"})]))},[u]);let A=p("grid",At),y=p("emptyState","py-12 text-center text-sm"),x=p("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=p("retryButton",Z),{projectID:J,host:W}=t,It=_react.useCallback.call(void 0, (L,w)=>async()=>{if(o!=null){await _chunkHDLCLZOKjs.p.call(void 0, ()=>o(L)),Q(f,L);return}await yt(L,{projectID:J,host:W,showCart:n,analytics:f,url:w})},[o,J,W,n,f]),_;return u&&i.length===0?_=_jsxruntime.jsx.call(void 0, Gt,{count:Math.min(O(t.pageSize),8),label:s.loading}):b!=null?_=_jsxruntime.jsxs.call(void 0, "div",{...x,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:s.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...E,onClick:v,children:s.retry})]}):i.length===0?_=_jsxruntime.jsx.call(void 0, "p",{...y,children:s.empty}):_=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":u||void 0,className:_chunk4BV5IUZHjs.d.call(void 0, A.className,u&&"opacity-60"),children:i.map((L,w)=>{let Y=e(L);return _jsxruntime.jsx.call(void 0, qt,{product:L,position:(d-1)*g+w,href:Y,onAdd:It(L,Y),renderItem:r},L.id)})}),_jsxruntime.jsx.call(void 0, Ct.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[_,c>1&&b==null?_jsxruntime.jsx.call(void 0, Qt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Zt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Jt({productHref:t=Zt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:s=!0,className:i,analytics:d,...c}){let m=_chunkHDLCLZOKjs.n.call(void 0, c.projectID,d,"catalog"),u=_nullishCoalesce(c.locale, () => (_chunk4BV5IUZHjs.k)),b=_react.useMemo.call(void 0, ()=>pt(e),[e]),v=_react.useMemo.call(void 0, ()=>ht(u,r),[u,r]),f=_react.useMemo.call(void 0, ()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return _jsxruntime.jsx.call(void 0, _chunkHDLCLZOKjs.l,{value:m,children:_jsxruntime.jsx.call(void 0, vt.Provider,{value:f,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunk4BV5IUZHjs.d.call(void 0, "bitsnap-react",b.boundaryClassName,i,_optionalChain([l, 'optionalAccess', _34 => _34.className])),style:{...b.boundaryStyle,..._optionalChain([l, 'optionalAccess', _35 => _35.style])},children:_jsxruntime.jsx.call(void 0, Xt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:s})})})})}exports.a = wt; exports.b = H; exports.c = G; exports.d = Jt;
|
|
2
|
+
//# sourceMappingURL=chunk-3ITTSNWG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-3ITTSNWG.js","../src/components/products/appearance.ts","../src/components/products/format.ts"],"names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","createFormatter","locale","currency","formatProductPrice","amount","DEFAULT_LOCALE","value","formatter"],"mappings":"AAAA,y/BAAgD,sDAAsF,sDAAiF,IC2D1MA,EAAAA,CAA0B,CACrC,MAAA,CACA,MAAA,CACA,MAAA,CACA,UAAA,CACA,OAAA,CACA,kBAAA,CACA,MAAA,CACA,MAAA,CACA,aAAA,CACA,OAAA,CACA,cAAA,CACA,OAAA,CACA,SAAA,CACA,iBAAA,CACA,cAAA,CACA,SAAA,CACA,YAAA,CACA,kBAAA,CACA,eAAA,CACA,YAAA,CACA,OAAA,CACA,aAAA,CACA,UACF,CAAA,CA8BaC,EAAAA,CAA+B,CAC1C,UAAA,CAAY,gCAAA,CACZ,QAAA,CAAU,8BAAA,CACV,UAAA,CAAY,+BAAA,CACZ,OAAA,CAAS,4BAAA,CACT,UAAA,CAAY,+BAAA,CACZ,eAAA,CAAiB,qCAAA,CACjB,MAAA,CAAQ,2BAAA,CACR,gBAAA,CAAkB,sCAAA,CAClB,gBAAA,CAAkB,sCAAA,CAClB,qBAAA,CAAuB,4CAAA,CACvB,YAAA,CAAc,kCAAA,CACd,SAAA,CAAW,+BAAA,CACX,KAAA,CAAO,0BAAA,CACP,eAAA,CAAiB,qCAAA,CACjB,eAAA,CAAiB,qCAAA,CACjB,MAAA,CAAQ,2BACV,CAAA,CASaC,EAAAA,CAGT,CACF,KAAA,CAAO,CACL,UAAA,CAAY,SAAA,CACZ,OAAA,CAAS,SAAA,CACT,UAAA,CAAY,SAAA,CACZ,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,SAAA,CACR,gBAAA,CAAkB,SAAA,CAClB,gBAAA,CAAkB,SAAA,CAClB,qBAAA,CAAuB,SAAA,CACvB,YAAA,CAAc,SAAA,CACd,SAAA,CAAW,SAAA,CACX,KAAA,CAAO,SAAA,CACP,eAAA,CAAiB,SAAA,CACjB,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,KACV,CAAA,CACA,IAAA,CAAM,CACJ,UAAA,CAAY,SAAA,CACZ,OAAA,CAAS,SAAA,CACT,UAAA,CAAY,SAAA,CACZ,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,SAAA,CACR,gBAAA,CAAkB,SAAA,CAClB,gBAAA,CAAkB,SAAA,CAClB,qBAAA,CAAuB,SAAA,CACvB,YAAA,CAAc,SAAA,CACd,SAAA,CAAW,SAAA,CACX,KAAA,CAAO,SAAA,CACP,eAAA,CAAiB,SAAA,CACjB,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,KACV,CACF,CAAA,CAGMC,EAAAA,CACJ,CAAC,CAAA,CAEI,SAASC,EAAAA,CACdC,CAAAA,CAC+B,CAC/B,IAAMC,CAAAA,CAAWC,gCAAAA,CAIfF,CAAY,CACZ,YAAA,CAAc,OAAA,CACd,OAAA,CAASH,EAAAA,CACT,SAAA,CAAWD,EAAAA,CACX,eAAA,CAAiBE,EACnB,CAAC,CAAA,CAED,MAAO,CACL,KAAA,CAAOG,CAAAA,CAAS,KAAA,CAChB,MAAA,CAAQA,CAAAA,CAAS,MAAA,CACjB,QAAA,CAAUA,CAAAA,CAAS,QAAA,CACnB,iBAAA,CAAmBA,CAAAA,CAAS,KAAA,CAC5B,aAAA,CAAeA,CAAAA,CAAS,aAC1B,CACF,CAGO,SAASE,CAAAA,CACdF,CAAAA,CACAG,CAAAA,CACuC,CACvC,OAAOC,gCAAAA,CAAkBJ,CAAS,QAAA,CAAUG,CAAI,CAClD,CChNA,SAASE,EAAAA,CACPC,CAAAA,CACAC,CAAAA,CAC+B,CAC/B,GAAI,CACF,OAAO,IAAI,IAAA,CAAK,YAAA,CAAaD,CAAAA,CAAQ,CACnC,KAAA,CAAO,UAAA,CACP,QAAA,CAAAC,CAAAA,CACA,eAAA,CAAiB,QACnB,CAAC,CACH,CAAA,UAAQ,CAEN,MACF,CACF,CAOO,SAASC,CAAAA,CACdC,CAAAA,CACAF,CAAAA,CACAD,CAAAA,CAAiBI,kBAAAA,CACT,CACR,IAAMC,CAAAA,CAAQF,CAAAA,CAAS,GAAA,CACjBG,CAAAA,kBACJP,EAAAA,CAAgBC,CAAAA,CAAQC,CAAQ,CAAA,SAChCF,EAAAA,CAAgBK,kBAAAA,CAAgBH,CAAQ,GAAA,CAE1C,OAAOK,CAAAA,EAAa,IAAA,CAChBA,CAAAA,CAAU,MAAA,CAAOD,CAAK,CAAA,CACtB,CAAA,EAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-3ITTSNWG.js","sourcesContent":[null,"import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { DEFAULT_LOCALE } from \"../checkout/locale\";\n\nfunction createFormatter(\n locale: string,\n currency: string,\n): Intl.NumberFormat | undefined {\n try {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n currencyDisplay: \"symbol\",\n });\n } catch {\n // RangeError: invalid locale or currency code.\n return undefined;\n }\n}\n\n/**\n * Formats a price in minor units (grosze, cents) for the locale, the same way\n * the cart does (`amount / 100`). An unknown locale falls back to Polish and an\n * invalid currency code to a plain number followed by the code.\n */\nexport function formatProductPrice(\n amount: number,\n currency: string,\n locale: string = DEFAULT_LOCALE,\n): string {\n const value = amount / 100;\n const formatter =\n createFormatter(locale, currency) ??\n createFormatter(DEFAULT_LOCALE, currency);\n\n return formatter != null\n ? formatter.format(value)\n : `${value.toFixed(2)} ${currency}`;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkHDLCLZOKjs = require('./chunk-HDLCLZOK.js');var u="X-Bitsnap-Client",i=`bitsnap-react@${_chunkHDLCLZOKjs.a}`,d="bs_client",z= exports.a ={[u]:i},b= exports.b =e=>t=>(t.header.set(u,i),e(t));function j(e){let t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t),a=n.includes("?")?/[?&]$/.test(n)?"":"&":"?";return`${n}${a}${d}=${encodeURIComponent(i)}${r}`}var g="https://bitsnap.pl",m= exports.f =g;function K(e){console.log("setCustomHost",e),m= exports.f =e}function h(e,t){return t.toLowerCase().startsWith("en")?e.en:e.pl}function k(e,t){let n={...e};if(t!=null)for(let[r,a]of Object.entries(t))a!=null&&(n[r]=a);return n}function l(e,t,n){return k(h(e,t),n)}function y(e,t){return _nullishCoalesce(e[t], () => (t))}var T={en:{cart:"Cart",emptyCart:"Your cart is empty.",total:"Total:",delivery:"+ delivery",chooseCountry:"Choose a country",nextStep:"Next step",unavailableProducts:"Not all products are available.",checkoutFailed:"Something went wrong. Please try again later.",noPaymentGateway:"This shop doesn't accept online payments yet. Try again later or contact the seller.",gatewayNotConfigured:"Payments in this shop are not set up correctly. Try again later or contact the seller.",shippingNotConfigured:"Delivery in this shop is not configured yet. Try again later or contact the seller.",mixedRecurring:"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.",currencyUnsupported:"The shop doesn't accept payments in this currency. Contact the seller.",priceChanged:"The product price has changed. Refresh the page to see the current price.",close:"Close cart",remove:"Remove",quantity:"Quantity",increaseQuantity:"Increase quantity",decreaseQuantity:"Decrease quantity",openCart:"Open cart",cartItemsCount:"Items in cart",lowestPrice30Days:"Lowest price in the last 30 days:",noPriceHistory:"No price data for the last 30 days",redirectFailed:"Could not redirect to the payment. Please try again later.",subscriptionUnsupported:"Subscriptions cannot be added to the cart yet.",searchCountry:"Find a country",noCountriesFound:"No countries found",countryRequired:"Choose a country to continue.",paymentForCart:"Cart payment",coupon:"Coupon",extrasCalculatedNext:"Discounts, shipping and taxes are calculated at the next step",loadFailed:"Could not load your cart.",retry:"Try again",paymentMethodLegend:"How would you like to pay?",paymentMethodOnline:"Pay online",paymentMethodOnlineDescription:"Card, BLIK code or instant bank payment. You pay right away.",paymentMethodManualTransfer:"Bank transfer",paymentMethodManualBlik:"BLIK \u2013 transfer to a phone number",paymentMethodManualBoth:"Bank transfer or BLIK to a phone number",paymentMethodManualDescription:"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.",paymentMethodManualBlikNote:"This is not a BLIK code payment \u2013 you do not enter a 6\u2011digit code."},pl:{cart:"Koszyk",emptyCart:"Brak produkt\xF3w w koszyku.",total:"Suma:",delivery:"+ dostawa",chooseCountry:"Wybierz kraj",nextStep:"Nast\u0119pny krok",unavailableProducts:"Nie wszystkie produkty s\u0105 dost\u0119pne w magazynie.",checkoutFailed:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie p\xF3\u017Aniej.",noPaymentGateway:"Ten sklep nie przyjmuje jeszcze p\u0142atno\u015Bci online. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",gatewayNotConfigured:"P\u0142atno\u015Bci w tym sklepie nie s\u0105 poprawnie skonfigurowane. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",shippingNotConfigured:"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",mixedRecurring:"Subskrypcji i produkt\xF3w jednorazowych nie mo\u017Cna op\u0142aci\u0107 razem. Op\u0142a\u0107 je w osobnych zam\xF3wieniach.",currencyUnsupported:"Sklep nie przyjmuje p\u0142atno\u015Bci w tej walucie. Skontaktuj si\u0119 ze sprzedawc\u0105.",priceChanged:"Cena produktu si\u0119 zmieni\u0142a. Od\u015Bwie\u017C stron\u0119, aby zobaczy\u0107 aktualn\u0105 cen\u0119.",close:"Zamknij koszyk",remove:"Usu\u0144",quantity:"Ilo\u015B\u0107",increaseQuantity:"Zwi\u0119ksz ilo\u015B\u0107",decreaseQuantity:"Zmniejsz ilo\u015B\u0107",openCart:"Otw\xF3rz koszyk",cartItemsCount:"Produkt\xF3w w koszyku",lowestPrice30Days:"Najni\u017Csza cena z 30 dni:",noPriceHistory:"Brak danych o cenie z ostatnich 30 dni",redirectFailed:"Nie uda\u0142o si\u0119 przekierowa\u0107 do p\u0142atno\u015Bci. Spr\xF3buj ponownie p\xF3\u017Aniej.",subscriptionUnsupported:"Subskrypcji nie mo\u017Cna jeszcze doda\u0107 do koszyka.",searchCountry:"Znajd\u017A kraj",noCountriesFound:"Nie znaleziono kraj\xF3w",countryRequired:"Wybierz kraj, aby przej\u015B\u0107 dalej.",paymentForCart:"P\u0142atno\u015B\u0107 za koszyk",coupon:"Kupon",extrasCalculatedNext:"Rabaty, dostawa i podatki w nast\u0119pnym kroku",loadFailed:"Nie uda\u0142o si\u0119 wczyta\u0107 koszyka.",retry:"Spr\xF3buj ponownie",paymentMethodLegend:"Jak chcesz zap\u0142aci\u0107?",paymentMethodOnline:"Zap\u0142a\u0107 online",paymentMethodOnlineDescription:"Karta, kod BLIK lub szybki przelew. P\u0142acisz od razu.",paymentMethodManualTransfer:"Przelew bankowy",paymentMethodManualBlik:"BLIK \u2013 przelew na telefon",paymentMethodManualBoth:"Przelew lub BLIK na telefon",paymentMethodManualDescription:"Zap\u0142acisz w aplikacji swojego banku. Dane do p\u0142atno\u015Bci poka\u017Cemy po z\u0142o\u017Ceniu zam\xF3wienia, a zam\xF3wienie poczeka na Twoj\u0105 wp\u0142at\u0119.",paymentMethodManualBlikNote:"To nie jest p\u0142atno\u015B\u0107 kodem BLIK \u2013 nie wpisujesz 6\u2011cyfrowego kodu."}};function x(e,t){return l(T,e,t)}function N(e,t,n){return y(x(t,n),e)}var s="pl-PL",p="bitsnap-locale",o;function B(e){let t=_optionalChain([e, 'optionalAccess', _ => _.trim, 'call', _2 => _2()]);o=t?t.toLowerCase()==="en"?"en-US":t.toLowerCase()==="pl"?s:t:void 0,typeof localStorage<"u"&&(o==null?localStorage.removeItem(p):localStorage.setItem(p,o))}function R(){return _nullishCoalesce(o, () => ((typeof localStorage<"u"?_nullishCoalesce(localStorage.getItem(p), () => (s)):s)))}var _clsx = require('clsx');var _tailwindmerge = require('tailwind-merge');function O(...e){return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, e))}exports.a = z; exports.b = b; exports.c = j; exports.d = O; exports.e = g; exports.f = m; exports.g = K; exports.h = h; exports.i = l; exports.j = N; exports.k = s; exports.l = B; exports.m = R;
|
|
2
|
+
//# sourceMappingURL=chunk-4BV5IUZH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-4BV5IUZH.js","../src/lib/client-header.ts"],"names":["CLIENT_HEADER_NAME","CLIENT_HEADER_VALUE","SDK_VERSION"],"mappings":"AAAA,uuBAAuC,ICG1BA,CAAAA,CAAqB,kBAAA,CACrBC,CAAAA,CAAsB,CAAA,cAAA,EAAiBC,kBAAW,CAAA,CAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-4BV5IUZH.js","sourcesContent":[null,"import type { Interceptor } from \"@connectrpc/connect\";\nimport { SDK_VERSION } from \"../version\";\n\nexport const CLIENT_HEADER_NAME = \"X-Bitsnap-Client\";\nexport const CLIENT_HEADER_VALUE = `bitsnap-react@${SDK_VERSION}`;\n\nexport const CLIENT_QUERY_PARAM = \"bs_client\";\n\n/**\n * Spread into the `headers` of a fetch that already triggers a CORS preflight\n * (JSON POST, Connect RPC). Never use it on a simple cross-origin GET: the\n * custom header would force a preflight that older servers and merchant\n * proxies do not allow. Use `withClientParam` there.\n */\nexport const clientHeaders: Record<string, string> = {\n [CLIENT_HEADER_NAME]: CLIENT_HEADER_VALUE,\n};\n\n/** Connect interceptor adding the client header to every RPC. */\nexport const clientHeaderInterceptor: Interceptor = (next) => (req) => {\n req.header.set(CLIENT_HEADER_NAME, CLIENT_HEADER_VALUE);\n return next(req);\n};\n\n/** Adds `bs_client=<pkg>@<ver>` to a URL, for simple GETs that must stay preflight-free. */\nexport function withClientParam(url: string): string {\n const hash = url.indexOf(\"#\");\n const base = hash === -1 ? url : url.slice(0, hash);\n const fragment = hash === -1 ? \"\" : url.slice(hash);\n const separator = base.includes(\"?\") ? (/[?&]$/.test(base) ? \"\" : \"&\") : \"?\";\n return `${base}${separator}${CLIENT_QUERY_PARAM}=${encodeURIComponent(CLIENT_HEADER_VALUE)}${fragment}`;\n}\n"]}
|