@yorkjs/hive-ui 0.0.1 → 0.0.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/Cell/Cell.tsx +153 -0
- package/src/components/Cell/CellArrow.tsx +25 -0
- package/src/components/Cell/CellCard.tsx +44 -0
- package/src/components/Cell/CellDescription.tsx +28 -0
- package/src/components/Cell/CellGroup.tsx +46 -0
- package/src/components/Cell/CellTitle.tsx +71 -0
- package/src/components/Cell/CellValue.tsx +50 -0
- package/src/components/Cell/config.ts +13 -0
- package/src/components/Cell/index.module.styl +145 -0
- package/src/components/Cell/index.tsx +24 -0
- package/src/components/Icon/index.tsx +51 -0
- package/src/components/NumberKeyboard/index.module.styl +20 -7
- package/src/components/NumberKeyboard/index.tsx +30 -8
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import CellTitle from './CellTitle'
|
|
7
|
+
import CellValue from './CellValue'
|
|
8
|
+
import CellArrow from './CellArrow'
|
|
9
|
+
|
|
10
|
+
import styles from './index.module.styl'
|
|
11
|
+
|
|
12
|
+
export interface CellProps {
|
|
13
|
+
vertical?: boolean
|
|
14
|
+
icon?: React.ReactNode
|
|
15
|
+
title?: React.ReactNode | string
|
|
16
|
+
placeholder?: string | number
|
|
17
|
+
value?: string | number
|
|
18
|
+
content?: React.ReactNode
|
|
19
|
+
titleWidth?: number
|
|
20
|
+
tooltip?: string
|
|
21
|
+
required?: boolean
|
|
22
|
+
showArrow?: boolean
|
|
23
|
+
showSeparator?: boolean
|
|
24
|
+
showTopBorder?: boolean
|
|
25
|
+
showBottomBorder?: boolean
|
|
26
|
+
onClick?: () => void
|
|
27
|
+
className?: string
|
|
28
|
+
children?: React.ReactNode
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const Cell: React.FC<CellProps> = (props) => {
|
|
32
|
+
const {
|
|
33
|
+
vertical = false,
|
|
34
|
+
icon,
|
|
35
|
+
title,
|
|
36
|
+
placeholder,
|
|
37
|
+
value,
|
|
38
|
+
content,
|
|
39
|
+
titleWidth,
|
|
40
|
+
tooltip,
|
|
41
|
+
required = false,
|
|
42
|
+
showArrow = false,
|
|
43
|
+
showSeparator = false,
|
|
44
|
+
showTopBorder = false,
|
|
45
|
+
showBottomBorder = false,
|
|
46
|
+
onClick,
|
|
47
|
+
className,
|
|
48
|
+
children
|
|
49
|
+
} = props
|
|
50
|
+
|
|
51
|
+
const containerClass = formatClassNames(
|
|
52
|
+
styles['cell-container'],
|
|
53
|
+
vertical ? styles['is-vertical'] : styles['is-horizontal'],
|
|
54
|
+
{
|
|
55
|
+
[styles['is-clickable']]: !!onClick,
|
|
56
|
+
[styles['border-top']]: showTopBorder,
|
|
57
|
+
[styles['border-bottom']]: showBottomBorder,
|
|
58
|
+
},
|
|
59
|
+
className
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
const innerClass = formatClassNames(styles['cell-inner'], {
|
|
63
|
+
[styles['show-separator']]: showSeparator,
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const renderContent = () => {
|
|
67
|
+
if (content) return content
|
|
68
|
+
if (value != null || placeholder != null) {
|
|
69
|
+
return (
|
|
70
|
+
<CellValue
|
|
71
|
+
value={value}
|
|
72
|
+
placeholder={placeholder}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<View className={containerClass} onClick={onClick}>
|
|
81
|
+
<View className={innerClass}>
|
|
82
|
+
{
|
|
83
|
+
vertical ? (
|
|
84
|
+
<>
|
|
85
|
+
<View className={styles['header-row']}>
|
|
86
|
+
<View style={{
|
|
87
|
+
display: 'flex',
|
|
88
|
+
flexDirection: 'row',
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
flex: 1
|
|
91
|
+
}}>
|
|
92
|
+
{
|
|
93
|
+
icon
|
|
94
|
+
? (
|
|
95
|
+
<View className={styles['icon-wrapper']}>
|
|
96
|
+
{icon}
|
|
97
|
+
</View>
|
|
98
|
+
) : undefined
|
|
99
|
+
}
|
|
100
|
+
<View className={styles['title-section']}>
|
|
101
|
+
{
|
|
102
|
+
typeof title === 'string'
|
|
103
|
+
? <CellTitle title={title} required={required} tooltip={tooltip} />
|
|
104
|
+
: title
|
|
105
|
+
}
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
108
|
+
{
|
|
109
|
+
showArrow
|
|
110
|
+
? <View className={styles['arrow-wrapper']}><CellArrow /></View>
|
|
111
|
+
: undefined
|
|
112
|
+
}
|
|
113
|
+
</View>
|
|
114
|
+
<View className={styles['content-section']}>
|
|
115
|
+
{renderContent()}
|
|
116
|
+
</View>
|
|
117
|
+
</>
|
|
118
|
+
)
|
|
119
|
+
: (
|
|
120
|
+
<>
|
|
121
|
+
{
|
|
122
|
+
icon
|
|
123
|
+
? <View className={styles['icon-wrapper']}>{icon}</View>
|
|
124
|
+
: undefined
|
|
125
|
+
}
|
|
126
|
+
<View
|
|
127
|
+
className={styles['title-section']}
|
|
128
|
+
style={titleWidth ? { width: `${titleWidth}px` } : { maxWidth: '60%' }}
|
|
129
|
+
>
|
|
130
|
+
{
|
|
131
|
+
typeof title === 'string'
|
|
132
|
+
? <CellTitle title={title} required={required} tooltip={tooltip} />
|
|
133
|
+
: title
|
|
134
|
+
}
|
|
135
|
+
</View>
|
|
136
|
+
<View className={styles['content-section']}>
|
|
137
|
+
{renderContent()}
|
|
138
|
+
</View>
|
|
139
|
+
{
|
|
140
|
+
showArrow
|
|
141
|
+
? <View className={styles['arrow-wrapper']}><CellArrow /></View>
|
|
142
|
+
: undefined
|
|
143
|
+
}
|
|
144
|
+
</>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
{children}
|
|
148
|
+
</View>
|
|
149
|
+
</View>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default Cell
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Icon from '../Icon'
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.styl'
|
|
7
|
+
|
|
8
|
+
export interface CellArrowProps {
|
|
9
|
+
className?: string
|
|
10
|
+
}
|
|
11
|
+
const CellArrow: React.FC<CellArrowProps> = ({
|
|
12
|
+
className
|
|
13
|
+
}) => (
|
|
14
|
+
<Icon
|
|
15
|
+
name="right"
|
|
16
|
+
className={formatClassNames(
|
|
17
|
+
styles['arrow-icon'],
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
color="var(--textPlaceholder)"
|
|
21
|
+
size={12}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export default CellArrow
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from '@tarojs/components'
|
|
3
|
+
import { formatClassNames } from '../../util/function'
|
|
4
|
+
import styles from './index.module.styl'
|
|
5
|
+
|
|
6
|
+
export interface CellCardProps {
|
|
7
|
+
className?: string
|
|
8
|
+
showTopGutter?: boolean
|
|
9
|
+
showBottomGutter?: boolean
|
|
10
|
+
showTopBlank?: boolean
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
onClick?: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CellCard: React.FC<CellCardProps> = ({
|
|
16
|
+
showTopGutter = false,
|
|
17
|
+
showBottomGutter = false,
|
|
18
|
+
showTopBlank = false,
|
|
19
|
+
onClick,
|
|
20
|
+
className,
|
|
21
|
+
children
|
|
22
|
+
}) => {
|
|
23
|
+
const combinedClass = formatClassNames(
|
|
24
|
+
styles['cell-card'],
|
|
25
|
+
{
|
|
26
|
+
[styles['show-top-gutter']]: showTopGutter,
|
|
27
|
+
[styles['show-bottom-gutter']]: showBottomGutter,
|
|
28
|
+
[styles['show-top-blank']]: showTopBlank,
|
|
29
|
+
[styles['is-clickable']]: !!onClick,
|
|
30
|
+
},
|
|
31
|
+
className
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<View
|
|
36
|
+
className={combinedClass}
|
|
37
|
+
onClick={onClick}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</View>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default CellCard
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { View, Text } from "@tarojs/components"
|
|
2
|
+
import { formatClassNames } from "../../util/function"
|
|
3
|
+
|
|
4
|
+
import styles from './index.module.styl'
|
|
5
|
+
|
|
6
|
+
export interface CellDescriptionProps {
|
|
7
|
+
desc: string
|
|
8
|
+
align?: 'left' | 'center' | 'right'
|
|
9
|
+
className?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const CellDescription: React.FC<CellDescriptionProps> = ({ desc, align = 'left', className }) => {
|
|
13
|
+
return (
|
|
14
|
+
<View className={formatClassNames(
|
|
15
|
+
styles['cell-description'],
|
|
16
|
+
className)
|
|
17
|
+
}>
|
|
18
|
+
<Text
|
|
19
|
+
className={styles['desc-text']}
|
|
20
|
+
style={{ textAlign: align }}
|
|
21
|
+
>
|
|
22
|
+
{desc}
|
|
23
|
+
</Text>
|
|
24
|
+
</View>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default CellDescription
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Text, ITouchEvent } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import Icon from '../Icon'
|
|
7
|
+
import { getCellConfig } from './config'
|
|
8
|
+
|
|
9
|
+
import styles from './index.module.styl'
|
|
10
|
+
|
|
11
|
+
export interface CellGroupProps {
|
|
12
|
+
title: string
|
|
13
|
+
tooltip?: any
|
|
14
|
+
className?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const CellGroup: React.FC<CellGroupProps> = ({ title, tooltip, className }) => {
|
|
18
|
+
const handleTooltip = (e: ITouchEvent) => {
|
|
19
|
+
e.stopPropagation()
|
|
20
|
+
|
|
21
|
+
const data = { title, tooltip }
|
|
22
|
+
const config = getCellConfig()
|
|
23
|
+
config.onTooltipPress(data)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View className={formatClassNames(styles['cell-group'], className)}>
|
|
28
|
+
<Text className={styles['group-text']}>
|
|
29
|
+
{title}
|
|
30
|
+
</Text>
|
|
31
|
+
{
|
|
32
|
+
tooltip ? (
|
|
33
|
+
<Icon
|
|
34
|
+
className={styles['tooltip-icon']}
|
|
35
|
+
name='question-circle'
|
|
36
|
+
onClick={handleTooltip}
|
|
37
|
+
size={14}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
: undefined
|
|
41
|
+
}
|
|
42
|
+
</View>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default CellGroup
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Text, ITouchEvent } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import Icon from '../Icon'
|
|
7
|
+
|
|
8
|
+
import { getCellConfig } from './config'
|
|
9
|
+
|
|
10
|
+
import styles from './index.module.styl'
|
|
11
|
+
|
|
12
|
+
export interface CellTitleProps {
|
|
13
|
+
className?: string
|
|
14
|
+
required?: boolean
|
|
15
|
+
title: string
|
|
16
|
+
tooltip?: any
|
|
17
|
+
style?: React.CSSProperties
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CellTitle: React.FC<CellTitleProps> = ({
|
|
21
|
+
required,
|
|
22
|
+
title,
|
|
23
|
+
tooltip,
|
|
24
|
+
style,
|
|
25
|
+
className
|
|
26
|
+
}) => {
|
|
27
|
+
const handleTooltip = (e: ITouchEvent) => {
|
|
28
|
+
e.stopPropagation()
|
|
29
|
+
|
|
30
|
+
const data = { title, tooltip }
|
|
31
|
+
const config = getCellConfig()
|
|
32
|
+
config.onTooltipPress(data)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View className={formatClassNames(
|
|
37
|
+
styles['title-view'],
|
|
38
|
+
className,
|
|
39
|
+
)}>
|
|
40
|
+
{
|
|
41
|
+
required
|
|
42
|
+
? (
|
|
43
|
+
<Icon
|
|
44
|
+
name="asterisk"
|
|
45
|
+
color="#FF0000"
|
|
46
|
+
size={7}
|
|
47
|
+
className={styles['required-icon']}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
: undefined
|
|
51
|
+
}
|
|
52
|
+
<Text className={styles['title-text']} style={style}>
|
|
53
|
+
{title}
|
|
54
|
+
</Text>
|
|
55
|
+
{
|
|
56
|
+
tooltip
|
|
57
|
+
? (
|
|
58
|
+
<Icon
|
|
59
|
+
className={styles['tooltip-icon']}
|
|
60
|
+
name='question-circle'
|
|
61
|
+
onClick={handleTooltip}
|
|
62
|
+
size={14}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
: undefined
|
|
66
|
+
}
|
|
67
|
+
</View>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default CellTitle
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.styl'
|
|
7
|
+
|
|
8
|
+
export interface CellValueProps {
|
|
9
|
+
className?: string
|
|
10
|
+
value?: string | number
|
|
11
|
+
placeholder?: string | number
|
|
12
|
+
maxLines?: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CellValue: React.FC<CellValueProps> = ({ value, placeholder, maxLines, className }) => {
|
|
16
|
+
const hasValue = value !== undefined && value !== null && value !== ''
|
|
17
|
+
|
|
18
|
+
const dynamicStyle: React.CSSProperties = maxLines !== 1 ? {
|
|
19
|
+
WebkitLineClamp: maxLines,
|
|
20
|
+
} : {}
|
|
21
|
+
|
|
22
|
+
if (hasValue) {
|
|
23
|
+
return (
|
|
24
|
+
<Text
|
|
25
|
+
className={formatClassNames(
|
|
26
|
+
styles['value-text'],
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
style={dynamicStyle}
|
|
30
|
+
>
|
|
31
|
+
{value}
|
|
32
|
+
</Text>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (placeholder !== undefined && placeholder !== null) {
|
|
37
|
+
return (
|
|
38
|
+
<Text className={formatClassNames(
|
|
39
|
+
styles['placeholder-text'],
|
|
40
|
+
className
|
|
41
|
+
)}>
|
|
42
|
+
{placeholder}
|
|
43
|
+
</Text>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default CellValue
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let onTooltipPress = (data: { title: string; tooltip: any }) => {
|
|
2
|
+
console.log('触发 Tooltip:', data)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const setCellConfig = (config: { onTooltipPress: typeof onTooltipPress }) => {
|
|
6
|
+
if (config.onTooltipPress) {
|
|
7
|
+
onTooltipPress = config.onTooltipPress
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getCellConfig = () => ({
|
|
12
|
+
onTooltipPress
|
|
13
|
+
})
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
@import '../../styles/mixin.styl'
|
|
2
|
+
|
|
3
|
+
$CELL_PADDING_HORIZONTAL = 16PX
|
|
4
|
+
$CELL_PADDING_VERTICAL = 14PX
|
|
5
|
+
$TITLE_FONT_SIZE = 16PX
|
|
6
|
+
$VALUE_FONT_SIZE = 14PX
|
|
7
|
+
$DESC_FONT_SIZE = 13PX
|
|
8
|
+
|
|
9
|
+
.cell-card
|
|
10
|
+
border-radius 10PX
|
|
11
|
+
overflow hidden
|
|
12
|
+
background-color var(--containerCard)
|
|
13
|
+
margin 0 $WING_BLANK
|
|
14
|
+
&.show-top-gutter
|
|
15
|
+
margin-top $GUTTER_BLANK
|
|
16
|
+
&.show-bottom-gutter
|
|
17
|
+
margin-bottom $GUTTER_BLANK
|
|
18
|
+
&.show-top-blank
|
|
19
|
+
margin-top $CARD_BLANK
|
|
20
|
+
|
|
21
|
+
.cell-description
|
|
22
|
+
padding 6PX $CELL_PADDING_HORIZONTAL 0 $CELL_PADDING_HORIZONTAL
|
|
23
|
+
.desc-text
|
|
24
|
+
color var(--textMuted)
|
|
25
|
+
font-size $DESC_FONT_SIZE
|
|
26
|
+
line-height calc($DESC_FONT_SIZE + 6PX)
|
|
27
|
+
display block
|
|
28
|
+
|
|
29
|
+
.cell-group
|
|
30
|
+
display flex
|
|
31
|
+
flex-direction row
|
|
32
|
+
align-items center
|
|
33
|
+
margin 0 $WING_BLANK
|
|
34
|
+
padding 20PX $CELL_PADDING_HORIZONTAL 8PX $CELL_PADDING_HORIZONTAL
|
|
35
|
+
.group-text
|
|
36
|
+
color var(--textMuted)
|
|
37
|
+
font-size $VALUE_FONT_SIZE
|
|
38
|
+
|
|
39
|
+
.cell-container
|
|
40
|
+
background-color var(--containerCard)
|
|
41
|
+
padding 0 $CELL_PADDING_HORIZONTAL
|
|
42
|
+
position relative
|
|
43
|
+
transition background-color 0.1s
|
|
44
|
+
|
|
45
|
+
&.border-top
|
|
46
|
+
halfBorder(top, var(--lineBorder))
|
|
47
|
+
|
|
48
|
+
&.border-bottom
|
|
49
|
+
halfBorder(bottom, var(--lineBorder))
|
|
50
|
+
|
|
51
|
+
&.is-clickable
|
|
52
|
+
cursor pointer
|
|
53
|
+
&:active
|
|
54
|
+
background-color rgba(0, 0, 0, 0.03)
|
|
55
|
+
|
|
56
|
+
.cell-inner
|
|
57
|
+
padding $CELL_PADDING_VERTICAL 0
|
|
58
|
+
display flex
|
|
59
|
+
flex-direction column
|
|
60
|
+
position relative
|
|
61
|
+
|
|
62
|
+
&.show-separator
|
|
63
|
+
halfBorder(bottom, var(--lineBorder))
|
|
64
|
+
|
|
65
|
+
.is-horizontal
|
|
66
|
+
.cell-inner
|
|
67
|
+
flex-direction row
|
|
68
|
+
align-items center
|
|
69
|
+
|
|
70
|
+
.title-section
|
|
71
|
+
flex-shrink 0
|
|
72
|
+
margin-right 10PX
|
|
73
|
+
|
|
74
|
+
.content-section
|
|
75
|
+
flex 1
|
|
76
|
+
display flex
|
|
77
|
+
flex-direction row
|
|
78
|
+
justify-content flex-end
|
|
79
|
+
align-items center
|
|
80
|
+
text-align right
|
|
81
|
+
|
|
82
|
+
.is-vertical
|
|
83
|
+
.header-row
|
|
84
|
+
display flex
|
|
85
|
+
flex-direction row
|
|
86
|
+
align-items center
|
|
87
|
+
justify-content space-between
|
|
88
|
+
width 100%
|
|
89
|
+
|
|
90
|
+
.title-section
|
|
91
|
+
flex 1
|
|
92
|
+
|
|
93
|
+
.content-section
|
|
94
|
+
margin-top 8PX
|
|
95
|
+
width 100%
|
|
96
|
+
display flex
|
|
97
|
+
flex-direction row
|
|
98
|
+
justify-content flex-start
|
|
99
|
+
text-align left
|
|
100
|
+
|
|
101
|
+
.icon-wrapper
|
|
102
|
+
margin-right 12PX
|
|
103
|
+
display flex
|
|
104
|
+
align-items center
|
|
105
|
+
justify-content center
|
|
106
|
+
|
|
107
|
+
.title-view
|
|
108
|
+
display flex
|
|
109
|
+
flex-direction row
|
|
110
|
+
align-items center
|
|
111
|
+
position relative
|
|
112
|
+
|
|
113
|
+
.title-text
|
|
114
|
+
color var(--textTitle)
|
|
115
|
+
font-size $TITLE_FONT_SIZE
|
|
116
|
+
line-height 1.4
|
|
117
|
+
|
|
118
|
+
.required-icon
|
|
119
|
+
position absolute
|
|
120
|
+
left -10PX
|
|
121
|
+
top 7PX
|
|
122
|
+
|
|
123
|
+
.tooltip-icon
|
|
124
|
+
margin-left 4PX
|
|
125
|
+
color var(--textMuted)
|
|
126
|
+
display flex
|
|
127
|
+
align-items center
|
|
128
|
+
|
|
129
|
+
.value-text
|
|
130
|
+
color var(--textContent)
|
|
131
|
+
font-size $VALUE_FONT_SIZE
|
|
132
|
+
line-height 1.4
|
|
133
|
+
lineClamp(1)
|
|
134
|
+
|
|
135
|
+
.placeholder-text
|
|
136
|
+
color var(--textPlaceholder)
|
|
137
|
+
font-size $VALUE_FONT_SIZE
|
|
138
|
+
line-height 1.4
|
|
139
|
+
|
|
140
|
+
.arrow-wrapper
|
|
141
|
+
margin-left 6PX
|
|
142
|
+
display flex
|
|
143
|
+
align-items center
|
|
144
|
+
color var(--textPlaceholder)
|
|
145
|
+
font-size 12PX
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import CellMain from './Cell'
|
|
2
|
+
import CellGroup from './CellGroup'
|
|
3
|
+
import CellCard from './CellCard'
|
|
4
|
+
import CellTitle from './CellTitle'
|
|
5
|
+
import CellValue from './CellValue'
|
|
6
|
+
import CellArrow from './CellArrow'
|
|
7
|
+
import CellDescription from './CellDescription'
|
|
8
|
+
|
|
9
|
+
export type { CellProps } from './Cell'
|
|
10
|
+
export type { CellCardProps } from './CellCard'
|
|
11
|
+
export type { CellTitleProps } from './CellTitle'
|
|
12
|
+
|
|
13
|
+
export { setCellConfig } from './config'
|
|
14
|
+
|
|
15
|
+
const Cell = Object.assign(CellMain, {
|
|
16
|
+
Group: CellGroup,
|
|
17
|
+
Card: CellCard,
|
|
18
|
+
Title: CellTitle,
|
|
19
|
+
Value: CellValue,
|
|
20
|
+
Arrow: CellArrow,
|
|
21
|
+
Description: CellDescription
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export default Cell
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
interface IconProps {
|
|
7
|
+
/** 图标名称,对应 iconfont 中的类名后缀 */
|
|
8
|
+
name: string
|
|
9
|
+
/** 图标颜色 */
|
|
10
|
+
color?: string
|
|
11
|
+
/** 图标大小,默认单位为 PX */
|
|
12
|
+
size?: number | string
|
|
13
|
+
/** 自定义类名 */
|
|
14
|
+
className?: string
|
|
15
|
+
/** 自定义样式 */
|
|
16
|
+
style?: React.CSSProperties
|
|
17
|
+
/** 点击事件 */
|
|
18
|
+
onClick?: (event: any) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Icon: React.FC<IconProps> = (props) => {
|
|
22
|
+
const {
|
|
23
|
+
name,
|
|
24
|
+
color,
|
|
25
|
+
size,
|
|
26
|
+
className,
|
|
27
|
+
style,
|
|
28
|
+
onClick
|
|
29
|
+
} = props
|
|
30
|
+
|
|
31
|
+
const iconStyle: React.CSSProperties = {
|
|
32
|
+
...style,
|
|
33
|
+
lineHeight: 1,
|
|
34
|
+
color: color,
|
|
35
|
+
fontSize: typeof size === 'number' ? `${size}PX` : size
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Text
|
|
40
|
+
className={formatClassNames(
|
|
41
|
+
'iconfont',
|
|
42
|
+
`icon-${name}`,
|
|
43
|
+
className)
|
|
44
|
+
}
|
|
45
|
+
style={iconStyle}
|
|
46
|
+
onClick={onClick}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default React.memo(Icon)
|
|
@@ -14,8 +14,26 @@
|
|
|
14
14
|
background-color var(--containerInner)
|
|
15
15
|
halfBorder(top, var(--lineBorder))
|
|
16
16
|
|
|
17
|
-
.header-
|
|
17
|
+
.header-side
|
|
18
18
|
flex 1
|
|
19
|
+
height 100%
|
|
20
|
+
display flex
|
|
21
|
+
align-items center
|
|
22
|
+
|
|
23
|
+
&.side-right
|
|
24
|
+
justify-content flex-end
|
|
25
|
+
|
|
26
|
+
.header-main
|
|
27
|
+
flex 2
|
|
28
|
+
display flex
|
|
29
|
+
align-items center
|
|
30
|
+
justify-content center
|
|
31
|
+
overflow hidden
|
|
32
|
+
|
|
33
|
+
.header-title
|
|
34
|
+
font-size 14PX
|
|
35
|
+
color var(--textContent)
|
|
36
|
+
lineClamp(1)
|
|
19
37
|
|
|
20
38
|
.done-btn
|
|
21
39
|
height 100%
|
|
@@ -29,7 +47,6 @@
|
|
|
29
47
|
.done-text
|
|
30
48
|
font-size 18PX
|
|
31
49
|
color var(--primary)
|
|
32
|
-
font-weight 500
|
|
33
50
|
|
|
34
51
|
.keyboard-grid
|
|
35
52
|
display flex
|
|
@@ -67,8 +84,4 @@
|
|
|
67
84
|
|
|
68
85
|
.key-text
|
|
69
86
|
font-size 24PX
|
|
70
|
-
color var(--textTitle)
|
|
71
|
-
|
|
72
|
-
.delete-icon
|
|
73
|
-
width 22PX
|
|
74
|
-
height 22PX
|
|
87
|
+
color var(--textTitle)
|
|
@@ -3,9 +3,11 @@ import { View, Text, Image } from '@tarojs/components'
|
|
|
3
3
|
|
|
4
4
|
import { formatClassNames } from '../../util/function'
|
|
5
5
|
|
|
6
|
+
import Icon from '../Icon'
|
|
7
|
+
|
|
6
8
|
import styles from './index.module.styl'
|
|
7
9
|
|
|
8
|
-
type KeyboardType = 'int' | 'number'
|
|
10
|
+
type KeyboardType = 'int' | 'number' | 'idCard'
|
|
9
11
|
|
|
10
12
|
interface IProps {
|
|
11
13
|
/** 键盘类型:int(整数), number(带小数点) */
|
|
@@ -16,6 +18,8 @@ interface IProps {
|
|
|
16
18
|
onDelete: () => void
|
|
17
19
|
/** 是否显示头部状态栏 */
|
|
18
20
|
showHead?: boolean
|
|
21
|
+
/** 标题 */
|
|
22
|
+
title?: string
|
|
19
23
|
/** 完成按钮文案 */
|
|
20
24
|
doneText?: string
|
|
21
25
|
/** 完成按钮点击 */
|
|
@@ -30,13 +34,20 @@ const NumberKeyboard: React.FC<IProps> = (props) => {
|
|
|
30
34
|
onInsert,
|
|
31
35
|
onDelete,
|
|
32
36
|
showHead = false,
|
|
37
|
+
title,
|
|
33
38
|
doneText = '完成',
|
|
34
39
|
onDone,
|
|
35
40
|
className
|
|
36
41
|
} = props
|
|
37
42
|
|
|
38
43
|
const keys = useMemo(() => {
|
|
39
|
-
|
|
44
|
+
let leftBottomKey = ''
|
|
45
|
+
if (type === 'number') {
|
|
46
|
+
leftBottomKey = '.'
|
|
47
|
+
}
|
|
48
|
+
else if (type === 'idCard') {
|
|
49
|
+
leftBottomKey = 'X'
|
|
50
|
+
}
|
|
40
51
|
return ['1', '2', '3', '4', '5', '6', '7', '8', '9', leftBottomKey, '0', 'delete']
|
|
41
52
|
}, [type])
|
|
42
53
|
|
|
@@ -55,9 +66,20 @@ const NumberKeyboard: React.FC<IProps> = (props) => {
|
|
|
55
66
|
showHead
|
|
56
67
|
? (
|
|
57
68
|
<View className="keyboard-header">
|
|
58
|
-
<View className="header-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
<View className="header-side" />
|
|
70
|
+
|
|
71
|
+
<View className="header-main">
|
|
72
|
+
{title && (
|
|
73
|
+
<Text className="header-title" numberOfLines={1}>
|
|
74
|
+
{title}
|
|
75
|
+
</Text>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
|
|
79
|
+
<View className="header-side side-right">
|
|
80
|
+
<View className="done-btn" onClick={onDone}>
|
|
81
|
+
<Text className="done-text">{doneText}</Text>
|
|
82
|
+
</View>
|
|
61
83
|
</View>
|
|
62
84
|
</View>
|
|
63
85
|
) : undefined
|
|
@@ -81,9 +103,9 @@ const NumberKeyboard: React.FC<IProps> = (props) => {
|
|
|
81
103
|
{
|
|
82
104
|
isDelete
|
|
83
105
|
? (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
<Icon
|
|
107
|
+
name="delete"
|
|
108
|
+
size={22}
|
|
87
109
|
/>
|
|
88
110
|
)
|
|
89
111
|
: (
|
package/src/index.ts
CHANGED