Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type improvements #13069

Merged
merged 267 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
267 commits
Select commit Hold shift + click to select a range
4767e69
Merge branch 'types-misc' of https://github.com/primefaces/primeng in…
cetincakiroglu May 3, 2023
52a947b
Update types for card and accordion
gucal May 3, 2023
de7dc53
Merge branch 'types' of https://github.com/primefaces/primeng into types
gucal May 3, 2023
1102892
Merge pull request #12984 from primefaces/types-misc
cetincakiroglu May 3, 2023
6ecb483
Rename files
gucal May 3, 2023
4508b9f
Refactor panel
cetincakiroglu May 3, 2023
c199cc5
Divider | add types
cetincakiroglu May 3, 2023
9d2d788
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 3, 2023
74bfec4
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 3, 2023
c86d500
Refactor accordion model
gucal May 3, 2023
8dff8c6
Refactor Card model
gucal May 3, 2023
a537fb7
Fieldset | add types
cetincakiroglu May 3, 2023
81655cd
refactor
cetincakiroglu May 3, 2023
63bedd6
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 3, 2023
d4fce65
Update type for ScrollPanel
gucal May 3, 2023
c1d36d8
Update types for Toolbar
gucal May 3, 2023
07d0c60
Refactor type for Avatar
gucal May 4, 2023
f1d09c3
Splitter | Add types
cetincakiroglu May 4, 2023
e592aaa
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 4, 2023
ecbf92f
Code format
cetincakiroglu May 4, 2023
dde8c36
Refactor on Tabview and tsconfig.json
mertsincan May 5, 2023
cfb0108
rename file
cetincakiroglu May 5, 2023
cb61061
rename file
cetincakiroglu May 5, 2023
7d658a9
refactor event names
cetincakiroglu May 5, 2023
66460ed
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 5, 2023
b71b86c
Merge master and fix conflicts
cetincakiroglu May 8, 2023
1e72e5c
refactor
cetincakiroglu May 8, 2023
a92c2e2
refactor
cetincakiroglu May 8, 2023
49adf81
refactor fieldset
cetincakiroglu May 8, 2023
793925d
refactor divider
cetincakiroglu May 8, 2023
7b4c13e
refactor panel
cetincakiroglu May 8, 2023
3f76fcf
refactor panel
cetincakiroglu May 8, 2023
b5158e5
refactor fieldset
cetincakiroglu May 8, 2023
face701
Refactor types for panel components
gucal May 8, 2023
01fe4ff
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 8, 2023
d100e4f
refactor
cetincakiroglu May 8, 2023
6586e6b
Refactor types for MISC components
gucal May 8, 2023
ed2097a
Add types for inplace component
gucal May 8, 2023
f98d95e
refactor
cetincakiroglu May 8, 2023
c285ff5
Add types for scrolltop component
gucal May 8, 2023
38d469c
Add types for Progressbar - Prosressspinner - Skeleton components
gucal May 8, 2023
2089a62
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 8, 2023
b9f4526
Add types for BlockUI component
gucal May 8, 2023
e52067d
Tag | Add types
cetincakiroglu May 8, 2023
2ff6b01
Terminal | Add Types
cetincakiroglu May 8, 2023
1ca54f5
refactor
cetincakiroglu May 8, 2023
e377cfa
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 8, 2023
6082000
refactor
cetincakiroglu May 8, 2023
6efc656
add missing type
cetincakiroglu May 8, 2023
3cd5762
refactor inplace
cetincakiroglu May 8, 2023
e17f039
add typedoc package
cetincakiroglu May 8, 2023
8954471
add types
cetincakiroglu May 8, 2023
21dae94
Refactor type accordion
gucal May 8, 2023
95a46d1
Merge branch 'types' of https://github.com/primefaces/primeng into types
gucal May 8, 2023
bba4fe1
Refactor tpye for Card
gucal May 8, 2023
61a1b74
Refactor Scrollpanel
gucal May 8, 2023
315f72f
Refactor type for MISC components
gucal May 9, 2023
834e7f1
add ts-helpers
cetincakiroglu May 9, 2023
ecf4e3f
Refactor
cetincakiroglu May 9, 2023
69d3483
Add types for MISC components
gucal May 9, 2023
2f98109
Add types for image component
gucal May 10, 2023
2787d6a
Add types for galleria component
gucal May 10, 2023
b431ee3
Add types for Carousel component
gucal May 10, 2023
6b22693
Add output type for galleria
gucal May 10, 2023
6207033
Autocomplete | add types
cetincakiroglu May 10, 2023
099b017
Add types for message
gucal May 10, 2023
4fa2d7d
Add types for messages
gucal May 10, 2023
ad70dbe
Add types for toast
gucal May 10, 2023
da04184
Refactor type for messages
gucal May 10, 2023
d0fa446
Add types for dragdrop component
gucal May 10, 2023
f8f6358
Add types for breadcrumb component
gucal May 10, 2023
6594e5e
ADd types for button component
gucal May 10, 2023
1609053
Add types for splitbutton
gucal May 10, 2023
0b52adc
Add types for speeddial
gucal May 10, 2023
e61b7c8
Add type for fileupload component
gucal May 10, 2023
e68e8d4
Add types for dock component
gucal May 11, 2023
291a6b5
Calendar | Add types
cetincakiroglu May 11, 2023
9491a8c
Add types for menubar
gucal May 11, 2023
5bc3e44
Add types for megamenu
gucal May 11, 2023
7467c0f
Calendar | refactor types
cetincakiroglu May 11, 2023
650d558
Autocomplete | Add interface.ts
cetincakiroglu May 11, 2023
a19f5ba
refactor
cetincakiroglu May 11, 2023
a13427c
Add types for panelmenu component
gucal May 11, 2023
e8734e9
CascadeSelect | Add types
cetincakiroglu May 11, 2023
619c52b
Checkbox | Add types
cetincakiroglu May 11, 2023
8bb1eb6
Chips | Add types
cetincakiroglu May 11, 2023
10112a7
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 11, 2023
88a35e3
Add types for slidemenu
gucal May 11, 2023
167f69e
Add types for Steps
gucal May 11, 2023
b6adad0
Merge branch 'types' of https://github.com/primefaces/primeng into types
gucal May 11, 2023
1f1fdc2
Add types for tabmenu
gucal May 11, 2023
1095fd1
ColorPicker | Add types
cetincakiroglu May 11, 2023
74db7b2
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 11, 2023
8e9e798
Editor | Add types
cetincakiroglu May 11, 2023
01d6b94
fix typo
cetincakiroglu May 11, 2023
827dda2
InputSwitch | Add types
cetincakiroglu May 11, 2023
5bc0dea
InputtextArea | add types
cetincakiroglu May 11, 2023
bd5bb04
RadioButton | Add types
cetincakiroglu May 11, 2023
e5dfdcf
RadioButton | Add types
cetincakiroglu May 11, 2023
e2a4cff
Add types for tieredmenu component
gucal May 12, 2023
0034643
Rating | Add types
cetincakiroglu May 12, 2023
6c519af
SelectButton | Add types
cetincakiroglu May 12, 2023
529b7e6
Slider | Add types
cetincakiroglu May 12, 2023
146d4d4
add missing property
cetincakiroglu May 12, 2023
d206951
add template interface
cetincakiroglu May 12, 2023
2597c34
ToggleButton | Add types
cetincakiroglu May 12, 2023
1d6cc4e
TriStateCheckbox | Add types
cetincakiroglu May 12, 2023
8ef25d7
Knob | Add types
cetincakiroglu May 12, 2023
caa6982
refactor
cetincakiroglu May 12, 2023
9aa71f1
Password | Add types
cetincakiroglu May 12, 2023
20821da
KeyFilter | Add types
cetincakiroglu May 12, 2023
8e9832a
Listbox | Add types
cetincakiroglu May 12, 2023
6bf309a
refactor
cetincakiroglu May 12, 2023
3192ea2
InputMask | Add types
cetincakiroglu May 13, 2023
209aa0e
InputNumber | Add types
cetincakiroglu May 13, 2023
f38992f
TreeSelect | Add Types
cetincakiroglu May 13, 2023
b9d2dd9
fix typo
cetincakiroglu May 13, 2023
ae7c42f
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 13, 2023
a674c81
refactor
cetincakiroglu May 14, 2023
df02bee
Dropdown | Add types
cetincakiroglu May 14, 2023
28e4e21
MultiSelect | Add types
cetincakiroglu May 14, 2023
44e56b8
refactor
cetincakiroglu May 14, 2023
e472aef
OrderList | Add types
cetincakiroglu May 14, 2023
bc696d9
OrganizationChart | Add Types
cetincakiroglu May 14, 2023
571eacd
refactor
cetincakiroglu May 14, 2023
bb28f2a
DataView | Add types
cetincakiroglu May 14, 2023
bdd1aac
refactor
cetincakiroglu May 14, 2023
03249fe
Timeline | Add Types
cetincakiroglu May 14, 2023
8ee8a23
Paginator | Add types
cetincakiroglu May 14, 2023
19662ce
refactor
cetincakiroglu May 14, 2023
c4ba651
VirtualScroller | Add types
cetincakiroglu May 14, 2023
deb5fd8
refactor
cetincakiroglu May 14, 2023
af2cdb7
Tree | Add types
cetincakiroglu May 15, 2023
56b2770
PickList | Add types
cetincakiroglu May 15, 2023
e8a9ba2
Scroller | Add Types
cetincakiroglu May 15, 2023
62dc308
refactor
cetincakiroglu May 15, 2023
8f057c9
refactor
cetincakiroglu May 15, 2023
4bdc2d8
TreeTable | Add types
cetincakiroglu May 16, 2023
c7b6252
refactor
cetincakiroglu May 16, 2023
3716b74
refactor
cetincakiroglu May 16, 2023
a11a8e8
fix import path
cetincakiroglu May 16, 2023
d0f8ed8
TreeTable | Add missing interfaces and descriptions
cetincakiroglu May 17, 2023
0fbf654
Types | FilterService
gucal May 17, 2023
107acfd
Types | Overlay
gucal May 17, 2023
4301af2
Types | ConfirmDialog
gucal May 17, 2023
526c8ec
Types | ConfirmPopup
gucal May 17, 2023
2c5822d
Types | Dialog
gucal May 17, 2023
d89ea51
Types | OverlayPanel
gucal May 17, 2023
2251258
Types | Sidebar
gucal May 17, 2023
35d80b2
Types | DynamicDialog
gucal May 17, 2023
0bb742a
Types | Tooltip
gucal May 17, 2023
ac5f2e7
Types | ContextMenu
gucal May 17, 2023
f3adac5
Table | Add Types
cetincakiroglu May 17, 2023
e566f5d
refactor
cetincakiroglu May 17, 2023
1d6e50f
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 17, 2023
76d7152
Code format
cetincakiroglu May 17, 2023
0583797
refactor
cetincakiroglu May 17, 2023
4d7b6b1
Refactor
gucal May 17, 2023
267fa5d
Add param for overlay section
gucal May 18, 2023
1047c89
Fix import paths
cetincakiroglu May 18, 2023
e0dd293
Autocomplete | Refactor
cetincakiroglu May 18, 2023
2f1f91e
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 18, 2023
003d88e
Calendar | Refactor types
cetincakiroglu May 18, 2023
290ec64
CascadeSelect | Refactor
cetincakiroglu May 18, 2023
154a141
add import
cetincakiroglu May 18, 2023
a9272b3
Checkbox | Refactor
cetincakiroglu May 18, 2023
19d8c10
Remove @event tag
cetincakiroglu May 18, 2023
090241b
add missing import
cetincakiroglu May 18, 2023
7f55f85
refactor
cetincakiroglu May 18, 2023
ed6b6cd
Add missing import
cetincakiroglu May 18, 2023
21f4308
refactor
cetincakiroglu May 18, 2023
beef998
Editor | refactor
cetincakiroglu May 18, 2023
926010a
add missing import
cetincakiroglu May 18, 2023
142dfc8
Inputmask | add missing description
cetincakiroglu May 18, 2023
c5f0e84
InputSwitch | add missing import
cetincakiroglu May 18, 2023
62e43d2
Refactor
cetincakiroglu May 18, 2023
7f3221f
add missing import
cetincakiroglu May 18, 2023
0fcd635
add missing import
cetincakiroglu May 18, 2023
e4301f8
refactor
cetincakiroglu May 18, 2023
a43e000
add missing import
cetincakiroglu May 18, 2023
7923ce4
Rating | Add missing interface
cetincakiroglu May 18, 2023
ed08bd6
Add missing import
cetincakiroglu May 18, 2023
542fc0b
add missing import
cetincakiroglu May 18, 2023
8a5ecb8
add missing import
cetincakiroglu May 18, 2023
387a72b
add missing import
cetincakiroglu May 18, 2023
073df18
add missing import
cetincakiroglu May 18, 2023
4f7b2d8
refactor
cetincakiroglu May 18, 2023
a406196
Refactor
cetincakiroglu May 18, 2023
6ee87d5
refactor
cetincakiroglu May 18, 2023
4177293
PickList | Refactor
cetincakiroglu May 18, 2023
52e6cce
TreeTable | add missing import
cetincakiroglu May 18, 2023
863c6a0
Refactor
cetincakiroglu May 18, 2023
f006364
refactor
cetincakiroglu May 18, 2023
d362e8e
refactor
cetincakiroglu May 18, 2023
571dcb3
refactor badge
cetincakiroglu May 18, 2023
13081cb
refactor
cetincakiroglu May 18, 2023
8bf56ac
add event descriptions
cetincakiroglu May 18, 2023
b38e389
add event descriptions
cetincakiroglu May 18, 2023
9972188
add paramaters
cetincakiroglu May 18, 2023
aaa3140
add event description
cetincakiroglu May 18, 2023
65d2c9a
refactor
cetincakiroglu May 18, 2023
96601f7
add event params
cetincakiroglu May 18, 2023
9f4198d
refactor
cetincakiroglu May 18, 2023
3c8c9c7
refactor
cetincakiroglu May 18, 2023
e54f853
refactor
cetincakiroglu May 18, 2023
74e4576
refactor
cetincakiroglu May 18, 2023
fe006b8
refactor
cetincakiroglu May 18, 2023
825740f
refactor toast
cetincakiroglu May 18, 2023
2ef209d
add description
cetincakiroglu May 18, 2023
849edc4
refactor
cetincakiroglu May 18, 2023
ae238aa
Refactor
cetincakiroglu May 18, 2023
8620a5f
refactor
cetincakiroglu May 18, 2023
4379013
refactor menu section
cetincakiroglu May 18, 2023
7533a62
refactor
cetincakiroglu May 18, 2023
c82d460
refactor
cetincakiroglu May 18, 2023
9e51248
refactor
cetincakiroglu May 18, 2023
39eb921
refactor
cetincakiroglu May 18, 2023
25d6155
refactor
cetincakiroglu May 18, 2023
1a69777
Menu | Add types
cetincakiroglu May 18, 2023
790770c
code format
cetincakiroglu May 18, 2023
db3f7d9
refactor
gucal May 18, 2023
3214aae
Merge branch 'types' of https://github.com/primefaces/primeng into types
gucal May 18, 2023
0effbad
add types
cetincakiroglu May 18, 2023
6a70817
refactor
cetincakiroglu May 18, 2023
9956674
refactor
cetincakiroglu May 18, 2023
0e2a2b7
export types
cetincakiroglu May 18, 2023
0a2bd7e
Export types
cetincakiroglu May 18, 2023
4330e6d
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 18, 2023
ead1c34
Add types for API
gucal May 18, 2023
7a43348
Refactor
gucal May 18, 2023
ccdd07d
Refactor
gucal May 18, 2023
2b66a61
Fix type error
cetincakiroglu May 19, 2023
ad384ad
Fix mask close
gucal May 19, 2023
ce917f0
Fix loading glitch
cetincakiroglu May 19, 2023
82fb999
Add description for MenuItem API
gucal May 19, 2023
76f323d
fix test error
cetincakiroglu May 19, 2023
50c9854
fix test errors and code refactor
cetincakiroglu May 19, 2023
b626295
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 19, 2023
3ff82d8
Code format
cetincakiroglu May 19, 2023
b2732be
export ts-helpers
cetincakiroglu May 19, 2023
28f8061
move ts-helpers
cetincakiroglu May 19, 2023
4142c80
Add description for api interfaces
gucal May 19, 2023
6f4a6c0
Fix import paths
cetincakiroglu May 19, 2023
a345811
Fix build errors
cetincakiroglu May 19, 2023
0ce5eeb
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 19, 2023
0289a3b
fix build errors
cetincakiroglu May 19, 2023
f914162
revert tsconfig
cetincakiroglu May 19, 2023
b2a22fa
Merge branch 'master' into types
cetincakiroglu May 19, 2023
a5881b0
Merge branch 'types' of https://github.com/primefaces/primeng into types
cetincakiroglu May 19, 2023
bacf237
fix typo
cetincakiroglu May 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
490 changes: 490 additions & 0 deletions api-generator/build-apidoc.ts

Large diffs are not rendered by default.

1,405 changes: 1,405 additions & 0 deletions api-generator/typedoc.json

Large diffs are not rendered by default.

1,686 changes: 892 additions & 794 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"serve:ssr": "node dist/primeng/server/main.js",
"build:ssr": "ng build --configuration=production && ng run primeng:server",
"prerender": "ng run primeng:prerender",
"vercel-build": "npm run build:ssr"
"vercel-build": "npm run build:ssr",
"apidoc": "node ./api-generator/build-apidoc.ts"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -85,6 +86,7 @@
"rxjs": "~7.8.1",
"ts-node": "~8.3.0",
"tslib": "^2.5.0",
"typedoc": "0.24.7",
"typescript": "5.0.4",
"xlsx": "^0.18.5",
"zone.js": "~0.13.0"
Expand Down
47 changes: 47 additions & 0 deletions src/app/components/accordion/accordion.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { TemplateRef } from '@angular/core';

/**
* Custom tab open event.
* @see {@link Accordion.onOpen}
*/
export interface AccordionTabOpenEvent {
/**
* Browser event.
*/
originalEvent: Event;
/**
* Opened tab index.
*/
index: number;
}

/**
* Custom tab close event.
* @see {@link Accordion.onClose}
* @extends {AccordionTabOpenEvent}
*/
export interface AccordionTabCloseEvent extends AccordionTabOpenEvent {}

/**
* Defines valid templates in Accordion.
* @group Templates
*/
export interface AccordionTemplates {
/**
* Custom template of content.
*/
content: TemplateRef<any> | null;
/**
* Custom template of header.
*/
header: TemplateRef<any> | null;
/**
* Custom template of icon.
*/
icon(context: {
/**
* Data of the selected.
*/
$implicit: any;
}): TemplateRef<{ $implicit: any }>;
}
224 changes: 147 additions & 77 deletions src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import { CommonModule } from '@angular/common';
import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, ElementRef, EventEmitter, forwardRef, Inject, Input, NgModule, OnDestroy, Output, QueryList, TemplateRef, ViewEncapsulation } from '@angular/core';
import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, ElementRef, EventEmitter, Inject, Input, NgModule, OnDestroy, Output, QueryList, TemplateRef, ViewEncapsulation, forwardRef } from '@angular/core';
import { BlockableUI, Header, PrimeTemplate, SharedModule } from 'primeng/api';
import { Subscription } from 'rxjs';
import { ChevronRightIcon } from 'primeng/icons/chevronright';
import { ChevronDownIcon } from 'primeng/icons/chevrondown';
import { ChevronRightIcon } from 'primeng/icons/chevronright';
import { Subscription } from 'rxjs';
import { AccordionTabCloseEvent, AccordionTabOpenEvent } from './accordion.interface';

let idx: number = 0;

Expand Down Expand Up @@ -86,41 +87,82 @@ let idx: number = 0;
}
})
export class AccordionTab implements AfterContentInit, OnDestroy {
@Input() header: string;

@Input() headerStyle: any;

@Input() tabStyle: any;

@Input() contentStyle: any;

@Input() tabStyleClass: string;

@Input() headerStyleClass: string;

@Input() contentStyleClass: string;

@Input() disabled: boolean;

/**
* Used to define the header of the tab.
* @group Props
*/
@Input() header: string | undefined;
/**
* Inline style of the tab header.
* @group Props
*/
@Input() headerStyle: { [klass: string]: any } | null | undefined;
/**
* Inline style of the tab.
* @group Props
*/
@Input() tabStyle: { [klass: string]: any } | null | undefined;
/**
* Inline style of the tab content.
* @group Props
*/
@Input() contentStyle: { [klass: string]: any } | null | undefined;
/**
* Style class of the tab.
* @group Props
*/
@Input() tabStyleClass: string | undefined;
/**
* Style class of the tab header.
* @group Props
*/
@Input() headerStyleClass: string | undefined;
/**
* Style class of the tab content.
* @group Props
*/
@Input() contentStyleClass: string | undefined;
/**
* Whether the tab is disabled.
* @group Props
*/
@Input() disabled: boolean | undefined;
/**
* Whether a lazy loaded panel should avoid getting loaded again on reselection.
* @group Props
*/
@Input() cache: boolean = true;

@Output() selectedChange: EventEmitter<any> = new EventEmitter();

/**
* Transition options of the animation.
* @group Props
*/
@Input() transitionOptions: string = '400ms cubic-bezier(0.86, 0, 0.07, 1)';

/**
* Position of the icon, valid values are "end", "start".
* @group Props
*/
@Input() iconPos: string = 'start';
/**
* Event triggered by changing the choice
* @group Emits
*/
@Output() selectedChange: EventEmitter<boolean> = new EventEmitter();

@ContentChildren(Header) headerFacet: QueryList<Header>;
@ContentChildren(Header) headerFacet!: QueryList<Header>;

@ContentChildren(PrimeTemplate) templates: QueryList<any>;
@ContentChildren(PrimeTemplate) templates!: QueryList<PrimeTemplate>;

private _selected: boolean;
private _selected: boolean = false;

@Input() get selected(): any {
/**
* The value that returns the selection.
* @group Props
*/
@Input() get selected(): boolean {
return this._selected;
}

set selected(val: any) {
set selected(val: boolean) {
this._selected = val;

if (!this.loaded) {
Expand All @@ -140,19 +182,19 @@ export class AccordionTab implements AfterContentInit, OnDestroy {
}
}

contentTemplate: TemplateRef<any>;
contentTemplate: TemplateRef<any> | undefined;

headerTemplate: TemplateRef<any>;
headerTemplate: TemplateRef<any> | undefined;

id: string = `p-accordiontab-${idx++}`;
iconTemplate: TemplateRef<any> | undefined;

loaded: boolean;
id: string = `p-accordiontab-${idx++}`;

iconTemplate: TemplateRef<any>;
loaded: boolean = false;

accordion: Accordion;

constructor(@Inject(forwardRef(() => Accordion)) accordion, public changeDetector: ChangeDetectorRef) {
constructor(@Inject(forwardRef(() => Accordion)) accordion: Accordion, public changeDetector: ChangeDetectorRef) {
this.accordion = accordion as Accordion;
}

Expand All @@ -178,7 +220,7 @@ export class AccordionTab implements AfterContentInit, OnDestroy {
});
}

toggle(event) {
toggle(event: MouseEvent | KeyboardEvent) {
if (this.disabled) {
return false;
}
Expand Down Expand Up @@ -223,7 +265,7 @@ export class AccordionTab implements AfterContentInit, OnDestroy {
}

get hasHeaderFacet(): boolean {
return this.headerFacet && this.headerFacet.length > 0;
return (this.headerFacet as QueryList<Header>) && (this.headerFacet as QueryList<Header>).length > 0;
}

onKeydown(event: KeyboardEvent) {
Expand Down Expand Up @@ -251,29 +293,71 @@ export class AccordionTab implements AfterContentInit, OnDestroy {
}
})
export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
@Input() multiple: boolean;

@Output() onClose: EventEmitter<any> = new EventEmitter();

@Output() onOpen: EventEmitter<any> = new EventEmitter();

@Input() style: any;

@Input() styleClass: string;

@Input() expandIcon: string;

@Input() collapseIcon: string;

@Output() activeIndexChange: EventEmitter<any> = new EventEmitter();

@ContentChildren(AccordionTab) tabList: QueryList<AccordionTab>;

tabListSubscription: Subscription;
/**
* When enabled, multiple tabs can be activated at the same time.
* @group Props
*/
@Input() multiple: boolean = false;
/**
* Inline style of the tab header and content.
* @group Props
*/
@Input() style: { [klass: string]: any } | null | undefined;
/**
* Class of the element.
* @group Props
*/
@Input() styleClass: string | undefined;
/**
* Icon of a collapsed tab.
* @group Props
*/
@Input() expandIcon: string | undefined;
/**
* Icon of an expanded tab.
* @group Props
*/
@Input() collapseIcon: string | undefined;
/**
* Index of the active tab or an array of indexes in multiple mode.
* @group Props
*/
@Input() get activeIndex(): number | number[] | null | undefined {
return this._activeIndex;
}

private _activeIndex: any;
set activeIndex(val: number | number[] | null | undefined) {
this._activeIndex = val;
if (this.preventActiveIndexPropagation) {
this.preventActiveIndexPropagation = false;
return;
}

preventActiveIndexPropagation: boolean;
this.updateSelectionState();
}
/**
* Callback to invoke when an active tab is collapsed by clicking on the header.
* @group Emits
*/
@Output() onClose: EventEmitter<AccordionTabCloseEvent> = new EventEmitter();
/**
* Callback to invoke when a tab gets expanded.
* @group Emits
*/
@Output() onOpen: EventEmitter<AccordionTabOpenEvent> = new EventEmitter();
/**
* Returns the active index.
* @group Emits
*/
@Output() activeIndexChange: EventEmitter<number | number[] | null> = new EventEmitter();

@ContentChildren(AccordionTab) tabList: QueryList<AccordionTab> | undefined;

tabListSubscription: Subscription | null = null;

private _activeIndex: number | number[] | null | undefined;

preventActiveIndexPropagation: boolean = false;

public tabs: AccordionTab[] = [];

Expand All @@ -282,13 +366,13 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
ngAfterContentInit() {
this.initTabs();

this.tabListSubscription = this.tabList.changes.subscribe((_) => {
this.tabListSubscription = (this.tabList as QueryList<AccordionTab>).changes.subscribe((_) => {
this.initTabs();
});
}

initTabs(): any {
this.tabs = this.tabList.toArray();
initTabs() {
this.tabs = (this.tabList as QueryList<AccordionTab>).toArray();
this.updateSelectionState();
this.changeDetector.markForCheck();
}
Expand All @@ -297,24 +381,10 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
return this.el.nativeElement.children[0];
}

@Input() get activeIndex(): any {
return this._activeIndex;
}

set activeIndex(val: any) {
this._activeIndex = val;
if (this.preventActiveIndexPropagation) {
this.preventActiveIndexPropagation = false;
return;
}

this.updateSelectionState();
}

updateSelectionState() {
if (this.tabs && this.tabs.length && this._activeIndex != null) {
for (let i = 0; i < this.tabs.length; i++) {
let selected = this.multiple ? this._activeIndex.includes(i) : i === this._activeIndex;
let selected = this.multiple ? (this._activeIndex as number[]).includes(i) : i === this._activeIndex;
let changed = selected !== this.tabs[i].selected;

if (changed) {
Expand All @@ -327,11 +397,11 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
}

updateActiveIndex() {
let index: any = this.multiple ? [] : null;
let index: number | number[] | null = this.multiple ? [] : null;
this.tabs.forEach((tab, i) => {
if (tab.selected) {
if (this.multiple) {
index.push(i);
(index as number[]).push(i);
} else {
index = i;
return;
Expand Down
1 change: 1 addition & 0 deletions src/app/components/accordion/public_api.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './accordion';
export * from './accordion.interface';
Loading