@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/README.md +308 -624
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/components/OkendoProvider/OkendoProvider.d.ts +3 -9
- package/dist/cjs/types/components/OkendoReviews/OkendoReviews.d.ts +4 -7
- package/dist/cjs/types/components/OkendoReviewsCarousel/OkendoReviewsCarousel.d.ts +4 -7
- package/dist/cjs/types/components/OkendoStarRating/OkendoStarRating.d.ts +4 -7
- package/dist/cjs/types/internal/OkendoWidget/OkendoWidget.d.ts +4 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/types/components/OkendoProvider/OkendoProvider.d.ts +3 -9
- package/dist/esm/types/components/OkendoReviews/OkendoReviews.d.ts +4 -7
- package/dist/esm/types/components/OkendoReviewsCarousel/OkendoReviewsCarousel.d.ts +4 -7
- package/dist/esm/types/components/OkendoStarRating/OkendoStarRating.d.ts +4 -7
- package/dist/esm/types/internal/OkendoWidget/OkendoWidget.d.ts +4 -2
- package/dist/index.d.ts +13 -28
- package/package.json +6 -6
- package/dist/cjs/types/internal/OkendoContext.d.ts +0 -10
- package/dist/esm/types/internal/OkendoContext.d.ts +0 -10
- package/readme-res/okendo-star-rating-and-reviews-widgets.png +0 -0
- package/readme-res/okendo-star-rating-widget.png +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("
|
|
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,
|
|
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
|
-
*
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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"
|
|
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,
|
|
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
|
-
*
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
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
|
-
*
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
-
"description": "Okendo React components for Shopify Hydrogen
|
|
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.
|
|
24
|
-
"@okendo/reviews-widget-plus": "^0.
|
|
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;
|
|
Binary file
|
|
Binary file
|