pixuireactcomponents 1.3.13 → 1.3.15

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  export { Progress } from "./ui/components/progress/Progress";
2
2
  export { Logger } from "./tools/Logger";
3
3
  export { Carousel } from "./ui/components/carousel/Carousel";
4
+ export { Button } from "./ui/components/button/Button";
5
+ export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
4
6
  export { ImageViewer } from "./ui/components/imageViewer/imageViewer";
5
7
  export { Slider, SliderProps } from "./ui/components/slider/Slider";
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { Tabs } from "./ui/components/tab/Tabs";
2
- export { Tab } from "./ui/components/tab/Tab";
1
+ // export {Tabs} from "./ui/components/tab/Tabs"
2
+ // export {Tab} from "./ui/components/tab/Tab"
3
3
  export { Slider } from "./ui/components/slider/Slider";
4
4
  export { Progress } from "./ui/components/progress/Progress";
5
5
  // export{ Dropdown} from "./ui/components/dropdown/Dropdown"
@@ -12,7 +12,7 @@ export { Logger } from "./tools/Logger";
12
12
  // export{EventDispatcherJs} from "./tools/EventDispatcherJs"
13
13
  export { Carousel } from "./ui/components/carousel/Carousel";
14
14
  // export {Slapface} from "./ui/components/slapface/Slapface"
15
- // export {Button} from "./ui/components/button/Button"
16
- // export {ToggleGroup} from "./ui/components/togglegroup/ToggleGroup"
15
+ export { Button } from "./ui/components/button/Button";
16
+ export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
17
17
  export { ImageViewer } from './ui/components/imageViewer/imageViewer';
18
18
  console.log("Hello, 欢迎使用PixUI React Components");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixuireactcomponents",
3
- "version": "1.3.13",
3
+ "version": "1.3.15",
4
4
  "description": "pixui react components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,21 @@
1
+ import { h, Component } from 'preact';
2
+ interface ButtonInfo {
3
+ buttonPic: string;
4
+ buttonText: string;
5
+ width: number;
6
+ height: number;
7
+ fontSize: number;
8
+ }
9
+ interface ButtonProps {
10
+ picNormal: ButtonInfo;
11
+ picPress: ButtonInfo;
12
+ picHover: ButtonInfo;
13
+ [key: string]: any;
14
+ }
15
+ export declare class Button extends Component<ButtonProps, any> {
16
+ private btnImg;
17
+ private btnText;
18
+ private buttonStateChange;
19
+ render(props: any): h.JSX.Element;
20
+ }
21
+ export {};
@@ -0,0 +1,68 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { h, Component } from 'preact';
17
+ var Button = /** @class */ (function (_super) {
18
+ __extends(Button, _super);
19
+ function Button() {
20
+ var _this = _super !== null && _super.apply(this, arguments) || this;
21
+ _this.btnImg = null;
22
+ _this.btnText = null;
23
+ _this.buttonStateChange = function (picState) {
24
+ if (!_this.btnImg) {
25
+ return;
26
+ }
27
+ _this.btnImg.src = picState.buttonPic;
28
+ _this.btnImg.style.width = "".concat(picState.width, "px");
29
+ _this.btnImg.style.height = "".concat(picState.height, "px");
30
+ if (!_this.btnText) {
31
+ return;
32
+ }
33
+ _this.btnText.textContent = picState.buttonText;
34
+ _this.btnText.style.fontSize = "".concat(picState.fontSize, "px");
35
+ };
36
+ return _this;
37
+ }
38
+ Button.prototype.render = function (props) {
39
+ var _this = this;
40
+ return (h("div", { style: { alignItems: 'center', justifyContent: 'center' }, onClick: function () {
41
+ var _a;
42
+ if (_this.props.clickEvent) {
43
+ if (_this.props.clickArr) {
44
+ (_a = _this.props).clickEvent.apply(_a, props.clickArr);
45
+ }
46
+ else {
47
+ _this.props.clickEvent();
48
+ }
49
+ }
50
+ }, onMouseDown: function () {
51
+ _this.buttonStateChange(_this.props.picPress);
52
+ }, onMouseUp: function () {
53
+ _this.buttonStateChange(_this.props.picHover);
54
+ }, onMouseOver: function () {
55
+ _this.buttonStateChange(_this.props.picHover);
56
+ }, onMouseOut: function () {
57
+ _this.buttonStateChange(_this.props.picNormal);
58
+ } },
59
+ h("img", { ref: function (img) {
60
+ _this.btnImg = img;
61
+ }, style: { width: "".concat(props.picNormal.width, "px"), height: "".concat(props.picNormal.height, "px") }, src: this.props.picNormal.buttonPic }),
62
+ h("div", { ref: function (text) {
63
+ _this.btnText = text;
64
+ }, style: { position: 'absolute', fontSize: "".concat(props.picNormal.fontSize, "px") } }, this.props.picNormal.buttonText)));
65
+ };
66
+ return Button;
67
+ }(Component));
68
+ export { Button };
@@ -0,0 +1,31 @@
1
+ import preact, { Component } from 'preact';
2
+ interface TogglePicInfo {
3
+ selectedPic: string;
4
+ notSelectedPic: string;
5
+ }
6
+ interface ToggleInfo {
7
+ toggleText: string;
8
+ selectedFun: Function;
9
+ notSelectedFun: Function;
10
+ [key: string]: any;
11
+ }
12
+ interface ToggleGroupProps {
13
+ togglePic: TogglePicInfo;
14
+ toggleArray: ToggleInfo[];
15
+ isMultiOption: boolean;
16
+ }
17
+ export declare class ToggleGroup extends Component<ToggleGroupProps, {
18
+ refreshStatus: boolean;
19
+ }> {
20
+ private isMultiOption;
21
+ private toggleArray;
22
+ private togglePic;
23
+ private currentIndex;
24
+ private items;
25
+ private refreshAll;
26
+ private GenerateToggleItem;
27
+ private checkSelected;
28
+ constructor(props: any);
29
+ render(): preact.JSX.Element;
30
+ }
31
+ export {};
@@ -0,0 +1,113 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { h, Component } from 'preact';
17
+ var ToggleGroup = /** @class */ (function (_super) {
18
+ __extends(ToggleGroup, _super);
19
+ function ToggleGroup(props) {
20
+ var _this = _super.call(this, props) || this;
21
+ _this.isMultiOption = _this.props.isMultiOption != undefined ? _this.props.isMultiOption : true;
22
+ _this.toggleArray = _this.props.toggleArray;
23
+ _this.togglePic = _this.props.togglePic;
24
+ _this.currentIndex = -1;
25
+ _this.items = [];
26
+ _this.refreshAll = true;
27
+ _this.GenerateToggleItem = function (toggleItem, togglePic, index, refreshAll) {
28
+ return (h(Toggle, { toggleItem: toggleItem, togglePic: togglePic, index: index, checkSelected: _this.checkSelected, refreshAll: refreshAll }));
29
+ };
30
+ _this.checkSelected = function (index) {
31
+ if (_this.isMultiOption)
32
+ return;
33
+ else {
34
+ if (index == _this.currentIndex) {
35
+ _this.toggleArray[index].isSelected = false;
36
+ _this.currentIndex = -1;
37
+ }
38
+ else {
39
+ if (_this.currentIndex == -1) {
40
+ _this.currentIndex = index;
41
+ _this.toggleArray[index].isSelected = true;
42
+ return;
43
+ }
44
+ _this.refreshAll = !_this.refreshAll;
45
+ _this.toggleArray[_this.currentIndex].isSelected = false;
46
+ _this.toggleArray[_this.currentIndex].notSelectedFun();
47
+ _this.toggleArray[index].isSelected = true;
48
+ _this.currentIndex = index;
49
+ _this.items = [];
50
+ _this.setState({
51
+ refreshStatus: !_this.state.refreshStatus,
52
+ });
53
+ }
54
+ }
55
+ };
56
+ for (var i = 0; i < _this.toggleArray.length; i++) {
57
+ _this.toggleArray[i].isSelected = false;
58
+ }
59
+ _this.state = {
60
+ refreshStatus: true,
61
+ };
62
+ return _this;
63
+ }
64
+ ToggleGroup.prototype.render = function () {
65
+ for (var i = 0; i < this.toggleArray.length; i++) {
66
+ this.items.push(this.GenerateToggleItem(this.toggleArray[i], this.togglePic, i, this.refreshAll));
67
+ }
68
+ return h("div", { style: { flexDirection: 'row' } }, this.items);
69
+ };
70
+ return ToggleGroup;
71
+ }(Component));
72
+ export { ToggleGroup };
73
+ var Toggle = /** @class */ (function (_super) {
74
+ __extends(Toggle, _super);
75
+ function Toggle(props) {
76
+ var _this = _super.call(this, props) || this;
77
+ _this.selectedPic = _this.props.togglePic.selectedPic;
78
+ _this.notSelectedPic = _this.props.togglePic.notSelectedPic;
79
+ _this.toggleText = _this.props.toggleItem.toggleText;
80
+ _this.selectedFun = _this.props.toggleItem.selectedFun;
81
+ _this.notSelectedFun = _this.props.toggleItem.notSelectedFun;
82
+ _this.index = _this.props.index;
83
+ _this.checkSelected = _this.props.checkSelected;
84
+ _this.refreshAll = _this.props.refreshAll;
85
+ _this.state = {
86
+ isSelected: _this.props.toggleItem.isSelected,
87
+ };
88
+ return _this;
89
+ }
90
+ Toggle.prototype.render = function (props) {
91
+ var _this = this;
92
+ if (props.refreshAll != this.refreshAll && this.props.toggleItem.isSelected != this.state.isSelected) {
93
+ this.setState({ isSelected: !this.state.isSelected });
94
+ return;
95
+ }
96
+ this.refreshAll = props.refreshAll;
97
+ return (h("div", { style: { alignItems: 'flex-end', flexDirection: 'row' } },
98
+ h("div", { style: {
99
+ width: '36px',
100
+ height: '36px',
101
+ backgroundSize: 'contain',
102
+ backgroundImage: "url(".concat(this.state.isSelected ? this.selectedPic : this.notSelectedPic, ")"),
103
+ }, onClick: function () {
104
+ _this.state.isSelected ? _this.notSelectedFun() : _this.selectedFun();
105
+ _this.setState({ isSelected: !_this.state.isSelected });
106
+ _this.checkSelected(_this.index);
107
+ } }),
108
+ h("div", null,
109
+ h("text", null, "".concat(this.toggleText))),
110
+ h("div", { style: { width: '50px' } })));
111
+ };
112
+ return Toggle;
113
+ }(Component));