@gem-sdk/core 3.0.0-pre-production.15 → 3.0.6
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 +1 -1
- package/dist/cjs/components/AddOn.js +2 -18
- package/dist/cjs/components/ComponentAnimation.js +2 -17
- package/dist/cjs/components/ComponentToolbarPreview.js +2 -752
- package/dist/cjs/components/ComponentWrapper.js +2 -61
- package/dist/cjs/components/ComponentWrapperPreview.js +2 -213
- package/dist/cjs/components/Empty.js +2 -7
- package/dist/cjs/components/InteractionSuffix.js +2 -42
- package/dist/cjs/components/Render.js +2 -75
- package/dist/cjs/components/Render.liquid.js +16 -307
- package/dist/cjs/components/RenderBlock.js +2 -54
- package/dist/cjs/components/RenderCustomCode.js +4 -59
- package/dist/cjs/components/RenderPreview.js +2 -67
- package/dist/cjs/components/RenderSection.js +2 -23
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +2 -252
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +2 -85
- package/dist/cjs/components/ai-generator/components/PickProduct.js +2 -220
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +2 -77
- package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +1 -47
- package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +1 -110
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -37
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +1 -70
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +2 -67
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +2 -19
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +2 -37
- package/dist/cjs/components/ai-generator/icons/SearchIcon.js +2 -21
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +2 -21
- package/dist/cjs/components/ai-generator/icons/UpgradeIcon.js +2 -27
- package/dist/cjs/components/ai-generator/icons/WarningIcon.js +2 -31
- package/dist/cjs/components/constant.js +1 -82
- package/dist/cjs/components/resize/Resize.js +2 -16
- package/dist/cjs/components/resize/Spacing.js +2 -260
- package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -56
- package/dist/cjs/components/theme-section/CreateThemeSection.js +2 -123
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +2 -45
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +2 -126
- package/dist/cjs/components/toolbar/Tooltip.js +2 -28
- package/dist/cjs/constants/device.js +1 -0
- package/dist/cjs/contexts/AddonContext.js +2 -36
- package/dist/cjs/contexts/ArticleContext.js +2 -39
- package/dist/cjs/contexts/ArticleListContext.js +2 -31
- package/dist/cjs/contexts/BuilderComponent.js +2 -34
- package/dist/cjs/contexts/BuilderContext.js +2 -39
- package/dist/cjs/contexts/BuilderPreviewContext.js +2 -482
- package/dist/cjs/contexts/CartLineContext.js +2 -29
- package/dist/cjs/contexts/CollectionContext.js +2 -38
- package/dist/cjs/contexts/I18nContext.js +2 -0
- package/dist/cjs/contexts/ModalContext.js +2 -47
- package/dist/cjs/contexts/PageContext.js +2 -111
- package/dist/cjs/contexts/ProductContext.js +2 -182
- package/dist/cjs/contexts/ProductListContext.js +2 -32
- package/dist/cjs/contexts/SectionContext.js +2 -53
- package/dist/cjs/contexts/ShopContext.js +2 -107
- package/dist/cjs/graphql/fragments/analytic.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection-product.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection.generated.js +2 -6
- package/dist/cjs/graphql/fragments/custom-code.generated.js +2 -6
- package/dist/cjs/graphql/fragments/custom-font.generated.js +7 -7
- package/dist/cjs/graphql/fragments/data-seo.generated.js +2 -6
- package/dist/cjs/graphql/fragments/media.generated.js +2 -6
- package/dist/cjs/graphql/fragments/preview-theme-page.generated.js +6 -6
- package/dist/cjs/graphql/fragments/product-little.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product-option.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +4 -18
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +2 -6
- package/dist/cjs/graphql/fragments/selected-option.generated.js +2 -6
- package/dist/cjs/graphql/fragments/variant.generated.js +2 -6
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +2 -6
- package/dist/cjs/graphql/queries/articles.generated.js +2 -6
- package/dist/cjs/graphql/queries/blogs.generated.js +2 -6
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +2 -16
- package/dist/cjs/graphql/queries/collection.generated.js +2 -14
- package/dist/cjs/graphql/queries/collections.generated.js +2 -9
- package/dist/cjs/graphql/queries/preview-page.generated.js +2 -12
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +2 -11
- package/dist/cjs/graphql/queries/product-medias.generated.js +2 -8
- package/dist/cjs/graphql/queries/product-value-label.generated.js +2 -6
- package/dist/cjs/graphql/queries/product-variants.generated.js +3 -11
- package/dist/cjs/graphql/queries/products.generated.js +3 -17
- package/dist/cjs/graphql/queries/{published-shop-metas.js → published-shop-metas.generated.js} +2 -6
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +3 -19
- package/dist/cjs/graphql/queries/shop-shopify.generated.js +2 -6
- package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/SaleFunnelOffer.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/ShopLibraryPage.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +2 -6
- package/dist/cjs/helpers/GlobalEvent.js +1 -19
- package/dist/cjs/helpers/align.js +1 -37
- package/dist/cjs/helpers/animations.js +1 -222
- package/dist/cjs/helpers/background.js +1 -236
- package/dist/cjs/helpers/backgroundImage.js +1 -0
- package/dist/cjs/helpers/borders.js +4 -198
- package/dist/cjs/helpers/carousel.js +1 -55
- package/dist/cjs/helpers/clone-deep.js +1 -5
- package/dist/cjs/helpers/cls.js +1 -16
- package/dist/cjs/helpers/colors.js +1 -184
- package/dist/cjs/helpers/compose-advance-style.js +1 -323
- package/dist/cjs/helpers/composeClasses.js +1 -0
- package/dist/cjs/helpers/const.js +1 -0
- package/dist/cjs/helpers/constant.js +1 -23
- package/dist/cjs/helpers/convert.js +1 -7
- package/dist/cjs/helpers/covert-entities-html.js +1 -19
- package/dist/cjs/helpers/css-variable.js +1 -7
- package/dist/cjs/helpers/email.js +1 -11
- package/dist/cjs/helpers/filter-styles.js +1 -0
- package/dist/cjs/helpers/filter-toolbar-preview.js +2 -14
- package/dist/cjs/helpers/flatten-connection.js +1 -9
- package/dist/cjs/helpers/get-resonsive-value.js +1 -36
- package/dist/cjs/helpers/get-shortname.js +1 -92
- package/dist/cjs/helpers/icon-list.js +1 -61
- package/dist/cjs/helpers/interaction/index.js +2 -134
- package/dist/cjs/helpers/is-browser.js +1 -9
- package/dist/cjs/helpers/is-defined.js +1 -7
- package/dist/cjs/helpers/is-empty-children.js +2 -15
- package/dist/cjs/helpers/is-safari.js +1 -9
- package/dist/cjs/helpers/layout.js +1 -76
- package/dist/cjs/helpers/load-script.js +1 -31
- package/dist/cjs/helpers/loop-component.js +1 -16
- package/dist/cjs/helpers/make-style.js +1 -163
- package/dist/cjs/helpers/normalize-builder-data.js +1 -23
- package/dist/cjs/helpers/pascal-to-kebab-case.js +1 -7
- package/dist/cjs/helpers/prefetch-queries.js +1 -78
- package/dist/cjs/helpers/product.js +1 -48
- package/dist/cjs/helpers/queries/get-collection.js +1 -226
- package/dist/cjs/helpers/queries/get-collections.js +1 -21
- package/dist/cjs/helpers/queries/get-product-by-slug.js +1 -125
- package/dist/cjs/helpers/queries/get-product.js +1 -154
- package/dist/cjs/helpers/queries/get-products.js +1 -214
- package/dist/cjs/helpers/query.js +1 -29
- package/dist/cjs/helpers/radius.js +6 -140
- package/dist/cjs/helpers/render.js +1 -91
- package/dist/cjs/helpers/shadow.js +1 -69
- package/dist/cjs/helpers/size.js +4 -228
- package/dist/cjs/helpers/spacing.js +1 -43
- package/dist/cjs/helpers/third-party/addAppBlockId.js +1 -20
- package/dist/cjs/helpers/third-party/appConfig.js +1 -416
- package/dist/cjs/helpers/third-party/appSetting.js +1 -1324
- package/dist/cjs/helpers/third-party/composeAppBlockId.js +1 -11
- package/dist/cjs/helpers/third-party/constant.js +1 -69
- package/dist/cjs/helpers/third-party/generateAppBlockConfigs.js +1 -34
- package/dist/cjs/helpers/third-party/getAppBlockConfig.js +1 -55
- package/dist/cjs/helpers/third-party/getAppBlockType.js +1 -12
- package/dist/cjs/helpers/third-party/getAppBlocks.js +1 -30
- package/dist/cjs/helpers/third-party/mergeBlock.js +1 -19
- package/dist/cjs/helpers/third-party/mergeBlockOrder.js +1 -47
- package/dist/cjs/helpers/third-party/removeGPAppItems.js +1 -18
- package/dist/cjs/helpers/tracking/fpixel.js +1 -28
- package/dist/cjs/helpers/tracking/gtag.js +1 -93
- package/dist/cjs/helpers/tracking/tiktokpixel.js +1 -17
- package/dist/cjs/helpers/typography.js +19 -160
- package/dist/cjs/helpers/variant.js +1 -11
- package/dist/cjs/hooks/animation/useAnimationActions.js +2 -39
- package/dist/cjs/hooks/animation/useAnimationConfig.js +2 -30
- package/dist/cjs/hooks/animation/useAnimationPreview.js +2 -31
- package/dist/cjs/hooks/animation/useAnimationTarget.js +2 -122
- package/dist/cjs/hooks/animation/useApplyAnimation.js +2 -89
- package/dist/cjs/hooks/articles/useArticlesQuery.js +2 -33
- package/dist/cjs/hooks/cart/use-add-to-cart.js +2 -20
- package/dist/cjs/hooks/cart/use-cart-data.js +2 -28
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +2 -20
- package/dist/cjs/hooks/cart/use-cart-note-update.js +2 -20
- package/dist/cjs/hooks/cart/use-create-cart.js +2 -22
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +2 -20
- package/dist/cjs/hooks/cart/use-update-cart-item.js +2 -20
- package/dist/cjs/hooks/shop/use-collection-query.js +2 -22
- package/dist/cjs/hooks/shop/use-collections-query.js +2 -17
- package/dist/cjs/hooks/shop/use-product-query.js +2 -22
- package/dist/cjs/hooks/shop/use-products-query.js +2 -63
- package/dist/cjs/hooks/shop/useShopifyLink.js +2 -0
- package/dist/cjs/hooks/shop.js +2 -135
- package/dist/cjs/hooks/use-current-device.js +2 -30
- package/dist/cjs/hooks/use-lazy-video.js +2 -15
- package/dist/cjs/hooks/useAnimations.js +2 -29
- package/dist/cjs/hooks/useCartId.js +2 -44
- package/dist/cjs/hooks/useCartLine.js +2 -11
- package/dist/cjs/hooks/useCartUI.js +2 -48
- package/dist/cjs/hooks/useCollection.js +2 -9
- package/dist/cjs/hooks/useFetchHandle.js +2 -13
- package/dist/cjs/hooks/useFormatMoney.js +2 -75
- package/dist/cjs/hooks/useI18n.js +2 -0
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +2 -127
- package/dist/cjs/hooks/useInteraction.js +2 -19
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +2 -10
- package/dist/cjs/hooks/useLoadScript.js +2 -32
- package/dist/cjs/hooks/useMoney.js +2 -84
- package/dist/cjs/hooks/usePrevious.js +2 -19
- package/dist/cjs/hooks/useProduct.js +2 -250
- package/dist/cjs/hooks/useProductList.js +2 -21
- package/dist/cjs/hooks/useStickyStore.js +1 -0
- package/dist/cjs/hooks/useSuspenseFetch.js +2 -27
- package/dist/cjs/hooks/useSwatchesOptions.js +2 -41
- package/dist/cjs/hooks/useToolbarPostPurchase.js +2 -89
- package/dist/cjs/index.js +1 -425
- package/dist/cjs/types/animations.js +1 -49
- package/dist/cjs/types/appAPI.js +1 -2
- package/dist/cjs/types/custom.js +1 -52
- package/dist/cjs/types/global-style.js +1 -15
- package/dist/cjs/types/shop.js +1 -2
- package/dist/esm/components/AddOn.js +2 -14
- package/dist/esm/components/ComponentAnimation.js +2 -13
- package/dist/esm/components/ComponentToolbarPreview.js +2 -748
- package/dist/esm/components/ComponentWrapper.js +2 -57
- package/dist/esm/components/ComponentWrapperPreview.js +2 -209
- package/dist/esm/components/Empty.js +2 -3
- package/dist/esm/components/InteractionSuffix.js +2 -40
- package/dist/esm/components/Render.js +2 -71
- package/dist/esm/components/Render.liquid.js +16 -301
- package/dist/esm/components/RenderBlock.js +2 -50
- package/dist/esm/components/RenderCustomCode.js +4 -55
- package/dist/esm/components/RenderPreview.js +2 -63
- package/dist/esm/components/RenderSection.js +2 -19
- package/dist/esm/components/ai-generator/AIContentGenerator.js +2 -250
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +2 -83
- package/dist/esm/components/ai-generator/components/PickProduct.js +2 -218
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +2 -75
- package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +1 -45
- package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +1 -108
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -35
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +1 -68
- package/dist/esm/components/ai-generator/icons/AIIcon.js +2 -65
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +2 -17
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +2 -34
- package/dist/esm/components/ai-generator/icons/SearchIcon.js +2 -19
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +2 -19
- package/dist/esm/components/ai-generator/icons/UpgradeIcon.js +2 -25
- package/dist/esm/components/ai-generator/icons/WarningIcon.js +2 -29
- package/dist/esm/components/constant.js +1 -75
- package/dist/esm/components/resize/Resize.js +2 -12
- package/dist/esm/components/resize/Spacing.js +2 -256
- package/dist/esm/components/src/product/helpers/variant-presets.js +1 -54
- package/dist/esm/components/theme-section/CreateThemeSection.js +2 -121
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +2 -43
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +2 -124
- package/dist/esm/components/toolbar/Tooltip.js +2 -24
- package/dist/esm/constants/device.js +1 -0
- package/dist/esm/contexts/AddonContext.js +2 -32
- package/dist/esm/contexts/ArticleContext.js +2 -36
- package/dist/esm/contexts/ArticleListContext.js +2 -27
- package/dist/esm/contexts/BuilderComponent.js +2 -31
- package/dist/esm/contexts/BuilderContext.js +2 -36
- package/dist/esm/contexts/BuilderPreviewContext.js +2 -479
- package/dist/esm/contexts/CartLineContext.js +2 -26
- package/dist/esm/contexts/CollectionContext.js +2 -35
- package/dist/esm/contexts/I18nContext.js +2 -0
- package/dist/esm/contexts/ModalContext.js +2 -44
- package/dist/esm/contexts/PageContext.js +2 -108
- package/dist/esm/contexts/ProductContext.js +2 -179
- package/dist/esm/contexts/ProductListContext.js +2 -28
- package/dist/esm/contexts/SectionContext.js +2 -49
- package/dist/esm/contexts/ShopContext.js +2 -104
- package/dist/esm/graphql/fragments/analytic.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection-detail.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection-product.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection.generated.js +2 -4
- package/dist/esm/graphql/fragments/custom-code.generated.js +2 -4
- package/dist/esm/graphql/fragments/custom-font.generated.js +7 -5
- package/dist/esm/graphql/fragments/data-seo.generated.js +2 -4
- package/dist/esm/graphql/fragments/media.generated.js +2 -4
- package/dist/esm/graphql/fragments/preview-theme-page.generated.js +6 -4
- package/dist/esm/graphql/fragments/product-little.generated.js +2 -4
- package/dist/esm/graphql/fragments/product-option-value.generated.js +2 -4
- package/dist/esm/graphql/fragments/product-option.generated.js +2 -4
- package/dist/esm/graphql/fragments/product.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-page-section.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -16
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +2 -4
- package/dist/esm/graphql/fragments/selected-option.generated.js +2 -4
- package/dist/esm/graphql/fragments/variant.generated.js +2 -4
- package/dist/esm/graphql/mutations/page-view-up.generated.js +2 -4
- package/dist/esm/graphql/queries/articles.generated.js +2 -4
- package/dist/esm/graphql/queries/blogs.generated.js +2 -4
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +10 -22
- package/dist/esm/graphql/queries/collection.generated.js +8 -18
- package/dist/esm/graphql/queries/collections.generated.js +3 -8
- package/dist/esm/graphql/queries/preview-page.generated.js +6 -14
- package/dist/esm/graphql/queries/product-little-detail.generated.js +5 -12
- package/dist/esm/graphql/queries/product-medias.generated.js +2 -6
- package/dist/esm/graphql/queries/product-value-label.generated.js +2 -4
- package/dist/esm/graphql/queries/product-variants.generated.js +5 -11
- package/dist/esm/graphql/queries/products.generated.js +9 -20
- package/dist/esm/graphql/queries/{published-shop-metas.js → published-shop-metas.generated.js} +2 -4
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +6 -20
- package/dist/esm/graphql/queries/shop-shopify.generated.js +2 -4
- package/dist/esm/graphql/queries/store-property.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/SaleFunnelOffer.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/ShopLibraryPage.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +2 -4
- package/dist/esm/helpers/GlobalEvent.js +1 -15
- package/dist/esm/helpers/align.js +1 -34
- package/dist/esm/helpers/animations.js +1 -220
- package/dist/esm/helpers/background.js +1 -227
- package/dist/esm/helpers/backgroundImage.js +1 -0
- package/dist/esm/helpers/borders.js +4 -189
- package/dist/esm/helpers/carousel.js +1 -51
- package/dist/esm/helpers/clone-deep.js +1 -3
- package/dist/esm/helpers/cls.js +1 -14
- package/dist/esm/helpers/colors.js +1 -169
- package/dist/esm/helpers/compose-advance-style.js +1 -315
- package/dist/esm/helpers/composeClasses.js +1 -0
- package/dist/esm/helpers/const.js +1 -0
- package/dist/esm/helpers/constant.js +1 -19
- package/dist/esm/helpers/convert.js +1 -4
- package/dist/esm/helpers/covert-entities-html.js +1 -17
- package/dist/esm/helpers/css-variable.js +1 -5
- package/dist/esm/helpers/email.js +1 -6
- package/dist/esm/helpers/filter-styles.js +1 -0
- package/dist/esm/helpers/filter-toolbar-preview.js +2 -9
- package/dist/esm/helpers/flatten-connection.js +1 -7
- package/dist/esm/helpers/get-resonsive-value.js +1 -31
- package/dist/esm/helpers/get-shortname.js +1 -90
- package/dist/esm/helpers/icon-list.js +1 -58
- package/dist/esm/helpers/interaction/index.js +2 -132
- package/dist/esm/helpers/is-browser.js +1 -5
- package/dist/esm/helpers/is-defined.js +1 -5
- package/dist/esm/helpers/is-empty-children.js +2 -10
- package/dist/esm/helpers/is-safari.js +1 -5
- package/dist/esm/helpers/layout.js +1 -70
- package/dist/esm/helpers/load-script.js +1 -29
- package/dist/esm/helpers/loop-component.js +1 -14
- package/dist/esm/helpers/make-style.js +1 -149
- package/dist/esm/helpers/normalize-builder-data.js +1 -21
- package/dist/esm/helpers/pascal-to-kebab-case.js +1 -5
- package/dist/esm/helpers/prefetch-queries.js +1 -76
- package/dist/esm/helpers/product.js +1 -44
- package/dist/esm/helpers/queries/get-collection.js +1 -223
- package/dist/esm/helpers/queries/get-collections.js +1 -19
- package/dist/esm/helpers/queries/get-product-by-slug.js +1 -123
- package/dist/esm/helpers/queries/get-product.js +1 -150
- package/dist/esm/helpers/queries/get-products.js +1 -210
- package/dist/esm/helpers/query.js +1 -25
- package/dist/esm/helpers/radius.js +6 -132
- package/dist/esm/helpers/render.js +1 -82
- package/dist/esm/helpers/shadow.js +1 -63
- package/dist/esm/helpers/size.js +4 -213
- package/dist/esm/helpers/spacing.js +1 -40
- package/dist/esm/helpers/third-party/addAppBlockId.js +1 -18
- package/dist/esm/helpers/third-party/appConfig.js +1 -356
- package/dist/esm/helpers/third-party/appSetting.js +1 -1321
- package/dist/esm/helpers/third-party/composeAppBlockId.js +1 -9
- package/dist/esm/helpers/third-party/constant.js +1 -66
- package/dist/esm/helpers/third-party/generateAppBlockConfigs.js +1 -32
- package/dist/esm/helpers/third-party/getAppBlockConfig.js +1 -53
- package/dist/esm/helpers/third-party/getAppBlockType.js +1 -10
- package/dist/esm/helpers/third-party/getAppBlocks.js +1 -28
- package/dist/esm/helpers/third-party/mergeBlock.js +1 -17
- package/dist/esm/helpers/third-party/mergeBlockOrder.js +1 -45
- package/dist/esm/helpers/third-party/removeGPAppItems.js +1 -15
- package/dist/esm/helpers/tracking/fpixel.js +1 -24
- package/dist/esm/helpers/tracking/gtag.js +1 -87
- package/dist/esm/helpers/tracking/tiktokpixel.js +1 -15
- package/dist/esm/helpers/typography.js +19 -149
- package/dist/esm/helpers/variant.js +1 -9
- package/dist/esm/hooks/animation/useAnimationActions.js +2 -37
- package/dist/esm/hooks/animation/useAnimationConfig.js +2 -28
- package/dist/esm/hooks/animation/useAnimationPreview.js +2 -29
- package/dist/esm/hooks/animation/useAnimationTarget.js +2 -120
- package/dist/esm/hooks/animation/useApplyAnimation.js +2 -85
- package/dist/esm/hooks/articles/useArticlesQuery.js +2 -30
- package/dist/esm/hooks/cart/use-add-to-cart.js +2 -18
- package/dist/esm/hooks/cart/use-cart-data.js +2 -26
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +2 -18
- package/dist/esm/hooks/cart/use-cart-note-update.js +2 -18
- package/dist/esm/hooks/cart/use-create-cart.js +2 -20
- package/dist/esm/hooks/cart/use-remove-cart-item.js +2 -18
- package/dist/esm/hooks/cart/use-update-cart-item.js +2 -18
- package/dist/esm/hooks/shop/use-collection-query.js +2 -20
- package/dist/esm/hooks/shop/use-collections-query.js +2 -15
- package/dist/esm/hooks/shop/use-product-query.js +2 -20
- package/dist/esm/hooks/shop/use-products-query.js +2 -59
- package/dist/esm/hooks/shop/useShopifyLink.js +2 -0
- package/dist/esm/hooks/shop.js +2 -119
- package/dist/esm/hooks/use-current-device.js +2 -28
- package/dist/esm/hooks/use-lazy-video.js +2 -13
- package/dist/esm/hooks/useAnimations.js +2 -27
- package/dist/esm/hooks/useCartId.js +2 -40
- package/dist/esm/hooks/useCartLine.js +2 -7
- package/dist/esm/hooks/useCartUI.js +2 -44
- package/dist/esm/hooks/useCollection.js +2 -7
- package/dist/esm/hooks/useFetchHandle.js +2 -11
- package/dist/esm/hooks/useFormatMoney.js +2 -71
- package/dist/esm/hooks/useI18n.js +2 -0
- package/dist/esm/hooks/useInitialSwatchesOptions.js +2 -123
- package/dist/esm/hooks/useInteraction.js +2 -17
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +2 -6
- package/dist/esm/hooks/useLoadScript.js +2 -28
- package/dist/esm/hooks/useMoney.js +2 -80
- package/dist/esm/hooks/usePrevious.js +2 -17
- package/dist/esm/hooks/useProduct.js +2 -233
- package/dist/esm/hooks/useProductList.js +2 -16
- package/dist/esm/hooks/useStickyStore.js +1 -0
- package/dist/esm/hooks/useSuspenseFetch.js +2 -23
- package/dist/esm/hooks/useSwatchesOptions.js +2 -37
- package/dist/esm/hooks/useToolbarPostPurchase.js +2 -87
- package/dist/esm/index.js +1 -119
- package/dist/esm/types/animations.js +1 -49
- package/dist/esm/types/custom.js +1 -52
- package/dist/esm/types/global-style.js +1 -12
- package/dist/types/index.d.ts +12025 -8969
- package/package.json +6 -6
- package/dist/cjs/web-components/src/helpers/styles/constant.js +0 -9
- package/dist/esm/web-components/src/helpers/styles/constant.js +0 -7
|
@@ -1,252 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var AIIcon = require('./icons/AIIcon.js');
|
|
6
|
-
var CloseIcon = require('./icons/CloseIcon.js');
|
|
7
|
-
var ShowMoreIcon = require('./icons/ShowMoreIcon.js');
|
|
8
|
-
var WarningIcon = require('./icons/WarningIcon.js');
|
|
9
|
-
var UpgradeIcon = require('./icons/UpgradeIcon.js');
|
|
10
|
-
var PickProduct = require('./components/PickProduct.js');
|
|
11
|
-
var ToneAndVoice = require('./components/ToneAndVoice.js');
|
|
12
|
-
var classNames = require('classnames');
|
|
13
|
-
var useListenEventGenerate = require('./hooks/useListenEventGenerate.js');
|
|
14
|
-
var useGettingGenerateRequest = require('./hooks/useGettingGenerateRequest.js');
|
|
15
|
-
var useFlipPopup = require('./hooks/useFlipPopup.js');
|
|
16
|
-
var useCheckingProductInside = require('./hooks/useCheckingProductInside.js');
|
|
17
|
-
require('zustand');
|
|
18
|
-
require('react-transition-group');
|
|
19
|
-
require('@gem-sdk/core');
|
|
20
|
-
var ShopContext = require('../../contexts/ShopContext.js');
|
|
21
|
-
var dayjs = require('dayjs');
|
|
22
|
-
require('swr');
|
|
23
|
-
require('../../helpers/convert.js');
|
|
24
|
-
require('@gem-sdk/adapter-shopify');
|
|
25
|
-
require('swr/mutation');
|
|
26
|
-
require('swr/infinite');
|
|
27
|
-
require('vanilla-lazyload');
|
|
28
|
-
require('../../hooks/useCartUI.js');
|
|
29
|
-
|
|
30
|
-
const AIContentGenerator = ({ ...props })=>{
|
|
31
|
-
const [isShowPopup, setIsShowPopup] = react.useState(false);
|
|
32
|
-
const [isShowMore, setIsShowMore] = react.useState(false);
|
|
33
|
-
const genTool = react.useRef(null);
|
|
34
|
-
const genPopup = react.useRef(null);
|
|
35
|
-
const genPopupHeader = react.useRef(null);
|
|
36
|
-
const genButtonWrapper = react.useRef(null);
|
|
37
|
-
const nextMonth = dayjs().add(1, 'month').startOf('month').format('DD MMM');
|
|
38
|
-
const { popupPositionX, popupPositionY, isValidating: isValidatingFlipPopup, bodyMaxHeight: popupBodyMaxHeight } = useFlipPopup.useFlipPopup(isShowPopup, {
|
|
39
|
-
genTool,
|
|
40
|
-
genPopup,
|
|
41
|
-
genPopupHeader,
|
|
42
|
-
genButtonWrapper
|
|
43
|
-
});
|
|
44
|
-
const { isGenerating, onGenerate, onOpenProductElementSettings, goToPricing } = useListenEventGenerate.useListenEventGenerate({
|
|
45
|
-
uid: props.uid,
|
|
46
|
-
tag: String(props.tag)
|
|
47
|
-
});
|
|
48
|
-
const { getRequestBody, prompt, changeProductName, changePrompt, changeTone } = useGettingGenerateRequest.useGettingGenerateRequest();
|
|
49
|
-
const { productElement, checkSectionHasProduct } = useCheckingProductInside.useCheckingProductInside(genTool);
|
|
50
|
-
const generateLimitation = ShopContext.useShopStore((s)=>s.generateContentLimitation);
|
|
51
|
-
const togglePopup = ()=>{
|
|
52
|
-
setIsShowPopup(!isShowPopup);
|
|
53
|
-
};
|
|
54
|
-
const hidePopup = ()=>{
|
|
55
|
-
setIsShowPopup(false);
|
|
56
|
-
};
|
|
57
|
-
const onChangePrompt = (e)=>{
|
|
58
|
-
changePrompt(e.target.value);
|
|
59
|
-
};
|
|
60
|
-
const onActiveComponent = react.useCallback((e)=>{
|
|
61
|
-
const detail = e.detail;
|
|
62
|
-
if (detail?.componentUid !== props.uid) {
|
|
63
|
-
hidePopup();
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
checkSectionHasProduct();
|
|
67
|
-
}, [
|
|
68
|
-
props.uid,
|
|
69
|
-
checkSectionHasProduct
|
|
70
|
-
]);
|
|
71
|
-
const toggleShowMore = ()=>{
|
|
72
|
-
setIsShowMore(!isShowMore);
|
|
73
|
-
};
|
|
74
|
-
const handleGenerateContent = ()=>{
|
|
75
|
-
const body = getRequestBody();
|
|
76
|
-
onGenerate(body);
|
|
77
|
-
hidePopup();
|
|
78
|
-
};
|
|
79
|
-
const handleOpenProductSetting = ()=>{
|
|
80
|
-
onOpenProductElementSettings(productElement.uid ?? '');
|
|
81
|
-
};
|
|
82
|
-
react.useEffect(()=>{
|
|
83
|
-
if (!isGenerating) {
|
|
84
|
-
hidePopup();
|
|
85
|
-
}
|
|
86
|
-
}, [
|
|
87
|
-
isGenerating
|
|
88
|
-
]);
|
|
89
|
-
react.useEffect(()=>{
|
|
90
|
-
if (productElement.productId) {
|
|
91
|
-
setIsShowMore(false);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
setIsShowMore(true);
|
|
95
|
-
}, [
|
|
96
|
-
productElement
|
|
97
|
-
]);
|
|
98
|
-
react.useEffect(()=>{
|
|
99
|
-
window.addEventListener('editor:active-component', onActiveComponent);
|
|
100
|
-
return ()=>{
|
|
101
|
-
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
102
|
-
};
|
|
103
|
-
}, [
|
|
104
|
-
onActiveComponent
|
|
105
|
-
]);
|
|
106
|
-
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
107
|
-
className: "gp-gen-content-toolbar-wrapper gp-relative",
|
|
108
|
-
ref: genTool,
|
|
109
|
-
children: [
|
|
110
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
111
|
-
className: "gp-gen-content-btn gp-border-r gp-pr-1 gp-mr-1",
|
|
112
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
113
|
-
className: classNames({
|
|
114
|
-
'gp-toolbar-ai-active': isShowPopup
|
|
115
|
-
}, 'gp-p-1 gp-text-xs gp-flex gp-gap-1 gp-items-center gp-rounded-md hover:gp-bg-[#3B3B3B] gp-font-medium'),
|
|
116
|
-
onClick: togglePopup,
|
|
117
|
-
children: [
|
|
118
|
-
/*#__PURE__*/ jsxRuntime.jsx(AIIcon.AIIcon, {}),
|
|
119
|
-
"AI Content"
|
|
120
|
-
]
|
|
121
|
-
})
|
|
122
|
-
}),
|
|
123
|
-
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
124
|
-
className: classNames({
|
|
125
|
-
'gp-hidden': !isShowPopup,
|
|
126
|
-
'gp-right-0': props.tag === 'Section' || popupPositionX === 'right',
|
|
127
|
-
'gp-left-0': popupPositionX === 'left' && props.tag !== 'Section',
|
|
128
|
-
'gp-top-8': popupPositionY === 'top',
|
|
129
|
-
'gp-bottom-8': popupPositionY === 'bottom',
|
|
130
|
-
'!gp-visible': !isValidatingFlipPopup
|
|
131
|
-
}, 'gp-absolute gp-invisible gp-rounded-lg gp-bg-[#151515] gp-w-[312px] !gp-max-w-[312px] !gp-cursor-default'),
|
|
132
|
-
ref: genPopup,
|
|
133
|
-
children: [
|
|
134
|
-
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
135
|
-
className: "gp-flex gp-items-center gp-justify-between gp-px-4 gp-py-[10px]",
|
|
136
|
-
ref: genPopupHeader,
|
|
137
|
-
children: [
|
|
138
|
-
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
139
|
-
className: "gp-font-medium gp-text-sm",
|
|
140
|
-
children: "Write with GemAI"
|
|
141
|
-
}),
|
|
142
|
-
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
143
|
-
className: "gp-p-2 gp-cursor-pointer hover:gp-bg-[#3B3B3B] gp-rounded-md",
|
|
144
|
-
onClick: hidePopup,
|
|
145
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(CloseIcon.CloseIcon, {})
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
}),
|
|
149
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
150
|
-
className: classNames({
|
|
151
|
-
'gp-overflow-auto': popupBodyMaxHeight !== null
|
|
152
|
-
}, 'gp-pt-2 gp-text-left gp-px-4 scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl'),
|
|
153
|
-
style: {
|
|
154
|
-
maxHeight: popupBodyMaxHeight !== null ? `${popupBodyMaxHeight}px` : 'auto'
|
|
155
|
-
},
|
|
156
|
-
children: generateLimitation?.isAllow ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
157
|
-
children: [
|
|
158
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
159
|
-
className: "gp-mb-4",
|
|
160
|
-
children: /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
161
|
-
className: "gp-text-xs",
|
|
162
|
-
children: "What would you like to describe here?"
|
|
163
|
-
})
|
|
164
|
-
}),
|
|
165
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
166
|
-
className: "gp-mb-4 gp-flex",
|
|
167
|
-
children: /*#__PURE__*/ jsxRuntime.jsx("textarea", {
|
|
168
|
-
className: "gp-p-2 gp-bg-[#333333] gp-rounded-lg gp-w-full gp-text-xs gp-text-white placeholder:gp-text-[#AAAAAA] gp-resize-none focus-visible:gp-outline-none",
|
|
169
|
-
placeholder: "e.g: generate feature benefits",
|
|
170
|
-
rows: 4,
|
|
171
|
-
value: prompt,
|
|
172
|
-
onChange: onChangePrompt
|
|
173
|
-
})
|
|
174
|
-
}),
|
|
175
|
-
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
176
|
-
className: classNames({
|
|
177
|
-
'gp-hidden': !isShowMore
|
|
178
|
-
}, 'gp-mb-4 gp-gap-4 gp-flex gp-flex-col'),
|
|
179
|
-
children: [
|
|
180
|
-
/*#__PURE__*/ jsxRuntime.jsx(ToneAndVoice.ToneAndVoice, {
|
|
181
|
-
changeToneAndVoice: changeTone
|
|
182
|
-
}),
|
|
183
|
-
/*#__PURE__*/ jsxRuntime.jsx(PickProduct.PickProduct, {
|
|
184
|
-
changeProductName: changeProductName,
|
|
185
|
-
openProductSetting: handleOpenProductSetting,
|
|
186
|
-
productId: productElement.productId
|
|
187
|
-
})
|
|
188
|
-
]
|
|
189
|
-
}),
|
|
190
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
191
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
192
|
-
className: "gp-flex gp-justify-center gp-items-center gp-w-full gp-bg-[#333333] gp-py-2 gp-rounded-lg gp-gap-2 gp-text-xs gp-font-medium",
|
|
193
|
-
onClick: toggleShowMore,
|
|
194
|
-
children: [
|
|
195
|
-
"Show more",
|
|
196
|
-
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
197
|
-
className: classNames({
|
|
198
|
-
'gp-rotate-180': isShowMore
|
|
199
|
-
}),
|
|
200
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(ShowMoreIcon.ShowMoreIcon, {})
|
|
201
|
-
})
|
|
202
|
-
]
|
|
203
|
-
})
|
|
204
|
-
})
|
|
205
|
-
]
|
|
206
|
-
}) : /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
207
|
-
className: "gp-flex gp-gap-2 gp-p-3 gp-rounded-xl gp-bg-[#FDB913] gp-bg-opacity-20",
|
|
208
|
-
children: [
|
|
209
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
210
|
-
className: "gp-flex-none gp-w-7 gp-h-7 gp-rounded-lg gp-bg-[#FFB800] gp-flex gp-justify-center gp-items-center",
|
|
211
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(WarningIcon.WarningIcon, {})
|
|
212
|
-
}),
|
|
213
|
-
/*#__PURE__*/ jsxRuntime.jsxs("p", {
|
|
214
|
-
className: "gp-text-xs gp-whitespace-normal",
|
|
215
|
-
children: [
|
|
216
|
-
"You've reached ",
|
|
217
|
-
generateLimitation?.maxGenerateCount,
|
|
218
|
-
"/",
|
|
219
|
-
generateLimitation?.maxGenerateCount,
|
|
220
|
-
" rewrites of your AI generative this month.",
|
|
221
|
-
/*#__PURE__*/ jsxRuntime.jsx("br", {}),
|
|
222
|
-
"Resets on ",
|
|
223
|
-
nextMonth,
|
|
224
|
-
"."
|
|
225
|
-
]
|
|
226
|
-
})
|
|
227
|
-
]
|
|
228
|
-
})
|
|
229
|
-
}),
|
|
230
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
231
|
-
className: "gp-p-4",
|
|
232
|
-
ref: genButtonWrapper,
|
|
233
|
-
children: generateLimitation?.isAllow ? /*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
234
|
-
className: "gp-rounded-lg gp-w-full gp-text-xs gp-font-medium gp-bg-gradient-to-tl gp-from-[#3C38E1] gp-to-[#874CFD] gp-py-2",
|
|
235
|
-
onClick: handleGenerateContent,
|
|
236
|
-
children: isGenerating ? 'Generating...' : 'Generate'
|
|
237
|
-
}) : /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
238
|
-
className: "gp-flex gp-items-center gp-gap-2 gp-justify-center gp-rounded-lg gp-w-full gp-text-xs gp-font-medium gp-bg-gradient-to-tl gp-from-[#3C38E1] gp-to-[#874CFD] gp-py-2",
|
|
239
|
-
onClick: goToPricing,
|
|
240
|
-
children: [
|
|
241
|
-
/*#__PURE__*/ jsxRuntime.jsx(UpgradeIcon.UpgradeIcon, {}),
|
|
242
|
-
generateLimitation?.nextQuota ? `Upgrade to generate ${generateLimitation?.nextQuota} rewrites` : 'You have reached limit this month'
|
|
243
|
-
]
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
]
|
|
247
|
-
})
|
|
248
|
-
]
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
exports.AIContentGenerator = AIContentGenerator;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var jsxRuntime=require("react/jsx-runtime"),react=require("react"),AIIcon=require("./icons/AIIcon.js"),CloseIcon=require("./icons/CloseIcon.js"),ShowMoreIcon=require("./icons/ShowMoreIcon.js"),WarningIcon=require("./icons/WarningIcon.js"),UpgradeIcon=require("./icons/UpgradeIcon.js"),PickProduct=require("./components/PickProduct.js"),ToneAndVoice=require("./components/ToneAndVoice.js"),classNames=require("classnames"),useListenEventGenerate=require("./hooks/useListenEventGenerate.js"),useGettingGenerateRequest=require("./hooks/useGettingGenerateRequest.js"),useFlipPopup=require("./hooks/useFlipPopup.js"),useCheckingProductInside=require("./hooks/useCheckingProductInside.js");require("zustand");var I18nContext=require("../../contexts/I18nContext.js");require("react-transition-group"),require("@gem-sdk/core");var ShopContext=require("../../contexts/ShopContext.js"),dayjs=require("dayjs");require("swr"),require("../../helpers/convert.js"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("swr/infinite"),require("vanilla-lazyload"),require("../../hooks/useCartUI.js"),require("../../hooks/useStickyStore.js");const AIContentGenerator=({...e})=>{let[t,s]=react.useState(!1),[n,r]=react.useState(!1),i=react.useRef(null),o=react.useRef(null),a=react.useRef(null),p=react.useRef(null),u=dayjs().add(1,"month").startOf("month").format("DD MMM"),{t:g}=I18nContext.useI18nStore(),{popupPositionX:c,popupPositionY:l,isValidating:d,bodyMaxHeight:x}=useFlipPopup.useFlipPopup(t,{genTool:i,genPopup:o,genPopupHeader:a,genButtonWrapper:p}),{isGenerating:m,onGenerate:j,onOpenProductElementSettings:h,goToPricing:f}=useListenEventGenerate.useListenEventGenerate({uid:e.uid,tag:String(e.tag)}),{getRequestBody:I,prompt:R,changeProductName:b,changePrompt:v,changeTone:C}=useGettingGenerateRequest.useGettingGenerateRequest(),{productElement:q,checkSectionHasProduct:w}=useCheckingProductInside.useCheckingProductInside(i),N=ShopContext.useShopStore(e=>e.generateContentLimitation),k=()=>{s(!t)},A=()=>{s(!1)},G=e=>{v(e.target.value)},y=react.useCallback(t=>{let s=t.detail;if(s?.componentUid!==e.uid){A();return}w()},[e.uid,w]),S=()=>{r(!n)},P=()=>{let e=I();j(e),A()},E=()=>{h(q.uid??"")};return react.useEffect(()=>{m||A()},[m]),react.useEffect(()=>{if(q.productId){r(!1);return}r(!0)},[q]),react.useEffect(()=>(window.addEventListener("editor:active-component",y),()=>{window.removeEventListener("editor:active-component",y)}),[y]),jsxRuntime.jsxs("div",{className:"gp-gen-content-toolbar-wrapper gp-relative",ref:i,children:[jsxRuntime.jsx("div",{className:"gp-gen-content-btn gp-border-r gp-pr-1 gp-mr-1",children:jsxRuntime.jsxs("button",{className:classNames({"gp-toolbar-ai-active":t},"gp-p-1 gp-text-xs gp-flex gp-gap-1 gp-items-center gp-rounded-md hover:gp-bg-[#3B3B3B] gp-font-medium"),onClick:k,children:[jsxRuntime.jsx(AIIcon.AIIcon,{}),g("AI Content")]})}),jsxRuntime.jsxs("div",{className:classNames({"gp-hidden":!t,"gp-right-0":"Section"===e.tag||"right"===c,"gp-left-0":"left"===c&&"Section"!==e.tag,"gp-top-8":"top"===l,"gp-bottom-8":"bottom"===l,"!gp-visible":!d},"gp-absolute gp-invisible gp-rounded-lg gp-bg-[#151515] gp-w-[312px] !gp-max-w-[312px] !gp-cursor-default"),ref:o,children:[jsxRuntime.jsxs("div",{className:"gp-flex gp-items-center gp-justify-between gp-px-4 gp-py-[10px]",ref:a,children:[jsxRuntime.jsx("span",{className:"gp-font-medium gp-text-sm",children:"Write with GemAI"}),jsxRuntime.jsx("button",{className:"gp-p-2 gp-cursor-pointer hover:gp-bg-[#3B3B3B] gp-rounded-md",onClick:A,children:jsxRuntime.jsx(CloseIcon.CloseIcon,{})})]}),jsxRuntime.jsx("div",{className:classNames({"gp-overflow-auto":null!==x},"gp-pt-2 gp-text-left gp-px-4 scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl"),style:{maxHeight:null!==x?`${x}px`:"auto"},children:N?.isAllow?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"gp-mb-4",children:jsxRuntime.jsx("span",{className:"gp-text-xs",children:"What would you like to describe here?"})}),jsxRuntime.jsx("div",{className:"gp-mb-4 gp-flex",children:jsxRuntime.jsx("textarea",{className:"gp-p-2 gp-bg-[#333333] gp-rounded-lg gp-w-full gp-text-xs gp-text-white placeholder:gp-text-[#AAAAAA] gp-resize-none focus-visible:gp-outline-none",placeholder:"e.g: generate feature benefits",rows:4,value:R,onChange:G})}),jsxRuntime.jsxs("div",{className:classNames({"gp-hidden":!n},"gp-mb-4 gp-gap-4 gp-flex gp-flex-col"),children:[jsxRuntime.jsx(ToneAndVoice.ToneAndVoice,{changeToneAndVoice:C}),jsxRuntime.jsx(PickProduct.PickProduct,{changeProductName:b,openProductSetting:E,productId:q.productId})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("button",{className:"gp-flex gp-justify-center gp-items-center gp-w-full gp-bg-[#333333] gp-py-2 gp-rounded-lg gp-gap-2 gp-text-xs gp-font-medium",onClick:S,children:["Show more",jsxRuntime.jsx("span",{className:classNames({"gp-rotate-180":n}),children:jsxRuntime.jsx(ShowMoreIcon.ShowMoreIcon,{})})]})})]}):jsxRuntime.jsxs("div",{className:"gp-flex gp-gap-2 gp-p-3 gp-rounded-xl gp-bg-[#FDB913] gp-bg-opacity-20",children:[jsxRuntime.jsx("div",{className:"gp-flex-none gp-w-7 gp-h-7 gp-rounded-lg gp-bg-[#FFB800] gp-flex gp-justify-center gp-items-center",children:jsxRuntime.jsx(WarningIcon.WarningIcon,{})}),jsxRuntime.jsxs("p",{className:"gp-text-xs gp-whitespace-normal",children:["You've reached ",N?.maxGenerateCount,"/",N?.maxGenerateCount," rewrites of your AI generative this month.",jsxRuntime.jsx("br",{}),"Resets on ",u,"."]})]})}),jsxRuntime.jsx("div",{className:"gp-p-4",ref:p,children:N?.isAllow?jsxRuntime.jsx("button",{className:"gp-rounded-lg gp-w-full gp-text-xs gp-font-medium gp-bg-gradient-to-tl gp-from-[#3C38E1] gp-to-[#874CFD] gp-py-2",onClick:P,children:m?"Generating...":"Generate"}):jsxRuntime.jsxs("button",{className:"gp-flex gp-items-center gp-gap-2 gp-justify-center gp-rounded-lg gp-w-full gp-text-xs gp-font-medium gp-bg-gradient-to-tl gp-from-[#3C38E1] gp-to-[#874CFD] gp-py-2",onClick:f,children:[jsxRuntime.jsx(UpgradeIcon.UpgradeIcon,{}),N?.nextQuota?`Upgrade to generate ${N?.nextQuota} rewrites`:"You have reached limit this month"]})})]})]})};exports.AIContentGenerator=AIContentGenerator;
|
|
@@ -1,85 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var AIIcon = require('./icons/AIIcon.js');
|
|
6
|
-
|
|
7
|
-
function getRandomArbitrary(min, max) {
|
|
8
|
-
const randomNum = Math.random();
|
|
9
|
-
return randomNum * (max - min) + min;
|
|
10
|
-
}
|
|
11
|
-
const AIGenContentLoading = ({ ...props })=>{
|
|
12
|
-
const [isGenerating, setIsGenerating] = react.useState(false);
|
|
13
|
-
const [time, setTime] = react.useState(0);
|
|
14
|
-
const interval = react.useRef(null);
|
|
15
|
-
const onGenerateContentStatus = react.useCallback((e)=>{
|
|
16
|
-
const detail = e.detail;
|
|
17
|
-
if (detail?.generatingUid !== props.uid) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (detail.status === 'loading') {
|
|
21
|
-
setIsGenerating(true);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (detail.status === 'success') {
|
|
25
|
-
setIsGenerating(false);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}, [
|
|
29
|
-
props.uid
|
|
30
|
-
]);
|
|
31
|
-
react.useEffect(()=>{
|
|
32
|
-
if (isGenerating) {
|
|
33
|
-
handleFakeLoading();
|
|
34
|
-
} else {
|
|
35
|
-
setTime(0);
|
|
36
|
-
}
|
|
37
|
-
return ()=>{
|
|
38
|
-
interval.current && clearInterval(interval.current);
|
|
39
|
-
};
|
|
40
|
-
}, [
|
|
41
|
-
isGenerating
|
|
42
|
-
]);
|
|
43
|
-
const handleFakeLoading = ()=>{
|
|
44
|
-
setTime(0);
|
|
45
|
-
interval.current = setInterval(()=>{
|
|
46
|
-
setTime((time)=>{
|
|
47
|
-
const randomNum = getRandomArbitrary(0, 6);
|
|
48
|
-
return time >= 580 ? time : time + randomNum;
|
|
49
|
-
});
|
|
50
|
-
}, 50);
|
|
51
|
-
};
|
|
52
|
-
react.useEffect(()=>{
|
|
53
|
-
window.addEventListener('editor:ai-generate-content-status', onGenerateContentStatus);
|
|
54
|
-
return ()=>{
|
|
55
|
-
window.removeEventListener('editor:ai-generate-content-status', onGenerateContentStatus);
|
|
56
|
-
};
|
|
57
|
-
}, [
|
|
58
|
-
onGenerateContentStatus
|
|
59
|
-
]);
|
|
60
|
-
return isGenerating ? /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
61
|
-
className: "gp-absolute gp-top-0 gp-left-0 gp-w-full gp-h-full gp-bg-white gp-bg-opacity-70 gp-flex gp-justify-center gp-items-center gp-z-100 gp-gap-2",
|
|
62
|
-
children: [
|
|
63
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
64
|
-
className: "gp-absolute gp-left-0 gp-top-0 gp-z-2 gp-flex gp-h-full gp-w-full",
|
|
65
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
66
|
-
className: `gp-relative gp-h-[2px] gp-w-full gp-overflow-hidden gp-rounded-md`,
|
|
67
|
-
children: [
|
|
68
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
69
|
-
className: "gp-absolute gp-h-full gp-w-full gp-rounded-md gp-bg-[#F4F4F4]"
|
|
70
|
-
}),
|
|
71
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
72
|
-
className: "gps-image-to-layout-progress-bar gp-absolute gp-h-full gp-rounded-md gp-transition-all",
|
|
73
|
-
style: {
|
|
74
|
-
width: `${time / 600 * 100}%`
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
]
|
|
78
|
-
})
|
|
79
|
-
}),
|
|
80
|
-
/*#__PURE__*/ jsxRuntime.jsx(AIIcon.AIIcon, {})
|
|
81
|
-
]
|
|
82
|
-
}) : null;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
exports.AIGenContentLoading = AIGenContentLoading;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var jsxRuntime=require("react/jsx-runtime"),react=require("react"),AIIcon=require("./icons/AIIcon.js");function getRandomArbitrary(e,t){return Math.random()*(t-e)+e}const AIGenContentLoading=({...e})=>{let[t,n]=react.useState(!1),[r,s]=react.useState(0),a=react.useRef(null),i=react.useCallback(t=>{let r=t.detail;if(r?.generatingUid===e.uid){if("loading"===r.status){n(!0);return}if("success"===r.status){n(!1);return}}},[e.uid]);react.useEffect(()=>(t?l():s(0),()=>{a.current&&clearInterval(a.current)}),[t]);let l=()=>{s(0),a.current=setInterval(()=>{s(e=>{let t=getRandomArbitrary(0,6);return e>=580?e:e+t})},50)};return react.useEffect(()=>(window.addEventListener("editor:ai-generate-content-status",i),()=>{window.removeEventListener("editor:ai-generate-content-status",i)}),[i]),t?jsxRuntime.jsxs("div",{className:"gp-absolute gp-top-0 gp-left-0 gp-w-full gp-h-full gp-bg-white gp-bg-opacity-70 gp-flex gp-justify-center gp-items-center gp-z-100 gp-gap-2",children:[jsxRuntime.jsx("div",{className:"gp-absolute gp-left-0 gp-top-0 gp-z-2 gp-flex gp-h-full gp-w-full",children:jsxRuntime.jsxs("div",{className:"gp-relative gp-h-[2px] gp-w-full gp-overflow-hidden gp-rounded-md",children:[jsxRuntime.jsx("div",{className:"gp-absolute gp-h-full gp-w-full gp-rounded-md gp-bg-[#F4F4F4]"}),jsxRuntime.jsx("div",{className:"gps-image-to-layout-progress-bar gp-absolute gp-h-full gp-rounded-md gp-transition-all",style:{width:`${r/600*100}%`}})]})}),jsxRuntime.jsx(AIIcon.AIIcon,{})]}):null};exports.AIGenContentLoading=AIGenContentLoading;
|
|
@@ -1,220 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var SearchIcon = require('../icons/SearchIcon.js');
|
|
6
|
-
var useProductsQuery = require('../../../hooks/shop/use-products-query.js');
|
|
7
|
-
var classNames = require('classnames');
|
|
8
|
-
require('zustand');
|
|
9
|
-
require('react-transition-group');
|
|
10
|
-
require('@gem-sdk/core');
|
|
11
|
-
require('swr');
|
|
12
|
-
require('dayjs');
|
|
13
|
-
require('../../../helpers/convert.js');
|
|
14
|
-
require('@gem-sdk/adapter-shopify');
|
|
15
|
-
require('swr/mutation');
|
|
16
|
-
var useProductQuery = require('../../../hooks/shop/use-product-query.js');
|
|
17
|
-
require('vanilla-lazyload');
|
|
18
|
-
require('../../../hooks/useCartUI.js');
|
|
19
|
-
|
|
20
|
-
const PickProduct = (props)=>{
|
|
21
|
-
const LIMIT_PRODUCTS = 8;
|
|
22
|
-
const [productVariables, setProductVariables] = react.useState(!props.productId ? {
|
|
23
|
-
first: LIMIT_PRODUCTS
|
|
24
|
-
} : undefined);
|
|
25
|
-
const { data: productList, isLoading: isLoadingGetProducts, isValidating: isValidatingGetProducts, size: productsSize, setSize: setProductsSize } = useProductsQuery.useListProductQuery(productVariables, {
|
|
26
|
-
revalidateFirstPage: false
|
|
27
|
-
});
|
|
28
|
-
const { data: sectionProduct } = useProductQuery.useProductQuery(props.productId);
|
|
29
|
-
const [activeProduct, setActiveProduct] = react.useState();
|
|
30
|
-
const [isShowChooseProduct, setIsShowChooseProduct] = react.useState(false);
|
|
31
|
-
const debounceSearch = react.useRef(null);
|
|
32
|
-
const debounceScroll = react.useRef(null);
|
|
33
|
-
const toggleChooseProduct = ()=>{
|
|
34
|
-
if (props.productId) return;
|
|
35
|
-
setIsShowChooseProduct(!isShowChooseProduct);
|
|
36
|
-
};
|
|
37
|
-
const chooseProduct = (product)=>{
|
|
38
|
-
setActiveProduct(product);
|
|
39
|
-
setIsShowChooseProduct(false);
|
|
40
|
-
};
|
|
41
|
-
const searchProduct = (e)=>{
|
|
42
|
-
debounceSearch.current && clearTimeout(debounceSearch.current);
|
|
43
|
-
debounceSearch.current = setTimeout(()=>{
|
|
44
|
-
const searchValue = e.target.value ?? '';
|
|
45
|
-
if (searchValue) {
|
|
46
|
-
setProductVariables({
|
|
47
|
-
first: LIMIT_PRODUCTS,
|
|
48
|
-
where: {
|
|
49
|
-
titleContainsFold: searchValue
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
setProductVariables({
|
|
55
|
-
first: LIMIT_PRODUCTS
|
|
56
|
-
});
|
|
57
|
-
}, 200);
|
|
58
|
-
};
|
|
59
|
-
const handleOpenProductElementSettings = ()=>{
|
|
60
|
-
props.openProductSetting();
|
|
61
|
-
};
|
|
62
|
-
const handleLoadMore = (e)=>{
|
|
63
|
-
const target = e.target;
|
|
64
|
-
if (target.scrollHeight - target.scrollTop === target.clientHeight) {
|
|
65
|
-
debounceScroll.current && clearTimeout(debounceScroll.current);
|
|
66
|
-
debounceScroll.current = setTimeout(()=>{
|
|
67
|
-
setProductsSize(productsSize + 1);
|
|
68
|
-
}, 50);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const products = react.useMemo(()=>{
|
|
72
|
-
return productList?.reduce((acc, curr)=>{
|
|
73
|
-
return [
|
|
74
|
-
...acc,
|
|
75
|
-
...curr.products?.edges ?? []
|
|
76
|
-
];
|
|
77
|
-
}, []) ?? [];
|
|
78
|
-
}, [
|
|
79
|
-
productList
|
|
80
|
-
]);
|
|
81
|
-
react.useEffect(()=>{
|
|
82
|
-
if (products.length && !activeProduct && !props.productId) {
|
|
83
|
-
const firstProduct = products[0]?.node;
|
|
84
|
-
if (!firstProduct) return;
|
|
85
|
-
setActiveProduct({
|
|
86
|
-
id: firstProduct?.id,
|
|
87
|
-
name: firstProduct?.title,
|
|
88
|
-
image: firstProduct.featuredImage?.src
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}, [
|
|
92
|
-
products,
|
|
93
|
-
activeProduct,
|
|
94
|
-
props.productId
|
|
95
|
-
]);
|
|
96
|
-
react.useEffect(()=>{
|
|
97
|
-
if (activeProduct && activeProduct.name) {
|
|
98
|
-
props.changeProductName(activeProduct.name);
|
|
99
|
-
}
|
|
100
|
-
}, [
|
|
101
|
-
activeProduct,
|
|
102
|
-
props
|
|
103
|
-
]);
|
|
104
|
-
react.useEffect(()=>{
|
|
105
|
-
if (sectionProduct) {
|
|
106
|
-
setActiveProduct({
|
|
107
|
-
id: sectionProduct.id,
|
|
108
|
-
name: sectionProduct.title,
|
|
109
|
-
image: sectionProduct.featuredImage?.src
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}, [
|
|
113
|
-
sectionProduct
|
|
114
|
-
]);
|
|
115
|
-
const NO_IMAGE_SRC = 'https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif';
|
|
116
|
-
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
117
|
-
className: "gp-flex gp-flex-col gp-gap-2",
|
|
118
|
-
children: [
|
|
119
|
-
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
120
|
-
className: "gp-py-2 gp-text-xs",
|
|
121
|
-
children: "Product"
|
|
122
|
-
}),
|
|
123
|
-
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
124
|
-
className: "gp-relative",
|
|
125
|
-
children: [
|
|
126
|
-
!isLoadingGetProducts || activeProduct ? /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
127
|
-
className: classNames({
|
|
128
|
-
'gp-cursor-default': props.productId
|
|
129
|
-
}, 'gp-flex gp-gap-2 gp-items-center gp-w-full gp-p-2 gp-rounded-lg gp-bg-[#333333] gp-text-xs'),
|
|
130
|
-
onClick: toggleChooseProduct,
|
|
131
|
-
children: [
|
|
132
|
-
/*#__PURE__*/ jsxRuntime.jsx("img", {
|
|
133
|
-
className: "gp-rounded-lg gp-w-10 gp-h-10",
|
|
134
|
-
src: activeProduct?.image || NO_IMAGE_SRC,
|
|
135
|
-
alt: "product_image"
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
138
|
-
className: "gp-truncate gp-max-w-[210px]",
|
|
139
|
-
children: activeProduct?.name
|
|
140
|
-
})
|
|
141
|
-
]
|
|
142
|
-
}) : /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
143
|
-
children: /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
144
|
-
className: "gp-text-xs",
|
|
145
|
-
children: "Getting products..."
|
|
146
|
-
})
|
|
147
|
-
}),
|
|
148
|
-
props.productId && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
149
|
-
className: "gp-mt-2 gp-text-xs",
|
|
150
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs("p", {
|
|
151
|
-
children: [
|
|
152
|
-
"You can manage it in",
|
|
153
|
-
' ',
|
|
154
|
-
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
155
|
-
className: "gp-text-[#8AA4FF] gp-cursor-pointer hover:gp-underline",
|
|
156
|
-
onClick: handleOpenProductElementSettings,
|
|
157
|
-
children: "Product element"
|
|
158
|
-
})
|
|
159
|
-
]
|
|
160
|
-
})
|
|
161
|
-
}),
|
|
162
|
-
isShowChooseProduct && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
163
|
-
className: "gp-absolute gp-w-full gp-top-16 gp-left-0 gp-rounded-lg gp-bg-[#333333] gp-p-2 gp-flex gp-flex-col gp-gap-2 gp-z-10",
|
|
164
|
-
children: [
|
|
165
|
-
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
166
|
-
className: "gp-flex gp-items-center gp-gap-2 gp-p-2",
|
|
167
|
-
children: [
|
|
168
|
-
/*#__PURE__*/ jsxRuntime.jsx(SearchIcon.SearchIcon, {}),
|
|
169
|
-
/*#__PURE__*/ jsxRuntime.jsx("input", {
|
|
170
|
-
className: "gp-bg-transparent gp-w-full focus-visible:!gp-outline-none gp-text-xs",
|
|
171
|
-
placeholder: "Search product...",
|
|
172
|
-
onChange: searchProduct
|
|
173
|
-
})
|
|
174
|
-
]
|
|
175
|
-
}),
|
|
176
|
-
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
177
|
-
className: "gp-max-h-[168px] gp-overflow-auto scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl",
|
|
178
|
-
onScroll: handleLoadMore,
|
|
179
|
-
children: [
|
|
180
|
-
products?.map((item)=>{
|
|
181
|
-
return /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
182
|
-
className: "gp-flex gp-p-2 hover:gp-bg-[#3B3B3B] gp-rounded-lg gp-cursor-pointer gp-gap-2 gp-items-center",
|
|
183
|
-
onClick: ()=>{
|
|
184
|
-
chooseProduct({
|
|
185
|
-
id: item.node?.id,
|
|
186
|
-
name: item.node?.title,
|
|
187
|
-
image: item.node?.featuredImage?.src
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
children: [
|
|
191
|
-
/*#__PURE__*/ jsxRuntime.jsx("img", {
|
|
192
|
-
className: "gp-rounded-lg gp-w-10 gp-h-10",
|
|
193
|
-
src: item.node?.featuredImage?.src || NO_IMAGE_SRC,
|
|
194
|
-
alt: "product_image"
|
|
195
|
-
}),
|
|
196
|
-
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
197
|
-
className: "gp-truncate gp-max-w-[210px] gp-text-xs",
|
|
198
|
-
children: item.node?.title
|
|
199
|
-
})
|
|
200
|
-
]
|
|
201
|
-
}, item.node?.id);
|
|
202
|
-
}),
|
|
203
|
-
isLoadingGetProducts || isValidatingGetProducts && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
204
|
-
className: "gp-p-2",
|
|
205
|
-
children: /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
206
|
-
className: "gp-text-xs",
|
|
207
|
-
children: "Getting products..."
|
|
208
|
-
})
|
|
209
|
-
})
|
|
210
|
-
]
|
|
211
|
-
})
|
|
212
|
-
]
|
|
213
|
-
})
|
|
214
|
-
]
|
|
215
|
-
})
|
|
216
|
-
]
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
exports.PickProduct = PickProduct;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var jsxRuntime=require("react/jsx-runtime"),react=require("react"),SearchIcon=require("../icons/SearchIcon.js"),useProductsQuery=require("../../../hooks/shop/use-products-query.js"),classNames=require("classnames");require("zustand"),require("react-transition-group"),require("@gem-sdk/core"),require("swr"),require("dayjs"),require("../../../helpers/convert.js"),require("@gem-sdk/adapter-shopify"),require("swr/mutation");var useProductQuery=require("../../../hooks/shop/use-product-query.js");require("vanilla-lazyload"),require("../../../hooks/useCartUI.js"),require("../../../hooks/useStickyStore.js");const PickProduct=e=>{let[s,t]=react.useState(e.productId?void 0:{first:8}),{data:r,isLoading:a,isValidating:u,size:c,setSize:i}=useProductsQuery.useListProductQuery(s,{revalidateFirstPage:!1}),{data:n}=useProductQuery.useProductQuery(e.productId),[p,l]=react.useState(),[g,o]=react.useState(!1),d=react.useRef(null),m=react.useRef(null),x=()=>{e.productId||o(!g)},j=e=>{l(e),o(!1)},h=e=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{let s=e.target.value??"";if(s){t({first:8,where:{titleContainsFold:s}});return}t({first:8})},200)},f=()=>{e.openProductSetting()},b=e=>{let s=e.target;s.scrollHeight-s.scrollTop===s.clientHeight&&(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{i(c+1)},50))},R=react.useMemo(()=>r?.reduce((e,s)=>[...e,...s.products?.edges??[]],[])??[],[r]);react.useEffect(()=>{if(R.length&&!p&&!e.productId){let e=R[0]?.node;e&&l({id:e?.id,name:e?.title,image:e.featuredImage?.src})}},[R,p,e.productId]),react.useEffect(()=>{p&&p.name&&e.changeProductName(p.name)},[p,e]),react.useEffect(()=>{n&&l({id:n.id,name:n.title,image:n.featuredImage?.src})},[n]);let N="https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif";return jsxRuntime.jsxs("div",{className:"gp-flex gp-flex-col gp-gap-2",children:[jsxRuntime.jsx("p",{className:"gp-py-2 gp-text-xs",children:"Product"}),jsxRuntime.jsxs("div",{className:"gp-relative",children:[!a||p?jsxRuntime.jsxs("button",{className:classNames({"gp-cursor-default":e.productId},"gp-flex gp-gap-2 gp-items-center gp-w-full gp-p-2 gp-rounded-lg gp-bg-[#333333] gp-text-xs"),onClick:x,children:[jsxRuntime.jsx("img",{className:"gp-rounded-lg gp-w-10 gp-h-10",src:p?.image||N,alt:"product_image"}),jsxRuntime.jsx("span",{className:"gp-truncate gp-max-w-[210px]",children:p?.name})]}):jsxRuntime.jsx("div",{children:jsxRuntime.jsx("span",{className:"gp-text-xs",children:"Getting products..."})}),e.productId&&jsxRuntime.jsx("div",{className:"gp-mt-2 gp-text-xs",children:jsxRuntime.jsxs("p",{children:["You can manage it in"," ",jsxRuntime.jsx("button",{className:"gp-text-[#8AA4FF] gp-cursor-pointer hover:gp-underline",onClick:f,children:"Product element"})]})}),g&&jsxRuntime.jsxs("div",{className:"gp-absolute gp-w-full gp-top-16 gp-left-0 gp-rounded-lg gp-bg-[#333333] gp-p-2 gp-flex gp-flex-col gp-gap-2 gp-z-10",children:[jsxRuntime.jsxs("div",{className:"gp-flex gp-items-center gp-gap-2 gp-p-2",children:[jsxRuntime.jsx(SearchIcon.SearchIcon,{}),jsxRuntime.jsx("input",{className:"gp-bg-transparent gp-w-full focus-visible:!gp-outline-none gp-text-xs",placeholder:"Search product...",onChange:h})]}),jsxRuntime.jsxs("div",{className:"gp-max-h-[168px] gp-overflow-auto scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl",onScroll:b,children:[R?.map(e=>jsxRuntime.jsxs("button",{className:"gp-flex gp-p-2 hover:gp-bg-[#3B3B3B] gp-rounded-lg gp-cursor-pointer gp-gap-2 gp-items-center",onClick:()=>{j({id:e.node?.id,name:e.node?.title,image:e.node?.featuredImage?.src})},children:[jsxRuntime.jsx("img",{className:"gp-rounded-lg gp-w-10 gp-h-10",src:e.node?.featuredImage?.src||N,alt:"product_image"}),jsxRuntime.jsx("span",{className:"gp-truncate gp-max-w-[210px] gp-text-xs",children:e.node?.title})]},e.node?.id)),a||u&&jsxRuntime.jsx("div",{className:"gp-p-2",children:jsxRuntime.jsx("span",{className:"gp-text-xs",children:"Getting products..."})})]})]})]})]})};exports.PickProduct=PickProduct;
|