@anker-in/headless-ui 1.0.26-alpha.1763109270406 → 1.0.26-alpha.1763367560339

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 (104) hide show
  1. package/dist/cjs/biz-components/DownLoad/index.js +1 -1
  2. package/dist/cjs/biz-components/DownLoad/index.js.map +2 -2
  3. package/dist/cjs/biz-components/Features/index.js +1 -1
  4. package/dist/cjs/biz-components/Features/index.js.map +2 -2
  5. package/dist/cjs/biz-components/Listing/components/PaidShipping/index.d.ts +23 -7
  6. package/dist/cjs/biz-components/Listing/components/PaidShipping/index.js +1 -1
  7. package/dist/cjs/biz-components/Listing/components/PaidShipping/index.js.map +3 -3
  8. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.d.ts +5 -2
  9. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +5 -5
  10. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
  11. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.d.ts +6 -2
  12. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js +1 -1
  13. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js.map +3 -3
  14. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.d.ts +6 -2
  15. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js +1 -1
  16. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js.map +3 -3
  17. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.d.ts +6 -2
  18. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js +1 -1
  19. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js.map +3 -3
  20. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.d.ts +6 -2
  21. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js +1 -1
  22. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js.map +3 -3
  23. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.d.ts +6 -2
  24. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js +1 -1
  25. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js.map +3 -3
  26. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.d.ts +6 -2
  27. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
  28. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +3 -3
  29. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/types.d.ts +43 -12
  30. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/types.js +1 -1
  31. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/types.js.map +2 -2
  32. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.d.ts +6 -2
  33. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  34. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +3 -3
  35. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
  36. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +2 -2
  37. package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.d.ts +6 -2
  38. package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.js +1 -1
  39. package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.js.map +3 -3
  40. package/dist/cjs/biz-components/SelectStore/index.js +1 -1
  41. package/dist/cjs/biz-components/SelectStore/index.js.map +2 -2
  42. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js +2 -2
  43. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js.map +2 -2
  44. package/dist/cjs/components/ExposureDetector.d.ts +45 -0
  45. package/dist/cjs/components/ExposureDetector.js +2 -0
  46. package/dist/cjs/components/ExposureDetector.js.map +7 -0
  47. package/dist/cjs/components/index.d.ts +1 -0
  48. package/dist/cjs/components/index.js +1 -1
  49. package/dist/cjs/components/index.js.map +3 -3
  50. package/dist/cjs/hooks/useExposureDetection.d.ts +69 -0
  51. package/dist/cjs/hooks/useExposureDetection.js +2 -0
  52. package/dist/cjs/hooks/useExposureDetection.js.map +7 -0
  53. package/dist/esm/biz-components/DownLoad/index.js +1 -1
  54. package/dist/esm/biz-components/DownLoad/index.js.map +2 -2
  55. package/dist/esm/biz-components/Features/index.js +1 -1
  56. package/dist/esm/biz-components/Features/index.js.map +2 -2
  57. package/dist/esm/biz-components/Listing/components/PaidShipping/index.d.ts +23 -7
  58. package/dist/esm/biz-components/Listing/components/PaidShipping/index.js +1 -1
  59. package/dist/esm/biz-components/Listing/components/PaidShipping/index.js.map +3 -3
  60. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.d.ts +5 -2
  61. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +5 -5
  62. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
  63. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.d.ts +6 -2
  64. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js +1 -1
  65. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js.map +3 -3
  66. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.d.ts +6 -2
  67. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js +1 -1
  68. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js.map +3 -3
  69. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.d.ts +6 -2
  70. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js +1 -1
  71. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js.map +3 -3
  72. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.d.ts +6 -2
  73. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js +1 -1
  74. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js.map +3 -3
  75. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.d.ts +6 -2
  76. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js +1 -1
  77. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js.map +3 -3
  78. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.d.ts +6 -2
  79. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
  80. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +3 -3
  81. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/types.d.ts +43 -12
  82. package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/types.js.map +2 -2
  83. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.d.ts +6 -2
  84. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  85. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +3 -3
  86. package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
  87. package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +2 -2
  88. package/dist/esm/biz-components/Listing/components/PurchaseBar/index.d.ts +6 -2
  89. package/dist/esm/biz-components/Listing/components/PurchaseBar/index.js +1 -1
  90. package/dist/esm/biz-components/Listing/components/PurchaseBar/index.js.map +3 -3
  91. package/dist/esm/biz-components/SelectStore/index.js +1 -1
  92. package/dist/esm/biz-components/SelectStore/index.js.map +2 -2
  93. package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js +2 -2
  94. package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js.map +2 -2
  95. package/dist/esm/components/ExposureDetector.d.ts +45 -0
  96. package/dist/esm/components/ExposureDetector.js +2 -0
  97. package/dist/esm/components/ExposureDetector.js.map +7 -0
  98. package/dist/esm/components/index.d.ts +1 -0
  99. package/dist/esm/components/index.js +1 -1
  100. package/dist/esm/components/index.js.map +3 -3
  101. package/dist/esm/hooks/useExposureDetection.d.ts +69 -0
  102. package/dist/esm/hooks/useExposureDetection.js +2 -0
  103. package/dist/esm/hooks/useExposureDetection.js.map +7 -0
  104. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/ShelfDisplay/shelfDisplayItem.tsx"],
4
- "sourcesContent": ["import { useAiuiContext } from '../AiuiProvider/index.js'\nimport { formatVariantPrice } from './shelfDisplay.js'\nimport Picture from '../../components/picture.js'\nimport Badge from '../../components/badge.js'\nimport { cn } from '../../helpers/utils.js'\nimport { Text } from '../../components/text.js'\nimport Button from '../../components/button.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { Heading } from '../../components/heading.js'\nimport type { ShelfDisplayItem, ShelfDisplayType } from './shelfDisplay.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { useRef, useEffect, useState } from 'react'\n\nconst componentType = 'image'\nconst componentName = 'product_shelf'\n\nconst SOLD_OUT_PRICE = 9999999.99\n\nexport const ShelfDisplayWrapItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const {\n isDisplayBackImage = false,\n itemShape,\n metafields,\n isTopTag = false,\n isShowTag,\n isShowOriginalPrice,\n } = configuration || {}\n const { locale = 'us', copyWriting } = useAiuiContext()\n const { discounts } = metafields || {}\n const ref = useRef<HTMLDivElement>(null)\n const [showTags, setShowTags] = useState<string[]>([])\n const [currentPriceTag, setCurrentPriceTag] = useState<string>('')\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.primaryButton?.(params, index + 1, data)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data)\n\n const variant = data?.variants?.find((item: any) => item?.sku === data?.sku) || data?.variants?.[0] || {}\n\n const isSoldOut = !variant?.availableForSale && variant?.price?.amount === SOLD_OUT_PRICE\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const { price, basePrice, discount } = formatVariantPrice({\n locale: locale,\n amount: isShowOriginalPrice && coupon ? coupon.variant_price4wscode : variant.price,\n baseAmount: isShowOriginalPrice && coupon ? variant.price : 0,\n currencyCode: data?.price?.currencyCode || 'USD',\n })\n\n const handleUrl = () => {\n const sku = data?.sku\n const skuArray = data?.variants\n const findSku = skuArray?.find((item: any) => item?.sku === sku)\n return findSku?.image?.url || skuArray?.[0]?.image?.url || ''\n }\n\n const displayTitle = data?.custom_name || data?.title\n const displayDescription = data?.custom_description || data?.description\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount) {\n const discountTag = `${discount}${discounts?.off || ''}`\n setCurrentPriceTag(discountTag)\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount])\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const bottomContent = () => {\n return (\n <>\n {isShowTag && showTags?.length > 0 ? (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.map?.((item: any, index: number) => <Badge key={index} className=\"shelf-items-tag\">{item}</Badge>)}\n </div>\n ) : null}\n {displayTitle ? (\n <Heading\n as=\"h3\"\n title={displayTitle || ''}\n size={2}\n className=\"shelf-display-product-title line-clamp-2\"\n html={displayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg desktop:text-base shelf-display-product-description truncate text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-4 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n onClick={() => onSecondaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n variant=\"primary\"\n onClick={() => onPrimaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </>\n )\n }\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n 'bg-container-secondary-1 tablet:hover:bg-info-white box-border w-full cursor-pointer overflow-hidden duration-300',\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480] desktop:aspect-w-[316] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[288] laptop:aspect-h-[360] aspect-w-[296] aspect-h-[360] relative',\n 'md-tablet:h-[360px] shelf-display-item'\n )}\n >\n {isDisplayBackImage ? (\n <div className=\"absolute inset-0 box-border overflow-hidden\">\n <div className=\"relative inset-0 size-full\">\n <Picture source={handleUrl()} alt=\"\" className=\"flex h-full justify-center object-cover [&_img]:w-auto\" />\n <div className=\"desktop:p-6 absolute inset-x-0 bottom-0 box-border overflow-hidden p-4\">\n {bottomContent()}\n </div>\n </div>\n </div>\n ) : (\n <div className=\"desktop:p-6 absolute inset-0 box-border flex flex-col justify-between overflow-hidden p-4\">\n {currentPriceTag && isTopTag && (\n <Badge className=\"absolute left-4 top-4 z-10 shelf-prices-tag\">{currentPriceTag || ''}</Badge>\n )}\n <div\n className={cn(\n 'lg-desktop:h-[195px] relative mb-2 inline-block h-[140px] w-full flex-1 overflow-hidden shelf-display-item-image'\n )}\n >\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture source={handleUrl()} alt=\"\" className=\"flex h-full justify-center object-cover [&_img]:w-auto\" />\n </a>\n </div>\n {bottomContent()}\n </div>\n )}\n </div>\n )\n}\n\nexport const ShelfDisplayHorizontalItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const { itemShape, itemLength, metafields } = configuration || {}\n const { discounts } = metafields || {}\n const { locale = 'us', copyWriting } = useAiuiContext()\n const [showTags, setShowTags] = useState<string[]>([])\n const ref = useRef<HTMLDivElement>(null)\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.primaryButton?.(params, index + 1, data)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data)\n\n const variant = data?.variants?.find((item: any) => item?.sku === data?.sku) || data?.variants?.[0] || {}\n\n const isSoldOut = !variant?.availableForSale && variant?.price?.amount === SOLD_OUT_PRICE\n const isShowTag = configuration?.isShowTag\n const isShowOriginalPrice = configuration?.isShowOriginalPrice\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const { price, basePrice, discount } = formatVariantPrice({\n locale: locale,\n amount: isShowOriginalPrice && coupon ? coupon.variant_price4wscode : variant.price,\n baseAmount: isShowOriginalPrice && coupon ? variant.price : 0,\n currencyCode: data?.price?.currencyCode || 'USD',\n })\n\n const handleUrl = () => {\n const sku = data?.sku\n const skuArray = data?.variants\n const findSku = skuArray?.find((item: any) => item?.sku === sku)\n return findSku?.image?.url || skuArray?.[0]?.image?.url || ''\n }\n\n const displayTitle = data?.custom_name || data?.title\n const displayDescription = data?.custom_description || data?.description\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const showSizeClass = (): {\n boxItem: string\n imgItem: string\n wrap: string\n } => {\n if (itemLength >= 2) {\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] max-w-full',\n imgItem:\n 'm-tablet:m-auto lg-desktop:max-w-[330px] lg-desktop:max-h-[330px] desktop:max-w-[260px] desktop:max-h-[260px] max-w-[138px] max-h-[138px]',\n wrap: 'lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480] desktop:aspect-w-[648] desktop:aspect-h-[380] laptop:aspect-w-[440] laptop:aspect-h-[356] tablet:aspect-w-[346] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] laptop:max-w-[289px] max-w-[262px]',\n imgItem:\n 'md-tablet:m-auto lg-desktop:max-w-[450px] lg-desktop:max-h-[450px] desktop:max-w-[332px] desktop:max-h-[332px] max-w-[312px] max-h-[312px]',\n wrap: 'lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[480] desktop:aspect-w-[1312] desktop:aspect-h-[380] laptop:aspect-w-[896] laptop:aspect-h-[356] tablet:aspect-w-[704] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n\n const handleWrapClass = () => {\n if (itemLength >= 2) {\n return 'flex flex-col justify-between desktop:gap-12 desktop:flex-row desktop:justify-center desktop:items-center'\n }\n return 'flex justify-center items-center gap-6 md-tablet:flex-col'\n }\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount) {\n const discountTag = `${discount}${discounts?.off || ''}`\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount])\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n showSizeClass().wrap,\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'shelf-display-item',\n 'bg-container-secondary-1 tablet:hover:bg-info-white duration-300 gap-6',\n 'box-border w-full cursor-pointer overflow-hidden relative md-tablet:h-[360px]'\n )}\n >\n <div className={cn(handleWrapClass(), 'desktop:p-6 absolute inset-0 box-border overflow-hidden p-4')}>\n <div className={cn(showSizeClass().imgItem, 'relative overflow-hidden desktop:mb-0 mb-1')}>\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture source={handleUrl()} alt=\"\" className=\"flex h-full justify-center object-cover [&_img]:w-auto\" />\n </a>\n </div>\n <div className={cn('flex flex-col justify-center items-start', showSizeClass().boxItem)}>\n {isShowTag ? (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.map?.((item: any, index: number) => (\n <Badge key={index} className=\"shelf-items-tag\">\n {item}\n </Badge>\n ))}\n </div>\n ) : null}\n {displayTitle ? (\n <Heading\n as=\"h3\"\n title={displayTitle || ''}\n size={2}\n className=\"shelf-display-product-title mb-1 line-clamp-2\"\n html={displayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg lg-desktop:h-[26px] desktop:text-base desktop:h-6 shelf-display-product-description line-clamp-1 h-5 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-5 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n onClick={() => onSecondaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n variant=\"primary\"\n onClick={() => onPrimaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "AA4F2D,OAuB/C,YAAAA,EAvB+C,OAAAC,EAuB/C,QAAAC,MAvB+C,oBA5F3D,OAAS,kBAAAC,MAAsB,2BAC/B,OAAS,sBAAAC,MAA0B,oBACnC,OAAOC,MAAa,8BACpB,OAAOC,MAAW,4BAClB,OAAS,MAAAC,MAAU,yBACnB,OAAS,QAAAC,MAAY,2BACrB,OAAOC,MAAY,6BACnB,OAAS,WAAAC,MAAe,wBACxB,OAAS,eAAAC,MAAmB,8BAC5B,OAAS,WAAAC,MAAe,8BAExB,OAAS,eAAAC,MAAmB,6BAC5B,OAAS,UAAAC,EAAQ,aAAAC,EAAW,YAAAC,MAAgB,QAE5C,MAAMC,EAAgB,QAChBC,EAAgB,gBAEhBC,EAAiB,aAEVC,GAAuB,CAAC,CAAE,KAAAC,EAAM,cAAAC,CAAc,IAA0C,CACnG,KAAM,CACJ,mBAAAC,EAAqB,GACrB,UAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EACA,oBAAAC,CACF,EAAIN,GAAiB,CAAC,EAChB,CAAE,OAAAO,EAAS,KAAM,YAAAC,CAAY,EAAI3B,EAAe,EAChD,CAAE,UAAA4B,CAAU,EAAIN,GAAc,C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ACQ,EAAA,CACC,QAAQ,YACR,QAAS,IAAM+B,EAAkBnB,EAAMC,GAAe,MAAOA,CAAa,EAC1E,UAAW;AAAA,kBACTA,EAAc,YAAc,WAAa,SAAW,EAAE;AAAA,gBAGvD,SAAAA,GAAe,iBAAmB,GACrC,EACE,KACHA,GAAe,cACdrB,EAACQ,EAAA,CACC,QAAQ,UACR,QAAS,IAAM4B,EAAgBhB,EAAMC,GAAe,MAAOA,CAAa,EACxE,UAAW;AAAA,gBACXA,EAAc,YAAc,WAAa,SAAW,EAAE;AAAA,cAGrD,SAAAA,GAAe,eAAiB,GACnC,EACE,MACN,GACF,GACF,GAjHKD,GAAM,IAAMA,GAAM,MAkHzB,CAEJ",
4
+ "sourcesContent": ["import { useAiuiContext } from '../AiuiProvider/index.js'\nimport { formatVariantPrice } from './shelfDisplay.js'\nimport Picture from '../../components/picture.js'\nimport Badge from '../../components/badge.js'\nimport { cn } from '../../helpers/utils.js'\nimport { Text } from '../../components/text.js'\nimport Button from '../../components/button.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { Heading } from '../../components/heading.js'\nimport type { ShelfDisplayItem, ShelfDisplayType } from './shelfDisplay.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { useRef, useEffect, useState } from 'react'\n\nconst componentType = 'image'\nconst componentName = 'product_shelf'\n\nconst SOLD_OUT_PRICE = 9999999.99\n\nexport const ShelfDisplayWrapItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const {\n isDisplayBackImage = false,\n itemShape,\n metafields,\n isTopTag = false,\n isShowTag,\n isShowOriginalPrice,\n } = configuration || {}\n const { locale = 'us', copyWriting } = useAiuiContext()\n const { discounts } = metafields || {}\n const ref = useRef<HTMLDivElement>(null)\n const [showTags, setShowTags] = useState<string[]>([])\n const [currentPriceTag, setCurrentPriceTag] = useState<string>('')\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.primaryButton?.(params, index + 1, data)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data)\n\n const variant = data?.variants?.find((item: any) => item?.sku === data?.sku) || data?.variants?.[0] || {}\n\n const isSoldOut = !variant?.availableForSale && variant?.price?.amount === SOLD_OUT_PRICE\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const { price, basePrice, discount } = formatVariantPrice({\n locale: locale,\n amount: isShowOriginalPrice && coupon ? coupon.variant_price4wscode : variant.price,\n baseAmount: isShowOriginalPrice && coupon ? variant.price : 0,\n currencyCode: data?.price?.currencyCode || 'USD',\n })\n\n const handleUrl = () => {\n const sku = data?.sku\n const skuArray = data?.variants\n const findSku = skuArray?.find((item: any) => item?.sku === sku)\n return findSku?.image?.url || skuArray?.[0]?.image?.url || ''\n }\n\n const displayTitle = data?.custom_name || data?.title\n const displayDescription = data?.custom_description || data?.description\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount) {\n const discountTag = `${discount}${discounts?.off || ''}`\n setCurrentPriceTag(discountTag)\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount])\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const bottomContent = () => {\n return (\n <>\n {isShowTag && showTags?.length > 0 ? (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.map?.((item: any, index: number) => <Badge key={index} className=\"shelf-items-tag\">{item}</Badge>)}\n </div>\n ) : null}\n {displayTitle ? (\n <Heading\n as=\"h3\"\n title={displayTitle || ''}\n size={2}\n className=\"shelf-display-product-title line-clamp-2\"\n html={displayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg desktop:text-base shelf-display-product-description line-clamp-1 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-4 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n onClick={() => onSecondaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n variant=\"primary\"\n onClick={() => onPrimaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </>\n )\n }\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n 'bg-container-secondary-1 tablet:hover:bg-info-white box-border w-full cursor-pointer overflow-hidden duration-300',\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480] desktop:aspect-w-[316] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[288] laptop:aspect-h-[360] aspect-w-[296] aspect-h-[360] relative',\n 'md-tablet:h-[360px] shelf-display-item'\n )}\n >\n {isDisplayBackImage ? (\n <div className=\"absolute inset-0 box-border overflow-hidden\">\n <div className=\"relative inset-0 size-full\">\n <Picture source={handleUrl()} alt=\"\" className=\"flex h-full justify-center object-cover [&_img]:w-auto\" />\n <div className=\"desktop:p-6 absolute inset-x-0 bottom-0 box-border overflow-hidden p-4\">\n {bottomContent()}\n </div>\n </div>\n </div>\n ) : (\n <div className=\"desktop:p-6 absolute inset-0 box-border flex flex-col justify-between overflow-hidden p-4\">\n {currentPriceTag && isTopTag && (\n <Badge className=\"absolute left-4 top-4 z-10 shelf-prices-tag\">{currentPriceTag || ''}</Badge>\n )}\n <div\n className={cn(\n 'lg-desktop:h-[195px] relative mb-2 inline-block h-[140px] w-full flex-1 overflow-hidden shelf-display-item-image'\n )}\n >\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture source={handleUrl()} alt=\"\" className=\"flex h-full justify-center object-cover [&_img]:w-auto\" />\n </a>\n </div>\n {bottomContent()}\n </div>\n )}\n </div>\n )\n}\n\nexport const ShelfDisplayHorizontalItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const { itemShape, itemLength, metafields } = configuration || {}\n const { discounts } = metafields || {}\n const { locale = 'us', copyWriting } = useAiuiContext()\n const [showTags, setShowTags] = useState<string[]>([])\n const ref = useRef<HTMLDivElement>(null)\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.primaryButton?.(params, index + 1, data)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data)\n\n const variant = data?.variants?.find((item: any) => item?.sku === data?.sku) || data?.variants?.[0] || {}\n\n const isSoldOut = !variant?.availableForSale && variant?.price?.amount === SOLD_OUT_PRICE\n const isShowTag = configuration?.isShowTag\n const isShowOriginalPrice = configuration?.isShowOriginalPrice\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const { price, basePrice, discount } = formatVariantPrice({\n locale: locale,\n amount: isShowOriginalPrice && coupon ? coupon.variant_price4wscode : variant.price,\n baseAmount: isShowOriginalPrice && coupon ? variant.price : 0,\n currencyCode: data?.price?.currencyCode || 'USD',\n })\n\n const handleUrl = () => {\n const sku = data?.sku\n const skuArray = data?.variants\n const findSku = skuArray?.find((item: any) => item?.sku === sku)\n return findSku?.image?.url || skuArray?.[0]?.image?.url || ''\n }\n\n const displayTitle = data?.custom_name || data?.title\n const displayDescription = data?.custom_description || data?.description\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const showSizeClass = (): {\n boxItem: string\n imgItem: string\n wrap: string\n } => {\n if (itemLength >= 2) {\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] max-w-full',\n imgItem:\n 'm-tablet:m-auto lg-desktop:max-w-[330px] lg-desktop:max-h-[330px] desktop:max-w-[260px] desktop:max-h-[260px] max-w-[138px] max-h-[138px]',\n wrap: 'lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480] desktop:aspect-w-[648] desktop:aspect-h-[380] laptop:aspect-w-[440] laptop:aspect-h-[356] tablet:aspect-w-[346] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] laptop:max-w-[289px] max-w-[262px]',\n imgItem:\n 'md-tablet:m-auto lg-desktop:max-w-[450px] lg-desktop:max-h-[450px] desktop:max-w-[332px] desktop:max-h-[332px] max-w-[312px] max-h-[312px]',\n wrap: 'lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[480] desktop:aspect-w-[1312] desktop:aspect-h-[380] laptop:aspect-w-[896] laptop:aspect-h-[356] tablet:aspect-w-[704] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n\n const handleWrapClass = () => {\n if (itemLength >= 2) {\n return 'flex flex-col justify-between desktop:gap-12 desktop:flex-row desktop:justify-center desktop:items-center'\n }\n return 'flex justify-center items-center gap-6 md-tablet:flex-col'\n }\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount) {\n const discountTag = `${discount}${discounts?.off || ''}`\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount])\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n showSizeClass().wrap,\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'shelf-display-item',\n 'bg-container-secondary-1 tablet:hover:bg-info-white duration-300 gap-6',\n 'box-border w-full cursor-pointer overflow-hidden relative md-tablet:h-[360px]'\n )}\n >\n <div className={cn(handleWrapClass(), 'desktop:p-6 absolute inset-0 box-border overflow-hidden p-4')}>\n <div className={cn(showSizeClass().imgItem, 'relative overflow-hidden desktop:mb-0 mb-1')}>\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture source={handleUrl()} alt=\"\" className=\"flex h-full justify-center object-cover [&_img]:w-auto\" />\n </a>\n </div>\n <div className={cn('flex flex-col justify-center items-start', showSizeClass().boxItem)}>\n {isShowTag ? (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.map?.((item: any, index: number) => (\n <Badge key={index} className=\"shelf-items-tag\">\n {item}\n </Badge>\n ))}\n </div>\n ) : null}\n {displayTitle ? (\n <Heading\n as=\"h3\"\n title={displayTitle || ''}\n size={2}\n className=\"shelf-display-product-title mb-1 line-clamp-2\"\n html={displayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg lg-desktop:h-[26px] desktop:text-base desktop:h-6 shelf-display-product-description line-clamp-1 h-5 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-5 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n onClick={() => onSecondaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n variant=\"primary\"\n onClick={() => onPrimaryButton(data, configuration?.index, configuration)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "AA4F2D,OAuB/C,YAAAA,EAvB+C,OAAAC,EAuB/C,QAAAC,MAvB+C,oBA5F3D,OAAS,kBAAAC,MAAsB,2BAC/B,OAAS,sBAAAC,MAA0B,oBACnC,OAAOC,MAAa,8BACpB,OAAOC,MAAW,4BAClB,OAAS,MAAAC,MAAU,yBACnB,OAAS,QAAAC,MAAY,2BACrB,OAAOC,MAAY,6BACnB,OAAS,WAAAC,MAAe,wBACxB,OAAS,eAAAC,MAAmB,8BAC5B,OAAS,WAAAC,MAAe,8BAExB,OAAS,eAAAC,MAAmB,6BAC5B,OAAS,UAAAC,EAAQ,aAAAC,EAAW,YAAAC,MAAgB,QAE5C,MAAMC,EAAgB,QAChBC,EAAgB,gBAEhBC,EAAiB,aAEVC,GAAuB,CAAC,CAAE,KAAAC,EAAM,cAAAC,CAAc,IAA0C,CACnG,KAAM,CACJ,mBAAAC,EAAqB,GACrB,UAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EACA,oBAAAC,CACF,EAAIN,GAAiB,CAAC,EAChB,CAAE,OAAAO,EAAS,KAAM,YAAAC,CAAY,EAAI3B,EAAe,EAChD,CAAE,UAAA4B,CAAU,EAAIN,GAAc,CAAC,EAC/BO,EAAMlB,EAAuB,IAAI,EACjC,CAACmB,EAAUC,CAAW,EAAIlB,EAAmB,CAAC,CAAC,EAC/C,CAACmB,EAAiBC,CAAkB,EAAIpB,EAAiB,EAAE,EAE3DqB,EAAkB,CAACC,EAA0BC,EAAelB,IAChEC,GAAe,OAAO,gBAAgBgB,EAAQC,EAAQ,EAAGlB,CAAI,EAEzDmB,EAAoB,CAACF,EAA0BC,EAAelB,IAClEC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ACxE,UAAW;AAAA,gBACXA,EAAc,YAAc,WAAa,SAAW,EAAE;AAAA,cAGrD,SAAAA,GAAe,eAAiB,GACnC,EACE,MACN,GACF,GACF,GAjHKD,GAAM,IAAMA,GAAM,MAkHzB,CAEJ",
6
6
  "names": ["Fragment", "jsx", "jsxs", "useAiuiContext", "formatVariantPrice", "Picture", "Badge", "cn", "Text", "Button", "gaTrack", "trackUrlRef", "Heading", "useExposure", "useRef", "useEffect", "useState", "componentType", "componentName", "SOLD_OUT_PRICE", "ShelfDisplayWrapItem", "data", "configuration", "isDisplayBackImage", "itemShape", "metafields", "isTopTag", "isShowTag", "isShowOriginalPrice", "locale", "copyWriting", "discounts", "ref", "showTags", "setShowTags", "currentPriceTag", "setCurrentPriceTag", "onPrimaryButton", "params", "index", "onSecondaryButton", "variant", "item", "isSoldOut", "coupon", "price", "basePrice", "discount", "handleUrl", "sku", "skuArray", "displayTitle", "displayDescription", "handleTags", "discountTag", "newTags", "bottomContent", "ShelfDisplayHorizontalItem", "itemLength", "showSizeClass", "handleWrapClass"]
7
7
  }
@@ -0,0 +1,45 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type UseExposureDetectionOptions } from '../hooks/useExposureDetection.js';
3
+ export interface ExposureDetectorProps extends Omit<UseExposureDetectionOptions, 'onExposure'> {
4
+ /**
5
+ * 子元素
6
+ */
7
+ children: ReactNode;
8
+ /**
9
+ * 曝光回调函数
10
+ */
11
+ onExposure?: () => void;
12
+ /**
13
+ * 包装元素的标签,默认 'div'
14
+ */
15
+ as?: keyof JSX.IntrinsicElements;
16
+ /**
17
+ * 包装元素的 className
18
+ */
19
+ className?: string;
20
+ /**
21
+ * 包装元素的 style
22
+ */
23
+ style?: React.CSSProperties;
24
+ }
25
+ /**
26
+ * 曝光检测组件
27
+ * 使用 IntersectionObserver 检测子元素是否至少 50% 可见且停留时间超过指定时间
28
+ * 确保在整个页面生命周期中只曝光一次
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * <ExposureDetector
33
+ * exposureKey="my-component-1"
34
+ * threshold={0.5}
35
+ * duration={2000}
36
+ * onExposure={() => {
37
+ * console.log('元素已曝光')
38
+ * }}
39
+ * >
40
+ * <div>内容</div>
41
+ * </ExposureDetector>
42
+ * ```
43
+ */
44
+ export declare const ExposureDetector: React.FC<ExposureDetectorProps>;
45
+ export default ExposureDetector;
@@ -0,0 +1,2 @@
1
+ import E,{useRef as l}from"react";import{useExposureDetection as m}from"../hooks/useExposureDetection.js";const f=({children:t,onExposure:o,exposureKey:r,threshold:s=.5,duration:n=2e3,once:p=!0,rootMargin:c="0px",as:i="div",className:u,style:x,...a})=>{const e=l(null);return m(e,{exposureKey:r,threshold:s,duration:n,once:p,onExposure:o,rootMargin:c}),E.createElement(i,{ref:e,className:u,style:x,...a},t)};var D=f;export{f as ExposureDetector,D as default};
2
+ //# sourceMappingURL=ExposureDetector.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ExposureDetector.tsx"],
4
+ "sourcesContent": ["import React, { useRef, type ReactNode } from 'react'\nimport { useExposureDetection, type UseExposureDetectionOptions } from '../hooks/useExposureDetection.js'\n\nexport interface ExposureDetectorProps extends Omit<UseExposureDetectionOptions, 'onExposure'> {\n /**\n * \u5B50\u5143\u7D20\n */\n children: ReactNode\n /**\n * \u66DD\u5149\u56DE\u8C03\u51FD\u6570\n */\n onExposure?: () => void\n /**\n * \u5305\u88C5\u5143\u7D20\u7684\u6807\u7B7E\uFF0C\u9ED8\u8BA4 'div'\n */\n as?: keyof JSX.IntrinsicElements\n /**\n * \u5305\u88C5\u5143\u7D20\u7684 className\n */\n className?: string\n /**\n * \u5305\u88C5\u5143\u7D20\u7684 style\n */\n style?: React.CSSProperties\n}\n\n/**\n * \u66DD\u5149\u68C0\u6D4B\u7EC4\u4EF6\n * \u4F7F\u7528 IntersectionObserver \u68C0\u6D4B\u5B50\u5143\u7D20\u662F\u5426\u81F3\u5C11 50% \u53EF\u89C1\u4E14\u505C\u7559\u65F6\u95F4\u8D85\u8FC7\u6307\u5B9A\u65F6\u95F4\n * \u786E\u4FDD\u5728\u6574\u4E2A\u9875\u9762\u751F\u547D\u5468\u671F\u4E2D\u53EA\u66DD\u5149\u4E00\u6B21\n *\n * @example\n * ```tsx\n * <ExposureDetector\n * exposureKey=\"my-component-1\"\n * threshold={0.5}\n * duration={2000}\n * onExposure={() => {\n * console.log('\u5143\u7D20\u5DF2\u66DD\u5149')\n * }}\n * >\n * <div>\u5185\u5BB9</div>\n * </ExposureDetector>\n * ```\n */\nexport const ExposureDetector: React.FC<ExposureDetectorProps> = ({\n children,\n onExposure,\n exposureKey,\n threshold = 0.5,\n duration = 2000,\n once = true,\n rootMargin = '0px',\n as: Component = 'div',\n className,\n style,\n ...rest\n}) => {\n const elementRef = useRef<HTMLElement>(null)\n\n useExposureDetection(elementRef, {\n exposureKey,\n threshold,\n duration,\n once,\n onExposure,\n rootMargin,\n })\n\n return React.createElement(\n Component,\n {\n ref: elementRef,\n className,\n style,\n ...rest,\n },\n children\n )\n}\n\nexport default ExposureDetector\n\n"],
5
+ "mappings": "AAAA,OAAOA,GAAS,UAAAC,MAA8B,QAC9C,OAAS,wBAAAC,MAA8D,mCA4ChE,MAAMC,EAAoD,CAAC,CAChE,SAAAC,EACA,WAAAC,EACA,YAAAC,EACA,UAAAC,EAAY,GACZ,SAAAC,EAAW,IACX,KAAAC,EAAO,GACP,WAAAC,EAAa,MACb,GAAIC,EAAY,MAChB,UAAAC,EACA,MAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAAad,EAAoB,IAAI,EAE3C,OAAAC,EAAqBa,EAAY,CAC/B,YAAAT,EACA,UAAAC,EACA,SAAAC,EACA,KAAAC,EACA,WAAAJ,EACA,WAAAK,CACF,CAAC,EAEMV,EAAM,cACXW,EACA,CACE,IAAKI,EACL,UAAAH,EACA,MAAAC,EACA,GAAGC,CACL,EACAV,CACF,CACF,EAEA,IAAOY,EAAQb",
6
+ "names": ["React", "useRef", "useExposureDetection", "ExposureDetector", "children", "onExposure", "exposureKey", "threshold", "duration", "once", "rootMargin", "Component", "className", "style", "rest", "elementRef", "ExposureDetector_default"]
7
+ }
@@ -25,3 +25,4 @@ export { default as Theme } from './theme.js';
25
25
  export { default as Board } from './board.js';
26
26
  export { default as LoadingDots } from './loadingDots.js';
27
27
  export { default as Breadcrumb } from './breadcrumb.js';
28
+ export { ExposureDetector, type ExposureDetectorProps } from './ExposureDetector.js';
@@ -1,2 +1,2 @@
1
- import{default as e}from"./button.js";import{default as a}from"./badge.js";import{Input as n,InputSlot as u}from"./input.js";import{default as i}from"./checkbox.js";import{default as m}from"./skeleton.js";import{Dialog as D,DialogPortal as f,DialogOverlay as x,DialogClose as C,DialogTrigger as g,DialogContent as w,DialogHeader as P,DialogFooter as T,DialogTitle as M,DialogDescription as b}from"./dialog.js";import{Popover as I,PopoverTrigger as c,PopoverContent as G}from"./popover.js";import{RadioGroup as A,RadioGroupItem as S}from"./radio.js";import{Text as R}from"./text.js";import{Grid as L,GridItem as h}from"./gird.js";import{Heading as F}from"./heading.js";import{Container as O}from"./container.js";import{Color as q}from"./color.js";import{Drawer as E,DrawerPortal as J,DrawerOverlay as K,DrawerTrigger as Q,DrawerClose as U,DrawerContent as V,DrawerHeader as W,DrawerFooter as X,DrawerTitle as Y,DrawerDescription as Z}from"./drawer.js";import{default as $}from"./link.js";import{Avatar as or,AvatarImage as er,AvatarFallback as tr}from"./avatar.js";import{default as pr}from"./input-number.js";import{DropdownMenu as ur,DropdownMenuTrigger as dr,DropdownMenuContent as ir,DropdownMenuItem as lr,DropdownMenuCheckboxItem as mr,DropdownMenuRadioItem as sr,DropdownMenuLabel as Dr,DropdownMenuSeparator as fr,DropdownMenuShortcut as xr,DropdownMenuGroup as Cr,DropdownMenuPortal as gr,DropdownMenuSub as wr,DropdownMenuSubContent as Pr,DropdownMenuSubTrigger as Tr,DropdownMenuRadioGroup as Mr}from"./drop-down.js";import{Card as yr,CardHeader as Ir,CardFooter as cr,CardTitle as Gr,CardDescription as vr,CardContent as Ar}from"./card.js";import{Carousel as kr,CarouselContent as Rr,CarouselItem as Hr,CarouselPrevious as Lr,CarouselNext as hr}from"./carousel.js";import{Tabs as Fr,TabsList as Nr,TabsTrigger as Or,TabsContent as jr}from"./tabs.js";import{Alert as zr,AlertTitle as Er,AlertDescription as Jr}from"./alert.js";import{default as Qr}from"./picture.js";import{default as Vr}from"./theme.js";import{default as Xr}from"./board.js";import{default as Zr}from"./loadingDots.js";import{default as $r}from"./breadcrumb.js";export{zr as Alert,Jr as AlertDescription,Er as AlertTitle,or as Avatar,tr as AvatarFallback,er as AvatarImage,a as Badge,Xr as Board,$r as Breadcrumb,e as Button,yr as Card,Ar as CardContent,vr as CardDescription,cr as CardFooter,Ir as CardHeader,Gr as CardTitle,kr as Carousel,Rr as CarouselContent,Hr as CarouselItem,hr as CarouselNext,Lr as CarouselPrevious,i as Checkbox,q as Color,O as Container,D as Dialog,C as DialogClose,w as DialogContent,b as DialogDescription,T as DialogFooter,P as DialogHeader,x as DialogOverlay,f as DialogPortal,M as DialogTitle,g as DialogTrigger,E as Drawer,U as DrawerClose,V as DrawerContent,Z as DrawerDescription,X as DrawerFooter,W as DrawerHeader,K as DrawerOverlay,J as DrawerPortal,Y as DrawerTitle,Q as DrawerTrigger,ur as DropdownMenu,mr as DropdownMenuCheckboxItem,ir as DropdownMenuContent,Cr as DropdownMenuGroup,lr as DropdownMenuItem,Dr as DropdownMenuLabel,gr as DropdownMenuPortal,Mr as DropdownMenuRadioGroup,sr as DropdownMenuRadioItem,fr as DropdownMenuSeparator,xr as DropdownMenuShortcut,wr as DropdownMenuSub,Pr as DropdownMenuSubContent,Tr as DropdownMenuSubTrigger,dr as DropdownMenuTrigger,L as Grid,h as GridItem,F as Heading,n as Input,pr as InputNumber,u as InputSlot,$ as Link,Zr as LoadingDots,Qr as Picture,I as Popover,G as PopoverContent,c as PopoverTrigger,A as RadioGroup,S as RadioGroupItem,m as Skeleton,Fr as Tabs,jr as TabsContent,Nr as TabsList,Or as TabsTrigger,R as Text,Vr as Theme};
1
+ import{default as e}from"./button.js";import{default as a}from"./badge.js";import{Input as n,InputSlot as u}from"./input.js";import{default as i}from"./checkbox.js";import{default as s}from"./skeleton.js";import{Dialog as m,DialogPortal as f,DialogOverlay as x,DialogClose as C,DialogTrigger as g,DialogContent as w,DialogHeader as P,DialogFooter as T,DialogTitle as M,DialogDescription as b}from"./dialog.js";import{Popover as I,PopoverTrigger as c,PopoverContent as G}from"./popover.js";import{RadioGroup as A,RadioGroupItem as S}from"./radio.js";import{Text as R}from"./text.js";import{Grid as L,GridItem as h}from"./gird.js";import{Heading as F}from"./heading.js";import{Container as E}from"./container.js";import{Color as j}from"./color.js";import{Drawer as z,DrawerPortal as J,DrawerOverlay as K,DrawerTrigger as Q,DrawerClose as U,DrawerContent as V,DrawerHeader as W,DrawerFooter as X,DrawerTitle as Y,DrawerDescription as Z}from"./drawer.js";import{default as $}from"./link.js";import{Avatar as or,AvatarImage as er,AvatarFallback as tr}from"./avatar.js";import{default as pr}from"./input-number.js";import{DropdownMenu as ur,DropdownMenuTrigger as dr,DropdownMenuContent as ir,DropdownMenuItem as lr,DropdownMenuCheckboxItem as sr,DropdownMenuRadioItem as Dr,DropdownMenuLabel as mr,DropdownMenuSeparator as fr,DropdownMenuShortcut as xr,DropdownMenuGroup as Cr,DropdownMenuPortal as gr,DropdownMenuSub as wr,DropdownMenuSubContent as Pr,DropdownMenuSubTrigger as Tr,DropdownMenuRadioGroup as Mr}from"./drop-down.js";import{Card as yr,CardHeader as Ir,CardFooter as cr,CardTitle as Gr,CardDescription as vr,CardContent as Ar}from"./card.js";import{Carousel as kr,CarouselContent as Rr,CarouselItem as Hr,CarouselPrevious as Lr,CarouselNext as hr}from"./carousel.js";import{Tabs as Fr,TabsList as Nr,TabsTrigger as Er,TabsContent as Or}from"./tabs.js";import{Alert as qr,AlertTitle as zr,AlertDescription as Jr}from"./alert.js";import{default as Qr}from"./picture.js";import{default as Vr}from"./theme.js";import{default as Xr}from"./board.js";import{default as Zr}from"./loadingDots.js";import{default as $r}from"./breadcrumb.js";import{ExposureDetector as oo}from"./ExposureDetector.js";export{qr as Alert,Jr as AlertDescription,zr as AlertTitle,or as Avatar,tr as AvatarFallback,er as AvatarImage,a as Badge,Xr as Board,$r as Breadcrumb,e as Button,yr as Card,Ar as CardContent,vr as CardDescription,cr as CardFooter,Ir as CardHeader,Gr as CardTitle,kr as Carousel,Rr as CarouselContent,Hr as CarouselItem,hr as CarouselNext,Lr as CarouselPrevious,i as Checkbox,j as Color,E as Container,m as Dialog,C as DialogClose,w as DialogContent,b as DialogDescription,T as DialogFooter,P as DialogHeader,x as DialogOverlay,f as DialogPortal,M as DialogTitle,g as DialogTrigger,z as Drawer,U as DrawerClose,V as DrawerContent,Z as DrawerDescription,X as DrawerFooter,W as DrawerHeader,K as DrawerOverlay,J as DrawerPortal,Y as DrawerTitle,Q as DrawerTrigger,ur as DropdownMenu,sr as DropdownMenuCheckboxItem,ir as DropdownMenuContent,Cr as DropdownMenuGroup,lr as DropdownMenuItem,mr as DropdownMenuLabel,gr as DropdownMenuPortal,Mr as DropdownMenuRadioGroup,Dr as DropdownMenuRadioItem,fr as DropdownMenuSeparator,xr as DropdownMenuShortcut,wr as DropdownMenuSub,Pr as DropdownMenuSubContent,Tr as DropdownMenuSubTrigger,dr as DropdownMenuTrigger,oo as ExposureDetector,L as Grid,h as GridItem,F as Heading,n as Input,pr as InputNumber,u as InputSlot,$ as Link,Zr as LoadingDots,Qr as Picture,I as Popover,G as PopoverContent,c as PopoverTrigger,A as RadioGroup,S as RadioGroupItem,s as Skeleton,Fr as Tabs,Or as TabsContent,Nr as TabsList,Er as TabsTrigger,R as Text,Vr as Theme};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/index.ts"],
4
- "sourcesContent": ["export { default as Button } from './button.js'\nexport { default as Badge } from './badge.js'\nexport { Input, InputSlot } from './input.js'\n\nexport { default as Checkbox } from './checkbox.js'\n\nexport { default as Skeleton } from './skeleton.js'\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n} from './dialog.js'\nexport { Popover, PopoverTrigger, PopoverContent } from './popover.js'\nexport { RadioGroup, RadioGroupItem, type RadioGroupProps, type RadioGroupItemProps } from './radio.js'\nexport { Text, type TextProps } from './text.js'\nexport { Grid, GridItem, type GridProps, type GridItemProps } from './gird.js'\nexport { Heading, type HeadingProps } from './heading.js'\nexport { Container, type ContainerProps } from './container.js'\nexport { Color, type ColorProps } from './color.js'\nexport {\n Drawer,\n DrawerPortal,\n DrawerOverlay,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerHeader,\n DrawerFooter,\n DrawerTitle,\n DrawerDescription,\n} from './drawer.js'\nexport { default as Link, type LinkProps } from './link.js'\nexport { Avatar, AvatarImage, AvatarFallback } from './avatar.js'\nexport { default as InputNumber, type InputNumberProps } from './input-number.js'\nexport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuRadioGroup,\n} from './drop-down.js'\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from './card.js'\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n} from './carousel.js'\nexport { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs.js'\nexport { Alert, AlertTitle, AlertDescription } from './alert.js'\nexport { default as Picture } from './picture.js'\nexport { default as Theme } from './theme.js'\nexport { default as Board } from './board.js'\nexport { default as LoadingDots } from './loadingDots.js'\nexport { default as Breadcrumb } from './breadcrumb.js'\n"],
5
- "mappings": "AAAA,OAAoB,WAAXA,MAAyB,cAClC,OAAoB,WAAXA,MAAwB,aACjC,OAAS,SAAAC,EAAO,aAAAC,MAAiB,aAEjC,OAAoB,WAAXF,MAA2B,gBAEpC,OAAoB,WAAXA,MAA2B,gBACpC,OACE,UAAAG,EACA,gBAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,qBAAAC,MACK,cACP,OAAS,WAAAC,EAAS,kBAAAC,EAAgB,kBAAAC,MAAsB,eACxD,OAAS,cAAAC,EAAY,kBAAAC,MAAsE,aAC3F,OAAS,QAAAC,MAA4B,YACrC,OAAS,QAAAC,EAAM,YAAAC,MAAoD,YACnE,OAAS,WAAAC,MAAkC,eAC3C,OAAS,aAAAC,MAAsC,iBAC/C,OAAS,SAAAC,MAA8B,aACvC,OACE,UAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,qBAAAC,MACK,cACP,OAAoB,WAAXjC,MAAuC,YAChD,OAAS,UAAAkC,GAAQ,eAAAC,GAAa,kBAAAC,OAAsB,cACpD,OAAoB,WAAXpC,OAAqD,oBAC9D,OACE,gBAAAqC,GACA,uBAAAC,GACA,uBAAAC,GACA,oBAAAC,GACA,4BAAAC,GACA,yBAAAC,GACA,qBAAAC,GACA,yBAAAC,GACA,wBAAAC,GACA,qBAAAC,GACA,sBAAAC,GACA,mBAAAC,GACA,0BAAAC,GACA,0BAAAC,GACA,0BAAAC,OACK,iBACP,OAAS,QAAAC,GAAM,cAAAC,GAAY,cAAAC,GAAY,aAAAC,GAAW,mBAAAC,GAAiB,eAAAC,OAAmB,YACtF,OAEE,YAAAC,GACA,mBAAAC,GACA,gBAAAC,GACA,oBAAAC,GACA,gBAAAC,OACK,gBACP,OAAS,QAAAC,GAAM,YAAAC,GAAU,eAAAC,GAAa,eAAAC,OAAmB,YACzD,OAAS,SAAAC,GAAO,cAAAC,GAAY,oBAAAC,OAAwB,aACpD,OAAoB,WAAXrE,OAA0B,eACnC,OAAoB,WAAXA,OAAwB,aACjC,OAAoB,WAAXA,OAAwB,aACjC,OAAoB,WAAXA,OAA8B,mBACvC,OAAoB,WAAXA,OAA6B",
6
- "names": ["default", "Input", "InputSlot", "Dialog", "DialogPortal", "DialogOverlay", "DialogClose", "DialogTrigger", "DialogContent", "DialogHeader", "DialogFooter", "DialogTitle", "DialogDescription", "Popover", "PopoverTrigger", "PopoverContent", "RadioGroup", "RadioGroupItem", "Text", "Grid", "GridItem", "Heading", "Container", "Color", "Drawer", "DrawerPortal", "DrawerOverlay", "DrawerTrigger", "DrawerClose", "DrawerContent", "DrawerHeader", "DrawerFooter", "DrawerTitle", "DrawerDescription", "Avatar", "AvatarImage", "AvatarFallback", "DropdownMenu", "DropdownMenuTrigger", "DropdownMenuContent", "DropdownMenuItem", "DropdownMenuCheckboxItem", "DropdownMenuRadioItem", "DropdownMenuLabel", "DropdownMenuSeparator", "DropdownMenuShortcut", "DropdownMenuGroup", "DropdownMenuPortal", "DropdownMenuSub", "DropdownMenuSubContent", "DropdownMenuSubTrigger", "DropdownMenuRadioGroup", "Card", "CardHeader", "CardFooter", "CardTitle", "CardDescription", "CardContent", "Carousel", "CarouselContent", "CarouselItem", "CarouselPrevious", "CarouselNext", "Tabs", "TabsList", "TabsTrigger", "TabsContent", "Alert", "AlertTitle", "AlertDescription"]
4
+ "sourcesContent": ["export { default as Button } from './button.js'\nexport { default as Badge } from './badge.js'\nexport { Input, InputSlot } from './input.js'\n\nexport { default as Checkbox } from './checkbox.js'\n\nexport { default as Skeleton } from './skeleton.js'\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n} from './dialog.js'\nexport { Popover, PopoverTrigger, PopoverContent } from './popover.js'\nexport { RadioGroup, RadioGroupItem, type RadioGroupProps, type RadioGroupItemProps } from './radio.js'\nexport { Text, type TextProps } from './text.js'\nexport { Grid, GridItem, type GridProps, type GridItemProps } from './gird.js'\nexport { Heading, type HeadingProps } from './heading.js'\nexport { Container, type ContainerProps } from './container.js'\nexport { Color, type ColorProps } from './color.js'\nexport {\n Drawer,\n DrawerPortal,\n DrawerOverlay,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerHeader,\n DrawerFooter,\n DrawerTitle,\n DrawerDescription,\n} from './drawer.js'\nexport { default as Link, type LinkProps } from './link.js'\nexport { Avatar, AvatarImage, AvatarFallback } from './avatar.js'\nexport { default as InputNumber, type InputNumberProps } from './input-number.js'\nexport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuRadioGroup,\n} from './drop-down.js'\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from './card.js'\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n} from './carousel.js'\nexport { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs.js'\nexport { Alert, AlertTitle, AlertDescription } from './alert.js'\nexport { default as Picture } from './picture.js'\nexport { default as Theme } from './theme.js'\nexport { default as Board } from './board.js'\nexport { default as LoadingDots } from './loadingDots.js'\nexport { default as Breadcrumb } from './breadcrumb.js'\nexport { ExposureDetector, type ExposureDetectorProps } from './ExposureDetector.js'\n"],
5
+ "mappings": "AAAA,OAAoB,WAAXA,MAAyB,cA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C,GAAO,cAAAC,GAAY,oBAAAC,OAAwB,aACpD,OAAoB,WAAXrE,OAA0B,eACnC,OAAoB,WAAXA,OAAwB,aACjC,OAAoB,WAAXA,OAAwB,aACjC,OAAoB,WAAXA,OAA8B,mBACvC,OAAoB,WAAXA,OAA6B,kBACtC,OAAS,oBAAAsE,OAAoD",
6
+ "names": ["default", "Input", "InputSlot", "Dialog", "DialogPortal", "DialogOverlay", "DialogClose", "DialogTrigger", "DialogContent", "DialogHeader", "DialogFooter", "DialogTitle", "DialogDescription", "Popover", "PopoverTrigger", "PopoverContent", "RadioGroup", "RadioGroupItem", "Text", "Grid", "GridItem", "Heading", "Container", "Color", "Drawer", "DrawerPortal", "DrawerOverlay", "DrawerTrigger", "DrawerClose", "DrawerContent", "DrawerHeader", "DrawerFooter", "DrawerTitle", "DrawerDescription", "Avatar", "AvatarImage", "AvatarFallback", "DropdownMenu", "DropdownMenuTrigger", "DropdownMenuContent", "DropdownMenuItem", "DropdownMenuCheckboxItem", "DropdownMenuRadioItem", "DropdownMenuLabel", "DropdownMenuSeparator", "DropdownMenuShortcut", "DropdownMenuGroup", "DropdownMenuPortal", "DropdownMenuSub", "DropdownMenuSubContent", "DropdownMenuSubTrigger", "DropdownMenuRadioGroup", "Card", "CardHeader", "CardFooter", "CardTitle", "CardDescription", "CardContent", "Carousel", "CarouselContent", "CarouselItem", "CarouselPrevious", "CarouselNext", "Tabs", "TabsList", "TabsTrigger", "TabsContent", "Alert", "AlertTitle", "AlertDescription", "ExposureDetector"]
7
7
  }
@@ -0,0 +1,69 @@
1
+ import { type RefObject } from 'react';
2
+ export interface UseExposureDetectionOptions {
3
+ /**
4
+ * 唯一标识,用于判断是否已曝光
5
+ * 如果不提供,将使用元素的唯一标识(如果可能)
6
+ */
7
+ exposureKey?: string;
8
+ /**
9
+ * 可见性阈值,0-1 之间,默认 0.5(50%)
10
+ */
11
+ threshold?: number;
12
+ /**
13
+ * 停留时间(毫秒),默认 2000ms
14
+ */
15
+ duration?: number;
16
+ /**
17
+ * 是否只触发一次,默认 true
18
+ */
19
+ once?: boolean;
20
+ /**
21
+ * 曝光回调函数
22
+ */
23
+ onExposure?: () => void;
24
+ /**
25
+ * IntersectionObserver 的 rootMargin
26
+ */
27
+ rootMargin?: string;
28
+ }
29
+ /**
30
+ * 曝光检测 Hook
31
+ * 使用 IntersectionObserver 检测元素是否至少 50% 可见且停留时间超过指定时间
32
+ * 确保在整个页面生命周期中只曝光一次
33
+ *
34
+ * @param elementRef - 要检测的元素的 ref
35
+ * @param options - 配置选项
36
+ * @returns 返回清除计时器的方法(用于切换时清理)
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * const MyComponent = () => {
41
+ * const ref = useRef<HTMLDivElement>(null)
42
+ * const { clearTimer } = useExposureDetection(ref, {
43
+ * exposureKey: 'my-component-1',
44
+ * threshold: 0.5,
45
+ * duration: 2000,
46
+ * onExposure: () => {
47
+ * console.log('元素已曝光')
48
+ * }
49
+ * })
50
+ *
51
+ * return <div ref={ref}>内容</div>
52
+ * }
53
+ * ```
54
+ */
55
+ export declare const useExposureDetection: (elementRef: RefObject<HTMLElement>, options?: UseExposureDetectionOptions) => {
56
+ clearTimer: () => void;
57
+ };
58
+ /**
59
+ * 清除指定 key 的曝光记录(用于测试或特殊场景)
60
+ */
61
+ export declare const clearExposureRecord: (key: string) => void;
62
+ /**
63
+ * 清除所有曝光记录(用于测试或特殊场景)
64
+ */
65
+ export declare const clearAllExposureRecords: () => void;
66
+ /**
67
+ * 检查指定 key 是否已曝光
68
+ */
69
+ export declare const hasExposed: (key: string) => boolean;
@@ -0,0 +1,2 @@
1
+ import{useRef as E,useEffect as y,useCallback as h}from"react";const o=new Set,K=(r,m={})=>{const{exposureKey:i,threshold:l=.5,duration:d=2e3,once:s=!0,onExposure:a,rootMargin:x="0px"}=m,e=E(null),c=E(null),f=h(()=>{if(i)return i;if(r.current&&!c.current){const u=r.current.getAttribute("data-exposure-id");if(u)return c.current=u,u;const n=[];let t=r.current;for(;t&&t!==document.body;){const p=Array.from(t.parentElement?.children||[]).indexOf(t);n.unshift(`${t.tagName.toLowerCase()}[${p}]`),t=t.parentElement}return c.current=n.join(" > "),c.current}return c.current||""},[i,r]),g=h(()=>{e.current&&(clearTimeout(e.current),e.current=null)},[]);return y(()=>{const u=r.current;if(!u||!a)return;const n=f();if(!n){console.warn("useExposureDetection: \u65E0\u6CD5\u751F\u6210\u552F\u4E00\u7684 exposureKey\uFF0C\u8BF7\u63D0\u4F9B exposureKey \u53C2\u6570");return}if(s&&o.has(n))return;const t=new IntersectionObserver(p=>{p.forEach(b=>{b.intersectionRatio>=l?(!s||!o.has(n))&&!e.current&&(e.current=setTimeout(()=>{s&&o.has(n)||(s&&o.add(n),a())},d)):e.current&&(clearTimeout(e.current),e.current=null)})},{threshold:l,rootMargin:x});return t.observe(u),()=>{t.disconnect(),e.current&&(clearTimeout(e.current),e.current=null)}},[r,a,l,d,s,x,f]),{clearTimer:g}},O=r=>{o.delete(r)},w=()=>{o.clear()},v=r=>o.has(r);export{w as clearAllExposureRecords,O as clearExposureRecord,v as hasExposed,K as useExposureDetection};
2
+ //# sourceMappingURL=useExposureDetection.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/useExposureDetection.ts"],
4
+ "sourcesContent": ["import { type RefObject, useRef, useEffect, useCallback } from 'react'\n\n// \u5168\u5C40\u66DD\u5149\u8BB0\u5F55\uFF0C\u786E\u4FDD\u6BCF\u4E2A\u5143\u7D20\u5728\u6574\u4E2A\u9875\u9762\u751F\u547D\u5468\u671F\u4E2D\u53EA\u66DD\u5149\u4E00\u6B21\nconst exposedElementsSet = new Set<string>()\n\nexport interface UseExposureDetectionOptions {\n /**\n * \u552F\u4E00\u6807\u8BC6\uFF0C\u7528\u4E8E\u5224\u65AD\u662F\u5426\u5DF2\u66DD\u5149\n * \u5982\u679C\u4E0D\u63D0\u4F9B\uFF0C\u5C06\u4F7F\u7528\u5143\u7D20\u7684\u552F\u4E00\u6807\u8BC6\uFF08\u5982\u679C\u53EF\u80FD\uFF09\n */\n exposureKey?: string\n /**\n * \u53EF\u89C1\u6027\u9608\u503C\uFF0C0-1 \u4E4B\u95F4\uFF0C\u9ED8\u8BA4 0.5\uFF0850%\uFF09\n */\n threshold?: number\n /**\n * \u505C\u7559\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 2000ms\n */\n duration?: number\n /**\n * \u662F\u5426\u53EA\u89E6\u53D1\u4E00\u6B21\uFF0C\u9ED8\u8BA4 true\n */\n once?: boolean\n /**\n * \u66DD\u5149\u56DE\u8C03\u51FD\u6570\n */\n onExposure?: () => void\n /**\n * IntersectionObserver \u7684 rootMargin\n */\n rootMargin?: string\n}\n\n/**\n * \u66DD\u5149\u68C0\u6D4B Hook\n * \u4F7F\u7528 IntersectionObserver \u68C0\u6D4B\u5143\u7D20\u662F\u5426\u81F3\u5C11 50% \u53EF\u89C1\u4E14\u505C\u7559\u65F6\u95F4\u8D85\u8FC7\u6307\u5B9A\u65F6\u95F4\n * \u786E\u4FDD\u5728\u6574\u4E2A\u9875\u9762\u751F\u547D\u5468\u671F\u4E2D\u53EA\u66DD\u5149\u4E00\u6B21\n *\n * @param elementRef - \u8981\u68C0\u6D4B\u7684\u5143\u7D20\u7684 ref\n * @param options - \u914D\u7F6E\u9009\u9879\n * @returns \u8FD4\u56DE\u6E05\u9664\u8BA1\u65F6\u5668\u7684\u65B9\u6CD5\uFF08\u7528\u4E8E\u5207\u6362\u65F6\u6E05\u7406\uFF09\n *\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = useRef<HTMLDivElement>(null)\n * const { clearTimer } = useExposureDetection(ref, {\n * exposureKey: 'my-component-1',\n * threshold: 0.5,\n * duration: 2000,\n * onExposure: () => {\n * console.log('\u5143\u7D20\u5DF2\u66DD\u5149')\n * }\n * })\n *\n * return <div ref={ref}>\u5185\u5BB9</div>\n * }\n * ```\n */\nexport const useExposureDetection = (\n elementRef: RefObject<HTMLElement>,\n options: UseExposureDetectionOptions = {}\n) => {\n const {\n exposureKey,\n threshold = 0.5,\n duration = 2000,\n once = true,\n onExposure,\n rootMargin = '0px',\n } = options\n\n const exposureTimerRef = useRef<NodeJS.Timeout | null>(null)\n const generatedKeyRef = useRef<string | null>(null)\n\n // \u751F\u6210\u552F\u4E00\u7684\u66DD\u5149 key\n const getExposureKey = useCallback(() => {\n if (exposureKey) {\n return exposureKey\n }\n // \u5982\u679C\u6CA1\u6709\u63D0\u4F9B key\uFF0C\u5C1D\u8BD5\u4F7F\u7528\u5143\u7D20\u7684\u552F\u4E00\u6807\u8BC6\n if (elementRef.current && !generatedKeyRef.current) {\n // \u4F7F\u7528\u5143\u7D20\u7684 data-exposure-id \u5C5E\u6027\uFF0C\u6216\u8005\u751F\u6210\u4E00\u4E2A\u57FA\u4E8E\u4F4D\u7F6E\u7684 key\n const dataId = elementRef.current.getAttribute('data-exposure-id')\n if (dataId) {\n generatedKeyRef.current = dataId\n return dataId\n }\n // \u5982\u679C\u6CA1\u6709 data-exposure-id\uFF0C\u4F7F\u7528\u5143\u7D20\u5728 DOM \u4E2D\u7684\u4F4D\u7F6E\u751F\u6210 key\n const path: string[] = []\n let el: Element | null = elementRef.current\n while (el && el !== document.body) {\n const index = Array.from(el.parentElement?.children || []).indexOf(el)\n path.unshift(`${el.tagName.toLowerCase()}[${index}]`)\n el = el.parentElement\n }\n generatedKeyRef.current = path.join(' > ')\n return generatedKeyRef.current\n }\n return generatedKeyRef.current || ''\n }, [exposureKey, elementRef])\n\n // \u6E05\u9664\u8BA1\u65F6\u5668\u7684\u65B9\u6CD5\uFF08\u4E0D\u91CD\u7F6E\u66DD\u5149\u72B6\u6001\uFF09\n const clearTimer = useCallback(() => {\n if (exposureTimerRef.current) {\n clearTimeout(exposureTimerRef.current)\n exposureTimerRef.current = null\n }\n }, [])\n\n useEffect(() => {\n const element = elementRef.current\n if (!element || !onExposure) return\n\n const key = getExposureKey()\n if (!key) {\n console.warn('useExposureDetection: \u65E0\u6CD5\u751F\u6210\u552F\u4E00\u7684 exposureKey\uFF0C\u8BF7\u63D0\u4F9B exposureKey \u53C2\u6570')\n return\n }\n\n // \u5982\u679C\u5DF2\u7ECF\u66DD\u5149\u8FC7\u4E14\u8BBE\u7F6E\u4E86 once\uFF0C\u76F4\u63A5\u8FD4\u56DE\uFF0C\u4E0D\u518D\u76D1\u542C\n if (once && exposedElementsSet.has(key)) {\n return\n }\n\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n // \u5982\u679C\u53EF\u89C1\u6027\u8FBE\u5230\u9608\u503C\uFF08\u9ED8\u8BA4 50%\uFF09\n if (entry.intersectionRatio >= threshold) {\n // \u5982\u679C\u8FD8\u6CA1\u6709\u89E6\u53D1\u8FC7\u66DD\u5149\u4E14\u6CA1\u6709\u6B63\u5728\u8BA1\u65F6\u7684\u8BA1\u65F6\u5668\uFF0C\u5F00\u59CB\u8BA1\u65F6\n if ((!once || !exposedElementsSet.has(key)) && !exposureTimerRef.current) {\n exposureTimerRef.current = setTimeout(() => {\n // \u518D\u6B21\u68C0\u67E5\u662F\u5426\u5DF2\u66DD\u5149\uFF08\u9632\u6B62\u5728\u8BA1\u65F6\u671F\u95F4\u88AB\u5176\u4ED6\u64CD\u4F5C\u89E6\u53D1\uFF09\n if (once && exposedElementsSet.has(key)) return\n\n // \u6807\u8BB0\u4E3A\u5DF2\u66DD\u5149\n if (once) {\n exposedElementsSet.add(key)\n }\n // \u89E6\u53D1\u66DD\u5149\u4E8B\u4EF6\n onExposure()\n }, duration)\n }\n } else {\n // \u5982\u679C\u53EF\u89C1\u6027\u4F4E\u4E8E\u9608\u503C\uFF0C\u6E05\u9664\u8BA1\u65F6\u5668\uFF08\u4F46\u4E0D\u79FB\u9664\u66DD\u5149\u6807\u8BB0\uFF09\n if (exposureTimerRef.current) {\n clearTimeout(exposureTimerRef.current)\n exposureTimerRef.current = null\n }\n }\n })\n },\n {\n threshold: threshold,\n rootMargin: rootMargin,\n }\n )\n\n observer.observe(element)\n\n return () => {\n observer.disconnect()\n if (exposureTimerRef.current) {\n clearTimeout(exposureTimerRef.current)\n exposureTimerRef.current = null\n }\n }\n }, [elementRef, onExposure, threshold, duration, once, rootMargin, getExposureKey])\n\n return { clearTimer }\n}\n\n/**\n * \u6E05\u9664\u6307\u5B9A key \u7684\u66DD\u5149\u8BB0\u5F55\uFF08\u7528\u4E8E\u6D4B\u8BD5\u6216\u7279\u6B8A\u573A\u666F\uFF09\n */\nexport const clearExposureRecord = (key: string) => {\n exposedElementsSet.delete(key)\n}\n\n/**\n * \u6E05\u9664\u6240\u6709\u66DD\u5149\u8BB0\u5F55\uFF08\u7528\u4E8E\u6D4B\u8BD5\u6216\u7279\u6B8A\u573A\u666F\uFF09\n */\nexport const clearAllExposureRecords = () => {\n exposedElementsSet.clear()\n}\n\n/**\n * \u68C0\u67E5\u6307\u5B9A key \u662F\u5426\u5DF2\u66DD\u5149\n */\nexport const hasExposed = (key: string): boolean => {\n return exposedElementsSet.has(key)\n}\n\n"],
5
+ "mappings": "AAAA,OAAyB,UAAAA,EAAQ,aAAAC,EAAW,eAAAC,MAAmB,QAG/D,MAAMC,EAAqB,IAAI,IAwDlBC,EAAuB,CAClCC,EACAC,EAAuC,CAAC,IACrC,CACH,KAAM,CACJ,YAAAC,EACA,UAAAC,EAAY,GACZ,SAAAC,EAAW,IACX,KAAAC,EAAO,GACP,WAAAC,EACA,WAAAC,EAAa,KACf,EAAIN,EAEEO,EAAmBb,EAA8B,IAAI,EACrDc,EAAkBd,EAAsB,IAAI,EAG5Ce,EAAiBb,EAAY,IAAM,CACvC,GAAIK,EACF,OAAOA,EAGT,GAAIF,EAAW,SAAW,CAACS,EAAgB,QAAS,CAElD,MAAME,EAASX,EAAW,QAAQ,aAAa,kBAAkB,EACjE,GAAIW,EACF,OAAAF,EAAgB,QAAUE,EACnBA,EAGT,MAAMC,EAAiB,CAAC,EACxB,IAAIC,EAAqBb,EAAW,QACpC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B,CACF,EAAG,CAACR,EAAYM,EAAYH,EAAWC,EAAUC,EAAME,EAAYG,CAAc,CAAC,EAE3E,CAAE,WAAAK,CAAW,CACtB,EAKaM,EAAuBJ,GAAgB,CAClDnB,EAAmB,OAAOmB,CAAG,CAC/B,EAKaK,EAA0B,IAAM,CAC3CxB,EAAmB,MAAM,CAC3B,EAKayB,EAAcN,GAClBnB,EAAmB,IAAImB,CAAG",
6
+ "names": ["useRef", "useEffect", "useCallback", "exposedElementsSet", "useExposureDetection", "elementRef", "options", "exposureKey", "threshold", "duration", "once", "onExposure", "rootMargin", "exposureTimerRef", "generatedKeyRef", "getExposureKey", "dataId", "path", "el", "index", "clearTimer", "element", "key", "observer", "entries", "entry", "clearExposureRecord", "clearAllExposureRecords", "hasExposed"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/headless-ui",
3
- "version": "1.0.26-alpha.1763109270406",
3
+ "version": "1.0.26-alpha.1763367560339",
4
4
  "type": "commonjs",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",