pixuireactcomponents 0.0.0
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 +17 -0
- package/index.js +18 -0
- package/package.json +11 -0
- 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 +6 -0
- package/ui/components/button/Button.js +66 -0
- package/ui/components/carousel/Carousel.d.ts +5 -0
- package/ui/components/carousel/Carousel.js +226 -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.js +329 -0
- package/ui/components/imageViewer/imageViewer.d.ts +23 -0
- package/ui/components/imageViewer/imageViewer.js +149 -0
- package/ui/components/outlinetext/OutlineText.d.ts +94 -0
- package/ui/components/outlinetext/OutlineText.js +167 -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 +18 -0
- package/ui/components/slapface/Slapface.js +485 -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/ui/components/togglegroup/ToggleGroup.d.ts +13 -0
- package/ui/components/togglegroup/ToggleGroup.js +99 -0
- package/ui/sample/Images.d.ts +28 -0
- package/ui/sample/Images.js +54 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
import { Component, createRef, h } from 'preact';
|
|
28
|
+
var row_center_center = {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center'
|
|
33
|
+
};
|
|
34
|
+
var row_between_center = {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
justifyContent: 'space-between',
|
|
38
|
+
alignItems: 'center'
|
|
39
|
+
};
|
|
40
|
+
var wrapperStyle;
|
|
41
|
+
var outerStyle;
|
|
42
|
+
var innerStyle;
|
|
43
|
+
var dotStyle;
|
|
44
|
+
var dotWrapperStyle;
|
|
45
|
+
var incButtonStyle;
|
|
46
|
+
var decButtonStyle;
|
|
47
|
+
var withButtonStyle;
|
|
48
|
+
var lastX = undefined; // 上一次位置的横坐标
|
|
49
|
+
var count = 0; // 拖动条距离最左端的位置 [0, this.props.wrapperWidth]
|
|
50
|
+
var rect = undefined; // 滑动区域
|
|
51
|
+
var Slider = /** @class */ (function (_super) {
|
|
52
|
+
__extends(Slider, _super);
|
|
53
|
+
function Slider(props) {
|
|
54
|
+
var _this = _super.call(this, props) || this;
|
|
55
|
+
_this.discrete = Math.round(_this.props.discrete == null ? 0 : _this.props.discrete);
|
|
56
|
+
_this.refWrapper = createRef();
|
|
57
|
+
_this.onDragStart = function (event) {
|
|
58
|
+
console.log('【Slider】DragStart event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
|
|
59
|
+
lastX = event.clentX;
|
|
60
|
+
count = _this.state.percent / 10000 * _this.props.wrapperWidth;
|
|
61
|
+
if (_this.props.onDragStart) {
|
|
62
|
+
_this.props.onDragStart();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
_this.onDrag = function (event) {
|
|
66
|
+
if (event.clientX < rect.left - 50 || event.clientX > rect.right + 50)
|
|
67
|
+
return;
|
|
68
|
+
if (lastX == undefined) {
|
|
69
|
+
lastX = event.clientX;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
var move = Number(event.clientX) - Number(lastX);
|
|
73
|
+
count += move;
|
|
74
|
+
count = Math.min(_this.props.wrapperWidth, count);
|
|
75
|
+
count = Math.max(0, count);
|
|
76
|
+
var newPercent = count / _this.props.wrapperWidth * 10000;
|
|
77
|
+
if (_this.props.isDiscrete == true && _this.props.maxDiscrete != null) {
|
|
78
|
+
newPercent = count / _this.props.wrapperWidth * _this.props.maxDiscrete;
|
|
79
|
+
_this.discrete = Math.round(newPercent);
|
|
80
|
+
// this.setState({
|
|
81
|
+
// discrete: Math.round(newPercent),
|
|
82
|
+
// })
|
|
83
|
+
if (_this.props.rangeControl) {
|
|
84
|
+
if (_this.props.endRange != null)
|
|
85
|
+
_this.discrete = Math.min(_this.discrete, _this.props.endRange);
|
|
86
|
+
if (_this.props.startRange != null)
|
|
87
|
+
_this.discrete = Math.max(_this.discrete, _this.props.startRange);
|
|
88
|
+
}
|
|
89
|
+
newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
|
|
90
|
+
}
|
|
91
|
+
_this.setState({
|
|
92
|
+
percent: newPercent
|
|
93
|
+
}, function () {
|
|
94
|
+
console.log('【Slider】OnDrag event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----discrete----' + _this.discrete + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
|
|
95
|
+
if (_this.props.onDrag)
|
|
96
|
+
_this.props.onDrag(_this.props.isDiscrete ? _this.discrete : newPercent);
|
|
97
|
+
});
|
|
98
|
+
lastX = event.clientX;
|
|
99
|
+
};
|
|
100
|
+
_this.onDragEnd = function (event) {
|
|
101
|
+
lastX = undefined;
|
|
102
|
+
if (_this.props.isDiscrete == true && _this.props.maxDiscrete != null) {
|
|
103
|
+
//console.log("OnDragEnd -----discrete----"+this.state.discrete)
|
|
104
|
+
_this.setState({
|
|
105
|
+
percent: _this.discrete * (10000 / _this.props.maxDiscrete),
|
|
106
|
+
}, function () {
|
|
107
|
+
console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----discrete----' + _this.discrete + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
|
|
108
|
+
if (_this.props.onDragEnd) {
|
|
109
|
+
_this.props.onDragEnd(_this.props.isDiscrete ? _this.discrete : _this.state.percent);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
|
|
115
|
+
if (_this.props.onDragEnd) {
|
|
116
|
+
_this.props.onDragEnd(_this.props.isDiscrete ? _this.discrete : _this.state.percent);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
_this.onDecClick = function () {
|
|
121
|
+
//离散的情况
|
|
122
|
+
if (_this.props.isDiscrete && _this.props.maxDiscrete) {
|
|
123
|
+
if (_this.discrete >= 1) {
|
|
124
|
+
_this.discrete -= 1;
|
|
125
|
+
if (_this.props.rangeControl && _this.props.startRange != null) {
|
|
126
|
+
_this.discrete = Math.max(_this.discrete, _this.props.startRange);
|
|
127
|
+
}
|
|
128
|
+
var newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
|
|
129
|
+
_this.setState({
|
|
130
|
+
//discrete: this.state.discrete - 1,
|
|
131
|
+
percent: newPercent
|
|
132
|
+
}, function () {
|
|
133
|
+
if (_this.props.onDecClick) {
|
|
134
|
+
_this.props.onDecClick(_this.discrete);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//连续的情况
|
|
140
|
+
else {
|
|
141
|
+
if (_this.state.percent > 0) {
|
|
142
|
+
_this.setState({
|
|
143
|
+
percent: _this.state.percent - 1
|
|
144
|
+
}, function () {
|
|
145
|
+
if (_this.props.onDecClick) {
|
|
146
|
+
_this.props.onDecClick(_this.state.percent);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
_this.onIncClick = function () {
|
|
153
|
+
//离散的情况
|
|
154
|
+
if (_this.props.isDiscrete && _this.props.maxDiscrete) {
|
|
155
|
+
if (_this.discrete < _this.props.maxDiscrete) {
|
|
156
|
+
_this.discrete += 1;
|
|
157
|
+
if (_this.props.rangeControl && _this.props.startRange != null) {
|
|
158
|
+
_this.discrete = Math.max(_this.discrete, _this.props.startRange);
|
|
159
|
+
}
|
|
160
|
+
var newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
|
|
161
|
+
_this.setState({
|
|
162
|
+
// discrete: this.state.discrete + 1,
|
|
163
|
+
percent: newPercent
|
|
164
|
+
}, function () {
|
|
165
|
+
if (_this.props.onIncClick) {
|
|
166
|
+
_this.props.onIncClick(_this.discrete);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//连续的情况
|
|
172
|
+
else {
|
|
173
|
+
if (_this.state.percent < 10000) {
|
|
174
|
+
_this.setState({
|
|
175
|
+
percent: _this.state.percent + 1
|
|
176
|
+
}, function () {
|
|
177
|
+
if (_this.props.onIncClick) {
|
|
178
|
+
_this.props.onIncClick(_this.state.percent);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
_this.computeWrapperStyle = function () {
|
|
185
|
+
wrapperStyle = __assign({ width: _this.props.wrapperWidth + 'px', height: _this.props.wrapperHeight + 'px' }, row_center_center);
|
|
186
|
+
};
|
|
187
|
+
_this.computeOuterStyle = function () {
|
|
188
|
+
outerStyle = {
|
|
189
|
+
width: '100%',
|
|
190
|
+
height: _this.props.height + 'px',
|
|
191
|
+
backgroundImage: "url(".concat(_this.props.outerBg, ")"),
|
|
192
|
+
backgroundSize: '100% 100%',
|
|
193
|
+
display: 'flex',
|
|
194
|
+
flexDirection: 'row',
|
|
195
|
+
justifyContent: 'start',
|
|
196
|
+
alignItems: 'center'
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
_this.computeInnerStyle = function () {
|
|
200
|
+
var _width = Math.floor(_this.state.percent / 100) + '%';
|
|
201
|
+
innerStyle = {
|
|
202
|
+
width: _width,
|
|
203
|
+
height: (_this.props.innerHeight != null) ? _this.props.innerHeight + 'px' : '100%',
|
|
204
|
+
backgroundImage: "url(".concat(_this.props.innerBg, ")"),
|
|
205
|
+
backgroundSize: '100% 100%',
|
|
206
|
+
display: 'flex',
|
|
207
|
+
flexDirection: 'row',
|
|
208
|
+
justifyContent: 'start',
|
|
209
|
+
alignItems: 'center'
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
_this.computeDotWrapperStyle = function () {
|
|
213
|
+
dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px',
|
|
214
|
+
//marginTop: (this.props.height - this.props.dotWrapperHeight) / 2 + "px",
|
|
215
|
+
marginLeft: (_this.props.wrapperWidth * _this.state.percent / 10000 - _this.props.dotWrapperWidth / 2) + 'px' }, row_center_center
|
|
216
|
+
// backgroundColor: '#FF000066'
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
_this.computeDotStyle = function () {
|
|
220
|
+
dotStyle = {
|
|
221
|
+
width: _this.props.dotWidth + 'px',
|
|
222
|
+
height: _this.props.dotHeight + 'px',
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
_this.computeIncButtonStyle = function () {
|
|
226
|
+
incButtonStyle = {
|
|
227
|
+
width: _this.props.incButtonWidth + 'px',
|
|
228
|
+
height: _this.props.incButtonHeight + 'px',
|
|
229
|
+
//marginLeft:this.props.incButtonLeft+"px",
|
|
230
|
+
//backgroundImage: `url(${this.props.incButtonBg})`,
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
_this.computeDecButtonStyle = function () {
|
|
234
|
+
decButtonStyle = {
|
|
235
|
+
width: _this.props.decButtonWidth + 'px',
|
|
236
|
+
height: _this.props.decButtonHeight + 'px',
|
|
237
|
+
//marginRight:this.props.decButtonRight+"px",
|
|
238
|
+
//backgroundImage: `url(${this.props.decButtonBg})`,
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
_this.computeWithButtonStyle = function () {
|
|
242
|
+
withButtonStyle = __assign({ minWidth: _this.props.overallWidth + 'px' }, row_between_center);
|
|
243
|
+
};
|
|
244
|
+
_this.state = {
|
|
245
|
+
percent: (props.discrete != null && _this.props.maxDiscrete != null && _this.props.discrete != null) ? _this.props.discrete * (10000 / _this.props.maxDiscrete) : Math.floor(_this.props.percent),
|
|
246
|
+
//discrete: Math.round(this.props.discrete==null?0:this.props.discrete)
|
|
247
|
+
};
|
|
248
|
+
_this.computeWrapperStyle();
|
|
249
|
+
_this.computeOuterStyle();
|
|
250
|
+
return _this;
|
|
251
|
+
}
|
|
252
|
+
Slider.prototype.componentDidMount = function () {
|
|
253
|
+
rect = this.refWrapper.current.getBoundingClientRect();
|
|
254
|
+
};
|
|
255
|
+
Slider.prototype.componentWillReceiveProps = function (nextProps) {
|
|
256
|
+
if (nextProps.percent == this.props.percent && nextProps.discrete == this.props.discrete)
|
|
257
|
+
return;
|
|
258
|
+
if (this.props.isDiscrete == true && this.props.maxDiscrete != null) {
|
|
259
|
+
this.discrete = nextProps.discrete;
|
|
260
|
+
this.setState({
|
|
261
|
+
//discrete:nextProps.discrete,
|
|
262
|
+
percent: this.discrete * (10000 / this.props.maxDiscrete)
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
this.setState({
|
|
267
|
+
percent: nextProps.percent,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
Slider.prototype.render = function () {
|
|
272
|
+
this.computeInnerStyle();
|
|
273
|
+
this.computeDotWrapperStyle();
|
|
274
|
+
this.computeDotStyle();
|
|
275
|
+
this.computeIncButtonStyle();
|
|
276
|
+
this.computeDecButtonStyle();
|
|
277
|
+
this.computeWithButtonStyle();
|
|
278
|
+
return (h("div", { style: this.props.hasIncDecButton ? withButtonStyle : {} },
|
|
279
|
+
this.props.hasIncDecButton && h("img", { src: this.props.decButtonBg, style: decButtonStyle, onClick: this.onDecClick }),
|
|
280
|
+
h("div", { ref: this.refWrapper, style: wrapperStyle },
|
|
281
|
+
h("div", { style: outerStyle },
|
|
282
|
+
h("div", { style: innerStyle },
|
|
283
|
+
h("div", { style: dotWrapperStyle, draggable: true, onDragStart: this.onDragStart, onDrag: this.onDrag, onDragEnd: this.onDragEnd },
|
|
284
|
+
h("img", { src: this.props.dotBg, style: dotStyle }))))),
|
|
285
|
+
this.props.hasIncDecButton && h("img", { src: this.props.incButtonBg, style: incButtonStyle, onClick: this.onIncClick })));
|
|
286
|
+
};
|
|
287
|
+
return Slider;
|
|
288
|
+
}(Component));
|
|
289
|
+
export { Slider };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { Component } from "preact";
|
|
17
|
+
var Tab = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Tab, _super);
|
|
19
|
+
function Tab() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
Tab.prototype.render = function () {
|
|
23
|
+
return (this.props.realTab);
|
|
24
|
+
};
|
|
25
|
+
return Tab;
|
|
26
|
+
}(Component));
|
|
27
|
+
export { Tab };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component, CSSProperties, h } from "preact";
|
|
2
|
+
export declare class Tabs extends Component<{
|
|
3
|
+
tabBarStyle: CSSProperties;
|
|
4
|
+
onChoose: Function;
|
|
5
|
+
defaultIndex: number | null;
|
|
6
|
+
}, {
|
|
7
|
+
selectedIndex: number;
|
|
8
|
+
}> {
|
|
9
|
+
constructor(props: any);
|
|
10
|
+
SetCurrentIndex: (index: number) => void;
|
|
11
|
+
render(): h.JSX.Element;
|
|
12
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { Component, h } from "preact";
|
|
17
|
+
import { Tab } from "./Tab";
|
|
18
|
+
var Tabs = /** @class */ (function (_super) {
|
|
19
|
+
__extends(Tabs, _super);
|
|
20
|
+
function Tabs(props) {
|
|
21
|
+
var _this = _super.call(this, props) || this;
|
|
22
|
+
_this.SetCurrentIndex = function (index) {
|
|
23
|
+
if (index < 0 || index >= _this.props.children.length)
|
|
24
|
+
return;
|
|
25
|
+
_this.setState({
|
|
26
|
+
selectedIndex: index
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var initIndex = _this.props.defaultIndex == null ? 0 : _this.props.defaultIndex;
|
|
30
|
+
_this.state = {
|
|
31
|
+
selectedIndex: initIndex
|
|
32
|
+
};
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
Tabs.prototype.render = function () {
|
|
36
|
+
var _this = this;
|
|
37
|
+
return (h("div", { style: this.props.tabBarStyle }, this.props.children.map(function (v, index) {
|
|
38
|
+
if (v.type != Tab)
|
|
39
|
+
return v; // 留的口子,方便往Tabs里插入一些东西
|
|
40
|
+
return (h("div", { onClick: function () {
|
|
41
|
+
if (_this.state.selectedIndex == index) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
_this.setState({
|
|
45
|
+
selectedIndex: index
|
|
46
|
+
}, function () {
|
|
47
|
+
_this.props.onChoose(_this.state.selectedIndex);
|
|
48
|
+
});
|
|
49
|
+
} }, v));
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
52
|
+
return Tabs;
|
|
53
|
+
}(Component));
|
|
54
|
+
export { Tabs };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { h, Component } from "preact";
|
|
2
|
+
export declare class ToggleGroup extends Component<any, any> {
|
|
3
|
+
private isMultiOption;
|
|
4
|
+
private toggleArray;
|
|
5
|
+
private togglePic;
|
|
6
|
+
private currentIndex;
|
|
7
|
+
private items;
|
|
8
|
+
private refreshAll;
|
|
9
|
+
private GenerateToggleItem;
|
|
10
|
+
private checkSelected;
|
|
11
|
+
constructor(props: any);
|
|
12
|
+
render(props: any): h.JSX.Element;
|
|
13
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { h, Component } from "preact";
|
|
17
|
+
var ToggleGroup = /** @class */ (function (_super) {
|
|
18
|
+
__extends(ToggleGroup, _super);
|
|
19
|
+
function ToggleGroup(props) {
|
|
20
|
+
var _this = _super.call(this, props) || this;
|
|
21
|
+
_this.GenerateToggleItem = function (toggleItem, togglePic, index, refreshAll) {
|
|
22
|
+
return h(Toggle, { toggleText: toggleItem.toggleText, selectedFun: toggleItem.selectedFun, notSelectedFun: toggleItem.notSelectedFun, isSelected: toggleItem.isSelected, selected_pic: togglePic.selected_pic, not_selected_pic: togglePic.not_selected_pic, index: index, checkSelected: _this.checkSelected, refreshAll: _this.refreshAll });
|
|
23
|
+
};
|
|
24
|
+
_this.checkSelected = function (index) {
|
|
25
|
+
if (_this.isMultiOption)
|
|
26
|
+
return;
|
|
27
|
+
else {
|
|
28
|
+
if (index == _this.currentIndex) {
|
|
29
|
+
_this.toggleArray[index].isSelected = false;
|
|
30
|
+
_this.currentIndex = -1;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (_this.currentIndex == -1) {
|
|
34
|
+
_this.currentIndex = index;
|
|
35
|
+
_this.toggleArray[index].isSelected = true;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
_this.refreshAll = !_this.refreshAll;
|
|
39
|
+
_this.toggleArray[_this.currentIndex].isSelected = false;
|
|
40
|
+
_this.toggleArray[_this.currentIndex].notSelectedFun();
|
|
41
|
+
_this.toggleArray[index].isSelected = true;
|
|
42
|
+
_this.currentIndex = index;
|
|
43
|
+
_this.items = [];
|
|
44
|
+
_this.forceUpdate();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
_this.toggleArray = props.toggleArray;
|
|
49
|
+
for (var i = 0; i < _this.toggleArray.length; i++) {
|
|
50
|
+
_this.toggleArray[i].isSelected = false;
|
|
51
|
+
}
|
|
52
|
+
_this.togglePic = props.togglePic;
|
|
53
|
+
_this.isMultiOption = props.isMultiOption != undefined ? props.isMultiOption : true;
|
|
54
|
+
_this.currentIndex = -1;
|
|
55
|
+
_this.refreshAll = true;
|
|
56
|
+
_this.items = [];
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
ToggleGroup.prototype.render = function (props) {
|
|
60
|
+
for (var i = 0; i < this.toggleArray.length; i++) {
|
|
61
|
+
this.items.push(this.GenerateToggleItem(this.toggleArray[i], this.togglePic, i, this.refreshAll));
|
|
62
|
+
}
|
|
63
|
+
return (h("div", { style: { flexDirection: "row" } }, this.items));
|
|
64
|
+
};
|
|
65
|
+
return ToggleGroup;
|
|
66
|
+
}(Component));
|
|
67
|
+
export { ToggleGroup };
|
|
68
|
+
var Toggle = /** @class */ (function (_super) {
|
|
69
|
+
__extends(Toggle, _super);
|
|
70
|
+
function Toggle(props) {
|
|
71
|
+
var _this = _super.call(this, props) || this;
|
|
72
|
+
_this.selected_pic = props.selected_pic;
|
|
73
|
+
_this.not_selected_pic = props.not_selected_pic;
|
|
74
|
+
_this.toggleText = props.toggleText;
|
|
75
|
+
_this.selectedFun = props.selectedFun;
|
|
76
|
+
_this.notSelectedFun = props.notSelectedFun;
|
|
77
|
+
_this.index = props.index;
|
|
78
|
+
_this.checkSelected = props.checkSelected;
|
|
79
|
+
_this.refreshAll = props.refreshAll;
|
|
80
|
+
_this.state = {
|
|
81
|
+
isSelected: props.isSelected
|
|
82
|
+
};
|
|
83
|
+
return _this;
|
|
84
|
+
}
|
|
85
|
+
Toggle.prototype.render = function (props) {
|
|
86
|
+
var _this = this;
|
|
87
|
+
if (props.refreshAll != this.refreshAll && props.isSelected != this.state.isSelected) {
|
|
88
|
+
this.setState({ isSelected: !this.state.isSelected });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.refreshAll = props.refreshAll;
|
|
92
|
+
return (h("div", { style: { alignItems: "flex-end", flexDirection: "row" } },
|
|
93
|
+
h("div", { style: { width: "36px", height: "36px", backgroundSize: "contain", backgroundImage: "url(".concat(this.state.isSelected ? this.selected_pic : this.not_selected_pic, ")") }, onClick: function () { _this.state.isSelected ? _this.notSelectedFun() : _this.selectedFun(); _this.setState({ isSelected: !_this.state.isSelected }); _this.checkSelected(_this.index); } }),
|
|
94
|
+
h("div", null,
|
|
95
|
+
h("text", null, "".concat(this.toggleText))),
|
|
96
|
+
h("div", { style: { width: "50px" } })));
|
|
97
|
+
};
|
|
98
|
+
return Toggle;
|
|
99
|
+
}(Component));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const Images: {
|
|
2
|
+
btn_close: any;
|
|
3
|
+
changtai_button: any;
|
|
4
|
+
checkbox0: any;
|
|
5
|
+
checkbox1: any;
|
|
6
|
+
data_arrow_down: any;
|
|
7
|
+
data_arrow_up: any;
|
|
8
|
+
dot: any;
|
|
9
|
+
inner: any;
|
|
10
|
+
item_reddot: any;
|
|
11
|
+
loading: any;
|
|
12
|
+
money_dropdown: any;
|
|
13
|
+
money_dropdownall: any;
|
|
14
|
+
outer: any;
|
|
15
|
+
tab_choosed: any;
|
|
16
|
+
tabs_bg: any;
|
|
17
|
+
video_pause: any;
|
|
18
|
+
video_play: any;
|
|
19
|
+
video_reload: any;
|
|
20
|
+
xuanfu_button: any;
|
|
21
|
+
yaxia_button: any;
|
|
22
|
+
slapface_samplepic1: any;
|
|
23
|
+
slapface_samplepic2: any;
|
|
24
|
+
slapface_samplepic3: any;
|
|
25
|
+
slapface_samplepic4: any;
|
|
26
|
+
slapface_samplepic5: any;
|
|
27
|
+
slapface_samplepic6: any;
|
|
28
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import btn_close from './asset/btn_close.png';
|
|
2
|
+
import changtai_button from './asset/changtai_button.jpg';
|
|
3
|
+
import checkbox0 from './asset/checkbox0.png';
|
|
4
|
+
import checkbox1 from './asset/checkbox1.png';
|
|
5
|
+
import data_arrow_down from './asset/data_arrow_down.png';
|
|
6
|
+
import data_arrow_up from './asset/data_arrow_up.png';
|
|
7
|
+
import dot from './asset/dot.png';
|
|
8
|
+
import inner from './asset/inner.png';
|
|
9
|
+
import item_reddot from './asset/item_reddot.png';
|
|
10
|
+
import loading from './asset/loading.png';
|
|
11
|
+
import money_dropdown from './asset/money_dropdown.png';
|
|
12
|
+
import money_dropdownall from './asset/money_dropdownall.png';
|
|
13
|
+
import outer from './asset/outer.png';
|
|
14
|
+
import tab_choosed from './asset/tab_choosed.png';
|
|
15
|
+
import tabs_bg from './asset/tabs_bg.png';
|
|
16
|
+
import video_pause from './asset/video_pause.png';
|
|
17
|
+
import video_play from './asset/video_play.png';
|
|
18
|
+
import video_reload from './asset/video_reload.png';
|
|
19
|
+
import xuanfu_button from './asset/xuanfu_button.jpg';
|
|
20
|
+
import yaxia_button from './asset/yaxia_button.jpg';
|
|
21
|
+
import slapface_samplepic1 from './asset/slapface_samplepic1.png';
|
|
22
|
+
import slapface_samplepic2 from './asset/slapface_samplepic2.png';
|
|
23
|
+
import slapface_samplepic3 from './asset/slapface_samplepic3.png';
|
|
24
|
+
import slapface_samplepic4 from './asset/slapface_samplepic4.png';
|
|
25
|
+
import slapface_samplepic5 from './asset/slapface_samplepic5.png';
|
|
26
|
+
import slapface_samplepic6 from './asset/slapface_samplepic6.png';
|
|
27
|
+
export var Images = {
|
|
28
|
+
btn_close: btn_close,
|
|
29
|
+
changtai_button: changtai_button,
|
|
30
|
+
checkbox0: checkbox0,
|
|
31
|
+
checkbox1: checkbox1,
|
|
32
|
+
data_arrow_down: data_arrow_down,
|
|
33
|
+
data_arrow_up: data_arrow_up,
|
|
34
|
+
dot: dot,
|
|
35
|
+
inner: inner,
|
|
36
|
+
item_reddot: item_reddot,
|
|
37
|
+
loading: loading,
|
|
38
|
+
money_dropdown: money_dropdown,
|
|
39
|
+
money_dropdownall: money_dropdownall,
|
|
40
|
+
outer: outer,
|
|
41
|
+
tab_choosed: tab_choosed,
|
|
42
|
+
tabs_bg: tabs_bg,
|
|
43
|
+
video_pause: video_pause,
|
|
44
|
+
video_play: video_play,
|
|
45
|
+
video_reload: video_reload,
|
|
46
|
+
xuanfu_button: xuanfu_button,
|
|
47
|
+
yaxia_button: yaxia_button,
|
|
48
|
+
slapface_samplepic1: slapface_samplepic1,
|
|
49
|
+
slapface_samplepic2: slapface_samplepic2,
|
|
50
|
+
slapface_samplepic3: slapface_samplepic3,
|
|
51
|
+
slapface_samplepic4: slapface_samplepic4,
|
|
52
|
+
slapface_samplepic5: slapface_samplepic5,
|
|
53
|
+
slapface_samplepic6: slapface_samplepic6
|
|
54
|
+
};
|