11import { Component , HostBinding , Input , ElementRef , Output , EventEmitter } from '@angular/core' ;
22
33/**
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.
815 */
916@Component ( {
1017 selector : 'igx-splitter-pane' ,
1118 templateUrl : './splitter-pane.component.html'
1219} )
1320export class IgxSplitterPaneComponent {
1421
15- public _size = 'auto' ;
22+ private _size = 'auto' ;
23+ private _collapsed = false ;
24+
25+ /** @hidden @internal */
26+ public owner ;
27+
1628 /**
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+ * ```
1836 */
1937 @Input ( )
2038 get size ( ) {
@@ -24,73 +42,98 @@ export class IgxSplitterPaneComponent {
2442 set size ( value ) {
2543 this . _size = value ;
2644 this . el . nativeElement . style . flex = this . flex ;
27- this . sizeChange . emit ( value ) ;
2845 }
2946
3047 /**
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+ * ```
3855 */
3956 @Input ( )
4057 public minSize ! : string ;
4158
4259 /**
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+ * ```
4467 */
4568 @Input ( )
4669 public maxSize ! : string ;
4770
4871 /**
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.
5081 */
5182 @Input ( )
5283 public resizable = true ;
5384
54-
5585 /**
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+ * ```
5793 */
58- @Input ( )
94+ @Output ( )
95+ public onToggle = new EventEmitter < IgxSplitterPaneComponent > ( ) ;
96+
97+
98+ /** @hidden @internal */
5999 @HostBinding ( 'style.order' )
60100 public order ! : number ;
61101
62102 /**
103+ *
104+ * @hidden @internal
63105 * Gets the host native element.
64- * @readonly
65- * @type *
66106 */
67107 public get element ( ) : any {
68108 return this . el . nativeElement ;
69109 }
70110
71111 /**
72- * Sets/gets the `overflow` property of the current `IgxSplitterPaneComponent`.
112+ * @hidden @internal
113+ * Gets/Sets the `overflow`.
73114 */
74115 @HostBinding ( 'style.overflow' )
75116 public overflow = 'auto' ;
76117
77118 /**
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.
79121 */
80122 @HostBinding ( 'style.min-height' )
81123 @HostBinding ( 'style.min-width' )
82124 public minHeight = 0 ;
83125
84126 /**
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`.
86129 */
87130 @HostBinding ( 'style.max-height' )
88131 @HostBinding ( 'style.max-width' )
89132 public maxHeight = '100%' ;
90133
91134 /**
135+ * @hidden @internal
92136 * Gets the `flex` property of the current `IgxSplitterPaneComponent`.
93- * @readonly
94137 */
95138 @HostBinding ( 'style.flex' )
96139 public get flex ( ) {
@@ -101,31 +144,56 @@ export class IgxSplitterPaneComponent {
101144 }
102145
103146 /**
104- * Sets/gets the 'display' property of the current `IgxSplitterPaneComponent`
147+ * @hidden @internal
148+ * Gets/Sets the 'display' property of the current pane.
105149 */
106150 @HostBinding ( 'style.display' )
107151 public display = 'flex' ;
108152
109- private _hidden = false ;
110-
111153 /**
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+ * ```
113159 */
114160 @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 ;
118168 }
119169
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 ;
122182 }
123183
124184 /**
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+ * ```
126190 */
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+ }
129197
130198 constructor ( private el : ElementRef ) { }
131199}
0 commit comments