@gem-sdk/core 1.56.2 → 1.57.0-dev.45

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.
Files changed (54) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +181 -107
  2. package/dist/cjs/components/ComponentWrapper.js +16 -1
  3. package/dist/cjs/components/ComponentWrapperPreview.js +16 -2
  4. package/dist/cjs/components/InteractionSuffix.js +42 -0
  5. package/dist/cjs/components/Render.liquid.js +22 -7
  6. package/dist/cjs/contexts/PageContext.js +42 -1
  7. package/dist/cjs/contexts/ProductContext.js +10 -0
  8. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +4 -0
  9. package/dist/cjs/helpers/animations.js +17 -8
  10. package/dist/cjs/helpers/background.js +10 -5
  11. package/dist/cjs/helpers/compose-advance-style.js +30 -4
  12. package/dist/cjs/helpers/interaction/index.js +110 -0
  13. package/dist/cjs/helpers/radius.js +11 -1
  14. package/dist/cjs/helpers/shadow.js +5 -4
  15. package/dist/cjs/helpers/third-party/appConfig.js +49 -0
  16. package/dist/cjs/helpers/third-party/appSetting.js +116 -1
  17. package/dist/cjs/helpers/third-party/constant.js +8 -1
  18. package/dist/cjs/helpers/third-party/getAppBlockConfig.js +8 -1
  19. package/dist/cjs/hooks/animation/useAnimationConfig.js +2 -1
  20. package/dist/cjs/hooks/animation/useAnimationTarget.js +5 -2
  21. package/dist/cjs/hooks/animation/useApplyAnimation.js +6 -4
  22. package/dist/cjs/hooks/useInteraction.js +19 -0
  23. package/dist/cjs/hooks/useToolbarPostPurchase.js +2 -2
  24. package/dist/cjs/index.js +14 -1
  25. package/dist/cjs/types/animations.js +2 -0
  26. package/dist/cjs/types/custom.js +52 -0
  27. package/dist/esm/components/ComponentToolbarPreview.js +181 -107
  28. package/dist/esm/components/ComponentWrapper.js +16 -1
  29. package/dist/esm/components/ComponentWrapperPreview.js +16 -2
  30. package/dist/esm/components/InteractionSuffix.js +40 -0
  31. package/dist/esm/components/Render.liquid.js +22 -7
  32. package/dist/esm/contexts/PageContext.js +42 -1
  33. package/dist/esm/contexts/ProductContext.js +10 -0
  34. package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -0
  35. package/dist/esm/helpers/animations.js +17 -8
  36. package/dist/esm/helpers/background.js +10 -5
  37. package/dist/esm/helpers/compose-advance-style.js +31 -5
  38. package/dist/esm/helpers/interaction/index.js +108 -0
  39. package/dist/esm/helpers/radius.js +11 -1
  40. package/dist/esm/helpers/shadow.js +5 -4
  41. package/dist/esm/helpers/third-party/appConfig.js +43 -1
  42. package/dist/esm/helpers/third-party/appSetting.js +116 -1
  43. package/dist/esm/helpers/third-party/constant.js +9 -2
  44. package/dist/esm/helpers/third-party/getAppBlockConfig.js +8 -1
  45. package/dist/esm/hooks/animation/useAnimationConfig.js +2 -1
  46. package/dist/esm/hooks/animation/useAnimationTarget.js +5 -2
  47. package/dist/esm/hooks/animation/useApplyAnimation.js +6 -4
  48. package/dist/esm/hooks/useInteraction.js +17 -0
  49. package/dist/esm/hooks/useToolbarPostPurchase.js +2 -2
  50. package/dist/esm/index.js +4 -1
  51. package/dist/esm/types/animations.js +2 -0
  52. package/dist/esm/types/custom.js +52 -0
  53. package/dist/types/index.d.ts +547 -184
  54. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig, SkioSubscriptionsYcS20Config, ShopifyFormsConfig, ReviewxpoProductReviewsAppConfig, PumperBundlesVolumeDiscountConfig, UnlimitedBundlesDiscountsConfig, KiteFreeGiftDiscountConfig, FastBundleBundlesDiscountsConfig, SimpleBundlesKitsConfig, EasyBundleBuilderSkailamaConfig, PreorderNowPreOrderPqConfig, FlyBundlesUpsellsFbtConfig, JunipProductReviewsUgcConfig, PreorderNowWodPresaleConfig, YotpoReviewsV3UgcConfig, WhatmoreShoppableVideosreelConfig, ProductOptionsCustomizerConfig, AppointmentBookingCowlendarConfig, BoldSubscriptionsConfig } from './appConfig.js';
1
+ import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig, SkioSubscriptionsYcS20Config, ShopifyFormsConfig, ReviewxpoProductReviewsAppConfig, PumperBundlesVolumeDiscountConfig, UnlimitedBundlesDiscountsConfig, KiteFreeGiftDiscountConfig, FastBundleBundlesDiscountsConfig, SimpleBundlesKitsConfig, EasyBundleBuilderSkailamaConfig, PreorderNowPreOrderPqConfig, FlyBundlesUpsellsFbtConfig, JunipProductReviewsUgcConfig, PreorderNowWodPresaleConfig, YotpoReviewsV3UgcConfig, WhatmoreShoppableVideosreelConfig, ProductOptionsCustomizerConfig, AppointmentBookingCowlendarConfig, BoldSubscriptionsConfig, SproutPlantTreesGrowSalesConfig, InstasellShoppableInstagramConfig, GrowaveConfig, KachingBundlesConfig, LoloyalLoyaltyReferralsConfig, PowerfulContactFormBuilderConfig, WishlistKingConfig } from './appConfig.js';
2
2
 
3
3
  const mapShopifyAppMeta = {
4
4
  ...RechargeSubscriptionsConfig,
@@ -23,7 +23,14 @@ const mapShopifyAppMeta = {
23
23
  ...WhatmoreShoppableVideosreelConfig,
24
24
  ...ProductOptionsCustomizerConfig,
25
25
  ...AppointmentBookingCowlendarConfig,
26
- ...BoldSubscriptionsConfig
26
+ ...BoldSubscriptionsConfig,
27
+ ...SproutPlantTreesGrowSalesConfig,
28
+ ...InstasellShoppableInstagramConfig,
29
+ ...GrowaveConfig,
30
+ ...KachingBundlesConfig,
31
+ ...LoloyalLoyaltyReferralsConfig,
32
+ ...PowerfulContactFormBuilderConfig,
33
+ ...WishlistKingConfig
27
34
  };
28
35
  const THIRD_PARTY_APP_BLOCK_ID_PREFIX = 'gp_app';
29
36
 
@@ -1,10 +1,17 @@
1
1
  import { composeSettingsByWidgetType, overrideSettings } from './appSetting.js';
2
2
  import { getAppBlockType } from './getAppBlockType.js';
3
3
 
4
+ const listAppUpdateNewVersion = [
5
+ 'Growave'
6
+ ];
4
7
  const getAppBlockConfig = (tag, appBlockId, settings)=>{
8
+ let widgetType = settings?.widgetType;
9
+ if (listAppUpdateNewVersion.includes(tag)) {
10
+ widgetType = settings?.widgetTypeV2;
11
+ }
5
12
  const appBlockType = getAppBlockType({
6
13
  tag,
7
- widgetType: settings?.widgetType
14
+ widgetType
8
15
  });
9
16
  const settingByWidget = composeSettingsByWidgetType[tag][settings?.widgetType];
10
17
  const appSettings = overrideSettings(tag, settingByWidget, settings);
@@ -12,7 +12,8 @@ const useAnimationConfig = (props)=>{
12
12
  const { animation, setting } = triggerConfig[trigger];
13
13
  return {
14
14
  type: animation,
15
- setting: setting[animation]
15
+ setting: setting[animation],
16
+ reverse: trigger === "hidden"
16
17
  };
17
18
  }, [
18
19
  configByDevices
@@ -96,9 +96,12 @@ const useAnimationTarget = (props)=>{
96
96
  const initListOfTargets = useCallback(()=>{
97
97
  if (!isEnabledAnimation) return;
98
98
  if (!targets.current) {
99
- targets.current = document.querySelectorAll(`[data-uid="${componentUid}"]`);
99
+ const $storefront = document.body.querySelector('#storefront');
100
+ if ($storefront) {
101
+ targets.current = $storefront.querySelectorAll(`[data-uid="${componentUid}"]`);
102
+ }
100
103
  }
101
- const targetsArray = Array.from(targets.current);
104
+ const targetsArray = Array.from(targets.current || []);
102
105
  if (!targetsArray.length) return;
103
106
  const updatedTargetObjects = getUpdatedTargetObjects(targetsArray);
104
107
  targetObjects.current = updatedTargetObjects;
@@ -4,6 +4,7 @@ import { useAnimationTarget } from './useAnimationTarget.js';
4
4
  import { useAnimationConfig } from './useAnimationConfig.js';
5
5
  import { useAnimationActions } from './useAnimationActions.js';
6
6
  import { useAnimationPreview } from './useAnimationPreview.js';
7
+ import '../../types/custom.js';
7
8
  import { AnimationType } from '../../types/animations.js';
8
9
 
9
10
  const useApplyAnimation = ({ props })=>{
@@ -20,13 +21,13 @@ const useApplyAnimation = ({ props })=>{
20
21
  setAnimationOnFinish,
21
22
  setToolbarActive
22
23
  });
23
- const generateAnimation = useCallback(({ target, setting, type })=>{
24
- return animation[type](target, setting);
24
+ const generateAnimation = useCallback(({ target, setting, type, reverse })=>{
25
+ return animation[type](target, setting, reverse);
25
26
  }, [
26
27
  animation
27
28
  ]);
28
29
  const initListAnimations = useCallback(()=>{
29
- const { type, setting } = getAnimationConfig();
30
+ const { type, setting, reverse } = getAnimationConfig();
30
31
  if (!type || type === AnimationType.None || !targetObjects.current.length) {
31
32
  cancelAnimation();
32
33
  return;
@@ -34,7 +35,8 @@ const useApplyAnimation = ({ props })=>{
34
35
  const listAnimations = targetObjects.current.map((item)=>generateAnimation({
35
36
  type,
36
37
  setting,
37
- target: item.target
38
+ target: item.target,
39
+ reverse
38
40
  }));
39
41
  cancelAnimation();
40
42
  setAnimation(listAnimations);
@@ -0,0 +1,17 @@
1
+ import { usePageStore } from '../contexts/PageContext.js';
2
+
3
+ const useInteraction = ()=>{
4
+ const interactionData = usePageStore((state)=>state.interactionData);
5
+ const { item } = interactionData || {};
6
+ const getAnimationByUid = (uid)=>{
7
+ const targets = item?.targets;
8
+ const targetByUid = targets?.find((target)=>target.uid === uid);
9
+ const metaDataContainsAnimation = targetByUid?.events?.find((it)=>it.condition?.metaData?.animation);
10
+ return metaDataContainsAnimation?.condition?.metaData?.animation;
11
+ };
12
+ return {
13
+ getAnimationByUid
14
+ };
15
+ };
16
+
17
+ export { useInteraction };
@@ -29,7 +29,7 @@ const usePostPurchase = (uid, tag)=>{
29
29
  return count <= 1;
30
30
  };
31
31
  const verifyWrapContainsRequireElement = ()=>{
32
- const $component = document.querySelector(`[data-uid="${uid}"]`);
32
+ const $component = document.body.querySelector('#storefront')?.querySelector(`[data-uid="${uid}"]`);
33
33
  if (!$component) return false;
34
34
  for (const requiredElementTag of postPurchaseRequiredElements){
35
35
  const countElementInsidePage = getElementCountInPage(requiredElementTag);
@@ -42,7 +42,7 @@ const usePostPurchase = (uid, tag)=>{
42
42
  };
43
43
  const countRequiredElement = ()=>{
44
44
  return postPurchaseRequiredElements.reduce((acc, requiredElementTag)=>{
45
- const $component = document.querySelector(`[data-uid="${uid}"]`);
45
+ const $component = document.body.querySelector('#storefront')?.querySelector(`[data-uid="${uid}"]`);
46
46
  if (!$component) return 0;
47
47
  const count = $component.querySelectorAll(`[data-component-tag="${requiredElementTag}"]`).length;
48
48
  return acc + count;
package/dist/esm/index.js CHANGED
@@ -63,11 +63,12 @@ export { isDefined } from './helpers/is-defined.js';
63
63
  export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle } from './helpers/layout.js';
64
64
  export { makeAspectRatio, makeGlobalSizeHeightResponsive, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveByScreen, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined } from './helpers/make-style.js';
65
65
  export { convertTextAlignToJustify } from './helpers/align.js';
66
+ export { checkInStock } from './helpers/variant.js';
66
67
  export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption } from './helpers/product.js';
67
68
  export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey } from './helpers/query.js';
68
69
  export { composeCornerCss, composeRadius, composeRadiusResponsive, getCornerCSSFromGlobal, getCustomRadius, getRadiusCSSFromGlobal, getRadiusStyleActiveState } from './helpers/radius.js';
69
70
  export { RenderIf, composeMemo, dataStringify, props, removeUndefinedValuesFromObject, styles, template } from './helpers/render.js';
70
- export { composeShadowCss, getResonsiveStyleShadow, getStyleShadow, getStyleShadowState, parseValueWithUnit } from './helpers/shadow.js';
71
+ export { composeShadowCss, getResponsiveStyleShadow, getStyleShadow, getStyleShadowState, parseValueWithUnit } from './helpers/shadow.js';
71
72
  export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getGlobalSizeGap, getHeightByShapeGlobalSize, getPaddingGlobalSize, getValueByDevice, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeGlobalSizeIcon, makeStyleWithDefault } from './helpers/size.js';
72
73
  export { composeFallbackTypographyStyle, composeFontFamilyTypographyV2, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, genTypoClass } from './helpers/typography.js';
73
74
  export { useAddToCart } from './hooks/cart/use-add-to-cart.js';
@@ -100,6 +101,7 @@ export { useProductList, useProductListProducts, useProductListSettings, useProd
100
101
  export { default as useSuspenseFetch } from './hooks/useSuspenseFetch.js';
101
102
  export { default as useSwatchesOptions } from './hooks/useSwatchesOptions.js';
102
103
  export { default as useInitialSwatchesOptions } from './hooks/useInitialSwatchesOptions.js';
104
+ export { InteractionTargetEvent, InteractionTriggerEvent } from './types/custom.js';
103
105
  import * as shop from './types/shop.js';
104
106
  export { shop as ShopType };
105
107
  import * as appAPI from './types/appAPI.js';
@@ -111,3 +113,4 @@ export { fetchMedias, fetchVariants, getProduct } from './helpers/queries/get-pr
111
113
  export { getProductBySlug } from './helpers/queries/get-product-by-slug.js';
112
114
  export { getAppBlocks } from './helpers/third-party/getAppBlocks.js';
113
115
  export { addAppBlockId } from './helpers/third-party/addAppBlockId.js';
116
+ export { useInteraction } from './helpers/interaction/index.js';
@@ -30,6 +30,8 @@ var AnimationTriggerType;
30
30
  (function(AnimationTriggerType) {
31
31
  AnimationTriggerType["Appear"] = 'appear';
32
32
  AnimationTriggerType["Hover"] = 'hover';
33
+ AnimationTriggerType["Hidden"] = 'hidden';
34
+ AnimationTriggerType["AppearByTrigger"] = 'appearByTrigger';
33
35
  })(AnimationTriggerType || (AnimationTriggerType = {}));
34
36
  var AnimationZoomDirectionType;
35
37
  (function(AnimationZoomDirectionType) {
@@ -0,0 +1,52 @@
1
+ var InteractionTargetEvent;
2
+ (function(InteractionTargetEvent) {
3
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-background-color'] = 0] = 'gp:change-background-color';
4
+ InteractionTargetEvent[InteractionTargetEvent['gp:run-animation'] = 1] = 'gp:run-animation';
5
+ InteractionTargetEvent[InteractionTargetEvent['gp:toggle-element-visibility'] = 2] = 'gp:toggle-element-visibility';
6
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-text'] = 3] = 'gp:change-text';
7
+ InteractionTargetEvent[InteractionTargetEvent['gp:scroll-to'] = 4] = 'gp:scroll-to';
8
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-text-style'] = 5] = 'gp:change-text-style';
9
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-content'] = 6] = 'gp:change-content';
10
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-button-style'] = 7] = 'gp:change-button-style';
11
+ InteractionTargetEvent[InteractionTargetEvent['gp:copy-text'] = 8] = 'gp:copy-text';
12
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-image'] = 9] = 'gp:change-image';
13
+ InteractionTargetEvent[InteractionTargetEvent['gp:toggle-video-play'] = 10] = 'gp:toggle-video-play';
14
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-slider-ratio'] = 11] = 'gp:change-slider-ratio';
15
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-icon-style'] = 12] = 'gp:change-icon-style';
16
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-expanded-item'] = 13] = 'gp:change-expanded-item';
17
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-active-item'] = 14] = 'gp:change-active-item';
18
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-slide'] = 15] = 'gp:change-slide';
19
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-image-step'] = 16] = 'gp:change-image-step';
20
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-text-value'] = 17] = 'gp:change-text-value';
21
+ InteractionTargetEvent[InteractionTargetEvent['gp:toggle-popup-open'] = 18] = 'gp:toggle-popup-open';
22
+ InteractionTargetEvent[InteractionTargetEvent['gp:show-or-hide'] = 19] = 'gp:show-or-hide';
23
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-banner'] = 20] = 'gp:change-banner';
24
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-open-tab'] = 21] = 'gp:change-open-tab';
25
+ })(InteractionTargetEvent || (InteractionTargetEvent = {}));
26
+ var InteractionTriggerEvent;
27
+ (function(InteractionTriggerEvent) {
28
+ InteractionTriggerEvent[InteractionTriggerEvent['click'] = 0] = 'click';
29
+ InteractionTriggerEvent[InteractionTriggerEvent["active"] = 1] = "active";
30
+ InteractionTriggerEvent[InteractionTriggerEvent['mouseover'] = 2] = 'mouseover';
31
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:appear'] = 3] = 'gp:appear';
32
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-selected'] = 4] = 'gp:item-selected';
33
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-unselected'] = 5] = 'gp:item-unselected';
34
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-hovered'] = 6] = 'gp:item-hovered';
35
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-click'] = 7] = 'gp:item-click';
36
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:after-submit'] = 8] = 'gp:after-submit';
37
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:quantity-change'] = 9] = 'gp:quantity-change';
38
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:after-checked-value'] = 10] = 'gp:after-checked-value';
39
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:after-add-to-cart'] = 11] = 'gp:after-add-to-cart';
40
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:popup-open'] = 12] = 'gp:popup-open';
41
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:popup-close'] = 13] = 'gp:popup-close';
42
+ InteractionTriggerEvent[InteractionTriggerEvent['scroll-up'] = 14] = 'scroll-up';
43
+ InteractionTriggerEvent[InteractionTriggerEvent['scroll-down'] = 15] = 'scroll-down';
44
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:price-change'] = 16] = 'gp:price-change';
45
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:rollback-price-change'] = 17] = 'gp:rollback-price-change';
46
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:compare-price-change'] = 18] = 'gp:compare-price-change';
47
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:rollback:compare-price-change'] = 19] = 'gp:rollback:compare-price-change';
48
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:stock-change'] = 20] = 'gp:stock-change';
49
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:rollback:stock-change'] = 21] = 'gp:rollback:stock-change';
50
+ })(InteractionTriggerEvent || (InteractionTriggerEvent = {}));
51
+
52
+ export { InteractionTargetEvent, InteractionTriggerEvent };