pixuireactcomponents 1.3.7 → 1.3.8
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/package.json
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import preact, { Component } from 'preact';
|
|
2
|
+
interface TogglePicInfo {
|
|
3
|
+
selected_pic: string;
|
|
4
|
+
not_selected_pic: 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
|
+
}> {
|
|
3
20
|
private isMultiOption;
|
|
4
21
|
private toggleArray;
|
|
5
22
|
private togglePic;
|
|
@@ -9,5 +26,6 @@ export declare class ToggleGroup extends Component<any, any> {
|
|
|
9
26
|
private GenerateToggleItem;
|
|
10
27
|
private checkSelected;
|
|
11
28
|
constructor(props: any);
|
|
12
|
-
render(
|
|
29
|
+
render(): preact.JSX.Element;
|
|
13
30
|
}
|
|
31
|
+
export {};
|
|
@@ -18,8 +18,14 @@ var ToggleGroup = /** @class */ (function (_super) {
|
|
|
18
18
|
__extends(ToggleGroup, _super);
|
|
19
19
|
function ToggleGroup(props) {
|
|
20
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;
|
|
21
27
|
_this.GenerateToggleItem = function (toggleItem, togglePic, index, refreshAll) {
|
|
22
|
-
return (h(Toggle, {
|
|
28
|
+
return (h(Toggle, { toggleItem: toggleItem, togglePic: togglePic, index: index, checkSelected: _this.checkSelected, refreshAll: refreshAll }));
|
|
23
29
|
};
|
|
24
30
|
_this.checkSelected = function (index) {
|
|
25
31
|
if (_this.isMultiOption)
|
|
@@ -41,22 +47,21 @@ var ToggleGroup = /** @class */ (function (_super) {
|
|
|
41
47
|
_this.toggleArray[index].isSelected = true;
|
|
42
48
|
_this.currentIndex = index;
|
|
43
49
|
_this.items = [];
|
|
44
|
-
_this.
|
|
50
|
+
_this.setState({
|
|
51
|
+
refreshStatus: !_this.state.refreshStatus,
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
};
|
|
48
|
-
_this.toggleArray = props.toggleArray;
|
|
49
56
|
for (var i = 0; i < _this.toggleArray.length; i++) {
|
|
50
57
|
_this.toggleArray[i].isSelected = false;
|
|
51
58
|
}
|
|
52
|
-
_this.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_this.refreshAll = true;
|
|
56
|
-
_this.items = [];
|
|
59
|
+
_this.state = {
|
|
60
|
+
refreshStatus: true,
|
|
61
|
+
};
|
|
57
62
|
return _this;
|
|
58
63
|
}
|
|
59
|
-
ToggleGroup.prototype.render = function (
|
|
64
|
+
ToggleGroup.prototype.render = function () {
|
|
60
65
|
for (var i = 0; i < this.toggleArray.length; i++) {
|
|
61
66
|
this.items.push(this.GenerateToggleItem(this.toggleArray[i], this.togglePic, i, this.refreshAll));
|
|
62
67
|
}
|
|
@@ -69,22 +74,22 @@ var Toggle = /** @class */ (function (_super) {
|
|
|
69
74
|
__extends(Toggle, _super);
|
|
70
75
|
function Toggle(props) {
|
|
71
76
|
var _this = _super.call(this, props) || this;
|
|
72
|
-
_this.selected_pic = props.selected_pic;
|
|
73
|
-
_this.not_selected_pic = props.not_selected_pic;
|
|
74
|
-
_this.toggleText = props.toggleText;
|
|
75
|
-
_this.selectedFun = props.selectedFun;
|
|
76
|
-
_this.notSelectedFun = props.notSelectedFun;
|
|
77
|
-
_this.index = props.index;
|
|
78
|
-
_this.checkSelected = props.checkSelected;
|
|
79
|
-
_this.refreshAll = props.refreshAll;
|
|
77
|
+
_this.selected_pic = _this.props.togglePic.selected_pic;
|
|
78
|
+
_this.not_selected_pic = _this.props.togglePic.not_selected_pic;
|
|
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;
|
|
80
85
|
_this.state = {
|
|
81
|
-
isSelected: props.isSelected,
|
|
86
|
+
isSelected: _this.props.toggleItem.isSelected,
|
|
82
87
|
};
|
|
83
88
|
return _this;
|
|
84
89
|
}
|
|
85
90
|
Toggle.prototype.render = function (props) {
|
|
86
91
|
var _this = this;
|
|
87
|
-
if (props.refreshAll != this.refreshAll && props.isSelected != this.state.isSelected) {
|
|
92
|
+
if (props.refreshAll != this.refreshAll && this.props.toggleItem.isSelected != this.state.isSelected) {
|
|
88
93
|
this.setState({ isSelected: !this.state.isSelected });
|
|
89
94
|
return;
|
|
90
95
|
}
|