@yorkjs/hive-ui 2.3.5 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorkjs/hive-ui",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -49,6 +49,10 @@ export interface IProductCardProps {
49
49
  image: { url: string }
50
50
  /** 是否显示售罄标记 */
51
51
  showSoldOut?: boolean
52
+ /** 是否显图片上的遮罩 */
53
+ showImageOverlay?: boolean
54
+ /** 遮罩文案 */
55
+ imageOverlayText?: string
52
56
  /** 是否显示已下架标记 */
53
57
  showOffline?: boolean
54
58
  /** 商品标题 */
@@ -57,6 +61,8 @@ export interface IProductCardProps {
57
61
  titleMaxLines?: number
58
62
  /** 商品类型:实物/虚拟/服务 */
59
63
  productType?: number
64
+ /** 自定义商品类型 */
65
+ productTypeCustom?: { color: string; text: string, backgroundColor?: string }
60
66
  /** 是否显示“多规格”标签 */
61
67
  showMultipleSpec?: boolean
62
68
  /** 库存数量文案 */
@@ -124,6 +130,7 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
124
130
  title,
125
131
  titleMaxLines = 1,
126
132
  productType,
133
+ productTypeCustom,
127
134
  customTags,
128
135
  showMultipleSpec,
129
136
  stockCount,
@@ -144,6 +151,8 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
144
151
  remainingTotal,
145
152
  buyCount,
146
153
  showSoldOut = false,
154
+ showImageOverlay = false,
155
+ imageOverlayText = '',
147
156
  showOffline = false,
148
157
  showCheckbox = false,
149
158
  checkboxChecked = false,
@@ -159,6 +168,10 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
159
168
  children
160
169
  } = props
161
170
 
171
+ const isOverlayVisible = useMemo(() => {
172
+ return showSoldOut || showOffline || showImageOverlay
173
+ }, [showSoldOut, showOffline, showImageOverlay])
174
+
162
175
  const handleCardClick = (e: ITouchEvent) => {
163
176
  if (showCheckbox) {
164
177
  if (!checkboxDisabled) {
@@ -178,7 +191,27 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
178
191
  }, [])
179
192
 
180
193
  const productTypeTag = useMemo(() => {
181
- if (productType === undefined) return null
194
+
195
+ if (productTypeCustom) {
196
+ return (
197
+ <View className={styles['product-tag-container']}>
198
+ <Tag
199
+ type='light-warning'
200
+ text={productTypeCustom.text}
201
+ className="product-tag"
202
+ style={{
203
+ backgroundColor: productTypeCustom.backgroundColor,
204
+ color: productTypeCustom.color
205
+ }}
206
+ />
207
+ </View>
208
+ )
209
+ }
210
+
211
+ if (productType === undefined) {
212
+ return null
213
+ }
214
+
182
215
  const colorMap: Record<number, { color: string; text: string | undefined }> = {
183
216
  [MALL_PRODUCT_TYPE_REAL]: {
184
217
  color: 'var(--primary)',
@@ -209,7 +242,7 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
209
242
  />
210
243
  </View>
211
244
  )
212
- }, [productType, labels])
245
+ }, [productType, labels, productTypeCustom])
213
246
 
214
247
  const deliveryTags = useMemo(() => {
215
248
  if (isEmpty(deliveryTypes)) return null
@@ -319,10 +352,10 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
319
352
  className={styles['product-image']}
320
353
  mode='aspectFill'
321
354
  />
322
- {(showSoldOut || showOffline) && (
355
+ {isOverlayVisible && (
323
356
  <View className={styles['status-overlay']}>
324
357
  <Text className={styles['status-text']}>
325
- {showSoldOut ? labels.sold_out : labels.offline}
358
+ {showImageOverlay ? imageOverlayText : showSoldOut ? labels.sold_out : labels.offline}
326
359
  </Text>
327
360
  </View>
328
361
  )}