@gem-sdk/components 2.0.0-dev.690 → 2.0.0-dev.692

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.
@@ -21,7 +21,7 @@ const Header = ({ builderAttrs, builderProps, style, setting, styles, children }
21
21
  if (builderProps?.isPreview && isSalesPage) return null;
22
22
  return /*#__PURE__*/ jsxRuntime.jsxs("nav", {
23
23
  "data-id": builderProps?.uid,
24
- className: core.cls('gp-w-full gp-z-10 hover:gp-z-50', builderProps?.uid),
24
+ className: core.cls('gp-z-10 hover:gp-z-50', builderProps?.uid),
25
25
  ...builderAttrs,
26
26
  style: {
27
27
  ...style,
@@ -12,22 +12,22 @@ var WithoutProduct = require('./Judgeme/WithoutProduct.js');
12
12
 
13
13
  const InstantJudgemeReviews = ({ setting, styles, builderProps })=>{
14
14
  const { widgetType, publicToken } = setting ?? {};
15
+ const mode = core.useEditorMode();
15
16
  const { storefrontUrl } = core.useStoreFront();
16
17
  const SHOPIFY_DOMAIN = storefrontUrl?.replace('https://', '')?.replace('http://', '')?.split('/')?.[0];
17
- const addScript = (id, src)=>{
18
- const existing = document.getElementById(id);
19
- if (existing) {
20
- return existing;
21
- } else {
18
+ const addScripts = (scripts)=>{
19
+ scripts.forEach(([id, src])=>{
20
+ if (document.getElementById(id)) return;
22
21
  const script = document.createElement('script');
23
- script.id = id;
24
- script.src = src;
25
- script.defer = true;
26
- script.type = 'text/javascript';
22
+ Object.assign(script, {
23
+ id,
24
+ src,
25
+ defer: true,
26
+ type: 'text/javascript'
27
+ });
27
28
  script.setAttribute('data-cfasync', 'false');
28
29
  document.head.appendChild(script);
29
- return script;
30
- }
30
+ });
31
31
  };
32
32
  const addTextScript = React.useCallback((id, public_token)=>{
33
33
  if (SHOPIFY_DOMAIN && public_token) {
@@ -48,9 +48,25 @@ const InstantJudgemeReviews = ({ setting, styles, builderProps })=>{
48
48
  }
49
49
  };
50
50
  React.useEffect(()=>{
51
- addScript(JudgemeReviews.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID, JudgemeReviews.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL);
52
- addScript(JudgemeReviews.JUDGEME_REVIEWS_INSTALLED_JS_ID, JudgemeReviews.JUDGEME_REVIEWS_INSTALLED_JS_URL);
53
- }, []);
51
+ if (mode !== 'edit') {
52
+ addScripts([
53
+ [
54
+ JudgemeReviews.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID,
55
+ JudgemeReviews.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL
56
+ ],
57
+ [
58
+ JudgemeReviews.JUDGEME_REVIEWS_INSTALLED_JS_ID,
59
+ JudgemeReviews.JUDGEME_REVIEWS_INSTALLED_JS_URL
60
+ ],
61
+ [
62
+ JudgemeReviews.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2,
63
+ JudgemeReviews.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2
64
+ ]
65
+ ]);
66
+ }
67
+ }, [
68
+ mode
69
+ ]);
54
70
  React.useEffect(()=>{
55
71
  if (publicToken) {
56
72
  removeScript(JudgemeReviews.JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID);
@@ -2,7 +2,9 @@
2
2
 
3
3
  const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL = 'https://cdn.judge.me/widget_preloader.js';
4
4
  const JUDGEME_REVIEWS_INSTALLED_JS_URL = 'https://cdn.judge.me/assets/installed.js';
5
+ const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2 = 'https://cdnwidget.judge.me/widget_preloader.js';
5
6
  const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID = 'judge_widget_preloader';
7
+ const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2 = 'judge_widget_preloader_v2';
6
8
  const JUDGEME_REVIEWS_INSTALLED_JS_ID = 'judge_installed';
7
9
  const JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID = 'judge_public_token';
8
10
 
@@ -10,4 +12,6 @@ exports.JUDGEME_REVIEWS_INSTALLED_JS_ID = JUDGEME_REVIEWS_INSTALLED_JS_ID;
10
12
  exports.JUDGEME_REVIEWS_INSTALLED_JS_URL = JUDGEME_REVIEWS_INSTALLED_JS_URL;
11
13
  exports.JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID = JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID;
12
14
  exports.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID = JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID;
15
+ exports.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2 = JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2;
13
16
  exports.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL = JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL;
17
+ exports.JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2 = JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2;
@@ -17,7 +17,7 @@ const Header = ({ builderAttrs, builderProps, style, setting, styles, children }
17
17
  if (builderProps?.isPreview && isSalesPage) return null;
18
18
  return /*#__PURE__*/ jsxs("nav", {
19
19
  "data-id": builderProps?.uid,
20
- className: cls('gp-w-full gp-z-10 hover:gp-z-50', builderProps?.uid),
20
+ className: cls('gp-z-10 hover:gp-z-50', builderProps?.uid),
21
21
  ...builderAttrs,
22
22
  style: {
23
23
  ...style,
@@ -1,29 +1,29 @@
1
1
  'use client';
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
- import { useStoreFront } from '@gem-sdk/core';
3
+ import { useEditorMode, useStoreFront } from '@gem-sdk/core';
4
4
  import { useCallback, useEffect } from 'react';
5
- import { JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID, JUDGEME_REVIEWS_INSTALLED_JS_URL, JUDGEME_REVIEWS_INSTALLED_JS_ID } from '../types/JudgemeReviews.js';
5
+ import { JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL, JUDGEME_REVIEWS_INSTALLED_JS_ID, JUDGEME_REVIEWS_INSTALLED_JS_URL, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2 } from '../types/JudgemeReviews.js';
6
6
  import JudgemeSingleProduct from './Judgeme/SingleProduct.js';
7
7
  import JudgemeWithoutProduct from './Judgeme/WithoutProduct.js';
8
8
 
9
9
  const InstantJudgemeReviews = ({ setting, styles, builderProps })=>{
10
10
  const { widgetType, publicToken } = setting ?? {};
11
+ const mode = useEditorMode();
11
12
  const { storefrontUrl } = useStoreFront();
12
13
  const SHOPIFY_DOMAIN = storefrontUrl?.replace('https://', '')?.replace('http://', '')?.split('/')?.[0];
13
- const addScript = (id, src)=>{
14
- const existing = document.getElementById(id);
15
- if (existing) {
16
- return existing;
17
- } else {
14
+ const addScripts = (scripts)=>{
15
+ scripts.forEach(([id, src])=>{
16
+ if (document.getElementById(id)) return;
18
17
  const script = document.createElement('script');
19
- script.id = id;
20
- script.src = src;
21
- script.defer = true;
22
- script.type = 'text/javascript';
18
+ Object.assign(script, {
19
+ id,
20
+ src,
21
+ defer: true,
22
+ type: 'text/javascript'
23
+ });
23
24
  script.setAttribute('data-cfasync', 'false');
24
25
  document.head.appendChild(script);
25
- return script;
26
- }
26
+ });
27
27
  };
28
28
  const addTextScript = useCallback((id, public_token)=>{
29
29
  if (SHOPIFY_DOMAIN && public_token) {
@@ -44,9 +44,25 @@ const InstantJudgemeReviews = ({ setting, styles, builderProps })=>{
44
44
  }
45
45
  };
46
46
  useEffect(()=>{
47
- addScript(JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL);
48
- addScript(JUDGEME_REVIEWS_INSTALLED_JS_ID, JUDGEME_REVIEWS_INSTALLED_JS_URL);
49
- }, []);
47
+ if (mode !== 'edit') {
48
+ addScripts([
49
+ [
50
+ JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID,
51
+ JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL
52
+ ],
53
+ [
54
+ JUDGEME_REVIEWS_INSTALLED_JS_ID,
55
+ JUDGEME_REVIEWS_INSTALLED_JS_URL
56
+ ],
57
+ [
58
+ JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2,
59
+ JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2
60
+ ]
61
+ ]);
62
+ }
63
+ }, [
64
+ mode
65
+ ]);
50
66
  useEffect(()=>{
51
67
  if (publicToken) {
52
68
  removeScript(JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID);
@@ -1,7 +1,9 @@
1
1
  const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL = 'https://cdn.judge.me/widget_preloader.js';
2
2
  const JUDGEME_REVIEWS_INSTALLED_JS_URL = 'https://cdn.judge.me/assets/installed.js';
3
+ const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2 = 'https://cdnwidget.judge.me/widget_preloader.js';
3
4
  const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID = 'judge_widget_preloader';
5
+ const JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2 = 'judge_widget_preloader_v2';
4
6
  const JUDGEME_REVIEWS_INSTALLED_JS_ID = 'judge_installed';
5
7
  const JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID = 'judge_public_token';
6
8
 
7
- export { JUDGEME_REVIEWS_INSTALLED_JS_ID, JUDGEME_REVIEWS_INSTALLED_JS_URL, JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL };
9
+ export { JUDGEME_REVIEWS_INSTALLED_JS_ID, JUDGEME_REVIEWS_INSTALLED_JS_URL, JUDGEME_REVIEWS_PUBLIC_TOKEN_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_ID, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_I_V2, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL, JUDGEME_REVIEWS_WIDGET_PRELOADER_JS_URL_V2 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.690",
3
+ "version": "2.0.0-dev.692",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",