@anker-in/headless-ui 1.1.56 → 1.1.57

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 (187) hide show
  1. package/dist/cjs/biz-components/ActiveShelf/ProductCard.d.ts +1 -1
  2. package/dist/cjs/biz-components/ActiveShelf/ProductCard.js +1 -1
  3. package/dist/cjs/biz-components/ActiveShelf/ProductCard.js.map +2 -2
  4. package/dist/cjs/biz-components/ActiveShelf/index.js +1 -1
  5. package/dist/cjs/biz-components/ActiveShelf/index.js.map +2 -2
  6. package/dist/cjs/biz-components/BuyOneGetOneShelf/FreeGiftItem.js +1 -1
  7. package/dist/cjs/biz-components/BuyOneGetOneShelf/FreeGiftItem.js.map +2 -2
  8. package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.js +1 -1
  9. package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.js.map +2 -2
  10. package/dist/cjs/biz-components/BuyOneGetOneShelf/index.js +1 -1
  11. package/dist/cjs/biz-components/BuyOneGetOneShelf/index.js.map +2 -2
  12. package/dist/cjs/biz-components/Category/SwiperCategory.d.ts +2 -0
  13. package/dist/cjs/biz-components/Category/SwiperCategory.js +1 -1
  14. package/dist/cjs/biz-components/Category/SwiperCategory.js.map +3 -3
  15. package/dist/cjs/biz-components/Category/index.js +1 -1
  16. package/dist/cjs/biz-components/Category/index.js.map +3 -3
  17. package/dist/cjs/biz-components/CreditsShelf/ProductCard.d.ts +41 -0
  18. package/dist/cjs/biz-components/CreditsShelf/ProductCard.js +2 -0
  19. package/dist/cjs/biz-components/CreditsShelf/ProductCard.js.map +7 -0
  20. package/dist/cjs/biz-components/CreditsShelf/ProductsList.d.ts +20 -0
  21. package/dist/cjs/biz-components/CreditsShelf/ProductsList.js +2 -0
  22. package/dist/cjs/biz-components/CreditsShelf/ProductsList.js.map +7 -0
  23. package/dist/cjs/biz-components/CreditsShelf/Root.d.ts +43 -0
  24. package/dist/cjs/biz-components/CreditsShelf/Root.js +2 -0
  25. package/dist/cjs/biz-components/CreditsShelf/Root.js.map +7 -0
  26. package/dist/cjs/biz-components/CreditsShelf/context.d.ts +40 -0
  27. package/dist/cjs/biz-components/CreditsShelf/context.js +2 -0
  28. package/dist/cjs/biz-components/CreditsShelf/context.js.map +7 -0
  29. package/dist/cjs/biz-components/CreditsShelf/index.d.ts +15 -0
  30. package/dist/cjs/biz-components/CreditsShelf/index.js +2 -0
  31. package/dist/cjs/biz-components/CreditsShelf/index.js.map +7 -0
  32. package/dist/cjs/biz-components/CreditsShelf/types.d.ts +73 -0
  33. package/dist/cjs/biz-components/CreditsShelf/types.js +2 -0
  34. package/dist/cjs/biz-components/CreditsShelf/types.js.map +7 -0
  35. package/dist/cjs/biz-components/ImageOverlayShelf/ProductCard.js +1 -1
  36. package/dist/cjs/biz-components/ImageOverlayShelf/ProductCard.js.map +2 -2
  37. package/dist/cjs/biz-components/MediaPlayerBase/index.js +1 -1
  38. package/dist/cjs/biz-components/MediaPlayerBase/index.js.map +2 -2
  39. package/dist/cjs/biz-components/MediaShelf/ProductCard.js +1 -1
  40. package/dist/cjs/biz-components/MediaShelf/ProductCard.js.map +2 -2
  41. package/dist/cjs/biz-components/MiniCart/CircleProgress.d.ts +38 -0
  42. package/dist/cjs/biz-components/MiniCart/CircleProgress.js +2 -0
  43. package/dist/cjs/biz-components/MiniCart/CircleProgress.js.map +7 -0
  44. package/dist/cjs/biz-components/MiniCart/MiniCartDialog.js +1 -1
  45. package/dist/cjs/biz-components/MiniCart/MiniCartDialog.js.map +1 -1
  46. package/dist/cjs/biz-components/MiniCart/index.d.ts +31 -1
  47. package/dist/cjs/biz-components/MiniCart/index.js +1 -1
  48. package/dist/cjs/biz-components/MiniCart/index.js.map +3 -3
  49. package/dist/cjs/biz-components/SceneShelf/Footer.d.ts +21 -0
  50. package/dist/cjs/biz-components/SceneShelf/Footer.js +2 -0
  51. package/dist/cjs/biz-components/SceneShelf/Footer.js.map +7 -0
  52. package/dist/cjs/biz-components/SceneShelf/ProductCard.d.ts +23 -0
  53. package/dist/cjs/biz-components/SceneShelf/ProductCard.js +2 -0
  54. package/dist/cjs/biz-components/SceneShelf/ProductCard.js.map +7 -0
  55. package/dist/cjs/biz-components/SceneShelf/ProductsPanel.d.ts +26 -0
  56. package/dist/cjs/biz-components/SceneShelf/ProductsPanel.js +2 -0
  57. package/dist/cjs/biz-components/SceneShelf/ProductsPanel.js.map +7 -0
  58. package/dist/cjs/biz-components/SceneShelf/Root.d.ts +20 -0
  59. package/dist/cjs/biz-components/SceneShelf/Root.js +2 -0
  60. package/dist/cjs/biz-components/SceneShelf/Root.js.map +7 -0
  61. package/dist/cjs/biz-components/SceneShelf/Scene.d.ts +38 -0
  62. package/dist/cjs/biz-components/SceneShelf/Scene.js +2 -0
  63. package/dist/cjs/biz-components/SceneShelf/Scene.js.map +7 -0
  64. package/dist/cjs/biz-components/SceneShelf/SceneImage.d.ts +14 -0
  65. package/dist/cjs/biz-components/SceneShelf/SceneImage.js +2 -0
  66. package/dist/cjs/biz-components/SceneShelf/SceneImage.js.map +7 -0
  67. package/dist/cjs/biz-components/SceneShelf/context.d.ts +40 -0
  68. package/dist/cjs/biz-components/SceneShelf/context.js +2 -0
  69. package/dist/cjs/biz-components/SceneShelf/context.js.map +7 -0
  70. package/dist/cjs/biz-components/SceneShelf/index.d.ts +21 -0
  71. package/dist/cjs/biz-components/SceneShelf/index.js +2 -0
  72. package/dist/cjs/biz-components/SceneShelf/index.js.map +7 -0
  73. package/dist/cjs/biz-components/SceneShelf/types.d.ts +51 -0
  74. package/dist/cjs/biz-components/SceneShelf/types.js +2 -0
  75. package/dist/cjs/biz-components/SceneShelf/types.js.map +7 -0
  76. package/dist/cjs/biz-components/SecondaryBanner/index.d.ts +25 -0
  77. package/dist/cjs/biz-components/SecondaryBanner/index.js +1 -1
  78. package/dist/cjs/biz-components/SecondaryBanner/index.js.map +3 -3
  79. package/dist/cjs/biz-components/index.d.ts +7 -1
  80. package/dist/cjs/biz-components/index.js +1 -1
  81. package/dist/cjs/biz-components/index.js.map +3 -3
  82. package/dist/cjs/components/Countdown.js +1 -1
  83. package/dist/cjs/components/Countdown.js.map +2 -2
  84. package/dist/cjs/components/button.js +1 -1
  85. package/dist/cjs/components/button.js.map +2 -2
  86. package/dist/cjs/components/checkbox.js +1 -1
  87. package/dist/cjs/components/checkbox.js.map +2 -2
  88. package/dist/cjs/components/text.js +1 -1
  89. package/dist/cjs/components/text.js.map +2 -2
  90. package/dist/esm/biz-components/ActiveShelf/ProductCard.d.ts +1 -1
  91. package/dist/esm/biz-components/ActiveShelf/ProductCard.js +1 -1
  92. package/dist/esm/biz-components/ActiveShelf/ProductCard.js.map +2 -2
  93. package/dist/esm/biz-components/ActiveShelf/index.js +1 -1
  94. package/dist/esm/biz-components/ActiveShelf/index.js.map +2 -2
  95. package/dist/esm/biz-components/BuyOneGetOneShelf/FreeGiftItem.js +1 -1
  96. package/dist/esm/biz-components/BuyOneGetOneShelf/FreeGiftItem.js.map +2 -2
  97. package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.js +1 -1
  98. package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.js.map +2 -2
  99. package/dist/esm/biz-components/BuyOneGetOneShelf/index.js +1 -1
  100. package/dist/esm/biz-components/BuyOneGetOneShelf/index.js.map +2 -2
  101. package/dist/esm/biz-components/Category/SwiperCategory.d.ts +2 -0
  102. package/dist/esm/biz-components/Category/SwiperCategory.js +1 -1
  103. package/dist/esm/biz-components/Category/SwiperCategory.js.map +3 -3
  104. package/dist/esm/biz-components/Category/index.js +1 -1
  105. package/dist/esm/biz-components/Category/index.js.map +3 -3
  106. package/dist/esm/biz-components/CreditsShelf/ProductCard.d.ts +41 -0
  107. package/dist/esm/biz-components/CreditsShelf/ProductCard.js +2 -0
  108. package/dist/esm/biz-components/CreditsShelf/ProductCard.js.map +7 -0
  109. package/dist/esm/biz-components/CreditsShelf/ProductsList.d.ts +20 -0
  110. package/dist/esm/biz-components/CreditsShelf/ProductsList.js +2 -0
  111. package/dist/esm/biz-components/CreditsShelf/ProductsList.js.map +7 -0
  112. package/dist/esm/biz-components/CreditsShelf/Root.d.ts +43 -0
  113. package/dist/esm/biz-components/CreditsShelf/Root.js +2 -0
  114. package/dist/esm/biz-components/CreditsShelf/Root.js.map +7 -0
  115. package/dist/esm/biz-components/CreditsShelf/context.d.ts +40 -0
  116. package/dist/esm/biz-components/CreditsShelf/context.js +2 -0
  117. package/dist/esm/biz-components/CreditsShelf/context.js.map +7 -0
  118. package/dist/esm/biz-components/CreditsShelf/index.d.ts +15 -0
  119. package/dist/esm/biz-components/CreditsShelf/index.js +2 -0
  120. package/dist/esm/biz-components/CreditsShelf/index.js.map +7 -0
  121. package/dist/esm/biz-components/CreditsShelf/types.d.ts +73 -0
  122. package/dist/esm/biz-components/CreditsShelf/types.js +2 -0
  123. package/dist/esm/biz-components/CreditsShelf/types.js.map +7 -0
  124. package/dist/esm/biz-components/ImageOverlayShelf/ProductCard.js +1 -1
  125. package/dist/esm/biz-components/ImageOverlayShelf/ProductCard.js.map +2 -2
  126. package/dist/esm/biz-components/MediaPlayerBase/index.js +1 -1
  127. package/dist/esm/biz-components/MediaPlayerBase/index.js.map +2 -2
  128. package/dist/esm/biz-components/MediaShelf/ProductCard.js +1 -1
  129. package/dist/esm/biz-components/MediaShelf/ProductCard.js.map +2 -2
  130. package/dist/esm/biz-components/MiniCart/CircleProgress.d.ts +38 -0
  131. package/dist/esm/biz-components/MiniCart/CircleProgress.js +2 -0
  132. package/dist/esm/biz-components/MiniCart/CircleProgress.js.map +7 -0
  133. package/dist/esm/biz-components/MiniCart/MiniCartDialog.js +1 -1
  134. package/dist/esm/biz-components/MiniCart/MiniCartDialog.js.map +1 -1
  135. package/dist/esm/biz-components/MiniCart/index.d.ts +31 -1
  136. package/dist/esm/biz-components/MiniCart/index.js +1 -1
  137. package/dist/esm/biz-components/MiniCart/index.js.map +3 -3
  138. package/dist/esm/biz-components/SceneShelf/Footer.d.ts +21 -0
  139. package/dist/esm/biz-components/SceneShelf/Footer.js +2 -0
  140. package/dist/esm/biz-components/SceneShelf/Footer.js.map +7 -0
  141. package/dist/esm/biz-components/SceneShelf/ProductCard.d.ts +23 -0
  142. package/dist/esm/biz-components/SceneShelf/ProductCard.js +2 -0
  143. package/dist/esm/biz-components/SceneShelf/ProductCard.js.map +7 -0
  144. package/dist/esm/biz-components/SceneShelf/ProductsPanel.d.ts +26 -0
  145. package/dist/esm/biz-components/SceneShelf/ProductsPanel.js +2 -0
  146. package/dist/esm/biz-components/SceneShelf/ProductsPanel.js.map +7 -0
  147. package/dist/esm/biz-components/SceneShelf/Root.d.ts +20 -0
  148. package/dist/esm/biz-components/SceneShelf/Root.js +2 -0
  149. package/dist/esm/biz-components/SceneShelf/Root.js.map +7 -0
  150. package/dist/esm/biz-components/SceneShelf/Scene.d.ts +38 -0
  151. package/dist/esm/biz-components/SceneShelf/Scene.js +2 -0
  152. package/dist/esm/biz-components/SceneShelf/Scene.js.map +7 -0
  153. package/dist/esm/biz-components/SceneShelf/SceneImage.d.ts +14 -0
  154. package/dist/esm/biz-components/SceneShelf/SceneImage.js +2 -0
  155. package/dist/esm/biz-components/SceneShelf/SceneImage.js.map +7 -0
  156. package/dist/esm/biz-components/SceneShelf/context.d.ts +40 -0
  157. package/dist/esm/biz-components/SceneShelf/context.js +2 -0
  158. package/dist/esm/biz-components/SceneShelf/context.js.map +7 -0
  159. package/dist/esm/biz-components/SceneShelf/index.d.ts +21 -0
  160. package/dist/esm/biz-components/SceneShelf/index.js +2 -0
  161. package/dist/esm/biz-components/SceneShelf/index.js.map +7 -0
  162. package/dist/esm/biz-components/SceneShelf/types.d.ts +51 -0
  163. package/dist/esm/biz-components/SceneShelf/types.js +2 -0
  164. package/dist/esm/biz-components/SceneShelf/types.js.map +7 -0
  165. package/dist/esm/biz-components/SecondaryBanner/index.d.ts +25 -0
  166. package/dist/esm/biz-components/SecondaryBanner/index.js +1 -1
  167. package/dist/esm/biz-components/SecondaryBanner/index.js.map +3 -3
  168. package/dist/esm/biz-components/index.d.ts +7 -1
  169. package/dist/esm/biz-components/index.js +1 -1
  170. package/dist/esm/biz-components/index.js.map +3 -3
  171. package/dist/esm/components/Countdown.js +1 -1
  172. package/dist/esm/components/Countdown.js.map +2 -2
  173. package/dist/esm/components/button.js +1 -1
  174. package/dist/esm/components/button.js.map +2 -2
  175. package/dist/esm/components/checkbox.js +1 -1
  176. package/dist/esm/components/checkbox.js.map +2 -2
  177. package/dist/esm/components/text.js +1 -1
  178. package/dist/esm/components/text.js.map +2 -2
  179. package/dist/tokens/anker.css +1 -0
  180. package/dist/tokens/base.css +1 -0
  181. package/dist/tokens/eufy.css +1 -0
  182. package/dist/tokens/eufyMake.css +1 -0
  183. package/dist/tokens/solix.css +1 -0
  184. package/dist/tokens/soundcore.css +1 -0
  185. package/package.json +1 -1
  186. package/style.css +20 -3
  187. package/tailwind.config.js +1 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/ImageOverlayShelf/ProductCard.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/utils.js'\n\nimport Badge from '../../components/badge.js'\nimport { Text } from '../../components/text.js'\nimport Button from '../../components/button.js'\nimport Picture from '../../components/picture.js'\nimport { Heading } from '../../components/heading.js'\nimport type { ProductCardProps, ButtonFunctionType, ImageObjectPosition } from './types.js'\n\n/**\n * \u56FE\u7247\u88C1\u5207\u4F4D\u7F6E\u6620\u5C04\n */\nconst objectPositionClassMap: Record<ImageObjectPosition, string> = {\n center: 'object-center',\n top: 'object-top',\n bottom: 'object-bottom',\n left: 'object-left',\n right: 'object-right',\n 'top-left': 'object-left-top',\n 'top-right': 'object-right-top',\n 'bottom-left': 'object-left-bottom',\n 'bottom-right': 'object-right-bottom',\n}\n\n/**\n * ProductCard - ImageOverlayShelf \u7684\u5355\u4E2A\u4EA7\u54C1\u5361\u7247\n * \u56FE\u6587\u53E0\u52A0\u6837\u5F0F\uFF0C\u80CC\u666F\u56FE\u5B8C\u5168\u8986\u76D6\u5361\u7247\n */\nconst ProductCard = React.forwardRef<HTMLDivElement, ProductCardProps>(\n (\n {\n product,\n className,\n showTags = true,\n showOriginalPrice = true,\n onLearnMore,\n onShopNow,\n onAddToCart,\n onProductImageClick,\n classNames,\n secondaryButtonText,\n secondaryButtonFun,\n primaryButtonText,\n primaryButtonFun,\n copy,\n },\n ref\n ) => {\n const [primaryLoading, setPrimaryLoading] = React.useState(false)\n const [secondaryLoading, setSecondaryLoading] = React.useState(false)\n\n const isSoldOut = !product.availableForSale\n\n // \u6839\u636E\u6309\u94AE\u529F\u80FD\u7C7B\u578B\u8C03\u7528\u76F8\u5E94\u7684\u56DE\u8C03\u51FD\u6570\n const handleButtonClick = async (buttonFun?: ButtonFunctionType, buttonType?: 'primary' | 'secondary') => {\n if (!buttonFun) return\n\n const setLoading = buttonType === 'primary' ? setPrimaryLoading : setSecondaryLoading\n setLoading(true)\n\n try {\n switch (buttonFun) {\n case 'buyNow':\n await onShopNow?.(product)\n break\n case 'addCart':\n await onAddToCart?.(product)\n break\n case 'learnMore':\n await onLearnMore?.(product)\n break\n default:\n break\n }\n } finally {\n setLoading(false)\n }\n }\n\n const displayTitle = product.custom_name || product.name\n const displayDescription = product.custom_description || product.description\n const theme = product.custom_theme ?? 'dark'\n\n return (\n <div\n ref={ref}\n className={cn(\n 'rounded-box relative box-border w-full cursor-pointer overflow-hidden duration-300',\n 'desktop:h-[384px] lg-desktop:h-[480px] h-[360px]',\n 'min-w-[296px] max-w-[824px]',\n {\n 'aiui-dark': theme === 'dark',\n },\n className,\n classNames?.productCard\n )}\n >\n <div className=\"box-border flex h-full flex-col justify-between overflow-hidden\">\n {/* \u80CC\u666F\u56FE */}\n <a\n onClick={() => onProductImageClick?.(product)}\n {...(!onProductImageClick &&\n product.listingLink && {\n href: product.listingLink,\n })}\n rel=\"noreferrer\"\n className={cn('absolute inset-0', classNames?.productImage)}\n >\n <Picture\n alt={product.name}\n source={product.custom_image ?? product.image}\n className={cn(\n 'rounded-box h-full overflow-hidden object-cover transition-all duration-300 [&_img]:size-full'\n )}\n imgClassName={cn('object-cover', objectPositionClassMap[product.imageObjectPosition ?? 'center'])}\n />\n </a>\n {/* \u5185\u5BB9\u533A\u57DF */}\n <div\n className={cn(\n 'desktop:p-6 collection-shelves-product-content pointer-events-none z-10 box-border flex flex-1 flex-col justify-end overflow-hidden p-4',\n classNames?.productContent\n )}\n >\n {/* \u6807\u7B7E */}\n {showTags && product.tags?.length ? (\n <div className={cn('mb-2 box-border flex flex-wrap gap-1 overflow-visible', classNames?.tagsContainer)}>\n {product.tags.map((tag: any, index: number) =>\n (tag as any).label ? (\n <Badge\n key={index}\n size=\"sm\"\n variant={(tag.variant as any) || 'outline'}\n promotionalType={tag.promotionalType}\n >\n {tag.label}\n </Badge>\n ) : (\n React.isValidElement(tag) && <React.Fragment key={index}>123</React.Fragment>\n )\n )}\n </div>\n ) : null}\n\n {/* \u4EA7\u54C1\u6807\u9898 */}\n {displayTitle ? (\n <Heading\n as=\"h3\"\n title={displayTitle}\n html={displayTitle}\n className={cn(\n 'lg-desktop:text-2xl lg-desktop:leading-7 tablet:text-xl text-info-primary tablet:leading-6 line-clamp-2 text-base font-bold',\n classNames?.productTitle\n )}\n />\n ) : null}\n\n {/* \u4EA7\u54C1\u63CF\u8FF0 */}\n {displayDescription ? (\n <Text\n size={2}\n html={displayDescription}\n className={cn(\n 'lg-desktop:text-lg desktop:text-base text-info-primary line-clamp-1 text-sm font-bold',\n classNames?.productDescription\n )}\n />\n ) : null}\n\n {/* \u4EF7\u683C\u533A\u57DF */}\n <div className={cn('mb-1 mt-4 flex items-center', classNames?.priceContainer)}>\n {isSoldOut ? (\n <div className={cn('tablet:text-2xl text-info-primary text-xl font-bold', classNames?.productPrice)}>\n {copy?.outOfStockLabel ?? 'Sold Out'}\n </div>\n ) : (\n <>\n <div className={cn('tablet:text-2xl text-info-primary text-xl font-bold', classNames?.productPrice)}>\n {product.price}\n </div>\n {showOriginalPrice && product.originalPrice && (\n <div\n className={cn(\n 'tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through',\n classNames?.originalPrice\n )}\n >\n {product.originalPrice}\n </div>\n )}\n </>\n )}\n </div>\n\n {/* \u6309\u94AE\u533A\u57DF */}\n <div\n className={cn('lg-desktop:gap-3 pointer-events-auto flex items-center gap-2', classNames?.buttonGroup)}\n >\n {secondaryButtonText && (\n <Button\n variant=\"secondary\"\n onClick={() => handleButtonClick(secondaryButtonFun, 'secondary')}\n disabled={isSoldOut && secondaryButtonFun !== 'learnMore'}\n loading={secondaryLoading}\n className={cn(classNames?.secondaryButton)}\n >\n {secondaryButtonText}\n </Button>\n )}\n {primaryButtonText && (\n <Button\n variant=\"primary\"\n onClick={() => handleButtonClick(primaryButtonFun, 'primary')}\n disabled={isSoldOut && primaryButtonFun !== 'learnMore'}\n loading={primaryLoading}\n className={cn(classNames?.primaryButton)}\n >\n {primaryButtonText}\n </Button>\n )}\n </div>\n </div>\n </div>\n </div>\n )\n }\n)\n\nProductCard.displayName = 'ImageOverlayShelf.ProductCard'\n\nexport { ProductCard }\nexport default ProductCard\n"],
5
- "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GA+GY,IAAAK,EAAA,6BA7GZC,EAAuB,oBACvBC,EAAmB,kCAEnBC,EAAkB,wCAClBC,EAAqB,oCACrBC,EAAmB,yCACnBC,EAAoB,0CACpBC,EAAwB,uCAMxB,MAAMC,EAA8D,CAClE,OAAQ,gBACR,IAAK,aACL,OAAQ,gBACR,KAAM,cACN,MAAO,eACP,WAAY,kBACZ,YAAa,mBACb,cAAe,qBACf,eAAgB,qBAClB,EAMMX,EAAcI,EAAM,WACxB,CACE,CACE,QAAAQ,EACA,UAAAC,EACA,SAAAC,EAAW,GACX,kBAAAC,EAAoB,GACpB,YAAAC,EACA,UA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,EAC5D,SAAUO,GAAaP,IAAqB,YAC5C,QAASG,EACT,aAAW,MAAGP,GAAY,aAAa,EAEtC,SAAAG,EACH,GAEJ,GACF,GACF,EACF,CAEJ,CACF,EAEAvB,EAAY,YAAc,gCAG1B,IAAOC,EAAQD",
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/utils.js'\n\nimport Badge from '../../components/badge.js'\nimport { Text } from '../../components/text.js'\nimport Button from '../../components/button.js'\nimport Picture from '../../components/picture.js'\nimport { Heading } from '../../components/heading.js'\nimport type { ProductCardProps, ButtonFunctionType, ImageObjectPosition } from './types.js'\n\n/**\n * \u56FE\u7247\u88C1\u5207\u4F4D\u7F6E\u6620\u5C04\n */\nconst objectPositionClassMap: Record<ImageObjectPosition, string> = {\n center: 'object-center',\n top: 'object-top',\n bottom: 'object-bottom',\n left: 'object-left',\n right: 'object-right',\n 'top-left': 'object-left-top',\n 'top-right': 'object-right-top',\n 'bottom-left': 'object-left-bottom',\n 'bottom-right': 'object-right-bottom',\n}\n\n/**\n * ProductCard - ImageOverlayShelf \u7684\u5355\u4E2A\u4EA7\u54C1\u5361\u7247\n * \u56FE\u6587\u53E0\u52A0\u6837\u5F0F\uFF0C\u80CC\u666F\u56FE\u5B8C\u5168\u8986\u76D6\u5361\u7247\n */\nconst ProductCard = React.forwardRef<HTMLDivElement, ProductCardProps>(\n (\n {\n product,\n className,\n showTags = true,\n showOriginalPrice = true,\n onLearnMore,\n onShopNow,\n onAddToCart,\n onProductImageClick,\n classNames,\n secondaryButtonText,\n secondaryButtonFun,\n primaryButtonText,\n primaryButtonFun,\n copy,\n },\n ref\n ) => {\n const [primaryLoading, setPrimaryLoading] = React.useState(false)\n const [secondaryLoading, setSecondaryLoading] = React.useState(false)\n\n const isSoldOut = !product.availableForSale\n\n // \u6839\u636E\u6309\u94AE\u529F\u80FD\u7C7B\u578B\u8C03\u7528\u76F8\u5E94\u7684\u56DE\u8C03\u51FD\u6570\n const handleButtonClick = async (buttonFun?: ButtonFunctionType, buttonType?: 'primary' | 'secondary') => {\n if (!buttonFun) return\n\n const setLoading = buttonType === 'primary' ? setPrimaryLoading : setSecondaryLoading\n setLoading(true)\n\n try {\n switch (buttonFun) {\n case 'buyNow':\n await onShopNow?.(product)\n break\n case 'addCart':\n await onAddToCart?.(product)\n break\n case 'learnMore':\n await onLearnMore?.(product)\n break\n default:\n break\n }\n } finally {\n setLoading(false)\n }\n }\n\n const displayTitle = product.custom_name || product.name\n const displayDescription = product.custom_description || product.description\n const theme = product.custom_theme ?? 'dark'\n\n return (\n <div\n ref={ref}\n className={cn(\n 'rounded-box relative box-border w-full cursor-pointer overflow-hidden duration-300',\n 'desktop:h-[384px] lg-desktop:h-[480px] h-[360px]',\n 'tablet:min-w-[auto] min-w-[296px] max-w-[824px]',\n {\n 'aiui-dark': theme === 'dark',\n },\n className,\n classNames?.productCard\n )}\n >\n <div className=\"box-border flex h-full flex-col justify-between overflow-hidden\">\n {/* \u80CC\u666F\u56FE */}\n <a\n onClick={() => onProductImageClick?.(product)}\n {...(!onProductImageClick &&\n product.listingLink && {\n href: product.listingLink,\n })}\n rel=\"noreferrer\"\n className={cn('absolute inset-0', classNames?.productImage)}\n >\n <Picture\n alt={product.name}\n source={product.custom_image ?? product.image}\n className={cn(\n 'rounded-box h-full overflow-hidden object-cover transition-all duration-300 [&_img]:size-full'\n )}\n imgClassName={cn('object-cover', objectPositionClassMap[product.imageObjectPosition ?? 'center'])}\n />\n </a>\n {/* \u5185\u5BB9\u533A\u57DF */}\n <div\n className={cn(\n 'desktop:p-6 collection-shelves-product-content pointer-events-none z-10 box-border flex flex-1 flex-col justify-end overflow-hidden p-4',\n classNames?.productContent\n )}\n >\n {/* \u6807\u7B7E */}\n {showTags && product.tags?.length ? (\n <div className={cn('mb-2 box-border flex flex-wrap gap-1 overflow-visible', classNames?.tagsContainer)}>\n {product.tags.map((tag: any, index: number) =>\n (tag as any).label ? (\n <Badge\n key={index}\n size=\"sm\"\n variant={(tag.variant as any) || 'outline'}\n promotionalType={tag.promotionalType}\n >\n {tag.label}\n </Badge>\n ) : (\n React.isValidElement(tag) && <React.Fragment key={index}>123</React.Fragment>\n )\n )}\n </div>\n ) : null}\n\n {/* \u4EA7\u54C1\u6807\u9898 */}\n {displayTitle ? (\n <Heading\n as=\"h3\"\n title={displayTitle}\n html={displayTitle}\n className={cn(\n 'lg-desktop:text-2xl lg-desktop:leading-7 tablet:text-xl text-info-primary tablet:leading-6 line-clamp-2 text-base font-bold',\n classNames?.productTitle\n )}\n />\n ) : null}\n\n {/* \u4EA7\u54C1\u63CF\u8FF0 */}\n {displayDescription ? (\n <Text\n size={2}\n html={displayDescription}\n className={cn(\n 'lg-desktop:text-lg desktop:text-base text-info-primary line-clamp-1 text-sm font-bold',\n classNames?.productDescription\n )}\n />\n ) : null}\n\n {/* \u4EF7\u683C\u533A\u57DF */}\n <div className={cn('mb-1 mt-4 flex items-center', classNames?.priceContainer)}>\n {isSoldOut ? (\n <div className={cn('tablet:text-2xl text-info-primary text-xl font-bold', classNames?.productPrice)}>\n {copy?.outOfStockLabel ?? 'Sold Out'}\n </div>\n ) : (\n <>\n <div className={cn('tablet:text-2xl text-info-primary text-xl font-bold', classNames?.productPrice)}>\n {product.price}\n </div>\n {showOriginalPrice && product.originalPrice && (\n <div\n className={cn(\n 'tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through',\n classNames?.originalPrice\n )}\n >\n {product.originalPrice}\n </div>\n )}\n </>\n )}\n </div>\n\n {/* \u6309\u94AE\u533A\u57DF */}\n <div\n className={cn('lg-desktop:gap-3 pointer-events-auto flex items-center gap-2', classNames?.buttonGroup)}\n >\n {secondaryButtonText && (\n <Button\n variant=\"secondary\"\n onClick={() => handleButtonClick(secondaryButtonFun, 'secondary')}\n disabled={isSoldOut && secondaryButtonFun !== 'learnMore'}\n loading={secondaryLoading}\n className={cn(classNames?.secondaryButton)}\n >\n {secondaryButtonText}\n </Button>\n )}\n {primaryButtonText && (\n <Button\n variant=\"primary\"\n onClick={() => handleButtonClick(primaryButtonFun, 'primary')}\n disabled={isSoldOut && primaryButtonFun !== 'learnMore'}\n loading={primaryLoading}\n className={cn(classNames?.primaryButton)}\n >\n {primaryButtonText}\n </Button>\n )}\n </div>\n </div>\n </div>\n </div>\n )\n }\n)\n\nProductCard.displayName = 'ImageOverlayShelf.ProductCard'\n\nexport { ProductCard }\nexport default ProductCard\n"],
5
+ "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GA+GY,IAAAK,EAAA,6BA7GZC,EAAuB,oBACvBC,EAAmB,kCAEnBC,EAAkB,wCAClBC,EAAqB,oCACrBC,EAAmB,yCACnBC,EAAoB,0CACpBC,EAAwB,uCAMxB,MAAMC,EAA8D,CAClE,OAAQ,gBACR,IAAK,aACL,OAAQ,gBACR,KAAM,cACN,MAAO,eACP,WAAY,kBACZ,YAAa,mBACb,cAAe,qBACf,eAAgB,qBAClB,EAMMX,EAAcI,EAAM,WACxB,CACE,CACE,QAAAQ,EACA,UAAAC,EACA,SAAAC,EAAW,GACX,kBAAAC,EAAoB,GACpB,YAAAC,EACA,UAAAC,EACA,YAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,iBAAAC,EACA,KAAAC,CACF,EACAC,IACG,CACH,KAAM,CAACC,EAAgBC,CAAiB,EAAIxB,EAAM,SAAS,EAAK,EAC1D,CAACyB,EAAkBC,CAAmB,EAAI1B,EAAM,SAAS,EAAK,EAE9D2B,EAAY,CAACnB,EAAQ,iBAGrBoB,EAAoB,MAAOC,EAAgCC,IAAyC,CACxG,GAAI,CAACD,EAAW,OAEhB,MAAME,EAAaD,IAAe,UAAYN,EAAoBE,EAClEK,EAAW,EAAI,EAEf,GAAI,CACF,OAAQF,EAAW,CACjB,IAAK,SACH,MAAMhB,IAAYL,CAAO,EACzB,MACF,IAAK,UACH,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iB,KACC,OAAC,QACC,KAAM,EACN,KAAMA,EACN,aAAW,MACT,wFACAjB,GAAY,kBACd,EACF,EACE,QAGJ,OAAC,OAAI,aAAW,MAAG,8BAA+BA,GAAY,cAAc,EACzE,SAAAW,KACC,OAAC,OAAI,aAAW,MAAG,sDAAuDX,GAAY,YAAY,EAC/F,SAAAK,GAAM,iBAAmB,WAC5B,KAEA,oBACE,oBAAC,OAAI,aAAW,MAAG,sDAAuDL,GAAY,YAAY,EAC/F,SAAAR,EAAQ,MACX,EACCG,GAAqBH,EAAQ,kBAC5B,OAAC,OACC,aAAW,MACT,yEACAQ,GAAY,aACd,EAEC,SAAAR,EAAQ,cACX,GAEJ,EAEJ,KAGA,QAAC,OACC,aAAW,MAAG,+DAAgEQ,GAAY,WAAW,EAEpG,UAAAC,MACC,OAAC,EAAAsB,QAAA,CACC,QAAQ,YACR,QAAS,IAAMX,EAAkBV,EAAoB,WAAW,EAChE,SAAUS,GAAaT,IAAuB,YAC9C,QAASO,EACT,aAAW,MAAGT,GAAY,eAAe,EAExC,SAAAC,EACH,EAEDE,MACC,OAAC,EAAAoB,QAAA,CACC,QAAQ,UACR,QAAS,IAAMX,EAAkBR,EAAkB,SAAS,EAC5D,SAAUO,GAAaP,IAAqB,YAC5C,QAASG,EACT,aAAW,MAAGP,GAAY,aAAa,EAEtC,SAAAG,EACH,GAEJ,GACF,GACF,EACF,CAEJ,CACF,EAEAvB,EAAY,YAAc,gCAG1B,IAAOC,EAAQD",
6
6
  "names": ["ProductCard_exports", "__export", "ProductCard", "ProductCard_default", "__toCommonJS", "import_jsx_runtime", "React", "import_utils", "import_badge", "import_text", "import_button", "import_picture", "import_heading", "objectPositionClassMap", "product", "className", "showTags", "showOriginalPrice", "onLearnMore", "onShopNow", "onAddToCart", "onProductImageClick", "classNames", "secondaryButtonText", "secondaryButtonFun", "primaryButtonText", "primaryButtonFun", "copy", "ref", "primaryLoading", "setPrimaryLoading", "secondaryLoading", "setSecondaryLoading", "isSoldOut", "handleButtonClick", "buttonFun", "buttonType", "setLoading", "displayTitle", "displayDescription", "theme", "Picture", "tag", "index", "Badge", "Button"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var be=Object.create;var H=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var Me=(r,n)=>{for(var o in n)H(r,o,{get:n[o],enumerable:!0})},Q=(r,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of He(n))!ke.call(r,s)&&s!==o&&H(r,s,{get:()=>n[s],enumerable:!(a=we(n,s))||a.enumerable});return r};var W=(r,n,o)=>(o=r!=null?be(Te(r)):{},Q(n||!r||!r.__esModule?H(o,"default",{value:r,enumerable:!0}):o,r)),Le=r=>Q(H({},"__esModule",{value:!0}),r);var Ee={};Me(Ee,{default:()=>ze});module.exports=Le(Ee);var t=require("react/jsx-runtime"),e=require("react"),A=require("lodash"),f=require("../../helpers/utils.js"),ee=require("../../shared/Styles.js"),te=W(require("../../components/button.js")),re=require("../VideoModal/index.js"),E=require("@payloadcms/richtext-lexical/html"),oe=require("react-intersection-observer"),ne=require("../../hooks/useExposure.js"),I=W(require("../../helpers/ScrollLoadVideo.js")),T=require("gsap"),se=require("gsap/dist/SplitText"),P=require("gsap/dist/ScrollTrigger");const Ne="media_player_base",Re="video",X=({defaultConverters:r})=>({...r,text:n=>{const{node:o}=n;return o.$&&o.$.color?`<span class="lexical-${o.$.color}">${o.text}</span>`:o.text}}),Z=(0,e.forwardRef)(({className:r="",id:n,onBtnClick:o,data:{title:a,videoTitle:s,btnText:_,youtubeId:S,video:V,mobileVideo:le,theme:$,img:B,shape:C,titleAnimation:v,...ie}},ae)=>{const{sticky:p}=ie,[D,F]=(0,e.useState)(!1),[j,ce]=(0,e.useState)(0),[de,pe]=(0,e.useState)(0),[x,ue]=(0,e.useState)(0),[U,Y]=(0,e.useState)(!1),y=(0,e.useRef)(null),q=(0,e.useRef)(null),l=(0,e.useRef)(null),h=(0,e.useRef)(null),O=(0,e.useRef)(null),b=(0,e.useRef)(null),k=(0,e.useRef)(null),M=(0,e.useRef)(null),{ref:me,inView:c}=(0,oe.useInView)();(0,e.useImperativeHandle)(ae,()=>l.current);const w=typeof a=="string"?a:a&&(0,E.convertLexicalToHTML)({data:a,converters:X}),L=typeof s=="string"?s:s&&(0,E.convertLexicalToHTML)({data:s,converters:X});(0,e.useEffect)(()=>{c?(y.current?.play(),F(!0)):(y.current?.pause(),F(!1))},[c]);const N=(0,A.debounce)(()=>{if(l.current){const u=l.current.getBoundingClientRect(),d=window.innerHeight,m=window.scrollY||window.pageYOffset,i=u.bottom+m,g=document.documentElement.scrollHeight-i;ce(g>d?d:g)}if(l.current){const u=l.current.clientHeight,d=window.innerHeight;pe(u+d)}},600);(0,e.useEffect)(()=>(N(),window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N)}),[]),(0,e.useEffect)(()=>{function u(){if(!h.current||v!=="fade-in")return;const m=h.current?.clientHeight||80;b.current=new se.SplitText(h.current,{type:"words",wordsClass:"word"});const i=b.current.words;T.gsap.set(i,{opacity:0}),k.current=P.ScrollTrigger.create({trigger:l.current,start:"top center-=10%",end:`top+=${m*1.5+80}px center-=10%`,scrub:!0,onUpdate:G=>{const g=G.progress,J=i.length,fe=1/J,K=.5;i.forEach((ve,xe)=>{const ye=xe/J*(1-K),he=fe*(1+K);let z=(g-ye)/he;z=Math.max(0,Math.min(z,1)),T.gsap.set(ve,{opacity:z})}),T.gsap.set(q.current,{opacity:g})}})}function d(){M.current=P.ScrollTrigger.create({trigger:l.current,start:"bottom bottom",end:"bottom top",scrub:!0,onUpdate:m=>{const i=m.progress;console.log("progress__",i),ue(i)}})}return c&&(u(),d()),()=>{b.current&&b.current.revert(),k.current&&k.current.kill(),M.current&&M.current.kill()}},[v,c]),(0,ne.useExposure)(O,{componentType:Re,componentName:Ne,componentTitle:L});const ge=(0,e.useMemo)(()=>c&&x>0&&x<.9?3:c?2:1,[x,c]),R="lg-desktop:aspect-w-[1920] lg-desktop:aspect-h-[930] desktop:aspect-w-[1024] desktop:aspect-h-[520] laptop:aspect-w-[1024] laptop:aspect-h-[520] tablet:aspect-w-[768] tablet:aspect-h-[660] aspect-w-[390] aspect-h-[660]";return(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsx)("div",{ref:l,className:(0,f.cn)("relative z-10",R,{"aiui-dark":$==="dark","rounded-box":C==="rounded"},r),children:(0,t.jsx)("div",{ref:me,children:!v&&(0,t.jsxs)("div",{className:"media-content absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 px-4 text-center",children:[w&&!D&&(0,t.jsx)("div",{className:"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl",dangerouslySetInnerHTML:{__html:w}}),L&&D&&(0,t.jsx)("div",{className:"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl",dangerouslySetInnerHTML:{__html:L}}),_&&(0,t.jsx)(te.default,{variant:"link",className:(0,f.cn)("member-equity-button-secondary text-btn-primary-foreground"),onClick:()=>{Y(!0),o&&o?.()},children:_})]})})}),(0,t.jsxs)("div",{style:p?{marginBottom:`-${j}px`,marginTop:`-${de}px`,zIndex:ge}:{},className:"relative",children:[(0,t.jsx)("div",{className:"sticky top-0 ",children:(0,t.jsxs)("div",{id:n,className:(0,f.cn)("relative overflow-hidden",p?"h-screen w-full":R,{"aiui-dark":$==="dark","rounded-box":C==="rounded"}),children:[v==="fade-in"&&w&&(0,t.jsx)("div",{ref:h,className:"lg-desktop:text-[64px] text-btn-primary-foreground absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 text-center text-[40px] font-bold leading-none lg:text-5xl",dangerouslySetInnerHTML:{__html:w}}),(0,t.jsxs)("div",{className:"media-cover left-0 top-0 h-screen w-screen overflow-hidden",style:{height:`${102-x*100}vh`},children:[(0,t.jsx)(I.default,{videoRef:y,poster:B?.url||"",src:V?.url,className:"tablet:block hidden size-full min-h-screen",videoClassName:"object-cover",muted:!0,loop:!0,playsInline:!0,autoplay:!0,"webkit-playsinline":!0,"x5-playsinline":!0}),(0,t.jsx)(I.default,{videoRef:y,poster:B?.url||"",src:le?.url||V?.url,className:"tablet:hidden block size-full min-h-screen",videoClassName:"object-cover",muted:!0,loop:!0,playsInline:!0,autoplay:!0,"webkit-playsinline":!0,"x5-playsinline":!0}),(0,t.jsx)("div",{ref:q,className:"absolute left-0 top-0 z-10 size-full opacity-0",style:{background:"rgba(0, 0, 0, 0.2)"}})]})]})}),(0,t.jsx)("div",{className:(0,f.cn)(p&&"relative box-content block",R),style:p?{height:`${j}px`}:{},ref:O})]}),U&&S&&(0,t.jsx)(re.VideoModal,{visible:U,youTubeId:S,onCloseModal:()=>Y(!1)})]})});Z.displayName="MediaPlayerBase";var ze=(0,ee.withLayout)(Z);
1
+ "use strict";"use client";var be=Object.create;var H=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var Me=(r,n)=>{for(var o in n)H(r,o,{get:n[o],enumerable:!0})},Q=(r,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of He(n))!ke.call(r,s)&&s!==o&&H(r,s,{get:()=>n[s],enumerable:!(a=we(n,s))||a.enumerable});return r};var W=(r,n,o)=>(o=r!=null?be(Te(r)):{},Q(n||!r||!r.__esModule?H(o,"default",{value:r,enumerable:!0}):o,r)),Le=r=>Q(H({},"__esModule",{value:!0}),r);var Ee={};Me(Ee,{default:()=>ze});module.exports=Le(Ee);var t=require("react/jsx-runtime"),e=require("react"),A=require("lodash"),f=require("../../helpers/utils.js"),ee=require("../../shared/Styles.js"),te=W(require("../../components/button.js")),re=require("../VideoModal/index.js"),E=require("@payloadcms/richtext-lexical/html"),oe=require("react-intersection-observer"),ne=require("../../hooks/useExposure.js"),I=W(require("../../helpers/ScrollLoadVideo.js")),T=require("gsap"),se=require("gsap/dist/SplitText"),P=require("gsap/dist/ScrollTrigger");const Ne="media_player_base",Re="video",X=({defaultConverters:r})=>({...r,text:n=>{const{node:o}=n;return o.$&&o.$.color?`<span class="lexical-${o.$.color}">${o.text}</span>`:o.text}}),Z=(0,e.forwardRef)(({className:r="",id:n,onBtnClick:o,data:{title:a,videoTitle:s,btnText:_,youtubeId:S,video:V,mobileVideo:le,theme:$,img:B,shape:C,titleAnimation:v,...ie}},ae)=>{const{sticky:d}=ie,[D,F]=(0,e.useState)(!1),[j,ce]=(0,e.useState)(0),[de,pe]=(0,e.useState)(0),[x,ue]=(0,e.useState)(0),[U,Y]=(0,e.useState)(!1),y=(0,e.useRef)(null),q=(0,e.useRef)(null),l=(0,e.useRef)(null),h=(0,e.useRef)(null),O=(0,e.useRef)(null),b=(0,e.useRef)(null),k=(0,e.useRef)(null),M=(0,e.useRef)(null),{ref:me,inView:c}=(0,oe.useInView)();(0,e.useImperativeHandle)(ae,()=>l.current);const w=typeof a=="string"?a:a&&(0,E.convertLexicalToHTML)({data:a,converters:X}),L=typeof s=="string"?s:s&&(0,E.convertLexicalToHTML)({data:s,converters:X});(0,e.useEffect)(()=>{c?(y.current?.play(),F(!0)):(y.current?.pause(),F(!1))},[c]);const N=(0,A.debounce)(()=>{if(l.current){const u=l.current.getBoundingClientRect(),p=window.innerHeight,m=window.scrollY||window.pageYOffset,i=u.bottom+m,g=document.documentElement.scrollHeight-i;ce(g>p?p:g)}if(l.current){const u=l.current.clientHeight,p=window.innerHeight;pe(u+p)}},600);(0,e.useEffect)(()=>(N(),window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N)}),[]),(0,e.useEffect)(()=>{function u(){if(!h.current||v!=="fade-in")return;const m=h.current?.clientHeight||80;b.current=new se.SplitText(h.current,{type:"words",wordsClass:"word"});const i=b.current.words;T.gsap.set(i,{opacity:0}),k.current=P.ScrollTrigger.create({trigger:l.current,start:"top center-=10%",end:`top+=${m*1.5+80}px center-=10%`,scrub:!0,onUpdate:G=>{const g=G.progress,J=i.length,fe=1/J,K=.5;i.forEach((ve,xe)=>{const ye=xe/J*(1-K),he=fe*(1+K);let z=(g-ye)/he;z=Math.max(0,Math.min(z,1)),T.gsap.set(ve,{opacity:z})}),T.gsap.set(q.current,{opacity:g})}})}function p(){M.current=P.ScrollTrigger.create({trigger:l.current,start:"bottom bottom",end:"bottom top",scrub:!0,onUpdate:m=>{const i=m.progress;console.log("progress__",i),ue(i)}})}return c&&(u(),p()),()=>{b.current&&b.current.revert(),k.current&&k.current.kill(),M.current&&M.current.kill()}},[v,c]),(0,ne.useExposure)(O,{componentType:Re,componentName:Ne,componentTitle:L});const ge=(0,e.useMemo)(()=>c&&x>0&&x<.9?3:c?2:1,[x,c]),R="lg-desktop:aspect-w-[1920] lg-desktop:aspect-h-[930] desktop:aspect-w-[1024] desktop:aspect-h-[520] laptop:aspect-w-[1024] laptop:aspect-h-[520] tablet:aspect-w-[768] tablet:aspect-h-[660] aspect-w-[390] aspect-h-[660]";return(0,t.jsxs)(t.Fragment,{children:[d&&(0,t.jsx)("div",{ref:l,className:(0,f.cn)("relative z-10",R,{"aiui-dark":$==="dark","rounded-box":C==="rounded"},r),children:(0,t.jsx)("div",{ref:me,children:!v&&(0,t.jsxs)("div",{className:"media-content absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 px-4 text-center",children:[w&&!D&&(0,t.jsx)("div",{className:"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl",dangerouslySetInnerHTML:{__html:w}}),L&&D&&(0,t.jsx)("div",{className:"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl",dangerouslySetInnerHTML:{__html:L}}),_&&(0,t.jsx)(te.default,{variant:"link",className:(0,f.cn)("member-equity-button-secondary text-btn-primary-foreground"),onClick:()=>{Y(!0),o&&o?.()},children:_})]})})}),(0,t.jsxs)("div",{style:d?{marginBottom:`-${j}px`,marginTop:`-${de}px`,zIndex:ge}:{},className:"relative",children:[(0,t.jsx)("div",{className:"sticky top-0 ",children:(0,t.jsxs)("div",{id:n,className:(0,f.cn)("relative overflow-hidden",d?"h-screen w-full":R,{"aiui-dark":$==="dark","rounded-box":C==="rounded"}),children:[v==="fade-in"&&w&&(0,t.jsx)("div",{ref:h,className:"lg-desktop:text-[64px] text-btn-primary-foreground absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 text-center text-[40px] font-bold leading-none lg:text-5xl",dangerouslySetInnerHTML:{__html:w}}),(0,t.jsxs)("div",{className:"media-cover left-0 top-0 h-screen w-screen overflow-hidden",style:{height:`${102-x*100}vh`},children:[(0,t.jsx)(I.default,{videoRef:y,poster:B?.url||"",src:V?.url,className:"tablet:block hidden size-full min-h-screen",videoClassName:"object-cover",muted:!0,loop:!0,playsInline:!0,autoplay:!0,"webkit-playsinline":!0,"x5-playsinline":!0}),(0,t.jsx)(I.default,{videoRef:y,poster:B?.url||"",src:le?.url||V?.url,className:"tablet:hidden block size-full min-h-screen",videoClassName:"object-cover",muted:!0,loop:!0,playsInline:!0,autoplay:!0,"webkit-playsinline":!0,"x5-playsinline":!0}),(0,t.jsx)("div",{ref:q,className:"absolute left-0 top-0 z-10 size-full opacity-0",style:{background:"rgba(0, 0, 0, 0.2)"}})]})]})}),d&&(0,t.jsx)("div",{className:(0,f.cn)(d&&"relative box-content block",R),style:d?{height:`${j}px`}:{},ref:O})]}),U&&S&&(0,t.jsx)(re.VideoModal,{visible:U,youTubeId:S,onCloseModal:()=>Y(!1)})]})});Z.displayName="MediaPlayerBase";var ze=(0,ee.withLayout)(Z);
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/MediaPlayerBase/index.tsx"],
4
- "sourcesContent": ["'use client'\nimport { useState, useRef, useMemo, useEffect, forwardRef, useImperativeHandle } from 'react'\nimport { debounce } from 'lodash'\nimport { cn } from '../../helpers/utils.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport Button from '../../components/button.js'\nimport { VideoModal } from '../VideoModal/index.js'\nimport { convertLexicalToHTML } from '@payloadcms/richtext-lexical/html'\nimport type { MediaPlayerBaseProps } from './types.js'\n// import { Right } from './right.js'\nimport { useInView } from 'react-intersection-observer'\nimport type { HTMLConvertersFunction } from '@payloadcms/richtext-lexical/html'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport ScrollLoadVideo from '../../helpers/ScrollLoadVideo.js'\nimport { gsap } from 'gsap'\nimport { SplitText } from 'gsap/dist/SplitText'\nimport { ScrollTrigger } from 'gsap/dist/ScrollTrigger'\n\nconst componentName = 'media_player_base'\nconst componentType = 'video'\n\nconst htmlConverters: HTMLConvertersFunction = ({ defaultConverters }) => ({\n ...defaultConverters,\n text: args => {\n const { node } = args\n // \u68C0\u67E5\u662F\u5426\u6709\u81EA\u5B9A\u4E49 color\n if (node.$ && node.$.color) {\n return `<span class=\"lexical-${node.$.color}\">${node.text}</span>`\n }\n return node.text\n },\n})\n\nconst MediaPlayerBase = forwardRef<HTMLDivElement, MediaPlayerBaseProps>(\n (\n {\n className = '',\n id,\n onBtnClick,\n data: { title, videoTitle, btnText, youtubeId, video, mobileVideo, theme, img, shape, titleAnimation, ...rest },\n },\n ref\n ) => {\n const { sticky } = rest\n const [isPlaying, setIsPlaying] = useState(false)\n const [btb, setbtb] = useState(0)\n const [titleHeight, setTitleHeight] = useState(0)\n const [videoHeightProgress, setVideoHeightProgress] = useState(0)\n const [visible, setVisible] = useState<boolean>(false)\n\n const videoRef = useRef<HTMLVideoElement>(null)\n const bgRef = useRef<HTMLImageElement>(null)\n const titleRef = useRef<HTMLDivElement>(null)\n const titleFadeInRef = useRef<HTMLDivElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const splitTextInstance = useRef<SplitText | null>(null)\n const scrollTriggerRef = useRef<ScrollTrigger | null>(null)\n const heightTriggerRef = useRef<ScrollTrigger | null>(null)\n const { ref: inViewRef, inView } = useInView()\n\n useImperativeHandle(ref, () => titleRef.current as HTMLDivElement)\n\n const title_html =\n typeof title === 'string' ? title : title && convertLexicalToHTML({ data: title, converters: htmlConverters })\n const videoTitle_html =\n typeof videoTitle === 'string'\n ? videoTitle\n : videoTitle && convertLexicalToHTML({ data: videoTitle, converters: htmlConverters })\n\n useEffect(() => {\n if (inView) {\n videoRef.current?.play()\n setIsPlaying(true)\n } else {\n videoRef.current?.pause()\n setIsPlaying(false)\n }\n }, [inView])\n\n const debouncedHandleResize = debounce(() => {\n if (titleRef.current) {\n const rect = titleRef.current.getBoundingClientRect()\n const screenHeight = window.innerHeight\n const scrollTop = window.scrollY || window.pageYOffset\n const elementBottomToPageTop = rect.bottom + scrollTop\n const pageHeight = document.documentElement.scrollHeight\n const distanceToPageBottom = pageHeight - elementBottomToPageTop\n setbtb(distanceToPageBottom > screenHeight ? screenHeight : distanceToPageBottom)\n }\n if (titleRef.current) {\n const titleHeight = titleRef.current.clientHeight\n const screenHeight = window.innerHeight\n setTitleHeight(titleHeight + screenHeight)\n }\n }, 600)\n\n useEffect(() => {\n debouncedHandleResize()\n window.addEventListener('resize', debouncedHandleResize)\n return () => {\n window.removeEventListener('resize', debouncedHandleResize)\n }\n }, [])\n\n useEffect(() => {\n function gsapResize() {\n if (!titleFadeInRef.current || titleAnimation !== 'fade-in') return\n const height = titleFadeInRef.current?.clientHeight || 80\n splitTextInstance.current = new SplitText(titleFadeInRef.current, {\n type: 'words',\n wordsClass: 'word',\n })\n const words = splitTextInstance.current.words\n gsap.set(words, { opacity: 0 })\n scrollTriggerRef.current = ScrollTrigger.create({\n trigger: titleRef.current,\n start: 'top center-=10%',\n end: `top+=${height * 1.5 + 80}px center-=10%`,\n scrub: true,\n onUpdate: (self: any) => {\n const progress = self.progress\n const total = words.length\n const interval = 1 / total\n const overlap = 0.5\n words.forEach((word: any, i: number) => {\n const start = (i / total) * (1 - overlap)\n const width = interval * (1 + overlap)\n let opacity = (progress - start) / width\n opacity = Math.max(0, Math.min(opacity, 1))\n gsap.set(word, { opacity })\n })\n gsap.set(bgRef.current, { opacity: progress })\n },\n })\n }\n\n function gsapVideoHeightResize() {\n heightTriggerRef.current = ScrollTrigger.create({\n trigger: titleRef.current,\n start: 'bottom bottom',\n end: `bottom top`,\n // markers: true,\n scrub: true,\n onUpdate: (self: any) => {\n const progress = self.progress\n console.log('progress__', progress)\n setVideoHeightProgress(progress)\n },\n })\n }\n\n if (inView) {\n gsapResize()\n gsapVideoHeightResize()\n }\n\n return () => {\n splitTextInstance.current && splitTextInstance.current.revert()\n // ScrollTrigger.getAll().forEach((t: { kill: () => any }) => t.kill())\n scrollTriggerRef.current && scrollTriggerRef.current.kill()\n heightTriggerRef.current && heightTriggerRef.current.kill()\n }\n }, [titleAnimation, inView])\n\n useExposure(trackRef, {\n componentType,\n componentName,\n componentTitle: videoTitle_html,\n })\n\n const zIndexVideo = useMemo(() => {\n if (inView && videoHeightProgress > 0 && videoHeightProgress < 0.9) return 3\n if (inView) return 2\n return 1\n }, [videoHeightProgress, inView])\n\n const aspect =\n 'lg-desktop:aspect-w-[1920] lg-desktop:aspect-h-[930] desktop:aspect-w-[1024] desktop:aspect-h-[520] laptop:aspect-w-[1024] laptop:aspect-h-[520] tablet:aspect-w-[768] tablet:aspect-h-[660] aspect-w-[390] aspect-h-[660]'\n return (\n <>\n {sticky && (\n <div\n ref={titleRef}\n className={cn(\n 'relative z-10',\n aspect,\n {\n 'aiui-dark': theme === 'dark',\n 'rounded-box': shape === 'rounded',\n },\n className\n )}\n >\n <div ref={inViewRef}>\n {!titleAnimation && (\n <div className=\"media-content absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 px-4 text-center\">\n {title_html && !isPlaying && (\n <div\n className=\"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl\"\n dangerouslySetInnerHTML={{ __html: title_html }}\n />\n )}\n {videoTitle_html && isPlaying && (\n <div\n className=\"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl\"\n dangerouslySetInnerHTML={{ __html: videoTitle_html }}\n />\n )}\n {btnText && (\n <Button\n variant=\"link\"\n className={cn('member-equity-button-secondary text-btn-primary-foreground')}\n onClick={() => {\n setVisible(true)\n // if (isPlaying) {\n // if (videoRef.current) {\n // videoRef.current.pause()\n // }\n // setIsPlaying(false)\n // } else {\n // if (videoRef.current) {\n // videoRef.current.play()\n // }\n // setIsPlaying(true)\n // }\n onBtnClick && onBtnClick?.()\n }}\n >\n {btnText}\n {/* <Right /> */}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n )}\n <div\n style={\n sticky\n ? {\n marginBottom: `-${btb}px`,\n marginTop: `-${titleHeight}px`,\n zIndex: zIndexVideo,\n }\n : {}\n }\n className=\"relative\"\n >\n <div className=\"sticky top-0 \">\n <div\n id={id}\n className={cn('relative overflow-hidden', sticky ? 'h-screen w-full' : aspect, {\n 'aiui-dark': theme === 'dark',\n 'rounded-box': shape === 'rounded',\n })}\n >\n {titleAnimation === 'fade-in' && title_html && (\n <div\n ref={titleFadeInRef}\n className=\"lg-desktop:text-[64px] text-btn-primary-foreground absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 text-center text-[40px] font-bold leading-none lg:text-5xl\"\n dangerouslySetInnerHTML={{ __html: title_html }}\n />\n )}\n <div\n className=\"media-cover left-0 top-0 h-screen w-screen overflow-hidden\"\n style={{ height: `${102 - videoHeightProgress * 100}vh` }}\n >\n <ScrollLoadVideo\n videoRef={videoRef}\n poster={img?.url || ''}\n src={video?.url!}\n className=\"tablet:block hidden size-full min-h-screen\"\n videoClassName=\"object-cover\"\n muted\n loop\n playsInline\n autoplay\n webkit-playsinline\n x5-playsinline\n />\n <ScrollLoadVideo\n videoRef={videoRef}\n poster={img?.url || ''}\n src={mobileVideo?.url || video?.url!}\n className=\"tablet:hidden block size-full min-h-screen\"\n videoClassName=\"object-cover\"\n muted\n loop\n playsInline\n autoplay\n webkit-playsinline\n x5-playsinline\n />\n <div\n ref={bgRef}\n className=\"absolute left-0 top-0 z-10 size-full opacity-0\"\n style={{\n background: 'rgba(0, 0, 0, 0.2)',\n }}\n />\n </div>\n </div>\n </div>\n <div\n className={cn(sticky && 'relative box-content block', aspect)}\n style={sticky ? { height: `${btb}px` } : {}}\n ref={trackRef}\n />\n </div>\n {visible && youtubeId && (\n <VideoModal visible={visible} youTubeId={youtubeId} onCloseModal={() => setVisible(false)} />\n )}\n </>\n )\n }\n)\n\nMediaPlayerBase.displayName = 'MediaPlayerBase'\n\nexport default withLayout(MediaPlayerBase)\n"],
5
- "mappings": "mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IAmLM,IAAAI,EAAA,6BAlLNC,EAAsF,iBACtFC,EAAyB,kBACzBC,EAAmB,kCACnBC,GAA2B,kCAC3BC,GAAmB,yCACnBC,GAA2B,kCAC3BC,EAAqC,6CAGrCC,GAA0B,uCAE1BC,GAA4B,sCAC5BC,EAA4B,+CAC5BC,EAAqB,gBACrBC,GAA0B,+BAC1BC,EAA8B,mCAE9B,MAAMC,GAAgB,oBAChBC,GAAgB,QAEhBC,EAAyC,CAAC,CAAE,kBAAAC,CAAkB,KAAO,CACzE,GAAGA,EACH,KAAMC,GAAQ,CACZ,KAAM,CAAE,KAAAC,CAAK,EAAID,EAEjB,OAAIC,EAAK,GAAKA,EAAK,EAAE,MACZ,wBAAwBA,EAAK,EAAE,KAAK,KAAKA,EAAK,IAAI,UAEpDA,EAAK,IACd,CACF,GAEMC,KAAkB,cACtB,CACE,CACE,UAAAC,EAAY,GACZ,GAAAC,EACA,WAAAC,EACA,KAAM,CAAE,MAAAC,EAAO,WAAAC,EAAY,QAAAC,EAAS,UAAAC,EAAW,MAAAC,EAAO,YAAAC,GAAa,MAAAC,EAAO,IAAAC,EAAK,MAAAC,E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U,WAEV,oBAAC,OAAI,UAAU,gBACb,oBAAC,OACC,GAAIzD,EACJ,aAAW,MAAG,2BAA4Bc,EAAS,kBAAoB4C,EAAQ,CAC7E,YAAalD,IAAU,OACvB,cAAeE,IAAU,SAC3B,CAAC,EAEA,UAAAC,IAAmB,WAAawB,MAC/B,OAAC,OACC,IAAKP,EACL,UAAU,wLACV,wBAAyB,CAAE,OAAQO,CAAW,EAChD,KAEF,QAAC,OACC,UAAU,6DACV,MAAO,CAAE,OAAQ,GAAG,IAAMd,EAAsB,GAAG,IAAK,EAExD,oBAAC,EAAAuC,QAAA,CACC,SAAUnC,EACV,OAAQhB,GAAK,KAAO,GACpB,IAAKH,GAAO,IACZ,UAAU,6CACV,eAAe,eACf,MAAK,GACL,KAAI,GACJ,YAAW,GACX,SAAQ,GACR,qBAAkB,GAClB,iBAAc,GAChB,KACA,OAAC,EAAAsD,QAAA,CACC,SAAUnC,EACV,OAAQhB,GAAK,KAAO,GACpB,IAAKF,IAAa,KAAOD,GAAO,IAChC,UAAU,6CACV,eAAe,eACf,MAAK,GACL,KAAI,GACJ,YAAW,GACX,SAAQ,GACR,qBAAkB,GAClB,iBAAc,GAChB,KACA,OAAC,OACC,IAAKoB,EACL,UAAU,iDACV,MAAO,CACL,WAAY,oBACd,EACF,GACF,GACF,EACF,KACA,OAAC,OACC,aAAW,MAAGZ,GAAU,6BAA8B4C,CAAM,EAC5D,MAAO5C,EAAS,CAAE,OAAQ,GAAGG,CAAG,IAAK,EAAI,CAAC,EAC1C,IAAKY,EACP,GACF,EACCN,GAAWlB,MACV,OAAC,eAAW,QAASkB,EAAS,UAAWlB,EAAW,aAAc,IAAMmB,EAAW,EAAK,EAAG,GAE/F,CAEJ,CACF,EAEA1B,EAAgB,YAAc,kBAE9B,IAAOtB,MAAQ,eAAWsB,CAAe",
4
+ "sourcesContent": ["'use client'\nimport { useState, useRef, useMemo, useEffect, forwardRef, useImperativeHandle } from 'react'\nimport { debounce } from 'lodash'\nimport { cn } from '../../helpers/utils.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport Button from '../../components/button.js'\nimport { VideoModal } from '../VideoModal/index.js'\nimport { convertLexicalToHTML } from '@payloadcms/richtext-lexical/html'\nimport type { MediaPlayerBaseProps } from './types.js'\n// import { Right } from './right.js'\nimport { useInView } from 'react-intersection-observer'\nimport type { HTMLConvertersFunction } from '@payloadcms/richtext-lexical/html'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport ScrollLoadVideo from '../../helpers/ScrollLoadVideo.js'\nimport { gsap } from 'gsap'\nimport { SplitText } from 'gsap/dist/SplitText'\nimport { ScrollTrigger } from 'gsap/dist/ScrollTrigger'\n\nconst componentName = 'media_player_base'\nconst componentType = 'video'\n\nconst htmlConverters: HTMLConvertersFunction = ({ defaultConverters }) => ({\n ...defaultConverters,\n text: args => {\n const { node } = args\n // \u68C0\u67E5\u662F\u5426\u6709\u81EA\u5B9A\u4E49 color\n if (node.$ && node.$.color) {\n return `<span class=\"lexical-${node.$.color}\">${node.text}</span>`\n }\n return node.text\n },\n})\n\nconst MediaPlayerBase = forwardRef<HTMLDivElement, MediaPlayerBaseProps>(\n (\n {\n className = '',\n id,\n onBtnClick,\n data: { title, videoTitle, btnText, youtubeId, video, mobileVideo, theme, img, shape, titleAnimation, ...rest },\n },\n ref\n ) => {\n const { sticky } = rest\n const [isPlaying, setIsPlaying] = useState(false)\n const [btb, setbtb] = useState(0)\n const [titleHeight, setTitleHeight] = useState(0)\n const [videoHeightProgress, setVideoHeightProgress] = useState(0)\n const [visible, setVisible] = useState<boolean>(false)\n\n const videoRef = useRef<HTMLVideoElement>(null)\n const bgRef = useRef<HTMLImageElement>(null)\n const titleRef = useRef<HTMLDivElement>(null)\n const titleFadeInRef = useRef<HTMLDivElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const splitTextInstance = useRef<SplitText | null>(null)\n const scrollTriggerRef = useRef<ScrollTrigger | null>(null)\n const heightTriggerRef = useRef<ScrollTrigger | null>(null)\n const { ref: inViewRef, inView } = useInView()\n\n useImperativeHandle(ref, () => titleRef.current as HTMLDivElement)\n\n const title_html =\n typeof title === 'string' ? title : title && convertLexicalToHTML({ data: title, converters: htmlConverters })\n const videoTitle_html =\n typeof videoTitle === 'string'\n ? videoTitle\n : videoTitle && convertLexicalToHTML({ data: videoTitle, converters: htmlConverters })\n\n useEffect(() => {\n if (inView) {\n videoRef.current?.play()\n setIsPlaying(true)\n } else {\n videoRef.current?.pause()\n setIsPlaying(false)\n }\n }, [inView])\n\n const debouncedHandleResize = debounce(() => {\n if (titleRef.current) {\n const rect = titleRef.current.getBoundingClientRect()\n const screenHeight = window.innerHeight\n const scrollTop = window.scrollY || window.pageYOffset\n const elementBottomToPageTop = rect.bottom + scrollTop\n const pageHeight = document.documentElement.scrollHeight\n const distanceToPageBottom = pageHeight - elementBottomToPageTop\n setbtb(distanceToPageBottom > screenHeight ? screenHeight : distanceToPageBottom)\n }\n if (titleRef.current) {\n const titleHeight = titleRef.current.clientHeight\n const screenHeight = window.innerHeight\n setTitleHeight(titleHeight + screenHeight)\n }\n }, 600)\n\n useEffect(() => {\n debouncedHandleResize()\n window.addEventListener('resize', debouncedHandleResize)\n return () => {\n window.removeEventListener('resize', debouncedHandleResize)\n }\n }, [])\n\n useEffect(() => {\n function gsapResize() {\n if (!titleFadeInRef.current || titleAnimation !== 'fade-in') return\n const height = titleFadeInRef.current?.clientHeight || 80\n splitTextInstance.current = new SplitText(titleFadeInRef.current, {\n type: 'words',\n wordsClass: 'word',\n })\n const words = splitTextInstance.current.words\n gsap.set(words, { opacity: 0 })\n scrollTriggerRef.current = ScrollTrigger.create({\n trigger: titleRef.current,\n start: 'top center-=10%',\n end: `top+=${height * 1.5 + 80}px center-=10%`,\n scrub: true,\n onUpdate: (self: any) => {\n const progress = self.progress\n const total = words.length\n const interval = 1 / total\n const overlap = 0.5\n words.forEach((word: any, i: number) => {\n const start = (i / total) * (1 - overlap)\n const width = interval * (1 + overlap)\n let opacity = (progress - start) / width\n opacity = Math.max(0, Math.min(opacity, 1))\n gsap.set(word, { opacity })\n })\n gsap.set(bgRef.current, { opacity: progress })\n },\n })\n }\n\n function gsapVideoHeightResize() {\n heightTriggerRef.current = ScrollTrigger.create({\n trigger: titleRef.current,\n start: 'bottom bottom',\n end: `bottom top`,\n // markers: true,\n scrub: true,\n onUpdate: (self: any) => {\n const progress = self.progress\n console.log('progress__', progress)\n setVideoHeightProgress(progress)\n },\n })\n }\n\n if (inView) {\n gsapResize()\n gsapVideoHeightResize()\n }\n\n return () => {\n splitTextInstance.current && splitTextInstance.current.revert()\n // ScrollTrigger.getAll().forEach((t: { kill: () => any }) => t.kill())\n scrollTriggerRef.current && scrollTriggerRef.current.kill()\n heightTriggerRef.current && heightTriggerRef.current.kill()\n }\n }, [titleAnimation, inView])\n\n useExposure(trackRef, {\n componentType,\n componentName,\n componentTitle: videoTitle_html,\n })\n\n const zIndexVideo = useMemo(() => {\n if (inView && videoHeightProgress > 0 && videoHeightProgress < 0.9) return 3\n if (inView) return 2\n return 1\n }, [videoHeightProgress, inView])\n\n const aspect =\n 'lg-desktop:aspect-w-[1920] lg-desktop:aspect-h-[930] desktop:aspect-w-[1024] desktop:aspect-h-[520] laptop:aspect-w-[1024] laptop:aspect-h-[520] tablet:aspect-w-[768] tablet:aspect-h-[660] aspect-w-[390] aspect-h-[660]'\n return (\n <>\n {sticky && (\n <div\n ref={titleRef}\n className={cn(\n 'relative z-10',\n aspect,\n {\n 'aiui-dark': theme === 'dark',\n 'rounded-box': shape === 'rounded',\n },\n className\n )}\n >\n <div ref={inViewRef}>\n {!titleAnimation && (\n <div className=\"media-content absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 px-4 text-center\">\n {title_html && !isPlaying && (\n <div\n className=\"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl\"\n dangerouslySetInnerHTML={{ __html: title_html }}\n />\n )}\n {videoTitle_html && isPlaying && (\n <div\n className=\"lg-desktop:text-[64px] text-btn-primary-foreground text-center text-[40px] font-bold leading-none lg:text-5xl\"\n dangerouslySetInnerHTML={{ __html: videoTitle_html }}\n />\n )}\n {btnText && (\n <Button\n variant=\"link\"\n className={cn('member-equity-button-secondary text-btn-primary-foreground')}\n onClick={() => {\n setVisible(true)\n // if (isPlaying) {\n // if (videoRef.current) {\n // videoRef.current.pause()\n // }\n // setIsPlaying(false)\n // } else {\n // if (videoRef.current) {\n // videoRef.current.play()\n // }\n // setIsPlaying(true)\n // }\n onBtnClick && onBtnClick?.()\n }}\n >\n {btnText}\n {/* <Right /> */}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n )}\n <div\n style={\n sticky\n ? {\n marginBottom: `-${btb}px`,\n marginTop: `-${titleHeight}px`,\n zIndex: zIndexVideo,\n }\n : {}\n }\n className=\"relative\"\n >\n <div className=\"sticky top-0 \">\n <div\n id={id}\n className={cn('relative overflow-hidden', sticky ? 'h-screen w-full' : aspect, {\n 'aiui-dark': theme === 'dark',\n 'rounded-box': shape === 'rounded',\n })}\n >\n {titleAnimation === 'fade-in' && title_html && (\n <div\n ref={titleFadeInRef}\n className=\"lg-desktop:text-[64px] text-btn-primary-foreground absolute left-1/2 top-1/2 z-20 w-full -translate-x-1/2 -translate-y-1/2 text-center text-[40px] font-bold leading-none lg:text-5xl\"\n dangerouslySetInnerHTML={{ __html: title_html }}\n />\n )}\n <div\n className=\"media-cover left-0 top-0 h-screen w-screen overflow-hidden\"\n style={{ height: `${102 - videoHeightProgress * 100}vh` }}\n >\n <ScrollLoadVideo\n videoRef={videoRef}\n poster={img?.url || ''}\n src={video?.url!}\n className=\"tablet:block hidden size-full min-h-screen\"\n videoClassName=\"object-cover\"\n muted\n loop\n playsInline\n autoplay\n webkit-playsinline\n x5-playsinline\n />\n <ScrollLoadVideo\n videoRef={videoRef}\n poster={img?.url || ''}\n src={mobileVideo?.url || video?.url!}\n className=\"tablet:hidden block size-full min-h-screen\"\n videoClassName=\"object-cover\"\n muted\n loop\n playsInline\n autoplay\n webkit-playsinline\n x5-playsinline\n />\n <div\n ref={bgRef}\n className=\"absolute left-0 top-0 z-10 size-full opacity-0\"\n style={{\n background: 'rgba(0, 0, 0, 0.2)',\n }}\n />\n </div>\n </div>\n </div>\n {sticky && (\n <div\n className={cn(sticky && 'relative box-content block', aspect)}\n style={sticky ? { height: `${btb}px` } : {}}\n ref={trackRef}\n />\n )}\n </div>\n {visible && youtubeId && (\n <VideoModal visible={visible} youTubeId={youtubeId} onCloseModal={() => setVisible(false)} />\n )}\n </>\n )\n }\n)\n\nMediaPlayerBase.displayName = 'MediaPlayerBase'\n\nexport default withLayout(MediaPlayerBase)\n"],
5
+ "mappings": "mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IAmLM,IAAAI,EAAA,6BAlLNC,EAAsF,iBACtFC,EAAyB,kBACzBC,EAAmB,kCACnBC,GAA2B,kCAC3BC,GAAmB,yCACnBC,GAA2B,kCAC3BC,EAAqC,6CAGrCC,GAA0B,uCAE1BC,GAA4B,sCAC5BC,EAA4B,+CAC5BC,EAAqB,gBACrBC,GAA0B,+BAC1BC,EAA8B,mCAE9B,MAAMC,GAAgB,oBAChBC,GAAgB,QAEhBC,EAAyC,CAAC,CAAE,kBAAAC,CAAkB,KAAO,CACzE,GAAGA,EACH,KAAMC,GAAQ,CACZ,KAAM,CAAE,KAAAC,CAAK,EAAID,EAEjB,OAAIC,EAAK,GAAKA,EAAK,EAAE,MACZ,wBAAwBA,EAAK,EAAE,KAAK,KAAKA,EAAK,IAAI,UAEpDA,EAAK,IACd,CACF,GAEMC,KAAkB,cACtB,CACE,CACE,UAAAC,EAAY,GACZ,GAAAC,EACA,WAAAC,EACA,KAAM,CAAE,MAAAC,EAAO,WAAAC,EAAY,QAAAC,EAAS,UAAAC,EAAW,MAAAC,EAAO,YAAAC,GAAa,MAAAC,EAAO,IAAAC,EAAK,MAAAC,EAAO,eAAAC,EAAgB,GAAG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AU,gBACb,oBAAC,OACC,GAAIzD,EACJ,aAAW,MAAG,2BAA4Bc,EAAS,kBAAoB4C,EAAQ,CAC7E,YAAalD,IAAU,OACvB,cAAeE,IAAU,SAC3B,CAAC,EAEA,UAAAC,IAAmB,WAAawB,MAC/B,OAAC,OACC,IAAKP,EACL,UAAU,wLACV,wBAAyB,CAAE,OAAQO,CAAW,EAChD,KAEF,QAAC,OACC,UAAU,6DACV,MAAO,CAAE,OAAQ,GAAG,IAAMd,EAAsB,GAAG,IAAK,EAExD,oBAAC,EAAAuC,QAAA,CACC,SAAUnC,EACV,OAAQhB,GAAK,KAAO,GACpB,IAAKH,GAAO,IACZ,UAAU,6CACV,eAAe,eACf,MAAK,GACL,KAAI,GACJ,YAAW,GACX,SAAQ,GACR,qBAAkB,GAClB,iBAAc,GAChB,KACA,OAAC,EAAAsD,QAAA,CACC,SAAUnC,EACV,OAAQhB,GAAK,KAAO,GACpB,IAAKF,IAAa,KAAOD,GAAO,IAChC,UAAU,6CACV,eAAe,eACf,MAAK,GACL,KAAI,GACJ,YAAW,GACX,SAAQ,GACR,qBAAkB,GAClB,iBAAc,GAChB,KACA,OAAC,OACC,IAAKoB,EACL,UAAU,iDACV,MAAO,CACL,WAAY,oBACd,EACF,GACF,GACF,EACF,EACCZ,MACC,OAAC,OACC,aAAW,MAAGA,GAAU,6BAA8B4C,CAAM,EAC5D,MAAO5C,EAAS,CAAE,OAAQ,GAAGG,CAAG,IAAK,EAAI,CAAC,EAC1C,IAAKY,EACP,GAEJ,EACCN,GAAWlB,MACV,OAAC,eAAW,QAASkB,EAAS,UAAWlB,EAAW,aAAc,IAAMmB,EAAW,EAAK,EAAG,GAE/F,CAEJ,CACF,EAEA1B,EAAgB,YAAc,kBAE9B,IAAOtB,MAAQ,eAAWsB,CAAe",
6
6
  "names": ["MediaPlayerBase_exports", "__export", "MediaPlayerBase_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lodash", "import_utils", "import_Styles", "import_button", "import_VideoModal", "import_html", "import_react_intersection_observer", "import_useExposure", "import_ScrollLoadVideo", "import_gsap", "import_SplitText", "import_ScrollTrigger", "componentName", "componentType", "htmlConverters", "defaultConverters", "args", "node", "MediaPlayerBase", "className", "id", "onBtnClick", "title", "videoTitle", "btnText", "youtubeId", "video", "mobileVideo", "theme", "img", "shape", "titleAnimation", "rest", "ref", "sticky", "isPlaying", "setIsPlaying", "btb", "setbtb", "titleHeight", "setTitleHeight", "videoHeightProgress", "setVideoHeightProgress", "visible", "setVisible", "videoRef", "bgRef", "titleRef", "titleFadeInRef", "trackRef", "splitTextInstance", "scrollTriggerRef", "heightTriggerRef", "inViewRef", "inView", "title_html", "videoTitle_html", "debouncedHandleResize", "rect", "screenHeight", "scrollTop", "elementBottomToPageTop", "distanceToPageBottom", "gsapResize", "height", "words", "self", "progress", "total", "interval", "overlap", "word", "i", "start", "width", "opacity", "gsapVideoHeightResize", "zIndexVideo", "aspect", "Button", "ScrollLoadVideo"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var z=Object.create;var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var E=(e,i)=>{for(var r in i)f(e,r,{get:i[r],enumerable:!0})},h=(e,i,r,d)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of I(i))!q.call(e,s)&&s!==r&&f(e,s,{get:()=>i[s],enumerable:!(d=A(i,s))||d.enumerable});return e};var H=(e,i,r)=>(r=e!=null?z(_(e)):{},h(i||!e||!e.__esModule?f(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>h(f({},"__esModule",{value:!0}),e);var K={};E(K,{ProductCard:()=>u,default:()=>j});module.exports=R(K);var a=require("react/jsx-runtime"),c=H(require("react")),n=require("../../helpers/index.js"),t=require("../../components/index.js");const O=5;function G(e,i,r,d){if(e===void 0)return!0;switch(e){case"always":return!0;case"never":return!1;case"below-quantity":return i===void 0?!0:r<=i;case"below-percentage":return i===void 0?!0:r/d*100<=i;default:return!0}}const u=c.forwardRef(({product:e,className:i,stockDisplayMode:r,stockThresholdValue:d,onLearnMore:s,onShopNow:k,onAddToCart:w,classNames:l,secondaryButtonText:y,secondaryButtonFun:b,primaryButtonText:v,primaryButtonFun:g,showOriginalPrice:N,copy:p,onProductImageClick:x},P)=>{const[B,F]=c.useState(!1),[L,M]=c.useState(!1),T=c.useMemo(()=>e?.availableForSale&&e?.quantityAvailable<=0?O:e?.availableForSale?(e?.quantityAvailable??0)/(e?.totalInventory??1)*100:0,[e?.availableForSale,e?.quantityAvailable,e?.totalInventory]),C=async(o,m)=>{if(!o)return;const S=m==="primary"?F:M;S(!0);try{switch(o){case"buyNow":await k?.(e);break;case"addCart":await w?.(e);break;case"learnMore":await s?.(e);break;default:break}}finally{S(!1)}},D=e.availableForSale&&e.quantityAvailable<=0;return(0,a.jsxs)(t.Card,{ref:P,className:(0,n.cn)("flex h-full min-w-[296px] flex-col overflow-hidden",e.custom_link?"cursor-pointer":"",i,l?.productCard),children:[(0,a.jsxs)("div",{className:(0,n.cn)("media-shelf-product-card-image-wrapper desktop:h-[240px] relative h-[200px] shrink-0 overflow-hidden",l?.productCardImageWrapper),children:[(0,a.jsx)("div",{className:(0,n.cn)("media-shelf-product-card-image-bg absolute inset-0 ",l?.productCardImageBg),children:(0,a.jsx)("a",{onClick:()=>x?.(e),...!x&&{href:e.custom_link||e.listingLink},className:"cursor-pointer",children:(0,a.jsx)(t.Picture,{source:e.custom_image||e.image,alt:e.name,className:(0,n.cn)("h-full",l?.productCardImage),imgClassName:"h-full object-contain"})})}),(0,a.jsx)("div",{className:"lg-desktop:h-[28px] absolute left-4 top-4 flex h-[24px]",children:e.tags?.map((o,m)=>o.label?(0,a.jsx)(t.Badge,{size:"sm",variant:o.variant||"outline",className:(0,n.cn)("mr-1"),promotionalType:o.promotionalType,children:o.label},m):(0,a.jsx)(c.Fragment,{children:o},m))})]}),(0,a.jsxs)(t.CardContent,{className:"desktop:p-6 flex h-[calc(100%-240px)] grow flex-col justify-between p-4",children:[(0,a.jsxs)("div",{className:"mb-6 flex-1",children:[(0,a.jsx)(t.Heading,{as:"h3",size:2,className:(0,n.cn)("text-info-primary mb-1 line-clamp-2 tracking-tight",l?.productTitle),children:e.custom_name||e.name}),(e.custom_description||e?.description)&&(0,a.jsx)(t.Text,{size:2,className:(0,n.cn)("text-info-primary line-clamp-1",l?.productDescription),html:e.custom_description||e.description})]}),G(r,d,e?.quantityAvailable??0,e?.totalInventory??0)&&(0,a.jsxs)("div",{"data-total":e?.totalInventory??0,"data-available":e?.quantityAvailable??0,className:"space-y-2",children:[(0,a.jsx)(t.Progress,{value:T,max:100,min:0,size:"base",variant:"default","aria-label":"stock progress",classNames:{progressBar:"transition-all duration-300 ease-in-out"}}),(0,a.jsx)(t.Text,{size:3,className:"text-info-tertiary text-[14px]",children:D?p?.limitedStock:p?.stockDisplayText?.replace("{count}",`${e.availableForSale?e.quantityAvailable:0}`)})]}),(0,a.jsx)(a.Fragment,{children:e?.priceLabel&&e?.availableForSale&&(0,a.jsx)(t.Text,{size:4,className:(0,n.cn)("text-marketing-1 desktop:text-[16px] lg-desktop:text-[18px] mt-2 text-[12px]",l?.productPriceLabel),children:e.priceLabel})}),(0,a.jsx)("div",{className:(0,n.cn)("mb-6",l?.productPrice),children:(0,a.jsx)("div",{className:"flex items-baseline gap-2",children:e.availableForSale?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.Heading,{size:2,className:"text-info-primary",as:"h6",children:e.price}),N&&e.originalPrice&&(0,a.jsx)(t.Heading,{size:2,className:"text-info-tertiary line-through",as:"h6",children:e.originalPrice})]}):(0,a.jsx)(t.Heading,{size:2,className:"text-info-tertiary",children:p?.outOfStockLabel??"Sold Out"})})}),(0,a.jsxs)("div",{className:(0,n.cn)("lg-desktop:gap-3 tablet:flex-nowrap flex flex-wrap gap-2",l?.buttonGroup),children:[y&&(0,a.jsx)(t.Button,{variant:"secondary",size:"base",className:(0,n.cn)("tablet:w-fit w-full",l?.secondaryButton),onClick:()=>C(b,"secondary"),disabled:!e.availableForSale&&b!=="learnMore",loading:L,children:y}),v&&(0,a.jsx)(t.Button,{variant:"primary",size:"base",className:(0,n.cn)("tablet:w-fit w-full",l?.primaryButton),onClick:()=>C(g,"primary"),disabled:!e.availableForSale&&g!=="learnMore",loading:B,children:v})]})]})]})});u.displayName="MediaShelf.ProductCard";var j=u;
1
+ "use strict";"use client";var z=Object.create;var p=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var E=(e,i)=>{for(var r in i)p(e,r,{get:i[r],enumerable:!0})},k=(e,i,r,d)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of I(i))!q.call(e,s)&&s!==r&&p(e,s,{get:()=>i[s],enumerable:!(d=A(i,s))||d.enumerable});return e};var H=(e,i,r)=>(r=e!=null?z(_(e)):{},k(i||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>k(p({},"__esModule",{value:!0}),e);var K={};E(K,{ProductCard:()=>f,default:()=>G});module.exports=R(K);var a=require("react/jsx-runtime"),c=H(require("react")),n=require("../../helpers/index.js"),t=require("../../components/index.js");const O=5;function j(e,i,r,d){if(e===void 0)return!0;switch(e){case"always":return!0;case"never":return!1;case"below-quantity":return i===void 0?!0:r<=i;case"below-percentage":return i===void 0?!0:r/d*100<=i;default:return!0}}const f=c.forwardRef(({product:e,className:i,stockDisplayMode:r,stockThresholdValue:d,onLearnMore:s,onShopNow:S,onAddToCart:w,classNames:l,secondaryButtonText:y,secondaryButtonFun:b,primaryButtonText:g,primaryButtonFun:v,showOriginalPrice:N,copy:u,onProductImageClick:x},P)=>{const[B,F]=c.useState(!1),[L,M]=c.useState(!1),T=c.useMemo(()=>e?.availableForSale&&e?.quantityAvailable<=0?O:e?.availableForSale?(e?.quantityAvailable??0)/(e?.totalInventory??1)*100:0,[e?.availableForSale,e?.quantityAvailable,e?.totalInventory]),C=async(o,m)=>{if(!o)return;const h=m==="primary"?F:M;h(!0);try{switch(o){case"buyNow":await S?.(e);break;case"addCart":await w?.(e);break;case"learnMore":await s?.(e);break;default:break}}finally{h(!1)}},D=e.availableForSale&&e.quantityAvailable<=0;return(0,a.jsxs)(t.Card,{ref:P,className:(0,n.cn)("tablet:min-w-[auto] hover:bg-container-secondary-0 flex h-full min-w-[296px] flex-col overflow-hidden border-none",e.custom_link?"cursor-pointer":"",i,l?.productCard),children:[(0,a.jsxs)("div",{className:(0,n.cn)("media-shelf-product-card-image-wrapper desktop:h-[240px] relative h-[200px] shrink-0 overflow-hidden",l?.productCardImageWrapper),children:[(0,a.jsx)("div",{className:(0,n.cn)("media-shelf-product-card-image-bg absolute inset-0 ",l?.productCardImageBg),children:(0,a.jsx)("a",{onClick:()=>x?.(e),...!x&&{href:e.custom_link||e.listingLink},className:"cursor-pointer",children:(0,a.jsx)(t.Picture,{source:e.custom_image||e.image,alt:e.name,className:(0,n.cn)("h-full",l?.productCardImage),imgClassName:"h-full object-contain"})})}),(0,a.jsx)("div",{className:"lg-desktop:h-[28px] absolute left-4 top-4 flex h-[24px]",children:e.tags?.map((o,m)=>o.label?(0,a.jsx)(t.Badge,{size:"sm",variant:o.variant||"outline",className:(0,n.cn)("mr-1"),promotionalType:o.promotionalType,children:o.label},m):(0,a.jsx)(c.Fragment,{children:o},m))})]}),(0,a.jsxs)(t.CardContent,{className:"desktop:p-6 bg-container-primary laptop:gap-6 flex h-[calc(100%-240px)] grow flex-col justify-between gap-4 p-4",children:[(0,a.jsxs)("div",{className:"flex-0",children:[(0,a.jsx)(t.Heading,{as:"h3",size:2,className:(0,n.cn)("text-info-primary mb-1 line-clamp-2 tracking-tight",l?.productTitle),children:e.custom_name||e.name}),(e.custom_description||e?.description)&&(0,a.jsx)(t.Text,{size:2,className:(0,n.cn)("text-info-primary line-clamp-1",l?.productDescription),html:e.custom_description||e.description})]}),j(r,d,e?.quantityAvailable??0,e?.totalInventory??0)&&(0,a.jsxs)("div",{"data-total":e?.totalInventory??0,"data-available":e?.quantityAvailable??0,className:"space-y-2",children:[(0,a.jsx)(t.Progress,{value:T,max:100,min:0,size:"base",variant:"default","aria-label":"stock progress",classNames:{progressBar:"transition-all duration-300 ease-in-out"}}),(0,a.jsx)(t.Text,{size:3,className:"text-info-tertiary desktop:text-[16px] lg-desktop:text-[18px] text-[12px]",children:D?u?.limitedStock:u?.stockDisplayText?.replace("{count}",`${e.availableForSale?e.quantityAvailable:0}`)})]}),(0,a.jsxs)("div",{children:[e?.priceLabel&&e?.availableForSale&&(0,a.jsx)(t.Text,{size:4,className:(0,n.cn)("text-marketing-1 desktop:text-[16px] lg-desktop:text-[18px] mt-2 text-[12px]",l?.productPriceLabel),children:e.priceLabel}),(0,a.jsx)("div",{className:(0,n.cn)("mb-2",l?.productPrice),children:(0,a.jsx)("div",{className:"flex items-baseline gap-2",children:e.availableForSale?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.Heading,{size:2,className:"text-info-primary",as:"h6",children:e.price}),N&&e.originalPrice&&(0,a.jsx)(t.Heading,{size:2,className:"text-info-tertiary line-through",as:"h6",children:e.originalPrice})]}):(0,a.jsx)(t.Heading,{size:2,className:"text-info-tertiary",children:u?.outOfStockLabel??"Sold Out"})})}),(0,a.jsxs)("div",{className:(0,n.cn)("lg-desktop:gap-3 tablet:flex-nowrap flex flex-wrap gap-2",l?.buttonGroup),children:[y&&(0,a.jsx)(t.Button,{variant:"secondary",size:"base",className:(0,n.cn)("tablet:w-fit w-full",l?.secondaryButton),onClick:()=>C(b,"secondary"),disabled:!e.availableForSale&&b!=="learnMore",loading:L,children:y}),g&&(0,a.jsx)(t.Button,{variant:"primary",size:"base",className:(0,n.cn)("tablet:w-fit w-full",l?.primaryButton),onClick:()=>C(v,"primary"),disabled:!e.availableForSale&&v!=="learnMore",loading:B,children:g})]})]})]})]})});f.displayName="MediaShelf.ProductCard";var G=f;
2
2
  //# sourceMappingURL=ProductCard.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/MediaShelf/ProductCard.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { Button, Badge, Card, CardContent, Picture, Text, Heading, Progress } from '../../components/index.js'\n\nimport type {\n ButtonFunctionType,\n CopyConfig,\n ProductCardData,\n StockDisplayMode,\n MediaShelfSemanticName,\n} from './types.js'\n\n/**\n * \u8D85\u5356\u65F6\u5E93\u5B58\u6761\u663E\u793A\u7684\u6700\u5C0F\u767E\u5206\u6BD4\n * \u9632\u6B62\u8D85\u5356\u65F6\u5E93\u5B58\u6761\u663E\u793A\u4E3A\u6EE1\u683C\uFF08100%\uFF09\u6216\u5B8C\u5168\u7A7A\uFF080%\uFF09\n */\nconst OVERSELLING_STOCK_PERCENTAGE = 5\n\n/**\n * \u5224\u65AD\u662F\u5426\u5E94\u8BE5\u663E\u793A\u5E93\u5B58\u4FE1\u606F\n * @param stockDisplayMode \u5E93\u5B58\u5C55\u793A\u6A21\u5F0F\n * @param stockThresholdValue \u5E93\u5B58\u9608\u503C\uFF08\u5F53\u6A21\u5F0F\u4E3A below-quantity \u6216 below-percentage \u65F6\u4F7F\u7528\uFF09\n * @param quantityAvailable \u53EF\u7528\u5E93\u5B58\u6570\u91CF\n * @param totalInventory \u603B\u5E93\u5B58\n * @returns \u662F\u5426\u663E\u793A\u5E93\u5B58\u4FE1\u606F\n */\nfunction shouldShowStock(\n stockDisplayMode: StockDisplayMode | undefined,\n stockThresholdValue: number | undefined,\n quantityAvailable: number,\n totalInventory: number\n): boolean {\n // \u672A\u914D\u7F6E\u65F6\u9ED8\u8BA4\u663E\u793A\n if (stockDisplayMode === undefined) {\n return true\n }\n\n // \u6839\u636E\u5C55\u793A\u6A21\u5F0F\u5224\u65AD\n switch (stockDisplayMode) {\n case 'always':\n // \u603B\u662F\u663E\u793A\n return true\n\n case 'never':\n // \u6C38\u4E0D\u663E\u793A\n return false\n\n case 'below-quantity':\n // \u5F53\u5E93\u5B58\u6570\u91CF\u4F4E\u4E8E\u9608\u503C\u65F6\u663E\u793A\n if (stockThresholdValue === undefined) {\n return true // \u6CA1\u6709\u8BBE\u7F6E\u9608\u503C\u65F6\u9ED8\u8BA4\u663E\u793A\n }\n\n return quantityAvailable <= stockThresholdValue\n\n case 'below-percentage':\n // \u5F53\u5E93\u5B58\u767E\u5206\u6BD4\u4F4E\u4E8E\u9608\u503C\u65F6\u663E\u793A\n if (stockThresholdValue === undefined) {\n return true // \u6CA1\u6709\u8BBE\u7F6E\u9608\u503C\u65F6\u9ED8\u8BA4\u663E\u793A\n }\n return (quantityAvailable / totalInventory) * 100 <= stockThresholdValue\n\n default:\n // \u672A\u77E5\u6A21\u5F0F\u65F6\u9ED8\u8BA4\u663E\u793A\n return true\n }\n}\n\n/**\n * MediaShelf ProductCard \u7EC4\u4EF6 Props \u63A5\u53E3\n */\nexport interface MediaShelfProductCardProps {\n /** \u4EA7\u54C1\u6570\u636E */\n product: ProductCardData\n /** \u6837\u5F0F\u7C7B\u540D */\n className?: string\n /** \u5E93\u5B58\u5C55\u793A\u6A21\u5F0F */\n stockDisplayMode?: StockDisplayMode\n /** \u5E93\u5B58\u9608\u503C\uFF08\u5F53\u6A21\u5F0F\u4E3A below-quantity \u6216 below-percentage \u65F6\u4F7F\u7528\uFF09 */\n stockThresholdValue?: number\n /** \u70B9\u51FB\u4E86\u89E3\u66F4\u591A\u56DE\u8C03 */\n onLearnMore?: (product: ProductCardData) => void\n /** \u70B9\u51FB\u7ACB\u5373\u8D2D\u4E70\u56DE\u8C03 */\n onShopNow?: (product: ProductCardData) => void\n /** \u70B9\u51FB\u52A0\u5165\u8D2D\u7269\u8F66\u56DE\u8C03 */\n onAddToCart?: (product: ProductCardData) => void\n /** \u8BED\u4E49\u5316\u7C7B\u540D */\n classNames?: Partial<Record<MediaShelfSemanticName, string>>\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u6587\u672C */\n secondaryButtonText?: string\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u529F\u80FD */\n secondaryButtonFun?: ButtonFunctionType\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u6587\u672C */\n primaryButtonText?: string\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u529F\u80FD */\n primaryButtonFun?: ButtonFunctionType\n /** \u662F\u5426\u5C55\u793A\u539F\u4EF7\uFF08\u5220\u9664\u7EBF\u4EF7\u683C\uFF09 */\n showOriginalPrice?: boolean\n /** \u6587\u6848\u914D\u7F6E */\n copy?: CopyConfig\n /** \u70B9\u51FB\u4EA7\u54C1\u56FE\u7247\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n}\n\n/**\n * MediaShelf \u4EA7\u54C1\u5361\u7247\u7EC4\u4EF6\n */\nconst ProductCard = React.forwardRef<HTMLDivElement, MediaShelfProductCardProps>(\n (\n {\n product,\n className,\n stockDisplayMode,\n stockThresholdValue,\n onLearnMore,\n onShopNow,\n onAddToCart,\n classNames,\n secondaryButtonText,\n secondaryButtonFun,\n primaryButtonText,\n primaryButtonFun,\n showOriginalPrice,\n copy,\n onProductImageClick,\n },\n ref\n ) => {\n const [primaryLoading, setPrimaryLoading] = React.useState(false)\n const [secondaryLoading, setSecondaryLoading] = React.useState(false)\n\n const stockPercentage = React.useMemo(() => {\n if (product?.availableForSale && product?.quantityAvailable <= 0) {\n return OVERSELLING_STOCK_PERCENTAGE\n }\n // \u4E0D\u53EF\u552E\u65F6\u663E\u793A0%\n if (!product?.availableForSale) {\n return 0\n }\n return ((product?.quantityAvailable ?? 0) / (product?.totalInventory ?? 1)) * 100\n }, [product?.availableForSale, product?.quantityAvailable, product?.totalInventory])\n\n // \u6839\u636E\u6309\u94AE\u529F\u80FD\u7C7B\u578B\u8C03\u7528\u76F8\u5E94\u7684\u56DE\u8C03\u51FD\u6570\n const handleButtonClick = async (buttonFun?: ButtonFunctionType, buttonType?: 'primary' | 'secondary') => {\n if (!buttonFun) return\n\n const setLoading = buttonType === 'primary' ? setPrimaryLoading : setSecondaryLoading\n setLoading(true)\n\n try {\n switch (buttonFun) {\n case 'buyNow':\n await onShopNow?.(product)\n break\n case 'addCart':\n await onAddToCart?.(product)\n break\n case 'learnMore':\n await onLearnMore?.(product)\n break\n default:\n break\n }\n } finally {\n setLoading(false)\n }\n }\n\n const overselling = product.availableForSale && product.quantityAvailable <= 0\n\n return (\n <Card\n ref={ref}\n className={cn(\n 'flex h-full min-w-[296px] flex-col overflow-hidden',\n product.custom_link ? 'cursor-pointer' : '',\n className,\n classNames?.productCard\n )}\n >\n {/* \u56FE\u7247\u533A\u57DF */}\n <div\n className={cn(\n 'media-shelf-product-card-image-wrapper desktop:h-[240px] relative h-[200px] shrink-0 overflow-hidden',\n classNames?.productCardImageWrapper\n )}\n >\n {/* \u80CC\u666F\u56FE\u7247 */}\n <div className={cn('media-shelf-product-card-image-bg absolute inset-0 ', classNames?.productCardImageBg)}>\n <a\n onClick={() => onProductImageClick?.(product)}\n {...(!onProductImageClick && {\n href: product.custom_link || product.listingLink,\n })}\n className=\"cursor-pointer\"\n >\n <Picture\n source={product.custom_image || product.image}\n alt={product.name}\n className={cn('h-full', classNames?.productCardImage)}\n imgClassName=\"h-full object-contain\"\n />\n </a>\n </div>\n\n {/* \u6807\u7B7E\u533A\u57DF */}\n <div className=\"lg-desktop:h-[28px] absolute left-4 top-4 flex h-[24px]\">\n {product.tags?.map((tag: any, index) =>\n (tag as any).label ? (\n <Badge\n key={index}\n size=\"sm\"\n variant={(tag.variant as any) || 'outline'}\n className={cn('mr-1')}\n promotionalType={tag.promotionalType}\n >\n {tag.label}\n </Badge>\n ) : (\n <React.Fragment key={index}>{tag}</React.Fragment>\n )\n )}\n </div>\n </div>\n\n {/* \u5185\u5BB9\u533A\u57DF */}\n <CardContent className=\"desktop:p-6 flex h-[calc(100%-240px)] grow flex-col justify-between p-4\">\n {/* \u4EA7\u54C1\u6807\u9898\u548C\u526F\u6807\u9898 */}\n <div className=\"mb-6 flex-1\">\n <Heading\n as=\"h3\"\n size={2}\n className={cn('text-info-primary mb-1 line-clamp-2 tracking-tight', classNames?.productTitle)}\n >\n {product.custom_name || product.name}\n </Heading>\n {(product.custom_description || product?.description) && (\n <Text\n size={2}\n className={cn('text-info-primary line-clamp-1', classNames?.productDescription)}\n html={product.custom_description || product.description}\n />\n )}\n </div>\n\n {/* \u5E93\u5B58\u4FE1\u606F */}\n {shouldShowStock(\n stockDisplayMode,\n stockThresholdValue,\n product?.quantityAvailable ?? 0,\n product?.totalInventory ?? 0\n ) && (\n <div\n data-total={product?.totalInventory ?? 0}\n data-available={product?.quantityAvailable ?? 0}\n className=\"space-y-2\"\n >\n <Progress\n value={stockPercentage}\n max={100}\n min={0}\n size=\"base\"\n variant=\"default\"\n aria-label=\"stock progress\"\n classNames={{\n progressBar: 'transition-all duration-300 ease-in-out',\n }}\n />\n <Text size={3} className=\"text-info-tertiary text-[14px]\">\n {overselling\n ? copy?.limitedStock\n : copy?.stockDisplayText?.replace(\n '{count}',\n `${product.availableForSale ? product.quantityAvailable : 0}`\n )}\n </Text>\n </div>\n )}\n\n {/** \u4EF7\u683C\u6807\u7B7E */}\n <>\n {product?.priceLabel && product?.availableForSale && (\n <Text\n size={4}\n className={cn(\n 'text-marketing-1 desktop:text-[16px] lg-desktop:text-[18px] mt-2 text-[12px]',\n classNames?.productPriceLabel\n )}\n >\n {product.priceLabel}\n </Text>\n )}\n </>\n {/* \u4EF7\u683C\u533A\u57DF */}\n <div className={cn('mb-6', classNames?.productPrice)}>\n <div className=\"flex items-baseline gap-2\">\n {product.availableForSale ? (\n <>\n <Heading size={2} className=\"text-info-primary\" as=\"h6\">\n {product.price}\n </Heading>\n {showOriginalPrice && product.originalPrice && (\n <Heading size={2} className=\"text-info-tertiary line-through\" as=\"h6\">\n {product.originalPrice}\n </Heading>\n )}\n </>\n ) : (\n <Heading size={2} className=\"text-info-tertiary\">\n {copy?.outOfStockLabel ?? 'Sold Out'}\n </Heading>\n )}\n </div>\n </div>\n\n {/* \u6309\u94AE\u533A\u57DF */}\n <div className={cn('lg-desktop:gap-3 tablet:flex-nowrap flex flex-wrap gap-2', classNames?.buttonGroup)}>\n {secondaryButtonText && (\n <Button\n variant=\"secondary\"\n size=\"base\"\n className={cn('tablet:w-fit w-full', classNames?.secondaryButton)}\n onClick={() => handleButtonClick(secondaryButtonFun, 'secondary')}\n disabled={!product.availableForSale && secondaryButtonFun !== 'learnMore'}\n loading={secondaryLoading}\n >\n {secondaryButtonText}\n </Button>\n )}\n {primaryButtonText && (\n <Button\n variant=\"primary\"\n size=\"base\"\n className={cn('tablet:w-fit w-full', classNames?.primaryButton)}\n onClick={() => handleButtonClick(primaryButtonFun, 'primary')}\n disabled={!product.availableForSale && primaryButtonFun !== 'learnMore'}\n loading={primaryLoading}\n >\n {primaryButtonText}\n </Button>\n )}\n </div>\n </CardContent>\n </Card>\n )\n }\n)\n\nProductCard.displayName = 'MediaShelf.ProductCard'\n\nexport default ProductCard\nexport { ProductCard }\n"],
5
- "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAuLQ,IAAAK,EAAA,6BArLRC,EAAuB,oBACvBC,EAAmB,kCACnBC,EAAmF,qCAcnF,MAAMC,EAA+B,EAUrC,SAASC,EACPC,EACAC,EACAC,EACAC,EACS,CAET,GAAIH,IAAqB,OACvB,MAAO,GAIT,OAAQA,EAAkB,CACxB,IAAK,SAEH,MAAO,GAET,IAAK,QAEH,MAAO,GAET,IAAK,iBAEH,OAAIC,IAAwB,OACnB,GAGFC,GAAqBD,EAE9B,IAAK,mBAEH,OAAIA,IAAwB,OACnB,GAEDC,EAAoBC,EAAkB,KAAOF,EAEvD,QAEE,MAAO,EACX,CACF,CAyCA,MAAMV,EAAcI,EAAM,WACxB,CACE,CACE,QAAAS,EACA,UAAAC,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K,GAAY,iBACd,EAEC,SAAAL,EAAQ,WACX,EAEJ,KAEA,OAAC,OAAI,aAAW,MAAG,OAAQK,GAAY,YAAY,EACjD,mBAAC,OAAI,UAAU,4BACZ,SAAAL,EAAQ,oBACP,oBACE,oBAAC,WAAQ,KAAM,EAAG,UAAU,oBAAoB,GAAG,KAChD,SAAAA,EAAQ,MACX,EACCU,GAAqBV,EAAQ,kBAC5B,OAAC,WAAQ,KAAM,EAAG,UAAU,kCAAkC,GAAG,KAC9D,SAAAA,EAAQ,cACX,GAEJ,KAEA,OAAC,WAAQ,KAAM,EAAG,UAAU,qBACzB,SAAAW,GAAM,iBAAmB,WAC5B,EAEJ,EACF,KAGA,QAAC,OAAI,aAAW,MAAG,2DAA4DN,GAAY,WAAW,EACnG,UAAAC,MACC,OAAC,UACC,QAAQ,YACR,KAAK,OACL,aAAW,MAAG,sBAAuBD,GAAY,eAAe,EAChE,QAAS,IAAMc,EAAkBZ,EAAoB,WAAW,EAChE,SAAU,CAACP,EAAQ,kBAAoBO,IAAuB,YAC9D,QAASS,EAER,SAAAV,EACH,EAEDE,MACC,OAAC,UACC,QAAQ,UACR,KAAK,OACL,aAAW,MAAG,sBAAuBH,GAAY,aAAa,EAC9D,QAAS,IAAMc,EAAkBV,EAAkB,SAAS,EAC5D,SAAU,CAACT,EAAQ,kBAAoBS,IAAqB,YAC5D,QAASK,EAER,SAAAN,EACH,GAEJ,GACF,GACF,CAEJ,CACF,EAEArB,EAAY,YAAc,yBAE1B,IAAOC,EAAQD",
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { Button, Badge, Card, CardContent, Picture, Text, Heading, Progress } from '../../components/index.js'\n\nimport type {\n ButtonFunctionType,\n CopyConfig,\n ProductCardData,\n StockDisplayMode,\n MediaShelfSemanticName,\n} from './types.js'\nimport type { Theme } from '../../types/props.js'\n\n/**\n * \u8D85\u5356\u65F6\u5E93\u5B58\u6761\u663E\u793A\u7684\u6700\u5C0F\u767E\u5206\u6BD4\n * \u9632\u6B62\u8D85\u5356\u65F6\u5E93\u5B58\u6761\u663E\u793A\u4E3A\u6EE1\u683C\uFF08100%\uFF09\u6216\u5B8C\u5168\u7A7A\uFF080%\uFF09\n */\nconst OVERSELLING_STOCK_PERCENTAGE = 5\n\n/**\n * \u5224\u65AD\u662F\u5426\u5E94\u8BE5\u663E\u793A\u5E93\u5B58\u4FE1\u606F\n * @param stockDisplayMode \u5E93\u5B58\u5C55\u793A\u6A21\u5F0F\n * @param stockThresholdValue \u5E93\u5B58\u9608\u503C\uFF08\u5F53\u6A21\u5F0F\u4E3A below-quantity \u6216 below-percentage \u65F6\u4F7F\u7528\uFF09\n * @param quantityAvailable \u53EF\u7528\u5E93\u5B58\u6570\u91CF\n * @param totalInventory \u603B\u5E93\u5B58\n * @returns \u662F\u5426\u663E\u793A\u5E93\u5B58\u4FE1\u606F\n */\nfunction shouldShowStock(\n stockDisplayMode: StockDisplayMode | undefined,\n stockThresholdValue: number | undefined,\n quantityAvailable: number,\n totalInventory: number\n): boolean {\n // \u672A\u914D\u7F6E\u65F6\u9ED8\u8BA4\u663E\u793A\n if (stockDisplayMode === undefined) {\n return true\n }\n\n // \u6839\u636E\u5C55\u793A\u6A21\u5F0F\u5224\u65AD\n switch (stockDisplayMode) {\n case 'always':\n // \u603B\u662F\u663E\u793A\n return true\n\n case 'never':\n // \u6C38\u4E0D\u663E\u793A\n return false\n\n case 'below-quantity':\n // \u5F53\u5E93\u5B58\u6570\u91CF\u4F4E\u4E8E\u9608\u503C\u65F6\u663E\u793A\n if (stockThresholdValue === undefined) {\n return true // \u6CA1\u6709\u8BBE\u7F6E\u9608\u503C\u65F6\u9ED8\u8BA4\u663E\u793A\n }\n\n return quantityAvailable <= stockThresholdValue\n\n case 'below-percentage':\n // \u5F53\u5E93\u5B58\u767E\u5206\u6BD4\u4F4E\u4E8E\u9608\u503C\u65F6\u663E\u793A\n if (stockThresholdValue === undefined) {\n return true // \u6CA1\u6709\u8BBE\u7F6E\u9608\u503C\u65F6\u9ED8\u8BA4\u663E\u793A\n }\n return (quantityAvailable / totalInventory) * 100 <= stockThresholdValue\n\n default:\n // \u672A\u77E5\u6A21\u5F0F\u65F6\u9ED8\u8BA4\u663E\u793A\n return true\n }\n}\n\n/**\n * MediaShelf ProductCard \u7EC4\u4EF6 Props \u63A5\u53E3\n */\nexport interface MediaShelfProductCardProps {\n /** \u4EA7\u54C1\u6570\u636E */\n product: ProductCardData\n /** \u6837\u5F0F\u7C7B\u540D */\n className?: string\n /** \u5E93\u5B58\u5C55\u793A\u6A21\u5F0F */\n stockDisplayMode?: StockDisplayMode\n /** \u5E93\u5B58\u9608\u503C\uFF08\u5F53\u6A21\u5F0F\u4E3A below-quantity \u6216 below-percentage \u65F6\u4F7F\u7528\uFF09 */\n stockThresholdValue?: number\n /** \u70B9\u51FB\u4E86\u89E3\u66F4\u591A\u56DE\u8C03 */\n onLearnMore?: (product: ProductCardData) => void\n /** \u70B9\u51FB\u7ACB\u5373\u8D2D\u4E70\u56DE\u8C03 */\n onShopNow?: (product: ProductCardData) => void\n /** \u70B9\u51FB\u52A0\u5165\u8D2D\u7269\u8F66\u56DE\u8C03 */\n onAddToCart?: (product: ProductCardData) => void\n /** \u8BED\u4E49\u5316\u7C7B\u540D */\n classNames?: Partial<Record<MediaShelfSemanticName, string>>\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u6587\u672C */\n secondaryButtonText?: string\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u529F\u80FD */\n secondaryButtonFun?: ButtonFunctionType\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u6587\u672C */\n primaryButtonText?: string\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u529F\u80FD */\n primaryButtonFun?: ButtonFunctionType\n /** \u662F\u5426\u5C55\u793A\u539F\u4EF7\uFF08\u5220\u9664\u7EBF\u4EF7\u683C\uFF09 */\n showOriginalPrice?: boolean\n /** \u6587\u6848\u914D\u7F6E */\n copy?: CopyConfig\n /** \u70B9\u51FB\u4EA7\u54C1\u56FE\u7247\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n}\n\n/**\n * MediaShelf \u4EA7\u54C1\u5361\u7247\u7EC4\u4EF6\n */\nconst ProductCard = React.forwardRef<HTMLDivElement, MediaShelfProductCardProps>(\n (\n {\n product,\n className,\n stockDisplayMode,\n stockThresholdValue,\n onLearnMore,\n onShopNow,\n onAddToCart,\n classNames,\n secondaryButtonText,\n secondaryButtonFun,\n primaryButtonText,\n primaryButtonFun,\n showOriginalPrice,\n copy,\n onProductImageClick,\n },\n ref\n ) => {\n const [primaryLoading, setPrimaryLoading] = React.useState(false)\n const [secondaryLoading, setSecondaryLoading] = React.useState(false)\n\n const stockPercentage = React.useMemo(() => {\n if (product?.availableForSale && product?.quantityAvailable <= 0) {\n return OVERSELLING_STOCK_PERCENTAGE\n }\n // \u4E0D\u53EF\u552E\u65F6\u663E\u793A0%\n if (!product?.availableForSale) {\n return 0\n }\n return ((product?.quantityAvailable ?? 0) / (product?.totalInventory ?? 1)) * 100\n }, [product?.availableForSale, product?.quantityAvailable, product?.totalInventory])\n\n // \u6839\u636E\u6309\u94AE\u529F\u80FD\u7C7B\u578B\u8C03\u7528\u76F8\u5E94\u7684\u56DE\u8C03\u51FD\u6570\n const handleButtonClick = async (buttonFun?: ButtonFunctionType, buttonType?: 'primary' | 'secondary') => {\n if (!buttonFun) return\n\n const setLoading = buttonType === 'primary' ? setPrimaryLoading : setSecondaryLoading\n setLoading(true)\n\n try {\n switch (buttonFun) {\n case 'buyNow':\n await onShopNow?.(product)\n break\n case 'addCart':\n await onAddToCart?.(product)\n break\n case 'learnMore':\n await onLearnMore?.(product)\n break\n default:\n break\n }\n } finally {\n setLoading(false)\n }\n }\n\n const overselling = product.availableForSale && product.quantityAvailable <= 0\n\n return (\n <Card\n ref={ref}\n className={cn(\n 'tablet:min-w-[auto] hover:bg-container-secondary-0 flex h-full min-w-[296px] flex-col overflow-hidden border-none',\n product.custom_link ? 'cursor-pointer' : '',\n className,\n classNames?.productCard\n )}\n >\n {/* \u56FE\u7247\u533A\u57DF */}\n <div\n className={cn(\n 'media-shelf-product-card-image-wrapper desktop:h-[240px] relative h-[200px] shrink-0 overflow-hidden',\n classNames?.productCardImageWrapper\n )}\n >\n {/* \u80CC\u666F\u56FE\u7247 */}\n <div className={cn('media-shelf-product-card-image-bg absolute inset-0 ', classNames?.productCardImageBg)}>\n <a\n onClick={() => onProductImageClick?.(product)}\n {...(!onProductImageClick && {\n href: product.custom_link || product.listingLink,\n })}\n className=\"cursor-pointer\"\n >\n <Picture\n source={product.custom_image || product.image}\n alt={product.name}\n className={cn('h-full', classNames?.productCardImage)}\n imgClassName=\"h-full object-contain\"\n />\n </a>\n </div>\n\n {/* \u6807\u7B7E\u533A\u57DF */}\n <div className=\"lg-desktop:h-[28px] absolute left-4 top-4 flex h-[24px]\">\n {product.tags?.map((tag: any, index) =>\n (tag as any).label ? (\n <Badge\n key={index}\n size=\"sm\"\n variant={(tag.variant as any) || 'outline'}\n className={cn('mr-1')}\n promotionalType={tag.promotionalType}\n >\n {tag.label}\n </Badge>\n ) : (\n <React.Fragment key={index}>{tag}</React.Fragment>\n )\n )}\n </div>\n </div>\n\n {/* \u5185\u5BB9\u533A\u57DF */}\n <CardContent className=\"desktop:p-6 bg-container-primary laptop:gap-6 flex h-[calc(100%-240px)] grow flex-col justify-between gap-4 p-4\">\n {/* \u4EA7\u54C1\u6807\u9898\u548C\u526F\u6807\u9898 */}\n <div className=\"flex-0\">\n <Heading\n as=\"h3\"\n size={2}\n className={cn('text-info-primary mb-1 line-clamp-2 tracking-tight', classNames?.productTitle)}\n >\n {product.custom_name || product.name}\n </Heading>\n {(product.custom_description || product?.description) && (\n <Text\n size={2}\n className={cn('text-info-primary line-clamp-1', classNames?.productDescription)}\n html={product.custom_description || product.description}\n />\n )}\n </div>\n\n {/* \u5E93\u5B58\u4FE1\u606F */}\n {shouldShowStock(\n stockDisplayMode,\n stockThresholdValue,\n product?.quantityAvailable ?? 0,\n product?.totalInventory ?? 0\n ) && (\n <div\n data-total={product?.totalInventory ?? 0}\n data-available={product?.quantityAvailable ?? 0}\n className=\"space-y-2\"\n >\n <Progress\n value={stockPercentage}\n max={100}\n min={0}\n size=\"base\"\n variant=\"default\"\n aria-label=\"stock progress\"\n classNames={{\n progressBar: 'transition-all duration-300 ease-in-out',\n }}\n />\n <Text size={3} className=\"text-info-tertiary desktop:text-[16px] lg-desktop:text-[18px] text-[12px]\">\n {overselling\n ? copy?.limitedStock\n : copy?.stockDisplayText?.replace(\n '{count}',\n `${product.availableForSale ? product.quantityAvailable : 0}`\n )}\n </Text>\n </div>\n )}\n\n <div>\n {/** \u4EF7\u683C\u6807\u7B7E */}\n {product?.priceLabel && product?.availableForSale && (\n <Text\n size={4}\n className={cn(\n 'text-marketing-1 desktop:text-[16px] lg-desktop:text-[18px] mt-2 text-[12px]',\n classNames?.productPriceLabel\n )}\n >\n {product.priceLabel}\n </Text>\n )}\n {/* \u4EF7\u683C\u533A\u57DF */}\n <div className={cn('mb-2', classNames?.productPrice)}>\n <div className=\"flex items-baseline gap-2\">\n {product.availableForSale ? (\n <>\n <Heading size={2} className=\"text-info-primary\" as=\"h6\">\n {product.price}\n </Heading>\n {showOriginalPrice && product.originalPrice && (\n <Heading size={2} className=\"text-info-tertiary line-through\" as=\"h6\">\n {product.originalPrice}\n </Heading>\n )}\n </>\n ) : (\n <Heading size={2} className=\"text-info-tertiary\">\n {copy?.outOfStockLabel ?? 'Sold Out'}\n </Heading>\n )}\n </div>\n </div>\n\n {/* \u6309\u94AE\u533A\u57DF */}\n <div className={cn('lg-desktop:gap-3 tablet:flex-nowrap flex flex-wrap gap-2', classNames?.buttonGroup)}>\n {secondaryButtonText && (\n <Button\n variant=\"secondary\"\n size=\"base\"\n className={cn('tablet:w-fit w-full', classNames?.secondaryButton)}\n onClick={() => handleButtonClick(secondaryButtonFun, 'secondary')}\n disabled={!product.availableForSale && secondaryButtonFun !== 'learnMore'}\n loading={secondaryLoading}\n >\n {secondaryButtonText}\n </Button>\n )}\n {primaryButtonText && (\n <Button\n variant=\"primary\"\n size=\"base\"\n className={cn('tablet:w-fit w-full', classNames?.primaryButton)}\n onClick={() => handleButtonClick(primaryButtonFun, 'primary')}\n disabled={!product.availableForSale && primaryButtonFun !== 'learnMore'}\n loading={primaryLoading}\n >\n {primaryButtonText}\n </Button>\n )}\n </div>\n </div>\n </CardContent>\n </Card>\n )\n }\n)\n\nProductCard.displayName = 'MediaShelf.ProductCard'\n\nexport default ProductCard\nexport { ProductCard }\n"],
5
+ "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAwLQ,IAAAK,EAAA,6BAtLRC,EAAuB,oBACvBC,EAAmB,kCACnBC,EAAmF,qCAenF,MAAMC,EAA+B,EAUrC,SAASC,EACPC,EACAC,EACAC,EACAC,EACS,CAET,GAAIH,IAAqB,OACvB,MAAO,GAIT,OAAQA,EAAkB,CACxB,IAAK,SAEH,MAAO,GAET,IAAK,QAEH,MAAO,GAET,IAAK,iBAEH,OAAIC,IAAwB,OACnB,GAGFC,GAAqBD,EAE9B,IAAK,mBAEH,OAAIA,IAAwB,OACnB,GAEDC,EAAoBC,EAAkB,KAAOF,EAEvD,QAEE,MAAO,EACX,CACF,CAyCA,MAAMV,EAAcI,EAAM,WACxB,CACE,CACE,QAAAS,EACA,UAAAC,EACA,iBAAAL,EACA,oBAAAC,EACA,YAAAK,EACA,UAAAC,EACA,YAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,KAAAC,EACA,oBAAAC,CACF,EACAC,IACG,CACH,KAAM,CAACC,EAAgBC,CAAiB,EAAIxB,EAAM,SAAS,EAAK,EAC1D,CAACyB,EAAkBC,CAAmB,EAAI1B,EAAM,SAAS,E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kC,GAAG,KAC9D,SAAAA,EAAQ,cACX,GAEJ,KAEA,OAAC,WAAQ,KAAM,EAAG,UAAU,qBACzB,SAAAW,GAAM,iBAAmB,WAC5B,EAEJ,EACF,KAGA,QAAC,OAAI,aAAW,MAAG,2DAA4DN,GAAY,WAAW,EACnG,UAAAC,MACC,OAAC,UACC,QAAQ,YACR,KAAK,OACL,aAAW,MAAG,sBAAuBD,GAAY,eAAe,EAChE,QAAS,IAAMc,EAAkBZ,EAAoB,WAAW,EAChE,SAAU,CAACP,EAAQ,kBAAoBO,IAAuB,YAC9D,QAASS,EAER,SAAAV,EACH,EAEDE,MACC,OAAC,UACC,QAAQ,UACR,KAAK,OACL,aAAW,MAAG,sBAAuBH,GAAY,aAAa,EAC9D,QAAS,IAAMc,EAAkBV,EAAkB,SAAS,EAC5D,SAAU,CAACT,EAAQ,kBAAoBS,IAAqB,YAC5D,QAASK,EAER,SAAAN,EACH,GAEJ,GACF,GACF,GACF,CAEJ,CACF,EAEArB,EAAY,YAAc,yBAE1B,IAAOC,EAAQD",
6
6
  "names": ["ProductCard_exports", "__export", "ProductCard", "ProductCard_default", "__toCommonJS", "import_jsx_runtime", "React", "import_helpers", "import_components", "OVERSELLING_STOCK_PERCENTAGE", "shouldShowStock", "stockDisplayMode", "stockThresholdValue", "quantityAvailable", "totalInventory", "product", "className", "onLearnMore", "onShopNow", "onAddToCart", "classNames", "secondaryButtonText", "secondaryButtonFun", "primaryButtonText", "primaryButtonFun", "showOriginalPrice", "copy", "onProductImageClick", "ref", "primaryLoading", "setPrimaryLoading", "secondaryLoading", "setSecondaryLoading", "stockPercentage", "handleButtonClick", "buttonFun", "buttonType", "setLoading", "overselling", "tag", "index"]
7
7
  }
@@ -0,0 +1,38 @@
1
+ import type { Img } from '../../types/props.js';
2
+ export interface CircleProgressProps {
3
+ /** 总阶段数 (1-4) */
4
+ totalSteps?: 1 | 2 | 3 | 4;
5
+ /** 当前完成的阶段 (0 到 totalSteps) */
6
+ currentStep?: number;
7
+ /** 中间显示的图片 */
8
+ image?: Img;
9
+ /** 底部显示的文案 */
10
+ label?: string;
11
+ /** 进度条颜色,默认为品牌色 */
12
+ progressColor?: string;
13
+ /** 底部文案背景色,默认为品牌营销色 */
14
+ labelColor?: string;
15
+ /** 未完成阶段的颜色 */
16
+ trackColor?: string;
17
+ /** 背景颜色,默认为容器背景色 */
18
+ backgroundColor?: string;
19
+ /** 移动端组件尺寸,默认 64 */
20
+ size?: number;
21
+ /** laptop 以上组件尺寸,默认 80 */
22
+ laptopSize?: number;
23
+ /** 段之间的间隙(像素),默认 3 */
24
+ gap?: number;
25
+ /** 自定义类名 */
26
+ className?: string;
27
+ }
28
+ /**
29
+ * 分段式圆形进度条组件
30
+ * 用于 MiniCart 左侧显示阶段性进度,支持 1-4 个阶段配置
31
+ * 每个阶段是独立的弧段,中间有间隙
32
+ * 移动端默认 64px,laptop 以上默认 80px
33
+ */
34
+ declare const CircleProgress: {
35
+ ({ totalSteps, currentStep, image, label, progressColor, labelColor, trackColor, backgroundColor, size, laptopSize, gap, className, }: CircleProgressProps): import("react/jsx-runtime").JSX.Element;
36
+ displayName: string;
37
+ };
38
+ export default CircleProgress;
@@ -0,0 +1,2 @@
1
+ "use strict";"use client";var Y=Object.create;var x=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var q=(e,t)=>{for(var s in t)x(e,s,{get:t[s],enumerable:!0})},P=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of F(t))!T.call(e,a)&&a!==s&&x(e,a,{get:()=>t[a],enumerable:!(o=B(t,a))||o.enumerable});return e};var H=(e,t,s)=>(s=e!=null?Y(L(e)):{},P(t||!e||!e.__esModule?x(s,"default",{value:e,enumerable:!0}):s,e)),J=e=>P(x({},"__esModule",{value:!0}),e);var U={};q(U,{default:()=>Q});module.exports=J(U);var r=require("react/jsx-runtime"),K=H(require("react")),y=require("../../components/index.js"),v=require("../../helpers/index.js");const M=({totalSteps:e=4,currentStep:t=0,image:s,label:o,progressColor:a="var(--brand-color-0)",labelColor:z="var(--marketing-color-1)",trackColor:j="#DADCE0",backgroundColor:A="#EAEAEC",size:m=64,laptopSize:u=96,gap:$=3,className:w})=>{const d=Math.max(m,u),C=6,l=(d-C)/2,c=d/2,E=K.useMemo(()=>{const b=($+C)/l*(180/Math.PI),G=(360-b*e)/e,f=n=>n*Math.PI/180,I=(n,i)=>{const p=n-90,h=i-90,R=c+l*Math.cos(f(p)),D=c+l*Math.sin(f(p)),O=c+l*Math.cos(f(h)),W=c+l*Math.sin(f(h)),X=i-n>180?1:0;return`M ${R} ${D} A ${l} ${l} 0 ${X} 1 ${O} ${W}`},k=[];let N=e===2?-45:0;for(let n=0;n<e;n++){const i=N+b/2,p=i+G,h=n<t;k.push({path:I(i,p),isCompleted:h,index:n}),N=p+b/2}return k},[e,t,$,l,c]);return(0,r.jsxs)("div",{className:(0,v.cn)("relative inline-flex shrink-0 flex-col items-center","laptop:w-[--circle-laptop-size] w-[--circle-size]","laptop:h-[--circle-laptop-height] h-[--circle-height]",w),style:{"--circle-size":`${m}px`,"--circle-laptop-size":`${u}px`,"--circle-height":`${o?m+8:m}px`,"--circle-laptop-height":`${o?u+8:u}px`},children:[(0,r.jsxs)("div",{className:"laptop:size-[--circle-laptop-size] relative size-[--circle-size]",children:[(0,r.jsxs)("svg",{viewBox:`0 0 ${d} ${d}`,className:(0,v.cn)("absolute inset-0 size-full",o?"translate-y-[-8px]":""),children:[(0,r.jsx)("circle",{cx:c,cy:c,r:l,fill:A,stroke:"none"}),E.map(g=>(0,r.jsx)("path",{d:g.path,fill:"none",stroke:g.isCompleted?a:j,strokeWidth:C,strokeLinecap:"round",style:{transition:"stroke 0.3s ease-in-out"}},g.index))]}),(0,r.jsx)("div",{className:(0,v.cn)("absolute inset-[10px] flex items-center justify-center",o?"translate-y-[-8px]":""),children:(0,r.jsx)("div",{className:"flex size-full items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:A},children:s?.url&&(0,r.jsx)(y.Picture,{className:"size-full",imgClassName:"object-contain",source:s.url,alt:s.alt||""})})})]}),o&&(0,r.jsx)("div",{className:"absolute bottom-0 left-1/2 flex -translate-x-1/2 items-center justify-center rounded-full px-2 py-0.5",style:{backgroundColor:z},children:(0,r.jsx)(y.Text,{className:"text-xs font-medium text-white",html:o})})]})};M.displayName="CircleProgress";var Q=M;
2
+ //# sourceMappingURL=CircleProgress.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/biz-components/MiniCart/CircleProgress.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport type { Img } from '../../types/props.js'\nimport { Picture, Text } from '../../components/index.js'\nimport { cn } from '../../helpers/index.js'\n\nexport interface CircleProgressProps {\n /** \u603B\u9636\u6BB5\u6570 (1-4) */\n totalSteps?: 1 | 2 | 3 | 4\n /** \u5F53\u524D\u5B8C\u6210\u7684\u9636\u6BB5 (0 \u5230 totalSteps) */\n currentStep?: number\n /** \u4E2D\u95F4\u663E\u793A\u7684\u56FE\u7247 */\n image?: Img\n /** \u5E95\u90E8\u663E\u793A\u7684\u6587\u6848 */\n label?: string\n /** \u8FDB\u5EA6\u6761\u989C\u8272\uFF0C\u9ED8\u8BA4\u4E3A\u54C1\u724C\u8272 */\n progressColor?: string\n /** \u5E95\u90E8\u6587\u6848\u80CC\u666F\u8272\uFF0C\u9ED8\u8BA4\u4E3A\u54C1\u724C\u8425\u9500\u8272 */\n labelColor?: string\n /** \u672A\u5B8C\u6210\u9636\u6BB5\u7684\u989C\u8272 */\n trackColor?: string\n /** \u80CC\u666F\u989C\u8272\uFF0C\u9ED8\u8BA4\u4E3A\u5BB9\u5668\u80CC\u666F\u8272 */\n backgroundColor?: string\n /** \u79FB\u52A8\u7AEF\u7EC4\u4EF6\u5C3A\u5BF8\uFF0C\u9ED8\u8BA4 64 */\n size?: number\n /** laptop \u4EE5\u4E0A\u7EC4\u4EF6\u5C3A\u5BF8\uFF0C\u9ED8\u8BA4 80 */\n laptopSize?: number\n /** \u6BB5\u4E4B\u95F4\u7684\u95F4\u9699\uFF08\u50CF\u7D20\uFF09\uFF0C\u9ED8\u8BA4 3 */\n gap?: number\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\n/**\n * \u5206\u6BB5\u5F0F\u5706\u5F62\u8FDB\u5EA6\u6761\u7EC4\u4EF6\n * \u7528\u4E8E MiniCart \u5DE6\u4FA7\u663E\u793A\u9636\u6BB5\u6027\u8FDB\u5EA6\uFF0C\u652F\u6301 1-4 \u4E2A\u9636\u6BB5\u914D\u7F6E\n * \u6BCF\u4E2A\u9636\u6BB5\u662F\u72EC\u7ACB\u7684\u5F27\u6BB5\uFF0C\u4E2D\u95F4\u6709\u95F4\u9699\n * \u79FB\u52A8\u7AEF\u9ED8\u8BA4 64px\uFF0Claptop \u4EE5\u4E0A\u9ED8\u8BA4 80px\n */\nconst CircleProgress = ({\n totalSteps = 4,\n currentStep = 0,\n image,\n label,\n progressColor = 'var(--brand-color-0)',\n labelColor = 'var(--marketing-color-1)',\n trackColor = '#DADCE0',\n backgroundColor = '#EAEAEC',\n size = 64,\n laptopSize = 96,\n gap = 3,\n className,\n}: CircleProgressProps) => {\n // \u4F7F\u7528\u8F83\u5927\u5C3A\u5BF8\u8BA1\u7B97 SVG \u53C2\u6570\uFF0C\u786E\u4FDD\u5728\u6240\u6709\u5C3A\u5BF8\u4E0B\u90FD\u6E05\u6670\n const maxSize = Math.max(size, laptopSize) // \u5982\u679C\u6709\u6807\u7B7E\uFF0C\u9884\u7559\u5E95\u90E8\u7A7A\u95F4\n const strokeWidth = 6\n const radius = (maxSize - strokeWidth) / 2\n const center = maxSize / 2\n\n // \u751F\u6210\u6240\u6709\u5206\u6BB5\n const segments = React.useMemo(() => {\n // \u89C6\u89C9\u95F4\u9699\u9700\u8981\u52A0\u4E0A\u4E24\u7AEF\u5706\u89D2\u5E3D\u5B50\u7684\u5BBD\u5EA6\uFF08strokeLinecap=\"round\" \u4F1A\u5EF6\u4F38 strokeWidth/2\uFF09\n const actualGap = gap + strokeWidth\n // \u5C06\u50CF\u7D20\u95F4\u9699\u8F6C\u6362\u4E3A\u89D2\u5EA6\uFF08\u5F27\u5EA6 = \u5F27\u957F / \u534A\u5F84\uFF0C\u518D\u8F6C\u4E3A\u5EA6\uFF09\n const gapAngle = (actualGap / radius) * (180 / Math.PI)\n const totalGapAngle = gapAngle * totalSteps\n const availableAngle = 360 - totalGapAngle\n const segmentAngle = availableAngle / totalSteps\n\n // \u5C06\u89D2\u5EA6\u8F6C\u6362\u4E3A\u5F27\u5EA6\n const toRadians = (degrees: number) => (degrees * Math.PI) / 180\n\n // \u8BA1\u7B97\u5F27\u6BB5\u7684\u8D77\u70B9\u548C\u7EC8\u70B9\u5750\u6807\n const getArcPath = (startAngle: number, endAngle: number) => {\n // \u4ECE\u9876\u90E8\u5F00\u59CB\uFF08-90\u5EA6\uFF09\uFF0C\u987A\u65F6\u9488\u65B9\u5411\n const adjustedStart = startAngle - 90\n const adjustedEnd = endAngle - 90\n\n const startX = center + radius * Math.cos(toRadians(adjustedStart))\n const startY = center + radius * Math.sin(toRadians(adjustedStart))\n const endX = center + radius * Math.cos(toRadians(adjustedEnd))\n const endY = center + radius * Math.sin(toRadians(adjustedEnd))\n\n // \u5224\u65AD\u662F\u5426\u4E3A\u5927\u5F27\uFF08\u8D85\u8FC7180\u5EA6\uFF09\n const largeArcFlag = endAngle - startAngle > 180 ? 1 : 0\n\n return `M ${startX} ${startY} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${endX} ${endY}`\n }\n\n const result = []\n // totalSteps = 2 \u65F6\uFF0C\u8D77\u59CB\u4F4D\u7F6E\u9006\u65F6\u9488\u504F\u79FB 45 \u5EA6\uFF0C\u8BA9\u65AD\u5F00\u4F4D\u7F6E\u5728\u5DE6\u4E0A\u548C\u53F3\u4E0B\n const startOffset = totalSteps === 2 ? -45 : 0\n let currentAngle = startOffset\n\n for (let i = 0; i < totalSteps; i++) {\n const startAngle = currentAngle + gapAngle / 2\n const endAngle = startAngle + segmentAngle\n const isCompleted = i < currentStep\n\n result.push({\n path: getArcPath(startAngle, endAngle),\n isCompleted,\n index: i,\n })\n\n currentAngle = endAngle + gapAngle / 2\n }\n\n return result\n }, [totalSteps, currentStep, gap, radius, center])\n\n return (\n <div\n className={cn(\n 'relative inline-flex shrink-0 flex-col items-center',\n 'laptop:w-[--circle-laptop-size] w-[--circle-size]',\n 'laptop:h-[--circle-laptop-height] h-[--circle-height]',\n className\n )}\n style={\n {\n '--circle-size': `${size}px`,\n '--circle-laptop-size': `${laptopSize}px`,\n '--circle-height': `${label ? size + 8 : size}px`,\n '--circle-laptop-height': `${label ? laptopSize + 8 : laptopSize}px`,\n } as React.CSSProperties\n }\n >\n {/* \u8FDB\u5EA6\u6761\u5706\u73AF */}\n <div className=\"laptop:size-[--circle-laptop-size] relative size-[--circle-size]\">\n <svg\n viewBox={`0 0 ${maxSize} ${maxSize}`}\n className={cn('absolute inset-0 size-full', label ? 'translate-y-[-8px]' : '')}\n >\n {/* \u80CC\u666F\u5706\u5F62 */}\n <circle cx={center} cy={center} r={radius} fill={backgroundColor} stroke=\"none\" />\n\n {/* \u5206\u6BB5\u5F27 */}\n {segments.map(segment => (\n <path\n key={segment.index}\n d={segment.path}\n fill=\"none\"\n stroke={segment.isCompleted ? progressColor : trackColor}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n style={{\n transition: 'stroke 0.3s ease-in-out',\n }}\n />\n ))}\n </svg>\n\n {/* \u4E2D\u95F4\u5185\u5BB9\u533A\u57DF */}\n <div\n className={cn('absolute inset-[10px] flex items-center justify-center', label ? 'translate-y-[-8px]' : '')}\n >\n <div\n className=\"flex size-full items-center justify-center overflow-hidden rounded-full\"\n style={{ backgroundColor }}\n >\n {image?.url && (\n <Picture className=\"size-full\" imgClassName=\"object-contain\" source={image.url} alt={image.alt || ''} />\n )}\n </div>\n </div>\n </div>\n\n {/* \u5E95\u90E8\u6587\u6848 - \u548C\u5706\u5F62\u5E95\u90E8\u91CD\u53E0 */}\n {label && (\n <div\n className=\"absolute bottom-0 left-1/2 flex -translate-x-1/2 items-center justify-center rounded-full px-2 py-0.5\"\n style={{ backgroundColor: labelColor }}\n >\n <Text className=\"text-xs font-medium text-white\" html={label} />\n </div>\n )}\n </div>\n )\n}\n\nCircleProgress.displayName = 'CircleProgress'\n\nexport default CircleProgress\n"],
5
+ "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAmIQ,IAAAI,EAAA,6BAjIRC,EAAuB,oBAEvBC,EAA8B,qCAC9BC,EAAmB,kCAmCnB,MAAMC,EAAiB,CAAC,CACtB,WAAAC,EAAa,EACb,YAAAC,EAAc,EACd,MAAAC,EACA,MAAAC,EACA,cAAAC,EAAgB,uBAChB,WAAAC,EAAa,2BACb,WAAAC,EAAa,UACb,gBAAAC,EAAkB,UAClB,KAAAC,EAAO,GACP,WAAAC,EAAa,GACb,IAAAC,EAAM,EACN,UAAAC,CACF,IAA2B,CAEzB,MAAMC,EAAU,KAAK,IAAIJ,EAAMC,CAAU,EACnCI,EAAc,EACdC,GAAUF,EAAUC,GAAe,EACnCE,EAASH,EAAU,EAGnBI,EAAWpB,EAAM,QAAQ,IAAM,CAInC,MAAMqB,GAFYP,EAAMG,GAEMC,GAAW,IAAM,KAAK,IAG9CI,GADiB,IADDD,EAAWjB,GAEKA,EAGhCmB,EAAaC,GAAqBA,EAAU,KAAK,GAAM,IAGvDC,EAAa,CAACC,EAAoBC,IAAqB,CAE3D,MAAMC,EAAgBF,EAAa,GAC7BG,EAAcF,EAAW,GAEzBG,EAASX,EAASD,EAAS,KAAK,IAAIK,EAAUK,CAAa,CAAC,EAC5DG,EAASZ,EAASD,EAAS,KAAK,IAAIK,EAAUK,CAAa,CAAC,EAC5DI,EAAOb,EAASD,EAAS,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B,EAAQ,KASf,CACD,GACH,KAGA,OAAC,OACC,aAAW,MAAG,yDAA0DhC,EAAQ,qBAAuB,EAAE,EAEzG,mBAAC,OACC,UAAU,0EACV,MAAO,CAAE,gBAAAI,CAAgB,EAExB,SAAAL,GAAO,QACN,OAAC,WAAQ,UAAU,YAAY,aAAa,iBAAiB,OAAQA,EAAM,IAAK,IAAKA,EAAM,KAAO,GAAI,EAE1G,EACF,GACF,EAGCC,MACC,OAAC,OACC,UAAU,wGACV,MAAO,CAAE,gBAAiBE,CAAW,EAErC,mBAAC,QAAK,UAAU,iCAAiC,KAAMF,EAAO,EAChE,GAEJ,CAEJ,EAEAJ,EAAe,YAAc,iBAE7B,IAAON,EAAQM",
6
+ "names": ["CircleProgress_exports", "__export", "CircleProgress_default", "__toCommonJS", "import_jsx_runtime", "React", "import_components", "import_helpers", "CircleProgress", "totalSteps", "currentStep", "image", "label", "progressColor", "labelColor", "trackColor", "backgroundColor", "size", "laptopSize", "gap", "className", "maxSize", "strokeWidth", "radius", "center", "segments", "gapAngle", "segmentAngle", "toRadians", "degrees", "getArcPath", "startAngle", "endAngle", "adjustedStart", "adjustedEnd", "startX", "startY", "endX", "endY", "largeArcFlag", "result", "currentAngle", "i", "isCompleted", "segment"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var h=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(a,e)=>{for(var l in e)h(a,l,{get:e[l],enumerable:!0})},z=(a,e,l,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!I.call(a,o)&&o!==l&&h(a,o,{get:()=>e[o],enumerable:!(p=w(e,o))||p.enumerable});return a};var P=a=>z(h({},"__esModule",{value:!0}),a);var L={};N(L,{MiniCartDialog:()=>f,default:()=>M});module.exports=P(L);var t=require("react/jsx-runtime"),i=require("../../helpers/index.js"),n=require("../../components/index.js");const T=({className:a})=>(0,t.jsx)("svg",{className:a,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M2 6H10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),k=({className:a})=>(0,t.jsx)("svg",{className:a,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M6 2V10M2 6H10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),q=({item:a,classNames:e,onIncrease:l,onDecrease:p})=>{const{merchandise:o,quantity:u,cost:y}=a,{image:c,title:b}=o,{totalAmount:d,subtotalAmount:m}=y,x=b||o.sku||"Product",g=d?.formattedPrice||"",v=m&&d&&parseFloat(m.amount)>parseFloat(d.amount);return(0,t.jsxs)("div",{className:(0,i.cn)("bg-container-primary rounded-box flex items-center gap-2 px-2 py-4","laptop:bg-container-primary laptop:gap-4 laptop:p-4",e?.item),children:[(0,t.jsx)("div",{className:(0,i.cn)("rounded-box relative size-16 shrink-0 overflow-hidden","laptop:size-20",e?.itemImage),children:c?.url&&(0,t.jsx)("img",{src:c.url,alt:c.altText||x,className:"size-full object-cover"})}),(0,t.jsxs)("div",{className:(0,i.cn)("laptop:gap-4 flex flex-1 flex-col gap-2",e?.itemInfo),children:[(0,t.jsx)(n.Text,{as:"p",size:3,className:(0,i.cn)("text-info-primary laptop:text-[16px] line-clamp-2 text-[14px]",e?.itemTitle),children:x}),(0,t.jsxs)("div",{className:"laptop:flex-row laptop:items-center laptop:justify-between flex flex-col items-start gap-1",children:[(0,t.jsxs)("div",{className:(0,i.cn)("flex items-center gap-1",e?.itemPrice),children:[g&&(0,t.jsx)(n.Text,{size:4,className:(0,i.cn)("text-info-primary laptop:text-[18px] text-[16px]",e?.itemCurrentPrice),children:g}),v&&m?.formattedPrice&&(0,t.jsx)(n.Text,{size:4,className:(0,i.cn)("text-info-tertiary laptop:text-[18px] text-[16px] line-through",e?.itemOriginalPrice),children:m.formattedPrice})]}),(0,t.jsxs)("div",{className:(0,i.cn)("flex items-center",e?.quantityControl),children:[(0,t.jsx)("button",{type:"button",onClick:p,disabled:u<=0,className:(0,i.cn)("border-lines flex size-8 items-center justify-center border","laptop:size-10","text-info-primary hover:bg-container-secondary-0 transition-colors","disabled:cursor-not-allowed disabled:opacity-50",e?.quantityButton),"aria-label":"Decrease quantity",children:(0,t.jsx)(T,{className:"laptop:size-3 size-[10.67px]"})}),(0,t.jsx)("div",{className:(0,i.cn)("border-lines text-info-primary flex size-8 items-center justify-center border-y text-center text-sm font-semibold","laptop:size-10 laptop:text-base",e?.quantityValue),children:u}),(0,t.jsx)("button",{type:"button",onClick:l,className:(0,i.cn)("border-lines flex size-8 items-center justify-center border","laptop:size-10","text-info-primary hover:bg-container-secondary-0 transition-colors",e?.quantityButton),"aria-label":"Increase quantity",children:(0,t.jsx)(k,{className:"laptop:size-3 size-[10.67px]"})})]})]})]})]})},f=({open:a,onOpenChange:e,cart:l,copy:p,classNames:o={},onIncreaseQuantity:u,onDecreaseQuantity:y,onQuantityChange:c})=>{const b=p?.title||"Selected ({count})",d=p?.emptyText||"Your cart is empty",m=l?.lineItems?.reduce((r,s)=>r+(s?.quantity||0),0)||0,x=l?.lineItems||[],g=x.length===0,v=(r,s)=>{u?.(r,s),c?.(r,s+1)},C=(r,s)=>{s>1&&(y?.(r,s),c?.(r,s-1))};return(0,t.jsx)(n.Dialog,{open:a,onOpenChange:e,children:(0,t.jsxs)(n.DialogContent,{className:(0,i.cn)("bg-container-secondary-0 fixed left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col gap-0 overflow-hidden p-0","rounded-box max-h-[80vh] w-[calc(100%-64px)] min-w-[326px]","laptop:w-full laptop:max-w-[560px] laptop:rounded-box",o?.root),children:[(0,t.jsx)(n.DialogHeader,{className:(0,i.cn)("bg-container-secondary-0 flex flex-row items-start justify-between gap-4 px-4 pb-2 pt-4",o?.header),children:(0,t.jsx)(n.DialogTitle,{asChild:!0,children:(0,t.jsx)(n.Heading,{as:"h3",size:2,className:(0,i.cn)("text-info-primary font-bold",o?.title),children:b.replace("{count}",m.toString())})})}),(0,t.jsx)("div",{className:(0,i.cn)("bg-container-secondary-0 h- flex flex-col gap-2 overflow-y-auto px-4 py-2",o?.content),children:g?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(n.Text,{size:2,className:"text-info-tertiary",children:d})}):(0,t.jsx)("div",{className:(0,i.cn)("flex flex-col gap-2",o?.itemList),children:x.map(r=>(0,t.jsx)(q,{item:r,classNames:o,onIncrease:()=>v(r.id,r.quantity),onDecrease:()=>C(r.id,r.quantity)},r.id))})}),(0,t.jsx)("div",{className:"bg-container-secondary-0 h-8 w-full"})]})})};f.displayName="MiniCartDialog";var M=f;
1
+ "use strict";"use client";var h=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(a,e)=>{for(var l in e)h(a,l,{get:e[l],enumerable:!0})},z=(a,e,l,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!I.call(a,o)&&o!==l&&h(a,o,{get:()=>e[o],enumerable:!(p=w(e,o))||p.enumerable});return a};var P=a=>z(h({},"__esModule",{value:!0}),a);var L={};N(L,{MiniCartDialog:()=>f,default:()=>M});module.exports=P(L);var t=require("react/jsx-runtime"),i=require("../../helpers/index.js"),n=require("../../components/index.js");const T=({className:a})=>(0,t.jsx)("svg",{className:a,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M2 6H10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),k=({className:a})=>(0,t.jsx)("svg",{className:a,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M6 2V10M2 6H10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),q=({item:a,classNames:e,onIncrease:l,onDecrease:p})=>{const{merchandise:o,quantity:u,cost:y}=a,{image:c,title:b}=o,{totalAmount:d,subtotalAmount:m}=y,x=b||o.sku||"Product",g=d?.formattedPrice||"",v=m&&d&&parseFloat(m.amount)>parseFloat(d.amount);return(0,t.jsxs)("div",{className:(0,i.cn)("bg-container-primary rounded-box flex items-center gap-2 px-2 py-4","laptop:bg-container-primary laptop:gap-4 laptop:p-4",e?.item),children:[(0,t.jsx)("div",{className:(0,i.cn)("rounded-box relative size-16 shrink-0 overflow-hidden","laptop:size-20",e?.itemImage),children:c?.url&&(0,t.jsx)("img",{src:c.url,alt:c.altText||x,className:"size-full object-cover"})}),(0,t.jsxs)("div",{className:(0,i.cn)("laptop:gap-4 flex flex-1 flex-col gap-2",e?.itemInfo),children:[(0,t.jsx)(n.Text,{as:"p",size:3,className:(0,i.cn)("text-info-primary laptop:text-[16px] line-clamp-2 text-[14px]",e?.itemTitle),children:x}),(0,t.jsxs)("div",{className:"laptop:flex-row laptop:items-center laptop:justify-between flex flex-col items-start gap-1",children:[(0,t.jsxs)("div",{className:(0,i.cn)("flex items-center gap-1",e?.itemPrice),children:[g&&(0,t.jsx)(n.Text,{size:4,className:(0,i.cn)("text-info-primary laptop:text-[18px] text-[16px]",e?.itemCurrentPrice),children:g}),v&&m?.formattedPrice&&(0,t.jsx)(n.Text,{size:4,className:(0,i.cn)("text-info-tertiary laptop:text-[18px] text-[16px] line-through",e?.itemOriginalPrice),children:m.formattedPrice})]}),(0,t.jsxs)("div",{className:(0,i.cn)("flex items-center",e?.quantityControl),children:[(0,t.jsx)("button",{type:"button",onClick:p,disabled:u<=0,className:(0,i.cn)("border-lines flex size-8 items-center justify-center border","laptop:size-10","text-info-primary hover:bg-container-secondary-0 transition-colors","disabled:cursor-not-allowed disabled:opacity-50",e?.quantityButton),"aria-label":"Decrease quantity",children:(0,t.jsx)(T,{className:"laptop:size-3 size-[10.67px]"})}),(0,t.jsx)("div",{className:(0,i.cn)("border-lines text-info-primary flex size-8 items-center justify-center border-y text-center text-sm font-semibold","laptop:size-10 laptop:text-base",e?.quantityValue),children:u}),(0,t.jsx)("button",{type:"button",onClick:l,className:(0,i.cn)("border-lines flex size-8 items-center justify-center border","laptop:size-10","text-info-primary hover:bg-container-secondary-0 transition-colors",e?.quantityButton),"aria-label":"Increase quantity",children:(0,t.jsx)(k,{className:"laptop:size-3 size-[10.67px]"})})]})]})]})]})},f=({open:a,onOpenChange:e,cart:l,copy:p,classNames:o={},onIncreaseQuantity:u,onDecreaseQuantity:y,onQuantityChange:c})=>{const b=p?.title||"Selected ({count})",d=p?.emptyText||"Your cart is empty",m=l?.lineItems?.reduce((r,s)=>r+(s?.quantity||0),0)||0,x=l?.lineItems||[],g=x.length===0,v=(r,s)=>{u?.(r,s),c?.(r,s+1)},C=(r,s)=>{s>0&&(y?.(r,s),c?.(r,s-1))};return(0,t.jsx)(n.Dialog,{open:a,onOpenChange:e,children:(0,t.jsxs)(n.DialogContent,{className:(0,i.cn)("bg-container-secondary-0 fixed left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col gap-0 overflow-hidden p-0","rounded-box max-h-[80vh] w-[calc(100%-64px)] min-w-[326px]","laptop:w-full laptop:max-w-[560px] laptop:rounded-box",o?.root),children:[(0,t.jsx)(n.DialogHeader,{className:(0,i.cn)("bg-container-secondary-0 flex flex-row items-start justify-between gap-4 px-4 pb-2 pt-4",o?.header),children:(0,t.jsx)(n.DialogTitle,{asChild:!0,children:(0,t.jsx)(n.Heading,{as:"h3",size:2,className:(0,i.cn)("text-info-primary font-bold",o?.title),children:b.replace("{count}",m.toString())})})}),(0,t.jsx)("div",{className:(0,i.cn)("bg-container-secondary-0 h- flex flex-col gap-2 overflow-y-auto px-4 py-2",o?.content),children:g?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(n.Text,{size:2,className:"text-info-tertiary",children:d})}):(0,t.jsx)("div",{className:(0,i.cn)("flex flex-col gap-2",o?.itemList),children:x.map(r=>(0,t.jsx)(q,{item:r,classNames:o,onIncrease:()=>v(r.id,r.quantity),onDecrease:()=>C(r.id,r.quantity)},r.id))})}),(0,t.jsx)("div",{className:"bg-container-secondary-0 h-8 w-full"})]})})};f.displayName="MiniCartDialog";var M=f;
2
2
  //# sourceMappingURL=MiniCartDialog.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/MiniCart/MiniCartDialog.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport { cn } from '../../helpers/index.js'\nimport { Heading, Text, Dialog, DialogContent, DialogHeader, DialogTitle } from '../../components/index.js'\nimport type { CartLineItem, Cart } from './index.js'\n\n/**\n * \u8D2D\u7269\u8F66\u6570\u636E\u7C7B\u578B - \u590D\u7528 MiniCart \u7684\u7C7B\u578B\u5B9A\u4E49\n */\nexport interface CartData {\n id: string\n checkoutUrl: string\n lineItems: CartLineItem[]\n}\n\n// \u91CD\u65B0\u5BFC\u51FA\u7C7B\u578B\u4F9B\u5916\u90E8\u4F7F\u7528\nexport type { CartLineItem, Cart }\n\n/**\n * \u6587\u6848\u914D\u7F6E\n */\nexport interface MiniCartDialogCopy {\n /** \u6807\u9898\u6587\u6848\uFF0C{count} \u4F1A\u88AB\u66FF\u6362\u4E3A\u5546\u54C1\u6570\u91CF */\n title?: string\n /** \u7A7A\u8D2D\u7269\u8F66\u63D0\u793A */\n emptyText?: string\n}\n\nexport type MiniCartDialogSemanticName =\n | 'root'\n | 'header'\n | 'title'\n | 'content'\n | 'itemList'\n | 'item'\n | 'itemImage'\n | 'itemInfo'\n | 'itemTitle'\n | 'itemPrice'\n | 'itemCurrentPrice'\n | 'itemOriginalPrice'\n | 'quantityControl'\n | 'quantityButton'\n | 'quantityValue'\n\nexport interface MiniCartDialogProps {\n /** \u662F\u5426\u6253\u5F00\u5F39\u7A97 */\n open: boolean\n /** \u5173\u95ED\u5F39\u7A97\u56DE\u8C03 */\n onOpenChange: (open: boolean) => void\n /** \u8D2D\u7269\u8F66\u6570\u636E */\n cart: CartData\n /** \u6587\u6848\u914D\u7F6E */\n copy?: MiniCartDialogCopy\n /** \u5404\u90E8\u5206\u7684\u81EA\u5B9A\u4E49\u6837\u5F0F\u7C7B\u540D */\n classNames?: Partial<Record<MiniCartDialogSemanticName, string>>\n /**\n * \u589E\u52A0\u5546\u54C1\u6570\u91CF\u56DE\u8C03\n * @param lineItemId \u5546\u54C1\u884CID\n * @param currentQuantity \u5F53\u524D\u6570\u91CF\n */\n onIncreaseQuantity?: (lineItemId: string, currentQuantity: number) => void\n /**\n * \u51CF\u5C11\u5546\u54C1\u6570\u91CF\u56DE\u8C03\n * @param lineItemId \u5546\u54C1\u884CID\n * @param currentQuantity \u5F53\u524D\u6570\u91CF\n */\n onDecreaseQuantity?: (lineItemId: string, currentQuantity: number) => void\n /**\n * \u6570\u91CF\u53D8\u66F4\u56DE\u8C03\n * @param lineItemId \u5546\u54C1\u884CID\n * @param quantity \u65B0\u6570\u91CF\n */\n onQuantityChange?: (lineItemId: string, quantity: number) => void\n}\n\n/**\n * MinusIcon - \u51CF\u53F7\u56FE\u6807\n */\nconst MinusIcon = ({ className }: { className?: string }) => (\n <svg className={className} width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2 6H10\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n)\n\n/**\n * PlusIcon - \u52A0\u53F7\u56FE\u6807\n */\nconst PlusIcon = ({ className }: { className?: string }) => (\n <svg className={className} width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M6 2V10M2 6H10\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n)\n\n/**\n * CartItem - \u8D2D\u7269\u8F66\u5546\u54C1\u9879\u7EC4\u4EF6\n */\ninterface CartItemProps {\n item: CartLineItem\n classNames?: Partial<Record<MiniCartDialogSemanticName, string>>\n onIncrease?: () => void\n onDecrease?: () => void\n}\n\nconst CartItem = ({ item, classNames, onIncrease, onDecrease }: CartItemProps) => {\n const { merchandise, quantity, cost } = item\n const { image, title } = merchandise\n const { totalAmount, subtotalAmount } = cost\n\n // \u663E\u793A\u6807\u9898\uFF08\u56DE\u9000\u5230 SKU\uFF09\n const displayTitle = title || merchandise.sku || 'Product'\n // \u663E\u793A\u4EF7\u683C\uFF08\u73B0\u4EF7 = totalAmount\uFF09\n const displayPrice = totalAmount?.formattedPrice || ''\n // \u662F\u5426\u6709\u6298\u6263\uFF08\u539F\u4EF7 subtotalAmount \u5927\u4E8E\u73B0\u4EF7 totalAmount\uFF09\n const hasDiscount =\n subtotalAmount && totalAmount && parseFloat(subtotalAmount.amount) > parseFloat(totalAmount.amount)\n\n return (\n <div\n className={cn(\n // \u79FB\u52A8\u7AEF\uFF1A\u7070\u8272\u80CC\u666F\uFF0C\u8F83\u5C0F\u95F4\u8DDD\n 'bg-container-primary rounded-box flex items-center gap-2 px-2 py-4',\n // \u684C\u9762\u7AEF\uFF1A\u767D\u8272\u80CC\u666F\uFF0C\u8F83\u5927\u95F4\u8DDD\n 'laptop:bg-container-primary laptop:gap-4 laptop:p-4',\n classNames?.item\n )}\n >\n {/* \u5546\u54C1\u56FE\u7247 - \u79FB\u52A8\u7AEF 64px\uFF0C\u684C\u9762\u7AEF 80px */}\n <div\n className={cn('rounded-box relative size-16 shrink-0 overflow-hidden', 'laptop:size-20', classNames?.itemImage)}\n >\n {image?.url && <img src={image.url} alt={image.altText || displayTitle} className=\"size-full object-cover\" />}\n </div>\n\n {/* \u5546\u54C1\u4FE1\u606F */}\n <div className={cn('laptop:gap-4 flex flex-1 flex-col gap-2', classNames?.itemInfo)}>\n {/* \u5546\u54C1\u540D\u79F0 - \u79FB\u52A8\u7AEF\u8F83\u5C0F\u5B57\u4F53 */}\n <Text\n as=\"p\"\n size={3}\n className={cn('text-info-primary laptop:text-[16px] line-clamp-2 text-[14px]', classNames?.itemTitle)}\n >\n {displayTitle}\n </Text>\n\n {/* \u4EF7\u683C\u548C\u6570\u91CF\u63A7\u5236 - \u79FB\u52A8\u7AEF\u5782\u76F4\u6392\u5217\uFF0C\u684C\u9762\u7AEF\u6C34\u5E73\u6392\u5217 */}\n <div className=\"laptop:flex-row laptop:items-center laptop:justify-between flex flex-col items-start gap-1\">\n {/* \u4EF7\u683C\u533A\u57DF */}\n <div className={cn('flex items-center gap-1', classNames?.itemPrice)}>\n {displayPrice && (\n <Text\n size={4}\n className={cn('text-info-primary laptop:text-[18px] text-[16px]', classNames?.itemCurrentPrice)}\n >\n {displayPrice}\n </Text>\n )}\n {hasDiscount && subtotalAmount?.formattedPrice && (\n <Text\n size={4}\n className={cn(\n 'text-info-tertiary laptop:text-[18px] text-[16px] line-through',\n classNames?.itemOriginalPrice\n )}\n >\n {subtotalAmount.formattedPrice}\n </Text>\n )}\n </div>\n\n {/* \u6570\u91CF\u63A7\u5236 - \u79FB\u52A8\u7AEF 32px \u6309\u94AE\uFF0C\u684C\u9762\u7AEF 40px \u6309\u94AE */}\n <div className={cn('flex items-center', classNames?.quantityControl)}>\n {/* \u51CF\u5C11\u6309\u94AE */}\n <button\n type=\"button\"\n onClick={onDecrease}\n disabled={quantity <= 0}\n className={cn(\n 'border-lines flex size-8 items-center justify-center border',\n 'laptop:size-10',\n 'text-info-primary hover:bg-container-secondary-0 transition-colors',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n classNames?.quantityButton\n )}\n aria-label=\"Decrease quantity\"\n >\n <MinusIcon className=\"laptop:size-3 size-[10.67px]\" />\n </button>\n\n {/* \u6570\u91CF\u663E\u793A */}\n <div\n className={cn(\n 'border-lines text-info-primary flex size-8 items-center justify-center border-y text-center text-sm font-semibold',\n 'laptop:size-10 laptop:text-base',\n classNames?.quantityValue\n )}\n >\n {quantity}\n </div>\n\n {/* \u589E\u52A0\u6309\u94AE */}\n <button\n type=\"button\"\n onClick={onIncrease}\n className={cn(\n 'border-lines flex size-8 items-center justify-center border',\n 'laptop:size-10',\n 'text-info-primary hover:bg-container-secondary-0 transition-colors',\n classNames?.quantityButton\n )}\n aria-label=\"Increase quantity\"\n >\n <PlusIcon className=\"laptop:size-3 size-[10.67px]\" />\n </button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * MiniCartDialog - \u8FF7\u4F60\u8D2D\u7269\u8F66\u5F39\u7A97\u7EC4\u4EF6\n *\n * @description \u7528\u4E8E\u5C55\u793A\u8D2D\u7269\u8F66\u5546\u54C1\u5217\u8868\uFF0C\u652F\u6301\u8C03\u6574\u5546\u54C1\u6570\u91CF\n */\nconst MiniCartDialog = ({\n open,\n onOpenChange,\n cart,\n copy,\n classNames = {},\n onIncreaseQuantity,\n onDecreaseQuantity,\n onQuantityChange,\n}: MiniCartDialogProps) => {\n // \u6587\u6848\u914D\u7F6E\n const titleText = copy?.title || 'Selected ({count})'\n const emptyText = copy?.emptyText || 'Your cart is empty'\n\n // \u8BA1\u7B97\u5546\u54C1\u603B\u6570\u91CF\n const totalQuantity = cart?.lineItems?.reduce((total, item) => total + (item?.quantity || 0), 0) || 0\n\n const items = cart?.lineItems || []\n const isEmpty = items.length === 0\n\n // \u5904\u7406\u6570\u91CF\u589E\u52A0\n const handleIncrease = (lineItemId: string, currentQuantity: number) => {\n onIncreaseQuantity?.(lineItemId, currentQuantity)\n onQuantityChange?.(lineItemId, currentQuantity + 1)\n }\n\n // \u5904\u7406\u6570\u91CF\u51CF\u5C11\n const handleDecrease = (lineItemId: string, currentQuantity: number) => {\n if (currentQuantity > 1) {\n onDecreaseQuantity?.(lineItemId, currentQuantity)\n onQuantityChange?.(lineItemId, currentQuantity - 1)\n }\n }\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent\n className={cn(\n // \u57FA\u7840\u6837\u5F0F + \u5C45\u4E2D\u5B9A\u4F4D\n 'bg-container-secondary-0 fixed left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col gap-0 overflow-hidden p-0',\n // \u79FB\u52A8\u7AEF\uFF1A\u5C45\u4E2D\u5F39\u7A97\uFF0C\u6700\u5C0F\u5BBD\u5EA6326px\uFF0C\u5DE6\u53F3\u8DDD\u5C4F\u5E55\u8FB9\u7F1832px\n 'rounded-box max-h-[80vh] w-[calc(100%-64px)] min-w-[326px]',\n // \u684C\u9762\u7AEF\uFF1A\u6700\u5927\u5BBD\u5EA6560px\n 'laptop:w-full laptop:max-w-[560px] laptop:rounded-box',\n classNames?.root\n )}\n >\n {/* \u5934\u90E8 */}\n <DialogHeader\n className={cn(\n 'bg-container-secondary-0 flex flex-row items-start justify-between gap-4 px-4 pb-2 pt-4',\n classNames?.header\n )}\n >\n <DialogTitle asChild>\n <Heading as=\"h3\" size={2} className={cn('text-info-primary font-bold', classNames?.title)}>\n {titleText.replace('{count}', totalQuantity.toString())}\n </Heading>\n </DialogTitle>\n </DialogHeader>\n\n {/* \u5546\u54C1\u5217\u8868 */}\n <div\n className={cn(\n 'bg-container-secondary-0 h- flex flex-col gap-2 overflow-y-auto px-4 py-2',\n classNames?.content\n )}\n >\n {isEmpty ? (\n <div className=\"flex items-center justify-center py-8\">\n <Text size={2} className=\"text-info-tertiary\">\n {emptyText}\n </Text>\n </div>\n ) : (\n <div className={cn('flex flex-col gap-2', classNames?.itemList)}>\n {items.map(item => (\n <CartItem\n key={item.id}\n item={item}\n classNames={classNames}\n onIncrease={() => handleIncrease(item.id, item.quantity)}\n onDecrease={() => handleDecrease(item.id, item.quantity)}\n />\n ))}\n </div>\n )}\n </div>\n\n {/* \u5E95\u90E8\u5B89\u5168\u533A\u57DF */}\n <div className=\"bg-container-secondary-0 h-8 w-full\" />\n </DialogContent>\n </Dialog>\n )\n}\n\nMiniCartDialog.displayName = 'MiniCartDialog'\n\nexport default MiniCartDialog\nexport { MiniCartDialog }\n"],
4
+ "sourcesContent": ["'use client'\n\nimport { cn } from '../../helpers/index.js'\nimport { Heading, Text, Dialog, DialogContent, DialogHeader, DialogTitle } from '../../components/index.js'\nimport type { CartLineItem, Cart } from './index.js'\n\n/**\n * \u8D2D\u7269\u8F66\u6570\u636E\u7C7B\u578B - \u590D\u7528 MiniCart \u7684\u7C7B\u578B\u5B9A\u4E49\n */\nexport interface CartData {\n id: string\n checkoutUrl: string\n lineItems: CartLineItem[]\n}\n\n// \u91CD\u65B0\u5BFC\u51FA\u7C7B\u578B\u4F9B\u5916\u90E8\u4F7F\u7528\nexport type { CartLineItem, Cart }\n\n/**\n * \u6587\u6848\u914D\u7F6E\n */\nexport interface MiniCartDialogCopy {\n /** \u6807\u9898\u6587\u6848\uFF0C{count} \u4F1A\u88AB\u66FF\u6362\u4E3A\u5546\u54C1\u6570\u91CF */\n title?: string\n /** \u7A7A\u8D2D\u7269\u8F66\u63D0\u793A */\n emptyText?: string\n}\n\nexport type MiniCartDialogSemanticName =\n | 'root'\n | 'header'\n | 'title'\n | 'content'\n | 'itemList'\n | 'item'\n | 'itemImage'\n | 'itemInfo'\n | 'itemTitle'\n | 'itemPrice'\n | 'itemCurrentPrice'\n | 'itemOriginalPrice'\n | 'quantityControl'\n | 'quantityButton'\n | 'quantityValue'\n\nexport interface MiniCartDialogProps {\n /** \u662F\u5426\u6253\u5F00\u5F39\u7A97 */\n open: boolean\n /** \u5173\u95ED\u5F39\u7A97\u56DE\u8C03 */\n onOpenChange: (open: boolean) => void\n /** \u8D2D\u7269\u8F66\u6570\u636E */\n cart: CartData\n /** \u6587\u6848\u914D\u7F6E */\n copy?: MiniCartDialogCopy\n /** \u5404\u90E8\u5206\u7684\u81EA\u5B9A\u4E49\u6837\u5F0F\u7C7B\u540D */\n classNames?: Partial<Record<MiniCartDialogSemanticName, string>>\n /**\n * \u589E\u52A0\u5546\u54C1\u6570\u91CF\u56DE\u8C03\n * @param lineItemId \u5546\u54C1\u884CID\n * @param currentQuantity \u5F53\u524D\u6570\u91CF\n */\n onIncreaseQuantity?: (lineItemId: string, currentQuantity: number) => void\n /**\n * \u51CF\u5C11\u5546\u54C1\u6570\u91CF\u56DE\u8C03\n * @param lineItemId \u5546\u54C1\u884CID\n * @param currentQuantity \u5F53\u524D\u6570\u91CF\n */\n onDecreaseQuantity?: (lineItemId: string, currentQuantity: number) => void\n /**\n * \u6570\u91CF\u53D8\u66F4\u56DE\u8C03\n * @param lineItemId \u5546\u54C1\u884CID\n * @param quantity \u65B0\u6570\u91CF\n */\n onQuantityChange?: (lineItemId: string, quantity: number) => void\n}\n\n/**\n * MinusIcon - \u51CF\u53F7\u56FE\u6807\n */\nconst MinusIcon = ({ className }: { className?: string }) => (\n <svg className={className} width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2 6H10\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n)\n\n/**\n * PlusIcon - \u52A0\u53F7\u56FE\u6807\n */\nconst PlusIcon = ({ className }: { className?: string }) => (\n <svg className={className} width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M6 2V10M2 6H10\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n)\n\n/**\n * CartItem - \u8D2D\u7269\u8F66\u5546\u54C1\u9879\u7EC4\u4EF6\n */\ninterface CartItemProps {\n item: CartLineItem\n classNames?: Partial<Record<MiniCartDialogSemanticName, string>>\n onIncrease?: () => void\n onDecrease?: () => void\n}\n\nconst CartItem = ({ item, classNames, onIncrease, onDecrease }: CartItemProps) => {\n const { merchandise, quantity, cost } = item\n const { image, title } = merchandise\n const { totalAmount, subtotalAmount } = cost\n\n // \u663E\u793A\u6807\u9898\uFF08\u56DE\u9000\u5230 SKU\uFF09\n const displayTitle = title || merchandise.sku || 'Product'\n // \u663E\u793A\u4EF7\u683C\uFF08\u73B0\u4EF7 = totalAmount\uFF09\n const displayPrice = totalAmount?.formattedPrice || ''\n // \u662F\u5426\u6709\u6298\u6263\uFF08\u539F\u4EF7 subtotalAmount \u5927\u4E8E\u73B0\u4EF7 totalAmount\uFF09\n const hasDiscount =\n subtotalAmount && totalAmount && parseFloat(subtotalAmount.amount) > parseFloat(totalAmount.amount)\n\n return (\n <div\n className={cn(\n // \u79FB\u52A8\u7AEF\uFF1A\u7070\u8272\u80CC\u666F\uFF0C\u8F83\u5C0F\u95F4\u8DDD\n 'bg-container-primary rounded-box flex items-center gap-2 px-2 py-4',\n // \u684C\u9762\u7AEF\uFF1A\u767D\u8272\u80CC\u666F\uFF0C\u8F83\u5927\u95F4\u8DDD\n 'laptop:bg-container-primary laptop:gap-4 laptop:p-4',\n classNames?.item\n )}\n >\n {/* \u5546\u54C1\u56FE\u7247 - \u79FB\u52A8\u7AEF 64px\uFF0C\u684C\u9762\u7AEF 80px */}\n <div\n className={cn('rounded-box relative size-16 shrink-0 overflow-hidden', 'laptop:size-20', classNames?.itemImage)}\n >\n {image?.url && <img src={image.url} alt={image.altText || displayTitle} className=\"size-full object-cover\" />}\n </div>\n\n {/* \u5546\u54C1\u4FE1\u606F */}\n <div className={cn('laptop:gap-4 flex flex-1 flex-col gap-2', classNames?.itemInfo)}>\n {/* \u5546\u54C1\u540D\u79F0 - \u79FB\u52A8\u7AEF\u8F83\u5C0F\u5B57\u4F53 */}\n <Text\n as=\"p\"\n size={3}\n className={cn('text-info-primary laptop:text-[16px] line-clamp-2 text-[14px]', classNames?.itemTitle)}\n >\n {displayTitle}\n </Text>\n\n {/* \u4EF7\u683C\u548C\u6570\u91CF\u63A7\u5236 - \u79FB\u52A8\u7AEF\u5782\u76F4\u6392\u5217\uFF0C\u684C\u9762\u7AEF\u6C34\u5E73\u6392\u5217 */}\n <div className=\"laptop:flex-row laptop:items-center laptop:justify-between flex flex-col items-start gap-1\">\n {/* \u4EF7\u683C\u533A\u57DF */}\n <div className={cn('flex items-center gap-1', classNames?.itemPrice)}>\n {displayPrice && (\n <Text\n size={4}\n className={cn('text-info-primary laptop:text-[18px] text-[16px]', classNames?.itemCurrentPrice)}\n >\n {displayPrice}\n </Text>\n )}\n {hasDiscount && subtotalAmount?.formattedPrice && (\n <Text\n size={4}\n className={cn(\n 'text-info-tertiary laptop:text-[18px] text-[16px] line-through',\n classNames?.itemOriginalPrice\n )}\n >\n {subtotalAmount.formattedPrice}\n </Text>\n )}\n </div>\n\n {/* \u6570\u91CF\u63A7\u5236 - \u79FB\u52A8\u7AEF 32px \u6309\u94AE\uFF0C\u684C\u9762\u7AEF 40px \u6309\u94AE */}\n <div className={cn('flex items-center', classNames?.quantityControl)}>\n {/* \u51CF\u5C11\u6309\u94AE */}\n <button\n type=\"button\"\n onClick={onDecrease}\n disabled={quantity <= 0}\n className={cn(\n 'border-lines flex size-8 items-center justify-center border',\n 'laptop:size-10',\n 'text-info-primary hover:bg-container-secondary-0 transition-colors',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n classNames?.quantityButton\n )}\n aria-label=\"Decrease quantity\"\n >\n <MinusIcon className=\"laptop:size-3 size-[10.67px]\" />\n </button>\n\n {/* \u6570\u91CF\u663E\u793A */}\n <div\n className={cn(\n 'border-lines text-info-primary flex size-8 items-center justify-center border-y text-center text-sm font-semibold',\n 'laptop:size-10 laptop:text-base',\n classNames?.quantityValue\n )}\n >\n {quantity}\n </div>\n\n {/* \u589E\u52A0\u6309\u94AE */}\n <button\n type=\"button\"\n onClick={onIncrease}\n className={cn(\n 'border-lines flex size-8 items-center justify-center border',\n 'laptop:size-10',\n 'text-info-primary hover:bg-container-secondary-0 transition-colors',\n classNames?.quantityButton\n )}\n aria-label=\"Increase quantity\"\n >\n <PlusIcon className=\"laptop:size-3 size-[10.67px]\" />\n </button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * MiniCartDialog - \u8FF7\u4F60\u8D2D\u7269\u8F66\u5F39\u7A97\u7EC4\u4EF6\n *\n * @description \u7528\u4E8E\u5C55\u793A\u8D2D\u7269\u8F66\u5546\u54C1\u5217\u8868\uFF0C\u652F\u6301\u8C03\u6574\u5546\u54C1\u6570\u91CF\n */\nconst MiniCartDialog = ({\n open,\n onOpenChange,\n cart,\n copy,\n classNames = {},\n onIncreaseQuantity,\n onDecreaseQuantity,\n onQuantityChange,\n}: MiniCartDialogProps) => {\n // \u6587\u6848\u914D\u7F6E\n const titleText = copy?.title || 'Selected ({count})'\n const emptyText = copy?.emptyText || 'Your cart is empty'\n\n // \u8BA1\u7B97\u5546\u54C1\u603B\u6570\u91CF\n const totalQuantity = cart?.lineItems?.reduce((total, item) => total + (item?.quantity || 0), 0) || 0\n\n const items = cart?.lineItems || []\n const isEmpty = items.length === 0\n\n // \u5904\u7406\u6570\u91CF\u589E\u52A0\n const handleIncrease = (lineItemId: string, currentQuantity: number) => {\n onIncreaseQuantity?.(lineItemId, currentQuantity)\n onQuantityChange?.(lineItemId, currentQuantity + 1)\n }\n\n // \u5904\u7406\u6570\u91CF\u51CF\u5C11\n const handleDecrease = (lineItemId: string, currentQuantity: number) => {\n if (currentQuantity > 0) {\n onDecreaseQuantity?.(lineItemId, currentQuantity)\n onQuantityChange?.(lineItemId, currentQuantity - 1)\n }\n }\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent\n className={cn(\n // \u57FA\u7840\u6837\u5F0F + \u5C45\u4E2D\u5B9A\u4F4D\n 'bg-container-secondary-0 fixed left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col gap-0 overflow-hidden p-0',\n // \u79FB\u52A8\u7AEF\uFF1A\u5C45\u4E2D\u5F39\u7A97\uFF0C\u6700\u5C0F\u5BBD\u5EA6326px\uFF0C\u5DE6\u53F3\u8DDD\u5C4F\u5E55\u8FB9\u7F1832px\n 'rounded-box max-h-[80vh] w-[calc(100%-64px)] min-w-[326px]',\n // \u684C\u9762\u7AEF\uFF1A\u6700\u5927\u5BBD\u5EA6560px\n 'laptop:w-full laptop:max-w-[560px] laptop:rounded-box',\n classNames?.root\n )}\n >\n {/* \u5934\u90E8 */}\n <DialogHeader\n className={cn(\n 'bg-container-secondary-0 flex flex-row items-start justify-between gap-4 px-4 pb-2 pt-4',\n classNames?.header\n )}\n >\n <DialogTitle asChild>\n <Heading as=\"h3\" size={2} className={cn('text-info-primary font-bold', classNames?.title)}>\n {titleText.replace('{count}', totalQuantity.toString())}\n </Heading>\n </DialogTitle>\n </DialogHeader>\n\n {/* \u5546\u54C1\u5217\u8868 */}\n <div\n className={cn(\n 'bg-container-secondary-0 h- flex flex-col gap-2 overflow-y-auto px-4 py-2',\n classNames?.content\n )}\n >\n {isEmpty ? (\n <div className=\"flex items-center justify-center py-8\">\n <Text size={2} className=\"text-info-tertiary\">\n {emptyText}\n </Text>\n </div>\n ) : (\n <div className={cn('flex flex-col gap-2', classNames?.itemList)}>\n {items.map(item => (\n <CartItem\n key={item.id}\n item={item}\n classNames={classNames}\n onIncrease={() => handleIncrease(item.id, item.quantity)}\n onDecrease={() => handleDecrease(item.id, item.quantity)}\n />\n ))}\n </div>\n )}\n </div>\n\n {/* \u5E95\u90E8\u5B89\u5168\u533A\u57DF */}\n <div className=\"bg-container-secondary-0 h-8 w-full\" />\n </DialogContent>\n </Dialog>\n )\n}\n\nMiniCartDialog.displayName = 'MiniCartDialog'\n\nexport default MiniCartDialog\nexport { MiniCartDialog }\n"],
5
5
  "mappings": "sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAiFI,IAAAK,EAAA,6BA/EJC,EAAmB,kCACnBC,EAAgF,qCA4EhF,MAAMC,EAAY,CAAC,CAAE,UAAAC,CAAU,OAC7B,OAAC,OAAI,UAAWA,EAAW,MAAM,KAAK,OAAO,KAAK,QAAQ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AM,aAAcC,EAChC,oBAAC,iBACC,aAAW,MAET,4HAEA,6DAEA,wDACAd,GAAY,IACd,EAGA,oBAAC,gBACC,aAAW,MACT,0FACAA,GAAY,MACd,EAEA,mBAAC,eAAY,QAAO,GAClB,mBAAC,WAAQ,GAAG,KAAK,KAAM,EAAG,aAAW,MAAG,8BAA+BA,GAAY,KAAK,EACrF,SAAAoB,EAAU,QAAQ,UAAWE,EAAc,SAAS,CAAC,EACxD,EACF,EACF,KAGA,OAAC,OACC,aAAW,MACT,4EACAtB,GAAY,OACd,EAEC,SAAAyB,KACC,OAAC,OAAI,UAAU,wCACb,mBAAC,QAAK,KAAM,EAAG,UAAU,qBACtB,SAAAJ,EACH,EACF,KAEA,OAAC,OAAI,aAAW,MAAG,sBAAuBrB,GAAY,QAAQ,EAC3D,SAAAwB,EAAM,IAAIzB,MACT,OAACD,EAAA,CAEC,KAAMC,EACN,WAAYC,EACZ,WAAY,IAAM0B,EAAe3B,EAAK,GAAIA,EAAK,QAAQ,EACvD,WAAY,IAAM8B,EAAe9B,EAAK,GAAIA,EAAK,QAAQ,GAJlDA,EAAK,EAKZ,CACD,EACH,EAEJ,KAGA,OAAC,OAAI,UAAU,sCAAsC,GACvD,EACF,CAEJ,EAEAV,EAAe,YAAc,iBAE7B,IAAOC,EAAQD",
6
6
  "names": ["MiniCartDialog_exports", "__export", "MiniCartDialog", "MiniCartDialog_default", "__toCommonJS", "import_jsx_runtime", "import_helpers", "import_components", "MinusIcon", "className", "PlusIcon", "CartItem", "item", "classNames", "onIncrease", "onDecrease", "merchandise", "quantity", "cost", "image", "title", "totalAmount", "subtotalAmount", "displayTitle", "displayPrice", "hasDiscount", "open", "onOpenChange", "cart", "copy", "onIncreaseQuantity", "onDecreaseQuantity", "onQuantityChange", "titleText", "emptyText", "totalQuantity", "total", "items", "isEmpty", "handleIncrease", "lineItemId", "currentQuantity", "handleDecrease"]
7
7
  }
@@ -1,5 +1,29 @@
1
1
  import * as React from 'react';
2
- export type MiniCartSemanticName = 'root' | 'content' | 'cartInfo' | 'cartTitle' | 'cartDescription' | 'priceSection' | 'totalPrice' | 'originalPrice' | 'saveAmount' | 'actionButton' | 'itemsGrid' | 'itemGridContainer' | 'gridItem' | 'gridItemOverlay' | 'expandButton';
2
+ import type { Img } from '../../types/props.js';
3
+ export type MiniCartSemanticName = 'root' | 'content' | 'cartInfo' | 'cartTitle' | 'cartDescription' | 'priceSection' | 'totalPrice' | 'originalPrice' | 'saveAmount' | 'actionButton' | 'itemsGrid' | 'itemGridContainer' | 'gridItem' | 'gridItemOverlay' | 'expandButton' | 'circleProgress' | 'mobileViewMoreButton';
4
+ /**
5
+ * 圆形进度条配置
6
+ */
7
+ export interface CircleProgressConfig {
8
+ /** 总阶段数 (1-4) */
9
+ totalSteps?: 1 | 2 | 3 | 4;
10
+ /** 当前完成的阶段 (0 到 totalSteps) */
11
+ currentStep?: number;
12
+ /** 中间显示的图片 */
13
+ image?: Img;
14
+ /** 底部显示的文案 */
15
+ label?: string;
16
+ /** 进度条颜色,默认为品牌色 */
17
+ progressColor?: string;
18
+ /** 底部文案背景色,默认为品牌营销色 */
19
+ labelColor?: string;
20
+ /** 背景颜色,默认为容器背景色 */
21
+ backgroundColor?: string;
22
+ /** 移动端组件尺寸,默认 48 */
23
+ size?: number;
24
+ /** laptop 以上组件尺寸,默认 80 */
25
+ laptopSize?: number;
26
+ }
3
27
  /**
4
28
  * 文案配置
5
29
  */
@@ -22,6 +46,8 @@ export interface MiniCartData {
22
46
  theme?: 'light' | 'dark';
23
47
  /** 地区代码,用于价格格式化 */
24
48
  locale?: string;
49
+ /** 是否显示手机端查看更多按钮,默认 true */
50
+ showMobileViewMore?: boolean;
25
51
  }
26
52
  /**
27
53
  * 购物车商品项类型
@@ -88,6 +114,10 @@ export interface MiniCartProps extends React.HTMLAttributes<HTMLDivElement> {
88
114
  * 产品信息(用于主要展示的产品)
89
115
  */
90
116
  cart: Cart;
117
+ /**
118
+ * 圆形进度条配置,不传则不显示进度条
119
+ */
120
+ progressConfig?: CircleProgressConfig;
91
121
  /**
92
122
  * 删除商品项的回调函数
93
123
  * @param id 商品 ID