forked from ant-design/ant-design-mini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.axml.tsx
139 lines (138 loc) · 3.61 KB
/
index.axml.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import {
View,
Slot,
Page,
InternalData,
Text,
PickerView,
PickerViewColumn,
Block,
TSXMLProps,
} from 'tsxml';
import { IPickerProps } from './props';
import AntPopup from '../Popup/index.axml';
import _sjs from './index.sjs';
export default (
{
cancelText,
okText,
title,
placeholder,
className,
disabled,
style,
popClassName,
animationType,
popStyle,
maskStyle,
maskClassName,
indicatorStyle,
indicatorClassName,
options,
emptyText
}: TSXMLProps<IPickerProps>,
{ state, formatValue, selectedIndex, columns }: InternalData
) => (
<Page>
<View
class={`ant-picker ${disabled ? 'ant-picker-disabled' : ''} ${
className || ''
}`}
style={style || ''}
onTap="onOpen"
>
{/* #if ALIPAY */}
<Slot name="prefix" />
{/* #endif */}
<View class="ant-picker-value">
{/* #if ALIPAY */}
<Slot name="content" />
{/* #endif */}
{formatValue ? (
<View class="ant-picker-value-text">{formatValue}</View>
) : (
<Block>
{placeholder && (
<View class="ant-picker-value-placeholder">{placeholder}</View>
)}
</Block>
)}
</View>
{/* #if ALIPAY */}
<Slot name="suffix" />
{/* #endif */}
</View>
<AntPopup
className={`ant-picker-popup ${popClassName || ''}`}
style={popStyle || ''}
position="bottom"
animationType={animationType}
destroyOnClose
onClose="onMaskDismiss"
visible={state.visible}
>
<View class="ant-picker-header">
<View
class="ant-picker-header-item ant-picker-header-cancel"
hover-class="ant-picker-header-item-hover"
hover-start-time="20"
hover-stay-time="50"
onTap="onCancel"
>
{cancelText}
</View>
<View class="ant-picker-header-item ant-picker-header-title">
{/* #if ALIPAY */}
<Slot name="title">{title}</Slot>
{/* #endif */}
</View>
<View
class="ant-picker-header-item ant-picker-header-confirm"
hover-class="ant-picker-header-item-hover"
hover-start-time="20"
hover-stay-time="50"
onTap="onOk"
>
{okText}
</View>
</View>
<View class="ant-picker-content">
<Slot name="content-header" />
{columns ? (
<Block>
<PickerView
class="ant-picker-picker-view"
mask-style={maskStyle || ''}
mask-class={maskClassName || ''}
indicator-style={indicatorStyle || ''}
indicator-class={indicatorClassName || ''}
value={selectedIndex}
onChange="onChange"
>
{columns.map(
(dataRoot, dataIndex) =>
dataIndex < options.length && (
<PickerViewColumn class="ant-picker-picker-view-column">
{dataRoot.map((item) => (
<View class="ant-picker-content-item">
{_sjs.getPickerViewLabel(item)}
</View>
))}
</PickerViewColumn>
)
)}
</PickerView>
</Block>
) : (
<Block>
<PickerView>
<PickerViewColumn>
<Text style="color: #ccc">{emptyText}</Text>
</PickerViewColumn>
</PickerView>
</Block>
)}
</View>
</AntPopup>
</Page>
);