@yorkjs/hive-ui 0.0.9 → 0.1.1
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/Cell/Cell.tsx +68 -56
- package/src/components/Cell/CellValue.tsx +27 -9
- package/src/components/Cell/index.module.styl +12 -1
- package/src/components/FieldCard/index.module.styl +63 -0
- package/src/components/FieldCard/index.tsx +84 -0
- package/src/constant/mall.ts +3 -1
- package/src/index.ts +1 -0
- package/src/item/ProductItem/ProductItem.tsx +3 -1
- package/src/item/ProductItem/config.ts +2 -1
package/package.json
CHANGED
|
@@ -79,72 +79,84 @@ const Cell: React.FC<CellProps> = (props) => {
|
|
|
79
79
|
return (
|
|
80
80
|
<View className={containerClass} onClick={onClick}>
|
|
81
81
|
<View className={innerClass}>
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<View
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
icon
|
|
94
|
-
? (
|
|
95
|
-
<View className={styles['icon-wrapper']}>
|
|
96
|
-
{icon}
|
|
97
|
-
</View>
|
|
98
|
-
) : undefined
|
|
99
|
-
}
|
|
100
|
-
<View className={styles['title-section']}>
|
|
82
|
+
<View className={styles['cell-main']}>
|
|
83
|
+
{
|
|
84
|
+
vertical ? (
|
|
85
|
+
<>
|
|
86
|
+
<View className={styles['header-row']}>
|
|
87
|
+
<View style={{
|
|
88
|
+
display: 'flex',
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
flex: 1
|
|
92
|
+
}}>
|
|
101
93
|
{
|
|
102
|
-
|
|
103
|
-
?
|
|
104
|
-
|
|
94
|
+
icon
|
|
95
|
+
? (
|
|
96
|
+
<View className={styles['icon-wrapper']}>
|
|
97
|
+
{icon}
|
|
98
|
+
</View>
|
|
99
|
+
) : undefined
|
|
105
100
|
}
|
|
101
|
+
<View className={styles['title-section']}>
|
|
102
|
+
{
|
|
103
|
+
typeof title === 'string'
|
|
104
|
+
? <CellTitle title={title} required={required} tooltip={tooltip} />
|
|
105
|
+
: title
|
|
106
|
+
}
|
|
107
|
+
</View>
|
|
106
108
|
</View>
|
|
109
|
+
{
|
|
110
|
+
showArrow
|
|
111
|
+
? <View className={styles['arrow-wrapper']}><CellArrow /></View>
|
|
112
|
+
: undefined
|
|
113
|
+
}
|
|
107
114
|
</View>
|
|
115
|
+
<View className={styles['content-section']}>
|
|
116
|
+
{renderContent()}
|
|
117
|
+
</View>
|
|
118
|
+
</>
|
|
119
|
+
)
|
|
120
|
+
: (
|
|
121
|
+
<>
|
|
108
122
|
{
|
|
109
|
-
|
|
110
|
-
? <View className={styles['
|
|
123
|
+
icon
|
|
124
|
+
? <View className={styles['icon-wrapper']}>{icon}</View>
|
|
111
125
|
: undefined
|
|
112
126
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<View
|
|
127
|
-
className={styles['title-section']}
|
|
128
|
-
style={titleWidth ? { width: `${titleWidth}px` } : { maxWidth: '60%' }}
|
|
129
|
-
>
|
|
127
|
+
<View
|
|
128
|
+
className={styles['title-section']}
|
|
129
|
+
style={titleWidth ? { width: `${titleWidth}px` } : { maxWidth: '60%' }}
|
|
130
|
+
>
|
|
131
|
+
{
|
|
132
|
+
typeof title === 'string'
|
|
133
|
+
? <CellTitle title={title} required={required} tooltip={tooltip} />
|
|
134
|
+
: title
|
|
135
|
+
}
|
|
136
|
+
</View>
|
|
137
|
+
<View className={styles['content-section']}>
|
|
138
|
+
{renderContent()}
|
|
139
|
+
</View>
|
|
130
140
|
{
|
|
131
|
-
|
|
132
|
-
? <
|
|
133
|
-
:
|
|
141
|
+
showArrow
|
|
142
|
+
? <View className={styles['arrow-wrapper']}><CellArrow /></View>
|
|
143
|
+
: undefined
|
|
134
144
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
+
</>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
</View>
|
|
149
|
+
{
|
|
150
|
+
children
|
|
151
|
+
? (
|
|
152
|
+
<View
|
|
153
|
+
className={styles['cell-extra-children']}
|
|
154
|
+
>
|
|
155
|
+
{children}
|
|
156
|
+
</View>
|
|
145
157
|
)
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
: undefined
|
|
159
|
+
}
|
|
148
160
|
</View>
|
|
149
161
|
</View>
|
|
150
162
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { Text } from '@tarojs/components'
|
|
2
|
+
import { ITouchEvent, Text } from '@tarojs/components'
|
|
3
3
|
|
|
4
4
|
import { formatClassNames } from '../../util/function'
|
|
5
5
|
|
|
@@ -10,14 +10,28 @@ export interface CellValueProps {
|
|
|
10
10
|
value?: string | number
|
|
11
11
|
placeholder?: string | number
|
|
12
12
|
maxLines?: number
|
|
13
|
+
onClick?:(event: ITouchEvent) => void
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
const CellValue: React.FC<CellValueProps> = ({
|
|
16
|
+
const CellValue: React.FC<CellValueProps> = ({
|
|
17
|
+
value,
|
|
18
|
+
placeholder,
|
|
19
|
+
maxLines,
|
|
20
|
+
className,
|
|
21
|
+
onClick,
|
|
22
|
+
}) => {
|
|
16
23
|
const hasValue = value !== undefined && value !== null && value !== ''
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
const dynamicStyle: React.CSSProperties = maxLines !== 1 ? {
|
|
26
|
+
WebkitLineClamp: maxLines,
|
|
27
|
+
} : {}
|
|
28
|
+
|
|
29
|
+
const handlePress = (e: ITouchEvent) => {
|
|
30
|
+
if (onClick) {
|
|
31
|
+
e.stopPropagation()
|
|
32
|
+
onClick(e)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
21
35
|
|
|
22
36
|
if (hasValue) {
|
|
23
37
|
return (
|
|
@@ -27,6 +41,7 @@ const CellValue: React.FC<CellValueProps> = ({ value, placeholder, maxLines, cla
|
|
|
27
41
|
className
|
|
28
42
|
)}
|
|
29
43
|
style={dynamicStyle}
|
|
44
|
+
onClick={handlePress}
|
|
30
45
|
>
|
|
31
46
|
{value}
|
|
32
47
|
</Text>
|
|
@@ -35,10 +50,13 @@ const CellValue: React.FC<CellValueProps> = ({ value, placeholder, maxLines, cla
|
|
|
35
50
|
|
|
36
51
|
if (placeholder !== undefined && placeholder !== null) {
|
|
37
52
|
return (
|
|
38
|
-
<Text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
<Text
|
|
54
|
+
className={formatClassNames(
|
|
55
|
+
styles['placeholder-text'],
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
onClick={handlePress}
|
|
59
|
+
>
|
|
42
60
|
{placeholder}
|
|
43
61
|
</Text>
|
|
44
62
|
)
|
|
@@ -62,8 +62,12 @@ $DESC_FONT_SIZE = 13PX
|
|
|
62
62
|
&.show-separator
|
|
63
63
|
halfBorder(bottom, var(--lineBorder))
|
|
64
64
|
|
|
65
|
+
.cell-main
|
|
66
|
+
width 100%
|
|
67
|
+
display flex
|
|
68
|
+
|
|
65
69
|
.is-horizontal
|
|
66
|
-
.cell-
|
|
70
|
+
.cell-main
|
|
67
71
|
flex-direction row
|
|
68
72
|
align-items center
|
|
69
73
|
|
|
@@ -80,6 +84,9 @@ $DESC_FONT_SIZE = 13PX
|
|
|
80
84
|
text-align right
|
|
81
85
|
|
|
82
86
|
.is-vertical
|
|
87
|
+
.cell-main
|
|
88
|
+
flex-direction column
|
|
89
|
+
|
|
83
90
|
.header-row
|
|
84
91
|
display flex
|
|
85
92
|
flex-direction row
|
|
@@ -98,6 +105,10 @@ $DESC_FONT_SIZE = 13PX
|
|
|
98
105
|
justify-content flex-start
|
|
99
106
|
text-align left
|
|
100
107
|
|
|
108
|
+
.cell-extra-children
|
|
109
|
+
width 100%
|
|
110
|
+
display block
|
|
111
|
+
|
|
101
112
|
.icon-wrapper
|
|
102
113
|
margin-right 12PX
|
|
103
114
|
display flex
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@import '../../styles/mixin.styl'
|
|
2
|
+
@import '../../styles/variable.styl'
|
|
3
|
+
|
|
4
|
+
$CELL_PADDING_HORIZONTAL = 16PX
|
|
5
|
+
$CELL_PADDING_VERTICAL = 14PX
|
|
6
|
+
|
|
7
|
+
.field-card-container
|
|
8
|
+
border-radius 10PX
|
|
9
|
+
background-color var(--containerCard)
|
|
10
|
+
margin 0 $WING_BLANK
|
|
11
|
+
margin-bottom 12PX
|
|
12
|
+
overflow hidden
|
|
13
|
+
|
|
14
|
+
.card-header
|
|
15
|
+
display flex
|
|
16
|
+
flex-direction row
|
|
17
|
+
align-items center
|
|
18
|
+
justify-content space-between
|
|
19
|
+
padding $CELL_PADDING_VERTICAL $CELL_PADDING_HORIZONTAL
|
|
20
|
+
position relative
|
|
21
|
+
min-height 48PX
|
|
22
|
+
box-sizing border-box
|
|
23
|
+
halfBorder(bottom, var(--lineBorder))
|
|
24
|
+
|
|
25
|
+
.header-left
|
|
26
|
+
flex 1
|
|
27
|
+
display flex
|
|
28
|
+
flex-direction row
|
|
29
|
+
align-items center
|
|
30
|
+
min-width 0
|
|
31
|
+
|
|
32
|
+
.header-title
|
|
33
|
+
color var(--textTitle)
|
|
34
|
+
font-size 16PX
|
|
35
|
+
lineClamp(1)
|
|
36
|
+
|
|
37
|
+
.edit-icon-wrapper
|
|
38
|
+
padding 4PX 8PX
|
|
39
|
+
margin-left 2PX
|
|
40
|
+
display flex
|
|
41
|
+
align-items center
|
|
42
|
+
justify-content center
|
|
43
|
+
border-radius 4PX
|
|
44
|
+
transition background-color 0.2s
|
|
45
|
+
|
|
46
|
+
&:active
|
|
47
|
+
background-color rgba(0, 0, 0, 0.05)
|
|
48
|
+
|
|
49
|
+
.edit-icon
|
|
50
|
+
color var(--textMuted)
|
|
51
|
+
|
|
52
|
+
.header-extra
|
|
53
|
+
margin-left 12PX
|
|
54
|
+
flex-shrink 0
|
|
55
|
+
display flex
|
|
56
|
+
align-items center
|
|
57
|
+
|
|
58
|
+
.action-text
|
|
59
|
+
color #FF4D4F
|
|
60
|
+
font-size 14PX
|
|
61
|
+
padding 4PX
|
|
62
|
+
&:active
|
|
63
|
+
opacity 0.6
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Text, ITouchEvent } from '@tarojs/components'
|
|
3
|
+
import { formatClassNames } from '../../util/function'
|
|
4
|
+
import Icon from '../Icon'
|
|
5
|
+
import styles from './index.module.styl'
|
|
6
|
+
|
|
7
|
+
export interface FieldCardProps {
|
|
8
|
+
/** 标题内容:支持字符串或自定义 DOM */
|
|
9
|
+
title: React.ReactNode
|
|
10
|
+
/** 是否显示标题旁的编辑小图标 */
|
|
11
|
+
showEditIcon?: boolean
|
|
12
|
+
/** 点击编辑图标的回调 */
|
|
13
|
+
onEditClick?: (e: ITouchEvent) => void
|
|
14
|
+
/** 右侧动作区域:支持字符串、Icon 或自定义节点 */
|
|
15
|
+
extra?: React.ReactNode
|
|
16
|
+
/** 点击右侧 extra 区域的回调 (会自动阻止冒泡) */
|
|
17
|
+
onExtraClick?: (e: ITouchEvent) => void
|
|
18
|
+
/** 子组件 */
|
|
19
|
+
children?: React.ReactNode
|
|
20
|
+
/** 外部样式 */
|
|
21
|
+
className?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const FieldCard: React.FC<FieldCardProps> = (props) => {
|
|
25
|
+
const {
|
|
26
|
+
title,
|
|
27
|
+
showEditIcon = false,
|
|
28
|
+
onEditClick,
|
|
29
|
+
extra,
|
|
30
|
+
onExtraClick,
|
|
31
|
+
children,
|
|
32
|
+
className
|
|
33
|
+
} = props
|
|
34
|
+
|
|
35
|
+
const handleEditClick = (e: ITouchEvent) => {
|
|
36
|
+
if (onEditClick) {
|
|
37
|
+
e.stopPropagation()
|
|
38
|
+
onEditClick(e)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const handleExtraClick = (e: ITouchEvent) => {
|
|
43
|
+
if (onExtraClick) {
|
|
44
|
+
e.stopPropagation()
|
|
45
|
+
onExtraClick(e)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View className={formatClassNames(styles['field-card-container'], className)}>
|
|
51
|
+
<View className={styles['card-header']}>
|
|
52
|
+
<View className={styles['header-left']}>
|
|
53
|
+
{typeof title === 'string' ? (
|
|
54
|
+
<Text className={styles['header-title']}>{title}</Text>
|
|
55
|
+
) : (
|
|
56
|
+
title
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
{showEditIcon && (
|
|
60
|
+
<View className={styles['edit-icon-wrapper']} onClick={handleEditClick}>
|
|
61
|
+
<Icon name='edit' size={14} className={styles['edit-icon']} />
|
|
62
|
+
</View>
|
|
63
|
+
)}
|
|
64
|
+
</View>
|
|
65
|
+
|
|
66
|
+
{extra && (
|
|
67
|
+
<View className={styles['header-extra']} onClick={handleExtraClick}>
|
|
68
|
+
{typeof extra === 'string' ? (
|
|
69
|
+
<Text className={styles['action-text']}>{extra}</Text>
|
|
70
|
+
) : (
|
|
71
|
+
extra
|
|
72
|
+
)}
|
|
73
|
+
</View>
|
|
74
|
+
)}
|
|
75
|
+
</View>
|
|
76
|
+
|
|
77
|
+
<View className={styles['card-content']}>
|
|
78
|
+
{children}
|
|
79
|
+
</View>
|
|
80
|
+
</View>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default FieldCard
|
package/src/constant/mall.ts
CHANGED
|
@@ -19,4 +19,6 @@ export const PROMOTION_ACTIVITY_TYPE_BRAND = 2
|
|
|
19
19
|
// 热点活动
|
|
20
20
|
export const PROMOTION_ACTIVITY_TYPE_HOT = 3
|
|
21
21
|
//买赠活动
|
|
22
|
-
export const PROMOTION_ACTIVITY_TYPE_PRESENT = 4
|
|
22
|
+
export const PROMOTION_ACTIVITY_TYPE_PRESENT = 4
|
|
23
|
+
// 满减折扣
|
|
24
|
+
export const PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT = 5
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as Cell, setCellConfig } from './components/Cell'
|
|
|
5
5
|
export { default as Icon } from './components/Icon'
|
|
6
6
|
export { default as Checkbox } from './components/Checkbox'
|
|
7
7
|
export { default as Tag } from './components/Tag'
|
|
8
|
+
export { default as FieldCard } from './components/FieldCard'
|
|
8
9
|
|
|
9
10
|
export { default as FlowItem } from './item/FlowItem'
|
|
10
11
|
export { default as ProductItem, setProductItemConfig } from './item/ProductItem'
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
PROMOTION_ACTIVITY_TYPE_BRAND,
|
|
20
20
|
PROMOTION_ACTIVITY_TYPE_HOT,
|
|
21
21
|
PROMOTION_ACTIVITY_TYPE_PRESENT,
|
|
22
|
+
PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT,
|
|
22
23
|
} from '../../constant/mall'
|
|
23
24
|
import { getProductItemConfig } from './config'
|
|
24
25
|
|
|
@@ -27,7 +28,7 @@ import styles from './index.module.styl'
|
|
|
27
28
|
export interface IProductCardLabels {
|
|
28
29
|
product_type?: { real: string; virtual: string; service: string }
|
|
29
30
|
delivery_type?: { dine: string; self_pickup: string; delivery: string }
|
|
30
|
-
activity_type?: { flash: string; brand: string; hot: string; present: string }
|
|
31
|
+
activity_type?: { flash: string; brand: string; hot: string; present: string; full_discount: string }
|
|
31
32
|
present_badge?: string
|
|
32
33
|
stock_label?: string
|
|
33
34
|
sale_label?: string
|
|
@@ -321,6 +322,7 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
|
|
|
321
322
|
{activityType === PROMOTION_ACTIVITY_TYPE_BRAND && labels.activity_type.brand}
|
|
322
323
|
{activityType === PROMOTION_ACTIVITY_TYPE_HOT && labels.activity_type.hot}
|
|
323
324
|
{activityType === PROMOTION_ACTIVITY_TYPE_PRESENT && labels.activity_type.present}
|
|
325
|
+
{activityType === PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT && labels.activity_type.full_discount}
|
|
324
326
|
</Text>
|
|
325
327
|
</View>
|
|
326
328
|
</View>
|