@okendo/shopify-hydrogen 2.4.0 → 2.5.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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@remix-run/react"),t=require("react");const n=t.createContext(void 0),r=({children:e})=>{const[r,o]=t.useState(!1);return t.createElement(n.Provider,{value:{okendoDataLoaded:r,setOkendoDataLoaded:o}},e)},o=()=>{const e=t.useContext(n);return void 0===e?null:e},a=/^[0-9]*$/,s="app--1576377";function i(e){if(e)return`shopify-${a.test(e)?e:e.split("/").slice(-1)[0]}`}const d="cdn-static.okendo.io",l=({nonce:e="",okendoProviderData:n,productUrlFormatter:r,awaited:a,cdnDomain:s})=>{const i=o(),l=t.useRef(!1),c=t.useRef(!1);if(t.useEffect((()=>{if(n&&n.loyaltySettings&&!1===l.current){const e=document.createElement("script");e.src=`https://${s||d}/loyalty/js/init-onsite.js`,document.head.appendChild(e);const t=document.createElement("script");t.type="application/json",t.id="oke-loyalty-settings";const r=n.loyaltySettings?n.loyaltySettings.replace('<script type="application/json" id="oke-loyalty-settings">',"").replace('<\/script><script src="https://rhys-cdn.okendo.dev/loyalty/js/init-onsite.js" defer><\/script>',""):"";t.innerHTML=r,document.head.appendChild(t),l.current=!0}}),[n,s]),t.useEffect((()=>{if(n&&i?.setOkendoDataLoaded(!0),n&&a&&!c.current){const e=document.createElement("script");e.src=`https://${s||d}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),c.current=!0}}),[n,i,a,s]),!n)return null;const{reviewsHeaderConfig:u,cssVariables:p,customCss:m,initScriptContents:y,preRenderStyleTags:g,starSymbols:v}=n,k=(p??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),w=m?m.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return t.createElement(t.Fragment,null,t.createElement("script",{nonce:e,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(u)}}),t.createElement("style",{nonce:e,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:k}}),w&&t.createElement("style",{nonce:e,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:w}}),!a&&y&&t.createElement("script",{nonce:e,dangerouslySetInnerHTML:{__html:y}}),t.createElement("script",{nonce:e,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof r?r.toString():"string"==typeof r?r:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),g&&t.createElement("div",{dangerouslySetInnerHTML:{__html:g}}),v&&t.createElement("div",{dangerouslySetInnerHTML:{__html:v}}))};const c=({dataAttributes:e,metafieldContent:n=""})=>{const r=t.useRef(null),o=t.useRef(!1),a=function(e){const n=t.useRef();return t.useEffect((()=>{n.current=e})),n.current}(e),s=()=>{r.current&&(window.okeWidgetApi.initWidget(r.current),o.current=!0)};return t.useEffect((()=>{if(!a||e["data-oke-widget"]!==a["data-oke-widget"]||e["data-oke-star-rating"]!==a["data-oke-star-rating"]||e["data-oke-reviews-product-id"]!==a["data-oke-reviews-product-id"]||!o.current)return window.okeWidgetApi&&r.current?s():document.addEventListener("oke-script-loaded",s),()=>{document.removeEventListener("oke-script-loaded",s)}}),[e,a]),t.createElement("div",{ref:r,key:JSON.stringify(e),...e,dangerouslySetInnerHTML:n?{__html:n}:void 0})},u=`#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "${s}--reviews"\n\t\t\tkey: "star_rating_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`,p=`#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "${s}--reviews"\n\t\t\tkey: "reviews_widget_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`;exports.OKENDO_PRODUCT_REVIEWS_FRAGMENT=p,exports.OKENDO_PRODUCT_STAR_RATING_FRAGMENT=u,exports.OkendoLoyaltyEmbeddedWidget=function(){const n=e.useLocation();return t.useEffect((()=>{window?.okeLoyaltyApi?.initialiseWidgets()}),[n.pathname]),t.createElement("div",{"data-oke-loyalty-embedded-widget":""})},exports.OkendoProvider=({nonce:n="",okendoProviderData:o,customerAccessToken:a,productUrlFormatter:s,cdnDomain:i,children:d})=>t.createElement(r,null,o&&"then"in o?t.createElement(t.Suspense,null,t.createElement(e.Await,{resolve:o},(e=>t.createElement(l,{nonce:n,okendoProviderData:e,productUrlFormatter:s,cdnDomain:i,awaited:!0})))):t.createElement(l,{nonce:n,okendoProviderData:o,productUrlFormatter:s,cdnDomain:i}),a&&t.createElement("script",{nonce:n,id:"oke-loyalty-customer-access-token",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify({customerAccessToken:a})}}),d),exports.OkendoReviews=({productId:e,okendoReviewsSnippet:n,placeholder:r})=>{const a=o(),s=e?.length?i(e):null,d=e?.length?n:null,l={"data-oke-widget":"","data-oke-reviews-product-id":s};return null===a||a.okendoDataLoaded?t.createElement(c,{dataAttributes:l,metafieldContent:d?.value}):r||t.createElement("div",{style:{height:"350px"}})},exports.OkendoReviewsCarousel=({productId:e,groupId:n,headerBadgeUrl:r,placeholder:a})=>{const s=o(),d={"data-oke-carousel":"","data-oke-reviews-product-id":e?.length?i(e):null,"data-oke-reviews-group-id":n?.length?n:null,"data-oke-header-badge-url":r};return null===s||s.okendoDataLoaded?t.createElement(c,{dataAttributes:d}):a||t.createElement("div",{style:{height:"350px"}})},exports.OkendoStarRating=({productId:e,okendoStarRatingSnippet:n,placeholder:r})=>{const a=o(),s={"data-oke-star-rating":"","data-oke-reviews-product-id":i(e)};return null===a||a.okendoDataLoaded?t.createElement(c,{dataAttributes:s,metafieldContent:n?.value}):r||t.createElement("div",{style:{height:"20px"}})},exports.getOkendoProviderData=async({context:e,subscriberId:t,apiDomain:n,cdnDomain:r,okendoProducts:o=["reviews"],appNamespace:a})=>{if(!o.length)return null;const i=`loyaltySettings: metafield(\n namespace: "${a??s}--loyalty",\n key: "loyalty_settings"\n ) {\n value\n }`,l=`widgetPreRenderStyleTags: metafield(\n namespace: "${a??s}--reviews",\n key: "widget_pre_render_style_tags"\n ) {\n value\n }`,c=`#graphql\n query metafields {\n shop {\n ${o.includes("loyalty")?i:""}\n ${o.includes("reviews")?l:""}\n }\n }\n `,{shop:{loyaltySettings:u,widgetPreRenderStyleTags:p}}=await e.storefront.query(c);let m=null;if(o.includes("loyalty")&&(m={...m??{},loyaltySettings:u?.value??""}),o.includes("reviews")){const e=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,o=await fetch(e);if(!o.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),m;const{reviewsHeaderConfig:a,cssVariables:s,customCss:i,starSymbols:l}=await o.json(),c=await fetch(`https://${r||d}/reviews-widget-plus/js/okendo-reviews.js`);if(!c.ok)return console.error("Failed to retrieve widget initialisation script."),m;const u=await c.text(),y=p?.value??"";y||console.warn("Failed to retrieve pre-rendered widget style settings."),m={...m??{},reviewsHeaderConfig:a,cssVariables:s,customCss:i,initScriptContents:u,preRenderStyleTags:y,starSymbols:l}}return m};
1
+ "use strict";var e=require("react-router"),t=require("react");const n=/^[0-9]*$/,r="app--1576377";function s(e){if(e)return`shopify-${n.test(e)?e:e.split("/").slice(-1)[0]}`}const a="cdn-static.okendo.io",o=({nonce:e="",okendoProviderData:n,productUrlFormatter:r,cdnDomain:s})=>{const o=t.useRef(!1),i=t.useRef(!1);if(t.useEffect((()=>{if(n&&n.loyaltySettings&&!1===o.current){const e=document.createElement("script");e.src=`https://${s||a}/loyalty/js/init-onsite.js`,document.head.appendChild(e);const t=document.createElement("script");t.type="application/json",t.id="oke-loyalty-settings";const r=n.loyaltySettings?n.loyaltySettings.replaceAll(/<\/?script.*?>/g,""):"";t.innerHTML=r,document.head.appendChild(t),o.current=!0}}),[n,s]),t.useEffect((()=>{if(n&&!i.current){const e=document.createElement("script");e.src=`https://${s||a}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),i.current=!0}}),[n,s]),!n)return null;const{reviewsHeaderConfig:d,cssVariables:l,customCss:c,preRenderStyleTags:u,starSymbols:p}=n,m=(l??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),y=c?c.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return t.createElement(t.Fragment,null,t.createElement("script",{nonce:e,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(d)}}),t.createElement("style",{nonce:e,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:m}}),y&&t.createElement("style",{nonce:e,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:y}}),t.createElement("script",{nonce:e,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof r?r.toString():"string"==typeof r?r:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),u&&t.createElement("div",{dangerouslySetInnerHTML:{__html:u}}),p&&t.createElement("div",{dangerouslySetInnerHTML:{__html:p}}))};const i=({style:e,className:n,dataAttributes:r,metafieldContent:s=""})=>{const a=t.useRef(null),o=t.useRef(!1),i=function(e){const n=t.useRef();return t.useEffect((()=>{n.current=e})),n.current}(r),d=()=>{a.current&&(window.okeWidgetApi.initWidget(a.current),o.current=!0)};return t.useEffect((()=>{if(!i||r["data-oke-widget"]!==i["data-oke-widget"]||r["data-oke-star-rating"]!==i["data-oke-star-rating"]||r["data-oke-reviews-product-id"]!==i["data-oke-reviews-product-id"]||!o.current)return window.okeWidgetApi&&a.current?d():document.addEventListener("oke-script-loaded",d),()=>{document.removeEventListener("oke-script-loaded",d)}}),[r,i]),t.createElement("div",{ref:a,style:e,className:n,key:JSON.stringify(r),...r,dangerouslySetInnerHTML:s?{__html:s}:void 0})},d=`#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "${r}--reviews"\n\t\t\tkey: "star_rating_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`,l=`#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "${r}--reviews"\n\t\t\tkey: "reviews_widget_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`;exports.OKENDO_PRODUCT_REVIEWS_FRAGMENT=l,exports.OKENDO_PRODUCT_STAR_RATING_FRAGMENT=d,exports.OkendoLoyaltyEmbeddedWidget=function(){const n=e.useLocation();return t.useEffect((()=>{window?.okeLoyaltyApi?.initialiseWidgets()}),[n.pathname]),t.createElement("div",{"data-oke-loyalty-embedded-widget":""})},exports.OkendoProvider=({nonce:n="",okendoProviderData:r,customerAccessToken:s,productUrlFormatter:a,cdnDomain:i,children:d})=>t.createElement(t.Fragment,null,t.createElement(t.Suspense,null,t.createElement(e.Await,{resolve:r},(e=>t.createElement(o,{nonce:n,okendoProviderData:e,productUrlFormatter:a,cdnDomain:i})))),s&&t.createElement("script",{nonce:n,id:"oke-loyalty-customer-access-token",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify({customerAccessToken:s})}}),d),exports.OkendoReviews=({style:e,className:n,productId:r,okendoReviewsSnippet:a})=>{const o=r?.length?s(r):null,d=r?.length?a:null,l={"data-oke-widget":"","data-oke-reviews-product-id":o};return t.createElement(i,{style:e,className:n,dataAttributes:l,metafieldContent:d?.value})},exports.OkendoReviewsCarousel=({style:e,className:n,productId:r,groupId:a,headerBadgeUrl:o})=>{const d={"data-oke-carousel":"","data-oke-reviews-product-id":r?.length?s(r):null,"data-oke-reviews-group-id":a?.length?a:null,"data-oke-header-badge-url":o};return t.createElement(i,{style:e,className:n,dataAttributes:d})},exports.OkendoStarRating=({style:e,className:n,productId:r,okendoStarRatingSnippet:a})=>{const o={"data-oke-star-rating":"","data-oke-reviews-product-id":s(r)};return t.createElement(i,{style:e,className:n,dataAttributes:o,metafieldContent:a?.value})},exports.getOkendoProviderData=async({context:e,subscriberId:t,apiDomain:n,okendoProducts:s=["reviews"],appNamespace:a})=>{if(!s.length)return null;const o=`loyaltySettings: metafield(\n namespace: "${a??r}--loyalty",\n key: "loyalty_settings"\n ) {\n value\n }`,i=`widgetPreRenderStyleTags: metafield(\n namespace: "${a??r}--reviews",\n key: "widget_pre_render_style_tags"\n ) {\n value\n }`,d=`#graphql\n query metafields {\n shop {\n ${s.includes("loyalty")?o:""}\n ${s.includes("reviews")?i:""}\n }\n }\n `,{shop:{loyaltySettings:l,widgetPreRenderStyleTags:c}}=await e.storefront.query(d);let u=null;if(s.includes("loyalty")&&(u={...u??{},loyaltySettings:l?.value??""}),s.includes("reviews")){const e=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,r=await fetch(e);if(!r.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),u;const{reviewsHeaderConfig:s,cssVariables:a,customCss:o,starSymbols:i}=await r.json(),d=c?.value??"";d||console.warn("Failed to retrieve pre-rendered widget style settings."),u={...u??{},reviewsHeaderConfig:s,cssVariables:a,customCss:o,preRenderStyleTags:d,starSymbols:i}}return u};
@@ -7,18 +7,16 @@ interface OkendoReviewsProviderData {
7
7
  reviewsHeaderConfig: WidgetPlus.ReviewsHeaderConfig;
8
8
  cssVariables: string;
9
9
  customCss?: string;
10
- initScriptContents: string;
11
10
  preRenderStyleTags: string;
12
11
  starSymbols: string;
13
12
  }
14
13
  interface OkendoLoyaltyProviderData {
15
14
  loyaltySettings: string;
16
15
  }
17
- export declare const getOkendoProviderData: ({ context, subscriberId, apiDomain, cdnDomain, okendoProducts, appNamespace, }: {
16
+ export declare const getOkendoProviderData: ({ context, subscriberId, apiDomain, okendoProducts, appNamespace, }: {
18
17
  context: StorefrontContext;
19
18
  subscriberId: string;
20
19
  apiDomain?: string;
21
- cdnDomain?: string;
22
20
  okendoProducts?: OkendoProduct[];
23
21
  appNamespace?: string;
24
22
  }) => Promise<OkendoProviderData | null>;
@@ -38,13 +36,9 @@ interface OkendoProviderProps {
38
36
  */
39
37
  nonce?: string;
40
38
  /**
41
- * Either:
42
- * - the data returned by the promise returned by `getOkendoProviderData`, using this will allow the
43
- * Okendo widgets to show instantly on page load, but it will slightly increase the page load time;
44
- * - the promise returned by `getOkendoProviderData`, using this will make the Okendo widgets
45
- * show slightly after page load, but it have the advantage of not increasing the page load time.
39
+ * The promise returned by `getOkendoProviderData`.
46
40
  */
47
- okendoProviderData: Partial<OkendoProviderData> | null | Promise<Partial<OkendoProviderData> | null>;
41
+ okendoProviderData: Promise<OkendoProviderData | null>;
48
42
  /**
49
43
  * Used by the loyalty widget to verify the user's identity via the Storefront API.
50
44
  * Can be retrieved via `await context.customerAccount.getAccessToken()` in the loader function.
@@ -1,16 +1,13 @@
1
- import React from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  import { type MetafieldValue } from '../../internal/types';
3
3
  export interface WithOkendoReviewsSnippet {
4
4
  okendoReviewsSnippet?: MetafieldValue | null;
5
5
  }
6
6
  interface OkendoReviewsProps {
7
+ style?: CSSProperties;
8
+ className?: string;
7
9
  productId?: string;
8
10
  okendoReviewsSnippet?: MetafieldValue | null;
9
- /**
10
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
11
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
12
- */
13
- placeholder?: JSX.Element;
14
11
  }
15
- export declare const OkendoReviews: ({ productId, okendoReviewsSnippet, placeholder }: OkendoReviewsProps) => React.JSX.Element;
12
+ export declare const OkendoReviews: ({ style, className, productId, okendoReviewsSnippet }: OkendoReviewsProps) => React.JSX.Element;
16
13
  export {};
@@ -1,13 +1,10 @@
1
- import React from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  interface OkendoReviewsCarouselProps {
3
+ style?: CSSProperties;
4
+ className?: string;
3
5
  productId?: string;
4
6
  groupId?: string;
5
7
  headerBadgeUrl?: string;
6
- /**
7
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
8
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
9
- */
10
- placeholder?: JSX.Element;
11
8
  }
12
- export declare const OkendoReviewsCarousel: ({ productId, groupId, headerBadgeUrl, placeholder }: OkendoReviewsCarouselProps) => React.JSX.Element;
9
+ export declare const OkendoReviewsCarousel: ({ style, className, productId, groupId, headerBadgeUrl }: OkendoReviewsCarouselProps) => React.JSX.Element;
13
10
  export {};
@@ -1,16 +1,13 @@
1
- import React, { type ReactNode } from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  import { type MetafieldValue } from '../../internal/types';
3
3
  export interface WithOkendoStarRatingSnippet {
4
4
  okendoStarRatingSnippet?: MetafieldValue | null;
5
5
  }
6
6
  interface OkendoStarRatingProps {
7
+ style?: CSSProperties;
8
+ className?: string;
7
9
  productId: string;
8
10
  okendoStarRatingSnippet?: MetafieldValue | null;
9
- /**
10
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
11
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
12
- */
13
- placeholder?: ReactNode;
14
11
  }
15
- export declare const OkendoStarRating: ({ productId, okendoStarRatingSnippet, placeholder }: OkendoStarRatingProps) => string | number | true | React.JSX.Element | Iterable<React.ReactNode>;
12
+ export declare const OkendoStarRating: ({ style, className, productId, okendoStarRatingSnippet }: OkendoStarRatingProps) => React.JSX.Element;
16
13
  export {};
@@ -1,6 +1,8 @@
1
1
  import type { ReviewsWidgetPlus } from '@okendo/reviews-widget-plus/dist-utils/ReviewsWidgetPlus';
2
- import React from 'react';
2
+ import React, { type CSSProperties } from 'react';
3
3
  export interface OkendoWidgetProps {
4
+ style?: CSSProperties;
5
+ className?: string;
4
6
  dataAttributes: {
5
7
  'data-oke-widget'?: string;
6
8
  'data-oke-star-rating'?: string;
@@ -13,4 +15,4 @@ declare global {
13
15
  okeWidgetApi: ReviewsWidgetPlus.WidgetWindowApi;
14
16
  }
15
17
  }
16
- export declare const OkendoWidget: ({ dataAttributes, metafieldContent }: OkendoWidgetProps) => React.JSX.Element;
18
+ export declare const OkendoWidget: ({ style, className, dataAttributes, metafieldContent }: OkendoWidgetProps) => React.JSX.Element;
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{useLocation as e,Await as t}from"@remix-run/react";import n,{useEffect as r,createContext as o,useState as a,useContext as i,Suspense as s,useRef as d}from"react";function l(){const t=e();return r((()=>{window?.okeLoyaltyApi?.initialiseWidgets()}),[t.pathname]),n.createElement("div",{"data-oke-loyalty-embedded-widget":""})}const c=o(void 0),u=({children:e})=>{const[t,r]=a(!1);return n.createElement(c.Provider,{value:{okendoDataLoaded:t,setOkendoDataLoaded:r}},e)},p=()=>{const e=i(c);return void 0===e?null:e},m=/^[0-9]*$/,y="app--1576377";function g(e){if(e)return`shopify-${m.test(e)?e:e.split("/").slice(-1)[0]}`}const v="cdn-static.okendo.io",k=async({context:e,subscriberId:t,apiDomain:n,cdnDomain:r,okendoProducts:o=["reviews"],appNamespace:a})=>{if(!o.length)return null;const i=`loyaltySettings: metafield(\n namespace: "${a??y}--loyalty",\n key: "loyalty_settings"\n ) {\n value\n }`,s=`widgetPreRenderStyleTags: metafield(\n namespace: "${a??y}--reviews",\n key: "widget_pre_render_style_tags"\n ) {\n value\n }`,d=`#graphql\n query metafields {\n shop {\n ${o.includes("loyalty")?i:""}\n ${o.includes("reviews")?s:""}\n }\n }\n `,{shop:{loyaltySettings:l,widgetPreRenderStyleTags:c}}=await e.storefront.query(d);let u=null;if(o.includes("loyalty")&&(u={...u??{},loyaltySettings:l?.value??""}),o.includes("reviews")){const e=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,o=await fetch(e);if(!o.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),u;const{reviewsHeaderConfig:a,cssVariables:i,customCss:s,starSymbols:d}=await o.json(),l=await fetch(`https://${r||v}/reviews-widget-plus/js/okendo-reviews.js`);if(!l.ok)return console.error("Failed to retrieve widget initialisation script."),u;const p=await l.text(),m=c?.value??"";m||console.warn("Failed to retrieve pre-rendered widget style settings."),u={...u??{},reviewsHeaderConfig:a,cssVariables:i,customCss:s,initScriptContents:p,preRenderStyleTags:m,starSymbols:d}}return u},w=({nonce:e="",okendoProviderData:r,customerAccessToken:o,productUrlFormatter:a,cdnDomain:i,children:d})=>n.createElement(u,null,r&&"then"in r?n.createElement(s,null,n.createElement(t,{resolve:r},(t=>n.createElement(h,{nonce:e,okendoProviderData:t,productUrlFormatter:a,cdnDomain:i,awaited:!0})))):n.createElement(h,{nonce:e,okendoProviderData:r,productUrlFormatter:a,cdnDomain:i}),o&&n.createElement("script",{nonce:e,id:"oke-loyalty-customer-access-token",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify({customerAccessToken:o})}}),d),h=({nonce:e="",okendoProviderData:t,productUrlFormatter:o,awaited:a,cdnDomain:i})=>{const s=p(),l=d(!1),c=d(!1);if(r((()=>{if(t&&t.loyaltySettings&&!1===l.current){const e=document.createElement("script");e.src=`https://${i||v}/loyalty/js/init-onsite.js`,document.head.appendChild(e);const n=document.createElement("script");n.type="application/json",n.id="oke-loyalty-settings";const r=t.loyaltySettings?t.loyaltySettings.replace('<script type="application/json" id="oke-loyalty-settings">',"").replace('<\/script><script src="https://rhys-cdn.okendo.dev/loyalty/js/init-onsite.js" defer><\/script>',""):"";n.innerHTML=r,document.head.appendChild(n),l.current=!0}}),[t,i]),r((()=>{if(t&&s?.setOkendoDataLoaded(!0),t&&a&&!c.current){const e=document.createElement("script");e.src=`https://${i||v}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),c.current=!0}}),[t,s,a,i]),!t)return null;const{reviewsHeaderConfig:u,cssVariables:m,customCss:y,initScriptContents:g,preRenderStyleTags:k,starSymbols:w}=t,h=(m??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),f=y?y.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return n.createElement(n.Fragment,null,n.createElement("script",{nonce:e,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(u)}}),n.createElement("style",{nonce:e,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:h}}),f&&n.createElement("style",{nonce:e,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:f}}),!a&&g&&n.createElement("script",{nonce:e,dangerouslySetInnerHTML:{__html:g}}),n.createElement("script",{nonce:e,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof o?o.toString():"string"==typeof o?o:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),k&&n.createElement("div",{dangerouslySetInnerHTML:{__html:k}}),w&&n.createElement("div",{dangerouslySetInnerHTML:{__html:w}}))};const f=({dataAttributes:e,metafieldContent:t=""})=>{const o=d(null),a=d(!1),i=function(e){const t=d();return r((()=>{t.current=e})),t.current}(e),s=()=>{o.current&&(window.okeWidgetApi.initWidget(o.current),a.current=!0)};return r((()=>{if(!i||e["data-oke-widget"]!==i["data-oke-widget"]||e["data-oke-star-rating"]!==i["data-oke-star-rating"]||e["data-oke-reviews-product-id"]!==i["data-oke-reviews-product-id"]||!a.current)return window.okeWidgetApi&&o.current?s():document.addEventListener("oke-script-loaded",s),()=>{document.removeEventListener("oke-script-loaded",s)}}),[e,i]),n.createElement("div",{ref:o,key:JSON.stringify(e),...e,dangerouslySetInnerHTML:t?{__html:t}:void 0})},S=({productId:e,okendoReviewsSnippet:t,placeholder:r})=>{const o=p(),a=e?.length?g(e):null,i=e?.length?t:null,s={"data-oke-widget":"","data-oke-reviews-product-id":a};return null===o||o.okendoDataLoaded?n.createElement(f,{dataAttributes:s,metafieldContent:i?.value}):r||n.createElement("div",{style:{height:"350px"}})},_=({productId:e,groupId:t,headerBadgeUrl:r,placeholder:o})=>{const a=p(),i={"data-oke-carousel":"","data-oke-reviews-product-id":e?.length?g(e):null,"data-oke-reviews-group-id":t?.length?t:null,"data-oke-header-badge-url":r};return null===a||a.okendoDataLoaded?n.createElement(f,{dataAttributes:i}):o||n.createElement("div",{style:{height:"350px"}})},E=({productId:e,okendoStarRatingSnippet:t,placeholder:r})=>{const o=p(),a={"data-oke-star-rating":"","data-oke-reviews-product-id":g(e)};return null===o||o.okendoDataLoaded?n.createElement(f,{dataAttributes:a,metafieldContent:t?.value}):r||n.createElement("div",{style:{height:"20px"}})},L=`#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "${y}--reviews"\n\t\t\tkey: "star_rating_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`,b=`#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "${y}--reviews"\n\t\t\tkey: "reviews_widget_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`;export{b as OKENDO_PRODUCT_REVIEWS_FRAGMENT,L as OKENDO_PRODUCT_STAR_RATING_FRAGMENT,l as OkendoLoyaltyEmbeddedWidget,w as OkendoProvider,S as OkendoReviews,_ as OkendoReviewsCarousel,E as OkendoStarRating,k as getOkendoProviderData};
1
+ import{useLocation as e,Await as t}from"react-router";import n,{useEffect as r,Suspense as a,useRef as s}from"react";function o(){const t=e();return r((()=>{window?.okeLoyaltyApi?.initialiseWidgets()}),[t.pathname]),n.createElement("div",{"data-oke-loyalty-embedded-widget":""})}const i=/^[0-9]*$/,l="app--1576377";function d(e){if(e)return`shopify-${i.test(e)?e:e.split("/").slice(-1)[0]}`}const c="cdn-static.okendo.io",u=async({context:e,subscriberId:t,apiDomain:n,okendoProducts:r=["reviews"],appNamespace:a})=>{if(!r.length)return null;const s=`loyaltySettings: metafield(\n namespace: "${a??l}--loyalty",\n key: "loyalty_settings"\n ) {\n value\n }`,o=`widgetPreRenderStyleTags: metafield(\n namespace: "${a??l}--reviews",\n key: "widget_pre_render_style_tags"\n ) {\n value\n }`,i=`#graphql\n query metafields {\n shop {\n ${r.includes("loyalty")?s:""}\n ${r.includes("reviews")?o:""}\n }\n }\n `,{shop:{loyaltySettings:d,widgetPreRenderStyleTags:c}}=await e.storefront.query(i);let u=null;if(r.includes("loyalty")&&(u={...u??{},loyaltySettings:d?.value??""}),r.includes("reviews")){const e=`https://${n||"api.okendo.io/v1"}/stores/${t}/widget_plus_settings`,r=await fetch(e);if(!r.ok)return console.error(`Failed to retrieve subscriber settings for subscriber ID '${t}'.`),u;const{reviewsHeaderConfig:a,cssVariables:s,customCss:o,starSymbols:i}=await r.json(),l=c?.value??"";l||console.warn("Failed to retrieve pre-rendered widget style settings."),u={...u??{},reviewsHeaderConfig:a,cssVariables:s,customCss:o,preRenderStyleTags:l,starSymbols:i}}return u},p=({nonce:e="",okendoProviderData:r,customerAccessToken:s,productUrlFormatter:o,cdnDomain:i,children:l})=>n.createElement(n.Fragment,null,n.createElement(a,null,n.createElement(t,{resolve:r},(t=>n.createElement(m,{nonce:e,okendoProviderData:t,productUrlFormatter:o,cdnDomain:i})))),s&&n.createElement("script",{nonce:e,id:"oke-loyalty-customer-access-token",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify({customerAccessToken:s})}}),l),m=({nonce:e="",okendoProviderData:t,productUrlFormatter:a,cdnDomain:o})=>{const i=s(!1),l=s(!1);if(r((()=>{if(t&&t.loyaltySettings&&!1===i.current){const e=document.createElement("script");e.src=`https://${o||c}/loyalty/js/init-onsite.js`,document.head.appendChild(e);const n=document.createElement("script");n.type="application/json",n.id="oke-loyalty-settings";const r=t.loyaltySettings?t.loyaltySettings.replaceAll(/<\/?script.*?>/g,""):"";n.innerHTML=r,document.head.appendChild(n),i.current=!0}}),[t,o]),r((()=>{if(t&&!l.current){const e=document.createElement("script");e.src=`https://${o||c}/reviews-widget-plus/js/okendo-reviews.js`,document.head.appendChild(e),l.current=!0}}),[t,o]),!t)return null;const{reviewsHeaderConfig:d,cssVariables:u,customCss:p,preRenderStyleTags:m,starSymbols:y}=t,g=(u??"").replace('<style id="oke-css-vars">',"").replace("</style>",""),v=p?p.replace('<style id="oke-reviews-custom-css">',"").replace("</style>",""):"";return n.createElement(n.Fragment,null,n.createElement("script",{nonce:e,id:"oke-reviews-settings",type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(d)}}),n.createElement("style",{nonce:e,id:"oke-css-vars",dangerouslySetInnerHTML:{__html:g}}),v&&n.createElement("style",{nonce:e,id:"oke-reviews-custom-css",dangerouslySetInnerHTML:{__html:v}}),n.createElement("script",{nonce:e,type:"text/javascript",dangerouslySetInnerHTML:{__html:`window.okeProductUrlFormatter = ${"function"==typeof a?a.toString():"string"==typeof a?a:"(product) =>\n product && product.productHandle\n ? \"/products/\" + product.productHandle + \"/\" + (product.variantId ? '?variantId=' + product.variantId : '')\n : undefined"}`}}),m&&n.createElement("div",{dangerouslySetInnerHTML:{__html:m}}),y&&n.createElement("div",{dangerouslySetInnerHTML:{__html:y}}))};const y=({style:e,className:t,dataAttributes:a,metafieldContent:o=""})=>{const i=s(null),l=s(!1),d=function(e){const t=s();return r((()=>{t.current=e})),t.current}(a),c=()=>{i.current&&(window.okeWidgetApi.initWidget(i.current),l.current=!0)};return r((()=>{if(!d||a["data-oke-widget"]!==d["data-oke-widget"]||a["data-oke-star-rating"]!==d["data-oke-star-rating"]||a["data-oke-reviews-product-id"]!==d["data-oke-reviews-product-id"]||!l.current)return window.okeWidgetApi&&i.current?c():document.addEventListener("oke-script-loaded",c),()=>{document.removeEventListener("oke-script-loaded",c)}}),[a,d]),n.createElement("div",{ref:i,style:e,className:t,key:JSON.stringify(a),...a,dangerouslySetInnerHTML:o?{__html:o}:void 0})},g=({style:e,className:t,productId:r,okendoReviewsSnippet:a})=>{const s=r?.length?d(r):null,o=r?.length?a:null,i={"data-oke-widget":"","data-oke-reviews-product-id":s};return n.createElement(y,{style:e,className:t,dataAttributes:i,metafieldContent:o?.value})},v=({style:e,className:t,productId:r,groupId:a,headerBadgeUrl:s})=>{const o={"data-oke-carousel":"","data-oke-reviews-product-id":r?.length?d(r):null,"data-oke-reviews-group-id":a?.length?a:null,"data-oke-header-badge-url":s};return n.createElement(y,{style:e,className:t,dataAttributes:o})},k=({style:e,className:t,productId:r,okendoStarRatingSnippet:a})=>{const s={"data-oke-star-rating":"","data-oke-reviews-product-id":d(r)};return n.createElement(y,{style:e,className:t,dataAttributes:s,metafieldContent:a?.value})},w=`#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: "${l}--reviews"\n\t\t\tkey: "star_rating_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`,f=`#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: "${l}--reviews"\n\t\t\tkey: "reviews_widget_snippet"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n`;export{f as OKENDO_PRODUCT_REVIEWS_FRAGMENT,w as OKENDO_PRODUCT_STAR_RATING_FRAGMENT,o as OkendoLoyaltyEmbeddedWidget,p as OkendoProvider,g as OkendoReviews,v as OkendoReviewsCarousel,k as OkendoStarRating,u as getOkendoProviderData};
@@ -7,18 +7,16 @@ interface OkendoReviewsProviderData {
7
7
  reviewsHeaderConfig: WidgetPlus.ReviewsHeaderConfig;
8
8
  cssVariables: string;
9
9
  customCss?: string;
10
- initScriptContents: string;
11
10
  preRenderStyleTags: string;
12
11
  starSymbols: string;
13
12
  }
14
13
  interface OkendoLoyaltyProviderData {
15
14
  loyaltySettings: string;
16
15
  }
17
- export declare const getOkendoProviderData: ({ context, subscriberId, apiDomain, cdnDomain, okendoProducts, appNamespace, }: {
16
+ export declare const getOkendoProviderData: ({ context, subscriberId, apiDomain, okendoProducts, appNamespace, }: {
18
17
  context: StorefrontContext;
19
18
  subscriberId: string;
20
19
  apiDomain?: string;
21
- cdnDomain?: string;
22
20
  okendoProducts?: OkendoProduct[];
23
21
  appNamespace?: string;
24
22
  }) => Promise<OkendoProviderData | null>;
@@ -38,13 +36,9 @@ interface OkendoProviderProps {
38
36
  */
39
37
  nonce?: string;
40
38
  /**
41
- * Either:
42
- * - the data returned by the promise returned by `getOkendoProviderData`, using this will allow the
43
- * Okendo widgets to show instantly on page load, but it will slightly increase the page load time;
44
- * - the promise returned by `getOkendoProviderData`, using this will make the Okendo widgets
45
- * show slightly after page load, but it have the advantage of not increasing the page load time.
39
+ * The promise returned by `getOkendoProviderData`.
46
40
  */
47
- okendoProviderData: Partial<OkendoProviderData> | null | Promise<Partial<OkendoProviderData> | null>;
41
+ okendoProviderData: Promise<OkendoProviderData | null>;
48
42
  /**
49
43
  * Used by the loyalty widget to verify the user's identity via the Storefront API.
50
44
  * Can be retrieved via `await context.customerAccount.getAccessToken()` in the loader function.
@@ -1,16 +1,13 @@
1
- import React from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  import { type MetafieldValue } from '../../internal/types';
3
3
  export interface WithOkendoReviewsSnippet {
4
4
  okendoReviewsSnippet?: MetafieldValue | null;
5
5
  }
6
6
  interface OkendoReviewsProps {
7
+ style?: CSSProperties;
8
+ className?: string;
7
9
  productId?: string;
8
10
  okendoReviewsSnippet?: MetafieldValue | null;
9
- /**
10
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
11
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
12
- */
13
- placeholder?: JSX.Element;
14
11
  }
15
- export declare const OkendoReviews: ({ productId, okendoReviewsSnippet, placeholder }: OkendoReviewsProps) => React.JSX.Element;
12
+ export declare const OkendoReviews: ({ style, className, productId, okendoReviewsSnippet }: OkendoReviewsProps) => React.JSX.Element;
16
13
  export {};
@@ -1,13 +1,10 @@
1
- import React from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  interface OkendoReviewsCarouselProps {
3
+ style?: CSSProperties;
4
+ className?: string;
3
5
  productId?: string;
4
6
  groupId?: string;
5
7
  headerBadgeUrl?: string;
6
- /**
7
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
8
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
9
- */
10
- placeholder?: JSX.Element;
11
8
  }
12
- export declare const OkendoReviewsCarousel: ({ productId, groupId, headerBadgeUrl, placeholder }: OkendoReviewsCarouselProps) => React.JSX.Element;
9
+ export declare const OkendoReviewsCarousel: ({ style, className, productId, groupId, headerBadgeUrl }: OkendoReviewsCarouselProps) => React.JSX.Element;
13
10
  export {};
@@ -1,16 +1,13 @@
1
- import React, { type ReactNode } from 'react';
1
+ import React, { type CSSProperties } from 'react';
2
2
  import { type MetafieldValue } from '../../internal/types';
3
3
  export interface WithOkendoStarRatingSnippet {
4
4
  okendoStarRatingSnippet?: MetafieldValue | null;
5
5
  }
6
6
  interface OkendoStarRatingProps {
7
+ style?: CSSProperties;
8
+ className?: string;
7
9
  productId: string;
8
10
  okendoStarRatingSnippet?: MetafieldValue | null;
9
- /**
10
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
11
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
12
- */
13
- placeholder?: ReactNode;
14
11
  }
15
- export declare const OkendoStarRating: ({ productId, okendoStarRatingSnippet, placeholder }: OkendoStarRatingProps) => string | number | true | React.JSX.Element | Iterable<React.ReactNode>;
12
+ export declare const OkendoStarRating: ({ style, className, productId, okendoStarRatingSnippet }: OkendoStarRatingProps) => React.JSX.Element;
16
13
  export {};
@@ -1,6 +1,8 @@
1
1
  import type { ReviewsWidgetPlus } from '@okendo/reviews-widget-plus/dist-utils/ReviewsWidgetPlus';
2
- import React from 'react';
2
+ import React, { type CSSProperties } from 'react';
3
3
  export interface OkendoWidgetProps {
4
+ style?: CSSProperties;
5
+ className?: string;
4
6
  dataAttributes: {
5
7
  'data-oke-widget'?: string;
6
8
  'data-oke-star-rating'?: string;
@@ -13,4 +15,4 @@ declare global {
13
15
  okeWidgetApi: ReviewsWidgetPlus.WidgetWindowApi;
14
16
  }
15
17
  }
16
- export declare const OkendoWidget: ({ dataAttributes, metafieldContent }: OkendoWidgetProps) => React.JSX.Element;
18
+ export declare const OkendoWidget: ({ style, className, dataAttributes, metafieldContent }: OkendoWidgetProps) => React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React, { PropsWithChildren, ReactNode } from 'react';
1
+ import React, { PropsWithChildren, CSSProperties } from 'react';
2
2
  import { WidgetPlus } from '@okendo/reviews-common';
3
3
  import { CustomerAccount, Storefront } from '@shopify/hydrogen';
4
4
 
@@ -17,18 +17,16 @@ interface OkendoReviewsProviderData {
17
17
  reviewsHeaderConfig: WidgetPlus.ReviewsHeaderConfig;
18
18
  cssVariables: string;
19
19
  customCss?: string;
20
- initScriptContents: string;
21
20
  preRenderStyleTags: string;
22
21
  starSymbols: string;
23
22
  }
24
23
  interface OkendoLoyaltyProviderData {
25
24
  loyaltySettings: string;
26
25
  }
27
- declare const getOkendoProviderData: ({ context, subscriberId, apiDomain, cdnDomain, okendoProducts, appNamespace, }: {
26
+ declare const getOkendoProviderData: ({ context, subscriberId, apiDomain, okendoProducts, appNamespace, }: {
28
27
  context: StorefrontContext;
29
28
  subscriberId: string;
30
29
  apiDomain?: string;
31
- cdnDomain?: string;
32
30
  okendoProducts?: OkendoProduct[];
33
31
  appNamespace?: string;
34
32
  }) => Promise<OkendoProviderData | null>;
@@ -48,13 +46,9 @@ interface OkendoProviderProps {
48
46
  */
49
47
  nonce?: string;
50
48
  /**
51
- * Either:
52
- * - the data returned by the promise returned by `getOkendoProviderData`, using this will allow the
53
- * Okendo widgets to show instantly on page load, but it will slightly increase the page load time;
54
- * - the promise returned by `getOkendoProviderData`, using this will make the Okendo widgets
55
- * show slightly after page load, but it have the advantage of not increasing the page load time.
49
+ * The promise returned by `getOkendoProviderData`.
56
50
  */
57
- okendoProviderData: Partial<OkendoProviderData> | null | Promise<Partial<OkendoProviderData> | null>;
51
+ okendoProviderData: Promise<OkendoProviderData | null>;
58
52
  /**
59
53
  * Used by the loyalty widget to verify the user's identity via the Storefront API.
60
54
  * Can be retrieved via `await context.customerAccount.getAccessToken()` in the loader function.
@@ -74,41 +68,32 @@ interface WithOkendoReviewsSnippet {
74
68
  okendoReviewsSnippet?: MetafieldValue | null;
75
69
  }
76
70
  interface OkendoReviewsProps {
71
+ style?: CSSProperties;
72
+ className?: string;
77
73
  productId?: string;
78
74
  okendoReviewsSnippet?: MetafieldValue | null;
79
- /**
80
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
81
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
82
- */
83
- placeholder?: JSX.Element;
84
75
  }
85
- declare const OkendoReviews: ({ productId, okendoReviewsSnippet, placeholder }: OkendoReviewsProps) => React.JSX.Element;
76
+ declare const OkendoReviews: ({ style, className, productId, okendoReviewsSnippet }: OkendoReviewsProps) => React.JSX.Element;
86
77
 
87
78
  interface OkendoReviewsCarouselProps {
79
+ style?: CSSProperties;
80
+ className?: string;
88
81
  productId?: string;
89
82
  groupId?: string;
90
83
  headerBadgeUrl?: string;
91
- /**
92
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
93
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
94
- */
95
- placeholder?: JSX.Element;
96
84
  }
97
- declare const OkendoReviewsCarousel: ({ productId, groupId, headerBadgeUrl, placeholder }: OkendoReviewsCarouselProps) => React.JSX.Element;
85
+ declare const OkendoReviewsCarousel: ({ style, className, productId, groupId, headerBadgeUrl }: OkendoReviewsCarouselProps) => React.JSX.Element;
98
86
 
99
87
  interface WithOkendoStarRatingSnippet {
100
88
  okendoStarRatingSnippet?: MetafieldValue | null;
101
89
  }
102
90
  interface OkendoStarRatingProps {
91
+ style?: CSSProperties;
92
+ className?: string;
103
93
  productId: string;
104
94
  okendoStarRatingSnippet?: MetafieldValue | null;
105
- /**
106
- * Only used if the promise returned by `getOkendoProviderData` is given to the OkendoProvider
107
- * without being awaited; in this case, the placeholder here will be shown until the widget is ready
108
- */
109
- placeholder?: ReactNode;
110
95
  }
111
- declare const OkendoStarRating: ({ productId, okendoStarRatingSnippet, placeholder }: OkendoStarRatingProps) => string | number | true | React.JSX.Element | Iterable<React.ReactNode>;
96
+ declare const OkendoStarRating: ({ style, className, productId, okendoStarRatingSnippet }: OkendoStarRatingProps) => React.JSX.Element;
112
97
 
113
98
  declare const OKENDO_PRODUCT_STAR_RATING_FRAGMENT: "#graphql\n\tfragment OkendoStarRatingSnippet on Product {\n\t\tokendoStarRatingSnippet: metafield(\n\t\t\tnamespace: \"app--1576377--reviews\"\n\t\t\tkey: \"star_rating_snippet\"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n";
114
99
  declare const OKENDO_PRODUCT_REVIEWS_FRAGMENT: "#graphql\n\tfragment OkendoReviewsSnippet on Product {\n\t\tokendoReviewsSnippet: metafield(\n\t\t\tnamespace: \"app--1576377--reviews\"\n\t\t\tkey: \"reviews_widget_snippet\"\n\t\t) {\n\t\t\tvalue\n\t\t}\n\t}\n";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@okendo/shopify-hydrogen",
3
- "version": "2.4.0",
4
- "description": "Okendo React components for Shopify Hydrogen 2 (Remix)",
3
+ "version": "2.5.1",
4
+ "description": "Okendo React components for Shopify Hydrogen",
5
5
  "author": "Okendo",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
7
7
  "engines": {
@@ -20,8 +20,8 @@
20
20
  "eslint": "eslint src"
21
21
  },
22
22
  "devDependencies": {
23
- "@okendo/reviews-common": "^7.14.0",
24
- "@okendo/reviews-widget-plus": "^0.70.23",
23
+ "@okendo/reviews-common": "^7.111.2",
24
+ "@okendo/reviews-widget-plus": "^0.77.0",
25
25
  "@okendo/tsconfig": "0.0.2",
26
26
  "@rollup/plugin-commonjs": "^25.0.7",
27
27
  "@rollup/plugin-node-resolve": "^15.2.3",
@@ -41,9 +41,9 @@
41
41
  "typescript": "^5.3.3"
42
42
  },
43
43
  "peerDependencies": {
44
- "@remix-run/react": "*",
45
44
  "@shopify/hydrogen": "*",
46
45
  "@shopify/remix-oxygen": "*",
47
- "react": "*"
46
+ "react": "*",
47
+ "react-router": "*"
48
48
  }
49
49
  }
@@ -1,10 +0,0 @@
1
- import React, { type Dispatch, type PropsWithChildren, type SetStateAction } from 'react';
2
- export declare const OkendoContext: React.Context<{
3
- okendoDataLoaded: boolean;
4
- setOkendoDataLoaded: Dispatch<SetStateAction<boolean>>;
5
- } | undefined>;
6
- export declare const OkendoContextProvider: ({ children }: PropsWithChildren) => React.JSX.Element;
7
- export declare const useOkendoContext: () => {
8
- okendoDataLoaded: boolean;
9
- setOkendoDataLoaded: Dispatch<SetStateAction<boolean>>;
10
- } | null;
@@ -1,10 +0,0 @@
1
- import React, { type Dispatch, type PropsWithChildren, type SetStateAction } from 'react';
2
- export declare const OkendoContext: React.Context<{
3
- okendoDataLoaded: boolean;
4
- setOkendoDataLoaded: Dispatch<SetStateAction<boolean>>;
5
- } | undefined>;
6
- export declare const OkendoContextProvider: ({ children }: PropsWithChildren) => React.JSX.Element;
7
- export declare const useOkendoContext: () => {
8
- okendoDataLoaded: boolean;
9
- setOkendoDataLoaded: Dispatch<SetStateAction<boolean>>;
10
- } | null;