pixuireactcomponents 1.2.34 → 1.2.35
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 -16
- package/index.js +18 -17
- package/package.json +11 -11
- package/tools/EventDispatcherJs.d.ts +10 -10
- package/tools/EventDispatcherJs.js +71 -71
- package/tools/Logger.d.ts +6 -6
- package/tools/Logger.js +138 -138
- package/ui/components/button/Button.d.ts +6 -5
- package/ui/components/button/Button.js +66 -37
- package/ui/components/carousel/Carousel.d.ts +5 -5
- package/ui/components/carousel/Carousel.js +226 -219
- package/ui/components/dropdown/Dropdown.d.ts +30 -30
- package/ui/components/dropdown/Dropdown.js +92 -92
- package/ui/components/dropdown/DropdownOptionUI.d.ts +11 -11
- package/ui/components/dropdown/DropdownOptionUI.js +28 -28
- package/ui/components/dropdown/DropdownSpreadMainUI.d.ts +9 -9
- package/ui/components/dropdown/DropdownSpreadMainUI.js +27 -27
- package/ui/components/dropdown/DropdownUnspreadMainUI.d.ts +9 -9
- package/ui/components/dropdown/DropdownUnspreadMainUI.js +27 -27
- package/ui/components/gradient/GradientText.d.ts +63 -63
- package/ui/components/gradient/GradientText.js +329 -329
- 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 -94
- package/ui/components/outlinetext/OutlineText.js +167 -168
- package/ui/components/progress/Progress.d.ts +34 -34
- package/ui/components/progress/Progress.js +142 -142
- package/ui/components/slapface/Slapface.d.ts +18 -12
- package/ui/components/slapface/Slapface.js +485 -240
- package/ui/components/slider/Slider.d.ts +57 -57
- package/ui/components/slider/Slider.js +289 -289
- package/ui/components/tab/Tab.d.ts +6 -6
- package/ui/components/tab/Tab.js +27 -27
- package/ui/components/tab/Tabs.d.ts +12 -12
- package/ui/components/tab/Tabs.js +54 -54
- package/ui/components/togglegroup/ToggleGroup.d.ts +13 -13
- package/ui/components/togglegroup/ToggleGroup.js +99 -99
- package/ui/sample/Images.d.ts +28 -0
- package/ui/sample/Images.js +54 -0
- package/README.md +0 -8
- package/tools/tools.md +0 -22
- package/ui/components/slapface/Slapface.less +0 -107
- package/ui/ui.md +0 -2
package/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export { Tabs } from "./ui/components/tab/Tabs";
|
|
2
|
-
export { Tab } from "./ui/components/tab/Tab";
|
|
3
|
-
export { Slider } from "./ui/components/slider/Slider";
|
|
4
|
-
export { Progress } from "./ui/components/progress/Progress";
|
|
5
|
-
export { Dropdown } from "./ui/components/dropdown/Dropdown";
|
|
6
|
-
export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
|
|
7
|
-
export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
|
|
8
|
-
export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
|
|
9
|
-
export { GradientText } from "./ui/components/gradient/GradientText";
|
|
10
|
-
export { OutlineText } from "./ui/components/outlinetext/OutlineText";
|
|
11
|
-
export { Logger } from "./tools/Logger";
|
|
12
|
-
export { EventDispatcherJs } from "./tools/EventDispatcherJs";
|
|
13
|
-
export { Carousel } from "./ui/components/carousel/Carousel";
|
|
14
|
-
export { Slapface } from "./ui/components/slapface/Slapface";
|
|
15
|
-
export { Button } from "./ui/components/button/Button";
|
|
16
|
-
export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
|
|
1
|
+
export { Tabs } from "./ui/components/tab/Tabs";
|
|
2
|
+
export { Tab } from "./ui/components/tab/Tab";
|
|
3
|
+
export { Slider } from "./ui/components/slider/Slider";
|
|
4
|
+
export { Progress } from "./ui/components/progress/Progress";
|
|
5
|
+
export { Dropdown } from "./ui/components/dropdown/Dropdown";
|
|
6
|
+
export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
|
|
7
|
+
export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
|
|
8
|
+
export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
|
|
9
|
+
export { GradientText } from "./ui/components/gradient/GradientText";
|
|
10
|
+
export { OutlineText } from "./ui/components/outlinetext/OutlineText";
|
|
11
|
+
export { Logger } from "./tools/Logger";
|
|
12
|
+
export { EventDispatcherJs } from "./tools/EventDispatcherJs";
|
|
13
|
+
export { Carousel } from "./ui/components/carousel/Carousel";
|
|
14
|
+
export { Slapface } from "./ui/components/slapface/Slapface";
|
|
15
|
+
export { Button } from "./ui/components/button/Button";
|
|
16
|
+
export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
|
|
17
|
+
export { ImageViewer } from "./ui/components/imageViewer/imageViewer";
|
package/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
export { Tabs } from "./ui/components/tab/Tabs";
|
|
2
|
-
export { Tab } from "./ui/components/tab/Tab";
|
|
3
|
-
export { Slider } from "./ui/components/slider/Slider";
|
|
4
|
-
export { Progress } from "./ui/components/progress/Progress";
|
|
5
|
-
export { Dropdown } from "./ui/components/dropdown/Dropdown";
|
|
6
|
-
export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
|
|
7
|
-
export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
|
|
8
|
-
export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
|
|
9
|
-
export { GradientText } from "./ui/components/gradient/GradientText";
|
|
10
|
-
export { OutlineText } from "./ui/components/outlinetext/OutlineText";
|
|
11
|
-
export { Logger } from "./tools/Logger";
|
|
12
|
-
export { EventDispatcherJs } from "./tools/EventDispatcherJs";
|
|
13
|
-
export { Carousel } from "./ui/components/carousel/Carousel";
|
|
14
|
-
export { Slapface } from "./ui/components/slapface/Slapface";
|
|
15
|
-
export { Button } from "./ui/components/button/Button";
|
|
16
|
-
export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
|
|
17
|
-
|
|
1
|
+
export { Tabs } from "./ui/components/tab/Tabs";
|
|
2
|
+
export { Tab } from "./ui/components/tab/Tab";
|
|
3
|
+
export { Slider } from "./ui/components/slider/Slider";
|
|
4
|
+
export { Progress } from "./ui/components/progress/Progress";
|
|
5
|
+
export { Dropdown } from "./ui/components/dropdown/Dropdown";
|
|
6
|
+
export { DropdownOptionUI } from "./ui/components/dropdown/DropdownOptionUI";
|
|
7
|
+
export { DropdownSpreadMainUI } from "./ui/components/dropdown/DropdownSpreadMainUI";
|
|
8
|
+
export { DropdownUnspreadMainUI } from "./ui/components/dropdown/DropdownUnspreadMainUI";
|
|
9
|
+
export { GradientText } from "./ui/components/gradient/GradientText";
|
|
10
|
+
export { OutlineText } from "./ui/components/outlinetext/OutlineText";
|
|
11
|
+
export { Logger } from "./tools/Logger";
|
|
12
|
+
export { EventDispatcherJs } from "./tools/EventDispatcherJs";
|
|
13
|
+
export { Carousel } from "./ui/components/carousel/Carousel";
|
|
14
|
+
export { Slapface } from "./ui/components/slapface/Slapface";
|
|
15
|
+
export { Button } from "./ui/components/button/Button";
|
|
16
|
+
export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
|
|
17
|
+
export { ImageViewer } from './ui/components/imageViewer/imageViewer';
|
|
18
|
+
console.log("Hello, 欢迎使用PixUI React Components");
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pixuireactcomponents",
|
|
3
|
-
"version": "1.2.
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pixuireactcomponents",
|
|
3
|
+
"version": "1.2.35",
|
|
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
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare class EventDispatcherCls {
|
|
2
|
-
private 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 {};
|
|
1
|
+
declare class EventDispatcherCls {
|
|
2
|
+
private 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 {};
|
|
@@ -1,71 +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());
|
|
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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function Logger(): void;
|
|
2
|
-
export declare namespace Logger {
|
|
3
|
-
var ObjectPrinter: (object: any, name: any) => void;
|
|
4
|
-
var ObjectPrinter2: (object: any, name: any) => void;
|
|
5
|
-
var HierarchyPrinter: (object: any, name: any) => void;
|
|
6
|
-
}
|
|
1
|
+
export declare function Logger(): void;
|
|
2
|
+
export declare namespace Logger {
|
|
3
|
+
var ObjectPrinter: (object: any, name: any) => void;
|
|
4
|
+
var ObjectPrinter2: (object: any, name: any) => void;
|
|
5
|
+
var HierarchyPrinter: (object: any, name: any) => void;
|
|
6
|
+
}
|
package/tools/Logger.js
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
export function Logger() {
|
|
2
|
-
}
|
|
3
|
-
// 移除最后一个(key, value)后面的 ','
|
|
4
|
-
var regex = new RegExp("(,)(\n$)");
|
|
5
|
-
/**
|
|
6
|
-
* printer1: 完整打印,用4个空格缩进
|
|
7
|
-
* @param object Object
|
|
8
|
-
* @param name string
|
|
9
|
-
*/
|
|
10
|
-
Logger.ObjectPrinter = function (object, name) {
|
|
11
|
-
var strResult = "";
|
|
12
|
-
strResult += name + " = ";
|
|
13
|
-
strResult += getTreeStyleStr(object, 1);
|
|
14
|
-
strResult = strResult.replace(regex, "$2");
|
|
15
|
-
console.warn(strResult);
|
|
16
|
-
};
|
|
17
|
-
function getTreeStyleStr(object, level) {
|
|
18
|
-
var isArray = object instanceof Array;
|
|
19
|
-
var str = isArray ? "[\n" : "{\n";
|
|
20
|
-
for (var key in object) {
|
|
21
|
-
var value = object[key];
|
|
22
|
-
var curSeparation = getSeparation1(level);
|
|
23
|
-
if (typeof (value) != 'object') {
|
|
24
|
-
str += curSeparation + key + " : " + value + ",\n";
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
str = str.replace(regex, "$2");
|
|
31
|
-
str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
|
|
32
|
-
return str;
|
|
33
|
-
}
|
|
34
|
-
var SEPARARION1 = " ";
|
|
35
|
-
function getSeparation1(level) {
|
|
36
|
-
var totalSeparation = "";
|
|
37
|
-
while (level > 0) {
|
|
38
|
-
totalSeparation += SEPARARION1;
|
|
39
|
-
level--;
|
|
40
|
-
}
|
|
41
|
-
return totalSeparation;
|
|
42
|
-
}
|
|
43
|
-
var regexForLine = new RegExp(",$");
|
|
44
|
-
/**
|
|
45
|
-
* printer2: 完整打印,用\t
|
|
46
|
-
* @param object Object
|
|
47
|
-
* @param name sring
|
|
48
|
-
*/
|
|
49
|
-
Logger.ObjectPrinter2 = function (object, name) {
|
|
50
|
-
var lines = [];
|
|
51
|
-
lines.push("".concat(name, " = "));
|
|
52
|
-
getTreeStyleLines(object, 1, lines);
|
|
53
|
-
console.warn(lines.join("\n"));
|
|
54
|
-
};
|
|
55
|
-
function getTreeStyleLines(object, level, lines) {
|
|
56
|
-
var isArray = object instanceof Array;
|
|
57
|
-
var linePostFix = isArray ? "[" : "{";
|
|
58
|
-
var lastLine = lines.pop();
|
|
59
|
-
lines.push(lastLine + linePostFix);
|
|
60
|
-
for (var key in object) {
|
|
61
|
-
var value = object[key];
|
|
62
|
-
var curSeparation = getSeparation2(level);
|
|
63
|
-
if (typeof (value) != 'object') {
|
|
64
|
-
var curLine = curSeparation + key + " : " + value + ",";
|
|
65
|
-
lines.push(curLine);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
var curLinePreFix = curSeparation + key + " : ";
|
|
69
|
-
lines.push(curLinePreFix);
|
|
70
|
-
getTreeStyleLines(value, level + 1, lines);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
lastLine = lines.pop();
|
|
74
|
-
if (lastLine)
|
|
75
|
-
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
76
|
-
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
77
|
-
}
|
|
78
|
-
var SEPARARION2 = "\t";
|
|
79
|
-
function getSeparation2(level) {
|
|
80
|
-
var totalSeparation = "";
|
|
81
|
-
while (level > 0) {
|
|
82
|
-
totalSeparation += SEPARARION2;
|
|
83
|
-
level--;
|
|
84
|
-
}
|
|
85
|
-
return totalSeparation;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
|
|
90
|
-
* @param object Object
|
|
91
|
-
* @param name string
|
|
92
|
-
*/
|
|
93
|
-
Logger.HierarchyPrinter = function (object, name) {
|
|
94
|
-
var lines = [];
|
|
95
|
-
lines.push("".concat(name, " = "));
|
|
96
|
-
getTreeStyleHierarchyLines(object, 1, lines);
|
|
97
|
-
console.warn(lines.join("\n"));
|
|
98
|
-
};
|
|
99
|
-
function getTreeStyleHierarchyLines(object, level, lines) {
|
|
100
|
-
var isArray = object instanceof Array;
|
|
101
|
-
var linePostFix = isArray ? "[" : "{";
|
|
102
|
-
var lastLine = lines.pop();
|
|
103
|
-
lines.push(lastLine + linePostFix);
|
|
104
|
-
if (isArray) {
|
|
105
|
-
var key = 0;
|
|
106
|
-
var value = object[key];
|
|
107
|
-
var curSeparation = getSeparation2(level);
|
|
108
|
-
if (typeof (value) != 'object') {
|
|
109
|
-
var curLine = curSeparation + key + " : " + value + ",";
|
|
110
|
-
lines.push(curLine);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
var curLinePreFix = curSeparation + key + " : ";
|
|
114
|
-
lines.push(curLinePreFix);
|
|
115
|
-
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
116
|
-
}
|
|
117
|
-
lines.push(curSeparation + "...len=" + object.length);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
for (var key in object) {
|
|
121
|
-
var value = object[key];
|
|
122
|
-
var curSeparation = getSeparation2(level);
|
|
123
|
-
if (typeof (value) != 'object') {
|
|
124
|
-
var curLine = curSeparation + key + " : " + value + ",";
|
|
125
|
-
lines.push(curLine);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
var curLinePreFix = curSeparation + key + " : ";
|
|
129
|
-
lines.push(curLinePreFix);
|
|
130
|
-
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
lastLine = lines.pop();
|
|
134
|
-
if (lastLine)
|
|
135
|
-
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
136
|
-
}
|
|
137
|
-
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
138
|
-
}
|
|
1
|
+
export function Logger() {
|
|
2
|
+
}
|
|
3
|
+
// 移除最后一个(key, value)后面的 ','
|
|
4
|
+
var regex = new RegExp("(,)(\n$)");
|
|
5
|
+
/**
|
|
6
|
+
* printer1: 完整打印,用4个空格缩进
|
|
7
|
+
* @param object Object
|
|
8
|
+
* @param name string
|
|
9
|
+
*/
|
|
10
|
+
Logger.ObjectPrinter = function (object, name) {
|
|
11
|
+
var strResult = "";
|
|
12
|
+
strResult += name + " = ";
|
|
13
|
+
strResult += getTreeStyleStr(object, 1);
|
|
14
|
+
strResult = strResult.replace(regex, "$2");
|
|
15
|
+
console.warn(strResult);
|
|
16
|
+
};
|
|
17
|
+
function getTreeStyleStr(object, level) {
|
|
18
|
+
var isArray = object instanceof Array;
|
|
19
|
+
var str = isArray ? "[\n" : "{\n";
|
|
20
|
+
for (var key in object) {
|
|
21
|
+
var value = object[key];
|
|
22
|
+
var curSeparation = getSeparation1(level);
|
|
23
|
+
if (typeof (value) != 'object') {
|
|
24
|
+
str += curSeparation + key + " : " + value + ",\n";
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
str = str.replace(regex, "$2");
|
|
31
|
+
str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
|
|
32
|
+
return str;
|
|
33
|
+
}
|
|
34
|
+
var SEPARARION1 = " ";
|
|
35
|
+
function getSeparation1(level) {
|
|
36
|
+
var totalSeparation = "";
|
|
37
|
+
while (level > 0) {
|
|
38
|
+
totalSeparation += SEPARARION1;
|
|
39
|
+
level--;
|
|
40
|
+
}
|
|
41
|
+
return totalSeparation;
|
|
42
|
+
}
|
|
43
|
+
var regexForLine = new RegExp(",$");
|
|
44
|
+
/**
|
|
45
|
+
* printer2: 完整打印,用\t
|
|
46
|
+
* @param object Object
|
|
47
|
+
* @param name sring
|
|
48
|
+
*/
|
|
49
|
+
Logger.ObjectPrinter2 = function (object, name) {
|
|
50
|
+
var lines = [];
|
|
51
|
+
lines.push("".concat(name, " = "));
|
|
52
|
+
getTreeStyleLines(object, 1, lines);
|
|
53
|
+
console.warn(lines.join("\n"));
|
|
54
|
+
};
|
|
55
|
+
function getTreeStyleLines(object, level, lines) {
|
|
56
|
+
var isArray = object instanceof Array;
|
|
57
|
+
var linePostFix = isArray ? "[" : "{";
|
|
58
|
+
var lastLine = lines.pop();
|
|
59
|
+
lines.push(lastLine + linePostFix);
|
|
60
|
+
for (var key in object) {
|
|
61
|
+
var value = object[key];
|
|
62
|
+
var curSeparation = getSeparation2(level);
|
|
63
|
+
if (typeof (value) != 'object') {
|
|
64
|
+
var curLine = curSeparation + key + " : " + value + ",";
|
|
65
|
+
lines.push(curLine);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var curLinePreFix = curSeparation + key + " : ";
|
|
69
|
+
lines.push(curLinePreFix);
|
|
70
|
+
getTreeStyleLines(value, level + 1, lines);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
lastLine = lines.pop();
|
|
74
|
+
if (lastLine)
|
|
75
|
+
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
76
|
+
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
77
|
+
}
|
|
78
|
+
var SEPARARION2 = "\t";
|
|
79
|
+
function getSeparation2(level) {
|
|
80
|
+
var totalSeparation = "";
|
|
81
|
+
while (level > 0) {
|
|
82
|
+
totalSeparation += SEPARARION2;
|
|
83
|
+
level--;
|
|
84
|
+
}
|
|
85
|
+
return totalSeparation;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
|
|
90
|
+
* @param object Object
|
|
91
|
+
* @param name string
|
|
92
|
+
*/
|
|
93
|
+
Logger.HierarchyPrinter = function (object, name) {
|
|
94
|
+
var lines = [];
|
|
95
|
+
lines.push("".concat(name, " = "));
|
|
96
|
+
getTreeStyleHierarchyLines(object, 1, lines);
|
|
97
|
+
console.warn(lines.join("\n"));
|
|
98
|
+
};
|
|
99
|
+
function getTreeStyleHierarchyLines(object, level, lines) {
|
|
100
|
+
var isArray = object instanceof Array;
|
|
101
|
+
var linePostFix = isArray ? "[" : "{";
|
|
102
|
+
var lastLine = lines.pop();
|
|
103
|
+
lines.push(lastLine + linePostFix);
|
|
104
|
+
if (isArray) {
|
|
105
|
+
var key = 0;
|
|
106
|
+
var value = object[key];
|
|
107
|
+
var curSeparation = getSeparation2(level);
|
|
108
|
+
if (typeof (value) != 'object') {
|
|
109
|
+
var curLine = curSeparation + key + " : " + value + ",";
|
|
110
|
+
lines.push(curLine);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
var curLinePreFix = curSeparation + key + " : ";
|
|
114
|
+
lines.push(curLinePreFix);
|
|
115
|
+
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
116
|
+
}
|
|
117
|
+
lines.push(curSeparation + "...len=" + object.length);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
for (var key in object) {
|
|
121
|
+
var value = object[key];
|
|
122
|
+
var curSeparation = getSeparation2(level);
|
|
123
|
+
if (typeof (value) != 'object') {
|
|
124
|
+
var curLine = curSeparation + key + " : " + value + ",";
|
|
125
|
+
lines.push(curLine);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
var curLinePreFix = curSeparation + key + " : ";
|
|
129
|
+
lines.push(curLinePreFix);
|
|
130
|
+
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
lastLine = lines.pop();
|
|
134
|
+
if (lastLine)
|
|
135
|
+
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
136
|
+
}
|
|
137
|
+
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
138
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { h, Component } from
|
|
2
|
-
export declare class Button extends Component<any, any> {
|
|
3
|
-
private btnImg;
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { h, Component } from 'preact';
|
|
2
|
+
export declare class Button extends Component<any, any> {
|
|
3
|
+
private btnImg;
|
|
4
|
+
private btnText;
|
|
5
|
+
render(props: any): h.JSX.Element;
|
|
6
|
+
}
|