pixuireactcomponents 1.1.3 → 1.1.4

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,11 +1,11 @@
1
1
  {
2
2
  "name": "pixuireactcomponents",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "pixui react components",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
- "author": "nepdai",
9
+ "author": "hardenzheng",
10
10
  "license": "ISC"
11
11
  }
package/tools/Logger.js CHANGED
@@ -48,7 +48,7 @@ var regexForLine = new RegExp(",$");
48
48
  */
49
49
  Logger.ObjectPrinter2 = function (object, name) {
50
50
  var lines = [];
51
- lines.push("".concat(name, " = "));
51
+ lines.push(name + " = ");
52
52
  getTreeStyleLines(object, 1, lines);
53
53
  console.warn(lines.join("\n"));
54
54
  };
@@ -92,7 +92,7 @@ function getSeparation2(level) {
92
92
  */
93
93
  Logger.HierarchyPrinter = function (object, name) {
94
94
  var lines = [];
95
- lines.push("".concat(name, " = "));
95
+ lines.push(name + " = ");
96
96
  getTreeStyleHierarchyLines(object, 1, lines);
97
97
  console.warn(lines.join("\n"));
98
98
  };
@@ -14,6 +14,16 @@ var __extends = (this && this.__extends) || (function () {
14
14
  };
15
15
  })();
16
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
+ };
17
27
  var Dropdown = /** @class */ (function (_super) {
18
28
  __extends(Dropdown, _super);
19
29
  function Dropdown(props) {
@@ -75,7 +85,7 @@ var Dropdown = /** @class */ (function (_super) {
75
85
  return (h("div", null,
76
86
  h("div", { style: this.props.config.spreadStyle },
77
87
  this.props.spreadMainUI,
78
- _optionsUI)));
88
+ h("div", { style: optionsDivStyle }, _optionsUI))));
79
89
  };
80
90
  return Dropdown;
81
91
  }(Component));
@@ -1,6 +1,7 @@
1
1
  import { Component } from "preact";
2
2
  /**
3
3
  * dropdown 打开时options列表的单个Item UI
4
+ * 如果要使用滚动条,在创建改该组件时最外层div样式里面需添加flex-shrink : 0
4
5
  */
5
6
  export declare abstract class DropdownOptionUI<T> extends Component<{
6
7
  info: T;
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  import { Component } from "preact";
17
17
  /**
18
18
  * dropdown 打开时options列表的单个Item UI
19
+ * 如果要使用滚动条,在创建改该组件时最外层div样式里面需添加flex-shrink : 0
19
20
  */
20
21
  var DropdownOptionUI = /** @class */ (function (_super) {
21
22
  __extends(DropdownOptionUI, _super);
@@ -86,7 +86,7 @@ var Progress = /** @class */ (function (_super) {
86
86
  outerStyle = {
87
87
  width: '100%',
88
88
  height: _this.props.height + "px",
89
- backgroundImage: "url(".concat(_this.props.outerBg, ")"),
89
+ backgroundImage: "url(" + _this.props.outerBg + ")",
90
90
  backgroundSize: '100% 100%'
91
91
  };
92
92
  };
@@ -95,7 +95,7 @@ var Progress = /** @class */ (function (_super) {
95
95
  innerStyle = {
96
96
  width: _width,
97
97
  height: '100%',
98
- backgroundImage: "url(".concat(_this.props.innerBg, ")"),
98
+ backgroundImage: "url(" + _this.props.innerBg + ")",
99
99
  backgroundSize: '100% 100%'
100
100
  };
101
101
  };
@@ -188,7 +188,7 @@ var Slider = /** @class */ (function (_super) {
188
188
  outerStyle = {
189
189
  width: '100%',
190
190
  height: _this.props.height + "px",
191
- backgroundImage: "url(".concat(_this.props.outerBg, ")"),
191
+ backgroundImage: "url(" + _this.props.outerBg + ")",
192
192
  backgroundSize: '100% 100%',
193
193
  display: 'flex',
194
194
  flexDirection: 'row',
@@ -201,7 +201,7 @@ var Slider = /** @class */ (function (_super) {
201
201
  innerStyle = {
202
202
  width: _width,
203
203
  height: '100%',
204
- backgroundImage: "url(".concat(_this.props.innerBg, ")"),
204
+ backgroundImage: "url(" + _this.props.innerBg + ")",
205
205
  backgroundSize: '100% 100%',
206
206
  display: 'flex',
207
207
  flexDirection: 'row',
@@ -0,0 +1,53 @@
1
+
2
+ 下拉选中框Dropdown
3
+ ===
4
+
5
+
6
+ 前言
7
+ ---
8
+
9
+ <img src="../../images/前言.png" />
10
+ 下拉选中框Dropdown,其实也是一种N选1的UI组件。不过跟Tabs(另一篇介绍了)这种N选1相比,有所差别:
11
+ Tabs这种N选1场景,N个选项都是直接展示在外的。Dropdown这种N选1,有两种状态:展开态和收缩态。展开态展示所有选项,收缩态只展示选中的1。也是很常用的功能。
12
+ 开发过程遇到这种需求时,抽象沉淀了一个Dropdown组件。方便后续快速实现一个健壮的下拉列表需求。
13
+ 组件和示例的git地址:[https://git.woa.com/pixui_plugin/PixUIReactComponents.git。](https://git.woa.com/pixui_plugin/PixUIReactComponents.git)
14
+ 具体代码位置:
15
+ <img src="../../images/代码位置.png" />
16
+
17
+
18
+ 设计思路及用法
19
+ ---
20
+
21
+ <img src="../../images/设计思路及用法.png" />
22
+ <img src="../../images/设计思路及用法2.png" />
23
+ 看一下源码,基本的拆解思路是:
24
+
25
+ 1. 首先是有2个状态,收缩态 和 展开态
26
+
27
+
28
+ 2. 收缩态 需要传入一个DropdownUnspreadMainUI的实例(对应当前选中Item),直接展示
29
+
30
+ 3.展开态 时,依次展示DropdownSpreadMainUI的实例(对应当前选中Item)和 N - 1个DropdownOptionUI的实例(对应N - 1 个为选中Item)
31
+
32
+ 4.考虑到单个Item对应的数据类型不定,每个Item的样式也千变万化。所以上述3种实例对应的类均基于泛型实现,方便扩展。
33
+
34
+ 5.如果需要使用滚动条,在创建DropdownOptionUI(每项item)时,需要在最外层的div添加样式: ***flex-shrink : 0***
35
+
36
+ <img src="../../images/思路拆解.png" />
37
+
38
+
39
+
40
+ 结合Demo看下用法:
41
+
42
+ - 使用Dropdown组件时,定义好数据类型 和 3种状态的Item类型
43
+
44
+ - 传入3种状态的Item对应的实例对象 
45
+
46
+ - 传入一个DropdownConfig,里面包括了下拉列表的数据 和 展开态的整体Style
47
+
48
+
49
+
50
+
51
+
52
+
53
+
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # 组件库
2
- 本组件库目前分为2大类:ui组件和工具组件。分别参见目录ui/和目录tools。
3
- 具体组件说明,参见对应类别目录下的md文档
package/tools/tools.md DELETED
@@ -1,22 +0,0 @@
1
- # 工具类组件
2
- ### 1. EventDispatcherJs.tsx
3
- React里可供使用的事件派发器,类似Pandora Lua里的EventDispatcher。
4
-
5
- 用法主要就3个接口:
6
-
7
- * AddEventListener: 添加监听事件
8
- * DispatchEvent: 分发监听事件
9
- * RemoveEventListener: 移除监听事件
10
-
11
- ### 2. Logger.tsx
12
- React里可供使用的对象(数组)打印器。
13
-
14
- 直接console.log一个对象时,在游戏引擎中,无法打印出这个对象里的东西。而实际开发时,前后端联调时,需要方便的确认各种对象里的细节。
15
-
16
- 用法一共3个接口,打印粒度有差异。
17
-
18
- * ObjectPrinter: 打印一个对象的内部细节,效果如下
19
- ![](./img/logger.png)
20
-
21
- * ObjectPrinter2:比上一个打印的信息更多
22
- * HierarchyPrinter: 采样打印,对数组进行采样,能打印最多的信息
package/ui/ui.md DELETED
@@ -1,2 +0,0 @@
1
- # UI组件
2
- 组件源码,参见components目录;对应的示例Demo,参见sample目录