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.
Files changed (39) hide show
  1. package/index.d.ts +17 -0
  2. package/index.js +18 -0
  3. package/package.json +11 -0
  4. package/tools/EventDispatcherJs.d.ts +10 -0
  5. package/tools/EventDispatcherJs.js +71 -0
  6. package/tools/Logger.d.ts +6 -0
  7. package/tools/Logger.js +138 -0
  8. package/ui/components/button/Button.d.ts +6 -0
  9. package/ui/components/button/Button.js +66 -0
  10. package/ui/components/carousel/Carousel.d.ts +5 -0
  11. package/ui/components/carousel/Carousel.js +226 -0
  12. package/ui/components/dropdown/Dropdown.d.ts +30 -0
  13. package/ui/components/dropdown/Dropdown.js +92 -0
  14. package/ui/components/dropdown/DropdownOptionUI.d.ts +11 -0
  15. package/ui/components/dropdown/DropdownOptionUI.js +28 -0
  16. package/ui/components/dropdown/DropdownSpreadMainUI.d.ts +9 -0
  17. package/ui/components/dropdown/DropdownSpreadMainUI.js +27 -0
  18. package/ui/components/dropdown/DropdownUnspreadMainUI.d.ts +9 -0
  19. package/ui/components/dropdown/DropdownUnspreadMainUI.js +27 -0
  20. package/ui/components/gradient/GradientText.d.ts +63 -0
  21. package/ui/components/gradient/GradientText.js +329 -0
  22. package/ui/components/imageViewer/imageViewer.d.ts +23 -0
  23. package/ui/components/imageViewer/imageViewer.js +149 -0
  24. package/ui/components/outlinetext/OutlineText.d.ts +94 -0
  25. package/ui/components/outlinetext/OutlineText.js +167 -0
  26. package/ui/components/progress/Progress.d.ts +34 -0
  27. package/ui/components/progress/Progress.js +142 -0
  28. package/ui/components/slapface/Slapface.d.ts +18 -0
  29. package/ui/components/slapface/Slapface.js +485 -0
  30. package/ui/components/slider/Slider.d.ts +57 -0
  31. package/ui/components/slider/Slider.js +289 -0
  32. package/ui/components/tab/Tab.d.ts +6 -0
  33. package/ui/components/tab/Tab.js +27 -0
  34. package/ui/components/tab/Tabs.d.ts +12 -0
  35. package/ui/components/tab/Tabs.js +54 -0
  36. package/ui/components/togglegroup/ToggleGroup.d.ts +13 -0
  37. package/ui/components/togglegroup/ToggleGroup.js +99 -0
  38. package/ui/sample/Images.d.ts +28 -0
  39. package/ui/sample/Images.js +54 -0
@@ -0,0 +1,92 @@
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 optionsDivStyle = {
18
+ marginTop: 3,
19
+ display: 'flex',
20
+ flexDirection: 'column',
21
+ justifyContent: 'flex-start',
22
+ alignItems: 'center',
23
+ height: 'auto',
24
+ overflow: 'scroll',
25
+ overflowStyle: 'none',
26
+ };
27
+ var Dropdown = /** @class */ (function (_super) {
28
+ __extends(Dropdown, _super);
29
+ function Dropdown(props) {
30
+ var _this = _super.call(this, props) || this;
31
+ _this.addNetEvents = function () {
32
+ };
33
+ _this.removeNetEvents = function () {
34
+ };
35
+ _this.addLogicEvents = function () {
36
+ };
37
+ _this.removeLogicEvents = function () {
38
+ };
39
+ _this.openList = function () {
40
+ // console.warn("open dropdown====")
41
+ _this.setState({
42
+ isSpread: true
43
+ });
44
+ };
45
+ _this.closeList = function () {
46
+ // console.warn("close dropdown====")
47
+ _this.setState({
48
+ isSpread: false
49
+ });
50
+ };
51
+ _this.onChoose = function (index) {
52
+ _this.props.onChoose(index);
53
+ // console.warn('dropdown-=----', index)
54
+ _this.setState({
55
+ selectedIndex: index,
56
+ isSpread: false
57
+ });
58
+ };
59
+ _this.addNetEvents();
60
+ _this.addLogicEvents();
61
+ var initIndex = _this.props.defaultIndex == null ? 0 : _this.props.defaultIndex;
62
+ _this.state = {
63
+ selectedIndex: initIndex,
64
+ isSpread: false
65
+ };
66
+ return _this;
67
+ }
68
+ Dropdown.prototype.componentWillUnmount = function () {
69
+ this.removeLogicEvents();
70
+ this.removeNetEvents();
71
+ };
72
+ Dropdown.prototype.render = function () {
73
+ var _this = this;
74
+ if (!this.state.isSpread) {
75
+ this.props.unspreadMainUI.props.info = this.props.config.datas[this.state.selectedIndex];
76
+ this.props.unspreadMainUI.props.openList = this.openList;
77
+ return (h("div", null, this.props.unspreadMainUI));
78
+ }
79
+ this.props.spreadMainUI.props.info = this.props.config.datas[this.state.selectedIndex];
80
+ this.props.spreadMainUI.props.closeList = this.closeList;
81
+ this.props.optionsUI.forEach(function (v, index) { v.props.onChoose = function () { _this.onChoose(index); }; });
82
+ var _optionsUI = this.props.optionsUI.filter(function (v) { return v.props.index != _this.state.selectedIndex; });
83
+ if (_optionsUI.length > 0)
84
+ _optionsUI[_optionsUI.length - 1].props['isLast'] = true;
85
+ return (h("div", null,
86
+ h("div", { style: this.props.config.spreadStyle },
87
+ this.props.spreadMainUI,
88
+ h("div", { style: optionsDivStyle }, _optionsUI))));
89
+ };
90
+ return Dropdown;
91
+ }(Component));
92
+ export { Dropdown };
@@ -0,0 +1,11 @@
1
+ import { Component } from 'preact';
2
+ /**
3
+ * dropdown 打开时options列表的单个Item UI
4
+ * 如果要使用滚动条,在创建改该组件时最外层div样式里面需添加flex-shrink : 0
5
+ */
6
+ export declare abstract class DropdownOptionUI<T> extends Component<{
7
+ info: T;
8
+ onChoose: Function;
9
+ index: number;
10
+ }, any> {
11
+ }
@@ -0,0 +1,28 @@
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
+ * 如果要使用滚动条,在创建改该组件时最外层div样式里面需添加flex-shrink : 0
20
+ */
21
+ var DropdownOptionUI = /** @class */ (function (_super) {
22
+ __extends(DropdownOptionUI, _super);
23
+ function DropdownOptionUI() {
24
+ return _super !== null && _super.apply(this, arguments) || this;
25
+ }
26
+ return DropdownOptionUI;
27
+ }(Component));
28
+ export { DropdownOptionUI };
@@ -0,0 +1,9 @@
1
+ import { Component } from 'preact';
2
+ /**
3
+ * dropdown 打开时选中框的UI
4
+ */
5
+ export declare abstract class DropdownSpreadMainUI<T> extends Component<{
6
+ info: T;
7
+ closeList: Function;
8
+ }, any> {
9
+ }
@@ -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,9 @@
1
+ import { Component } from 'preact';
2
+ /**
3
+ * dropdown 未打开时选中框的UI
4
+ */
5
+ export declare abstract class DropdownUnspreadMainUI<T> extends Component<{
6
+ info: T;
7
+ openList: Function;
8
+ }, any> {
9
+ }
@@ -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,63 @@
1
+ import { Component, CSSProperties, h } from 'preact';
2
+ export interface GradientTextProps {
3
+ style?: CSSProperties;
4
+ text?: string;
5
+ color?: string;
6
+ fontSize?: number;
7
+ font?: string;
8
+ alignment?: string;
9
+ direction?: string;
10
+ colorTop?: string;
11
+ colorBottom?: string;
12
+ colorLeft?: string;
13
+ colorRight?: string;
14
+ fitRectTransform?: boolean;
15
+ richText?: boolean;
16
+ alignByGeometry?: boolean;
17
+ horizontalOverflow?: string;
18
+ verticalOverflow?: string;
19
+ bestFit?: boolean;
20
+ raycastTarget?: boolean;
21
+ fontStyle?: string;
22
+ lineSpacing?: number;
23
+ }
24
+ export declare class GradientText extends Component<GradientTextProps, GradientTextProps> {
25
+ isPrintLog: boolean;
26
+ textObj: null;
27
+ gradientObj: null;
28
+ constructor(props: any);
29
+ componentDidUpdate(): void;
30
+ static getDerivedStateFromProps(props: any, state: any): {
31
+ text: any;
32
+ color: any;
33
+ fontSize: any;
34
+ font: any;
35
+ alignment: any;
36
+ direction: any;
37
+ colorTop: any;
38
+ colorBottom: any;
39
+ colorLeft: any;
40
+ colorRight: any;
41
+ fitRectTransform: any;
42
+ richText: any;
43
+ alignByGeometry: any;
44
+ horizontalOverflow: any;
45
+ verticalOverflow: any;
46
+ bestFit: any;
47
+ raycastTarget: any;
48
+ fontStyle: any;
49
+ lineSpacing: any;
50
+ } | null;
51
+ getCSharp(): any;
52
+ onLoad(e: any): void;
53
+ updateGradientText(): void;
54
+ transFont(fontName: any): any;
55
+ transHorizontalOverflow(str: any): any;
56
+ transVerticalOverflow(str: any): any;
57
+ transFontStyle(str: any): any;
58
+ colorRgb(colorStr: any): any;
59
+ printLog(text: any): void;
60
+ transDirection(direction: any): any;
61
+ transAlignment(alignment: any): any;
62
+ render(props: any): h.JSX.Element;
63
+ }
@@ -0,0 +1,329 @@
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 GradientText = /** @class */ (function (_super) {
18
+ __extends(GradientText, _super);
19
+ function GradientText(props) {
20
+ var _this = _super.call(this, props) || this;
21
+ _this.isPrintLog = false;
22
+ _this.textObj = null;
23
+ _this.gradientObj = null;
24
+ _this.state = {
25
+ style: props.style,
26
+ text: props.text,
27
+ color: props.color,
28
+ fontSize: props.fontSize,
29
+ font: props.font,
30
+ alignment: props.alignment,
31
+ direction: props.direction,
32
+ colorTop: props.colorTop,
33
+ colorBottom: props.colorBottom,
34
+ colorLeft: props.colorLeft,
35
+ colorRight: props.colorLeft,
36
+ fitRectTransform: props.fitRectTransform,
37
+ richText: props.richText,
38
+ alignByGeometry: props.alignByGeometry,
39
+ horizontalOverflow: props.horizontalOverflow,
40
+ verticalOverflow: props.verticalOverflow,
41
+ bestFit: props.bestFit,
42
+ raycastTarget: props.raycastTarget,
43
+ fontStyle: props.fontStyle,
44
+ lineSpacing: props.lineSpacing,
45
+ };
46
+ return _this;
47
+ }
48
+ GradientText.prototype.componentDidUpdate = function () {
49
+ console.log('componentDidUpdate');
50
+ this.updateGradientText();
51
+ };
52
+ GradientText.getDerivedStateFromProps = function (props, state) {
53
+ console.log('getDerivedStateFromProps props:' + JSON.stringify(props));
54
+ console.log('getDerivedStateFromProps old state:' + JSON.stringify(state));
55
+ if (props.text !== state.text ||
56
+ props.color !== state.color ||
57
+ props.fontSize !== state.fontSize ||
58
+ props.alignment !== state.alignment ||
59
+ props.direction !== state.direction ||
60
+ props.colorTop !== state.colorTop ||
61
+ props.colorBottom !== state.colorBottom ||
62
+ props.colorLeft !== state.colorLeft ||
63
+ props.colorRight !== state.colorRight ||
64
+ props.fitRectTransform !== state.fitRectTransform ||
65
+ props.richText !== state.richText ||
66
+ props.alignByGeometry !== state.alignByGeometry ||
67
+ props.horizontalOverflow !== state.horizontalOverflow ||
68
+ props.verticalOverflow !== state.verticalOverflow ||
69
+ props.bestFit !== state.bestFit ||
70
+ props.raycastTarget !== state.raycastTarget ||
71
+ props.fontStyle !== state.fontStyle ||
72
+ props.lineSpacing !== state.lineSpacing) {
73
+ return {
74
+ text: props.text && props.text !== state.text ? props.text : state.text,
75
+ color: props.color && props.color !== state.color ? props.color : state.color,
76
+ fontSize: props.fontSize && props.fontSize !== state.fontSize ? props.fontSize : state.fontSize,
77
+ font: props.font && props.font !== state.font ? props.font : state.font,
78
+ alignment: props.alignment && props.alignment !== state.alignment ? props.alignment : state.alignment,
79
+ direction: props.direction && props.direction !== state.direction ? props.direction : state.direction,
80
+ colorTop: props.colorTop && props.colorTop !== state.colorTop ? props.colorTop : state.colorTop,
81
+ colorBottom: props.colorBottom && props.colorBottom !== state.colorBottom ? props.colorBottom : state.colorBottom,
82
+ colorLeft: props.colorLeft && props.colorLeft !== state.colorLeft ? props.colorLeft : state.colorLeft,
83
+ colorRight: props.colorRight && props.colorRight !== state.colorRight ? props.colorRight : state.colorRight,
84
+ fitRectTransform: props.fitRectTransform && props.fitRectTransform !== state.fitRectTransform ? props.fitRectTransform : state.fitRectTransform,
85
+ richText: props.richText && props.richText !== state.richText ? props.richText : state.richText,
86
+ alignByGeometry: props.alignByGeometry && props.alignByGeometry !== state.alignByGeometry ? props.alignByGeometry : state.alignByGeometry,
87
+ horizontalOverflow: props.horizontalOverflow && props.horizontalOverflow !== state.horizontalOverflow ? props.horizontalOverflow : state.horizontalOverflow,
88
+ verticalOverflow: props.verticalOverflow && props.verticalOverflow !== state.verticalOverflow ? props.verticalOverflow : state.verticalOverflow,
89
+ bestFit: props.bestFit && props.bestFit !== state.bestFit ? props.bestFit : state.bestFit,
90
+ raycastTarget: props.raycastTarget && props.raycastTarget !== state.raycastTarget ? props.raycastTarget : state.raycastTarget,
91
+ fontStyle: props.fontStyle && props.fontStyle !== state.fontStyle ? props.fontStyle : state.fontStyle,
92
+ lineSpacing: props.lineSpacing && props.lineSpacing !== state.lineSpacing ? props.lineSpacing : state.lineSpacing,
93
+ };
94
+ }
95
+ else {
96
+ return null;
97
+ }
98
+ };
99
+ GradientText.prototype.getCSharp = function () {
100
+ if (!window.require) {
101
+ console.error('need puerts env');
102
+ return null;
103
+ }
104
+ var CS = window.require('csharp');
105
+ if (!CS) {
106
+ console.error('need puerts env');
107
+ return null;
108
+ }
109
+ return CS;
110
+ };
111
+ GradientText.prototype.onLoad = function (e) {
112
+ this.printLog('OnLoad');
113
+ var CS = this.getCSharp();
114
+ if (CS == null) {
115
+ console.error('Get CS error');
116
+ return;
117
+ }
118
+ var windowId = window.external.id;
119
+ var puerts = window.require('puerts');
120
+ var handle = e.target.attachment.handle;
121
+ var attachment = CS.com.tencent.pandora.CSharpInterface.GetSlotAttachmentByHandle(windowId, handle);
122
+ if (!attachment) {
123
+ console.error("can't get relected attachment, handle:".concat(handle));
124
+ return;
125
+ }
126
+ var placeholder = attachment.GetMountingGameObject();
127
+ this.textObj = placeholder.AddComponent(puerts.$typeof(CS.UnityEngine.UI.Text));
128
+ this.gradientObj = placeholder.AddComponent(puerts.$typeof(CS.UiEffect.GradientColor));
129
+ this.updateGradientText();
130
+ };
131
+ GradientText.prototype.updateGradientText = function () {
132
+ var textStr = !this.state.text || typeof (this.state.text) != 'string' ? '' : this.state.text;
133
+ var color = !this.state.color || typeof (this.state.color) != 'string' ? '#FFFFFFFF' : this.state.color;
134
+ var fontSize = !this.state.fontSize || typeof (this.state.fontSize) != 'number' ? 18 : this.state.fontSize;
135
+ var font = !this.state.font || typeof (this.state.font) != 'string' ? 'gamefont' : this.state.font;
136
+ var alignment = !this.state.alignment || typeof (this.state.alignment) != 'string' ? 'UpperLeft' : this.state.alignment;
137
+ var direction = !this.state.direction || typeof (this.state.direction) != 'string' ? 'Both' : this.state.direction;
138
+ var colorTop = !this.state.colorTop || typeof (this.state.colorTop) != 'string' ? '#FFFFFFFF' : this.state.colorTop;
139
+ var colorBottom = !this.state.colorBottom || typeof (this.state.colorBottom) != 'string' ? '#000000FF' : this.state.colorBottom;
140
+ var colorLeft = !this.state.colorLeft || typeof (this.state.colorLeft) != 'string' ? '#FF0000FF' : this.state.colorLeft;
141
+ var colorRight = !this.state.colorRight || typeof (this.state.colorRight) != 'string' ? '#0000FFFF' : this.state.colorLeft;
142
+ var fitRectTransform = !this.state.fitRectTransform || typeof (this.state.fitRectTransform) != 'boolean' ? false : this.state.fitRectTransform;
143
+ var richText = !this.state.richText || typeof (this.state.richText) != 'boolean' ? true : this.state.richText;
144
+ var alignByGeometry = !this.state.alignByGeometry || typeof (this.state.alignByGeometry) != 'boolean' ? false : this.state.alignByGeometry;
145
+ var horizontalOverflow = !this.state.horizontalOverflow || typeof (this.state.horizontalOverflow) != 'string' ? 'Warp' : this.state.horizontalOverflow;
146
+ var verticalOverflow = !this.state.verticalOverflow || typeof (this.state.verticalOverflow) != 'string' ? 'Truncate' : this.state.verticalOverflow;
147
+ var bestFit = !this.state.bestFit || typeof (this.state.bestFit) != 'boolean' ? false : this.state.bestFit;
148
+ var raycastTarget = !this.state.raycastTarget || typeof (this.state.raycastTarget) != 'boolean' ? true : this.state.raycastTarget;
149
+ var fontStyle = !this.state.fontStyle || typeof (this.state.fontStyle) != 'string' ? 'Normal' : this.state.fontStyle;
150
+ var lineSpacing = !this.state.lineSpacing || typeof (this.state.lineSpacing) != 'number' ? 1 : this.state.lineSpacing;
151
+ if (this.textObj) {
152
+ this.textObj.text = textStr;
153
+ this.textObj.fontSize = fontSize;
154
+ this.textObj.font = this.transFont(font);
155
+ this.textObj.alignment = this.transAlignment(alignment);
156
+ this.textObj.color = this.colorRgb(color);
157
+ this.textObj.richText = richText;
158
+ this.textObj.alignByGeometry = alignByGeometry;
159
+ this.textObj.horizontalOverflow = this.transHorizontalOverflow(horizontalOverflow);
160
+ this.textObj.verticalOverflow = this.transVerticalOverflow(verticalOverflow);
161
+ this.textObj.bestFit = bestFit;
162
+ this.textObj.raycastTarget = raycastTarget;
163
+ this.textObj.fontStyle = this.transFontStyle(fontStyle);
164
+ this.textObj.lineSpacing = lineSpacing;
165
+ }
166
+ else {
167
+ this.printLog('empty CS.UnityEngine.UI.Text');
168
+ }
169
+ if (this.gradientObj) {
170
+ this.gradientObj.direction = this.transDirection(direction);
171
+ this.gradientObj.colorTop = this.colorRgb(colorTop);
172
+ this.gradientObj.colorBottom = this.colorRgb(colorBottom);
173
+ this.gradientObj.colorRight = this.colorRgb(colorRight);
174
+ this.gradientObj.colorLeft = this.colorRgb(colorLeft);
175
+ this.gradientObj.m_fitRectTransform = fitRectTransform;
176
+ }
177
+ else {
178
+ this.printLog('empty CS.UiEffect.GradientColor');
179
+ }
180
+ };
181
+ GradientText.prototype.transFont = function (fontName) {
182
+ var CS = this.getCSharp();
183
+ return CS.com.tencent.pandora.TextPartner.GetFont.Invoke(fontName);
184
+ };
185
+ GradientText.prototype.transHorizontalOverflow = function (str) {
186
+ var CS = this.getCSharp();
187
+ if (str == 'Warp') {
188
+ return CS.UnityEngine.HorizontalWrapMode.Wrap;
189
+ }
190
+ else if (str == 'Overflow') {
191
+ return CS.UnityEngine.HorizontalWrapMode.Overflow;
192
+ }
193
+ else {
194
+ console.error('invaild HorizontalOverflow');
195
+ return CS.UnityEngine.HorizontalWrapMode.Wrap;
196
+ }
197
+ };
198
+ GradientText.prototype.transVerticalOverflow = function (str) {
199
+ var CS = this.getCSharp();
200
+ if (str == 'Truncate') {
201
+ return CS.UnityEngine.VerticalWrapMode.Truncate;
202
+ }
203
+ else if (str == 'Overflow') {
204
+ return CS.UnityEngine.VerticalWrapMode.Overflow;
205
+ }
206
+ else {
207
+ console.error('invaild VerticalOverflow');
208
+ return CS.UnityEngine.VerticalWrapMode.Truncate;
209
+ }
210
+ };
211
+ GradientText.prototype.transFontStyle = function (str) {
212
+ var CS = this.getCSharp();
213
+ if (str == 'Normal') {
214
+ return CS.UnityEngine.FontStyle.Normal;
215
+ }
216
+ else if (str == 'Bold') {
217
+ return CS.UnityEngine.FontStyle.Bold;
218
+ }
219
+ else if (str == 'Italic') {
220
+ return CS.UnityEngine.FontStyle.Italic;
221
+ }
222
+ else if (str == 'BoldAndItalic') {
223
+ return CS.UnityEngine.FontStyle.BoldAndItalic;
224
+ }
225
+ else {
226
+ console.error('invaild FontStyle');
227
+ return CS.UnityEngine.FontStyle.Normal;
228
+ }
229
+ };
230
+ GradientText.prototype.colorRgb = function (colorStr) {
231
+ this.printLog("colorList[i]/255[".concat(0 / 255, "]"));
232
+ this.printLog("colorStr[".concat(colorStr, "]"));
233
+ //十六进制颜色值的正则表达式
234
+ var reg = /^#([0-9a-fA-f]{0,}|)$/;
235
+ var matchRes = colorStr.toString().toLowerCase().match(reg);
236
+ var transColor = '';
237
+ this.printLog("matchRes".concat(JSON.stringify(matchRes)));
238
+ if (matchRes.length > 0)
239
+ transColor = matchRes[matchRes.length - 1];
240
+ var colorList = [];
241
+ while (transColor != '') {
242
+ var hex = '0x' + transColor.substring(0, 2);
243
+ this.printLog("hex[".concat(hex, "]"));
244
+ colorList.push(parseInt(hex, 16));
245
+ transColor = transColor.substring(2, transColor.length);
246
+ }
247
+ var r, g, b, a = 1;
248
+ for (var i = 0; i < colorList.length; i++) {
249
+ this.printLog("colorList i[".concat(i, "]item[").concat(colorList[i], "]"));
250
+ if (i == 0 && colorList[i] != null && colorList[i] != undefined) {
251
+ r = colorList[i] / 255;
252
+ }
253
+ if (i == 1 && colorList[i] != null && colorList[i] != undefined) {
254
+ g = colorList[i] / 255;
255
+ }
256
+ if (i == 2 && colorList[i] != null && colorList[i] != undefined) {
257
+ b = colorList[i] / 255;
258
+ }
259
+ if (i == 3 && colorList[i] != null && colorList[i] != undefined) {
260
+ a = colorList[i] / 255;
261
+ }
262
+ }
263
+ this.printLog("New Color r[".concat(r, "]g[").concat(g, "]b[").concat(b, "]a[").concat(a, "]"));
264
+ var CS = this.getCSharp();
265
+ return CS.UnityEngine.Color(r, g, b, a);
266
+ };
267
+ GradientText.prototype.printLog = function (text) {
268
+ if (this.isPrintLog) {
269
+ console.log(text);
270
+ }
271
+ };
272
+ GradientText.prototype.transDirection = function (direction) {
273
+ var CS = this.getCSharp();
274
+ if (direction == 'Both') {
275
+ return CS.UiEffect.GradientColor.DIRECTION.Both;
276
+ }
277
+ else if (direction == 'Vertical') {
278
+ return CS.UiEffect.GradientColor.DIRECTION.Vertical;
279
+ }
280
+ else if (direction == 'Horizontal') {
281
+ return CS.UiEffect.GradientColor.DIRECTION.Horizontal;
282
+ }
283
+ else {
284
+ console.error('invaild direction');
285
+ return CS.UiEffect.GradientColor.DIRECTION.Both;
286
+ }
287
+ };
288
+ GradientText.prototype.transAlignment = function (alignment) {
289
+ var CS = this.getCSharp();
290
+ if (alignment == 'UpperLeft') {
291
+ return CS.UnityEngine.TextAnchor.UpperLeft;
292
+ }
293
+ else if (alignment == 'UpperCenter') {
294
+ return CS.UnityEngine.TextAnchor.UpperCenter;
295
+ }
296
+ else if (alignment == 'UpperRight') {
297
+ return CS.UnityEngine.TextAnchor.UpperRight;
298
+ }
299
+ else if (alignment == 'MiddleCenter') {
300
+ return CS.UnityEngine.TextAnchor.MiddleCenter;
301
+ }
302
+ else if (alignment == 'MiddleLeft') {
303
+ return CS.UnityEngine.TextAnchor.MiddleLeft;
304
+ }
305
+ else if (alignment == 'MiddleRight') {
306
+ return CS.UnityEngine.TextAnchor.MiddleRight;
307
+ }
308
+ else if (alignment == 'LowerLeft') {
309
+ return CS.UnityEngine.TextAnchor.LowerLeft;
310
+ }
311
+ else if (alignment == 'LowerCenter') {
312
+ return CS.UnityEngine.TextAnchor.LowerCenter;
313
+ }
314
+ else if (alignment == 'LowerRight') {
315
+ return CS.UnityEngine.TextAnchor.LowerRight;
316
+ }
317
+ else {
318
+ console.error('invaild alignment');
319
+ return CS.UnityEngine.TextAnchor.UpperLeft;
320
+ }
321
+ };
322
+ GradientText.prototype.render = function (props) {
323
+ var style = !props.style ? { width: '200px', height: '200px', backgroundColor: '#FF00FFFF' } : props.style;
324
+ this.printLog('OnRender');
325
+ return (h("pixslot", { style: style, src: 'pixui://method:placeholder', onLoad: this.onLoad.bind(this) }));
326
+ };
327
+ return GradientText;
328
+ }(Component));
329
+ export { GradientText };
@@ -0,0 +1,23 @@
1
+ import { Component, CSSProperties, h } from 'preact';
2
+ interface ImageViewerProps {
3
+ src: string;
4
+ onClose: Function;
5
+ backgroundStyle?: CSSProperties;
6
+ imageBoxStyle?: CSSProperties;
7
+ imageAreaStyle?: CSSProperties;
8
+ imageStyle?: CSSProperties;
9
+ closeOnClickOutside?: boolean;
10
+ }
11
+ interface ImageViewerStates {
12
+ imageHeight: number;
13
+ imageWidth: number;
14
+ reCalSize: boolean;
15
+ }
16
+ export declare class ImageViewer extends Component<ImageViewerProps, ImageViewerStates> {
17
+ constructor(props: ImageViewerProps);
18
+ onClose: () => void;
19
+ onBlock: (event: any) => void;
20
+ handleImageLoad: (event: any) => void;
21
+ render(): h.JSX.Element;
22
+ }
23
+ export {};