@yorkjs/hive-ui 2.3.1 → 2.3.3

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.1",
3
+ "version": "2.3.3",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -36,6 +36,7 @@ export interface IProductCardLabels {
36
36
  multiple_spec?: string
37
37
  barcode_label?: string
38
38
  spec_label?: string
39
+ remaining_label?: string
39
40
  sold_out?: string
40
41
  offline?: string
41
42
  }
@@ -88,6 +89,10 @@ export interface IProductCardProps {
88
89
  salePrice: string | number
89
90
  /** 原价 (划线价) */
90
91
  originalPrice?: string | number
92
+ /** 剩余次数(次卡独立权益等场景) */
93
+ remainingCount?: number | string
94
+ /** 剩余次数对应的总次数(与 remainingCount 组成 剩余/总数) */
95
+ remainingTotal?: number | string
91
96
  /** 已购数量 (显示为 xN) */
92
97
  buyCount?: number
93
98
  /** 是否显示左侧勾选框 */
@@ -135,6 +140,8 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
135
140
  salePricePrefix,
136
141
  salePrice,
137
142
  originalPrice,
143
+ remainingCount,
144
+ remainingTotal,
138
145
  buyCount,
139
146
  showSoldOut = false,
140
147
  showOffline = false,
@@ -260,6 +267,25 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
260
267
  )
261
268
  }, [stockCount, saleCount, labels])
262
269
 
270
+ const remainingElem = useMemo(() => {
271
+ if (remainingCount == null || remainingCount === '') return null
272
+ return (
273
+ <View className={styles['remaining-box']}>
274
+ <Text className={styles['info-text']}>{labels.remaining_label}</Text>
275
+ <Text className={styles['remaining-value']}>{remainingCount}</Text>
276
+ {
277
+ remainingTotal != null && remainingTotal !== ''
278
+ ? (
279
+ <Text className={styles['remaining-total']}>
280
+ /{remainingTotal}
281
+ </Text>
282
+ )
283
+ : undefined
284
+ }
285
+ </View>
286
+ )
287
+ }, [remainingCount, remainingTotal, labels])
288
+
263
289
  return (
264
290
  <View
265
291
  className={formatClassNames(
@@ -307,13 +333,15 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
307
333
  {productTypeTag}
308
334
  <Text className={styles['title']} style={{ WebkitLineClamp: titleMaxLines }}>{title}</Text>
309
335
  </View>
310
- {(showMultipleSpec || stockCount || saleCount || barcode) && (
336
+ {(showMultipleSpec || stockCount || saleCount || barcode || remainingElem) && (
311
337
  <ScrollView scrollX className={styles['second-row']} showScrollbar={false}>
312
338
  <View className={styles['second-row-inner']}>
313
339
  {showMultipleSpec && <Text className={styles['primary-text']}>{labels.multiple_spec}</Text>}
314
340
  {showMultipleSpec && stockAndSaleElem && <View className={styles['info-line']} />}
315
341
  {stockAndSaleElem}
316
- {((showMultipleSpec || stockAndSaleElem) && barcode) && <View className={styles['info-line']} />}
342
+ {(showMultipleSpec || stockAndSaleElem) && remainingElem && <View className={styles['info-line']} />}
343
+ {remainingElem}
344
+ {((showMultipleSpec || stockAndSaleElem || remainingElem) && barcode) && <View className={styles['info-line']} />}
317
345
  {barcode && <Text className={styles['info-text']}>{labels.barcode_label} {barcode}</Text>}
318
346
  </View>
319
347
  </ScrollView>
@@ -452,4 +480,4 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
452
480
  )
453
481
  }
454
482
 
455
- export default React.memo(ProductItem)
483
+ export default React.memo(ProductItem)
@@ -26,6 +26,7 @@ let globalLabels: IProductCardLabels = {
26
26
  multiple_spec: '多规格',
27
27
  barcode_label: '条码',
28
28
  spec_label: '规格',
29
+ remaining_label: '剩余次数',
29
30
  sold_out: '售罄',
30
31
  offline: '已下架'
31
32
  }
@@ -205,6 +205,20 @@ $F_BUY_COUNT = 14PX // RN 14
205
205
  margin-top 5PX
206
206
  lineClamp(1)
207
207
 
208
+ .remaining-box
209
+ display flex
210
+ flex-direction row
211
+ align-items center
212
+
213
+ .remaining-value
214
+ font-size $F_INFO
215
+ color var(--primary)
216
+ margin-left 5PX
217
+
218
+ .remaining-total
219
+ font-size $F_INFO
220
+ color var(--textTitle)
221
+
208
222
  .customization-text
209
223
  font-size $F_CUSTOM
210
224
  color var(--textMuted)
@@ -262,4 +276,4 @@ $F_BUY_COUNT = 14PX // RN 14
262
276
  color var(--textContent)
263
277
 
264
278
  .card-footer
265
- width 100%
279
+ width 100%