bitsnap-react 1.21.0 → 1.21.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/dist/BitsnapCart-3RSI3PIM.mjs +2 -0
- package/dist/BitsnapCart-4DKJ7OXL.js +2 -0
- package/dist/BitsnapCart-4DKJ7OXL.js.map +1 -0
- package/dist/{CartProvider-4WXJPQJB.mjs → CartProvider-TXRCAXOT.mjs} +2 -2
- package/dist/CartProvider-ZAGTSCHJ.js +2 -0
- package/dist/CartProvider-ZAGTSCHJ.js.map +1 -0
- package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/chat.mjs +1 -1
- package/dist/{chunk-WOA6W5RM.mjs → chunk-2HINORSP.mjs} +2 -2
- package/dist/{chunk-EFN4OW2C.js → chunk-3TUL63IC.js} +2 -2
- package/dist/chunk-3TUL63IC.js.map +1 -0
- package/dist/chunk-56X4DBMQ.mjs +5 -0
- package/dist/chunk-56X4DBMQ.mjs.map +1 -0
- package/dist/chunk-6DEKVABT.js.map +1 -1
- package/dist/chunk-6Q3VGPSF.js.map +1 -1
- package/dist/{chunk-LRUBBPTV.mjs → chunk-7WTQGXPQ.mjs} +2 -2
- package/dist/chunk-EK3D44XW.js.map +1 -1
- package/dist/{chunk-27JN2GIQ.mjs → chunk-FG7NLLJV.mjs} +2 -2
- package/dist/{chunk-EZGL6DPG.js → chunk-FPCMLZFM.js} +2 -2
- package/dist/chunk-FPCMLZFM.js.map +1 -0
- package/dist/{chunk-2G46TAUX.mjs → chunk-GLKBCVNH.mjs} +2 -2
- package/dist/{chunk-2G46TAUX.mjs.map → chunk-GLKBCVNH.mjs.map} +1 -1
- package/dist/{chunk-E5MMKBC4.js → chunk-J4GUVJP4.js} +2 -2
- package/dist/chunk-J4GUVJP4.js.map +1 -0
- package/dist/{chunk-IKKMSLKC.js → chunk-J6YI6FJN.js} +2 -2
- package/dist/chunk-J6YI6FJN.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/{chunk-FORZ5AH4.js → chunk-K2HIALKR.js} +2 -2
- package/dist/chunk-K2HIALKR.js.map +1 -0
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/chunk-MDAFPGPA.js.map +1 -1
- package/dist/{chunk-I2RHVELR.js → chunk-MMQTRSI5.js} +2 -2
- package/dist/chunk-MMQTRSI5.js.map +1 -0
- package/dist/{chunk-KYSMT6ZK.js → chunk-NW5PFIZB.js} +2 -2
- package/dist/chunk-NW5PFIZB.js.map +1 -0
- package/dist/{chunk-TM3E3L57.js → chunk-OCJ7YWFX.js} +2 -2
- package/dist/chunk-OCJ7YWFX.js.map +1 -0
- package/dist/chunk-Q337IQNA.js.map +1 -1
- package/dist/{chunk-6ALA5M44.mjs → chunk-QWQPAN4F.mjs} +2 -2
- package/dist/{chunk-HLULQA3B.mjs → chunk-QXCL5CE6.mjs} +2 -2
- package/dist/chunk-TWZQ4CBY.js +5 -0
- package/dist/chunk-TWZQ4CBY.js.map +1 -0
- package/dist/{chunk-KO7Z3E23.mjs → chunk-VU2MX5HY.mjs} +2 -2
- package/dist/chunk-W3RGQYPD.js.map +1 -1
- package/dist/{chunk-TMEII7BM.mjs → chunk-YV3UGLQ3.mjs} +2 -2
- package/dist/chunk-Z3YOJ6NZ.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/errors.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-27HZQY5L.js +2 -0
- package/dist/methods-27HZQY5L.js.map +1 -0
- package/dist/{methods-43RQLLWD.mjs → methods-27JU6IH7.mjs} +2 -2
- package/dist/model-files-client-P4PORZJ6.js.map +1 -1
- 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/dist/viewer3d.js.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/package.json +1 -1
- package/dist/BitsnapCart-73ESTTTH.mjs +0 -2
- package/dist/BitsnapCart-TWT7LVGJ.js +0 -2
- package/dist/BitsnapCart-TWT7LVGJ.js.map +0 -1
- package/dist/CartProvider-CPF2E7JA.js +0 -2
- package/dist/CartProvider-CPF2E7JA.js.map +0 -1
- package/dist/chunk-E5MMKBC4.js.map +0 -1
- package/dist/chunk-EFN4OW2C.js.map +0 -1
- package/dist/chunk-EZGL6DPG.js.map +0 -1
- package/dist/chunk-FORZ5AH4.js.map +0 -1
- package/dist/chunk-I2RHVELR.js.map +0 -1
- package/dist/chunk-IKKMSLKC.js.map +0 -1
- package/dist/chunk-KYSMT6ZK.js.map +0 -1
- package/dist/chunk-T5JO4SP7.mjs +0 -5
- package/dist/chunk-T5JO4SP7.mjs.map +0 -1
- package/dist/chunk-TM3E3L57.js.map +0 -1
- package/dist/chunk-XMRGA5AN.js +0 -5
- package/dist/chunk-XMRGA5AN.js.map +0 -1
- package/dist/methods-SZVF3HMF.js +0 -2
- package/dist/methods-SZVF3HMF.js.map +0 -1
- /package/dist/{BitsnapCart-73ESTTTH.mjs.map → BitsnapCart-3RSI3PIM.mjs.map} +0 -0
- /package/dist/{CartProvider-4WXJPQJB.mjs.map → CartProvider-TXRCAXOT.mjs.map} +0 -0
- /package/dist/{chunk-WOA6W5RM.mjs.map → chunk-2HINORSP.mjs.map} +0 -0
- /package/dist/{chunk-LRUBBPTV.mjs.map → chunk-7WTQGXPQ.mjs.map} +0 -0
- /package/dist/{chunk-27JN2GIQ.mjs.map → chunk-FG7NLLJV.mjs.map} +0 -0
- /package/dist/{chunk-6ALA5M44.mjs.map → chunk-QWQPAN4F.mjs.map} +0 -0
- /package/dist/{chunk-HLULQA3B.mjs.map → chunk-QXCL5CE6.mjs.map} +0 -0
- /package/dist/{chunk-KO7Z3E23.mjs.map → chunk-VU2MX5HY.mjs.map} +0 -0
- /package/dist/{chunk-TMEII7BM.mjs.map → chunk-YV3UGLQ3.mjs.map} +0 -0
- /package/dist/{methods-43RQLLWD.mjs.map → methods-27JU6IH7.mjs.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK2HIALKRjs = require('./chunk-K2HIALKR.js');var _chunk6DEKVABTjs = require('./chunk-6DEKVABT.js');var M=["orders","order","confirmation","result","myReturns","myReturn"];function k(e){return M.includes(e)}function L(e){return e?{name:"orders"}:{name:"email"}}function U(e,s){switch(s.type){case"SESSION_EXPIRED":return k(e.name)?{name:"email"}:e;case"CODE_SENT":return e.name==="email"?{name:"code"}:e;case"AUTHENTICATED":return e.name==="email"||e.name==="code"?{name:"orders"}:e;case"SELECT_ORDER":return e.name==="orders"?{name:"order",orderId:s.orderId}:e;case"REVIEW":return e.name==="order"?{name:"confirmation",orderId:e.orderId,items:s.items,note:s.note}:e;case"SUBMITTED":return e.name==="confirmation"?{name:"result",returnId:s.returnId}:e;case"OPEN_MY_RETURNS":return e.name==="orders"||e.name==="result"?{name:"myReturns"}:e;case"SELECT_RETURN":return e.name==="myReturns"?{name:"myReturn",returnId:s.returnId}:e;case"CONTINUE":return e.name==="result"?{name:"orders"}:e;case"BACK":switch(e.name){case"code":return{name:"email"};case"order":case"myReturns":return{name:"orders"};case"confirmation":return{name:"order",orderId:e.orderId,items:e.items,note:e.note};case"myReturn":return{name:"myReturns"};default:return e}}}var K={email:1,code:2,orders:3,order:4,confirmation:5,result:6},B=6;function D(e){return K[e]}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function V({current:e}){let s=_chunkK2HIALKRjs.r.call(void 0, ),o=_chunkK2HIALKRjs.o.call(void 0, "stepIndicator");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"stepIndicator",className:_chunk6DEKVABTjs.g.call(void 0, "text-xs",o.className),style:o.style,children:s("stepIndicator",{current:e,total:B})})}function W({panelToken:e,logo:s}){let{status:o,challenge:a,projectID:x}=_chunkK2HIALKRjs.t.call(void 0, "BitsnapReturns"),A=_chunkK2HIALKRjs.s.call(void 0, ),[r,t]=_react.useReducer.call(void 0, U,L(!1));_react.useEffect.call(void 0, ()=>{o==="authenticated"?t({type:"AUTHENTICATED"}):o==="anonymous"&&t({type:"SESSION_EXPIRED"})},[o]);let i=_react.useRef.call(void 0, !1);if(_react.useEffect.call(void 0, ()=>{i.current||o==="hydrating"||(i.current=!0,o==="anonymous"&&a!=null&&t({type:"CODE_SENT"}))},[o,a]),o==="exchanging"||o==="hydrating"&&e)return _jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.C,{});let m=D(r.name),b=r.name==="email"||r.name==="code";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-4",children:[b&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.c,{projectId:x,locale:A,...s}),m!=null&&_jsxruntime.jsx.call(void 0, V,{current:m}),r.name==="email"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.D,{showLogo:!1,onSubmitted:()=>t({type:"CODE_SENT"})}),r.name==="code"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.E,{showLogo:!1,onVerified:()=>t({type:"AUTHENTICATED"}),onBack:()=>t({type:"BACK"})}),r.name==="orders"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.F,{showLogout:!e,onSelectOrder:u=>t({type:"SELECT_ORDER",orderId:u}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="order"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.G,{orderId:r.orderId,initialItems:r.items,initialNote:r.note,onBack:()=>t({type:"BACK"}),onContinue:({items:u,note:h})=>t({type:"REVIEW",items:u,note:h})}),r.name==="confirmation"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.H,{orderId:r.orderId,items:r.items,note:r.note,onBack:()=>t({type:"BACK"}),onSubmitted:u=>t({type:"SUBMITTED",returnId:u})}),r.name==="result"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.I,{returnId:r.returnId,onContinue:()=>t({type:"CONTINUE"}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="myReturns"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.J,{onSelectReturn:u=>t({type:"SELECT_RETURN",returnId:u}),onBack:()=>t({type:"BACK"})}),r.name==="myReturn"&&_jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.K,{returnId:r.returnId,onBack:()=>t({type:"BACK"})})]})}function re({showLogo:e,logoUrl:s,logoDarkUrl:o,...a}){return _jsxruntime.jsx.call(void 0, _chunkK2HIALKRjs.u,{...a,children:_jsxruntime.jsx.call(void 0, W,{panelToken:a.panelAccessToken!=null&&a.panelAccessToken!=="",logo:{showLogo:e,logoUrl:s,logoDarkUrl:o}})})}exports.a = re;
|
|
2
|
+
//# sourceMappingURL=chunk-J4GUVJP4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react-panel-key/dist/chunk-J4GUVJP4.js","../src/components/returns/state-machine.ts","../src/components/returns/BitsnapReturns.tsx"],"names":["STEPS_WITH_SESSION","stepRequiresSession","step","initialReturnsStep","hasSession","reduceReturnsStep","event","STEP_NUMBERS","RETURNS_STEP_COUNT","returnsStepNumber","StepIndicator","current","text","useReturnsText","slot","useReturnsSlot","jsx","cn","ReturnsRouter","panelToken","logo","status","challenge","projectID","useReturnsContext","locale","useReturnsLocale","dispatch","useReducer","useEffect","restored","useRef","SkeletonRows","stepNumber","loginStep","jsxs","LoginBrandLogo","ReturnsEmailStep","ReturnsCodeStep","ReturnsOrderList","orderId","ReturnsOrderDetail","items","note","ReturnsConfirmation","returnId","ReturnsResult","ReturnsMyReturnsList","ReturnsMyReturnDetail","BitsnapReturns","showLogo","logoUrl","logoDarkUrl","props","ReturnsProvider"],"mappings":"AAAA,+HAAyI,sDAAwC,IC8C3KA,CAAAA,CAAiD,CACrD,QAAA,CACA,OAAA,CACA,cAAA,CACA,QAAA,CACA,WAAA,CACA,UACF,CAAA,CAGO,SAASC,CAAAA,CAAoBC,CAAAA,CAAgC,CAClE,OAAOF,CAAAA,CAAmB,QAAA,CAASE,CAAI,CACzC,CAGO,SAASC,CAAAA,CAAmBC,CAAAA,CAAkC,CACnE,OAAOA,CAAAA,CAAa,CAAE,IAAA,CAAM,QAAS,CAAA,CAAI,CAAE,IAAA,CAAM,OAAQ,CAC3D,CAMO,SAASC,CAAAA,CACdH,CAAAA,CACAI,CAAAA,CACa,CACb,MAAA,CAAQA,CAAAA,CAAM,IAAA,CAAM,CAClB,IAAK,iBAAA,CAEH,OAAOL,CAAAA,CAAoBC,CAAAA,CAAK,IAAI,CAAA,CAAI,CAAE,IAAA,CAAM,OAAQ,CAAA,CAAIA,CAAAA,CAC9D,IAAK,WAAA,CACH,OAAOA,CAAAA,CAAK,IAAA,GAAS,OAAA,CAAU,CAAE,IAAA,CAAM,MAAO,CAAA,CAAIA,CAAAA,CACpD,IAAK,eAAA,CACH,OAAOA,CAAAA,CAAK,IAAA,GAAS,OAAA,EAAWA,CAAAA,CAAK,IAAA,GAAS,MAAA,CAC1C,CAAE,IAAA,CAAM,QAAS,CAAA,CACjBA,CAAAA,CACN,IAAK,cAAA,CACH,OAAOA,CAAAA,CAAK,IAAA,GAAS,QAAA,CACjB,CAAE,IAAA,CAAM,OAAA,CAAS,OAAA,CAASI,CAAAA,CAAM,OAAQ,CAAA,CACxCJ,CAAAA,CACN,IAAK,QAAA,CACH,OAAOA,CAAAA,CAAK,IAAA,GAAS,OAAA,C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CAAAA,CACnB,QAAA,CAAArC,6BAAAA,CAACE,CAAA,CACC,UAAA,CAAYmC,CAAAA,CAAM,gBAAA,EAAoB,IAAA,EAAQA,CAAAA,CAAM,gBAAA,GAAqB,EAAA,CACzE,IAAA,CAAM,CAAE,QAAA,CAAAH,CAAAA,CAAU,OAAA,CAAAC,CAAAA,CAAS,WAAA,CAAAC,CAAY,CAAA,CACzC,CAAA,CACF,CAEJ,CAAA,eAAA","file":"/home/emems/.t3/worktrees/bitsnap-react-panel-key/dist/chunk-J4GUVJP4.js","sourcesContent":[null,"/** One line chosen for return. */\nexport type SelectedReturnLine = {\n lineId: string;\n quantity: number;\n};\n\n/** Where the default flow of `BitsnapReturns` currently is. */\nexport type ReturnsStep =\n | { name: \"email\" }\n | { name: \"code\" }\n | { name: \"orders\" }\n | {\n name: \"order\";\n orderId: string;\n /** Selection to restore when coming back from the confirmation. */\n items?: SelectedReturnLine[];\n note?: string;\n }\n | {\n name: \"confirmation\";\n orderId: string;\n items: SelectedReturnLine[];\n note: string;\n }\n | { name: \"result\"; returnId: string }\n | { name: \"myReturns\" }\n | { name: \"myReturn\"; returnId: string };\n\nexport type ReturnsStepName = ReturnsStep[\"name\"];\n\nexport type ReturnsStepEvent =\n /** A verification code was requested. */\n | { type: \"CODE_SENT\" }\n /** The session became valid: code verified, stored session or panel token. */\n | { type: \"AUTHENTICATED\" }\n /** The session was dropped by the backend, expiry or logout. */\n | { type: \"SESSION_EXPIRED\" }\n | { type: \"SELECT_ORDER\"; orderId: string }\n | { type: \"REVIEW\"; items: SelectedReturnLine[]; note: string }\n | { type: \"SUBMITTED\"; returnId: string }\n | { type: \"OPEN_MY_RETURNS\" }\n | { type: \"SELECT_RETURN\"; returnId: string }\n | { type: \"BACK\" }\n /** Leave the result screen for the order list. */\n | { type: \"CONTINUE\" };\n\nconst STEPS_WITH_SESSION: readonly ReturnsStepName[] = [\n \"orders\",\n \"order\",\n \"confirmation\",\n \"result\",\n \"myReturns\",\n \"myReturn\",\n];\n\n/** Steps that cannot be shown without a returns session. */\nexport function stepRequiresSession(step: ReturnsStepName): boolean {\n return STEPS_WITH_SESSION.includes(step);\n}\n\n/** Starts at the orders when a session exists, otherwise at the email. */\nexport function initialReturnsStep(hasSession: boolean): ReturnsStep {\n return hasSession ? { name: \"orders\" } : { name: \"email\" };\n}\n\n/**\n * Pure transition function of the default flow. Events that do not apply to\n * the current step leave it unchanged.\n */\nexport function reduceReturnsStep(\n step: ReturnsStep,\n event: ReturnsStepEvent,\n): ReturnsStep {\n switch (event.type) {\n case \"SESSION_EXPIRED\":\n // Email and code do not need a session; keep a pending verification.\n return stepRequiresSession(step.name) ? { name: \"email\" } : step;\n case \"CODE_SENT\":\n return step.name === \"email\" ? { name: \"code\" } : step;\n case \"AUTHENTICATED\":\n return step.name === \"email\" || step.name === \"code\"\n ? { name: \"orders\" }\n : step;\n case \"SELECT_ORDER\":\n return step.name === \"orders\"\n ? { name: \"order\", orderId: event.orderId }\n : step;\n case \"REVIEW\":\n return step.name === \"order\"\n ? {\n name: \"confirmation\",\n orderId: step.orderId,\n items: event.items,\n note: event.note,\n }\n : step;\n case \"SUBMITTED\":\n return step.name === \"confirmation\"\n ? { name: \"result\", returnId: event.returnId }\n : step;\n case \"OPEN_MY_RETURNS\":\n return step.name === \"orders\" || step.name === \"result\"\n ? { name: \"myReturns\" }\n : step;\n case \"SELECT_RETURN\":\n return step.name === \"myReturns\"\n ? { name: \"myReturn\", returnId: event.returnId }\n : step;\n case \"CONTINUE\":\n return step.name === \"result\" ? { name: \"orders\" } : step;\n case \"BACK\":\n switch (step.name) {\n case \"code\":\n return { name: \"email\" };\n case \"order\":\n case \"myReturns\":\n return { name: \"orders\" };\n case \"confirmation\":\n return {\n name: \"order\",\n orderId: step.orderId,\n items: step.items,\n note: step.note,\n };\n case \"myReturn\":\n return { name: \"myReturns\" };\n default:\n return step;\n }\n }\n}\n\nconst STEP_NUMBERS: Partial<Record<ReturnsStepName, number>> = {\n email: 1,\n code: 2,\n orders: 3,\n order: 4,\n confirmation: 5,\n result: 6,\n};\n\nexport const RETURNS_STEP_COUNT = 6;\n\n/** Position of a step in the return flow, `undefined` for the \"my returns\" views. */\nexport function returnsStepNumber(step: ReturnsStepName): number | undefined {\n return STEP_NUMBERS[step];\n}\n","import { useEffect, useReducer, useRef } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n LoginBrandLogo,\n type LoginLogoOptions,\n} from \"@/src/ui/email-code-login/LoginBrandLogo\";\nimport { useReturnsSlot } from \"./appearance.context\";\nimport { ReturnsCodeStep, ReturnsEmailStep } from \"./AuthSteps\";\nimport { SkeletonRows } from \"./internal\";\nimport { ReturnsMyReturnDetail, ReturnsMyReturnsList } from \"./MyReturns\";\nimport {\n ReturnsConfirmation,\n ReturnsOrderDetail,\n ReturnsOrderList,\n ReturnsResult,\n} from \"./OrderSteps\";\nimport {\n ReturnsProvider,\n useReturnsContext,\n type ReturnsProviderProps,\n} from \"./ReturnsProvider\";\nimport {\n initialReturnsStep,\n reduceReturnsStep,\n RETURNS_STEP_COUNT,\n returnsStepNumber,\n} from \"./state-machine\";\nimport { useReturnsLocale, useReturnsText } from \"./texts.context\";\n\n/**\n * Props of {@link BitsnapReturns}. `showLogo`, `logoUrl` and `logoDarkUrl` set\n * the shop logo above the e-mail and code steps: by default the logo from the\n * shop settings, or Bitsnap's when the shop has none.\n */\nexport type BitsnapReturnsProps = Omit<ReturnsProviderProps, \"children\"> &\n LoginLogoOptions;\n\nfunction StepIndicator({ current }: { current: number }) {\n const text = useReturnsText();\n const slot = useReturnsSlot(\"stepIndicator\");\n\n return (\n <p\n data-bitsnap-returns-slot=\"stepIndicator\"\n className={cn(\"text-xs\", slot.className)}\n style={slot.style}\n >\n {text(\"stepIndicator\", { current, total: RETURNS_STEP_COUNT })}\n </p>\n );\n}\n\n/** Default step router. All transitions come from the pure state machine. */\nfunction ReturnsRouter({\n panelToken,\n logo,\n}: {\n panelToken: boolean;\n logo: LoginLogoOptions;\n}) {\n const { status, challenge, projectID } = useReturnsContext(\"BitsnapReturns\");\n const locale = useReturnsLocale();\n const [step, dispatch] = useReducer(\n reduceReturnsStep,\n initialReturnsStep(false),\n );\n\n // A valid session (verified code, stored session, exchanged panel token)\n // moves on to the orders; a dropped one returns to the start.\n useEffect(() => {\n if (status === \"authenticated\") {\n dispatch({ type: \"AUTHENTICATED\" });\n } else if (status === \"anonymous\") {\n dispatch({ type: \"SESSION_EXPIRED\" });\n }\n }, [status]);\n\n // A verification that was pending before a reload or an app switch returns\n // to the code step once, when the stored state has been read.\n const restored = useRef(false);\n useEffect(() => {\n if (restored.current || status === \"hydrating\") {\n return;\n }\n restored.current = true;\n if (status === \"anonymous\" && challenge != null) {\n dispatch({ type: \"CODE_SENT\" });\n }\n }, [status, challenge]);\n\n // Without a panel token the server render and the first client render show\n // the email step; a stored session switches to the orders after hydration.\n if (status === \"exchanging\" || (status === \"hydrating\" && panelToken)) {\n return <SkeletonRows />;\n }\n\n const stepNumber = returnsStepNumber(step.name);\n\n // The logo sits above the step indicator, and stays mounted between the\n // e-mail and the code step; the steps themselves then show none.\n const loginStep = step.name === \"email\" || step.name === \"code\";\n\n return (\n <div className=\"flex flex-col gap-4\">\n {loginStep && (\n <LoginBrandLogo projectId={projectID} locale={locale} {...logo} />\n )}\n {stepNumber != null && <StepIndicator current={stepNumber} />}\n {step.name === \"email\" && (\n <ReturnsEmailStep\n showLogo={false}\n onSubmitted={() => dispatch({ type: \"CODE_SENT\" })}\n />\n )}\n {step.name === \"code\" && (\n <ReturnsCodeStep\n showLogo={false}\n onVerified={() => dispatch({ type: \"AUTHENTICATED\" })}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"orders\" && (\n <ReturnsOrderList\n showLogout={!panelToken}\n onSelectOrder={(orderId) =>\n dispatch({ type: \"SELECT_ORDER\", orderId })\n }\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"order\" && (\n <ReturnsOrderDetail\n orderId={step.orderId}\n initialItems={step.items}\n initialNote={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onContinue={({ items, note }) =>\n dispatch({ type: \"REVIEW\", items, note })\n }\n />\n )}\n {step.name === \"confirmation\" && (\n <ReturnsConfirmation\n orderId={step.orderId}\n items={step.items}\n note={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onSubmitted={(returnId) =>\n dispatch({ type: \"SUBMITTED\", returnId })\n }\n />\n )}\n {step.name === \"result\" && (\n <ReturnsResult\n returnId={step.returnId}\n onContinue={() => dispatch({ type: \"CONTINUE\" })}\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"myReturns\" && (\n <ReturnsMyReturnsList\n onSelectReturn={(returnId) =>\n dispatch({ type: \"SELECT_RETURN\", returnId })\n }\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"myReturn\" && (\n <ReturnsMyReturnDetail\n returnId={step.returnId}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n </div>\n );\n}\n\n/**\n * Customer return flow: email, code, orders, line selection, confirmation and\n * result, plus the list of earlier returns. It is `ReturnsProvider` with the\n * default step router; compose your own page from the step components to\n * change the layout.\n *\n * ```tsx\n * <BitsnapReturns projectID=\"…\" appearance={brand} texts={{ emailStepTitle: \"Return a product\" }} />\n * ```\n */\nexport function BitsnapReturns({\n showLogo,\n logoUrl,\n logoDarkUrl,\n ...props\n}: BitsnapReturnsProps) {\n return (\n <ReturnsProvider {...props}>\n <ReturnsRouter\n panelToken={props.panelAccessToken != null && props.panelAccessToken !== \"\"}\n logo={{ showLogo, logoUrl, logoDarkUrl }}\n />\n </ReturnsProvider>\n );\n}\n"]}
|
|
@@ -1,2 +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 _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkTM3E3L57js = require('./chunk-TM3E3L57.js');var _chunk6DEKVABTjs = require('./chunk-6DEKVABT.js');var _chunkEK3D44XWjs = require('./chunk-EK3D44XW.js');var _chunkQ337IQNAjs = require('./chunk-Q337IQNA.js');var xt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Tt={fontFamily:"--bitsnap-products-font-family",gridMinWidth:"--bitsnap-products-grid-min-width",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"},Ct={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",gridMinWidth:"9rem"},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",gridMinWidth:"9rem"}},St=[];function ct(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:Ct,variables:Tt,shadcnVariables:St});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 ut(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function U(t,e,n=_chunkQ337IQNAjs.d){let r=t/100,a=_nullishCoalesce(ut(n,e), () => (ut(_chunkQ337IQNAjs.d,e)));return a!=null?a.format(r):`${r.toFixed(2)} ${e}`}var _react = require('react');function V(t){let{projectID:e,locale:n,search:r,initialData:a}=t,[i]=_react.useState.call(void 0, ()=>_chunk6DEKVABTjs.e),d=_nullishCoalesce(t.host, () => (i)),c=_chunkTM3E3L57js.a.call(void 0, t.pageSize),s=JSON.stringify([e,d,_nullishCoalesce(n, () => (null)),_nullishCoalesce(_optionalChain([r, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]), () => (null)),c]),[g,l]=_react.useState.call(void 0, {queryKey:s,page:1});g.queryKey!==s&&l({queryKey:s,page:1});let[P,C]=_react.useState.call(void 0, 0),[m,p]=_react.useState.call(void 0, ()=>({requestKey:a!=null?`${s}|1|0`:"",data:a,error:void 0})),f=_nullishCoalesce(_optionalChain([m, 'access', _4 => _4.data, 'optionalAccess', _5 => _5.totalCount]), () => (0)),b=_chunkTM3E3L57js.b.call(void 0, f,c),h=g.queryKey===s?g.page:1,k=f>0?Math.min(h,b):h,S=`${s}|${k}|${P}`,T=m.requestKey===S;_react.useEffect.call(void 0, ()=>{if(T)return;let y=new AbortController;return _chunkTM3E3L57js.c.call(void 0, {projectID:e,host:d,locale:n,search:r,limit:c,offset:(k-1)*c},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(E=>({requestKey:S,data:E.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,T]);let I=_react.useCallback.call(void 0, y=>{let L=Math.max(1,Math.floor(y));l({queryKey:s,page:f>0?Math.min(L,b):L})},[s,f,b]),A=_react.useCallback.call(void 0, ()=>C(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([m, 'access', _6 => _6.data, 'optionalAccess', _7 => _7.items]), () => ([])),totalCount:f,page:k,pageCount:b,setPage:I,isLoading:!T,error:T?m.error:void 0,refetch:A}),[m,f,k,b,I,T,A])}var H=50,wt=1e3;function pt(t,e=wt){let n=new Set,r=new Map,a=[],i=[],d,c,s=!1;function g(){for(c!==void 0&&clearTimeout(c),c=void 0;a.length>0;){let p=a.slice(0,H),f=i.slice(0,H);a=a.slice(H),i=i.slice(H);try{t({productIds:p,positions:f})}catch (e3){}}}function l(){g();try{_optionalChain([_chunkEK3D44XWjs.f.call(void 0, ), 'optionalAccess', _8 => _8.flush, 'call', _9 => _9()])}catch (e4){}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function C(){s||typeof window>"u"||(s=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function m(){if(d)return d;if(!(typeof IntersectionObserver>"u"))return d=new IntersectionObserver(p=>{for(let f of p){let b=r.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(r.delete(f.target),_optionalChain([d, 'optionalAccess', _10 => _10.unobserve, 'call', _11 => _11(f.target)]),!n.has(b.id)&&(n.add(b.id),a.push(b.id),i.push(b.position)))}a.length>0&&c===void 0&&(c=setTimeout(g,e),_optionalChain([c, 'access', _12 => _12.unref, 'optionalCall', _13 => _13()]))},{threshold:[.5]}),C(),d}return{observe(p,f,b){try{if(n.has(f))return()=>{};let h=m();return h?(r.set(p,{id:f,position:b}),h.observe(p),()=>{r.delete(p),h.unobserve(p)}):()=>{}}catch (e5){return()=>{}}},flush:g,destroy(){try{g(),_optionalChain([d, 'optionalAccess', _14 => _14.disconnect, 'call', _15 => _15()]),s&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),s=!1)}catch (e6){}d=void 0,r.clear()}}}var It={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",model3d:"3D",model3dLabel:"3D model",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",model3d:"3D",model3dLabel:"Model 3D",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 gt(t,e){return _chunkQ337IQNAjs.b.call(void 0, It,t,e)}function $(t,e){return t.replace(/\{(\w+)\}/g,(n,r)=>r in e?String(e[r]):n)}var _jsxruntime = require('react/jsx-runtime');var bt=_react.createContext.call(void 0, void 0),_t={observe:()=>()=>{},clicked:()=>{}},Pt=_react.createContext.call(void 0, _t);function F(){let t=_react.useContext.call(void 0, bt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:n}=F(),r=q(n,t);return{"data-bitsnap-products-slot":t,className:_chunk6DEKVABTjs.g.call(void 0, e,_optionalChain([r, 'optionalAccess', _16 => _16.className])),style:_optionalChain([r, 'optionalAccess', _17 => _17.style])}}var W="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",yt=`${W} w-full`,Nt=`${yt} no-underline`;function Ot({product:t,onAdd:e}){let{texts:n}=F(),[r,a]=_react.useState.call(void 0, "idle"),i=u("addToCartButton",yt),d=u("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(r!=="added")return;let g=setTimeout(()=>a("idle"),2e3);return()=>clearTimeout(g)},[r]);let c=_react.useCallback.call(void 0, async()=>{a("adding");try{await e(),a("added")}catch(g){console.error("bitsnap-react: could not add to the cart",g),a("error")}},[e]),s=r==="adding"?n.addingToCart:r==="added"?n.addedToCart:n.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,disabled:r==="adding","aria-label":`${s}: ${t.name}`,onClick:c,children:s}),r==="error"?_jsxruntime.jsx.call(void 0, "p",{...d,role:"alert",children:n.addToCartError}):null]})}function Bt({product:t,position:e,href:n,onAdd:r,renderItem:a}){let{texts:i,locale:d}=F(),c=_react.useContext.call(void 0, Pt),s=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(s.current!=null)return c.observe(s.current,t.id,e)},[c,t.id,e]);let g=_react.useCallback.call(void 0, ()=>c.clicked(t,e),[c,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),C=u("image","aspect-square w-full overflow-hidden"),m=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),h=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),I=u("actions","p-4 pt-0"),A=u("selectButton",Nt),y=U(t.price,t.currency,d),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?U(t.compareAtPrice,t.currency,d):null;if(a!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:a(t,{href:n,price:y,compareAtPrice:L,texts:i,locale:d,addToCart:r,trackClick:g})});let E=_nullishCoalesce(_optionalChain([t, 'access', _18 => _18.image, 'optionalAccess', _19 => _19.thumbnailUrl]), () => (_optionalChain([t, 'access', _20 => _20.image, 'optionalAccess', _21 => _21.url]))),_=t.available?t.isRecurring?i.subscription:null:i.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...P,href:n,onClick:g,children:[E!=null?_jsxruntime.jsx.call(void 0, "div",{...C,children:_jsxruntime.jsx.call(void 0, "img",{src:E,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...m,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...p,children:[_jsxruntime.jsx.call(void 0, "h3",{...f,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...b,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...h,children:[t.priceFrom?$(i.priceFrom,{price:y}):y,L!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[i.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:L})]}):null]})]})]}),_!=null?_jsxruntime.jsx.call(void 0, "span",{...S,"data-kind":t.available?"subscription":"unavailable",children:_}):null,t.has3d===!0?_jsxruntime.jsxs.call(void 0, "span",{...T,title:i.model3dLabel,children:[_jsxruntime.jsx.call(void 0, Rt,{}),_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:i.model3d}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:i.model3dLabel})]}):null,_jsxruntime.jsx.call(void 0, "div",{...I,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Ot,{product:t,onAdd:r}):_jsxruntime.jsx.call(void 0, "a",{...A,href:n,onClick:g,children:t.variantCount>1?i.chooseOptions:i.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...A,disabled:!0,children:i.unavailable})})]})}function Rt(){return _jsxruntime.jsxs.call(void 0, "svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"m3.3 7 8.7 5 8.7-5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M12 22V12"})]})}var Lt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,var(--bitsnap-products-grid-min-width,9rem)),1fr))] gap-5 p-0";function Dt({count:t,label:e}){let n=u("grid",Lt),r=u("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...n,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(a,i)=>_jsxruntime.jsx.call(void 0, "div",{...r,"aria-hidden":"true"},i))})}function Ft({page:t,pageCount:e,isLoading:n,onPage:r}){let{texts:a}=F(),i=u("pagination","mt-8 flex items-center justify-center gap-4"),d=u("paginationButton",W),c=u("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...i,"aria-label":a.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...d,"aria-disabled":n||t<=1,onClick:()=>{!n&&t>1&&r(t-1)},children:a.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...c,"aria-live":"polite",children:$(a.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...d,"aria-disabled":n||t>=e,onClick:()=>{!n&&t<e&&r(t+1)},children:a.nextPage})]})}function Mt({options:t,productHref:e,renderItem:n,onAddToCart:r,showCartOnAdd:a}){let{texts:i}=F(),{products:d,page:c,pageCount:s,setPage:g,isLoading:l,error:P,refetch:C}=V(t),m=_chunkEK3D44XWjs.m.call(void 0, ),p=_optionalChain([t, 'access', _22 => _22.search, 'optionalAccess', _23 => _23.trim, 'call', _24 => _24()])?"search":"catalog",f=_chunkTM3E3L57js.a.call(void 0, t.pageSize),b=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{b.current||l||P!=null||(b.current=!0,m.track("product_list_viewed",{list_id:p,item_count:d.length}))},[m,l,P,p,d.length]);let h=_react.useMemo.call(void 0, ()=>pt(({productIds:v,positions:w})=>m.track("product_impression",{list_id:p,product_ids:v,positions:w})),[m,p]);_react.useEffect.call(void 0, ()=>()=>h.destroy(),[h]);let k=_react.useMemo.call(void 0, ()=>({observe:h.observe,clicked:(v,w)=>m.track("product_clicked",{list_id:p,position:w},{product_id:v.id})}),[h,m,p]),S=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, !1),I=_react.useCallback.call(void 0, v=>{T.current=!0,g(v)},[g]);_react.useEffect.call(void 0, ()=>{l||!T.current||(T.current=!1,_optionalChain([S, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.focus, 'call', _27 => _27({preventScroll:!0})]),_optionalChain([S, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.scrollIntoView, 'call', _30 => _30({block:"start"})]))},[l]);let A=u("grid",Lt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=u("retryButton",W),{projectID:_,host:G}=t,ht=_react.useCallback.call(void 0, (v,w)=>async()=>{if(r!=null){await _chunkEK3D44XWjs.p.call(void 0, ()=>r(v)),_chunkTM3E3L57js.d.call(void 0, m,v);return}await _chunkTM3E3L57js.e.call(void 0, v,{projectID:_,host:G,showCart:a,analytics:m,url:w})},[r,_,G,a,m]),N;return l&&d.length===0?N=_jsxruntime.jsx.call(void 0, Dt,{count:Math.min(_chunkTM3E3L57js.a.call(void 0, t.pageSize),8),label:i.loading}):P!=null?N=_jsxruntime.jsxs.call(void 0, "div",{...L,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:i.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...E,onClick:C,children:i.retry})]}):d.length===0?N=_jsxruntime.jsx.call(void 0, "p",{...y,children:i.empty}):N=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":l||void 0,className:_chunk6DEKVABTjs.g.call(void 0, A.className,l&&"opacity-60"),children:d.map((v,w)=>{let X=e(v);return _jsxruntime.jsx.call(void 0, Bt,{product:v,position:(c-1)*f+w,href:X,onAdd:ht(v,X),renderItem:n},v.id)})}),_jsxruntime.jsx.call(void 0, Pt.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[N,s>1&&P==null?_jsxruntime.jsx.call(void 0, Ft,{page:c,pageCount:s,isLoading:l,onPage:I}):null]})})}var Ut=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function zt({productHref:t=Ut,appearance:e,texts:n,renderItem:r,onAddToCart:a,showCartOnAdd:i=!0,className:d,analytics:c,...s}){let g=_chunkEK3D44XWjs.n.call(void 0, s.projectID,c,"catalog"),l=_nullishCoalesce(s.locale, () => (_chunkQ337IQNAjs.d)),P=_react.useMemo.call(void 0, ()=>ct(e),[e]),C=_react.useMemo.call(void 0, ()=>gt(l,n),[l,n]),m=_react.useMemo.call(void 0, ()=>({appearance:P,texts:C,locale:l}),[P,C,l]),p=q(P,"root");return _jsxruntime.jsx.call(void 0, _chunkEK3D44XWjs.l,{value:g,children:_jsxruntime.jsx.call(void 0, bt.Provider,{value:m,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunk6DEKVABTjs.g.call(void 0, "bitsnap-react",P.boundaryClassName,d,_optionalChain([p, 'optionalAccess', _31 => _31.className])),style:{...P.boundaryStyle,..._optionalChain([p, 'optionalAccess', _32 => _32.style])},children:_jsxruntime.jsx.call(void 0, Mt,{options:s,productHref:t,renderItem:r,onAddToCart:a,showCartOnAdd:i})})})})}exports.a = xt; exports.b = U; exports.c = V; exports.d = zt;
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
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 _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkOCJ7YWFXjs = require('./chunk-OCJ7YWFX.js');var _chunk6DEKVABTjs = require('./chunk-6DEKVABT.js');var _chunkEK3D44XWjs = require('./chunk-EK3D44XW.js');var _chunkQ337IQNAjs = require('./chunk-Q337IQNA.js');var xt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Tt={fontFamily:"--bitsnap-products-font-family",gridMinWidth:"--bitsnap-products-grid-min-width",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"},Ct={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",gridMinWidth:"9rem"},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",gridMinWidth:"9rem"}},St=[];function ct(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:Ct,variables:Tt,shadcnVariables:St});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 ut(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function U(t,e,n=_chunkQ337IQNAjs.d){let r=t/100,a=_nullishCoalesce(ut(n,e), () => (ut(_chunkQ337IQNAjs.d,e)));return a!=null?a.format(r):`${r.toFixed(2)} ${e}`}var _react = require('react');function V(t){let{projectID:e,locale:n,search:r,initialData:a}=t,[i]=_react.useState.call(void 0, ()=>_chunk6DEKVABTjs.e),d=_nullishCoalesce(t.host, () => (i)),c=_chunkOCJ7YWFXjs.a.call(void 0, t.pageSize),s=JSON.stringify([e,d,_nullishCoalesce(n, () => (null)),_nullishCoalesce(_optionalChain([r, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]), () => (null)),c]),[g,l]=_react.useState.call(void 0, {queryKey:s,page:1});g.queryKey!==s&&l({queryKey:s,page:1});let[P,C]=_react.useState.call(void 0, 0),[m,p]=_react.useState.call(void 0, ()=>({requestKey:a!=null?`${s}|1|0`:"",data:a,error:void 0})),f=_nullishCoalesce(_optionalChain([m, 'access', _4 => _4.data, 'optionalAccess', _5 => _5.totalCount]), () => (0)),b=_chunkOCJ7YWFXjs.b.call(void 0, f,c),h=g.queryKey===s?g.page:1,k=f>0?Math.min(h,b):h,S=`${s}|${k}|${P}`,T=m.requestKey===S;_react.useEffect.call(void 0, ()=>{if(T)return;let y=new AbortController;return _chunkOCJ7YWFXjs.c.call(void 0, {projectID:e,host:d,locale:n,search:r,limit:c,offset:(k-1)*c},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(E=>({requestKey:S,data:E.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,T]);let I=_react.useCallback.call(void 0, y=>{let L=Math.max(1,Math.floor(y));l({queryKey:s,page:f>0?Math.min(L,b):L})},[s,f,b]),A=_react.useCallback.call(void 0, ()=>C(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([m, 'access', _6 => _6.data, 'optionalAccess', _7 => _7.items]), () => ([])),totalCount:f,page:k,pageCount:b,setPage:I,isLoading:!T,error:T?m.error:void 0,refetch:A}),[m,f,k,b,I,T,A])}var H=50,wt=1e3;function pt(t,e=wt){let n=new Set,r=new Map,a=[],i=[],d,c,s=!1;function g(){for(c!==void 0&&clearTimeout(c),c=void 0;a.length>0;){let p=a.slice(0,H),f=i.slice(0,H);a=a.slice(H),i=i.slice(H);try{t({productIds:p,positions:f})}catch (e3){}}}function l(){g();try{_optionalChain([_chunkEK3D44XWjs.f.call(void 0, ), 'optionalAccess', _8 => _8.flush, 'call', _9 => _9()])}catch (e4){}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function C(){s||typeof window>"u"||(s=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function m(){if(d)return d;if(!(typeof IntersectionObserver>"u"))return d=new IntersectionObserver(p=>{for(let f of p){let b=r.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(r.delete(f.target),_optionalChain([d, 'optionalAccess', _10 => _10.unobserve, 'call', _11 => _11(f.target)]),!n.has(b.id)&&(n.add(b.id),a.push(b.id),i.push(b.position)))}a.length>0&&c===void 0&&(c=setTimeout(g,e),_optionalChain([c, 'access', _12 => _12.unref, 'optionalCall', _13 => _13()]))},{threshold:[.5]}),C(),d}return{observe(p,f,b){try{if(n.has(f))return()=>{};let h=m();return h?(r.set(p,{id:f,position:b}),h.observe(p),()=>{r.delete(p),h.unobserve(p)}):()=>{}}catch (e5){return()=>{}}},flush:g,destroy(){try{g(),_optionalChain([d, 'optionalAccess', _14 => _14.disconnect, 'call', _15 => _15()]),s&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),s=!1)}catch (e6){}d=void 0,r.clear()}}}var It={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",model3d:"3D",model3dLabel:"3D model",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",model3d:"3D",model3dLabel:"Model 3D",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 gt(t,e){return _chunkQ337IQNAjs.b.call(void 0, It,t,e)}function $(t,e){return t.replace(/\{(\w+)\}/g,(n,r)=>r in e?String(e[r]):n)}var _jsxruntime = require('react/jsx-runtime');var bt=_react.createContext.call(void 0, void 0),_t={observe:()=>()=>{},clicked:()=>{}},Pt=_react.createContext.call(void 0, _t);function F(){let t=_react.useContext.call(void 0, bt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:n}=F(),r=q(n,t);return{"data-bitsnap-products-slot":t,className:_chunk6DEKVABTjs.g.call(void 0, e,_optionalChain([r, 'optionalAccess', _16 => _16.className])),style:_optionalChain([r, 'optionalAccess', _17 => _17.style])}}var W="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",yt=`${W} w-full`,Nt=`${yt} no-underline`;function Ot({product:t,onAdd:e}){let{texts:n}=F(),[r,a]=_react.useState.call(void 0, "idle"),i=u("addToCartButton",yt),d=u("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(r!=="added")return;let g=setTimeout(()=>a("idle"),2e3);return()=>clearTimeout(g)},[r]);let c=_react.useCallback.call(void 0, async()=>{a("adding");try{await e(),a("added")}catch(g){console.error("bitsnap-react: could not add to the cart",g),a("error")}},[e]),s=r==="adding"?n.addingToCart:r==="added"?n.addedToCart:n.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,disabled:r==="adding","aria-label":`${s}: ${t.name}`,onClick:c,children:s}),r==="error"?_jsxruntime.jsx.call(void 0, "p",{...d,role:"alert",children:n.addToCartError}):null]})}function Bt({product:t,position:e,href:n,onAdd:r,renderItem:a}){let{texts:i,locale:d}=F(),c=_react.useContext.call(void 0, Pt),s=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(s.current!=null)return c.observe(s.current,t.id,e)},[c,t.id,e]);let g=_react.useCallback.call(void 0, ()=>c.clicked(t,e),[c,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),C=u("image","aspect-square w-full overflow-hidden"),m=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),h=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),I=u("actions","p-4 pt-0"),A=u("selectButton",Nt),y=U(t.price,t.currency,d),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?U(t.compareAtPrice,t.currency,d):null;if(a!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:a(t,{href:n,price:y,compareAtPrice:L,texts:i,locale:d,addToCart:r,trackClick:g})});let E=_nullishCoalesce(_optionalChain([t, 'access', _18 => _18.image, 'optionalAccess', _19 => _19.thumbnailUrl]), () => (_optionalChain([t, 'access', _20 => _20.image, 'optionalAccess', _21 => _21.url]))),_=t.available?t.isRecurring?i.subscription:null:i.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...P,href:n,onClick:g,children:[E!=null?_jsxruntime.jsx.call(void 0, "div",{...C,children:_jsxruntime.jsx.call(void 0, "img",{src:E,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...m,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...p,children:[_jsxruntime.jsx.call(void 0, "h3",{...f,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...b,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...h,children:[t.priceFrom?$(i.priceFrom,{price:y}):y,L!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[i.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:L})]}):null]})]})]}),_!=null?_jsxruntime.jsx.call(void 0, "span",{...S,"data-kind":t.available?"subscription":"unavailable",children:_}):null,t.has3d===!0?_jsxruntime.jsxs.call(void 0, "span",{...T,title:i.model3dLabel,children:[_jsxruntime.jsx.call(void 0, Rt,{}),_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:i.model3d}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:i.model3dLabel})]}):null,_jsxruntime.jsx.call(void 0, "div",{...I,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Ot,{product:t,onAdd:r}):_jsxruntime.jsx.call(void 0, "a",{...A,href:n,onClick:g,children:t.variantCount>1?i.chooseOptions:i.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...A,disabled:!0,children:i.unavailable})})]})}function Rt(){return _jsxruntime.jsxs.call(void 0, "svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"m3.3 7 8.7 5 8.7-5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M12 22V12"})]})}var Lt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,var(--bitsnap-products-grid-min-width,9rem)),1fr))] gap-5 p-0";function Dt({count:t,label:e}){let n=u("grid",Lt),r=u("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...n,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(a,i)=>_jsxruntime.jsx.call(void 0, "div",{...r,"aria-hidden":"true"},i))})}function Ft({page:t,pageCount:e,isLoading:n,onPage:r}){let{texts:a}=F(),i=u("pagination","mt-8 flex items-center justify-center gap-4"),d=u("paginationButton",W),c=u("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...i,"aria-label":a.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...d,"aria-disabled":n||t<=1,onClick:()=>{!n&&t>1&&r(t-1)},children:a.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...c,"aria-live":"polite",children:$(a.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...d,"aria-disabled":n||t>=e,onClick:()=>{!n&&t<e&&r(t+1)},children:a.nextPage})]})}function Mt({options:t,productHref:e,renderItem:n,onAddToCart:r,showCartOnAdd:a}){let{texts:i}=F(),{products:d,page:c,pageCount:s,setPage:g,isLoading:l,error:P,refetch:C}=V(t),m=_chunkEK3D44XWjs.m.call(void 0, ),p=_optionalChain([t, 'access', _22 => _22.search, 'optionalAccess', _23 => _23.trim, 'call', _24 => _24()])?"search":"catalog",f=_chunkOCJ7YWFXjs.a.call(void 0, t.pageSize),b=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{b.current||l||P!=null||(b.current=!0,m.track("product_list_viewed",{list_id:p,item_count:d.length}))},[m,l,P,p,d.length]);let h=_react.useMemo.call(void 0, ()=>pt(({productIds:v,positions:w})=>m.track("product_impression",{list_id:p,product_ids:v,positions:w})),[m,p]);_react.useEffect.call(void 0, ()=>()=>h.destroy(),[h]);let k=_react.useMemo.call(void 0, ()=>({observe:h.observe,clicked:(v,w)=>m.track("product_clicked",{list_id:p,position:w},{product_id:v.id})}),[h,m,p]),S=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, !1),I=_react.useCallback.call(void 0, v=>{T.current=!0,g(v)},[g]);_react.useEffect.call(void 0, ()=>{l||!T.current||(T.current=!1,_optionalChain([S, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.focus, 'call', _27 => _27({preventScroll:!0})]),_optionalChain([S, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.scrollIntoView, 'call', _30 => _30({block:"start"})]))},[l]);let A=u("grid",Lt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=u("retryButton",W),{projectID:_,host:G}=t,ht=_react.useCallback.call(void 0, (v,w)=>async()=>{if(r!=null){await _chunkEK3D44XWjs.p.call(void 0, ()=>r(v)),_chunkOCJ7YWFXjs.d.call(void 0, m,v);return}await _chunkOCJ7YWFXjs.e.call(void 0, v,{projectID:_,host:G,showCart:a,analytics:m,url:w})},[r,_,G,a,m]),N;return l&&d.length===0?N=_jsxruntime.jsx.call(void 0, Dt,{count:Math.min(_chunkOCJ7YWFXjs.a.call(void 0, t.pageSize),8),label:i.loading}):P!=null?N=_jsxruntime.jsxs.call(void 0, "div",{...L,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:i.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...E,onClick:C,children:i.retry})]}):d.length===0?N=_jsxruntime.jsx.call(void 0, "p",{...y,children:i.empty}):N=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":l||void 0,className:_chunk6DEKVABTjs.g.call(void 0, A.className,l&&"opacity-60"),children:d.map((v,w)=>{let X=e(v);return _jsxruntime.jsx.call(void 0, Bt,{product:v,position:(c-1)*f+w,href:X,onAdd:ht(v,X),renderItem:n},v.id)})}),_jsxruntime.jsx.call(void 0, Pt.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[N,s>1&&P==null?_jsxruntime.jsx.call(void 0, Ft,{page:c,pageCount:s,isLoading:l,onPage:I}):null]})})}var Ut=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function zt({productHref:t=Ut,appearance:e,texts:n,renderItem:r,onAddToCart:a,showCartOnAdd:i=!0,className:d,analytics:c,...s}){let g=_chunkEK3D44XWjs.n.call(void 0, s.projectID,c,"catalog"),l=_nullishCoalesce(s.locale, () => (_chunkQ337IQNAjs.d)),P=_react.useMemo.call(void 0, ()=>ct(e),[e]),C=_react.useMemo.call(void 0, ()=>gt(l,n),[l,n]),m=_react.useMemo.call(void 0, ()=>({appearance:P,texts:C,locale:l}),[P,C,l]),p=q(P,"root");return _jsxruntime.jsx.call(void 0, _chunkEK3D44XWjs.l,{value:g,children:_jsxruntime.jsx.call(void 0, bt.Provider,{value:m,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunk6DEKVABTjs.g.call(void 0, "bitsnap-react",P.boundaryClassName,d,_optionalChain([p, 'optionalAccess', _31 => _31.className])),style:{...P.boundaryStyle,..._optionalChain([p, 'optionalAccess', _32 => _32.style])},children:_jsxruntime.jsx.call(void 0, Mt,{options:s,productHref:t,renderItem:r,onAddToCart:a,showCartOnAdd:i})})})})}exports.a = xt; exports.b = U; exports.c = V; exports.d = zt;
|
|
2
|
+
//# sourceMappingURL=chunk-J6YI6FJN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react-panel-key/dist/chunk-J6YI6FJN.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,uuBAAgD,sDAAwE,sDAAgD,sDAAqE,sDAAgD,IC6DhRA,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,cAAA,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,YAAA,CAAc,mCAAA,CACd,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,s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BE,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,CCtNA,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-panel-key/dist/chunk-J6YI6FJN.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 /** Minimum grid track width. Use \"100%\" for one column. */\n gridMinWidth?: 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 \"model3dBadge\",\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 gridMinWidth: \"--bitsnap-products-grid-min-width\",\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 gridMinWidth: \"9rem\",\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 gridMinWidth: \"9rem\",\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react-panel-key/dist/chunk-JSDGZ4NY.js"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,6BAAqB","file":"/home/emems/.t3/worktrees/bitsnap-react-panel-key/dist/chunk-JSDGZ4NY.js"}
|