pixuireactcomponents 1.3.7 → 1.3.9

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,17 +1,6 @@
1
1
  export { Tabs } from "./ui/components/tab/Tabs";
2
2
  export { Tab } from "./ui/components/tab/Tab";
3
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 { GradientText } from "./ui/components/gradient/GradientText";
9
- export { OutlineText } from "./ui/components/outlinetext/OutlineText";
10
4
  export { Logger } from "./tools/Logger";
11
- export { EventDispatcherJs } from "./tools/EventDispatcherJs";
12
- export { Carousel } from "./ui/components/carousel/Carousel";
13
- export { Slapface } from "./ui/components/slapface/Slapface";
14
- export { Button } from "./ui/components/button/Button";
15
- export { ToggleGroup } from "./ui/components/togglegroup/ToggleGroup";
16
5
  export { ImageViewer } from "./ui/components/imageViewer/imageViewer";
17
6
  export { Slider, SliderProps } from "./ui/components/slider/Slider";
package/index.js CHANGED
@@ -2,17 +2,17 @@ export { Tabs } from "./ui/components/tab/Tabs";
2
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
- 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";
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
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";
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
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.7",
3
+ "version": "1.3.9",
4
4
  "description": "pixui react components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,13 +25,13 @@ var __assign = (this && this.__assign) || function () {
25
25
  return __assign.apply(this, arguments);
26
26
  };
27
27
  import { Component, createRef, h } from 'preact';
28
- var row_center_center = {
28
+ var rowCenterCenter = {
29
29
  display: 'flex',
30
30
  flexDirection: 'row',
31
31
  justifyContent: 'center',
32
32
  alignItems: 'center'
33
33
  };
34
- var row_between_center = {
34
+ var rowBetweenCenter = {
35
35
  display: 'flex',
36
36
  flexDirection: 'row',
37
37
  justifyContent: 'space-between',
@@ -182,7 +182,7 @@ var Slider = /** @class */ (function (_super) {
182
182
  }
183
183
  };
184
184
  _this.computeWrapperStyle = function () {
185
- wrapperStyle = __assign({ width: _this.props.wrapperWidth + 'px', height: _this.props.wrapperHeight + 'px' }, row_center_center);
185
+ wrapperStyle = __assign({ width: _this.props.wrapperWidth + 'px', height: _this.props.wrapperHeight + 'px' }, rowCenterCenter);
186
186
  };
187
187
  _this.computeOuterStyle = function () {
188
188
  outerStyle = {
@@ -197,9 +197,9 @@ var Slider = /** @class */ (function (_super) {
197
197
  };
198
198
  };
199
199
  _this.computeInnerStyle = function () {
200
- var _width = Math.floor(_this.state.percent / 100) + '%';
200
+ var innerWidth = Math.floor(_this.state.percent / 100) + '%';
201
201
  innerStyle = {
202
- width: _width,
202
+ width: innerWidth,
203
203
  height: (_this.props.innerHeight != null) ? _this.props.innerHeight + 'px' : '100%',
204
204
  backgroundImage: "url(".concat(_this.props.innerBg, ")"),
205
205
  backgroundSize: '100% 100%',
@@ -212,7 +212,7 @@ var Slider = /** @class */ (function (_super) {
212
212
  _this.computeDotWrapperStyle = function () {
213
213
  dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px',
214
214
  //marginTop: (this.props.height - this.props.dotWrapperHeight) / 2 + "px",
215
- marginLeft: (_this.props.wrapperWidth * _this.state.percent / 10000 - _this.props.dotWrapperWidth / 2) + 'px' }, row_center_center
215
+ marginLeft: (_this.props.wrapperWidth * _this.state.percent / 10000 - _this.props.dotWrapperWidth / 2) + 'px' }, rowCenterCenter
216
216
  // backgroundColor: '#FF000066'
217
217
  );
218
218
  };
@@ -239,7 +239,7 @@ var Slider = /** @class */ (function (_super) {
239
239
  };
240
240
  };
241
241
  _this.computeWithButtonStyle = function () {
242
- withButtonStyle = __assign({ minWidth: _this.props.overallWidth + 'px' }, row_between_center);
242
+ withButtonStyle = __assign({ minWidth: _this.props.overallWidth + 'px' }, rowBetweenCenter);
243
243
  };
244
244
  _this.state = {
245
245
  percent: (props.discrete != null && _this.props.maxDiscrete != null && _this.props.discrete != null) ? _this.props.discrete * (10000 / _this.props.maxDiscrete) : Math.floor(_this.props.percent),
@@ -1,6 +0,0 @@
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
- }
@@ -1,96 +0,0 @@
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 = document.createElement('img');
22
- _this.btnText = document.createElement('div');
23
- return _this;
24
- }
25
- Button.prototype.render = function (props) {
26
- var _this = this;
27
- return (h("div", { style: { alignItems: 'center', justifyContent: 'center' }, onClick: function () {
28
- var _a;
29
- if (_this.props.clickEvent) {
30
- if (_this.props.clickArr) {
31
- (_a = _this.props).clickEvent.apply(_a, props.clickArr);
32
- }
33
- else {
34
- _this.props.clickEvent();
35
- }
36
- }
37
- }, onMouseDown: function (e) {
38
- if (!_this.btnImg) {
39
- return;
40
- }
41
- _this.btnImg.src = _this.props.picPress.buttonPic;
42
- _this.btnImg.style.width = "".concat(props.picPress.width, "px"),
43
- _this.btnImg.style.height = "".concat(props.picPress.height, "px");
44
- if (!_this.btnText) {
45
- return;
46
- }
47
- _this.btnText.textContent = _this.props.picPress.buttonText;
48
- _this.btnText.style.fontSize = "".concat(props.picPress.fontSize, "px");
49
- }, onMouseUp: function () {
50
- if (!_this.btnImg) {
51
- return;
52
- }
53
- _this.btnImg.src = _this.props.picHover.buttonPic;
54
- _this.btnImg.style.width = "".concat(props.picHover.width, "px"),
55
- _this.btnImg.style.height = "".concat(props.picHover.height, "px");
56
- if (!_this.btnText) {
57
- return;
58
- }
59
- _this.btnText.textContent = _this.props.picHover.buttonText;
60
- _this.btnText.style.fontSize = "".concat(props.picHover.fontSize, "px");
61
- }, onMouseOver: function () {
62
- if (!_this.btnImg) {
63
- return;
64
- }
65
- _this.btnImg.src = _this.props.picHover.buttonPic;
66
- _this.btnImg.style.width = "".concat(props.picHover.width, "px"),
67
- _this.btnImg.style.height = "".concat(props.picHover.height, "px");
68
- if (!_this.btnText) {
69
- return;
70
- }
71
- ;
72
- _this.btnText.textContent = _this.props.picHover.buttonText;
73
- _this.btnText.style.fontSize = "".concat(props.picHover.fontSize, "px");
74
- }, onMouseOut: function () {
75
- if (!_this.btnImg) {
76
- return;
77
- }
78
- _this.btnImg.src = _this.props.picNormal.buttonPic;
79
- _this.btnImg.style.width = "".concat(props.picNormal.width, "px"),
80
- _this.btnImg.style.height = "".concat(props.picNormal.height, "px");
81
- if (!_this.btnText) {
82
- return;
83
- }
84
- _this.btnText.textContent = _this.props.picNormal.buttonText;
85
- _this.btnText.style.fontSize = "".concat(props.picNormal.fontSize, "px");
86
- } },
87
- h("img", { ref: function (img) {
88
- _this.btnImg = img;
89
- }, style: { width: "".concat(props.picNormal.width, "px"), height: "".concat(props.picNormal.height, "px") }, src: this.props.picNormal.buttonPic }),
90
- h("div", { ref: function (text) {
91
- _this.btnText = text;
92
- }, style: { position: 'absolute', fontSize: "".concat(props.picNormal.fontSize, "px") } }, this.props.picNormal.buttonText)));
93
- };
94
- return Button;
95
- }(Component));
96
- export { Button };
@@ -1,5 +0,0 @@
1
- import { h } from 'preact';
2
- export declare function Carousel(props: any): h.JSX.Element;
3
- export declare namespace Carousel {
4
- var Item: (props: any) => h.JSX.Element;
5
- }
@@ -1,226 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
- if (ar || !(i in from)) {
15
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
- ar[i] = from[i];
17
- }
18
- }
19
- return to.concat(ar || Array.prototype.slice.call(from));
20
- };
21
- import { h } from 'preact';
22
- import { useState, useEffect, useRef, useMemo, useImperativeHandle } from '../../../../../lib/preact/hooks/src';
23
- // import React, { useState, useEffect, useRef, useMemo } from 'preact/hooks';
24
- var indicatorStyle = { width: '20px', height: '8px', margin: '5px', backgroundColor: '#cecfda', borderRadius: '3px' };
25
- var indicatorSelectedStyle = __assign(__assign({}, indicatorStyle), { backgroundColor: '#fafbfc' });
26
- export function Carousel(props) {
27
- var _a = props.children, children = _a === void 0 ? [] : _a, _b = props.defaultIndex, defaultIndex = _b === void 0 ? 1 : _b, _c = props.compWidth, compWidth = _c === void 0 ? 100 : _c, _d = props.compHeight, compHeight = _d === void 0 ? 100 : _d, _e = props.autoplay, autoplay = _e === void 0 ? true : _e, _f = props.switchDuration, switchDuration = _f === void 0 ? 3000 : _f, _g = props.loop, loop = _g === void 0 ? true : _g, _h = props.isVertical, isVertical = _h === void 0 ? false : _h, _j = props.touchable, touchable = _j === void 0 ? true : _j, _k = props.onSlideChange, onSlideChange = _k === void 0 ? null : _k, _l = props.onclickEvent, onclickEvent = _l === void 0 ? null : _l;
28
- useImperativeHandle(props.cRef, function () { return ({
29
- handleNext: handleNext,
30
- handlePrev: handlePrev
31
- }); });
32
- var duration = switchDuration < 1000 ? 1000 : switchDuration;
33
- var _m = useState(defaultIndex), showIndex = _m[0], setShowIndex = _m[1];
34
- //轮播元素正在滚动
35
- var isMoving = useRef(false);
36
- //鼠标手势信息
37
- var isMouseDown = useRef(false);
38
- var mouseDownX = useRef(0);
39
- var mouseDownY = useRef(0);
40
- var handleNextRef = useRef(function () { });
41
- var nextInterval = useRef();
42
- var _o = useState(true), showTransition = _o[0], setShowTransition = _o[1];
43
- var _p = useState([0, 0]), gesteroffset = _p[0], setGesteroffset = _p[1];
44
- var _q = useState(''), logTex = _q[0], setLogTex = _q[1];
45
- var offset = useMemo(function () { return -(isVertical ? compHeight : compWidth) * showIndex; }, [showIndex]);
46
- var itemBoxStyle = { minWidth: compWidth + 'px', minHeight: compHeight + 'px', maxWidth: compWidth + 'px', maxHeight: compHeight + 'px', };
47
- var carouselItems = useMemo(function () {
48
- var firstChild = children[0];
49
- var lastChild = children[children.length - 1];
50
- return __spreadArray(__spreadArray([lastChild], children, true), [firstChild], false);
51
- }, [children]);
52
- var isLastCarouseItem = function () { return showIndex === carouselItems.length - 1; };
53
- var isFirstCarouseLastItem = function () { return showIndex === 0; };
54
- useEffect(function () {
55
- setNextInterval();
56
- }, [autoplay]);
57
- //组件展示内容长度改变的时候改回到第一个元素,刷新autoplay判断
58
- useEffect(function () {
59
- setNextInterval();
60
- setShowIndex(1);
61
- }, [children]);
62
- useEffect(function () {
63
- //每次跳转前判断打开动画,否则动画关闭以后不会调用handleTransitionEnd
64
- if (!isLastCarouseItem() && !isFirstCarouseLastItem()) {
65
- setShowTransition(true);
66
- }
67
- }, [showIndex]);
68
- //更新handleNext的环境
69
- useEffect(function () {
70
- handleNextRef.current = handleNext;
71
- });
72
- var setNextInterval = function () {
73
- clearInterval(nextInterval.current);
74
- if (children.length > 1 && autoplay) {
75
- nextInterval.current = setInterval(function () {
76
- handleNextRef.current();
77
- }, duration);
78
- }
79
- };
80
- useEffect(function () {
81
- setNextInterval();
82
- }, []);
83
- var handlePrev = function () {
84
- if (isMoving.current)
85
- return;
86
- isMoving.current = true;
87
- if (showIndex === 0) {
88
- setShowIndex(carouselItems.length - 1);
89
- }
90
- else {
91
- setShowIndex(showIndex - 1);
92
- }
93
- };
94
- var handleNext = function () {
95
- // console.log('nex', isMoving.current, showIndex, isVertical ? `translate(0px, ${offset}px)` : `translate(${offset}px, 0px)`)
96
- if (!loop && showIndex == carouselItems.length - 2)
97
- return;
98
- if (isMoving.current)
99
- return;
100
- isMoving.current = true;
101
- setShowIndex(showIndex + 1);
102
- };
103
- var handleTransitionEnd = function () {
104
- //判断前后补位元素准备跳转
105
- //在动画结束以后关掉,否则用鼠标拖动的时候不能补充剩下的offset
106
- if (isLastCarouseItem() || isFirstCarouseLastItem()) {
107
- setShowTransition(false);
108
- }
109
- // console.log('showIndex' + showIndex)
110
- isMoving.current = false;
111
- //触发onSlideChange
112
- if (!isLastCarouseItem() && !isFirstCarouseLastItem() && onSlideChange)
113
- onSlideChange(showIndex - 1);
114
- // 处理首尾特殊case
115
- if (isLastCarouseItem()) {
116
- setShowIndex(1);
117
- }
118
- if (isFirstCarouseLastItem()) {
119
- setShowIndex(carouselItems.length - 2);
120
- }
121
- };
122
- var gestureUp = function () {
123
- // setLogTex(logTex + 'UP ');
124
- if (!touchable)
125
- return;
126
- if (isMoving.current)
127
- return;
128
- //打开动画
129
- setShowTransition(true);
130
- isMouseDown.current = false;
131
- //拖动大于1/3的时候跳转
132
- if (isVertical) {
133
- if (gesteroffset[1] > compHeight / 3) {
134
- handlePrev();
135
- }
136
- else if (gesteroffset[1] < -compHeight / 3) {
137
- handleNext();
138
- }
139
- }
140
- else {
141
- if (gesteroffset[0] > compWidth / 3) {
142
- handlePrev();
143
- }
144
- else if (gesteroffset[0] < -compWidth / 3) {
145
- handleNext();
146
- }
147
- }
148
- setGesteroffset([0, 0]);
149
- setNextInterval();
150
- };
151
- var gestureMove = function (e) {
152
- if (!touchable)
153
- return;
154
- if (!isMouseDown.current)
155
- return;
156
- var l = e.target.getBoundingClientRect().left;
157
- var r = e.target.getBoundingClientRect().right;
158
- var t = e.target.getBoundingClientRect().top;
159
- var b = e.target.getBoundingClientRect().bottom;
160
- var x = e.clientX;
161
- var y = e.clientY;
162
- setGesteroffset([e.clientX - mouseDownX.current, e.clientY - mouseDownY.current]);
163
- //计算滑动超出元素范围
164
- if (x < l || x > r || y > b || y < t) {
165
- gestureUp();
166
- }
167
- };
168
- var gestureDown = function (e) {
169
- if (!touchable)
170
- return;
171
- if (isMoving.current)
172
- return;
173
- if (nextInterval.current) {
174
- clearInterval(nextInterval.current);
175
- nextInterval.current = null;
176
- }
177
- mouseDownX.current = e.clientX;
178
- mouseDownY.current = e.clientY;
179
- isMouseDown.current = true;
180
- //拖动时关闭动画
181
- setShowTransition(false);
182
- };
183
- var gestureClick = function (props) {
184
- if (isMoving.current)
185
- return;
186
- if (onclickEvent) {
187
- onclickEvent(showIndex - 1);
188
- }
189
- };
190
- return (h("div", { style: { flexDirection: 'column' } },
191
- h("div", { style: __assign(__assign({ position: 'relative' }, itemBoxStyle), { overflow: 'hidden', flexShrink: 0 }) },
192
- h("div", { style: {
193
- display: 'flex',
194
- width: isVertical ? compWidth : compWidth * carouselItems.length + 'px',
195
- height: isVertical ? compHeight * carouselItems.length : compHeight + 'px',
196
- transition: "transform ".concat(showTransition ? '0.5s' : '0s', " ease 0s"),
197
- transform: isVertical ? "translate(0px, ".concat(offset + gesteroffset[1], "px)") : "translate(".concat(offset + gesteroffset[0], "px, 0px)"),
198
- flexDirection: isVertical ? 'column' : 'row',
199
- flexShrink: 0,
200
- }, class: 'wrapper', onTransitionEnd: handleTransitionEnd }, carouselItems.map(function (child) { return child; }))),
201
- h("div", { draggable: true, style: __assign(__assign({}, itemBoxStyle), { position: 'absolute' }), onClick: function () { gestureClick(props); }, class: 'GestureComp', onDragStart: function (e) {
202
- if (children.length > 1) {
203
- gestureDown(e);
204
- }
205
- }, onDrag: function (e) {
206
- if (children.length > 1) {
207
- gestureMove(e);
208
- }
209
- }, onDragEnd: function () {
210
- if (children.length > 1) {
211
- gestureUp();
212
- }
213
- } }),
214
- h("div", { style: { flexDirection: isVertical ? 'column' : 'row', } }, children.map(function (v, i) {
215
- return h("div", { style: (showIndex == i + 1) ? indicatorSelectedStyle : indicatorStyle, onClick: function () { setShowIndex(i + 1); } });
216
- }))));
217
- }
218
- Carousel.Item = function (props) {
219
- return h("div", { style: {
220
- // width: '100%',
221
- // height: '100%',
222
- // flexShrink: 0,
223
- } },
224
- " ",
225
- props.children);
226
- };
@@ -1,30 +0,0 @@
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
- }
@@ -1,92 +0,0 @@
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 };
@@ -1,11 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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
- }