bitsnap-react 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +135 -0
  2. package/dist/CartProvider-FQCDE3HZ.mjs +2 -0
  3. package/dist/CartProvider-FQCDE3HZ.mjs.map +1 -0
  4. package/dist/CartProvider-PDEV6GCV.css +2 -0
  5. package/dist/CartProvider-PDEV6GCV.css.map +1 -0
  6. package/dist/appearance-core-Dt2grZdl.d.mts +19 -0
  7. package/dist/appearance-core-Dt2grZdl.d.ts +19 -0
  8. package/dist/catalog.css +2 -0
  9. package/dist/catalog.css.map +1 -0
  10. package/dist/catalog.d.mts +214 -0
  11. package/dist/catalog.d.ts +214 -0
  12. package/dist/catalog.js +2 -0
  13. package/dist/catalog.js.map +1 -0
  14. package/dist/catalog.mjs +2 -0
  15. package/dist/catalog.mjs.map +1 -0
  16. package/dist/chunk-3TENJTY4.mjs +2 -0
  17. package/dist/chunk-3TENJTY4.mjs.map +1 -0
  18. package/dist/chunk-4HOZFM6V.mjs +2 -0
  19. package/dist/chunk-4HOZFM6V.mjs.map +1 -0
  20. package/dist/chunk-6KQBDN7M.mjs +2 -0
  21. package/dist/chunk-6KQBDN7M.mjs.map +1 -0
  22. package/dist/chunk-6N24OFUB.mjs +4 -0
  23. package/dist/chunk-6N24OFUB.mjs.map +1 -0
  24. package/dist/chunk-6W4FCL22.mjs +2 -0
  25. package/dist/chunk-6W4FCL22.mjs.map +1 -0
  26. package/dist/index.css +1 -1
  27. package/dist/index.css.map +1 -1
  28. package/dist/index.d.mts +57 -23
  29. package/dist/index.d.ts +57 -23
  30. package/dist/index.js +2 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +1 -3
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/methods-J7S63RTQ.mjs +2 -0
  35. package/dist/methods-J7S63RTQ.mjs.map +1 -0
  36. package/dist/methods-QAZED7TJ.css +2 -0
  37. package/dist/methods-QAZED7TJ.css.map +1 -0
  38. package/dist/models.d.mts +54 -0
  39. package/dist/models.d.ts +54 -0
  40. package/dist/models.js +1 -1
  41. package/dist/models.js.map +1 -1
  42. package/dist/models.mjs +1 -1
  43. package/dist/models.mjs.map +1 -1
  44. package/dist/returns.d.mts +602 -52
  45. package/dist/returns.d.ts +602 -52
  46. package/dist/returns.js +1 -1
  47. package/dist/returns.js.map +1 -1
  48. package/dist/returns.mjs +1 -1
  49. package/package.json +21 -26
  50. package/dist/chunk-O4ICBP4G.mjs +0 -2
  51. package/dist/chunk-O4ICBP4G.mjs.map +0 -1
package/README.md CHANGED
@@ -530,6 +530,141 @@ panel's `theme.colors.brand` (set with `setTheme`) and `buttonForeground` is
530
530
  chosen for contrast. Other panel screens and `setTheme` are unchanged. The
531
531
  navigation label follows `setLocale` ("Zwroty" / "Returns").
532
532
 
533
+ ## Product list
534
+
535
+ `ProductList` renders a shop's product catalog: a responsive grid of cards with
536
+ image, name, price, "add to cart" and pagination. It is the same component the
537
+ Bitsnap custom-domain shop home page uses, and it can be embedded on any site.
538
+ It needs the same stylesheet (`bitsnap-react/dist/index.css`) and is safe to
539
+ render on the server.
540
+
541
+ ```tsx
542
+ import { ProductList } from "bitsnap-react";
543
+ import "bitsnap-react/dist/index.css";
544
+
545
+ function ShopPage() {
546
+ return (
547
+ <ProductList
548
+ projectID="your-project-id"
549
+ locale="pl-PL"
550
+ pageSize={24}
551
+ productHref={(product) => `https://shop.example.com/p/${product.uniqueSlug}`}
552
+ />
553
+ );
554
+ }
555
+ ```
556
+
557
+ Import it from `bitsnap-react/catalog` when you do not use the checkout on that
558
+ page: the entry exposes only the list and its hook, and the cart (the heavy
559
+ part of the package) is loaded on the first "Add to cart" click, or never when
560
+ you pass `onAddToCart`. The CommonJS build of the entry re-exports
561
+ `bitsnap-react`, so it shares state with it but is not lean; use ESM for the
562
+ smaller entry.
563
+
564
+ ```tsx
565
+ import { ProductList, useProducts } from "bitsnap-react/catalog";
566
+ ```
567
+
568
+ ### Props
569
+
570
+ | Prop | Meaning |
571
+ | --------------- | ---------------------------------------------------------------------------------------------------- |
572
+ | `projectID` | Project (shop) ID. Required. |
573
+ | `host` | Backend origin. Defaults to `https://bitsnap.pl` (or what `setCustomHost` set at first render). `""` = same origin. |
574
+ | `locale` | Language of the texts, price format and product translations. Defaults to `pl-PL`. |
575
+ | `pageSize` | Products per page, 1 to 48. Defaults to 24. |
576
+ | `search` | Text filter. A change goes back to page 1. |
577
+ | `initialData` | First page (`{ items, totalCount }`) fetched on the server. Always used for the first request (so it must be page 1 for the same props). |
578
+ | `productHref` | `(product) => string`. Defaults to the relative `/p/{uniqueSlug}`, which works on a custom domain. |
579
+ | `appearance` | `{ theme, tokens, elements }`, like the checkout. Light theme by default. |
580
+ | `texts` | `Partial<ProductListTexts>`. Polish and English defaults, picked by `locale`. |
581
+ | `renderItem` | `(product, context) => ReactNode` replaces the content of a card (`context` has `href`, `price`). |
582
+ | `onAddToCart` | `(product) => void \| Promise<void>`. Replaces the default add to cart. |
583
+ | `showCartOnAdd` | Open the cart drawer after the default add to cart. Defaults to `true`. |
584
+ | `className` | Class of the root element. |
585
+
586
+ Prices are in minor units (grosze, cents), as everywhere else in the library.
587
+ Cards show "od {price}" when the variants differ in price, a struck-through
588
+ regular price for discounts and an "unavailable" state for products out of
589
+ stock.
590
+
591
+ ### Add to cart
592
+
593
+ Products the backend marks `addToCart` (a single price, not a subscription) get
594
+ an "Add to cart" button. By default it calls `Bitsnap.addProductToCart` with
595
+ quantity 1 and then opens the cart (`BitsnapCheckout` must be mounted on the
596
+ page, see [Checkout appearance](#checkout-appearance)). The list aligns the
597
+ cart's project ID and host from the list's `projectID`/`host` props, but only
598
+ when the page has not set them yet (`setProjectID`, `setCustomHost`, or the
599
+ cart script tag). When the page cart already belongs to another project or
600
+ host, the list does not take it over: it logs a warning and shows the error
601
+ message, so pass `onAddToCart` there. The cart item is `cartItemId ?? id`, the
602
+ variant ID for single-variant products.
603
+ Products with variants or a subscription link to the product page ("Wybierz" /
604
+ "Zobacz"). Pass `onAddToCart` to do something else, for example to use your own
605
+ cart.
606
+
607
+ ### Server rendering
608
+
609
+ ```tsx
610
+ const firstPage = await fetch(
611
+ "https://bitsnap.pl/api/integrations/your-project-id/public-commerce/product-list?limit=24&offset=0",
612
+ ).then((response) => response.json());
613
+
614
+ <ProductList projectID="your-project-id" pageSize={24} initialData={firstPage} />;
615
+ ```
616
+
617
+ Without `initialData` the server renders a loading skeleton and the browser
618
+ fetches the first page. The component never reads `window` while rendering.
619
+
620
+ ### Appearance and texts
621
+
622
+ ```tsx
623
+ <ProductList
624
+ projectID="your-project-id"
625
+ appearance={{
626
+ theme: "dark",
627
+ tokens: { buttonBackground: "#635bff", radius: "12px", fontFamily: "Inter" },
628
+ elements: { card: { className: "my-card" }, name: { style: { fontSize: 18 } } },
629
+ }}
630
+ texts={{ addToCart: "Do koszyka" }}
631
+ />
632
+ ```
633
+
634
+ Tokens: `fontFamily`, `fontSize`, `background`, `surface`, `foreground`,
635
+ `mutedForeground`, `border`, `buttonBackground`, `buttonForeground`,
636
+ `buttonHoverBackground`, `hoverSurface`, `focusRing`, `error`, `badgeBackground`,
637
+ `badgeForeground`, `radius`. Slots (`PRODUCT_LIST_SLOT_NAMES`, also exposed as
638
+ `data-bitsnap-products-slot`): `root`, `grid`, `card`, `cardLink`, `image`,
639
+ `imagePlaceholder`, `body`, `name`, `description`, `price`, `comparePrice`,
640
+ `badge`, `actions`, `addToCartButton`, `selectButton`, `message`, `pagination`,
641
+ `paginationButton`, `pageIndicator`, `emptyState`, `error`, `retryButton`,
642
+ `skeleton`. All rules are scoped to `[data-bitsnap-products]`.
643
+
644
+ ### `useProducts`
645
+
646
+ Build your own layout on the same data:
647
+
648
+ ```tsx
649
+ const { products, totalCount, page, pageCount, setPage, isLoading, error, refetch } =
650
+ useProducts({ projectID: "your-project-id", pageSize: 12, search });
651
+ ```
652
+
653
+ It uses a plain `fetch` without credentials, does not read the global project ID
654
+ or host, aborts the request when the inputs change, does nothing during server
655
+ rendering and uses `initialData` for the first request instead of fetching
656
+ (so it must be page 1 for the same options). If the catalog shrinks below the
657
+ current page, `page` falls back to the last page. `page` starts at 1; `products` keeps the previous page while the next one
658
+ loads.
659
+
660
+ ### Embedding on your own site (CORS)
661
+
662
+ The list calls `GET {host}/api/integrations/{projectID}/public-commerce/product-list`
663
+ from the browser. The domain of the embedding site must be known to the project:
664
+ add it to the project's site, success or cancel URLs, or to the allowed domains
665
+ in the Bitsnap dashboard. Otherwise the browser blocks the response. On a Bitsnap
666
+ custom domain nothing has to be configured.
667
+
533
668
  # Examples
534
669
 
535
670
  1. `BitsnapCheckout` Component:
@@ -0,0 +1,2 @@
1
+ import{L as c,M as d,N as e,O as f,P as g,Q as h,R as i}from"./chunk-6N24OFUB.mjs";import"./chunk-4HOZFM6V.mjs";import{k as a,l as b}from"./chunk-3TENJTY4.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,h as default,i as getCheckoutMethods,b as getLocale,f as getProjectID,a as setLocale,e as setProjectID,g as useCartProvider};
2
+ //# sourceMappingURL=CartProvider-FQCDE3HZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ .bitsnap-react #audio-player-container{--seek-before-width: 0%;--buffered-width: 0%}.bitsnap-react input[type=range]{position:relative;-webkit-appearance:none;width:100%;margin:0;padding:0;height:19px;float:left;outline:none;background:transparent}.bitsnap-react input[type=range]::-webkit-slider-runnable-track{width:100%;height:3px;cursor:pointer;background:#d9d9d9}.bitsnap-react input[type=range]:before{position:absolute;content:"";top:8px;left:0;width:var(--seek-before-width);height:3px;background-color:#8c8c8c;cursor:pointer}.bitsnap-react input[type=range]::-webkit-slider-thumb{position:relative;-webkit-appearance:none;box-sizing:content-box;border:1px solid #d9d9d9;height:15px;width:15px;border-radius:50%;background-color:#8c8c8c;cursor:pointer;margin:-7px 0 0}.bitsnap-react input[type=range]:active::-webkit-slider-thumb{transform:scale(1.2);background:#e2e8f0}.bitsnap-react input[type=range]::-moz-range-track{width:100%;height:3px;cursor:pointer;background:linear-gradient(to right,rgba(0,125,181,.6) var(--buffered-width),rgba(0,125,181,.2) var(--buffered-width))}.bitsnap-react input[type=range]::-moz-range-progress{background-color:#007db5}.bitsnap-react input[type=range]::-moz-focus-outer{border:0}.bitsnap-react input[type=range]::-moz-range-thumb{box-sizing:content-box;border:1px solid #007db5;height:15px;width:15px;border-radius:50%;background-color:#fff;cursor:pointer}.bitsnap-react input[type=range]:active::-moz-range-thumb{transform:scale(1.2);background:#007db5}.bitsnap-react input[type=range]::-ms-track{width:100%;height:3px;cursor:pointer;background:transparent;border:solid transparent;color:transparent}.bitsnap-react input[type=range]::-ms-fill-lower{background-color:#007db5}.bitsnap-react input[type=range]::-ms-fill-upper{background:linear-gradient(to right,rgba(0,125,181,.6) var(--buffered-width),rgba(0,125,181,.2) var(--buffered-width))}.bitsnap-react input[type=range]::-ms-thumb{box-sizing:content-box;border:1px solid #007db5;height:15px;width:15px;border-radius:50%;background-color:#fff;cursor:pointer}.bitsnap-react input[type=range]:active::-ms-thumb{transform:scale(1.2);background:#007db5}.bitsnap-react .SliderRoot{position:relative;display:flex;align-items:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:none;width:200px;height:20px}.bitsnap-react .SliderTrack{background-color:var(--black-a10);position:relative;flex-grow:1;border-radius:9999px;height:3px}.bitsnap-react .SliderRange{position:absolute;background-color:#fff;border-radius:9999px;height:100%}.bitsnap-react .SliderThumb{display:block;width:20px;height:20px;background-color:#fff;box-shadow:0 2px 10px var(--black-a7);border-radius:10px}.bitsnap-react .SliderThumb:hover{background-color:var(--violet-3)}.bitsnap-react .SliderThumb:focus{outline:none;box-shadow:0 0 0 5px var(--black-a8)}
2
+ /*# sourceMappingURL=CartProvider-PDEV6GCV.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/panel/audio-player/audio-player.css"],"sourcesContent":[".bitsnap-react #audio-player-container {\n --seek-before-width: 0%;\n --buffered-width: 0%;\n}\n\n.bitsnap-react input[type=\"range\"] {\n position: relative;\n -webkit-appearance: none;\n width: 100%;\n margin: 0;\n padding: 0;\n height: 19px;\n float: left;\n outline: none;\n background: transparent;\n}\n.bitsnap-react input[type=\"range\"]::-webkit-slider-runnable-track {\n width: 100%;\n height: 3px;\n cursor: pointer;\n /*background: linear-gradient(to right, rgba(0, 125, 181, 0.6) var(--buffered-width), rgba(0, 125, 181, 0.2) var(--buffered-width));*/\n background: #d9d9d9;\n}\n.bitsnap-react input[type=\"range\"]::before {\n position: absolute;\n content: \"\";\n top: 8px;\n left: 0;\n width: var(--seek-before-width);\n height: 3px;\n background-color: #8c8c8c;\n cursor: pointer;\n}\n.bitsnap-react input[type=\"range\"]::-webkit-slider-thumb {\n position: relative;\n -webkit-appearance: none;\n box-sizing: content-box;\n border: 1px solid #d9d9d9;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: #8c8c8c;\n cursor: pointer;\n margin: -7px 0 0 0;\n}\n.bitsnap-react input[type=\"range\"]:active::-webkit-slider-thumb {\n transform: scale(1.2);\n background: #e2e8f0;\n}\n.bitsnap-react input[type=\"range\"]::-moz-range-track {\n width: 100%;\n height: 3px;\n cursor: pointer;\n background: linear-gradient(\n to right,\n rgba(0, 125, 181, 0.6) var(--buffered-width),\n rgba(0, 125, 181, 0.2) var(--buffered-width)\n );\n}\n.bitsnap-react input[type=\"range\"]::-moz-range-progress {\n background-color: #007db5;\n}\n.bitsnap-react input[type=\"range\"]::-moz-focus-outer {\n border: 0;\n}\n.bitsnap-react input[type=\"range\"]::-moz-range-thumb {\n box-sizing: content-box;\n border: 1px solid #007db5;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n}\n.bitsnap-react input[type=\"range\"]:active::-moz-range-thumb {\n transform: scale(1.2);\n background: #007db5;\n}\n.bitsnap-react input[type=\"range\"]::-ms-track {\n width: 100%;\n height: 3px;\n cursor: pointer;\n background: transparent;\n border: solid transparent;\n color: transparent;\n}\n.bitsnap-react input[type=\"range\"]::-ms-fill-lower {\n background-color: #007db5;\n}\n.bitsnap-react input[type=\"range\"]::-ms-fill-upper {\n background: linear-gradient(\n to right,\n rgba(0, 125, 181, 0.6) var(--buffered-width),\n rgba(0, 125, 181, 0.2) var(--buffered-width)\n );\n}\n.bitsnap-react input[type=\"range\"]::-ms-thumb {\n box-sizing: content-box;\n border: 1px solid #007db5;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n}\n.bitsnap-react input[type=\"range\"]:active::-ms-thumb {\n transform: scale(1.2);\n background: #007db5;\n}\n\n.bitsnap-react .SliderRoot {\n position: relative;\n display: flex;\n align-items: center;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n touch-action: none;\n width: 200px;\n height: 20px;\n}\n\n.bitsnap-react .SliderTrack {\n background-color: var(--black-a10);\n position: relative;\n flex-grow: 1;\n border-radius: 9999px;\n height: 3px;\n}\n\n.bitsnap-react .SliderRange {\n position: absolute;\n background-color: white;\n border-radius: 9999px;\n height: 100%;\n}\n\n.bitsnap-react .SliderThumb {\n display: block;\n width: 20px;\n height: 20px;\n background-color: white;\n box-shadow: 0 2px 10px var(--black-a7);\n border-radius: 10px;\n}\n.bitsnap-react .SliderThumb:hover {\n background-color: var(--violet-3);\n}\n.bitsnap-react .SliderThumb:focus {\n outline: none;\n box-shadow: 0 0 0 5px var(--black-a8);\n}\n"],"mappings":"AAAA,CAAC,cAAc,CAAC,uBACd,qBAAqB,GACrB,kBAAkB,EACpB,CAEA,CALC,cAKc,KAAK,CAAC,YACnB,SAAU,SACV,mBAAoB,KACpB,MAAO,KART,OASU,EATV,QAUW,EACT,OAAQ,KACR,MAAO,KACP,QAAS,KACT,WAAY,WACd,CACA,CAhBC,cAgBc,KAAK,CAAC,WAAa,gCAChC,MA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A,CAzFC,cAyFc,KAAK,CAAC,WAAa,iBAChC,WAAY,gBACV,GAAG,KAAK,CACR,KAAK,CAAC,CAAE,GAAG,CAAE,GAAG,CAAE,IAAK,IAAI,iBAAiB,CAC5C,KAAK,CAAC,CAAE,GAAG,CAAE,GAAG,CAAE,IAAK,IAAI,kBAE/B,CACA,CAhGC,cAgGc,KAAK,CAAC,WAAa,YAChC,WAAY,YACZ,OAAQ,IAAI,MAAM,QAClB,OAAQ,KACR,MAAO,KApGT,cAqGiB,IACf,iBAAkB,KAClB,OAAQ,OACV,CACA,CAzGC,cAyGc,KAAK,CAAC,WAAa,OAAO,YACvC,UAAW,MAAM,KACjB,WAAY,OACd,CAEA,CA9GC,cA8Gc,CAAC,WACd,SAAU,SACV,QAAS,KACT,YAAa,OACb,oBAAqB,KAClB,iBAAkB,KACb,YAAa,KACrB,aAAc,KACd,MAAO,MACP,OAAQ,IACV,CAEA,CA1HC,cA0Hc,CAAC,YACd,iBAAkB,IAAI,aACtB,SAAU,SACV,UAAW,EA7Hb,cA8HiB,OACf,OAAQ,GACV,CAEA,CAlIC,cAkIc,CAAC,YACd,SAAU,SACV,iBAAkB,KApIpB,cAqIiB,OACf,OAAQ,IACV,CAEA,CAzIC,cAyIc,CAAC,YACd,QAAS,MACT,MAAO,KACP,OAAQ,KACR,iBAAkB,KAClB,WAAY,EAAE,IAAI,KAAK,IAAI,YA9I7B,cA+IiB,IACjB,CACA,CAjJC,cAiJc,CARC,WAQW,OACzB,iBAAkB,IAAI,WACxB,CACA,CApJC,cAoJc,CAXC,WAWW,OACzB,QAAS,KACT,WAAY,EAAE,EAAE,EAAE,IAAI,IAAI,WAC5B","names":[]}
@@ -0,0 +1,19 @@
1
+ import { CSSProperties } from 'react';
2
+
3
+ /**
4
+ * Generic building blocks shared by the appearance modules (checkout, and
5
+ * later returns). Each module supplies its own token to CSS variable map, theme
6
+ * presets and shadcn mapping, and keeps its own public types. Everything here
7
+ * is pure so it can be tested without a DOM.
8
+ */
9
+ /** Caller overrides for a single slot. */
10
+ type SlotAppearance = {
11
+ /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */
12
+ className?: string;
13
+ /** Merged after the built-in inline styles. */
14
+ style?: CSSProperties;
15
+ };
16
+ /** Typed partial map of slot name to its overrides. */
17
+ type AppearanceElements<Slot extends string> = Partial<Record<Slot, SlotAppearance>>;
18
+
19
+ export type { AppearanceElements as A, SlotAppearance as S };
@@ -0,0 +1,19 @@
1
+ import { CSSProperties } from 'react';
2
+
3
+ /**
4
+ * Generic building blocks shared by the appearance modules (checkout, and
5
+ * later returns). Each module supplies its own token to CSS variable map, theme
6
+ * presets and shadcn mapping, and keeps its own public types. Everything here
7
+ * is pure so it can be tested without a DOM.
8
+ */
9
+ /** Caller overrides for a single slot. */
10
+ type SlotAppearance = {
11
+ /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */
12
+ className?: string;
13
+ /** Merged after the built-in inline styles. */
14
+ style?: CSSProperties;
15
+ };
16
+ /** Typed partial map of slot name to its overrides. */
17
+ type AppearanceElements<Slot extends string> = Partial<Record<Slot, SlotAppearance>>;
18
+
19
+ export type { AppearanceElements as A, SlotAppearance as S };
@@ -0,0 +1,2 @@
1
+ .bitsnap-react #audio-player-container{--seek-before-width: 0%;--buffered-width: 0%}.bitsnap-react input[type=range]{position:relative;-webkit-appearance:none;width:100%;margin:0;padding:0;height:19px;float:left;outline:none;background:transparent}.bitsnap-react input[type=range]::-webkit-slider-runnable-track{width:100%;height:3px;cursor:pointer;background:#d9d9d9}.bitsnap-react input[type=range]:before{position:absolute;content:"";top:8px;left:0;width:var(--seek-before-width);height:3px;background-color:#8c8c8c;cursor:pointer}.bitsnap-react input[type=range]::-webkit-slider-thumb{position:relative;-webkit-appearance:none;box-sizing:content-box;border:1px solid #d9d9d9;height:15px;width:15px;border-radius:50%;background-color:#8c8c8c;cursor:pointer;margin:-7px 0 0}.bitsnap-react input[type=range]:active::-webkit-slider-thumb{transform:scale(1.2);background:#e2e8f0}.bitsnap-react input[type=range]::-moz-range-track{width:100%;height:3px;cursor:pointer;background:linear-gradient(to right,rgba(0,125,181,.6) var(--buffered-width),rgba(0,125,181,.2) var(--buffered-width))}.bitsnap-react input[type=range]::-moz-range-progress{background-color:#007db5}.bitsnap-react input[type=range]::-moz-focus-outer{border:0}.bitsnap-react input[type=range]::-moz-range-thumb{box-sizing:content-box;border:1px solid #007db5;height:15px;width:15px;border-radius:50%;background-color:#fff;cursor:pointer}.bitsnap-react input[type=range]:active::-moz-range-thumb{transform:scale(1.2);background:#007db5}.bitsnap-react input[type=range]::-ms-track{width:100%;height:3px;cursor:pointer;background:transparent;border:solid transparent;color:transparent}.bitsnap-react input[type=range]::-ms-fill-lower{background-color:#007db5}.bitsnap-react input[type=range]::-ms-fill-upper{background:linear-gradient(to right,rgba(0,125,181,.6) var(--buffered-width),rgba(0,125,181,.2) var(--buffered-width))}.bitsnap-react input[type=range]::-ms-thumb{box-sizing:content-box;border:1px solid #007db5;height:15px;width:15px;border-radius:50%;background-color:#fff;cursor:pointer}.bitsnap-react input[type=range]:active::-ms-thumb{transform:scale(1.2);background:#007db5}.bitsnap-react .SliderRoot{position:relative;display:flex;align-items:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:none;width:200px;height:20px}.bitsnap-react .SliderTrack{background-color:var(--black-a10);position:relative;flex-grow:1;border-radius:9999px;height:3px}.bitsnap-react .SliderRange{position:absolute;background-color:#fff;border-radius:9999px;height:100%}.bitsnap-react .SliderThumb{display:block;width:20px;height:20px;background-color:#fff;box-shadow:0 2px 10px var(--black-a7);border-radius:10px}.bitsnap-react .SliderThumb:hover{background-color:var(--violet-3)}.bitsnap-react .SliderThumb:focus{outline:none;box-shadow:0 0 0 5px var(--black-a8)}
2
+ /*# sourceMappingURL=catalog.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/panel/audio-player/audio-player.css"],"sourcesContent":[".bitsnap-react #audio-player-container {\n --seek-before-width: 0%;\n --buffered-width: 0%;\n}\n\n.bitsnap-react input[type=\"range\"] {\n position: relative;\n -webkit-appearance: none;\n width: 100%;\n margin: 0;\n padding: 0;\n height: 19px;\n float: left;\n outline: none;\n background: transparent;\n}\n.bitsnap-react input[type=\"range\"]::-webkit-slider-runnable-track {\n width: 100%;\n height: 3px;\n cursor: pointer;\n /*background: linear-gradient(to right, rgba(0, 125, 181, 0.6) var(--buffered-width), rgba(0, 125, 181, 0.2) var(--buffered-width));*/\n background: #d9d9d9;\n}\n.bitsnap-react input[type=\"range\"]::before {\n position: absolute;\n content: \"\";\n top: 8px;\n left: 0;\n width: var(--seek-before-width);\n height: 3px;\n background-color: #8c8c8c;\n cursor: pointer;\n}\n.bitsnap-react input[type=\"range\"]::-webkit-slider-thumb {\n position: relative;\n -webkit-appearance: none;\n box-sizing: content-box;\n border: 1px solid #d9d9d9;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: #8c8c8c;\n cursor: pointer;\n margin: -7px 0 0 0;\n}\n.bitsnap-react input[type=\"range\"]:active::-webkit-slider-thumb {\n transform: scale(1.2);\n background: #e2e8f0;\n}\n.bitsnap-react input[type=\"range\"]::-moz-range-track {\n width: 100%;\n height: 3px;\n cursor: pointer;\n background: linear-gradient(\n to right,\n rgba(0, 125, 181, 0.6) var(--buffered-width),\n rgba(0, 125, 181, 0.2) var(--buffered-width)\n );\n}\n.bitsnap-react input[type=\"range\"]::-moz-range-progress {\n background-color: #007db5;\n}\n.bitsnap-react input[type=\"range\"]::-moz-focus-outer {\n border: 0;\n}\n.bitsnap-react input[type=\"range\"]::-moz-range-thumb {\n box-sizing: content-box;\n border: 1px solid #007db5;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n}\n.bitsnap-react input[type=\"range\"]:active::-moz-range-thumb {\n transform: scale(1.2);\n background: #007db5;\n}\n.bitsnap-react input[type=\"range\"]::-ms-track {\n width: 100%;\n height: 3px;\n cursor: pointer;\n background: transparent;\n border: solid transparent;\n color: transparent;\n}\n.bitsnap-react input[type=\"range\"]::-ms-fill-lower {\n background-color: #007db5;\n}\n.bitsnap-react input[type=\"range\"]::-ms-fill-upper {\n background: linear-gradient(\n to right,\n rgba(0, 125, 181, 0.6) var(--buffered-width),\n rgba(0, 125, 181, 0.2) var(--buffered-width)\n );\n}\n.bitsnap-react input[type=\"range\"]::-ms-thumb {\n box-sizing: content-box;\n border: 1px solid #007db5;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n}\n.bitsnap-react input[type=\"range\"]:active::-ms-thumb {\n transform: scale(1.2);\n background: #007db5;\n}\n\n.bitsnap-react .SliderRoot {\n position: relative;\n display: flex;\n align-items: center;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n touch-action: none;\n width: 200px;\n height: 20px;\n}\n\n.bitsnap-react .SliderTrack {\n background-color: var(--black-a10);\n position: relative;\n flex-grow: 1;\n border-radius: 9999px;\n height: 3px;\n}\n\n.bitsnap-react .SliderRange {\n position: absolute;\n background-color: white;\n border-radius: 9999px;\n height: 100%;\n}\n\n.bitsnap-react .SliderThumb {\n display: block;\n width: 20px;\n height: 20px;\n background-color: white;\n box-shadow: 0 2px 10px var(--black-a7);\n border-radius: 10px;\n}\n.bitsnap-react .SliderThumb:hover {\n background-color: var(--violet-3);\n}\n.bitsnap-react .SliderThumb:focus {\n outline: none;\n box-shadow: 0 0 0 5px var(--black-a8);\n}\n"],"mappings":"AAAA,CAAC,cAAc,CAAC,uBACd,qBAAqB,GACrB,kBAAkB,EACpB,CAEA,CALC,cAKc,KAAK,CAAC,YACnB,SAAU,SACV,mBAAoB,KACpB,MAAO,KART,OASU,EATV,QAUW,EACT,OAAQ,KACR,MAAO,KACP,QAAS,KACT,WAAY,WACd,CACA,CAhBC,cAgBc,KAAK,CAAC,WAAa,gCAChC,MAAO,KACP,OAAQ,IACR,OAAQ,QAER,WAAY,OACd,CACA,CAvBC,cAuBc,KAAK,CAAC,WAAa,QAChC,SAA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AAG,CAAE,GAAG,CAAE,IAAK,IAAI,iBAAiB,CAC5C,KAAK,CAAC,CAAE,GAAG,CAAE,GAAG,CAAE,IAAK,IAAI,kBAE/B,CACA,CAhGC,cAgGc,KAAK,CAAC,WAAa,YAChC,WAAY,YACZ,OAAQ,IAAI,MAAM,QAClB,OAAQ,KACR,MAAO,KApGT,cAqGiB,IACf,iBAAkB,KAClB,OAAQ,OACV,CACA,CAzGC,cAyGc,KAAK,CAAC,WAAa,OAAO,YACvC,UAAW,MAAM,KACjB,WAAY,OACd,CAEA,CA9GC,cA8Gc,CAAC,WACd,SAAU,SACV,QAAS,KACT,YAAa,OACb,oBAAqB,KAClB,iBAAkB,KACb,YAAa,KACrB,aAAc,KACd,MAAO,MACP,OAAQ,IACV,CAEA,CA1HC,cA0Hc,CAAC,YACd,iBAAkB,IAAI,aACtB,SAAU,SACV,UAAW,EA7Hb,cA8HiB,OACf,OAAQ,GACV,CAEA,CAlIC,cAkIc,CAAC,YACd,SAAU,SACV,iBAAkB,KApIpB,cAqIiB,OACf,OAAQ,IACV,CAEA,CAzIC,cAyIc,CAAC,YACd,QAAS,MACT,MAAO,KACP,OAAQ,KACR,iBAAkB,KAClB,WAAY,EAAE,IAAI,KAAK,IAAI,YA9I7B,cA+IiB,IACjB,CACA,CAjJC,cAiJc,CARC,WAQW,OACzB,iBAAkB,IAAI,WACxB,CACA,CApJC,cAoJc,CAXC,WAWW,OACzB,QAAS,KACT,WAAY,EAAE,EAAE,EAAE,IAAI,IAAI,WAC5B","names":[]}
@@ -0,0 +1,214 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { S as SlotAppearance, A as AppearanceElements } from './appearance-core-Dt2grZdl.mjs';
4
+ import { BitsnapModels } from './models.mjs';
5
+ import 'zod';
6
+
7
+ /**
8
+ * Product list appearance API.
9
+ *
10
+ * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,
11
+ * elements) so a shop can reuse one brand object for all of them. The resolver
12
+ * is pure: it turns the caller input into a theme name, the tokens in effect,
13
+ * the slot overrides and the inline style for the theme boundary.
14
+ */
15
+ type ProductListTheme = "light" | "dark";
16
+ type ProductListAppearanceTokens = {
17
+ /** Font family of the list. The library never loads fonts. */
18
+ fontFamily?: string;
19
+ /** Base font size. */
20
+ fontSize?: string;
21
+ /** List background. */
22
+ background?: string;
23
+ /** Raised surfaces: cards, image placeholders, skeletons. */
24
+ surface?: string;
25
+ /** Main text color. */
26
+ foreground?: string;
27
+ /** Secondary text: descriptions, the struck-through price. */
28
+ mutedForeground?: string;
29
+ /** Borders of cards and buttons. */
30
+ border?: string;
31
+ /** "Add to cart" button background. */
32
+ buttonBackground?: string;
33
+ /** "Add to cart" button text. */
34
+ buttonForeground?: string;
35
+ /** "Add to cart" button background on hover. */
36
+ buttonHoverBackground?: string;
37
+ /** Hover surface of cards and secondary buttons. */
38
+ hoverSurface?: string;
39
+ /** Focus ring color. */
40
+ focusRing?: string;
41
+ /** Error and unavailable state color. */
42
+ error?: string;
43
+ /** Badge background (subscription, unavailable). */
44
+ badgeBackground?: string;
45
+ /** Badge text. */
46
+ badgeForeground?: string;
47
+ /** Corner radius of cards, images and buttons. */
48
+ radius?: string;
49
+ };
50
+ /**
51
+ * Stable slot names. They are exposed as `data-bitsnap-products-slot`
52
+ * attributes so they can also be targeted from plain CSS.
53
+ */
54
+ declare const PRODUCT_LIST_SLOT_NAMES: readonly ["root", "grid", "card", "cardLink", "image", "imagePlaceholder", "body", "name", "description", "price", "comparePrice", "badge", "actions", "addToCartButton", "selectButton", "message", "pagination", "paginationButton", "pageIndicator", "emptyState", "error", "retryButton", "skeleton"];
55
+ type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];
56
+ type ProductListSlotAppearance = SlotAppearance;
57
+ type ProductListAppearanceElements = AppearanceElements<ProductListSlotName>;
58
+ type ProductListAppearance = {
59
+ /** `"light"` or `"dark"`. Omitted means `"light"`. */
60
+ theme?: ProductListTheme;
61
+ /** Partial overrides applied over the theme preset. */
62
+ tokens?: ProductListAppearanceTokens;
63
+ /** Per element `className`/`style` overrides. */
64
+ elements?: ProductListAppearanceElements;
65
+ };
66
+
67
+ type PublicListProduct = BitsnapModels.PublicListProduct;
68
+ type ProductListData = BitsnapModels.ProductListResponse;
69
+
70
+ /**
71
+ * Every string `ProductList` renders. Pass a partial object through the
72
+ * `texts` prop to override any of them, whatever the locale. Placeholders
73
+ * (`{price}`, `{page}`, `{pageCount}`) are filled by the component.
74
+ */
75
+ type ProductListTexts = {
76
+ /** "Add to cart" button of products that can be bought straight from the list. */
77
+ addToCart: string;
78
+ /** Button label while the product is being added. */
79
+ addingToCart: string;
80
+ /** Button label after the product was added. */
81
+ addedToCart: string;
82
+ /** Message shown when adding to the cart failed. */
83
+ addToCartError: string;
84
+ /** Link of products with variants, to pick one on the product page. */
85
+ chooseOptions: string;
86
+ /** Link of products that cannot be added from the list (subscriptions). */
87
+ viewProduct: string;
88
+ /** Label of products that are out of stock. */
89
+ unavailable: string;
90
+ /** Badge of subscription products. */
91
+ subscription: string;
92
+ /** Price of products whose variants differ in price. `{price}` is the lowest one. */
93
+ priceFrom: string;
94
+ /** Screen reader label of the struck-through regular price. */
95
+ originalPrice: string;
96
+ /** Accessible label of the loading skeleton. */
97
+ loading: string;
98
+ /** Shown when the shop has no products (or none matches the search). */
99
+ empty: string;
100
+ /** Shown when the products could not be loaded. */
101
+ error: string;
102
+ /** Retry button of the error state. */
103
+ retry: string;
104
+ /** Accessible label of the pagination. */
105
+ pagination: string;
106
+ previousPage: string;
107
+ nextPage: string;
108
+ /** Page indicator. `{page}` and `{pageCount}` are filled in. */
109
+ pageOf: string;
110
+ };
111
+ type ProductListTextKey = keyof ProductListTexts;
112
+
113
+ type UseProductsOptions = {
114
+ /** Project (shop) ID. */
115
+ projectID: string;
116
+ /**
117
+ * Origin of the Bitsnap backend. Defaults to the library host
118
+ * (`https://bitsnap.pl`, or what `setCustomHost` had set when the component
119
+ * first rendered; later `setCustomHost` calls do not move an existing list).
120
+ * On a custom domain pass the domain itself, or an empty string for
121
+ * same-origin requests.
122
+ */
123
+ host?: string;
124
+ locale?: string;
125
+ /** Products per page, 1 to 48. Defaults to 24. */
126
+ pageSize?: number;
127
+ search?: string;
128
+ /**
129
+ * First page, loaded on the server. It is always used for the first request
130
+ * of the mounted list (the first fetch is skipped and the products are
131
+ * available on the first render), so it has to be the page the props ask
132
+ * for: page 1 with the same `pageSize`, `locale` and `search`. Later changes
133
+ * of the props fetch again.
134
+ */
135
+ initialData?: ProductListData;
136
+ };
137
+ type UseProductsResult = {
138
+ /** Products of the current page. Keeps the previous page while loading. */
139
+ products: PublicListProduct[];
140
+ totalCount: number;
141
+ /** Current page, starting at 1. */
142
+ page: number;
143
+ pageCount: number;
144
+ setPage: (page: number) => void;
145
+ /** `true` until the current page is available, also during server rendering. */
146
+ isLoading: boolean;
147
+ error: Error | undefined;
148
+ /** Loads the current page again. */
149
+ refetch: () => void;
150
+ };
151
+ /**
152
+ * Loads the product catalog page by page. It uses a plain `fetch` without
153
+ * credentials, never reads global state (`setProjectID`, `setCustomHost`) other
154
+ * than the default host, and does nothing during server rendering - pass
155
+ * `initialData` to render products in the server HTML.
156
+ */
157
+ declare function useProducts(options: UseProductsOptions): UseProductsResult;
158
+
159
+ /** What `renderItem` gets next to the product. */
160
+ type ProductListItemContext = {
161
+ /** Product page URL from `productHref`. */
162
+ href: string;
163
+ /** Price formatted for the locale and currency, without the "from" prefix. */
164
+ price: string;
165
+ /** Formatted regular price when the product is discounted. */
166
+ compareAtPrice: string | null;
167
+ texts: ProductListTexts;
168
+ locale: string;
169
+ /** Adds the product to the cart the way the built-in button does. */
170
+ addToCart: () => Promise<void>;
171
+ };
172
+ type ProductListProps = UseProductsOptions & {
173
+ /**
174
+ * Product page URL. Defaults to the relative `/p/{uniqueSlug}`, which works
175
+ * on a Bitsnap custom domain. Embedded on another site, return the full
176
+ * URL of the product page.
177
+ */
178
+ productHref?: (product: PublicListProduct) => string;
179
+ appearance?: ProductListAppearance;
180
+ /** Text overrides, applied whatever the locale. */
181
+ texts?: Partial<ProductListTexts>;
182
+ /** Replaces the content of a card. The card frame stays. */
183
+ renderItem?: (product: PublicListProduct, context: ProductListItemContext) => ReactNode;
184
+ /**
185
+ * Called by the "Add to cart" button instead of the default action
186
+ * (`Bitsnap.addProductToCart`). A rejected promise shows the error message.
187
+ */
188
+ onAddToCart?: (product: PublicListProduct) => void | Promise<void>;
189
+ /** Open the cart drawer after the default add to cart. Defaults to `true`. */
190
+ showCartOnAdd?: boolean;
191
+ className?: string;
192
+ };
193
+ /**
194
+ * Responsive grid of the shop's products with pagination, loading, empty and
195
+ * error states. Cards link to the product page and can add to the cart.
196
+ *
197
+ * ```tsx
198
+ * <ProductList projectID="…" locale="pl-PL" initialData={firstPage} />
199
+ * ```
200
+ *
201
+ * It renders on the server: pass `initialData` (the first page, fetched on the
202
+ * server) to have the products in the HTML; without it the server renders the
203
+ * loading skeleton and the browser fetches the first page.
204
+ */
205
+ declare function ProductList({ productHref, appearance, texts, renderItem, onAddToCart, showCartOnAdd, className, ...options }: ProductListProps): react_jsx_runtime.JSX.Element;
206
+
207
+ /**
208
+ * Formats a price in minor units (grosze, cents) for the locale, the same way
209
+ * the cart does (`amount / 100`). An unknown locale falls back to Polish and an
210
+ * invalid currency code to a plain number followed by the code.
211
+ */
212
+ declare function formatProductPrice(amount: number, currency: string, locale?: string): string;
213
+
214
+ export { PRODUCT_LIST_SLOT_NAMES, ProductList, type ProductListAppearance, type ProductListAppearanceElements, type ProductListAppearanceTokens, type ProductListData, type ProductListItemContext, type ProductListProps, type ProductListSlotAppearance, type ProductListSlotName, type ProductListTextKey, type ProductListTexts, type ProductListTheme, type PublicListProduct, type UseProductsOptions, type UseProductsResult, formatProductPrice, useProducts };