@leafer/display 1.0.5 → 1.0.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "@leafer/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,17 +22,17 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.0.5",
26
- "@leafer/data": "1.0.5",
27
- "@leafer/layout": "1.0.5",
28
- "@leafer/display-module": "1.0.5",
29
- "@leafer/event": "1.0.5",
30
- "@leafer/decorator": "1.0.5",
31
- "@leafer/helper": "1.0.5",
32
- "@leafer/debug": "1.0.5",
33
- "@leafer/platform": "1.0.5"
25
+ "@leafer/math": "1.0.7",
26
+ "@leafer/data": "1.0.7",
27
+ "@leafer/layout": "1.0.7",
28
+ "@leafer/display-module": "1.0.7",
29
+ "@leafer/event": "1.0.7",
30
+ "@leafer/decorator": "1.0.7",
31
+ "@leafer/helper": "1.0.7",
32
+ "@leafer/debug": "1.0.7",
33
+ "@leafer/platform": "1.0.7"
34
34
  },
35
35
  "devDependencies": {
36
- "@leafer/interface": "1.0.5"
36
+ "@leafer/interface": "1.0.7"
37
37
  }
38
38
  }
package/src/Branch.ts CHANGED
@@ -65,12 +65,16 @@ export class Branch extends Leaf { // tip: rewrited Group
65
65
 
66
66
  public add(child: ILeaf, index?: number): void {
67
67
  if (child === this) return
68
- child.__ || (child = UICreator.get(child.tag, child))
68
+ const noIndex = index === undefined
69
+ if (!child.__) {
70
+ if (child instanceof Array) return child.forEach(item => { this.add(item, index); noIndex || index++ }) // add []
71
+ else child = UICreator.get(child.tag, child) // add JSON
72
+ }
69
73
 
70
74
  if (child.parent) child.parent.remove(child)
71
75
  child.parent = this
72
76
 
73
- index === undefined ? this.children.push(child) : this.children.splice(index, 0, child)
77
+ noIndex ? this.children.push(child) : this.children.splice(index, 0, child)
74
78
  if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1
75
79
 
76
80
  child.__layout.boxChanged || child.__layout.boxChange() // layouted(removed), need update
@@ -86,9 +90,7 @@ export class Branch extends Leaf { // tip: rewrited Group
86
90
  this.__layout.affectChildrenSort && this.__layout.childrenSortChange()
87
91
  }
88
92
 
89
- public addMany(...children: ILeaf[]): void {
90
- children.forEach(child => this.add(child))
91
- }
93
+ public addMany(...children: ILeaf[]): void { this.add(children as any) }
92
94
 
93
95
  public remove(child?: ILeaf, destroy?: boolean): void {
94
96
  if (child) {
package/src/Leaf.ts CHANGED
@@ -612,7 +612,7 @@ export class Leaf implements ILeaf {
612
612
 
613
613
  public __updateSortChildren(): void { }
614
614
 
615
- public add(_child: ILeaf | ILeafInputData, _index?: number): void { }
615
+ public add(_child: ILeaf | ILeaf[] | ILeafInputData | ILeafInputData[], _index?: number): void { }
616
616
 
617
617
  public remove(_child?: ILeaf | number | string | IFindMethod, destroy?: boolean): void {
618
618
  if (this.parent) this.parent.remove(this, destroy)
package/types/index.d.ts CHANGED
@@ -168,7 +168,7 @@ declare class Leaf implements ILeaf {
168
168
  __updateMotionPath(): void;
169
169
  __runAnimation(_type: 'in' | 'out', _complete?: IFunction): void;
170
170
  __updateSortChildren(): void;
171
- add(_child: ILeaf | ILeafInputData, _index?: number): void;
171
+ add(_child: ILeaf | ILeaf[] | ILeafInputData | ILeafInputData[], _index?: number): void;
172
172
  remove(_child?: ILeaf | number | string | IFindMethod, destroy?: boolean): void;
173
173
  dropTo(parent: ILeaf, index?: number, resize?: boolean): void;
174
174
  on(_type: string | string[] | IEventMap, _listener?: IEventListener, _options?: IEventOption): void;