pixuireactcomponents 1.0.2 → 1.0.5
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 +9 -5
- package/index.js +10 -2
- 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 +133 -0
- package/tools/tools.md +22 -0
- package/ui/components/dropdown/Dropdown.d.ts +30 -0
- package/ui/components/dropdown/Dropdown.js +82 -0
- package/ui/components/dropdown/DropdownOptionUI.d.ts +10 -0
- package/ui/components/dropdown/DropdownOptionUI.js +27 -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/progress/Progress.d.ts +34 -0
- package/ui/components/progress/Progress.js +142 -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/ui.md +2 -0
- 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/dropdown/Dropdown.tsx +0 -115
- package/ui/components/dropdown/DropdownOptionUI.tsx +0 -13
- package/ui/components/dropdown/DropdownSpreadMainUI.tsx +0 -11
- package/ui/components/dropdown/DropdownUnspreadMainUI.tsx +0 -11
- package/ui/components/progress/Progress.tsx +0 -166
- package/ui/components/tab/Tab.tsx +0 -12
- package/ui/components/tab/Tabs.tsx +0 -56
- package/ui/components/videoplayer/VideoPlayer.tsx +0 -200
- package/ui/sample/Images.tsx +0 -34
- 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/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/bulletscreen/BulletDemo.tsx +0 -86
- package/ui/sample/dropdown/DropdownDemo.tsx +0 -65
- package/ui/sample/dropdown/MoneyDropdownOption.tsx +0 -49
- package/ui/sample/dropdown/MoneyDropdownSpreadMain.tsx +0 -42
- package/ui/sample/dropdown/MoneyDropdownUnspreadMain.tsx +0 -44
- package/ui/sample/less/video.less +0 -143
- package/ui/sample/progress/ProgressDemo.tsx +0 -74
- package/ui/sample/tab/TabDemo.tsx +0 -67
- package/ui/sample/tab/TopTab.tsx +0 -74
- package/ui/sample/videoplayer/VideoPlayerDemo.tsx +0 -57
- package/utils/EventDispatcherJs.tsx +0 -74
- package/utils/GenerateConstructorAndGeterSeter.js +0 -223
- package/utils/Logger.tsx +0 -158
- package/utils/MakeImage.js +0 -204
- package/utils/img/logger.png +0 -0
- package/utils/img/makeImage.png +0 -0
- package/utils/utils.md +0 -145
package/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { Tabs } from "./ui/components/tab/Tabs";
|
|
2
|
+
export { Tab } from "./ui/components/tab/Tab";
|
|
3
|
+
export { Progress } from "./ui/components/progress/Progress";
|
|
4
|
+
export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
|
|
5
|
+
export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
|
|
6
|
+
export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
|
|
7
|
+
export { Logger } from "./tools/Logger";
|
|
8
|
+
export { EventDispatcherJs } from "./tools/EventDispatcherJs";
|
|
9
|
+
export { Dropdown, DropdownConfig } from "./ui/components/dropdown/Dropdown";
|
package/index.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { Tabs } from "./ui/components/tab/Tabs";
|
|
2
|
+
export { Tab } from "./ui/components/tab/Tab";
|
|
3
|
+
export { Progress } from "./ui/components/progress/Progress";
|
|
4
|
+
export { Dropdown } from "./ui/components/dropdown/Dropdown";
|
|
5
|
+
export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
|
|
6
|
+
export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
|
|
7
|
+
export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
|
|
8
|
+
export { Logger } from "./tools/Logger";
|
|
9
|
+
export { EventDispatcherJs } from "./tools/EventDispatcherJs";
|
|
10
|
+
console.log("Hello, 欢迎使用PixUI React Components");
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"name": "pixuireactcomponents",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "pixui react components",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "hardenzheng",
|
|
10
|
+
"license": "ISC"
|
|
11
11
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare class EventDispatcherCls {
|
|
2
|
+
listeners: {};
|
|
3
|
+
AddEventListener(eventName: string, listener: any, ...args: any[]): void;
|
|
4
|
+
HasEventListener(eventName: string): boolean;
|
|
5
|
+
RemoveEventListener(eventName: string, listener: any): void;
|
|
6
|
+
RemoveEventAllListener(eventName: string): void;
|
|
7
|
+
DispatchEvent(eventName: string, ...args: any[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare let EventDispatcherJs: Readonly<EventDispatcherCls>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var EventDispatcherCls = /** @class */ (function () {
|
|
2
|
+
function EventDispatcherCls() {
|
|
3
|
+
this.listeners = {};
|
|
4
|
+
}
|
|
5
|
+
EventDispatcherCls.prototype.AddEventListener = function (eventName, listener) {
|
|
6
|
+
var args = [];
|
|
7
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
8
|
+
args[_i - 2] = arguments[_i];
|
|
9
|
+
}
|
|
10
|
+
if (listener == undefined) {
|
|
11
|
+
console.warn("listener为空, eventName: " + eventName);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var listeners = this.listeners;
|
|
15
|
+
if (listeners[eventName] == undefined) {
|
|
16
|
+
listeners[eventName] = [];
|
|
17
|
+
}
|
|
18
|
+
var eventList = listeners[eventName];
|
|
19
|
+
eventList.forEach(function (v) {
|
|
20
|
+
if (v.eventName == eventName && v.listener == listener) {
|
|
21
|
+
console.warn("重复添加的事件监听, eventName: " + eventName);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
eventList.push({ "eventName": eventName, "listener": listener, "args": args, });
|
|
26
|
+
};
|
|
27
|
+
EventDispatcherCls.prototype.HasEventListener = function (eventName) {
|
|
28
|
+
if (this.listeners[eventName] == undefined || this.listeners[eventName].length == 0) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
EventDispatcherCls.prototype.RemoveEventListener = function (eventName, listener) {
|
|
34
|
+
if (this.HasEventListener(eventName) == false) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var eventList = this.listeners[eventName];
|
|
38
|
+
for (var i = eventList.length - 1; i >= 0; --i) {
|
|
39
|
+
var event_1 = eventList[i];
|
|
40
|
+
if (event_1.eventName == eventName && event_1.listener == listener) {
|
|
41
|
+
eventList.splice(i, 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (eventList.length == 0) {
|
|
45
|
+
this.listeners[eventName] = null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
EventDispatcherCls.prototype.RemoveEventAllListener = function (eventName) {
|
|
49
|
+
if (this.HasEventListener(eventName)) {
|
|
50
|
+
this.listeners[eventName] = null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
EventDispatcherCls.prototype.DispatchEvent = function (eventName) {
|
|
54
|
+
var args = [];
|
|
55
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
56
|
+
args[_i - 1] = arguments[_i];
|
|
57
|
+
}
|
|
58
|
+
if (eventName == undefined || this.HasEventListener(eventName) == false) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var eventList = this.listeners[eventName].slice(0);
|
|
62
|
+
for (var i = 0; i < eventList.length; ++i) {
|
|
63
|
+
var obj = eventList[i];
|
|
64
|
+
var listener = obj.listener;
|
|
65
|
+
// listener.apply(this, obj.args.concat(args));
|
|
66
|
+
listener.apply(void 0, obj.args.concat(args));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return EventDispatcherCls;
|
|
70
|
+
}());
|
|
71
|
+
export var EventDispatcherJs = Object.freeze(new EventDispatcherCls());
|
package/tools/Logger.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export function Logger() {
|
|
2
|
+
}
|
|
3
|
+
/**
|
|
4
|
+
* printer1: 完整打印,用4个空格缩进
|
|
5
|
+
*/
|
|
6
|
+
// 移除最后一个(key, value)后面的 ','
|
|
7
|
+
var regex = new RegExp("(,)(\n$)");
|
|
8
|
+
Logger.ObjectPrinter = function (object, name) {
|
|
9
|
+
var strResult = "";
|
|
10
|
+
strResult += name + " = ";
|
|
11
|
+
strResult += getTreeStyleStr(object, 1);
|
|
12
|
+
strResult = strResult.replace(regex, "$2");
|
|
13
|
+
console.warn(strResult);
|
|
14
|
+
};
|
|
15
|
+
function getTreeStyleStr(object, level) {
|
|
16
|
+
var isArray = object instanceof Array;
|
|
17
|
+
var str = isArray ? "[\n" : "{\n";
|
|
18
|
+
for (var key in object) {
|
|
19
|
+
var value = object[key];
|
|
20
|
+
var curSeparation = getSeparation1(level);
|
|
21
|
+
if (typeof (value) != 'object') {
|
|
22
|
+
str += curSeparation + key + " : " + value + ",\n";
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
str = str.replace(regex, "$2");
|
|
29
|
+
str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
|
|
30
|
+
return str;
|
|
31
|
+
}
|
|
32
|
+
var SEPARARION1 = " ";
|
|
33
|
+
function getSeparation1(level) {
|
|
34
|
+
var totalSeparation = "";
|
|
35
|
+
while (level > 0) {
|
|
36
|
+
totalSeparation += SEPARARION1;
|
|
37
|
+
level--;
|
|
38
|
+
}
|
|
39
|
+
return totalSeparation;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
printer2: 完整打印,用\t
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
var regexForLine = new RegExp(",$");
|
|
46
|
+
Logger.ObjectPrinter2 = function (object, name) {
|
|
47
|
+
var lines = [];
|
|
48
|
+
lines.push("".concat(name, " = "));
|
|
49
|
+
getTreeStyleLines(object, 1, lines);
|
|
50
|
+
console.warn(lines.join("\n"));
|
|
51
|
+
};
|
|
52
|
+
function getTreeStyleLines(object, level, lines) {
|
|
53
|
+
var isArray = object instanceof Array;
|
|
54
|
+
var linePostFix = isArray ? "[" : "{";
|
|
55
|
+
var lastLine = lines.pop();
|
|
56
|
+
lines.push(lastLine + linePostFix);
|
|
57
|
+
for (var key in object) {
|
|
58
|
+
var value = object[key];
|
|
59
|
+
var curSeparation = getSeparation2(level);
|
|
60
|
+
if (typeof (value) != 'object') {
|
|
61
|
+
var curLine = curSeparation + key + " : " + value + ",";
|
|
62
|
+
lines.push(curLine);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
var curLinePreFix = curSeparation + key + " : ";
|
|
66
|
+
lines.push(curLinePreFix);
|
|
67
|
+
getTreeStyleLines(value, level + 1, lines);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
lastLine = lines.pop();
|
|
71
|
+
if (lastLine)
|
|
72
|
+
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
73
|
+
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
74
|
+
}
|
|
75
|
+
var SEPARARION2 = "\t";
|
|
76
|
+
function getSeparation2(level) {
|
|
77
|
+
var totalSeparation = "";
|
|
78
|
+
while (level > 0) {
|
|
79
|
+
totalSeparation += SEPARARION2;
|
|
80
|
+
level--;
|
|
81
|
+
}
|
|
82
|
+
return totalSeparation;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
Logger.HierarchyPrinter = function (object, name) {
|
|
89
|
+
var lines = [];
|
|
90
|
+
lines.push("".concat(name, " = "));
|
|
91
|
+
getTreeStyleHierarchyLines(object, 1, lines);
|
|
92
|
+
console.warn(lines.join("\n"));
|
|
93
|
+
};
|
|
94
|
+
function getTreeStyleHierarchyLines(object, level, lines) {
|
|
95
|
+
var isArray = object instanceof Array;
|
|
96
|
+
var linePostFix = isArray ? "[" : "{";
|
|
97
|
+
var lastLine = lines.pop();
|
|
98
|
+
lines.push(lastLine + linePostFix);
|
|
99
|
+
if (isArray) {
|
|
100
|
+
var key = 0;
|
|
101
|
+
var value = object[key];
|
|
102
|
+
var curSeparation = getSeparation2(level);
|
|
103
|
+
if (typeof (value) != 'object') {
|
|
104
|
+
var curLine = curSeparation + key + " : " + value + ",";
|
|
105
|
+
lines.push(curLine);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
var curLinePreFix = curSeparation + key + " : ";
|
|
109
|
+
lines.push(curLinePreFix);
|
|
110
|
+
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
111
|
+
}
|
|
112
|
+
lines.push(curSeparation + "...len=" + object.length);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
for (var key in object) {
|
|
116
|
+
var value = object[key];
|
|
117
|
+
var curSeparation = getSeparation2(level);
|
|
118
|
+
if (typeof (value) != 'object') {
|
|
119
|
+
var curLine = curSeparation + key + " : " + value + ",";
|
|
120
|
+
lines.push(curLine);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
var curLinePreFix = curSeparation + key + " : ";
|
|
124
|
+
lines.push(curLinePreFix);
|
|
125
|
+
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
lastLine = lines.pop();
|
|
129
|
+
if (lastLine)
|
|
130
|
+
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
131
|
+
}
|
|
132
|
+
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
133
|
+
}
|
package/tools/tools.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 工具类组件
|
|
2
|
+
### 1. EventDispatcherJs.tsx
|
|
3
|
+
React里可供使用的事件派发器,类似Pandora Lua里的EventDispatcher。
|
|
4
|
+
|
|
5
|
+
用法主要就3个接口:
|
|
6
|
+
|
|
7
|
+
* AddEventListener: 添加监听事件
|
|
8
|
+
* DispatchEvent: 分发监听事件
|
|
9
|
+
* RemoveEventListener: 移除监听事件
|
|
10
|
+
|
|
11
|
+
### 2. Logger.tsx
|
|
12
|
+
React里可供使用的对象(数组)打印器。
|
|
13
|
+
|
|
14
|
+
直接console.log一个对象时,在游戏引擎中,无法打印出这个对象里的东西。而实际开发时,前后端联调时,需要方便的确认各种对象里的细节。
|
|
15
|
+
|
|
16
|
+
用法一共3个接口,打印粒度有差异。
|
|
17
|
+
|
|
18
|
+
* ObjectPrinter: 打印一个对象的内部细节,效果如下
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
* ObjectPrinter2:比上一个打印的信息更多
|
|
22
|
+
* HierarchyPrinter: 采样打印,对数组进行采样,能打印最多的信息
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Component, CSSProperties, h } from "preact";
|
|
2
|
+
import { DropdownOptionUI } from "./DropdownOptionUI";
|
|
3
|
+
import { DropdownSpreadMainUI } from "./DropdownSpreadMainUI";
|
|
4
|
+
import { DropdownUnspreadMainUI } from "./DropdownUnspreadMainUI";
|
|
5
|
+
export interface DropdownConfig<T> {
|
|
6
|
+
spreadStyle: CSSProperties;
|
|
7
|
+
datas: T[];
|
|
8
|
+
}
|
|
9
|
+
export declare class Dropdown<T, DDUnspreadMainUI extends DropdownUnspreadMainUI<T>, DDSpreadMainUI extends DropdownSpreadMainUI<T>, DDOptionUI extends DropdownOptionUI<T>> extends Component<{
|
|
10
|
+
config: DropdownConfig<T>;
|
|
11
|
+
onChoose: Function;
|
|
12
|
+
defaultIndex: number | null;
|
|
13
|
+
unspreadMainUI: DDUnspreadMainUI;
|
|
14
|
+
spreadMainUI: DDSpreadMainUI;
|
|
15
|
+
optionsUI: DDOptionUI[];
|
|
16
|
+
}, {
|
|
17
|
+
selectedIndex: number;
|
|
18
|
+
isSpread: boolean;
|
|
19
|
+
}> {
|
|
20
|
+
constructor(props: any);
|
|
21
|
+
componentWillUnmount(): void;
|
|
22
|
+
addNetEvents: () => void;
|
|
23
|
+
removeNetEvents: () => void;
|
|
24
|
+
addLogicEvents: () => void;
|
|
25
|
+
removeLogicEvents: () => void;
|
|
26
|
+
openList: () => void;
|
|
27
|
+
closeList: () => void;
|
|
28
|
+
onChoose: (index: number) => void;
|
|
29
|
+
render(): h.JSX.Element;
|
|
30
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
var Dropdown = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Dropdown, _super);
|
|
19
|
+
function Dropdown(props) {
|
|
20
|
+
var _this = _super.call(this, props) || this;
|
|
21
|
+
_this.addNetEvents = function () {
|
|
22
|
+
};
|
|
23
|
+
_this.removeNetEvents = function () {
|
|
24
|
+
};
|
|
25
|
+
_this.addLogicEvents = function () {
|
|
26
|
+
};
|
|
27
|
+
_this.removeLogicEvents = function () {
|
|
28
|
+
};
|
|
29
|
+
_this.openList = function () {
|
|
30
|
+
// console.warn("open dropdown====")
|
|
31
|
+
_this.setState({
|
|
32
|
+
isSpread: true
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
_this.closeList = function () {
|
|
36
|
+
// console.warn("close dropdown====")
|
|
37
|
+
_this.setState({
|
|
38
|
+
isSpread: false
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
_this.onChoose = function (index) {
|
|
42
|
+
_this.props.onChoose(index);
|
|
43
|
+
// console.warn('dropdown-=----', index)
|
|
44
|
+
_this.setState({
|
|
45
|
+
selectedIndex: index,
|
|
46
|
+
isSpread: false
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
_this.addNetEvents();
|
|
50
|
+
_this.addLogicEvents();
|
|
51
|
+
var initIndex = _this.props.defaultIndex == null ? 0 : _this.props.defaultIndex;
|
|
52
|
+
_this.state = {
|
|
53
|
+
selectedIndex: initIndex,
|
|
54
|
+
isSpread: false
|
|
55
|
+
};
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
Dropdown.prototype.componentWillUnmount = function () {
|
|
59
|
+
this.removeLogicEvents();
|
|
60
|
+
this.removeNetEvents();
|
|
61
|
+
};
|
|
62
|
+
Dropdown.prototype.render = function () {
|
|
63
|
+
var _this = this;
|
|
64
|
+
if (!this.state.isSpread) {
|
|
65
|
+
this.props.unspreadMainUI.props.info = this.props.config.datas[this.state.selectedIndex];
|
|
66
|
+
this.props.unspreadMainUI.props.openList = this.openList;
|
|
67
|
+
return (h("div", null, this.props.unspreadMainUI));
|
|
68
|
+
}
|
|
69
|
+
this.props.spreadMainUI.props.info = this.props.config.datas[this.state.selectedIndex];
|
|
70
|
+
this.props.spreadMainUI.props.closeList = this.closeList;
|
|
71
|
+
this.props.optionsUI.forEach(function (v, index) { v.props.onChoose = function () { _this.onChoose(index); }; });
|
|
72
|
+
var _optionsUI = this.props.optionsUI.filter(function (v) { return v.props.index != _this.state.selectedIndex; });
|
|
73
|
+
if (_optionsUI.length > 0)
|
|
74
|
+
_optionsUI[_optionsUI.length - 1].props["isLast"] = true;
|
|
75
|
+
return (h("div", null,
|
|
76
|
+
h("div", { style: this.props.config.spreadStyle },
|
|
77
|
+
this.props.spreadMainUI,
|
|
78
|
+
_optionsUI)));
|
|
79
|
+
};
|
|
80
|
+
return Dropdown;
|
|
81
|
+
}(Component));
|
|
82
|
+
export { Dropdown };
|
|
@@ -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
|
+
/**
|
|
18
|
+
* dropdown 打开时options列表的单个Item UI
|
|
19
|
+
*/
|
|
20
|
+
var DropdownOptionUI = /** @class */ (function (_super) {
|
|
21
|
+
__extends(DropdownOptionUI, _super);
|
|
22
|
+
function DropdownOptionUI() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return DropdownOptionUI;
|
|
26
|
+
}(Component));
|
|
27
|
+
export { DropdownOptionUI };
|
|
@@ -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
|
+
/**
|
|
18
|
+
* dropdown 打开时选中框的UI
|
|
19
|
+
*/
|
|
20
|
+
var DropdownSpreadMainUI = /** @class */ (function (_super) {
|
|
21
|
+
__extends(DropdownSpreadMainUI, _super);
|
|
22
|
+
function DropdownSpreadMainUI() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return DropdownSpreadMainUI;
|
|
26
|
+
}(Component));
|
|
27
|
+
export { DropdownSpreadMainUI };
|
|
@@ -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
|
+
/**
|
|
18
|
+
* dropdown 未打开时选中框的UI
|
|
19
|
+
*/
|
|
20
|
+
var DropdownUnspreadMainUI = /** @class */ (function (_super) {
|
|
21
|
+
__extends(DropdownUnspreadMainUI, _super);
|
|
22
|
+
function DropdownUnspreadMainUI() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return DropdownUnspreadMainUI;
|
|
26
|
+
}(Component));
|
|
27
|
+
export { DropdownUnspreadMainUI };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Component, h } from "preact";
|
|
2
|
+
export interface ProgressProps {
|
|
3
|
+
percent: number;
|
|
4
|
+
wrapperWidth: number;
|
|
5
|
+
wrapperHeight: number;
|
|
6
|
+
height: number;
|
|
7
|
+
dotWidth: number;
|
|
8
|
+
dotHeight: number;
|
|
9
|
+
dotWrapperWidth: number;
|
|
10
|
+
dotWrapperHeight: number;
|
|
11
|
+
outerBg: string;
|
|
12
|
+
innerBg: string;
|
|
13
|
+
dotBg: string;
|
|
14
|
+
onDragStart: Function | null;
|
|
15
|
+
onDrag: Function | null;
|
|
16
|
+
onDragEnd: Function | null;
|
|
17
|
+
}
|
|
18
|
+
export declare class Progress extends Component<ProgressProps, {
|
|
19
|
+
percent: number;
|
|
20
|
+
}> {
|
|
21
|
+
private refWrapper;
|
|
22
|
+
constructor(props: any);
|
|
23
|
+
componentDidMount(): void;
|
|
24
|
+
componentWillReceiveProps(nextProps: any): void;
|
|
25
|
+
onDragStart: (event: any) => void;
|
|
26
|
+
onDrag: (event: any) => void;
|
|
27
|
+
onDragEnd: (event: any) => void;
|
|
28
|
+
computeWrapperStyle: () => void;
|
|
29
|
+
computeOuterStyle: () => void;
|
|
30
|
+
computeInnerStyle: () => void;
|
|
31
|
+
computeDotWrapperStyle: () => void;
|
|
32
|
+
computeDotStyle: () => void;
|
|
33
|
+
render(): h.JSX.Element;
|
|
34
|
+
}
|