@yorkjs/hive-ui 2.2.9 → 2.3.2
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 +1 -1
- package/src/components/RichTextEditor/index.module.styl +4 -13
- package/src/components/RichTextEditor/index.tsx +7 -8
- package/src/components/Table/index.tsx +43 -10
- package/src/item/ProductItem/ProductItem.tsx +30 -0
- package/src/item/ProductItem/config.ts +1 -0
- package/src/item/ProductItem/index.module.styl +21 -0
package/package.json
CHANGED
|
@@ -22,20 +22,11 @@
|
|
|
22
22
|
position absolute
|
|
23
23
|
top -6PX
|
|
24
24
|
right -6PX
|
|
25
|
-
width 16PX
|
|
26
|
-
height 16PX
|
|
27
|
-
line-height 16PX
|
|
28
|
-
text-align center
|
|
29
|
-
border-radius 50%
|
|
30
25
|
z-index 2
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
left 50%
|
|
36
|
-
transform translate(-50%, -50%)
|
|
37
|
-
line-height 1
|
|
38
|
-
display block
|
|
26
|
+
width 17PX
|
|
27
|
+
height 17PX
|
|
28
|
+
line-height 1
|
|
29
|
+
flexHVCenter()
|
|
39
30
|
|
|
40
31
|
.text-block
|
|
41
32
|
background-color var(--containerCard)
|
|
@@ -97,9 +97,10 @@ const RichTextEditor: React.FC<RichTextEditorProps> = (props) => {
|
|
|
97
97
|
const textareaRefs = useRef<Record<number, any>>({})
|
|
98
98
|
const skipHeightSyncRef = useRef(false)
|
|
99
99
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
const deleteIconColor = useMemo(
|
|
101
|
+
() => themeSelect('rgba(0, 0, 0, 0.5)', 'rgba(255, 255, 255, 0.5)'),
|
|
102
|
+
[themeSelect]
|
|
103
|
+
)
|
|
103
104
|
|
|
104
105
|
const updateBlock = useCallback((index: number, patch: Partial<RichTextBlock>) => {
|
|
105
106
|
onChange?.(
|
|
@@ -175,14 +176,12 @@ const RichTextEditor: React.FC<RichTextEditorProps> = (props) => {
|
|
|
175
176
|
>
|
|
176
177
|
<View
|
|
177
178
|
className={styles['delete-btn']}
|
|
178
|
-
style={deleteBtnStyle}
|
|
179
179
|
onClick={(e) => handleDelete(e, index)}
|
|
180
180
|
>
|
|
181
181
|
<Icon
|
|
182
|
-
name=
|
|
183
|
-
size={
|
|
184
|
-
color=
|
|
185
|
-
className={styles['delete-icon']}
|
|
182
|
+
name="close-circle-fill"
|
|
183
|
+
size={17}
|
|
184
|
+
color={deleteIconColor}
|
|
186
185
|
/>
|
|
187
186
|
</View>
|
|
188
187
|
|
|
@@ -21,6 +21,8 @@ export interface TableColumn<T extends object> {
|
|
|
21
21
|
render?: (value: T[keyof T], record: T, index: number) => React.ReactNode
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export type TableTextAlign = 'left' | 'center' | 'right'
|
|
25
|
+
|
|
24
26
|
export interface TableProps<T extends object> {
|
|
25
27
|
/** 列配置 */
|
|
26
28
|
columns: TableColumn<T>[]
|
|
@@ -30,6 +32,10 @@ export interface TableProps<T extends object> {
|
|
|
30
32
|
rowKey: keyof T
|
|
31
33
|
/** 表头背景色 */
|
|
32
34
|
headerBackgroundColor?: string
|
|
35
|
+
/** 表头文字加粗 */
|
|
36
|
+
headerTextBold?: boolean
|
|
37
|
+
/** 表格文字对齐方式 */
|
|
38
|
+
textAlign?: TableTextAlign
|
|
33
39
|
/** 自定义类名 */
|
|
34
40
|
className?: string
|
|
35
41
|
/** 自定义样式 */
|
|
@@ -48,16 +54,29 @@ function formatWidth(width?: number | string) {
|
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
/**
|
|
51
|
-
*
|
|
57
|
+
* 根据列宽和对齐方式生成单元格样式;未指定宽度时均分剩余空间
|
|
52
58
|
*/
|
|
53
|
-
function getCellStyle(width?: number | string): React.CSSProperties {
|
|
59
|
+
function getCellStyle(width?: number | string, align: TableTextAlign = 'left'): React.CSSProperties {
|
|
54
60
|
const formattedWidth = formatWidth(width)
|
|
61
|
+
const justifyContent = align === 'center'
|
|
62
|
+
? 'center'
|
|
63
|
+
: align === 'right'
|
|
64
|
+
? 'flex-end'
|
|
65
|
+
: 'flex-start'
|
|
55
66
|
|
|
56
67
|
if (formattedWidth) {
|
|
57
|
-
return {
|
|
68
|
+
return {
|
|
69
|
+
flex: `0 0 ${formattedWidth}`,
|
|
70
|
+
justifyContent,
|
|
71
|
+
textAlign: align,
|
|
72
|
+
}
|
|
58
73
|
}
|
|
59
74
|
|
|
60
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
flex: 1,
|
|
77
|
+
justifyContent,
|
|
78
|
+
textAlign: align,
|
|
79
|
+
}
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
/**
|
|
@@ -84,10 +103,14 @@ function getRowKey<T extends object>(
|
|
|
84
103
|
/**
|
|
85
104
|
* 渲染文本节点;字符串/数字包一层 Text,其它节点原样返回
|
|
86
105
|
*/
|
|
87
|
-
function renderText(
|
|
106
|
+
function renderText(
|
|
107
|
+
content: React.ReactNode,
|
|
108
|
+
className: string,
|
|
109
|
+
style?: React.CSSProperties,
|
|
110
|
+
) {
|
|
88
111
|
if (typeof content === 'string' || typeof content === 'number') {
|
|
89
112
|
return (
|
|
90
|
-
<Text className={className}>
|
|
113
|
+
<Text className={className} style={style}>
|
|
91
114
|
{content}
|
|
92
115
|
</Text>
|
|
93
116
|
)
|
|
@@ -102,6 +125,8 @@ function Table<T extends object>(props: TableProps<T>) {
|
|
|
102
125
|
columns,
|
|
103
126
|
rowKey,
|
|
104
127
|
headerBackgroundColor,
|
|
128
|
+
headerTextBold = false,
|
|
129
|
+
textAlign = 'left',
|
|
105
130
|
className,
|
|
106
131
|
style,
|
|
107
132
|
} = props
|
|
@@ -124,9 +149,13 @@ function Table<T extends object>(props: TableProps<T>) {
|
|
|
124
149
|
<View
|
|
125
150
|
key={String(column.dataIndex)}
|
|
126
151
|
className={styles['table-cell']}
|
|
127
|
-
style={getCellStyle(column.width)}
|
|
152
|
+
style={getCellStyle(column.width, textAlign)}
|
|
128
153
|
>
|
|
129
|
-
{renderText(
|
|
154
|
+
{renderText(
|
|
155
|
+
column.title,
|
|
156
|
+
styles['table-header-text'],
|
|
157
|
+
headerTextBold ? { fontWeight: 500 } : undefined,
|
|
158
|
+
)}
|
|
130
159
|
</View>
|
|
131
160
|
))
|
|
132
161
|
}
|
|
@@ -153,9 +182,13 @@ function Table<T extends object>(props: TableProps<T>) {
|
|
|
153
182
|
<View
|
|
154
183
|
key={`${currentRowKey}-${String(column.dataIndex)}`}
|
|
155
184
|
className={styles['table-cell']}
|
|
156
|
-
style={getCellStyle(column.width)}
|
|
185
|
+
style={getCellStyle(column.width, textAlign)}
|
|
157
186
|
>
|
|
158
|
-
{renderText(
|
|
187
|
+
{renderText(
|
|
188
|
+
content as React.ReactNode,
|
|
189
|
+
styles['table-cell-text'],
|
|
190
|
+
{ textAlign },
|
|
191
|
+
)}
|
|
159
192
|
</View>
|
|
160
193
|
)
|
|
161
194
|
})
|
|
@@ -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,
|
|
@@ -350,6 +357,29 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
|
|
|
350
357
|
)
|
|
351
358
|
: undefined
|
|
352
359
|
}
|
|
360
|
+
{
|
|
361
|
+
remainingCount != null && remainingCount !== ''
|
|
362
|
+
? (
|
|
363
|
+
<View className={styles['remaining-row']}>
|
|
364
|
+
<Text className={styles['remaining-label']}>
|
|
365
|
+
{labels.remaining_label}:
|
|
366
|
+
</Text>
|
|
367
|
+
<Text className={styles['remaining-value']}>
|
|
368
|
+
{remainingCount}
|
|
369
|
+
</Text>
|
|
370
|
+
{
|
|
371
|
+
remainingTotal != null && remainingTotal !== ''
|
|
372
|
+
? (
|
|
373
|
+
<Text className={styles['remaining-total']}>
|
|
374
|
+
/{remainingTotal}
|
|
375
|
+
</Text>
|
|
376
|
+
)
|
|
377
|
+
: undefined
|
|
378
|
+
}
|
|
379
|
+
</View>
|
|
380
|
+
)
|
|
381
|
+
: undefined
|
|
382
|
+
}
|
|
353
383
|
{
|
|
354
384
|
customization
|
|
355
385
|
? (
|
|
@@ -205,6 +205,27 @@ $F_BUY_COUNT = 14PX // RN 14
|
|
|
205
205
|
margin-top 5PX
|
|
206
206
|
lineClamp(1)
|
|
207
207
|
|
|
208
|
+
.remaining-row
|
|
209
|
+
display flex
|
|
210
|
+
flex-direction row
|
|
211
|
+
align-items baseline
|
|
212
|
+
margin-top 5PX
|
|
213
|
+
|
|
214
|
+
.remaining-label
|
|
215
|
+
font-size $F_SPEC
|
|
216
|
+
color var(--textContent)
|
|
217
|
+
line-height 15PX
|
|
218
|
+
|
|
219
|
+
.remaining-value
|
|
220
|
+
font-size $F_SPEC
|
|
221
|
+
color var(--primary)
|
|
222
|
+
line-height 15PX
|
|
223
|
+
|
|
224
|
+
.remaining-total
|
|
225
|
+
font-size $F_SPEC
|
|
226
|
+
color var(--textContent)
|
|
227
|
+
line-height 15PX
|
|
228
|
+
|
|
208
229
|
.customization-text
|
|
209
230
|
font-size $F_CUSTOM
|
|
210
231
|
color var(--textMuted)
|