@leafer/display 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
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.4",
26
- "@leafer/data": "1.0.4",
27
- "@leafer/layout": "1.0.4",
28
- "@leafer/display-module": "1.0.4",
29
- "@leafer/event": "1.0.4",
30
- "@leafer/decorator": "1.0.4",
31
- "@leafer/helper": "1.0.4",
32
- "@leafer/debug": "1.0.4",
33
- "@leafer/platform": "1.0.4"
25
+ "@leafer/math": "1.0.6",
26
+ "@leafer/data": "1.0.6",
27
+ "@leafer/layout": "1.0.6",
28
+ "@leafer/display-module": "1.0.6",
29
+ "@leafer/event": "1.0.6",
30
+ "@leafer/decorator": "1.0.6",
31
+ "@leafer/helper": "1.0.6",
32
+ "@leafer/debug": "1.0.6",
33
+ "@leafer/platform": "1.0.6"
34
34
  },
35
35
  "devDependencies": {
36
- "@leafer/interface": "1.0.4"
36
+ "@leafer/interface": "1.0.6"
37
37
  }
38
38
  }
package/src/Branch.ts CHANGED
@@ -4,6 +4,7 @@ import { BoundsHelper } from '@leafer/math'
4
4
  import { BranchHelper, LeafBoundsHelper } from '@leafer/helper'
5
5
  import { useModule } from '@leafer/decorator'
6
6
  import { BranchRender } from '@leafer/display-module'
7
+ import { UICreator } from '@leafer/platform'
7
8
 
8
9
  import { Leaf } from './Leaf'
9
10
 
@@ -64,11 +65,16 @@ export class Branch extends Leaf { // tip: rewrited Group
64
65
 
65
66
  public add(child: ILeaf, index?: number): void {
66
67
  if (child === this) return
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
+ }
67
73
 
68
74
  if (child.parent) child.parent.remove(child)
69
75
  child.parent = this
70
76
 
71
- index === undefined ? this.children.push(child) : this.children.splice(index, 0, child)
77
+ noIndex ? this.children.push(child) : this.children.splice(index, 0, child)
72
78
  if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1
73
79
 
74
80
  child.__layout.boxChanged || child.__layout.boxChange() // layouted(removed), need update
@@ -84,15 +90,17 @@ export class Branch extends Leaf { // tip: rewrited Group
84
90
  this.__layout.affectChildrenSort && this.__layout.childrenSortChange()
85
91
  }
86
92
 
87
- public addMany(...children: ILeaf[]): void {
88
- children.forEach(child => this.add(child))
89
- }
93
+ public addMany(...children: ILeaf[]): void { this.add(children as any) }
90
94
 
91
95
  public remove(child?: ILeaf, destroy?: boolean): void {
92
96
  if (child) {
93
97
 
94
- if ((child as ILeaf).animationOut) child.__runAnimation('out', () => this.__remove(child, destroy))
95
- else this.__remove(child, destroy)
98
+ if (child.__) {
99
+
100
+ if ((child as ILeaf).animationOut) child.__runAnimation('out', () => this.__remove(child, destroy))
101
+ else this.__remove(child, destroy)
102
+
103
+ } else this.find(child as any).forEach(item => this.remove(item, destroy)) //
96
104
 
97
105
  } else if (child === undefined) {
98
106
  super.remove(null, destroy)
package/src/Leaf.ts CHANGED
@@ -36,6 +36,9 @@ export class Leaf implements ILeaf {
36
36
  public leafer?: ILeaferBase
37
37
  public parent?: ILeaf
38
38
 
39
+ public get leaferIsCreated(): boolean { return this.leafer && this.leafer.created }
40
+ public get leaferIsReady(): boolean { return this.leafer && this.leafer.ready }
41
+
39
42
  public get isLeafer(): boolean { return false }
40
43
  public get isBranch(): boolean { return false }
41
44
  public get isBranchLeaf(): boolean { return false }
@@ -609,9 +612,9 @@ export class Leaf implements ILeaf {
609
612
 
610
613
  public __updateSortChildren(): void { }
611
614
 
612
- public add(_child: ILeaf, _index?: number): void { }
615
+ public add(_child: ILeaf | ILeaf[] | ILeafInputData | ILeafInputData[], _index?: number): void { }
613
616
 
614
- public remove(_child?: ILeaf, destroy?: boolean): void {
617
+ public remove(_child?: ILeaf | number | string | IFindMethod, destroy?: boolean): void {
615
618
  if (this.parent) this.parent.remove(this, destroy)
616
619
  }
617
620
 
package/types/index.d.ts CHANGED
@@ -12,6 +12,8 @@ declare class Leaf implements ILeaf {
12
12
  get __LayoutProcessor(): typeof LeafLayout;
13
13
  leafer?: ILeaferBase;
14
14
  parent?: ILeaf;
15
+ get leaferIsCreated(): boolean;
16
+ get leaferIsReady(): boolean;
15
17
  get isLeafer(): boolean;
16
18
  get isBranch(): boolean;
17
19
  get isBranchLeaf(): boolean;
@@ -166,8 +168,8 @@ declare class Leaf implements ILeaf {
166
168
  __updateMotionPath(): void;
167
169
  __runAnimation(_type: 'in' | 'out', _complete?: IFunction): void;
168
170
  __updateSortChildren(): void;
169
- add(_child: ILeaf, _index?: number): void;
170
- remove(_child?: ILeaf, destroy?: boolean): void;
171
+ add(_child: ILeaf | ILeaf[] | ILeafInputData | ILeafInputData[], _index?: number): void;
172
+ remove(_child?: ILeaf | number | string | IFindMethod, destroy?: boolean): void;
171
173
  dropTo(parent: ILeaf, index?: number, resize?: boolean): void;
172
174
  on(_type: string | string[] | IEventMap, _listener?: IEventListener, _options?: IEventOption): void;
173
175
  off(_type?: string | string[], _listener?: IEventListener, _options?: IEventOption): void;