pixuireactcomponents 1.2.2 → 1.2.31
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/index.d.ts +15 -0
- package/index.js +16 -20
- package/package.json +9 -9
- package/tools/EventDispatcherJs.d.ts +10 -0
- package/tools/EventDispatcherJs.js +71 -0
- package/tools/Logger.d.ts +6 -0
- package/tools/Logger.js +138 -0
- package/ui/components/button/Button.d.ts +5 -0
- package/ui/components/button/Button.js +37 -0
- package/ui/components/carousel/Carousel.d.ts +5 -0
- package/ui/components/carousel/Carousel.js +219 -0
- package/ui/components/dropdown/Dropdown.d.ts +30 -0
- package/ui/components/dropdown/Dropdown.js +92 -0
- package/ui/components/dropdown/DropdownOptionUI.d.ts +11 -0
- package/ui/components/dropdown/DropdownOptionUI.js +28 -0
- package/ui/components/dropdown/DropdownSpreadMainUI.d.ts +9 -0
- package/ui/components/dropdown/DropdownSpreadMainUI.js +27 -0
- package/ui/components/dropdown/DropdownUnspreadMainUI.d.ts +9 -0
- package/ui/components/dropdown/DropdownUnspreadMainUI.js +27 -0
- package/ui/components/gradient/GradientText.d.ts +63 -0
- package/ui/components/gradient/{GradientText.tsx → GradientText.js} +174 -183
- package/ui/components/outlinetext/OutlineText.d.ts +94 -0
- package/ui/components/outlinetext/OutlineText.js +168 -0
- package/ui/components/progress/Progress.d.ts +34 -0
- package/ui/components/progress/Progress.js +142 -0
- package/ui/components/slapface/Slapface.d.ts +12 -0
- package/ui/components/slapface/Slapface.js +235 -0
- package/ui/components/slider/Slider.d.ts +57 -0
- package/ui/components/slider/Slider.js +289 -0
- package/ui/components/tab/Tab.d.ts +6 -0
- package/ui/components/tab/Tab.js +27 -0
- package/ui/components/tab/Tabs.d.ts +12 -0
- package/ui/components/tab/Tabs.js +54 -0
- package/cmdAfterTsBuild.js +0 -8
- package/tools/EventDispatcherJs.tsx +0 -74
- package/tools/Logger.tsx +0 -161
- package/tools/img/logger.png +0 -0
- package/tsconfig.json +0 -45
- package/ui/components/bulletscreen/BulletItemAnimation.tsx +0 -117
- package/ui/components/bulletscreen/BulletScreenAnimation.tsx +0 -278
- package/ui/components/bulletscreen/bullet.less +0 -17
- package/ui/components/button/Button.tsx +0 -18
- package/ui/components/carousel/Carousel.tsx +0 -279
- package/ui/components/checkBox/CheckBox.tsx +0 -40
- package/ui/components/dropdown/Dropdown.tsx +0 -126
- package/ui/components/dropdown/DropdownOptionUI.tsx +0 -14
- package/ui/components/dropdown/DropdownSpreadMainUI.tsx +0 -11
- package/ui/components/dropdown/DropdownUnspreadMainUI.tsx +0 -11
- package/ui/components/outlinetext/OutlineText.tsx +0 -184
- package/ui/components/progress/Progress.tsx +0 -174
- package/ui/components/slapface/Slapface.tsx +0 -284
- package/ui/components/slider/Slider.tsx +0 -366
- package/ui/components/tab/Tab.tsx +0 -12
- package/ui/components/tab/Tabs.tsx +0 -56
- package/ui/components/togglegroup/ToggleGroup.tsx +0 -105
- package/ui/components/videoplayer/VideoPlayer.tsx +0 -200
- package/ui/components/waterfallcomponent/WaterfallComponent.jsx +0 -687
- package/ui/components/waterfallcomponent/less/WaterfallComponent.less +0 -13
- package/ui/sample/Images.tsx +0 -60
- package/ui/sample/OutlineText/OutlineDemo.tsx +0 -61
- package/ui/sample/Slapface/SlapfaceDemo.tsx +0 -30
- package/ui/sample/asset/btn_close.png +0 -0
- package/ui/sample/asset/changtai_button.jpg +0 -0
- package/ui/sample/asset/checkbox0.png +0 -0
- package/ui/sample/asset/checkbox1.png +0 -0
- package/ui/sample/asset/data_arrow_down.png +0 -0
- package/ui/sample/asset/data_arrow_up.png +0 -0
- package/ui/sample/asset/dot.png +0 -0
- package/ui/sample/asset/inner.png +0 -0
- package/ui/sample/asset/item_reddot.png +0 -0
- package/ui/sample/asset/loading.png +0 -0
- package/ui/sample/asset/money_dropdown.png +0 -0
- package/ui/sample/asset/money_dropdownall.png +0 -0
- package/ui/sample/asset/outer.png +0 -0
- package/ui/sample/asset/slapface_samplepic1.png +0 -0
- package/ui/sample/asset/slapface_samplepic2.png +0 -0
- package/ui/sample/asset/slapface_samplepic3.png +0 -0
- package/ui/sample/asset/slapface_samplepic4.png +0 -0
- package/ui/sample/asset/slapface_samplepic5.png +0 -0
- package/ui/sample/asset/slapface_samplepic6.png +0 -0
- package/ui/sample/asset/tab_choosed.png +0 -0
- package/ui/sample/asset/tabs_bg.png +0 -0
- package/ui/sample/asset/video_pause.png +0 -0
- package/ui/sample/asset/video_play.png +0 -0
- package/ui/sample/asset/video_reload.png +0 -0
- package/ui/sample/asset/xuanfu_button.jpg +0 -0
- package/ui/sample/asset/yaxia_button.jpg +0 -0
- package/ui/sample/bulletscreen/BulletDemo.tsx +0 -84
- package/ui/sample/button/ButtonDemo.tsx +0 -19
- package/ui/sample/carousel/carouselDemo.tsx +0 -52
- package/ui/sample/checkBox/checkBoxDemo.tsx +0 -7
- package/ui/sample/dropdown/DropdownDemo.tsx +0 -65
- package/ui/sample/dropdown/MoneyDropdownOption.tsx +0 -50
- package/ui/sample/dropdown/MoneyDropdownSpreadMain.tsx +0 -42
- package/ui/sample/dropdown/MoneyDropdownUnspreadMain.tsx +0 -44
- package/ui/sample/gradient/GradientDemo.tsx +0 -51
- package/ui/sample/less/video.less +0 -144
- package/ui/sample/progress/ProgressDemo.tsx +0 -74
- package/ui/sample/slider/SliderDemo.tsx +0 -116
- package/ui/sample/tab/TabDemo.tsx +0 -67
- package/ui/sample/tab/TopTab.tsx +0 -74
- package/ui/sample/togglegroup/ToggleGroupDemo.tsx +0 -35
- package/ui/sample/videoplayer/VideoPlayerDemo.tsx +0 -57
- package/ui/sample/waterfallcomponent/WaterfallComponentDemo.jsx +0 -137
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import { Component, createRef, CSSProperties, h } from 'preact';
|
|
2
|
-
|
|
3
|
-
const row_center_center: CSSProperties = {
|
|
4
|
-
display: 'flex',
|
|
5
|
-
flexDirection: 'row',
|
|
6
|
-
justifyContent: 'center',
|
|
7
|
-
alignItems: 'center'
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const row_between_center: CSSProperties = {
|
|
11
|
-
display: 'flex',
|
|
12
|
-
flexDirection: 'row',
|
|
13
|
-
justifyContent: 'space-between',
|
|
14
|
-
alignItems: 'center'
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export interface SliderProps {
|
|
18
|
-
percent: number; // 0-100,表示0%-100%
|
|
19
|
-
wrapperWidth: number;
|
|
20
|
-
wrapperHeight: number;
|
|
21
|
-
height: number;
|
|
22
|
-
innerHeight?: number;
|
|
23
|
-
dotWidth: number;
|
|
24
|
-
dotHeight: number;
|
|
25
|
-
dotWrapperWidth: number;
|
|
26
|
-
dotWrapperHeight: number;
|
|
27
|
-
|
|
28
|
-
outerBg: string;
|
|
29
|
-
innerBg: string;
|
|
30
|
-
dotBg: string;
|
|
31
|
-
onDragStart: Function | null;
|
|
32
|
-
onDrag: Function | null;
|
|
33
|
-
onDragEnd: Function | null; // 拖动结束的事件
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isDiscrete: boolean | null; //slider是否是离散的
|
|
38
|
-
discrete?: number; //当slider为离散时用于表示离散值
|
|
39
|
-
maxDiscrete?: number; //传入的离散数量
|
|
40
|
-
|
|
41
|
-
hasIncDecButton: boolean | null; //是否具有增减按钮
|
|
42
|
-
incButtonWidth?: number;
|
|
43
|
-
incButtonHeight?: number;
|
|
44
|
-
decButtonWidth?: number;
|
|
45
|
-
decButtonHeight?: number;
|
|
46
|
-
incButtonBg?: string;
|
|
47
|
-
decButtonBg?: string;
|
|
48
|
-
//decButtonRight?: number,
|
|
49
|
-
//incButtonLeft?: number,
|
|
50
|
-
overallWidth?: number;
|
|
51
|
-
onIncClick?: Function | null;
|
|
52
|
-
onDecClick?: Function | null;
|
|
53
|
-
|
|
54
|
-
rangeControl?: boolean;
|
|
55
|
-
startRange?: number;
|
|
56
|
-
endRange?: number;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let wrapperStyle: CSSProperties;
|
|
60
|
-
let outerStyle: CSSProperties;
|
|
61
|
-
let innerStyle: CSSProperties;
|
|
62
|
-
let dotStyle: CSSProperties;
|
|
63
|
-
let dotWrapperStyle: CSSProperties;
|
|
64
|
-
let incButtonStyle: CSSProperties;
|
|
65
|
-
let decButtonStyle: CSSProperties;
|
|
66
|
-
let withButtonStyle: CSSProperties;
|
|
67
|
-
|
|
68
|
-
let lastX = undefined;// 上一次位置的横坐标
|
|
69
|
-
let count = 0; // 拖动条距离最左端的位置 [0, this.props.wrapperWidth]
|
|
70
|
-
let rect: any = undefined; // 滑动区域
|
|
71
|
-
|
|
72
|
-
export class Slider extends Component<
|
|
73
|
-
SliderProps,
|
|
74
|
-
{
|
|
75
|
-
percent: number;
|
|
76
|
-
//discrete: number,
|
|
77
|
-
}>{
|
|
78
|
-
|
|
79
|
-
discrete = Math.round(this.props.discrete == null ? 0 : this.props.discrete)
|
|
80
|
-
private refWrapper: any = createRef()
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
constructor(props) {
|
|
84
|
-
super(props);
|
|
85
|
-
|
|
86
|
-
this.state = {
|
|
87
|
-
percent: (props.discrete != null && this.props.maxDiscrete != null && this.props.discrete != null) ? this.props.discrete * (10000 / this.props.maxDiscrete) : Math.floor(this.props.percent),
|
|
88
|
-
//discrete: Math.round(this.props.discrete==null?0:this.props.discrete)
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.computeWrapperStyle();
|
|
93
|
-
this.computeOuterStyle();
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
componentDidMount() {
|
|
100
|
-
rect = this.refWrapper.current.getBoundingClientRect();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
componentWillReceiveProps(nextProps) {
|
|
104
|
-
if (nextProps.percent == this.props.percent && nextProps.discrete == this.props.discrete) return;
|
|
105
|
-
if (this.props.isDiscrete == true && this.props.maxDiscrete != null) {
|
|
106
|
-
this.discrete = nextProps.discrete;
|
|
107
|
-
this.setState({
|
|
108
|
-
//discrete:nextProps.discrete,
|
|
109
|
-
percent: this.discrete * (10000 / this.props.maxDiscrete)
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.setState({
|
|
114
|
-
percent: nextProps.percent,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
onDragStart = (event) => {
|
|
121
|
-
console.log('【Slider】DragStart event.clientX--' + event.clientX + '-----percent----' + this.state.percent + '-----currentX----' + (this.state.percent / 10000 * this.props.wrapperWidth));
|
|
122
|
-
lastX = event.clentX;
|
|
123
|
-
|
|
124
|
-
count = this.state.percent / 10000 * this.props.wrapperWidth;
|
|
125
|
-
|
|
126
|
-
if (this.props.onDragStart) {
|
|
127
|
-
this.props.onDragStart();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
onDrag = (event) => {
|
|
132
|
-
if (event.clientX < rect.left - 50 || event.clientX > rect.right + 50) return;
|
|
133
|
-
|
|
134
|
-
if (lastX == undefined) {
|
|
135
|
-
lastX = event.clientX;
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
let move = Number(event.clientX) - Number(lastX);
|
|
140
|
-
count += move;
|
|
141
|
-
count = Math.min(this.props.wrapperWidth, count);
|
|
142
|
-
count = Math.max(0, count);
|
|
143
|
-
|
|
144
|
-
let newPercent = count / this.props.wrapperWidth * 10000;
|
|
145
|
-
|
|
146
|
-
if (this.props.isDiscrete == true && this.props.maxDiscrete != null) {
|
|
147
|
-
newPercent = count / this.props.wrapperWidth * this.props.maxDiscrete;
|
|
148
|
-
this.discrete = Math.round(newPercent);
|
|
149
|
-
// this.setState({
|
|
150
|
-
// discrete: Math.round(newPercent),
|
|
151
|
-
// })
|
|
152
|
-
|
|
153
|
-
if (this.props.rangeControl) {
|
|
154
|
-
if (this.props.endRange != null)
|
|
155
|
-
this.discrete = Math.min(this.discrete, this.props.endRange);
|
|
156
|
-
if (this.props.startRange != null)
|
|
157
|
-
this.discrete = Math.max(this.discrete, this.props.startRange);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
newPercent = this.discrete * (10000 / this.props.maxDiscrete);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
this.setState({
|
|
164
|
-
percent: newPercent
|
|
165
|
-
}, () => {
|
|
166
|
-
console.log('【Slider】OnDrag event.clientX--' + event.clientX + '-----percent----' + this.state.percent + '-----discrete----' + this.discrete + '-----currentX----' + (this.state.percent / 10000 * this.props.wrapperWidth));
|
|
167
|
-
if (this.props.onDrag) this.props.onDrag(this.props.isDiscrete ? this.discrete : newPercent);
|
|
168
|
-
});
|
|
169
|
-
lastX = event.clientX;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
onDragEnd = (event) => {
|
|
173
|
-
lastX = undefined;
|
|
174
|
-
if (this.props.isDiscrete == true && this.props.maxDiscrete != null) {
|
|
175
|
-
//console.log("OnDragEnd -----discrete----"+this.state.discrete)
|
|
176
|
-
this.setState({
|
|
177
|
-
percent: this.discrete * (10000 / this.props.maxDiscrete),
|
|
178
|
-
}, () => {
|
|
179
|
-
console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + this.state.percent + '-----discrete----' + this.discrete + '-----currentX----' + (this.state.percent / 10000 * this.props.wrapperWidth));
|
|
180
|
-
if (this.props.onDragEnd) {
|
|
181
|
-
this.props.onDragEnd(this.props.isDiscrete ? this.discrete : this.state.percent);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + this.state.percent + '-----currentX----' + (this.state.percent / 10000 * this.props.wrapperWidth));
|
|
187
|
-
if (this.props.onDragEnd) {
|
|
188
|
-
this.props.onDragEnd(this.props.isDiscrete ? this.discrete : this.state.percent);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
onDecClick = () => {
|
|
194
|
-
//离散的情况
|
|
195
|
-
if (this.props.isDiscrete && this.props.maxDiscrete) {
|
|
196
|
-
if (this.discrete >= 1) {
|
|
197
|
-
this.discrete -= 1;
|
|
198
|
-
if (this.props.rangeControl && this.props.startRange != null) {
|
|
199
|
-
this.discrete = Math.max(this.discrete, this.props.startRange);
|
|
200
|
-
}
|
|
201
|
-
let newPercent = this.discrete * (10000 / this.props.maxDiscrete);
|
|
202
|
-
this.setState({
|
|
203
|
-
//discrete: this.state.discrete - 1,
|
|
204
|
-
percent: newPercent
|
|
205
|
-
}, () => {
|
|
206
|
-
if (this.props.onDecClick) {
|
|
207
|
-
this.props.onDecClick(this.discrete);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
//连续的情况
|
|
213
|
-
else {
|
|
214
|
-
if (this.state.percent > 0) {
|
|
215
|
-
this.setState({
|
|
216
|
-
percent: this.state.percent - 1
|
|
217
|
-
}, () => {
|
|
218
|
-
if (this.props.onIncClick) {
|
|
219
|
-
this.props.onIncClick(this.state.percent);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
onIncClick = () => {
|
|
228
|
-
//离散的情况
|
|
229
|
-
if (this.props.isDiscrete && this.props.maxDiscrete) {
|
|
230
|
-
if (this.discrete < this.props.maxDiscrete) {
|
|
231
|
-
this.discrete += 1;
|
|
232
|
-
if (this.props.rangeControl && this.props.startRange != null) {
|
|
233
|
-
this.discrete = Math.max(this.discrete, this.props.startRange);
|
|
234
|
-
}
|
|
235
|
-
let newPercent = this.discrete * (10000 / this.props.maxDiscrete);
|
|
236
|
-
this.setState({
|
|
237
|
-
// discrete: this.state.discrete + 1,
|
|
238
|
-
percent: newPercent
|
|
239
|
-
}, () => {
|
|
240
|
-
if (this.props.onIncClick) {
|
|
241
|
-
this.props.onIncClick(this.discrete);
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
//连续的情况
|
|
247
|
-
else {
|
|
248
|
-
if (this.state.percent < 10000) {
|
|
249
|
-
this.setState({
|
|
250
|
-
percent: this.state.percent + 1
|
|
251
|
-
}, () => {
|
|
252
|
-
if (this.props.onIncClick) {
|
|
253
|
-
this.props.onIncClick(this.state.percent);
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
computeWrapperStyle = () => {
|
|
261
|
-
wrapperStyle = {
|
|
262
|
-
width: this.props.wrapperWidth + 'px',
|
|
263
|
-
height: this.props.wrapperHeight + 'px',
|
|
264
|
-
...row_center_center
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
computeOuterStyle = () => {
|
|
269
|
-
outerStyle = {
|
|
270
|
-
width: '100%',
|
|
271
|
-
height: this.props.height + 'px',
|
|
272
|
-
backgroundImage: `url(${this.props.outerBg})`,
|
|
273
|
-
backgroundSize: '100% 100%',
|
|
274
|
-
|
|
275
|
-
display: 'flex',
|
|
276
|
-
flexDirection: 'row',
|
|
277
|
-
justifyContent: 'start',
|
|
278
|
-
alignItems: 'center'
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
computeInnerStyle = () => {
|
|
283
|
-
let _width = Math.floor(this.state.percent / 100) + '%';
|
|
284
|
-
innerStyle = {
|
|
285
|
-
width: _width,
|
|
286
|
-
height: (this.props.innerHeight != null) ? this.props.innerHeight + 'px' : '100%',
|
|
287
|
-
backgroundImage: `url(${this.props.innerBg})`,
|
|
288
|
-
backgroundSize: '100% 100%',
|
|
289
|
-
|
|
290
|
-
display: 'flex',
|
|
291
|
-
flexDirection: 'row',
|
|
292
|
-
justifyContent: 'start',
|
|
293
|
-
alignItems: 'center'
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
computeDotWrapperStyle = () => {
|
|
298
|
-
dotWrapperStyle = {
|
|
299
|
-
position: 'absolute',
|
|
300
|
-
width: this.props.dotWrapperWidth + 'px',
|
|
301
|
-
height: this.props.dotWrapperHeight + 'px',
|
|
302
|
-
//marginTop: (this.props.height - this.props.dotWrapperHeight) / 2 + "px",
|
|
303
|
-
marginLeft: (this.props.wrapperWidth * this.state.percent / 10000 - this.props.dotWrapperWidth / 2) + 'px',
|
|
304
|
-
...row_center_center
|
|
305
|
-
// backgroundColor: '#FF000066'
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
computeDotStyle = () => {
|
|
310
|
-
dotStyle = {
|
|
311
|
-
width: this.props.dotWidth + 'px',
|
|
312
|
-
height: this.props.dotHeight + 'px',
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
computeIncButtonStyle = () => {
|
|
317
|
-
incButtonStyle = {
|
|
318
|
-
width: this.props.incButtonWidth + 'px',
|
|
319
|
-
height: this.props.incButtonHeight + 'px',
|
|
320
|
-
//marginLeft:this.props.incButtonLeft+"px",
|
|
321
|
-
//backgroundImage: `url(${this.props.incButtonBg})`,
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
computeDecButtonStyle = () => {
|
|
326
|
-
decButtonStyle = {
|
|
327
|
-
width: this.props.decButtonWidth + 'px',
|
|
328
|
-
height: this.props.decButtonHeight + 'px',
|
|
329
|
-
//marginRight:this.props.decButtonRight+"px",
|
|
330
|
-
//backgroundImage: `url(${this.props.decButtonBg})`,
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
computeWithButtonStyle = () => {
|
|
335
|
-
withButtonStyle = {
|
|
336
|
-
minWidth: this.props.overallWidth + 'px',
|
|
337
|
-
...row_between_center
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
render() {
|
|
342
|
-
this.computeInnerStyle();
|
|
343
|
-
this.computeDotWrapperStyle();
|
|
344
|
-
this.computeDotStyle();
|
|
345
|
-
this.computeIncButtonStyle();
|
|
346
|
-
this.computeDecButtonStyle();
|
|
347
|
-
this.computeWithButtonStyle();
|
|
348
|
-
return (
|
|
349
|
-
<div style={this.props.hasIncDecButton ? withButtonStyle : {}}>
|
|
350
|
-
{this.props.hasIncDecButton && <img src={this.props.decButtonBg} style={decButtonStyle} onClick={this.onDecClick} />}
|
|
351
|
-
<div ref={this.refWrapper} style={wrapperStyle}>
|
|
352
|
-
<div style={outerStyle}>
|
|
353
|
-
<div style={innerStyle}>
|
|
354
|
-
<div style={dotWrapperStyle} draggable={true}
|
|
355
|
-
onDragStart={this.onDragStart} onDrag={this.onDrag} onDragEnd={this.onDragEnd}>
|
|
356
|
-
<img src={this.props.dotBg} style={dotStyle} />
|
|
357
|
-
</div>
|
|
358
|
-
</div>
|
|
359
|
-
</div>
|
|
360
|
-
</div>
|
|
361
|
-
{this.props.hasIncDecButton && <img src={this.props.incButtonBg} style={incButtonStyle} onClick={this.onIncClick} />}
|
|
362
|
-
</div>
|
|
363
|
-
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Component, CSSProperties, h } from "preact";
|
|
2
|
-
import { Tab } from "./Tab";
|
|
3
|
-
|
|
4
|
-
export class Tabs extends Component<
|
|
5
|
-
{
|
|
6
|
-
tabBarStyle: CSSProperties,
|
|
7
|
-
onChoose: Function,
|
|
8
|
-
defaultIndex: number | null
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
selectedIndex: number
|
|
12
|
-
}>{
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
|
|
16
|
-
let initIndex: number = this.props.defaultIndex == null ? 0 : this.props.defaultIndex
|
|
17
|
-
|
|
18
|
-
this.state = {
|
|
19
|
-
selectedIndex: initIndex
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
SetCurrentIndex = (index: number)=>{
|
|
24
|
-
if(index < 0 || index >= (this.props.children as any).length) return
|
|
25
|
-
this.setState({
|
|
26
|
-
selectedIndex: index
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
render(){
|
|
31
|
-
return(
|
|
32
|
-
<div style={this.props.tabBarStyle}>
|
|
33
|
-
{(this.props.children as any).map((v, index)=>{
|
|
34
|
-
if(v.type != Tab) return v; // 留的口子,方便往Tabs里插入一些东西
|
|
35
|
-
return(
|
|
36
|
-
<div onClick={()=>{
|
|
37
|
-
if (this.state.selectedIndex == index) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
this.setState(
|
|
41
|
-
{
|
|
42
|
-
selectedIndex: index
|
|
43
|
-
},
|
|
44
|
-
()=>{
|
|
45
|
-
this.props.onChoose(this.state.selectedIndex)
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
}}>
|
|
49
|
-
{v}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
})}
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { h, Component, CSSProperties, toChildArray } from "preact";
|
|
2
|
-
|
|
3
|
-
interface togglePicInfo {
|
|
4
|
-
selected_pic: string,
|
|
5
|
-
not_selected_pic: string,
|
|
6
|
-
}
|
|
7
|
-
interface toggleInfo {
|
|
8
|
-
toggleText: string,
|
|
9
|
-
isSelected:boolean,
|
|
10
|
-
selectedFun: Function,
|
|
11
|
-
notSelectedFun: Function,
|
|
12
|
-
}
|
|
13
|
-
export class ToggleGroup extends Component<any, any>{
|
|
14
|
-
private isMultiOption: boolean;
|
|
15
|
-
private toggleArray:toggleInfo[];
|
|
16
|
-
private togglePic: togglePicInfo;
|
|
17
|
-
private currentIndex: number;
|
|
18
|
-
private items;
|
|
19
|
-
private refreshAll;
|
|
20
|
-
private GenerateToggleItem = (toggleItem:toggleInfo,togglePic:togglePicInfo,index:number,refreshAll:boolean)=>{
|
|
21
|
-
return <Toggle toggleText = {toggleItem.toggleText} selectedFun = {toggleItem.selectedFun} notSelectedFun = {toggleItem.notSelectedFun}
|
|
22
|
-
isSelected = {toggleItem.isSelected} selected_pic = {togglePic.selected_pic} not_selected_pic = {togglePic.not_selected_pic}
|
|
23
|
-
index = {index} checkSelected = {this.checkSelected} refreshAll = {this.refreshAll}/>
|
|
24
|
-
}
|
|
25
|
-
private checkSelected = (index) => {
|
|
26
|
-
if(this.isMultiOption) return;
|
|
27
|
-
else{
|
|
28
|
-
if(index == this.currentIndex) {this.toggleArray[index].isSelected = false; this.currentIndex = -1;}
|
|
29
|
-
else{
|
|
30
|
-
if(this.currentIndex == -1) {
|
|
31
|
-
this.currentIndex = index;
|
|
32
|
-
this.toggleArray[index].isSelected = true;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.refreshAll = !this.refreshAll;
|
|
36
|
-
this.toggleArray[this.currentIndex].isSelected = false;
|
|
37
|
-
this.toggleArray[this.currentIndex].notSelectedFun();
|
|
38
|
-
this.toggleArray[index].isSelected = true;
|
|
39
|
-
this.currentIndex = index;
|
|
40
|
-
this.items = [];
|
|
41
|
-
this.forceUpdate();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
constructor(props) {
|
|
46
|
-
super(props)
|
|
47
|
-
this.toggleArray = props.toggleArray;
|
|
48
|
-
for(let i = 0;i<this.toggleArray.length;i++){
|
|
49
|
-
this.toggleArray[i].isSelected = false;
|
|
50
|
-
}
|
|
51
|
-
this.togglePic = props.togglePic;
|
|
52
|
-
this.isMultiOption = props.isMultiOption!=undefined? props.isMultiOption:true;
|
|
53
|
-
this.currentIndex = -1;
|
|
54
|
-
this.refreshAll = true;
|
|
55
|
-
this.items = [];
|
|
56
|
-
}
|
|
57
|
-
render(props) {
|
|
58
|
-
for(let i = 0;i<this.toggleArray.length;i++){
|
|
59
|
-
this.items.push(this.GenerateToggleItem(this.toggleArray[i],this.togglePic,i,this.refreshAll))
|
|
60
|
-
}
|
|
61
|
-
return(
|
|
62
|
-
<div style = {{flexDirection:"row"}}>{this.items}</div>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
class Toggle extends Component<any, any>{
|
|
67
|
-
private selected_pic;
|
|
68
|
-
private not_selected_pic;
|
|
69
|
-
private toggleText;
|
|
70
|
-
private selectedFun;
|
|
71
|
-
private notSelectedFun;
|
|
72
|
-
private index;
|
|
73
|
-
private checkSelected;
|
|
74
|
-
private refreshAll;
|
|
75
|
-
|
|
76
|
-
constructor(props) {
|
|
77
|
-
super(props)
|
|
78
|
-
this.selected_pic = props.selected_pic;
|
|
79
|
-
this.not_selected_pic = props.not_selected_pic;
|
|
80
|
-
this.toggleText = props.toggleText;
|
|
81
|
-
this.selectedFun = props.selectedFun;
|
|
82
|
-
this.notSelectedFun = props.notSelectedFun;
|
|
83
|
-
this.index = props.index;
|
|
84
|
-
this.checkSelected = props.checkSelected;
|
|
85
|
-
this.refreshAll = props.refreshAll;
|
|
86
|
-
this.state = {
|
|
87
|
-
isSelected: props.isSelected
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
render(props) {
|
|
91
|
-
if(props.refreshAll!=this.refreshAll && props.isSelected != this.state.isSelected) {
|
|
92
|
-
this.setState({isSelected:!this.state.isSelected})
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this.refreshAll = props.refreshAll;
|
|
96
|
-
return (
|
|
97
|
-
<div style={{flexDirection:"row"}}>
|
|
98
|
-
<div style={{ width: "36px", height: "36px", backgroundSize:"contain",backgroundImage: `url(${this.state.isSelected ? this.selected_pic : this.not_selected_pic})` }}
|
|
99
|
-
onClick={() => { this.state.isSelected ? this.notSelectedFun() : this.selectedFun();this.setState({isSelected:!this.state.isSelected});this.checkSelected(this.index) }}></div>
|
|
100
|
-
<div style={{alignItems:"end"}}><text>{`${this.toggleText}`}</text></div>
|
|
101
|
-
<div style={{width:"50px"}}></div>
|
|
102
|
-
</div>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
}
|