@gem-sdk/core 2.0.0-dev.460 → 2.0.0-dev.462

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.
@@ -10,26 +10,10 @@ var BuilderComponent = require('../contexts/BuilderComponent.js');
10
10
  var BuilderPreviewContext = require('../contexts/BuilderPreviewContext.js');
11
11
  var ComponentWrapperPreview = require('./ComponentWrapperPreview.js');
12
12
  var RenderSection = require('./RenderSection.js');
13
- require('zustand');
14
- var I18nContext = require('../contexts/I18nContext.js');
15
- require('swr');
16
- require('@gem-sdk/adapter-shopify');
17
- require('swr/mutation');
18
- require('swr/infinite');
19
- require('vanilla-lazyload');
20
- require('../hooks/useCartUI.js');
21
- var useI18n = require('../hooks/useI18n.js');
22
- require('react-transition-group');
23
- require('@gem-sdk/core');
24
- require('classnames');
25
- require('dayjs');
26
- require('../helpers/convert.js');
27
13
 
28
14
  const RenderPreview = ({ uid, ...passProps })=>{
29
15
  const item = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getItem(uid));
30
- BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getState());
31
16
  const Component = BuilderComponent.useBuilderComponent(item?.tag);
32
- const { t } = useI18n.useI18n();
33
17
  if (!item) return null;
34
18
  if (item?.type === 'section') {
35
19
  return /*#__PURE__*/ jsxRuntime.jsx(RenderSection.default, {
@@ -51,31 +35,28 @@ const RenderPreview = ({ uid, ...passProps })=>{
51
35
  })
52
36
  ]
53
37
  }),
54
- children: /*#__PURE__*/ jsxRuntime.jsx(I18nContext.I18nProvider, {
55
- t: t,
56
- children: /*#__PURE__*/ jsxRuntime.jsx(ComponentWrapperPreview.default, {
57
- ...item,
58
- children: item?.childrens?.length ? /*#__PURE__*/ jsxRuntime.jsx(Component, {
59
- builderProps: {
60
- uid,
61
- builderData: item
62
- },
63
- styles: item.styles,
64
- setting: item.settings,
65
- ...passProps,
66
- children: item.childrens.map((id)=>/*#__PURE__*/ jsxRuntime.jsx(RenderPreviewMemo, {
67
- "bundle-item": passProps?.['bundle-item'],
68
- uid: id
69
- }, id))
70
- }) : /*#__PURE__*/ jsxRuntime.jsx(Component, {
71
- builderProps: {
72
- uid,
73
- builderData: item
74
- },
75
- styles: item.styles,
76
- setting: item.settings,
77
- ...passProps
78
- })
38
+ children: /*#__PURE__*/ jsxRuntime.jsx(ComponentWrapperPreview.default, {
39
+ ...item,
40
+ children: item?.childrens?.length ? /*#__PURE__*/ jsxRuntime.jsx(Component, {
41
+ builderProps: {
42
+ uid,
43
+ builderData: item
44
+ },
45
+ styles: item.styles,
46
+ setting: item.settings,
47
+ ...passProps,
48
+ children: item.childrens.map((id)=>/*#__PURE__*/ jsxRuntime.jsx(RenderPreviewMemo, {
49
+ "bundle-item": passProps?.['bundle-item'],
50
+ uid: id
51
+ }, id))
52
+ }) : /*#__PURE__*/ jsxRuntime.jsx(Component, {
53
+ builderProps: {
54
+ uid,
55
+ builderData: item
56
+ },
57
+ styles: item.styles,
58
+ setting: item.settings,
59
+ ...passProps
79
60
  })
80
61
  })
81
62
  }, item.uid);
@@ -16,6 +16,7 @@ var useGettingGenerateRequest = require('./hooks/useGettingGenerateRequest.js');
16
16
  var useFlipPopup = require('./hooks/useFlipPopup.js');
17
17
  var useCheckingProductInside = require('./hooks/useCheckingProductInside.js');
18
18
  require('zustand');
19
+ var I18nContext = require('../../contexts/I18nContext.js');
19
20
  require('react-transition-group');
20
21
  require('@gem-sdk/core');
21
22
  var ShopContext = require('../../contexts/ShopContext.js');
@@ -36,6 +37,7 @@ const AIContentGenerator = ({ ...props })=>{
36
37
  const genPopupHeader = react.useRef(null);
37
38
  const genButtonWrapper = react.useRef(null);
38
39
  const nextMonth = dayjs().add(1, 'month').startOf('month').format('DD MMM');
40
+ const { t } = I18nContext.useI18nStore();
39
41
  const { popupPositionX, popupPositionY, isValidating: isValidatingFlipPopup, bodyMaxHeight: popupBodyMaxHeight } = useFlipPopup.useFlipPopup(isShowPopup, {
40
42
  genTool,
41
43
  genPopup,
@@ -117,7 +119,7 @@ const AIContentGenerator = ({ ...props })=>{
117
119
  onClick: togglePopup,
118
120
  children: [
119
121
  /*#__PURE__*/ jsxRuntime.jsx(AIIcon.AIIcon, {}),
120
- "AI Content"
122
+ t('AI Content')
121
123
  ]
122
124
  })
123
125
  }),
@@ -29,7 +29,7 @@ const transitions = {
29
29
  }
30
30
  };
31
31
  const ThemeSectionTooltip = ({ isShow, isFreeLimit, isRender, children, limitCreateThemeSection, onMouseEnter, onMouseLeave, onActions })=>{
32
- const { t } = core.useI18n();
32
+ const { t } = core.useI18nStore();
33
33
  const nodeRef = react.useRef(null);
34
34
  const actionBtnLabel = isFreeLimit ? 'Upgrade to create Theme Section' : 'Create Theme Section';
35
35
  const openHelpCenter = ()=>{
@@ -27,7 +27,7 @@ const I18nProvider = ({ children, t })=>{
27
27
  const useI18nStore = ()=>{
28
28
  const store = react.useContext(I18nContext);
29
29
  if (!store) {
30
- throw new Error('Element of article must be used inside a Article');
30
+ throw new Error('useI18nStore must be used inside a I18nProvider');
31
31
  }
32
32
  return zustand.useStore(store);
33
33
  };
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
4
  var react = require('react');
@@ -9,10 +10,12 @@ const useI18n = ()=>{
9
10
  if (!detail) return;
10
11
  setI18n(detail);
11
12
  };
12
- const t = (string)=>{
13
+ const t = react.useCallback((string)=>{
13
14
  if (!i18n) return string;
14
15
  return i18n?.t(string);
15
- };
16
+ }, [
17
+ i18n
18
+ ]);
16
19
  react.useEffect(()=>{
17
20
  window.addEventListener('editor:change-language', handleChangeLanguage);
18
21
  return ()=>{
@@ -6,26 +6,10 @@ import { useBuilderComponent } from '../contexts/BuilderComponent.js';
6
6
  import { useBuilderPreviewStore } from '../contexts/BuilderPreviewContext.js';
7
7
  import ComponentWrapperPreview from './ComponentWrapperPreview.js';
8
8
  import RenderSectionMemo from './RenderSection.js';
9
- import 'zustand';
10
- import { I18nProvider } from '../contexts/I18nContext.js';
11
- import 'swr';
12
- import '@gem-sdk/adapter-shopify';
13
- import 'swr/mutation';
14
- import 'swr/infinite';
15
- import 'vanilla-lazyload';
16
- import '../hooks/useCartUI.js';
17
- import { useI18n } from '../hooks/useI18n.js';
18
- import 'react-transition-group';
19
- import '@gem-sdk/core';
20
- import 'classnames';
21
- import 'dayjs';
22
- import '../helpers/convert.js';
23
9
 
24
10
  const RenderPreview = ({ uid, ...passProps })=>{
25
11
  const item = useBuilderPreviewStore((s)=>s.getItem(uid));
26
- useBuilderPreviewStore((s)=>s.getState());
27
12
  const Component = useBuilderComponent(item?.tag);
28
- const { t } = useI18n();
29
13
  if (!item) return null;
30
14
  if (item?.type === 'section') {
31
15
  return /*#__PURE__*/ jsx(RenderSectionMemo, {
@@ -47,31 +31,28 @@ const RenderPreview = ({ uid, ...passProps })=>{
47
31
  })
48
32
  ]
49
33
  }),
50
- children: /*#__PURE__*/ jsx(I18nProvider, {
51
- t: t,
52
- children: /*#__PURE__*/ jsx(ComponentWrapperPreview, {
53
- ...item,
54
- children: item?.childrens?.length ? /*#__PURE__*/ jsx(Component, {
55
- builderProps: {
56
- uid,
57
- builderData: item
58
- },
59
- styles: item.styles,
60
- setting: item.settings,
61
- ...passProps,
62
- children: item.childrens.map((id)=>/*#__PURE__*/ jsx(RenderPreviewMemo, {
63
- "bundle-item": passProps?.['bundle-item'],
64
- uid: id
65
- }, id))
66
- }) : /*#__PURE__*/ jsx(Component, {
67
- builderProps: {
68
- uid,
69
- builderData: item
70
- },
71
- styles: item.styles,
72
- setting: item.settings,
73
- ...passProps
74
- })
34
+ children: /*#__PURE__*/ jsx(ComponentWrapperPreview, {
35
+ ...item,
36
+ children: item?.childrens?.length ? /*#__PURE__*/ jsx(Component, {
37
+ builderProps: {
38
+ uid,
39
+ builderData: item
40
+ },
41
+ styles: item.styles,
42
+ setting: item.settings,
43
+ ...passProps,
44
+ children: item.childrens.map((id)=>/*#__PURE__*/ jsx(RenderPreviewMemo, {
45
+ "bundle-item": passProps?.['bundle-item'],
46
+ uid: id
47
+ }, id))
48
+ }) : /*#__PURE__*/ jsx(Component, {
49
+ builderProps: {
50
+ uid,
51
+ builderData: item
52
+ },
53
+ styles: item.styles,
54
+ setting: item.settings,
55
+ ...passProps
75
56
  })
76
57
  })
77
58
  }, item.uid);
@@ -14,6 +14,7 @@ import { useGettingGenerateRequest } from './hooks/useGettingGenerateRequest.js'
14
14
  import { useFlipPopup } from './hooks/useFlipPopup.js';
15
15
  import { useCheckingProductInside } from './hooks/useCheckingProductInside.js';
16
16
  import 'zustand';
17
+ import { useI18nStore } from '../../contexts/I18nContext.js';
17
18
  import 'react-transition-group';
18
19
  import '@gem-sdk/core';
19
20
  import { useShopStore } from '../../contexts/ShopContext.js';
@@ -34,6 +35,7 @@ const AIContentGenerator = ({ ...props })=>{
34
35
  const genPopupHeader = useRef(null);
35
36
  const genButtonWrapper = useRef(null);
36
37
  const nextMonth = dayjs().add(1, 'month').startOf('month').format('DD MMM');
38
+ const { t } = useI18nStore();
37
39
  const { popupPositionX, popupPositionY, isValidating: isValidatingFlipPopup, bodyMaxHeight: popupBodyMaxHeight } = useFlipPopup(isShowPopup, {
38
40
  genTool,
39
41
  genPopup,
@@ -115,7 +117,7 @@ const AIContentGenerator = ({ ...props })=>{
115
117
  onClick: togglePopup,
116
118
  children: [
117
119
  /*#__PURE__*/ jsx(AIIcon, {}),
118
- "AI Content"
120
+ t('AI Content')
119
121
  ]
120
122
  })
121
123
  }),
@@ -2,7 +2,7 @@
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import { useRef } from 'react';
4
4
  import { Transition } from 'react-transition-group';
5
- import { useI18n, cls } from '@gem-sdk/core';
5
+ import { useI18nStore, cls } from '@gem-sdk/core';
6
6
 
7
7
  const TRANSITION_DURATION = 350;
8
8
  const defaultStyles = {
@@ -27,7 +27,7 @@ const transitions = {
27
27
  }
28
28
  };
29
29
  const ThemeSectionTooltip = ({ isShow, isFreeLimit, isRender, children, limitCreateThemeSection, onMouseEnter, onMouseLeave, onActions })=>{
30
- const { t } = useI18n();
30
+ const { t } = useI18nStore();
31
31
  const nodeRef = useRef(null);
32
32
  const actionBtnLabel = isFreeLimit ? 'Upgrade to create Theme Section' : 'Create Theme Section';
33
33
  const openHelpCenter = ()=>{
@@ -25,7 +25,7 @@ const I18nProvider = ({ children, t })=>{
25
25
  const useI18nStore = ()=>{
26
26
  const store = useContext(I18nContext);
27
27
  if (!store) {
28
- throw new Error('Element of article must be used inside a Article');
28
+ throw new Error('useI18nStore must be used inside a I18nProvider');
29
29
  }
30
30
  return useStore(store);
31
31
  };
@@ -1,4 +1,5 @@
1
- import { useState, useEffect } from 'react';
1
+ 'use client';
2
+ import { useState, useCallback, useEffect } from 'react';
2
3
 
3
4
  const useI18n = ()=>{
4
5
  const [i18n, setI18n] = useState(null);
@@ -7,10 +8,12 @@ const useI18n = ()=>{
7
8
  if (!detail) return;
8
9
  setI18n(detail);
9
10
  };
10
- const t = (string)=>{
11
+ const t = useCallback((string)=>{
11
12
  if (!i18n) return string;
12
13
  return i18n?.t(string);
13
- };
14
+ }, [
15
+ i18n
16
+ ]);
14
17
  useEffect(()=>{
15
18
  window.addEventListener('editor:change-language', handleChangeLanguage);
16
19
  return ()=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "2.0.0-dev.460",
3
+ "version": "2.0.0-dev.462",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",