1
1
import { Component , HostBinding , Input , ElementRef , Output , EventEmitter } from '@angular/core' ;
2
2
3
3
/**
4
- * Provides reference to `SplitPaneComponent` component.
5
- * Represents individual resizable panes. Users can control the resize behavior via the min and max size properties.
6
- * @export
7
- * @class SplitPaneComponent
4
+ * Represents individual resizable/collapsible panes.
5
+ * @igxModule IgxSplitterModule
6
+ *
7
+ * @igxParent IgxSplitterComponent
8
+ *
9
+ * @igxKeywords pane
10
+ *
11
+ * @igxGroup presentation
12
+ *
13
+ * @remarks
14
+ * Users can control the resize behavior via the min and max size properties.
8
15
*/
9
16
@Component ( {
10
17
selector : 'igx-splitter-pane' ,
11
18
templateUrl : './splitter-pane.component.html'
12
19
} )
13
20
export class IgxSplitterPaneComponent {
14
21
15
- public _size = 'auto' ;
22
+ private _size = 'auto' ;
23
+ private _collapsed = false ;
24
+
25
+ /** @hidden @internal */
26
+ public owner ;
27
+
16
28
/**
17
- * Sets/gets the size of the current `IgxSplitterPaneComponent`.
29
+ * Gets/Sets the size of the current pane.
30
+ * * @example
31
+ * ```html
32
+ * <igx-splitter>
33
+ * <igx-splitter-pane [size]='size'>...</igx-splitter-pane>
34
+ * </igx-splitter>
35
+ * ```
18
36
*/
19
37
@Input ( )
20
38
get size ( ) {
@@ -24,73 +42,98 @@ export class IgxSplitterPaneComponent {
24
42
set size ( value ) {
25
43
this . _size = value ;
26
44
this . el . nativeElement . style . flex = this . flex ;
27
- this . sizeChange . emit ( value ) ;
28
45
}
29
46
30
47
/**
31
- * @hidden @internal
32
- */
33
- @ Output ( )
34
- public sizeChange = new EventEmitter < string > ( ) ;
35
-
36
- /**
37
- * Sets/gets the minimum allowable size of the current `IgxSplitterPaneComponent`.
48
+ * Gets/Sets the minimum allowed size of the current pane.
49
+ * @example
50
+ * ```html
51
+ * <igx-splitter>
52
+ * <igx-splitter-pane [minSize]='minSize'>...</igx-splitter-pane>
53
+ * </igx-splitter>
54
+ * ```
38
55
*/
39
56
@Input ( )
40
57
public minSize ! : string ;
41
58
42
59
/**
43
- * Sets/gets the maximum allowable size of the current `IgxSplitterPaneComponent`.
60
+ * Gets/Set the maximum allowed size of the current pane.
61
+ * @example
62
+ * ```html
63
+ * <igx-splitter>
64
+ * <igx-splitter-pane [maxSize]='maxSize'>...</igx-splitter-pane>
65
+ * </igx-splitter>
66
+ * ```
44
67
*/
45
68
@Input ( )
46
69
public maxSize ! : string ;
47
70
48
71
/**
49
- * Sets/Gets whether pane is resizable.
72
+ * Gets/Sets whether pane is resizable.
73
+ * @example
74
+ * ```html
75
+ * <igx-splitter>
76
+ * <igx-splitter-pane [resizable]='false'>...</igx-splitter-pane>
77
+ * </igx-splitter>
78
+ * ```
79
+ * @remarks
80
+ * If pane is not resizable its related splitter bar cannot be dragged.
50
81
*/
51
82
@Input ( )
52
83
public resizable = true ;
53
84
54
-
55
85
/**
56
- * Sets/gets the `order` property of the current `IgxSplitterPaneComponent`.
86
+ * Event fired when collapsed state of pane is changed.
87
+ * @example
88
+ * ```html
89
+ * <igx-splitter>
90
+ * <igx-splitter-pane (onToggle)='onPaneToggle($event)'>...</igx-splitter-pane>
91
+ * </igx-splitter>
92
+ * ```
57
93
*/
58
- @Input ( )
94
+ @Output ( )
95
+ public onToggle = new EventEmitter < IgxSplitterPaneComponent > ( ) ;
96
+
97
+
98
+ /** @hidden @internal */
59
99
@HostBinding ( 'style.order' )
60
100
public order ! : number ;
61
101
62
102
/**
103
+ *
104
+ * @hidden @internal
63
105
* Gets the host native element.
64
- * @readonly
65
- * @type *
66
106
*/
67
107
public get element ( ) : any {
68
108
return this . el . nativeElement ;
69
109
}
70
110
71
111
/**
72
- * Sets/gets the `overflow` property of the current `IgxSplitterPaneComponent`.
112
+ * @hidden @internal
113
+ * Gets/Sets the `overflow`.
73
114
*/
74
115
@HostBinding ( 'style.overflow' )
75
116
public overflow = 'auto' ;
76
117
77
118
/**
78
- * Sets/gets the `minHeight` and `minWidth` propertis of the current `IgxSplitterPaneComponent`.
119
+ * @hidden @internal
120
+ * Gets/Sets the `minHeight` and `minWidth` properties of the current pane.
79
121
*/
80
122
@HostBinding ( 'style.min-height' )
81
123
@HostBinding ( 'style.min-width' )
82
124
public minHeight = 0 ;
83
125
84
126
/**
85
- * Sets/gets the `maxHeight` and `maxWidth` propertis of the current `IgxSplitterPaneComponent`.
127
+ * @hidden @internal
128
+ * Gets/Sets the `maxHeight` and `maxWidth` properties of the current `IgxSplitterPaneComponent`.
86
129
*/
87
130
@HostBinding ( 'style.max-height' )
88
131
@HostBinding ( 'style.max-width' )
89
132
public maxHeight = '100%' ;
90
133
91
134
/**
135
+ * @hidden @internal
92
136
* Gets the `flex` property of the current `IgxSplitterPaneComponent`.
93
- * @readonly
94
137
*/
95
138
@HostBinding ( 'style.flex' )
96
139
public get flex ( ) {
@@ -101,31 +144,56 @@ export class IgxSplitterPaneComponent {
101
144
}
102
145
103
146
/**
104
- * Sets/gets the 'display' property of the current `IgxSplitterPaneComponent`
147
+ * @hidden @internal
148
+ * Gets/Sets the 'display' property of the current pane.
105
149
*/
106
150
@HostBinding ( 'style.display' )
107
151
public display = 'flex' ;
108
152
109
- private _hidden = false ;
110
-
111
153
/**
112
- * Sets/gets whether current `IgxSplitterPanecomponent` is hidden
154
+ * Gets/Sets whether current pane is collapsed.
155
+ * @example
156
+ * ```typescript
157
+ * const isCollapsed = pane.collapsed;
158
+ * ```
113
159
*/
114
160
@Input ( )
115
- public set hidden ( value ) {
116
- this . _hidden = value ;
117
- this . display = this . _hidden ? 'none' : 'flex' ;
161
+ public set collapsed ( value ) {
162
+ this . _collapsed = value ;
163
+ this . display = this . _collapsed ? 'none' : 'flex' ;
164
+ }
165
+
166
+ public get collapsed ( ) {
167
+ return this . _collapsed ;
118
168
}
119
169
120
- public get hidden ( ) {
121
- return this . _hidden ;
170
+ /** @hidden @internal */
171
+ private _getSiblings ( ) {
172
+ const panes = this . owner . panes . toArray ( ) ;
173
+ const index = panes . indexOf ( this ) ;
174
+ const siblings = [ ] ;
175
+ if ( index !== 0 ) {
176
+ siblings . push ( panes [ index - 1 ] ) ;
177
+ }
178
+ if ( index !== panes . length - 1 ) {
179
+ siblings . push ( panes [ index + 1 ] ) ;
180
+ }
181
+ return siblings ;
122
182
}
123
183
124
184
/**
125
- * Event fired when collapsing and changing the hidden state of the current pane
185
+ * Toggles the collapsed state of the pane.
186
+ * @example
187
+ * ```typescript
188
+ * pane.toggle();
189
+ * ```
126
190
*/
127
- @Output ( )
128
- public onPaneToggle = new EventEmitter < IgxSplitterPaneComponent > ( ) ;
191
+ public toggle ( ) {
192
+ // reset sibling sizes when pane collapse state changes.
193
+ this . _getSiblings ( ) . forEach ( sibling => sibling . size = 'auto' ) ;
194
+ this . collapsed = ! this . collapsed ;
195
+ this . onToggle . emit ( this ) ;
196
+ }
129
197
130
198
constructor ( private el : ElementRef ) { }
131
199
}
0 commit comments