pixuireactcomponents 1.2.2 → 1.2.3
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/slapface/less/Slapface.less +0 -112
- 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
|
@@ -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.onIncClick) {
|
|
146
|
+
_this.props.onIncClick(_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 };
|
package/cmdAfterTsBuild.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const { copyFile, copyFileSync } = require("fs");
|
|
2
|
-
|
|
3
|
-
const PUBLISH_PATH = "publish_components"
|
|
4
|
-
|
|
5
|
-
copyFileSync("./ui/ui.md", `./../${PUBLISH_PATH}/ui/ui.md`, )
|
|
6
|
-
copyFileSync("./tools/tools.md", `./../${PUBLISH_PATH}/tools/tools.md`)
|
|
7
|
-
copyFileSync("./README.md", `./../${PUBLISH_PATH}/README.md`)
|
|
8
|
-
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
class EventDispatcherCls { //变量在对象实例上,方法在原型上
|
|
2
|
-
private listeners = {};
|
|
3
|
-
|
|
4
|
-
AddEventListener(eventName:string, listener:any, ...args)
|
|
5
|
-
{
|
|
6
|
-
if (listener == undefined){
|
|
7
|
-
console.warn("listener为空, eventName: "+ eventName);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let listeners = this.listeners;
|
|
12
|
-
if (listeners[eventName] == undefined) {
|
|
13
|
-
listeners[eventName] = [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let eventList:Array<Object> = listeners[eventName];
|
|
17
|
-
eventList.forEach(function (v:any) {
|
|
18
|
-
if (v.eventName == eventName && v.listener == listener){
|
|
19
|
-
console.warn("重复添加的事件监听, eventName: " + eventName);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
eventList.push({"eventName":eventName,"listener":listener,"args":args,});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
HasEventListener(eventName:string){
|
|
28
|
-
if (this.listeners[eventName] == undefined || this.listeners[eventName].length == 0){
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
RemoveEventListener(eventName:string, listener){
|
|
36
|
-
if (this.HasEventListener(eventName) == false){
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let eventList:Array<Object> = this.listeners[eventName];
|
|
41
|
-
for (let i = eventList.length - 1; i >=0; --i) {
|
|
42
|
-
let event:any = eventList[i];
|
|
43
|
-
if (event.eventName == eventName && event.listener == listener) {
|
|
44
|
-
eventList.splice(i, 1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (eventList.length == 0){
|
|
49
|
-
this.listeners[eventName] = null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
RemoveEventAllListener(eventName:string){
|
|
54
|
-
if (this.HasEventListener(eventName)){
|
|
55
|
-
this.listeners[eventName] = null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
DispatchEvent(eventName:string, ...args){
|
|
60
|
-
if (eventName == undefined || this.HasEventListener(eventName) == false){
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let eventList:Array<Object> = this.listeners[eventName].slice(0);
|
|
65
|
-
for (let i = 0; i < eventList.length; ++i) {
|
|
66
|
-
let obj:any = eventList[i];
|
|
67
|
-
let listener:any = obj.listener;
|
|
68
|
-
// listener.apply(this, obj.args.concat(args));
|
|
69
|
-
listener(...obj.args.concat(args))
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export let EventDispatcherJs = Object.freeze(new EventDispatcherCls());
|
package/tools/Logger.tsx
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
export function Logger(){
|
|
2
|
-
}
|
|
3
|
-
|
|
4
|
-
// 移除最后一个(key, value)后面的 ','
|
|
5
|
-
let regex = new RegExp("(,)(\n$)");
|
|
6
|
-
/**
|
|
7
|
-
* printer1: 完整打印,用4个空格缩进
|
|
8
|
-
* @param object Object
|
|
9
|
-
* @param name string
|
|
10
|
-
*/
|
|
11
|
-
Logger.ObjectPrinter = function(object, name){
|
|
12
|
-
let strResult = "";
|
|
13
|
-
strResult += name + " = ";
|
|
14
|
-
strResult += getTreeStyleStr(object, 1);
|
|
15
|
-
|
|
16
|
-
strResult = strResult.replace(regex, "$2");
|
|
17
|
-
console.warn(strResult);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getTreeStyleStr(object, level){
|
|
21
|
-
const isArray = object instanceof Array
|
|
22
|
-
let str = isArray ? "[\n" : "{\n";
|
|
23
|
-
for (const key in object) {
|
|
24
|
-
let value = object[key];
|
|
25
|
-
let curSeparation = getSeparation1(level);
|
|
26
|
-
|
|
27
|
-
if(typeof(value) != 'object'){
|
|
28
|
-
str += curSeparation + key + " : " + value + ",\n";
|
|
29
|
-
}
|
|
30
|
-
else{
|
|
31
|
-
str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
str = str.replace(regex, "$2");
|
|
36
|
-
str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
|
|
37
|
-
return str;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const SEPARARION1 = " ";
|
|
41
|
-
function getSeparation1(level){
|
|
42
|
-
let totalSeparation = "";
|
|
43
|
-
while(level > 0){
|
|
44
|
-
totalSeparation += SEPARARION1;
|
|
45
|
-
level--;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return totalSeparation;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
let regexForLine = new RegExp(",$")
|
|
53
|
-
/**
|
|
54
|
-
* printer2: 完整打印,用\t
|
|
55
|
-
* @param object Object
|
|
56
|
-
* @param name sring
|
|
57
|
-
*/
|
|
58
|
-
Logger.ObjectPrinter2 = function(object, name){
|
|
59
|
-
let lines: string[] = []
|
|
60
|
-
lines.push(`${name} = `)
|
|
61
|
-
getTreeStyleLines(object, 1, lines)
|
|
62
|
-
|
|
63
|
-
console.warn(lines.join("\n"))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function getTreeStyleLines(object: Object, level: number, lines: string[]){
|
|
67
|
-
const isArray = object instanceof Array
|
|
68
|
-
let linePostFix = isArray ? "[" : "{"
|
|
69
|
-
|
|
70
|
-
let lastLine = lines.pop()
|
|
71
|
-
lines.push(lastLine + linePostFix)
|
|
72
|
-
|
|
73
|
-
for (const key in object) {
|
|
74
|
-
const value = object[key];
|
|
75
|
-
const curSeparation = getSeparation2(level);
|
|
76
|
-
|
|
77
|
-
if(typeof(value) != 'object'){
|
|
78
|
-
let curLine = curSeparation + key + " : " + value + ",";
|
|
79
|
-
lines.push(curLine)
|
|
80
|
-
}
|
|
81
|
-
else{
|
|
82
|
-
let curLinePreFix = curSeparation + key + " : "
|
|
83
|
-
lines.push(curLinePreFix)
|
|
84
|
-
getTreeStyleLines(value, level + 1, lines);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
lastLine = lines.pop()
|
|
89
|
-
if(lastLine) lines.push(lastLine.replace(regexForLine, "")) // 一定执行
|
|
90
|
-
|
|
91
|
-
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"))
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const SEPARARION2 = "\t";
|
|
95
|
-
function getSeparation2(level){
|
|
96
|
-
let totalSeparation = "";
|
|
97
|
-
while(level > 0){
|
|
98
|
-
totalSeparation += SEPARARION2;
|
|
99
|
-
level--;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return totalSeparation;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
|
|
108
|
-
* @param object Object
|
|
109
|
-
* @param name string
|
|
110
|
-
*/
|
|
111
|
-
Logger.HierarchyPrinter = function(object, name){
|
|
112
|
-
let lines: string[] = []
|
|
113
|
-
lines.push(`${name} = `)
|
|
114
|
-
getTreeStyleHierarchyLines(object, 1, lines)
|
|
115
|
-
|
|
116
|
-
console.warn(lines.join("\n"))
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function getTreeStyleHierarchyLines(object, level: number, lines: string[]){
|
|
120
|
-
const isArray = object instanceof Array
|
|
121
|
-
let linePostFix = isArray ? "[" : "{"
|
|
122
|
-
let lastLine = lines.pop()
|
|
123
|
-
lines.push(lastLine + linePostFix)
|
|
124
|
-
|
|
125
|
-
if(isArray){
|
|
126
|
-
const key = 0
|
|
127
|
-
const value = object[key];
|
|
128
|
-
const curSeparation = getSeparation2(level);
|
|
129
|
-
|
|
130
|
-
if(typeof(value) != 'object'){
|
|
131
|
-
let curLine = curSeparation + key + " : " + value + ",";
|
|
132
|
-
lines.push(curLine)
|
|
133
|
-
}
|
|
134
|
-
else{
|
|
135
|
-
let curLinePreFix = curSeparation + key + " : "
|
|
136
|
-
lines.push(curLinePreFix)
|
|
137
|
-
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
138
|
-
}
|
|
139
|
-
lines.push(curSeparation + "...len=" + object.length)
|
|
140
|
-
}
|
|
141
|
-
else{
|
|
142
|
-
for (const key in object) {
|
|
143
|
-
const value = object[key];
|
|
144
|
-
const curSeparation = getSeparation2(level);
|
|
145
|
-
|
|
146
|
-
if(typeof(value) != 'object'){
|
|
147
|
-
let curLine = curSeparation + key + " : " + value + ",";
|
|
148
|
-
lines.push(curLine)
|
|
149
|
-
}
|
|
150
|
-
else{
|
|
151
|
-
let curLinePreFix = curSeparation + key + " : "
|
|
152
|
-
lines.push(curLinePreFix)
|
|
153
|
-
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
lastLine = lines.pop()
|
|
157
|
-
if(lastLine) lines.push(lastLine.replace(regexForLine, "")) // 一定执行
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"))
|
|
161
|
-
}
|
package/tools/img/logger.png
DELETED
|
Binary file
|
package/tsconfig.json
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"module": "ES6",
|
|
5
|
-
"baseUrl": ".",
|
|
6
|
-
"paths": {
|
|
7
|
-
"preact": ["../../lib/preact/src"],
|
|
8
|
-
},
|
|
9
|
-
"outDir": "../publish_components",
|
|
10
|
-
"allowJs": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"moduleResolution":"node",
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"noImplicitAny": false,
|
|
19
|
-
"jsx":"react",
|
|
20
|
-
"jsxFactory": "h",
|
|
21
|
-
// "sourceMap": false,
|
|
22
|
-
"declaration": true,
|
|
23
|
-
"declarationDir": "../publish_components"
|
|
24
|
-
// "noEmit": true
|
|
25
|
-
},
|
|
26
|
-
"files":[
|
|
27
|
-
"index.js",
|
|
28
|
-
"package.json",
|
|
29
|
-
],
|
|
30
|
-
"include": [
|
|
31
|
-
"ui/components/tab/*",
|
|
32
|
-
"ui/components/slider/*",
|
|
33
|
-
"ui/components/progress/*",
|
|
34
|
-
"ui/components/dropdown/*",
|
|
35
|
-
"ui/components/gradient/*",
|
|
36
|
-
"ui/components/outlinetext",
|
|
37
|
-
"tools/*",
|
|
38
|
-
"ui/components/carousel/*",
|
|
39
|
-
"ui/components/slapface/*",
|
|
40
|
-
"ui/components/slapface/less/*",
|
|
41
|
-
"ui/components/button/*",
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
|
|
45
|
-
}
|