@gem-sdk/core 1.46.0-staging.10 → 1.46.0-staging.13

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.
@@ -20,6 +20,7 @@ require('dayjs');
20
20
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
21
21
  var convert = require('../helpers/convert.js');
22
22
  var render = require('../helpers/render.js');
23
+ var cssjson = require('cssjson');
23
24
 
24
25
  const componentsRenderWithParentId = [
25
26
  'CarouselItem'
@@ -181,19 +182,28 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
181
182
  };
182
183
  }
183
184
  };
185
+ const isEmptyCSS = (cssString)=>{
186
+ if (!cssString) return true;
187
+ const cssJSON = cssjson.toJSON(cssString);
188
+ const isObjectEmpty = (obj)=>{
189
+ if (typeof obj !== 'object' || obj === null) return true;
190
+ return !Object.keys(obj).some((key)=>{
191
+ return key === 'attributes' && Object.keys(obj[key]).length > 0 || typeof obj[key] === 'object' && !isObjectEmpty(obj[key]);
192
+ });
193
+ };
194
+ return isObjectEmpty(cssJSON.children);
195
+ };
184
196
  const RenderCustomCode = (item)=>{
185
197
  const { css, javascript, rootClassName } = item.advanced?.editorData || {};
186
198
  const replacedCSS = css?.replaceAll(rootClassName, item.uid);
187
199
  const replacedJS = javascript?.replaceAll(rootClassName, item.uid);
188
- const cssCode = render.RenderIf(!!css, render.template`
189
- <style
190
- id="${`custom-css-${item?.uid}`}"
191
- >${replacedCSS}</style>
200
+ const cssCode = render.RenderIf(!!css && !isEmptyCSS(replacedCSS), render.template`
201
+ <style id="${`custom-css-${item?.uid}`}">
202
+ ${replacedCSS}
203
+ </style>
192
204
  `);
193
205
  const jsCode = render.RenderIf(!!javascript, render.template`
194
- <script
195
- id="${`custom-js-${item?.uid}`}"
196
- >
206
+ <script id="${`custom-js-${item?.uid}`}">
197
207
  try {
198
208
  ${replacedJS}
199
209
  } catch(err){}
@@ -22,7 +22,9 @@ const ArticlesDocument = `
22
22
  descriptionMeta
23
23
  baseID
24
24
  platform
25
- tags
25
+ tags {
26
+ name
27
+ }
26
28
  isSample
27
29
  platformCreatedAt
28
30
  author
@@ -29,7 +29,9 @@ const BlogsDocument = `
29
29
  titleMeta
30
30
  descriptionMeta
31
31
  baseID
32
- tags
32
+ tags {
33
+ name
34
+ }
33
35
  isSample
34
36
  platformCreatedAt
35
37
  author
@@ -19,7 +19,7 @@ const SubifySubscriptionsConfig = {
19
19
  }
20
20
  };
21
21
  const SelleasyConfig = {
22
- SelleasyApp: {
22
+ Selleasy: {
23
23
  appName: 'selleasy',
24
24
  appId: '790c1a03-a71f-4bc1-9869-00dad526d3c2'
25
25
  }
@@ -16,6 +16,7 @@ import 'dayjs';
16
16
  import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
17
17
  import { baseAssetURL, isLocalEnv } from '../helpers/convert.js';
18
18
  import { RenderIf, template } from '../helpers/render.js';
19
+ import { toJSON } from 'cssjson';
19
20
 
20
21
  const componentsRenderWithParentId = [
21
22
  'CarouselItem'
@@ -177,19 +178,28 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
177
178
  };
178
179
  }
179
180
  };
181
+ const isEmptyCSS = (cssString)=>{
182
+ if (!cssString) return true;
183
+ const cssJSON = toJSON(cssString);
184
+ const isObjectEmpty = (obj)=>{
185
+ if (typeof obj !== 'object' || obj === null) return true;
186
+ return !Object.keys(obj).some((key)=>{
187
+ return key === 'attributes' && Object.keys(obj[key]).length > 0 || typeof obj[key] === 'object' && !isObjectEmpty(obj[key]);
188
+ });
189
+ };
190
+ return isObjectEmpty(cssJSON.children);
191
+ };
180
192
  const RenderCustomCode = (item)=>{
181
193
  const { css, javascript, rootClassName } = item.advanced?.editorData || {};
182
194
  const replacedCSS = css?.replaceAll(rootClassName, item.uid);
183
195
  const replacedJS = javascript?.replaceAll(rootClassName, item.uid);
184
- const cssCode = RenderIf(!!css, template`
185
- <style
186
- id="${`custom-css-${item?.uid}`}"
187
- >${replacedCSS}</style>
196
+ const cssCode = RenderIf(!!css && !isEmptyCSS(replacedCSS), template`
197
+ <style id="${`custom-css-${item?.uid}`}">
198
+ ${replacedCSS}
199
+ </style>
188
200
  `);
189
201
  const jsCode = RenderIf(!!javascript, template`
190
- <script
191
- id="${`custom-js-${item?.uid}`}"
192
- >
202
+ <script id="${`custom-js-${item?.uid}`}">
193
203
  try {
194
204
  ${replacedJS}
195
205
  } catch(err){}
@@ -20,7 +20,9 @@ const ArticlesDocument = `
20
20
  descriptionMeta
21
21
  baseID
22
22
  platform
23
- tags
23
+ tags {
24
+ name
25
+ }
24
26
  isSample
25
27
  platformCreatedAt
26
28
  author
@@ -27,7 +27,9 @@ const BlogsDocument = `
27
27
  titleMeta
28
28
  descriptionMeta
29
29
  baseID
30
- tags
30
+ tags {
31
+ name
32
+ }
31
33
  isSample
32
34
  platformCreatedAt
33
35
  author
@@ -17,7 +17,7 @@ const SubifySubscriptionsConfig = {
17
17
  }
18
18
  };
19
19
  const SelleasyConfig = {
20
- SelleasyApp: {
20
+ Selleasy: {
21
21
  appName: 'selleasy',
22
22
  appId: '790c1a03-a71f-4bc1-9869-00dad526d3c2'
23
23
  }
@@ -75,7 +75,7 @@ type Article$2 = {
75
75
  platform?: Maybe$1<ArticlePlatform$1>;
76
76
  platformCreatedAt?: Maybe$1<Scalars$2['Time']>;
77
77
  platformUpdatedAt?: Maybe$1<Scalars$2['Time']>;
78
- tags: Array<Scalars$2['String']>;
78
+ tags?: Maybe$1<Array<Maybe$1<Tag$1>>>;
79
79
  templateSuffix?: Maybe$1<Scalars$2['String']>;
80
80
  title?: Maybe$1<Scalars$2['String']>;
81
81
  titleMeta?: Maybe$1<Scalars$2['String']>;
@@ -2333,6 +2333,7 @@ type Entity = {
2333
2333
  findPublishedThemePageOnlineStoreDataByID: PublishedThemePageOnlineStoreData$1;
2334
2334
  findPublishedThemeSectionByID: PublishedThemeSection$1;
2335
2335
  findPublishedThemeStyleByID: PublishedThemeStyle$1;
2336
+ findTagByID: Tag$1;
2336
2337
  };
2337
2338
  type EntityFindMetafieldByIdArgs = {
2338
2339
  id: Scalars$2['ID'];
@@ -2373,6 +2374,9 @@ type EntityFindPublishedThemeSectionByIdArgs = {
2373
2374
  type EntityFindPublishedThemeStyleByIdArgs = {
2374
2375
  id: Scalars$2['ID'];
2375
2376
  };
2377
+ type EntityFindTagByIdArgs = {
2378
+ id: Scalars$2['ID'];
2379
+ };
2376
2380
  type Media$1 = {
2377
2381
  alt?: Maybe$1<Scalars$2['String']>;
2378
2382
  contentType?: Maybe$1<Scalars$2['String']>;
@@ -6334,6 +6338,12 @@ type StoreProperty$1 = {
6334
6338
  primaryDomain?: Maybe$1<Scalars$2['String']>;
6335
6339
  swatchesConfig: Scalars$2['String'];
6336
6340
  };
6341
+ type Tag$1 = {
6342
+ createdAt?: Maybe$1<Scalars$2['Time']>;
6343
+ id: Scalars$2['ID'];
6344
+ name?: Maybe$1<Scalars$2['String']>;
6345
+ updatedAt?: Maybe$1<Scalars$2['Time']>;
6346
+ };
6337
6347
  type TagType$1 = 'ARTICLE' | 'BLOG' | 'COLLECTION' | 'PRODUCT';
6338
6348
  /**
6339
6349
  * TagWhereInput is used for filtering Tag objects.
@@ -6452,7 +6462,7 @@ type VariantProductOptionWhereInput$1 = {
6452
6462
  variantIDNEQ?: InputMaybe$1<Scalars$2['ID']>;
6453
6463
  variantIDNotIn?: InputMaybe$1<Array<Scalars$2['ID']>>;
6454
6464
  };
6455
- type _Entity = Metafield$1 | Product$1 | PublishedCustomSection$1 | PublishedPageInteraction$1 | PublishedPageSection$1 | PublishedPageSectionMeta$1 | PublishedShopMeta$1 | PublishedThemePage$1 | PublishedThemePageCustomSection$1 | PublishedThemePageMeta$1 | PublishedThemePageOnlineStoreData$1 | PublishedThemeSection$1 | PublishedThemeStyle$1;
6465
+ type _Entity = Metafield$1 | Product$1 | PublishedCustomSection$1 | PublishedPageInteraction$1 | PublishedPageSection$1 | PublishedPageSectionMeta$1 | PublishedShopMeta$1 | PublishedThemePage$1 | PublishedThemePageCustomSection$1 | PublishedThemePageMeta$1 | PublishedThemePageOnlineStoreData$1 | PublishedThemeSection$1 | PublishedThemeStyle$1 | Tag$1;
6456
6466
  type _Service = {
6457
6467
  sdl?: Maybe$1<Scalars$2['String']>;
6458
6468
  };
@@ -6471,6 +6481,7 @@ type shop_EntityFindPublishedThemePageMetaByIdArgs = EntityFindPublishedThemePag
6471
6481
  type shop_EntityFindPublishedThemePageOnlineStoreDataByIdArgs = EntityFindPublishedThemePageOnlineStoreDataByIdArgs;
6472
6482
  type shop_EntityFindPublishedThemeSectionByIdArgs = EntityFindPublishedThemeSectionByIdArgs;
6473
6483
  type shop_EntityFindPublishedThemeStyleByIdArgs = EntityFindPublishedThemeStyleByIdArgs;
6484
+ type shop_EntityFindTagByIdArgs = EntityFindTagByIdArgs;
6474
6485
  type shop_Query_EntitiesArgs = Query_EntitiesArgs;
6475
6486
  type shop__Entity = _Entity;
6476
6487
  type shop__Service = _Service;
@@ -6553,6 +6564,7 @@ declare namespace shop {
6553
6564
  shop_EntityFindPublishedThemePageOnlineStoreDataByIdArgs as EntityFindPublishedThemePageOnlineStoreDataByIdArgs,
6554
6565
  shop_EntityFindPublishedThemeSectionByIdArgs as EntityFindPublishedThemeSectionByIdArgs,
6555
6566
  shop_EntityFindPublishedThemeStyleByIdArgs as EntityFindPublishedThemeStyleByIdArgs,
6567
+ shop_EntityFindTagByIdArgs as EntityFindTagByIdArgs,
6556
6568
  Exact$1 as Exact,
6557
6569
  InputMaybe$1 as InputMaybe,
6558
6570
  MakeMaybe$1 as MakeMaybe,
@@ -6693,6 +6705,7 @@ declare namespace shop {
6693
6705
  ShopShopify$1 as ShopShopify,
6694
6706
  ShopTokenWhereInput$1 as ShopTokenWhereInput,
6695
6707
  StoreProperty$1 as StoreProperty,
6708
+ Tag$1 as Tag,
6696
6709
  TagType$1 as TagType,
6697
6710
  TagWhereInput$1 as TagWhereInput,
6698
6711
  VariantProductOptionWhereInput$1 as VariantProductOptionWhereInput,
@@ -37217,7 +37230,8 @@ type ArticlesQueryVariables = Exact$1<{
37217
37230
  type ArticlesQueryResponse = {
37218
37231
  articles?: Maybe$1<(Pick<ArticleConnection$1, 'totalCount'> & {
37219
37232
  edges: Array<(Pick<ArticleEdge$1, 'cursor'> & {
37220
- node?: Maybe$1<(Pick<Article$2, 'id' | 'title' | 'handle' | 'description' | 'templateSuffix' | 'titleMeta' | 'descriptionMeta' | 'baseID' | 'platform' | 'tags' | 'isSample' | 'platformCreatedAt' | 'author'> & {
37233
+ node?: Maybe$1<(Pick<Article$2, 'id' | 'title' | 'handle' | 'description' | 'templateSuffix' | 'titleMeta' | 'descriptionMeta' | 'baseID' | 'platform' | 'isSample' | 'platformCreatedAt' | 'author'> & {
37234
+ tags: Array<never>;
37221
37235
  content?: Maybe$1<Pick<ArticleContent$1, 'excerptHtml'>>;
37222
37236
  blogs?: Maybe$1<{
37223
37237
  edges: Array<{
@@ -37246,9 +37260,15 @@ type BlogsQueryResponse = {
37246
37260
  node?: Maybe$1<(Pick<Blog$1, 'baseID' | 'description' | 'descriptionMeta' | 'handle' | 'id' | 'platform' | 'tags' | 'templateSuffix' | 'title' | 'titleMeta'> & {
37247
37261
  articles?: Maybe$1<(Pick<ArticleConnection$1, 'totalCount'> & {
37248
37262
  edges: Array<(Pick<ArticleEdge$1, 'cursor'> & {
37249
- node?: Maybe$1<(Pick<Article$2, 'id' | 'title' | 'handle' | 'description' | 'templateSuffix' | 'titleMeta' | 'descriptionMeta' | 'baseID' | 'tags' | 'isSample' | 'platformCreatedAt' | 'author'> & {
37263
+ node?: Maybe$1<(Pick<Article$2, 'id' | 'title' | 'handle' | 'description' | 'templateSuffix' | 'titleMeta' | 'descriptionMeta' | 'baseID' | 'platform' | 'isSample' | 'platformCreatedAt' | 'author'> & {
37264
+ tags: Array<never>;
37250
37265
  content?: Maybe$1<Pick<ArticleContent$1, 'excerptHtml'>>;
37251
- media?: Maybe$1<Pick<Media$1, 'width' | 'src' | 'height'>>;
37266
+ blogs?: Maybe$1<{
37267
+ edges: Array<{
37268
+ node?: Maybe$1<Pick<Blog$1, 'title' | 'handle'>>;
37269
+ }>;
37270
+ }>;
37271
+ media?: Maybe$1<Pick<Media$1, 'alt' | 'width' | 'src' | 'height'>>;
37252
37272
  })>;
37253
37273
  })>;
37254
37274
  })>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.46.0-staging.10",
3
+ "version": "1.46.0-staging.13",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -33,6 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "classnames": "^2.5.1",
36
+ "cssjson": "2.1.3",
36
37
  "dayjs": "^1.11.11",
37
38
  "react-error-boundary": "4.0.10",
38
39
  "swr": "2.1.2",