Skip to content

Commit 9cd3ef0

Browse files
authored
Merge pull request #653 from dxc-technology/gomezivann-accordionGroup-types
Types for Accordion Group
2 parents fdefdb4 + 3ed93c0 commit 9cd3ef0

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

projects/dxc-ngx-cdk-site/src/app/components/examples/accordion-group/properties/accordion-group-table-properties/accordion-group-table-properties.component.html

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
<td>If true, the component will be disabled.</td>
2727
</tr>
2828
<tr>
29-
<td>onActiveChange: function</td>
29+
<td>onActiveChange: EventEmitter</td>
3030
<td></td>
3131
<td>
32-
This function will be called when the user clicks on an accordion. The
33-
index of the clicked accordion will be passed as a parameter.
32+
This event will emit in case the user clicks on an accordion. The index of
33+
the clicked accordion will be passed as a parameter.
3434
</td>
3535
</tr>
3636
<tr>
@@ -85,13 +85,6 @@
8585
label.
8686
</td>
8787
</tr>
88-
<tr>
89-
<td>iconPosition: 'before' | 'after'</td>
90-
<td>
91-
<code>'before'</code>
92-
</td>
93-
<td>Whether the icon should appear after or before the label.</td>
94-
</tr>
9588
<tr>
9689
<td>assistiveText: string</td>
9790
<td></td>

projects/dxc-ngx-cdk/src/lib/dxc-accordionGroup/dxc-accordionGroup.component.ts

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,49 @@ import {
2323
coerceBooleanProperty,
2424
} from "@angular/cdk/coercion";
2525

26+
type Space =
27+
| "xxsmall"
28+
| "xsmall"
29+
| "small"
30+
| "medium"
31+
| "large"
32+
| "xlarge"
33+
| "xxlarge";
34+
35+
type Margin = {
36+
top?: Space;
37+
bottom?: Space;
38+
left?: Space;
39+
right?: Space;
40+
};
41+
2642
@Component({
2743
selector: "dxc-accordion-group",
2844
templateUrl: "./dxc-accordionGroup.component.html",
2945
providers: [CssUtils, AccordionService],
3046
})
3147
export class DxcAccordionGroupComponent implements OnChanges, OnInit {
32-
@Input() margin: any;
48+
/**
49+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
50+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
51+
*/
52+
@Input() margin: Space | Margin;
53+
/**
54+
* The index of the active accordion. If undefined, the component will be uncontrolled and the active accordion will be managed internally by the component.
55+
* If null, the component will be controlled and all accordions will be closed.
56+
*/
3357
@Input()
34-
get indexActive(): any {
58+
get indexActive(): number {
3559
return this._indexActive;
3660
}
37-
set indexActive(value: any) {
38-
if (value === undefined || value === "undefined") {
39-
this._indexActive = undefined;
40-
} else if (value === null || value === "null") {
41-
this._indexActive = null;
42-
} else {
43-
this._indexActive = coerceNumberProperty(value);
44-
}
61+
set indexActive(value: number) {
62+
if (value == null) this._indexActive = value;
63+
else this._indexActive = coerceNumberProperty(value);
4564
}
4665
private _indexActive;
66+
/**
67+
* If true, the component will be disabled.
68+
*/
4769
@Input()
4870
get disabled(): boolean {
4971
return this._disabled;
@@ -52,10 +74,17 @@ export class DxcAccordionGroupComponent implements OnChanges, OnInit {
5274
this._disabled = coerceBooleanProperty(value);
5375
}
5476
private _disabled = false;
55-
@Output() onActiveChange = new EventEmitter<any>();
77+
/**
78+
* This event will emit in case the user clicks on an accordion.
79+
* The index of the clicked accordion will be passed as a parameter.
80+
*/
81+
@Output() onActiveChange: EventEmitter<number> = new EventEmitter<number>();
5682

5783
@HostBinding("class") className;
5884

85+
/**
86+
* Customized accordion that allows this accordion group component. Accordion component can be checked here.
87+
*/
5988
@ContentChildren(DxcAccordionComponent)
6089
dxcAccordion: QueryList<DxcAccordionComponent>;
6190

0 commit comments

Comments
 (0)