@syncfusion/ej2-navigations 31.1.17 → 31.1.18
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/dist/ej2-navigations.min.js +1 -1
- package/dist/ej2-navigations.umd.min.js +1 -1
- package/dist/global/ej2-navigations.min.js +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +11 -64
- package/styles/bds-lite.css +2 -1
- package/styles/bds.css +2 -1
- package/styles/bootstrap-dark-lite.css +2 -1
- package/styles/bootstrap-dark.css +2 -1
- package/styles/bootstrap-lite.css +2 -1
- package/styles/bootstrap.css +2 -1
- package/styles/bootstrap4-lite.css +2 -1
- package/styles/bootstrap4.css +2 -1
- package/styles/bootstrap5-dark-lite.css +2 -1
- package/styles/bootstrap5-dark.css +2 -1
- package/styles/bootstrap5-lite.css +2 -1
- package/styles/bootstrap5.3-lite.css +2 -1
- package/styles/bootstrap5.3.css +2 -1
- package/styles/bootstrap5.css +2 -1
- package/styles/fabric-dark-lite.css +2 -1
- package/styles/fabric-dark.css +2 -1
- package/styles/fabric-lite.css +2 -1
- package/styles/fabric.css +2 -1
- package/styles/fluent-dark-lite.css +3 -2
- package/styles/fluent-dark.css +3 -2
- package/styles/fluent-lite.css +3 -2
- package/styles/fluent.css +3 -2
- package/styles/fluent2-lite.css +3 -2
- package/styles/fluent2.css +3 -2
- package/styles/highcontrast-light-lite.css +2 -1
- package/styles/highcontrast-light.css +2 -1
- package/styles/highcontrast-lite.css +2 -1
- package/styles/highcontrast.css +2 -1
- package/styles/material-dark-lite.css +2 -1
- package/styles/material-dark.css +2 -1
- package/styles/material-lite.css +2 -1
- package/styles/material.css +2 -1
- package/styles/material3-dark-lite.css +3 -2
- package/styles/material3-dark.css +3 -2
- package/styles/material3-lite.css +3 -2
- package/styles/material3.css +3 -2
- package/styles/menu/_bootstrap-dark-definition.scss +1 -0
- package/styles/menu/_bootstrap-definition.scss +1 -0
- package/styles/menu/_fluent-definition.scss +1 -1
- package/styles/menu/_fluent2-definition.scss +1 -1
- package/styles/menu/_layout.scss +7 -1
- package/styles/menu/_material3-definition.scss +1 -1
- package/styles/menu/bds.css +1 -0
- package/styles/menu/bootstrap-dark.css +1 -0
- package/styles/menu/bootstrap.css +1 -0
- package/styles/menu/bootstrap4.css +1 -0
- package/styles/menu/bootstrap5-dark.css +1 -0
- package/styles/menu/bootstrap5.3.css +1 -0
- package/styles/menu/bootstrap5.css +1 -0
- package/styles/menu/fabric-dark.css +1 -0
- package/styles/menu/fabric.css +1 -0
- package/styles/menu/fluent-dark.css +2 -1
- package/styles/menu/fluent.css +2 -1
- package/styles/menu/fluent2.css +2 -1
- package/styles/menu/highcontrast-light.css +1 -0
- package/styles/menu/highcontrast.css +1 -0
- package/styles/menu/material-dark.css +1 -0
- package/styles/menu/material.css +1 -0
- package/styles/menu/material3-dark.css +2 -1
- package/styles/menu/material3.css +2 -1
- package/styles/menu/tailwind-dark.css +1 -0
- package/styles/menu/tailwind.css +1 -0
- package/styles/menu/tailwind3.css +1 -0
- package/styles/tailwind-dark-lite.css +2 -1
- package/styles/tailwind-dark.css +2 -1
- package/styles/tailwind-lite.css +2 -1
- package/styles/tailwind.css +2 -1
- package/styles/tailwind3-lite.css +2 -1
- package/styles/tailwind3.css +2 -1
- package/styles/treeview/_layout.scss +1 -1
- package/styles/treeview/bds.css +1 -1
- package/styles/treeview/bootstrap-dark.css +1 -1
- package/styles/treeview/bootstrap.css +1 -1
- package/styles/treeview/bootstrap4.css +1 -1
- package/styles/treeview/bootstrap5-dark.css +1 -1
- package/styles/treeview/bootstrap5.3.css +1 -1
- package/styles/treeview/bootstrap5.css +1 -1
- package/styles/treeview/fabric-dark.css +1 -1
- package/styles/treeview/fabric.css +1 -1
- package/styles/treeview/fluent-dark.css +1 -1
- package/styles/treeview/fluent.css +1 -1
- package/styles/treeview/fluent2.css +1 -1
- package/styles/treeview/highcontrast-light.css +1 -1
- package/styles/treeview/highcontrast.css +1 -1
- package/styles/treeview/material-dark.css +1 -1
- package/styles/treeview/material.css +1 -1
- package/styles/treeview/material3-dark.css +1 -1
- package/styles/treeview/material3.css +1 -1
- package/styles/treeview/tailwind-dark.css +1 -1
- package/styles/treeview/tailwind.css +1 -1
- package/styles/treeview/tailwind3.css +1 -1
- package/dist/ts/accordion/accordion-model.d.ts +0 -285
- package/dist/ts/accordion/accordion.d.ts +0 -458
- package/dist/ts/accordion/accordion.ts +0 -1580
- package/dist/ts/accordion/index.d.ts +0 -5
- package/dist/ts/accordion/index.ts +0 -5
- package/dist/ts/appbar/appbar-model.d.ts +0 -76
- package/dist/ts/appbar/appbar.d.ts +0 -115
- package/dist/ts/appbar/appbar.ts +0 -281
- package/dist/ts/appbar/index.d.ts +0 -3
- package/dist/ts/appbar/index.ts +0 -3
- package/dist/ts/breadcrumb/breadcrumb-model.d.ts +0 -170
- package/dist/ts/breadcrumb/breadcrumb.d.ts +0 -297
- package/dist/ts/breadcrumb/breadcrumb.ts +0 -959
- package/dist/ts/breadcrumb/index.d.ts +0 -5
- package/dist/ts/breadcrumb/index.ts +0 -5
- package/dist/ts/carousel/carousel-model.d.ts +0 -282
- package/dist/ts/carousel/carousel.d.ts +0 -439
- package/dist/ts/carousel/carousel.ts +0 -1633
- package/dist/ts/carousel/index.d.ts +0 -3
- package/dist/ts/carousel/index.ts +0 -3
- package/dist/ts/common/h-scroll-model.d.ts +0 -16
- package/dist/ts/common/h-scroll.d.ts +0 -105
- package/dist/ts/common/h-scroll.ts +0 -481
- package/dist/ts/common/index.d.ts +0 -9
- package/dist/ts/common/index.ts +0 -10
- package/dist/ts/common/menu-base-model.d.ts +0 -308
- package/dist/ts/common/menu-base.d.ts +0 -558
- package/dist/ts/common/menu-base.ts +0 -2736
- package/dist/ts/common/menu-scroll.d.ts +0 -29
- package/dist/ts/common/menu-scroll.ts +0 -105
- package/dist/ts/common/v-scroll-model.d.ts +0 -16
- package/dist/ts/common/v-scroll.d.ts +0 -106
- package/dist/ts/common/v-scroll.ts +0 -454
- package/dist/ts/context-menu/context-menu-model.d.ts +0 -47
- package/dist/ts/context-menu/context-menu.d.ts +0 -102
- package/dist/ts/context-menu/context-menu.ts +0 -165
- package/dist/ts/context-menu/index.d.ts +0 -5
- package/dist/ts/context-menu/index.ts +0 -5
- package/dist/ts/index.d.ts +0 -16
- package/dist/ts/index.ts +0 -16
- package/dist/ts/menu/index.d.ts +0 -5
- package/dist/ts/menu/index.ts +0 -5
- package/dist/ts/menu/menu-model.d.ts +0 -70
- package/dist/ts/menu/menu.d.ts +0 -127
- package/dist/ts/menu/menu.ts +0 -313
- package/dist/ts/sidebar/index.d.ts +0 -5
- package/dist/ts/sidebar/index.ts +0 -5
- package/dist/ts/sidebar/sidebar-model.d.ts +0 -200
- package/dist/ts/sidebar/sidebar.d.ts +0 -336
- package/dist/ts/sidebar/sidebar.ts +0 -907
- package/dist/ts/stepper/index.d.ts +0 -3
- package/dist/ts/stepper/index.ts +0 -3
- package/dist/ts/stepper/stepper-model.d.ts +0 -159
- package/dist/ts/stepper/stepper.d.ts +0 -381
- package/dist/ts/stepper/stepper.ts +0 -1350
- package/dist/ts/stepper-base/index.d.ts +0 -5
- package/dist/ts/stepper-base/index.ts +0 -6
- package/dist/ts/stepper-base/stepper-base-model.d.ts +0 -124
- package/dist/ts/stepper-base/stepper-base.d.ts +0 -187
- package/dist/ts/stepper-base/stepper-base.ts +0 -290
- package/dist/ts/tab/index.d.ts +0 -5
- package/dist/ts/tab/index.ts +0 -5
- package/dist/ts/tab/tab-model.d.ts +0 -408
- package/dist/ts/tab/tab.d.ts +0 -715
- package/dist/ts/tab/tab.ts +0 -2842
- package/dist/ts/toolbar/index.d.ts +0 -5
- package/dist/ts/toolbar/index.ts +0 -5
- package/dist/ts/toolbar/toolbar-model.d.ts +0 -294
- package/dist/ts/toolbar/toolbar.d.ts +0 -541
- package/dist/ts/toolbar/toolbar.ts +0 -2646
- package/dist/ts/treeview/index.d.ts +0 -5
- package/dist/ts/treeview/index.ts +0 -5
- package/dist/ts/treeview/treeview-model.d.ts +0 -637
- package/dist/ts/treeview/treeview.d.ts +0 -1518
- package/dist/ts/treeview/treeview.ts +0 -6780
|
@@ -1,1580 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Component, EventHandler, Property, Event, EmitType, AnimationModel, KeyboardEvents, rippleEffect, animationMode } from '@syncfusion/ej2-base';
|
|
3
|
-
import { KeyboardEventArgs, BaseEventArgs, Effect, getUniqueID, compile as templateCompiler } from '@syncfusion/ej2-base';
|
|
4
|
-
import { isVisible, closest, attributes, detach, select, addClass, removeClass, append } from '@syncfusion/ej2-base';
|
|
5
|
-
import { INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, Collection, Animation } from '@syncfusion/ej2-base';
|
|
6
|
-
import { setStyleAttribute as setStyle, Complex } from '@syncfusion/ej2-base';
|
|
7
|
-
import { isNullOrUndefined as isNOU, formatUnit, selectAll, SanitizeHtmlHelper, isRippleEnabled } from '@syncfusion/ej2-base';
|
|
8
|
-
import { AccordionModel, AccordionItemModel, AccordionAnimationSettingsModel, AccordionActionSettingsModel } from './accordion-model';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Specifies the option to expand single or multiple panel at a time.
|
|
12
|
-
* ```props
|
|
13
|
-
* Single :- Only one Accordion item can be expanded at a time.
|
|
14
|
-
* Multiple :- Multiple Accordion items can be expanded simultaneously.
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export type ExpandMode = 'Single' | 'Multiple';
|
|
18
|
-
|
|
19
|
-
type HTEle = HTMLElement;
|
|
20
|
-
type Str = string;
|
|
21
|
-
|
|
22
|
-
const CLS_ACRDN_ROOT: Str = 'e-acrdn-root';
|
|
23
|
-
const CLS_ROOT: Str = 'e-accordion';
|
|
24
|
-
const CLS_ITEM: Str = 'e-acrdn-item';
|
|
25
|
-
const CLS_ITEMFOCUS: Str = 'e-item-focus';
|
|
26
|
-
const CLS_ITEMHIDE: Str = 'e-hide';
|
|
27
|
-
const CLS_HEADER: Str = 'e-acrdn-header';
|
|
28
|
-
const CLS_HEADERICN: Str = 'e-acrdn-header-icon';
|
|
29
|
-
const CLS_HEADERCTN: Str = 'e-acrdn-header-content';
|
|
30
|
-
const CLS_CONTENT: Str = 'e-acrdn-panel';
|
|
31
|
-
const CLS_CTENT: Str = 'e-acrdn-content';
|
|
32
|
-
const CLS_TOOGLEICN: Str = 'e-toggle-icon';
|
|
33
|
-
const CLS_COLLAPSEICN: Str = 'e-tgl-collapse-icon e-icons';
|
|
34
|
-
const CLS_EXPANDICN: Str = 'e-expand-icon';
|
|
35
|
-
const CLS_RTL: Str = 'e-rtl';
|
|
36
|
-
const CLS_CTNHIDE: Str = 'e-content-hide';
|
|
37
|
-
const CLS_SLCT: Str = 'e-select';
|
|
38
|
-
const CLS_SLCTED: Str = 'e-selected';
|
|
39
|
-
const CLS_ACTIVE: Str = 'e-active';
|
|
40
|
-
const CLS_ANIMATE: Str = 'e-animate';
|
|
41
|
-
const CLS_DISABLE: Str = 'e-overlay';
|
|
42
|
-
const CLS_TOGANIMATE: Str = 'e-toggle-animation';
|
|
43
|
-
const CLS_NEST: Str = 'e-nested';
|
|
44
|
-
const CLS_EXPANDSTATE: Str = 'e-expand-state';
|
|
45
|
-
const CLS_CONTAINER: Str = 'e-accordion-container';
|
|
46
|
-
|
|
47
|
-
interface AcrdnTemplateRef {
|
|
48
|
-
elementRef: AcrdnElementRef
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface AcrdnElementRef {
|
|
52
|
-
nativeElement: AcrdnElementComment
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface AcrdnElementComment {
|
|
56
|
-
childNodes?: NodeList
|
|
57
|
-
firstChild?: HTMLElement
|
|
58
|
-
lastChild?: HTMLElement
|
|
59
|
-
nextElementSibling?: HTMLElement
|
|
60
|
-
parentElement?: HTMLElement
|
|
61
|
-
propName?: HTMLElement
|
|
62
|
-
data?: string
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** An interface that holds options to control the accordion click action. */
|
|
66
|
-
export interface AccordionClickArgs extends BaseEventArgs {
|
|
67
|
-
/** Defines the current Accordion Item Object. */
|
|
68
|
-
item?: AccordionItemModel
|
|
69
|
-
/**
|
|
70
|
-
* Defines the current Event arguments.
|
|
71
|
-
*/
|
|
72
|
-
originalEvent?: Event
|
|
73
|
-
/**
|
|
74
|
-
* Defines whether to cancel the Accordion click action.
|
|
75
|
-
* When set to `true`, the default click behavior will be prevented,
|
|
76
|
-
* preventing any action associated with the Accordion item click (such as expanding or collapsing the item).
|
|
77
|
-
* When set to `false` or omitted, the default click behavior will proceed as normal.
|
|
78
|
-
*/
|
|
79
|
-
cancel?: boolean;
|
|
80
|
-
}
|
|
81
|
-
/** An interface that holds options to control the expanding item action. */
|
|
82
|
-
export interface ExpandEventArgs extends BaseEventArgs {
|
|
83
|
-
/** Defines the current Accordion Item Object. */
|
|
84
|
-
item?: AccordionItemModel
|
|
85
|
-
/** Defines the current Accordion Item Element. */
|
|
86
|
-
element?: HTMLElement
|
|
87
|
-
/** Defines the expand/collapse state. */
|
|
88
|
-
isExpanded?: boolean
|
|
89
|
-
/** Defines the prevent action. */
|
|
90
|
-
cancel?: boolean
|
|
91
|
-
/** Defines the Accordion Item Index */
|
|
92
|
-
index?: number
|
|
93
|
-
/** Defines the Accordion Item Content */
|
|
94
|
-
content?: HTMLElement
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** An interface that holds options to control the expanded item action. */
|
|
98
|
-
export interface ExpandedEventArgs extends BaseEventArgs {
|
|
99
|
-
/** Defines the current Accordion Item Object. */
|
|
100
|
-
item?: AccordionItemModel
|
|
101
|
-
/** Defines the current Accordion Item Element. */
|
|
102
|
-
element?: HTMLElement
|
|
103
|
-
/** Defines the expand/collapse state. */
|
|
104
|
-
isExpanded?: boolean
|
|
105
|
-
/** Defines the Accordion Item Index */
|
|
106
|
-
index?: number
|
|
107
|
-
/** Defines the Accordion Item Content */
|
|
108
|
-
content?: HTMLElement
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Objects used for configuring the Accordion expanding item action properties.
|
|
113
|
-
*/
|
|
114
|
-
export class AccordionActionSettings extends ChildProperty<AccordionActionSettings> {
|
|
115
|
-
/**
|
|
116
|
-
* Specifies the type of animation.
|
|
117
|
-
*
|
|
118
|
-
* @default 'SlideDown'
|
|
119
|
-
* @aspType string
|
|
120
|
-
*/
|
|
121
|
-
@Property('SlideDown')
|
|
122
|
-
public effect: 'None' | Effect;
|
|
123
|
-
/**
|
|
124
|
-
* Specifies the duration to animate.
|
|
125
|
-
*
|
|
126
|
-
* @default 400
|
|
127
|
-
*/
|
|
128
|
-
@Property(400)
|
|
129
|
-
public duration: number;
|
|
130
|
-
/**
|
|
131
|
-
* Specifies the animation timing function.
|
|
132
|
-
*
|
|
133
|
-
* @default 'linear'
|
|
134
|
-
*/
|
|
135
|
-
@Property('linear')
|
|
136
|
-
public easing: string;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Objects used for configuring the Accordion animation properties.
|
|
141
|
-
*/
|
|
142
|
-
export class AccordionAnimationSettings extends ChildProperty<AccordionAnimationSettings> {
|
|
143
|
-
/**
|
|
144
|
-
* Specifies the animation to appear while collapsing the Accordion item.
|
|
145
|
-
*
|
|
146
|
-
* @default { effect: 'SlideDown', duration: 400, easing: 'linear' }
|
|
147
|
-
*/
|
|
148
|
-
@Complex<AccordionActionSettingsModel>({ effect: 'SlideUp', duration: 400, easing: 'linear' }, AccordionActionSettings)
|
|
149
|
-
public collapse: AccordionActionSettingsModel;
|
|
150
|
-
/**
|
|
151
|
-
* Specifies the animation to appear while expanding the Accordion item.
|
|
152
|
-
*
|
|
153
|
-
* @default { effect: 'SlideDown', duration: 400, easing: 'linear' }
|
|
154
|
-
*/
|
|
155
|
-
@Complex<AccordionActionSettingsModel>({ effect: 'SlideDown', duration: 400, easing: 'linear' }, AccordionActionSettings)
|
|
156
|
-
public expand: AccordionActionSettingsModel;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* An item object that is used to configure Accordion items.
|
|
160
|
-
*/
|
|
161
|
-
export class AccordionItem extends ChildProperty<AccordionItem> {
|
|
162
|
-
/**
|
|
163
|
-
* Sets the text content to be displayed for the Accordion item.
|
|
164
|
-
* You can set the content of the Accordion item using `content` property.
|
|
165
|
-
* It also supports to include the title as `HTML element`, `string`, or `query selector`.
|
|
166
|
-
* ```typescript
|
|
167
|
-
* let accordionObj: Accordion = new Accordion( {
|
|
168
|
-
* items: [
|
|
169
|
-
* { header: 'Accordion Header', content: 'Accordion Content' },
|
|
170
|
-
* { header: '<div>Accordion Header</div>', content: '<div>Accordion Content</div>' },
|
|
171
|
-
* { header: '#headerContent', content: '#panelContent' }]
|
|
172
|
-
* });
|
|
173
|
-
* accordionObj.appendTo('#accordion');
|
|
174
|
-
* ```
|
|
175
|
-
*
|
|
176
|
-
* @default null
|
|
177
|
-
*/
|
|
178
|
-
@Property(null)
|
|
179
|
-
public content: string;
|
|
180
|
-
/**
|
|
181
|
-
* Sets the header text to be displayed for the Accordion item.
|
|
182
|
-
* You can set the title of the Accordion item using `header` property.
|
|
183
|
-
* It also supports to include the title as `HTML element`, `string`, or `query selector`.
|
|
184
|
-
* ```typescript
|
|
185
|
-
* let accordionObj: Accordion = new Accordion( {
|
|
186
|
-
* items: [
|
|
187
|
-
* { header: 'Accordion Header', content: 'Accordion Content' },
|
|
188
|
-
* { header: '<div>Accordion Header</div>', content: '<div>Accordion Content</div>' },
|
|
189
|
-
* { header: '#headerContent', content: '#panelContent' }]
|
|
190
|
-
* });
|
|
191
|
-
* accordionObj.appendTo('#accordion');
|
|
192
|
-
* ```
|
|
193
|
-
*
|
|
194
|
-
* @default null
|
|
195
|
-
*/
|
|
196
|
-
@Property(null)
|
|
197
|
-
public header: string;
|
|
198
|
-
/**
|
|
199
|
-
* Defines single/multiple classes (separated by a space) are to be used for Accordion item customization.
|
|
200
|
-
*
|
|
201
|
-
* @default null
|
|
202
|
-
*/
|
|
203
|
-
@Property(null)
|
|
204
|
-
public cssClass: string;
|
|
205
|
-
/**
|
|
206
|
-
* Defines an icon with the given custom CSS class that is to be rendered before the header text.
|
|
207
|
-
* Add the css classes to the `iconCss` property and write the css styles to the defined class to set images/icons.
|
|
208
|
-
* Adding icon is applicable only to the header.
|
|
209
|
-
* ```typescript
|
|
210
|
-
* let accordionObj: Accordion = new Accordion( {
|
|
211
|
-
* items: [
|
|
212
|
-
* { header: 'Accordion Header', iconCss: 'e-app-icon' }]
|
|
213
|
-
* });
|
|
214
|
-
* accordionObj.appendTo('#accordion');
|
|
215
|
-
* ```
|
|
216
|
-
* ```css
|
|
217
|
-
* .e-app-icon::before {
|
|
218
|
-
* content: "\e710";
|
|
219
|
-
* }
|
|
220
|
-
* ```
|
|
221
|
-
*
|
|
222
|
-
* @default null
|
|
223
|
-
*/
|
|
224
|
-
@Property(null)
|
|
225
|
-
public iconCss: string;
|
|
226
|
-
/**
|
|
227
|
-
* Sets the expand (true) or collapse (false) state of the Accordion item. By default, all the items are in a collapsed state.
|
|
228
|
-
*
|
|
229
|
-
* @default false
|
|
230
|
-
*/
|
|
231
|
-
@Property(false)
|
|
232
|
-
public expanded: boolean;
|
|
233
|
-
/**
|
|
234
|
-
* Sets false to hide an accordion item.
|
|
235
|
-
*
|
|
236
|
-
* @default true
|
|
237
|
-
*/
|
|
238
|
-
@Property(true)
|
|
239
|
-
public visible: boolean;
|
|
240
|
-
/**
|
|
241
|
-
* Sets true to disable an accordion item.
|
|
242
|
-
*
|
|
243
|
-
* @default false
|
|
244
|
-
*/
|
|
245
|
-
@Property(false)
|
|
246
|
-
public disabled: boolean;
|
|
247
|
-
/**
|
|
248
|
-
* Sets unique ID to accordion item.
|
|
249
|
-
*
|
|
250
|
-
* @default null
|
|
251
|
-
*/
|
|
252
|
-
@Property()
|
|
253
|
-
public id: string;
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* The Accordion is a vertically collapsible content panel that displays one or more panels at a time within the available space.
|
|
259
|
-
* ```html
|
|
260
|
-
* <div id='accordion'/>
|
|
261
|
-
* <script>
|
|
262
|
-
* var accordionObj = new Accordion();
|
|
263
|
-
* accordionObj.appendTo('#accordion');
|
|
264
|
-
* </script>
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
@NotifyPropertyChanges
|
|
268
|
-
export class Accordion extends Component<HTMLElement> implements INotifyPropertyChanged {
|
|
269
|
-
private lastActiveItemId: string;
|
|
270
|
-
private trgtEle: HTEle;
|
|
271
|
-
private ctrlTem: HTEle;
|
|
272
|
-
private keyModule: KeyboardEvents;
|
|
273
|
-
private initExpand: number[];
|
|
274
|
-
private isNested: boolean;
|
|
275
|
-
private isDestroy: boolean;
|
|
276
|
-
private templateEle: string[];
|
|
277
|
-
private headerTemplateFn: Function;
|
|
278
|
-
private itemTemplateFn: Function;
|
|
279
|
-
private removeRippleEffect: () => void;
|
|
280
|
-
/**
|
|
281
|
-
* Contains the keyboard configuration of the Accordion.
|
|
282
|
-
*/
|
|
283
|
-
private keyConfigs: { [key: string]: Str } = {
|
|
284
|
-
moveUp: 'uparrow',
|
|
285
|
-
moveDown: 'downarrow',
|
|
286
|
-
enter: 'enter',
|
|
287
|
-
space: 'space',
|
|
288
|
-
home: 'home',
|
|
289
|
-
end: 'end'
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* An array of item that is used to specify Accordion items.
|
|
294
|
-
* ```typescript
|
|
295
|
-
* let accordionObj: Accordion = new Accordion( {
|
|
296
|
-
* items: [
|
|
297
|
-
* { header: 'Accordion Header', content: 'Accordion Content' }]
|
|
298
|
-
* });
|
|
299
|
-
* accordionObj.appendTo('#accordion');
|
|
300
|
-
* ```
|
|
301
|
-
*
|
|
302
|
-
* @default []
|
|
303
|
-
*/
|
|
304
|
-
@Collection<AccordionItemModel>([], AccordionItem)
|
|
305
|
-
public items: AccordionItemModel[];
|
|
306
|
-
/**
|
|
307
|
-
* Specifies the datasource for the accordion items.
|
|
308
|
-
*
|
|
309
|
-
* @isdatamanager false
|
|
310
|
-
* @default []
|
|
311
|
-
*/
|
|
312
|
-
@Property([])
|
|
313
|
-
public dataSource: Object[];
|
|
314
|
-
/**
|
|
315
|
-
* Specifies the template option for accordion items.
|
|
316
|
-
*
|
|
317
|
-
* @default null
|
|
318
|
-
* @angularType string | object
|
|
319
|
-
* @reactType string | function | JSX.Element
|
|
320
|
-
* @vueType string | function
|
|
321
|
-
* @aspType string
|
|
322
|
-
*/
|
|
323
|
-
@Property()
|
|
324
|
-
public itemTemplate: string | Function;
|
|
325
|
-
/**
|
|
326
|
-
* Specifies the header title template option for accordion items.
|
|
327
|
-
*
|
|
328
|
-
* @default null
|
|
329
|
-
* @angularType string | object
|
|
330
|
-
* @reactType string | function | JSX.Element
|
|
331
|
-
* @vueType string | function
|
|
332
|
-
* @aspType string
|
|
333
|
-
*/
|
|
334
|
-
@Property()
|
|
335
|
-
public headerTemplate: string | Function;
|
|
336
|
-
/**
|
|
337
|
-
* Specifies the width of the Accordion in pixels/number/percentage. Number value is considered as pixels.
|
|
338
|
-
*
|
|
339
|
-
* @default '100%'
|
|
340
|
-
*/
|
|
341
|
-
@Property('100%')
|
|
342
|
-
public width: string | number;
|
|
343
|
-
/**
|
|
344
|
-
* Specifies the height of the Accordion in pixels/number/percentage. Number value is considered as pixels.
|
|
345
|
-
*
|
|
346
|
-
* @default 'auto'
|
|
347
|
-
*/
|
|
348
|
-
@Property('auto')
|
|
349
|
-
public height: string | number;
|
|
350
|
-
/**
|
|
351
|
-
* Specifies the expanded items at initial load.
|
|
352
|
-
*
|
|
353
|
-
* @default []
|
|
354
|
-
*/
|
|
355
|
-
@Property([])
|
|
356
|
-
public expandedIndices: number[];
|
|
357
|
-
/**
|
|
358
|
-
* Specifies the options to expand single or multiple panel at a time.
|
|
359
|
-
* The possible values are:
|
|
360
|
-
* * `Single`: Sets to expand only one Accordion item at a time.
|
|
361
|
-
* * `Multiple`: Sets to expand more than one Accordion item at a time.
|
|
362
|
-
*
|
|
363
|
-
* @default 'Multiple'
|
|
364
|
-
*/
|
|
365
|
-
@Property('Multiple')
|
|
366
|
-
public expandMode: ExpandMode;
|
|
367
|
-
/**
|
|
368
|
-
* Specifies whether to enable the rendering of untrusted HTML values in the Accordion component.
|
|
369
|
-
* When this property is enabled, the component will sanitize any suspected untrusted strings and scripts before rendering them.
|
|
370
|
-
*
|
|
371
|
-
* @default true
|
|
372
|
-
*/
|
|
373
|
-
@Property(true)
|
|
374
|
-
public enableHtmlSanitizer: boolean;
|
|
375
|
-
/**
|
|
376
|
-
* Specifies the animation configuration settings for expanding and collapsing the panel.
|
|
377
|
-
*
|
|
378
|
-
* @default { expand: { effect: 'SlideDown', duration: 400, easing: 'linear' },
|
|
379
|
-
* collapse: { effect: 'SlideUp', duration: 400, easing: 'linear' }}
|
|
380
|
-
*/
|
|
381
|
-
@Complex<AccordionAnimationSettingsModel>({}, AccordionAnimationSettings)
|
|
382
|
-
public animation: AccordionAnimationSettingsModel;
|
|
383
|
-
/**
|
|
384
|
-
* The event will be fired while clicking anywhere within the Accordion.
|
|
385
|
-
*
|
|
386
|
-
* @event clicked
|
|
387
|
-
*/
|
|
388
|
-
@Event()
|
|
389
|
-
public clicked: EmitType<AccordionClickArgs>;
|
|
390
|
-
/**
|
|
391
|
-
* The event will be fired before the item gets collapsed/expanded.
|
|
392
|
-
*
|
|
393
|
-
* @event expanding
|
|
394
|
-
*/
|
|
395
|
-
@Event()
|
|
396
|
-
public expanding: EmitType<ExpandEventArgs>;
|
|
397
|
-
/**
|
|
398
|
-
* The event will be fired after the item gets collapsed/expanded.
|
|
399
|
-
*
|
|
400
|
-
* @event expanded
|
|
401
|
-
*/
|
|
402
|
-
@Event()
|
|
403
|
-
public expanded: EmitType<ExpandedEventArgs>;
|
|
404
|
-
/**
|
|
405
|
-
* The event will be fired once the control rendering is completed.
|
|
406
|
-
*
|
|
407
|
-
* @event created
|
|
408
|
-
*/
|
|
409
|
-
@Event()
|
|
410
|
-
public created: EmitType<Event>;
|
|
411
|
-
/**
|
|
412
|
-
* The event will be fired when the control gets destroyed.
|
|
413
|
-
*
|
|
414
|
-
* @event destroyed
|
|
415
|
-
*/
|
|
416
|
-
@Event()
|
|
417
|
-
public destroyed: EmitType<Event>;
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Initializes a new instance of the Accordion class.
|
|
421
|
-
*
|
|
422
|
-
* @param {AccordionModel} options - Specifies Accordion model properties as options.
|
|
423
|
-
* @param {string | HTMLElement} element - Specifies the element that is rendered as an Accordion.
|
|
424
|
-
*/
|
|
425
|
-
public constructor(options?: AccordionModel, element?: string | HTMLElement) {
|
|
426
|
-
super(options, <HTEle | Str>element);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Removes the control from the DOM and also removes all its related events.
|
|
430
|
-
*
|
|
431
|
-
* @returns {void}
|
|
432
|
-
*/
|
|
433
|
-
public destroy(): void {
|
|
434
|
-
if (this.isReact || this.isAngular || this.isVue) {
|
|
435
|
-
this.clearTemplate();
|
|
436
|
-
}
|
|
437
|
-
const ele: HTEle = this.element;
|
|
438
|
-
super.destroy();
|
|
439
|
-
this.unWireEvents();
|
|
440
|
-
this.isDestroy = true;
|
|
441
|
-
this.restoreContent(null);
|
|
442
|
-
[].slice.call(ele.children).forEach((el: HTEle) => {
|
|
443
|
-
ele.removeChild(el);
|
|
444
|
-
});
|
|
445
|
-
if (this.trgtEle) {
|
|
446
|
-
this.trgtEle = null;
|
|
447
|
-
while (this.ctrlTem.firstElementChild) {
|
|
448
|
-
ele.appendChild(this.ctrlTem.firstElementChild);
|
|
449
|
-
}
|
|
450
|
-
this.ctrlTem = null;
|
|
451
|
-
}
|
|
452
|
-
ele.classList.remove(CLS_ACRDN_ROOT);
|
|
453
|
-
ele.removeAttribute('style');
|
|
454
|
-
this.element.removeAttribute('data-ripple');
|
|
455
|
-
if (!this.isNested && isRippleEnabled) {
|
|
456
|
-
this.removeRippleEffect();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
protected preRender(): void {
|
|
460
|
-
const nested: Element = closest(this.element, '.' + CLS_CONTENT);
|
|
461
|
-
this.isNested = false;
|
|
462
|
-
this.templateEle = [];
|
|
463
|
-
if (!this.isDestroy) {
|
|
464
|
-
this.isDestroy = false;
|
|
465
|
-
}
|
|
466
|
-
if (nested && nested.firstElementChild && nested.firstElementChild.firstElementChild) {
|
|
467
|
-
if (nested.firstElementChild.firstElementChild.classList.contains(CLS_ROOT)) {
|
|
468
|
-
nested.classList.add(CLS_NEST);
|
|
469
|
-
this.isNested = true;
|
|
470
|
-
}
|
|
471
|
-
} else {
|
|
472
|
-
this.element.classList.add(CLS_ACRDN_ROOT);
|
|
473
|
-
}
|
|
474
|
-
if (this.enableRtl) {
|
|
475
|
-
this.add(this.element, CLS_RTL);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
private add(ele: HTEle, val: Str): void {
|
|
479
|
-
ele.classList.add(val);
|
|
480
|
-
}
|
|
481
|
-
private remove(ele: HTEle, val: Str): void {
|
|
482
|
-
ele.classList.remove(val);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* To initialize the control rendering
|
|
486
|
-
*
|
|
487
|
-
* @private
|
|
488
|
-
* @returns {void}
|
|
489
|
-
*/
|
|
490
|
-
protected render(): void {
|
|
491
|
-
this.initializeHeaderTemplate();
|
|
492
|
-
this.initializeItemTemplate();
|
|
493
|
-
this.initialize();
|
|
494
|
-
this.renderControl();
|
|
495
|
-
this.wireEvents();
|
|
496
|
-
this.renderComplete();
|
|
497
|
-
}
|
|
498
|
-
private initialize(): void {
|
|
499
|
-
const width: Str = formatUnit(this.width);
|
|
500
|
-
const height: Str = formatUnit(this.height);
|
|
501
|
-
setStyle(this.element, { 'width': width, 'height': height });
|
|
502
|
-
if (isNOU(this.initExpand)) {
|
|
503
|
-
this.initExpand = [];
|
|
504
|
-
}
|
|
505
|
-
if (!isNOU(this.expandedIndices) && this.expandedIndices.length > 0) {
|
|
506
|
-
this.initExpand = this.expandedIndices;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
private renderControl(): void {
|
|
510
|
-
this.trgtEle = (this.element.children.length > 0) ? <HTEle>select('div', this.element) : null;
|
|
511
|
-
this.renderItems();
|
|
512
|
-
this.initItemExpand();
|
|
513
|
-
}
|
|
514
|
-
private wireFocusEvents(): void {
|
|
515
|
-
const acrdItem: HTEle[] = [].slice.call(this.element.querySelectorAll('.' + CLS_ITEM));
|
|
516
|
-
for (const item of acrdItem) {
|
|
517
|
-
const headerEle: Element = item.querySelector('.' + CLS_HEADER);
|
|
518
|
-
if (item.childElementCount > 0 && headerEle) {
|
|
519
|
-
EventHandler.clearEvents(headerEle);
|
|
520
|
-
EventHandler.add(headerEle, 'focus', this.focusIn, this);
|
|
521
|
-
EventHandler.add(headerEle, 'blur', this.focusOut, this);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
private unWireEvents(): void {
|
|
526
|
-
EventHandler.remove(this.element, 'click', this.clickHandler);
|
|
527
|
-
if (!isNOU(this.keyModule)) {
|
|
528
|
-
this.keyModule.destroy();
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
private wireEvents(): void {
|
|
532
|
-
EventHandler.add(this.element, 'click', this.clickHandler, this);
|
|
533
|
-
if (!this.isNested && !this.isDestroy) {
|
|
534
|
-
this.removeRippleEffect = rippleEffect(this.element, { selector: '.' + CLS_HEADER });
|
|
535
|
-
}
|
|
536
|
-
if (!this.isNested) {
|
|
537
|
-
this.keyModule = new KeyboardEvents(
|
|
538
|
-
this.element,
|
|
539
|
-
{
|
|
540
|
-
keyAction: this.keyActionHandler.bind(this),
|
|
541
|
-
keyConfigs: this.keyConfigs,
|
|
542
|
-
eventName: 'keydown'
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
private templateParser(template: string | Function): (template: string | Function) => NodeList | undefined {
|
|
547
|
-
if (template) {
|
|
548
|
-
try {
|
|
549
|
-
if (typeof template !== 'function' && document.querySelectorAll(template).length) {
|
|
550
|
-
return templateCompiler(document.querySelector(template).innerHTML.trim());
|
|
551
|
-
} else {
|
|
552
|
-
return templateCompiler(template);
|
|
553
|
-
}
|
|
554
|
-
} catch (error) {
|
|
555
|
-
return templateCompiler(template);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
return undefined;
|
|
559
|
-
}
|
|
560
|
-
private initializeHeaderTemplate(): void {
|
|
561
|
-
if (this.headerTemplate) {
|
|
562
|
-
this.headerTemplateFn = this.templateParser(this.headerTemplate);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
private initializeItemTemplate(): void {
|
|
566
|
-
if (this.itemTemplate) {
|
|
567
|
-
this.itemTemplateFn = this.templateParser(this.itemTemplate);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
private getHeaderTemplate(): Function {
|
|
571
|
-
return this.headerTemplateFn;
|
|
572
|
-
}
|
|
573
|
-
private getItemTemplate(): Function {
|
|
574
|
-
return this.itemTemplateFn;
|
|
575
|
-
}
|
|
576
|
-
private focusIn(e: FocusEvent): void {
|
|
577
|
-
(<HTEle>e.target).parentElement.classList.add(CLS_ITEMFOCUS);
|
|
578
|
-
}
|
|
579
|
-
private focusOut(e: FocusEvent): void {
|
|
580
|
-
(<HTEle>e.target).parentElement.classList.remove(CLS_ITEMFOCUS);
|
|
581
|
-
}
|
|
582
|
-
private ctrlTemplate(): void {
|
|
583
|
-
this.ctrlTem = <HTEle>this.element.cloneNode(true);
|
|
584
|
-
let innerEles: HTMLCollection;
|
|
585
|
-
const rootEle: HTMLElement = <HTMLElement>select('.' + CLS_CONTAINER, this.element);
|
|
586
|
-
if (rootEle) {
|
|
587
|
-
innerEles = rootEle.children as HTMLCollection;
|
|
588
|
-
} else {
|
|
589
|
-
innerEles = this.element.children as HTMLCollection;
|
|
590
|
-
}
|
|
591
|
-
const items: AccordionItemModel[] = [];
|
|
592
|
-
[].slice.call(innerEles).forEach((el: HTEle) => {
|
|
593
|
-
items.push({
|
|
594
|
-
header: (el.childElementCount > 0 && el.children[0]) ? (el.children[0]) as any : '',
|
|
595
|
-
content: (el.childElementCount > 1 && el.children[1]) ? (el.children[1]) as any : ''
|
|
596
|
-
});
|
|
597
|
-
el.parentNode.removeChild(el);
|
|
598
|
-
});
|
|
599
|
-
if (rootEle) {
|
|
600
|
-
this.element.removeChild(rootEle);
|
|
601
|
-
}
|
|
602
|
-
this.setProperties({ items: items }, true);
|
|
603
|
-
}
|
|
604
|
-
private toggleIconGenerate(): HTEle {
|
|
605
|
-
const tglIcon: HTEle = this.createElement('div', { className: CLS_TOOGLEICN });
|
|
606
|
-
const hdrColIcon: HTEle = this.createElement('span', { className: CLS_COLLAPSEICN });
|
|
607
|
-
tglIcon.appendChild(hdrColIcon);
|
|
608
|
-
return tglIcon;
|
|
609
|
-
}
|
|
610
|
-
private initItemExpand(): void {
|
|
611
|
-
const len: number = this.initExpand.length;
|
|
612
|
-
if (len === 0) {
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
if (this.expandMode === 'Single') {
|
|
616
|
-
this.expandItem(true, this.initExpand[len - 1]);
|
|
617
|
-
} else {
|
|
618
|
-
for (let i: number = 0; i < len; i++) {
|
|
619
|
-
this.expandItem(true, this.initExpand[parseInt(i.toString(), 10)]);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
if (this.isReact) {
|
|
623
|
-
this.renderReactTemplates();
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
private renderItems(): void {
|
|
627
|
-
const ele: HTEle = this.element;
|
|
628
|
-
let innerItem: HTEle;
|
|
629
|
-
let innerDataSourceItem: HTEle;
|
|
630
|
-
if (!isNOU(this.trgtEle)) {
|
|
631
|
-
this.ctrlTemplate();
|
|
632
|
-
}
|
|
633
|
-
if (!isNOU(this.dataSource) && this.dataSource.length > 0) {
|
|
634
|
-
this.dataSource.forEach((item: object, index: number) => {
|
|
635
|
-
innerDataSourceItem = this.renderInnerItem(item, index);
|
|
636
|
-
ele.appendChild(innerDataSourceItem);
|
|
637
|
-
if (innerDataSourceItem.childElementCount > 0) {
|
|
638
|
-
EventHandler.add(innerDataSourceItem.querySelector('.' + CLS_HEADER), 'focus', this.focusIn, this);
|
|
639
|
-
EventHandler.add(innerDataSourceItem.querySelector('.' + CLS_HEADER), 'blur', this.focusOut, this);
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
} else {
|
|
643
|
-
const items: AccordionItem[] = <AccordionItem[]>this.items;
|
|
644
|
-
if (ele && items.length > 0) {
|
|
645
|
-
items.forEach((item: AccordionItem, index: number) => {
|
|
646
|
-
innerItem = this.renderInnerItem(item, index);
|
|
647
|
-
ele.appendChild(innerItem);
|
|
648
|
-
if (innerItem.childElementCount > 0) {
|
|
649
|
-
EventHandler.add(innerItem.querySelector('.' + CLS_HEADER), 'focus', this.focusIn, this);
|
|
650
|
-
EventHandler.add(innerItem.querySelector('.' + CLS_HEADER), 'blur', this.focusOut, this);
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
if (this.isReact) {
|
|
656
|
-
this.renderReactTemplates();
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
private clickHandler(e: Event): void {
|
|
660
|
-
const trgt: HTEle = <HTEle>e.target;
|
|
661
|
-
const items: Object[] = this.getItems();
|
|
662
|
-
const eventArgs: AccordionClickArgs = {};
|
|
663
|
-
let tglIcon: HTEle;
|
|
664
|
-
const acrdEle: HTEle = <HTEle>closest(trgt, '.' + CLS_ROOT);
|
|
665
|
-
if (acrdEle !== this.element) {
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
trgt.classList.add('e-target');
|
|
669
|
-
const acrdnItem: HTEle = <HTEle>closest(trgt, '.' + CLS_ITEM);
|
|
670
|
-
let acrdnHdr: HTEle = <HTEle>closest(trgt, '.' + CLS_HEADER);
|
|
671
|
-
let acrdnCtn: HTEle = <HTEle>closest(trgt, '.' + CLS_CONTENT);
|
|
672
|
-
if (acrdnItem && (isNOU(acrdnHdr) || isNOU(acrdnCtn))) {
|
|
673
|
-
acrdnHdr = <HTEle>acrdnItem.children[0];
|
|
674
|
-
acrdnCtn = <HTEle>acrdnItem.children[1];
|
|
675
|
-
}
|
|
676
|
-
if (acrdnHdr) {
|
|
677
|
-
tglIcon = <HTEle>select('.' + CLS_TOOGLEICN, acrdnHdr);
|
|
678
|
-
}
|
|
679
|
-
let acrdnCtnItem: HTEle;
|
|
680
|
-
if (acrdnHdr) {
|
|
681
|
-
acrdnCtnItem = <HTEle>closest(acrdnHdr, '.' + CLS_ITEM);
|
|
682
|
-
} else if (acrdnCtn) {
|
|
683
|
-
acrdnCtnItem = <HTEle>closest(acrdnCtn, '.' + CLS_ITEM);
|
|
684
|
-
}
|
|
685
|
-
const index: number = this.getIndexByItem(acrdnItem);
|
|
686
|
-
if (acrdnCtnItem) {
|
|
687
|
-
eventArgs.item = items[this.getIndexByItem(acrdnCtnItem)];
|
|
688
|
-
}
|
|
689
|
-
eventArgs.originalEvent = e;
|
|
690
|
-
const ctnCheck: boolean = !isNOU(tglIcon) && acrdnItem.childElementCount <= 1;
|
|
691
|
-
if (ctnCheck && (isNOU(acrdnCtn) || !isNOU(select('.' + CLS_HEADER + ' .' + CLS_TOOGLEICN, acrdnCtnItem)))) {
|
|
692
|
-
acrdnItem.appendChild(this.contentRendering(index));
|
|
693
|
-
this.ariaAttrUpdate(acrdnItem);
|
|
694
|
-
this.afterContentRender(trgt, eventArgs, acrdnItem, acrdnHdr, acrdnCtn, acrdnCtnItem);
|
|
695
|
-
} else {
|
|
696
|
-
this.afterContentRender(trgt, eventArgs, acrdnItem, acrdnHdr, acrdnCtn, acrdnCtnItem);
|
|
697
|
-
}
|
|
698
|
-
if (this.isReact) {
|
|
699
|
-
this.renderReactTemplates();
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
private afterContentRender(
|
|
703
|
-
trgt: HTEle, eventArgs: AccordionClickArgs, acrdnItem: HTEle, acrdnHdr: HTEle, acrdnCtn: HTEle, acrdnCtnItem: HTEle): void {
|
|
704
|
-
const acrdActive: HTEle[] = [];
|
|
705
|
-
this.trigger('clicked', eventArgs, (eventArgs: AccordionClickArgs) => {
|
|
706
|
-
if (eventArgs.cancel) {
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
let cntclkCheck: boolean = (acrdnCtn && !isNOU(select('.e-target', acrdnCtn)));
|
|
710
|
-
const inlineAcrdnSel: string = '.' + CLS_CONTENT + ' .' + CLS_ROOT;
|
|
711
|
-
const inlineEleAcrdn: boolean = acrdnCtn && !isNOU(select('.' + CLS_ROOT, acrdnCtn)) && isNOU(closest(trgt, inlineAcrdnSel));
|
|
712
|
-
const nestContCheck: boolean = acrdnCtn && isNOU(select('.' + CLS_ROOT, acrdnCtn)) || !(closest(trgt, '.' + CLS_ROOT) === this.element);
|
|
713
|
-
cntclkCheck = cntclkCheck && (inlineEleAcrdn || nestContCheck);
|
|
714
|
-
trgt.classList.remove('e-target');
|
|
715
|
-
if (trgt.classList.contains(CLS_CONTENT) || trgt.classList.contains(CLS_CTENT) || cntclkCheck) {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
const acrdcontainer: HTMLElement = <HTMLElement>this.element.querySelector('.' + CLS_CONTAINER);
|
|
719
|
-
const acrdnchild: HTMLCollection = (acrdcontainer) ? acrdcontainer.children : this.element.children;
|
|
720
|
-
[].slice.call(acrdnchild).forEach((el: HTEle) => {
|
|
721
|
-
if (el.classList.contains(CLS_ACTIVE)) {
|
|
722
|
-
acrdActive.push(el);
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
const acrdAniEle: HTEle[] = [].slice.call(this.element.querySelectorAll('.' + CLS_ITEM + ' [' + CLS_ANIMATE + ']'));
|
|
726
|
-
if (acrdAniEle.length > 0) {
|
|
727
|
-
for (const el of acrdAniEle) {
|
|
728
|
-
acrdActive.push(el.parentElement);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
const sameContentCheck: boolean = acrdActive.indexOf(acrdnCtnItem) !== -1 && acrdnCtn.getAttribute('e-animate') === 'true';
|
|
732
|
-
let sameHeader: boolean = false;
|
|
733
|
-
if (!isNOU(acrdnItem) && !isNOU(acrdnHdr)) {
|
|
734
|
-
const acrdnCtn: HTEle = <HTEle>select('.' + CLS_CONTENT, acrdnItem);
|
|
735
|
-
const acrdnRoot: HTEle = <HTEle>closest(acrdnItem, '.' + CLS_ACRDN_ROOT);
|
|
736
|
-
const expandState: HTEle = <HTEle>acrdnRoot.querySelector('.' + CLS_EXPANDSTATE);
|
|
737
|
-
if (isNOU(acrdnCtn)) {
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
sameHeader = (expandState === acrdnItem);
|
|
741
|
-
if (isVisible(acrdnCtn) && (!sameContentCheck || acrdnCtnItem.classList.contains(CLS_SLCTED))) {
|
|
742
|
-
this.collapse(acrdnCtn);
|
|
743
|
-
} else {
|
|
744
|
-
if ((acrdActive.length > 0) && this.expandMode === 'Single' && !sameContentCheck) {
|
|
745
|
-
acrdActive.forEach((el: HTEle) => {
|
|
746
|
-
this.collapse(<HTEle>select('.' + CLS_CONTENT, el));
|
|
747
|
-
el.classList.remove(CLS_EXPANDSTATE);
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
this.expand(acrdnCtn);
|
|
751
|
-
}
|
|
752
|
-
if (!isNOU(expandState) && !sameHeader) {
|
|
753
|
-
expandState.classList.remove(CLS_EXPANDSTATE);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
private eleMoveFocus(action: Str, root: HTEle, trgt: HTEle): void {
|
|
759
|
-
let clst: HTEle;
|
|
760
|
-
let clstItem: HTEle = <HTEle>closest(trgt, '.' + CLS_ITEM);
|
|
761
|
-
if (trgt === root) {
|
|
762
|
-
clst = <HTEle>((action === 'moveUp' ? trgt.lastElementChild : trgt).querySelector('.' + CLS_HEADER));
|
|
763
|
-
} else if (trgt.classList.contains(CLS_HEADER)) {
|
|
764
|
-
clstItem = <HTEle>(action === 'moveUp' ? clstItem.previousElementSibling : clstItem.nextElementSibling);
|
|
765
|
-
if (clstItem) {
|
|
766
|
-
clst = <HTEle>select('.' + CLS_HEADER, clstItem);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
if (clst) {
|
|
770
|
-
clst.focus();
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
private keyActionHandler(e: KeyboardEventArgs): void {
|
|
774
|
-
const trgt: HTEle = <HTEle>e.target;
|
|
775
|
-
const header: HTEle = <HTEle>closest(e.target as HTEle, CLS_HEADER);
|
|
776
|
-
if (isNOU(header) && !trgt.classList.contains(CLS_ROOT) && !trgt.classList.contains(CLS_HEADER)) {
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
let clst: HTEle;
|
|
780
|
-
const root: HTEle = this.element;
|
|
781
|
-
let content: HTEle;
|
|
782
|
-
switch (e.action) {
|
|
783
|
-
case 'moveUp':
|
|
784
|
-
this.eleMoveFocus(e.action, root, trgt);
|
|
785
|
-
break;
|
|
786
|
-
case 'moveDown':
|
|
787
|
-
this.eleMoveFocus(e.action, root, trgt);
|
|
788
|
-
break;
|
|
789
|
-
case 'space':
|
|
790
|
-
case 'enter':
|
|
791
|
-
content = trgt.nextElementSibling as HTEle;
|
|
792
|
-
if (!isNOU(content) && content.classList.contains(CLS_CONTENT)) {
|
|
793
|
-
if (content.getAttribute('e-animate') !== 'true') {
|
|
794
|
-
trgt.click();
|
|
795
|
-
}
|
|
796
|
-
} else {
|
|
797
|
-
trgt.click();
|
|
798
|
-
}
|
|
799
|
-
e.preventDefault();
|
|
800
|
-
break;
|
|
801
|
-
case 'home':
|
|
802
|
-
case 'end':
|
|
803
|
-
clst = e.action === 'home' ? <HTEle>root.firstElementChild.children[0] : <HTEle>root.lastElementChild.children[0];
|
|
804
|
-
clst.focus();
|
|
805
|
-
e.preventDefault();
|
|
806
|
-
break;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
private headerEleGenerate(): HTEle {
|
|
810
|
-
const header: HTEle = this.createElement('div', { className: CLS_HEADER, id: getUniqueID('acrdn_header') });
|
|
811
|
-
const ariaAttr: { [key: string]: Str } = {
|
|
812
|
-
'tabindex': '0', 'role': 'button', 'aria-disabled': 'false', 'aria-expanded': 'false'
|
|
813
|
-
};
|
|
814
|
-
attributes(header, ariaAttr);
|
|
815
|
-
return header;
|
|
816
|
-
}
|
|
817
|
-
private renderInnerItem(item: AccordionItemModel, index: number): HTEle {
|
|
818
|
-
const innerEle: HTEle = this.createElement('div', {
|
|
819
|
-
className: CLS_ITEM, id: item.id || getUniqueID('acrdn_item')
|
|
820
|
-
});
|
|
821
|
-
if (this.headerTemplate) {
|
|
822
|
-
const ctnEle: HTEle = this.headerEleGenerate();
|
|
823
|
-
const hdrEle: HTEle = this.createElement('div', { className: CLS_HEADERCTN });
|
|
824
|
-
ctnEle.appendChild(hdrEle);
|
|
825
|
-
append(this.getHeaderTemplate()(item, this, 'headerTemplate', this.element.id + '_headerTemplate', false), hdrEle);
|
|
826
|
-
innerEle.appendChild(ctnEle);
|
|
827
|
-
ctnEle.appendChild(this.toggleIconGenerate());
|
|
828
|
-
this.add(innerEle, CLS_SLCT);
|
|
829
|
-
return innerEle;
|
|
830
|
-
}
|
|
831
|
-
if (item.header && this.angularnativeCondiCheck(item, 'header')) {
|
|
832
|
-
let header: string = item.header;
|
|
833
|
-
if (this.enableHtmlSanitizer && typeof (item.header) === 'string') {
|
|
834
|
-
header = SanitizeHtmlHelper.sanitize(item.header);
|
|
835
|
-
}
|
|
836
|
-
const ctnEle: HTEle = this.headerEleGenerate();
|
|
837
|
-
const hdrEle: HTEle = this.createElement('div', { className: CLS_HEADERCTN });
|
|
838
|
-
ctnEle.appendChild(hdrEle);
|
|
839
|
-
ctnEle.appendChild(this.fetchElement(hdrEle, header, index));
|
|
840
|
-
innerEle.appendChild(ctnEle);
|
|
841
|
-
}
|
|
842
|
-
let hdr: HTEle = <HTEle>select('.' + CLS_HEADER, innerEle);
|
|
843
|
-
if (item.expanded && !isNOU(index) && (!this.enablePersistence)) {
|
|
844
|
-
if (this.initExpand.indexOf(index) === -1) {
|
|
845
|
-
this.initExpand.push(index);
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
if (item.cssClass) {
|
|
849
|
-
addClass([innerEle], item.cssClass.split(' '));
|
|
850
|
-
}
|
|
851
|
-
if (item.disabled) {
|
|
852
|
-
addClass([innerEle], CLS_DISABLE);
|
|
853
|
-
}
|
|
854
|
-
if (item.visible === false) {
|
|
855
|
-
addClass([innerEle], CLS_ITEMHIDE);
|
|
856
|
-
}
|
|
857
|
-
if (item.iconCss) {
|
|
858
|
-
const hdrIcnEle: HTEle = this.createElement('div', { className: CLS_HEADERICN });
|
|
859
|
-
const icon: HTEle = this.createElement('span', { className: item.iconCss + ' e-icons' });
|
|
860
|
-
hdrIcnEle.appendChild(icon);
|
|
861
|
-
if (isNOU(hdr)) {
|
|
862
|
-
hdr = this.headerEleGenerate();
|
|
863
|
-
hdr.appendChild(hdrIcnEle);
|
|
864
|
-
innerEle.appendChild(hdr);
|
|
865
|
-
} else {
|
|
866
|
-
hdr.insertBefore(hdrIcnEle, hdr.childNodes[0]);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
if (item.content && this.angularnativeCondiCheck(item, 'content')) {
|
|
870
|
-
const hdrIcon: HTEle = this.toggleIconGenerate();
|
|
871
|
-
if (isNOU(hdr)) {
|
|
872
|
-
hdr = this.headerEleGenerate();
|
|
873
|
-
innerEle.appendChild(hdr);
|
|
874
|
-
}
|
|
875
|
-
hdr.appendChild(hdrIcon);
|
|
876
|
-
this.add(innerEle, CLS_SLCT);
|
|
877
|
-
}
|
|
878
|
-
return innerEle;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
private angularnativeCondiCheck(item: AccordionItemModel, prop: string): boolean {
|
|
882
|
-
const property: string = prop === 'content' ? item.content : item.header;
|
|
883
|
-
const content: AcrdnTemplateRef = (property as Object) as AcrdnTemplateRef;
|
|
884
|
-
if (this.isAngular && !isNOU(content.elementRef)) {
|
|
885
|
-
const data: string = content.elementRef.nativeElement.data;
|
|
886
|
-
if (isNOU(data) || data === '' || (data.indexOf('bindings=') === -1)) {
|
|
887
|
-
return true;
|
|
888
|
-
}
|
|
889
|
-
const parseddata: { [key: string]: string } = JSON.parse(content.elementRef.nativeElement.data.replace('bindings=', ''));
|
|
890
|
-
if (!isNOU(parseddata) && parseddata['ng-reflect-ng-if'] === 'false') {
|
|
891
|
-
return false;
|
|
892
|
-
} else {
|
|
893
|
-
return true;
|
|
894
|
-
}
|
|
895
|
-
} else {
|
|
896
|
-
return true;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
private fetchElement(ele: HTEle, value: Str, index: number): HTEle {
|
|
901
|
-
let templateFn: Function;
|
|
902
|
-
let temString: Str;
|
|
903
|
-
try {
|
|
904
|
-
if (document.querySelectorAll(value).length && value !== 'Button') {
|
|
905
|
-
const eleVal: HTEle = <HTEle>document.querySelector(value);
|
|
906
|
-
temString = eleVal.outerHTML.trim();
|
|
907
|
-
ele.appendChild(eleVal);
|
|
908
|
-
eleVal.style.display = '';
|
|
909
|
-
} else {
|
|
910
|
-
templateFn = templateCompiler(value);
|
|
911
|
-
}
|
|
912
|
-
} catch (e) {
|
|
913
|
-
if (typeof (value) === 'string') {
|
|
914
|
-
ele.innerHTML = this.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(value) : value;
|
|
915
|
-
} else if ((value as any) instanceof (HTMLElement)) {
|
|
916
|
-
ele.appendChild(value as HTMLElement);
|
|
917
|
-
if (this.trgtEle) {
|
|
918
|
-
(<HTMLElement>ele.firstElementChild).style.display = '';
|
|
919
|
-
}
|
|
920
|
-
} else {
|
|
921
|
-
templateFn = templateCompiler(value);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
let tempArray: HTEle[];
|
|
925
|
-
if (!isNOU(templateFn)) {
|
|
926
|
-
if (this.isReact) {
|
|
927
|
-
this.renderReactTemplates();
|
|
928
|
-
}
|
|
929
|
-
let templateProps: string;
|
|
930
|
-
let templateName: string;
|
|
931
|
-
if (ele.classList.contains(CLS_HEADERCTN)) {
|
|
932
|
-
templateProps = this.element.id + index + '_header';
|
|
933
|
-
templateName = 'header';
|
|
934
|
-
} else if (ele.classList.contains(CLS_CTENT)) {
|
|
935
|
-
templateProps = this.element.id + index + '_content';
|
|
936
|
-
templateName = 'content';
|
|
937
|
-
}
|
|
938
|
-
tempArray = templateFn({}, this, templateName, templateProps, this.isStringTemplate);
|
|
939
|
-
}
|
|
940
|
-
if (!isNOU(tempArray) && tempArray.length > 0 && !(isNOU(tempArray[0].tagName) && tempArray.length === 1)) {
|
|
941
|
-
[].slice.call(tempArray).forEach((el: HTEle): void => {
|
|
942
|
-
if (!isNOU(el.tagName)) {
|
|
943
|
-
el.style.display = '';
|
|
944
|
-
}
|
|
945
|
-
ele.appendChild(el);
|
|
946
|
-
});
|
|
947
|
-
} else if (ele.childElementCount === 0) {
|
|
948
|
-
ele.innerHTML = this.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(value) : value;
|
|
949
|
-
}
|
|
950
|
-
if (!isNOU(temString)) {
|
|
951
|
-
if (this.templateEle.indexOf(value) === -1) {
|
|
952
|
-
this.templateEle.push(value);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
return ele;
|
|
956
|
-
}
|
|
957
|
-
private ariaAttrUpdate(itemEle: HTEle): void {
|
|
958
|
-
const header: Element = select('.' + CLS_HEADER, itemEle);
|
|
959
|
-
const content: Element = select('.' + CLS_CONTENT, itemEle);
|
|
960
|
-
header.setAttribute('aria-controls', content.id);
|
|
961
|
-
content.setAttribute('aria-labelledby', header.id);
|
|
962
|
-
content.setAttribute('role', 'region');
|
|
963
|
-
}
|
|
964
|
-
private contentRendering(index: number): HTEle {
|
|
965
|
-
const itemcnt: HTEle = this.createElement('div', { className: CLS_CONTENT + ' ' + CLS_CTNHIDE, id: getUniqueID('acrdn_panel') });
|
|
966
|
-
attributes(itemcnt, { 'aria-hidden': 'true' });
|
|
967
|
-
const ctn: HTEle = this.createElement('div', { className: CLS_CTENT });
|
|
968
|
-
if (!isNOU(this.dataSource) && this.dataSource.length > 0) {
|
|
969
|
-
if (this.isReact) {
|
|
970
|
-
this.renderReactTemplates();
|
|
971
|
-
}
|
|
972
|
-
append(this.getItemTemplate()(this.dataSource[parseInt(index.toString(), 10)], this, 'itemTemplate', this.element.id + '_itemTemplate', false), ctn);
|
|
973
|
-
itemcnt.appendChild(ctn);
|
|
974
|
-
} else {
|
|
975
|
-
let content: string = this.items[parseInt(index.toString(), 10)].content;
|
|
976
|
-
if (this.enableHtmlSanitizer && typeof (content) === 'string') {
|
|
977
|
-
content = SanitizeHtmlHelper.sanitize(content);
|
|
978
|
-
}
|
|
979
|
-
itemcnt.appendChild(this.fetchElement(ctn, content, index));
|
|
980
|
-
}
|
|
981
|
-
return itemcnt;
|
|
982
|
-
}
|
|
983
|
-
private expand(trgt: HTEle): void {
|
|
984
|
-
const items: Object[] = this.getItems();
|
|
985
|
-
const trgtItemEle: HTEle = <HTEle>closest(trgt, '.' + CLS_ITEM);
|
|
986
|
-
if (isNOU(trgt) || (isVisible(trgt) && trgt.getAttribute('e-animate') !== 'true') || trgtItemEle.classList.contains(CLS_DISABLE)) {
|
|
987
|
-
return;
|
|
988
|
-
}
|
|
989
|
-
const acrdnRoot: HTEle = <HTEle>closest(trgtItemEle, '.' + CLS_ACRDN_ROOT);
|
|
990
|
-
const expandState: HTEle = <HTEle>acrdnRoot.querySelector('.' + CLS_EXPANDSTATE);
|
|
991
|
-
const animation: AnimationModel = {
|
|
992
|
-
name: <Effect>this.animation.expand.effect,
|
|
993
|
-
duration: this.animation.expand.duration,
|
|
994
|
-
timingFunction: this.animation.expand.easing
|
|
995
|
-
};
|
|
996
|
-
const icon: HTEle = <HTEle>select('.' + CLS_TOOGLEICN, trgtItemEle).firstElementChild;
|
|
997
|
-
const eventArgs: ExpandEventArgs = {
|
|
998
|
-
element: trgtItemEle,
|
|
999
|
-
item: items[this.getIndexByItem(trgtItemEle)],
|
|
1000
|
-
index: this.getIndexByItem(trgtItemEle),
|
|
1001
|
-
content: trgtItemEle.querySelector('.' + CLS_CONTENT),
|
|
1002
|
-
isExpanded: true
|
|
1003
|
-
};
|
|
1004
|
-
this.trigger('expanding', eventArgs, (expandArgs: ExpandEventArgs) => {
|
|
1005
|
-
if (!expandArgs.cancel) {
|
|
1006
|
-
icon.classList.add(CLS_TOGANIMATE);
|
|
1007
|
-
this.expandedItemsPush(trgtItemEle);
|
|
1008
|
-
if (!isNOU(expandState)) {
|
|
1009
|
-
expandState.classList.remove(CLS_EXPANDSTATE);
|
|
1010
|
-
}
|
|
1011
|
-
trgtItemEle.classList.add(CLS_EXPANDSTATE);
|
|
1012
|
-
if ((animation.name === <Effect>'None' && animationMode !== 'Enable') || (animationMode === 'Disable')) {
|
|
1013
|
-
this.expandProgress('begin', icon, trgt, trgtItemEle, expandArgs);
|
|
1014
|
-
this.expandProgress('end', icon, trgt, trgtItemEle, expandArgs);
|
|
1015
|
-
} else {
|
|
1016
|
-
this.expandAnimation(animation.name, icon, trgt, trgtItemEle, animation, expandArgs);
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
private expandAnimation(ef: Str, icn: HTEle, trgt: HTEle, trgtItemEle: HTEle, animate: AnimationModel, args: ExpandEventArgs): void {
|
|
1022
|
-
if (ef === 'None' && animationMode === 'Enable'){
|
|
1023
|
-
ef = 'SlideDown';
|
|
1024
|
-
animate.name = 'SlideDown';
|
|
1025
|
-
}
|
|
1026
|
-
let height: number;
|
|
1027
|
-
this.lastActiveItemId = trgtItemEle.id;
|
|
1028
|
-
if (ef === 'SlideDown') {
|
|
1029
|
-
animate.begin = () => {
|
|
1030
|
-
this.expandProgress('begin', icn, trgt, trgtItemEle, args);
|
|
1031
|
-
trgt.style.position = 'absolute';
|
|
1032
|
-
height = trgtItemEle.offsetHeight;
|
|
1033
|
-
trgt.style.maxHeight = (trgt.offsetHeight) + 'px';
|
|
1034
|
-
trgtItemEle.style.maxHeight = '';
|
|
1035
|
-
};
|
|
1036
|
-
animate.progress = () => {
|
|
1037
|
-
trgtItemEle.style.minHeight = (height + trgt.offsetHeight) + 'px';
|
|
1038
|
-
};
|
|
1039
|
-
animate.end = () => {
|
|
1040
|
-
setStyle(trgt, { 'position': '', 'maxHeight': '' });
|
|
1041
|
-
trgtItemEle.style.minHeight = '';
|
|
1042
|
-
this.expandProgress('end', icn, trgt, trgtItemEle, args);
|
|
1043
|
-
};
|
|
1044
|
-
} else {
|
|
1045
|
-
animate.begin = () => {
|
|
1046
|
-
this.expandProgress('begin', icn, trgt, trgtItemEle, args);
|
|
1047
|
-
};
|
|
1048
|
-
animate.end = () => {
|
|
1049
|
-
this.expandProgress('end', icn, trgt, trgtItemEle, args);
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
new Animation(animate).animate(trgt);
|
|
1053
|
-
}
|
|
1054
|
-
private expandProgress(progress: string, icon: HTEle, trgt: HTEle, trgtItemEle: HTEle, eventArgs: ExpandEventArgs): void {
|
|
1055
|
-
this.remove(trgt, CLS_CTNHIDE);
|
|
1056
|
-
this.add(trgtItemEle, CLS_SLCTED);
|
|
1057
|
-
this.add(icon, CLS_EXPANDICN);
|
|
1058
|
-
if (progress === 'end') {
|
|
1059
|
-
this.add(trgtItemEle, CLS_ACTIVE);
|
|
1060
|
-
trgt.setAttribute('aria-hidden', 'false');
|
|
1061
|
-
attributes(trgt.previousElementSibling, { 'aria-expanded': 'true' });
|
|
1062
|
-
icon.classList.remove(CLS_TOGANIMATE);
|
|
1063
|
-
this.trigger('expanded', eventArgs);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
private expandedItemsPush(item: HTEle): void {
|
|
1067
|
-
const index: number = this.getIndexByItem(item);
|
|
1068
|
-
if (this.expandedIndices.indexOf(index) === -1) {
|
|
1069
|
-
const temp: number[] = [].slice.call(this.expandedIndices);
|
|
1070
|
-
temp.push(index);
|
|
1071
|
-
this.setProperties({ expandedIndices: temp }, true);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
private getIndexByItem(item: HTEle): number {
|
|
1075
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1076
|
-
return [].slice.call(itemEle).indexOf(item);
|
|
1077
|
-
}
|
|
1078
|
-
private getItemElements(): HTEle[] {
|
|
1079
|
-
const itemEle: HTEle[] = [];
|
|
1080
|
-
const itemCollection: HTMLCollection = this.element.children;
|
|
1081
|
-
[].slice.call(itemCollection).forEach((el: HTEle) => {
|
|
1082
|
-
if (el.classList.contains(CLS_ITEM)) {
|
|
1083
|
-
itemEle.push(el);
|
|
1084
|
-
}
|
|
1085
|
-
});
|
|
1086
|
-
return itemEle;
|
|
1087
|
-
}
|
|
1088
|
-
private expandedItemsPop(item: HTEle): void {
|
|
1089
|
-
const index: number = this.getIndexByItem(item);
|
|
1090
|
-
const temp: number[] = [].slice.call(this.expandedIndices);
|
|
1091
|
-
temp.splice(temp.indexOf(index), 1);
|
|
1092
|
-
this.setProperties({ expandedIndices: temp }, true);
|
|
1093
|
-
}
|
|
1094
|
-
private collapse(trgt: HTEle): void {
|
|
1095
|
-
if (isNOU(trgt)) { return; }
|
|
1096
|
-
const items: Object[] = this.getItems();
|
|
1097
|
-
const trgtItemEle: HTEle = <HTEle>closest(trgt, '.' + CLS_ITEM);
|
|
1098
|
-
if (!isVisible(trgt) || trgtItemEle.classList.contains(CLS_DISABLE)) {
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
const animation: AnimationModel = {
|
|
1102
|
-
name: <Effect>this.animation.collapse.effect,
|
|
1103
|
-
duration: this.animation.collapse.duration,
|
|
1104
|
-
timingFunction: this.animation.collapse.easing
|
|
1105
|
-
};
|
|
1106
|
-
const icon: HTEle = <HTEle>select('.' + CLS_TOOGLEICN, trgtItemEle).firstElementChild;
|
|
1107
|
-
const eventArgs: ExpandEventArgs = {
|
|
1108
|
-
element: trgtItemEle,
|
|
1109
|
-
item: items[this.getIndexByItem(trgtItemEle)],
|
|
1110
|
-
index: this.getIndexByItem(trgtItemEle),
|
|
1111
|
-
content: trgtItemEle.querySelector('.' + CLS_CONTENT),
|
|
1112
|
-
isExpanded: false
|
|
1113
|
-
};
|
|
1114
|
-
this.trigger('expanding', eventArgs, (expandArgs: ExpandEventArgs) => {
|
|
1115
|
-
if (!expandArgs.cancel) {
|
|
1116
|
-
this.expandedItemsPop(trgtItemEle);
|
|
1117
|
-
trgtItemEle.classList.remove(CLS_EXPANDSTATE);
|
|
1118
|
-
icon.classList.add(CLS_TOGANIMATE);
|
|
1119
|
-
if ((animation.name === <Effect>'None' && animationMode !== 'Enable') || (animationMode === 'Disable')) {
|
|
1120
|
-
this.collapseProgress('begin', icon, trgt, trgtItemEle, expandArgs);
|
|
1121
|
-
this.collapseProgress('end', icon, trgt, trgtItemEle, expandArgs);
|
|
1122
|
-
} else {
|
|
1123
|
-
this.collapseAnimation(animation.name, trgt, trgtItemEle, icon, animation, expandArgs);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
private collapseAnimation(ef: Str, trgt: HTEle, trgtItEl: HTEle, icn: HTEle, animate: AnimationModel, args: ExpandEventArgs): void {
|
|
1129
|
-
if (ef === 'None' && animationMode === 'Enable') {
|
|
1130
|
-
ef = 'SlideUp';
|
|
1131
|
-
animate.name = 'SlideUp';
|
|
1132
|
-
}
|
|
1133
|
-
let height: number;
|
|
1134
|
-
let trgtHeight: number;
|
|
1135
|
-
let itemHeight: number;
|
|
1136
|
-
let remain: number;
|
|
1137
|
-
this.lastActiveItemId = trgtItEl.id;
|
|
1138
|
-
if (ef === 'SlideUp') {
|
|
1139
|
-
animate.begin = () => {
|
|
1140
|
-
itemHeight = trgtItEl.offsetHeight;
|
|
1141
|
-
trgtItEl.style.minHeight = itemHeight + 'px';
|
|
1142
|
-
trgt.style.position = 'absolute';
|
|
1143
|
-
height = trgtItEl.offsetHeight;
|
|
1144
|
-
trgtHeight = trgt.offsetHeight;
|
|
1145
|
-
trgt.style.maxHeight = trgtHeight + 'px';
|
|
1146
|
-
this.collapseProgress('begin', icn, trgt, trgtItEl, args);
|
|
1147
|
-
};
|
|
1148
|
-
animate.progress = () => {
|
|
1149
|
-
remain = ((height - (trgtHeight - trgt.offsetHeight)));
|
|
1150
|
-
if (remain < itemHeight) {
|
|
1151
|
-
trgtItEl.style.minHeight = remain + 'px';
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
animate.end = () => {
|
|
1155
|
-
trgt.style.display = 'none';
|
|
1156
|
-
this.collapseProgress('end', icn, trgt, trgtItEl, args);
|
|
1157
|
-
trgtItEl.style.minHeight = '';
|
|
1158
|
-
setStyle(trgt, { 'position': '', 'maxHeight': '', 'display': '' });
|
|
1159
|
-
};
|
|
1160
|
-
} else {
|
|
1161
|
-
animate.begin = () => {
|
|
1162
|
-
this.collapseProgress('begin', icn, trgt, trgtItEl, args);
|
|
1163
|
-
};
|
|
1164
|
-
animate.end = () => {
|
|
1165
|
-
this.collapseProgress('end', icn, trgt, trgtItEl, args);
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
new Animation(animate).animate(trgt);
|
|
1169
|
-
}
|
|
1170
|
-
private collapseProgress(progress: string, icon: HTEle, trgt: HTEle, trgtItemEle: HTEle, eventArgs: ExpandEventArgs): void {
|
|
1171
|
-
this.remove(icon, CLS_EXPANDICN);
|
|
1172
|
-
this.remove(trgtItemEle, CLS_SLCTED);
|
|
1173
|
-
if (progress === 'end') {
|
|
1174
|
-
this.add(trgt, CLS_CTNHIDE);
|
|
1175
|
-
icon.classList.remove(CLS_TOGANIMATE);
|
|
1176
|
-
this.remove(trgtItemEle, CLS_ACTIVE);
|
|
1177
|
-
trgt.setAttribute('aria-hidden', 'true');
|
|
1178
|
-
attributes(trgt.previousElementSibling, { 'aria-expanded': 'false' });
|
|
1179
|
-
this.trigger('expanded', eventArgs);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Returns the current module name.
|
|
1184
|
-
*
|
|
1185
|
-
* @returns {string} - It returns the current module name.
|
|
1186
|
-
* @private
|
|
1187
|
-
*/
|
|
1188
|
-
protected getModuleName(): string {
|
|
1189
|
-
return 'accordion';
|
|
1190
|
-
}
|
|
1191
|
-
private getItems(): Object[] {
|
|
1192
|
-
let items: AccordionItemModel[] | Object[];
|
|
1193
|
-
if (this.itemTemplate && this.headerTemplate) {
|
|
1194
|
-
items = this.dataSource;
|
|
1195
|
-
} else {
|
|
1196
|
-
items = this.items;
|
|
1197
|
-
}
|
|
1198
|
-
return items;
|
|
1199
|
-
}
|
|
1200
|
-
/**
|
|
1201
|
-
* Adds new item to the Accordion with the specified index of the Accordion.
|
|
1202
|
-
*
|
|
1203
|
-
* @param {AccordionItemModel | AccordionItemModel[] | Object | Object[]} item - Item array that is to be added to the Accordion.
|
|
1204
|
-
* @param {number} index - Number value that determines where the item should be added.
|
|
1205
|
-
* By default, item is added at the last index if the index is not specified.
|
|
1206
|
-
* @returns {void}
|
|
1207
|
-
*/
|
|
1208
|
-
public addItem(item: AccordionItemModel | AccordionItemModel[] | Object | Object[], index?: number): void {
|
|
1209
|
-
const ele: HTEle = this.element;
|
|
1210
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1211
|
-
const items: Object[] = this.getItems();
|
|
1212
|
-
if (isNOU(index)) {
|
|
1213
|
-
index = items.length;
|
|
1214
|
-
}
|
|
1215
|
-
if (ele.childElementCount >= index) {
|
|
1216
|
-
const addItems: AccordionItemModel[] = (item instanceof Array) ? item : [item];
|
|
1217
|
-
addItems.forEach((addItem: AccordionItemModel, i: number) => {
|
|
1218
|
-
const itemIndex: number = index + i;
|
|
1219
|
-
items.splice(itemIndex, 0, addItem);
|
|
1220
|
-
const innerItemEle: HTEle = this.renderInnerItem(addItem, itemIndex);
|
|
1221
|
-
if (ele.childElementCount === itemIndex) {
|
|
1222
|
-
ele.appendChild(innerItemEle);
|
|
1223
|
-
} else {
|
|
1224
|
-
ele.insertBefore(innerItemEle, itemEle[parseInt(itemIndex.toString(), 10)]);
|
|
1225
|
-
}
|
|
1226
|
-
EventHandler.add(innerItemEle.querySelector('.' + CLS_HEADER), 'focus', this.focusIn, this);
|
|
1227
|
-
EventHandler.add(innerItemEle.querySelector('.' + CLS_HEADER), 'blur', this.focusOut, this);
|
|
1228
|
-
this.expandedIndices = [];
|
|
1229
|
-
this.expandedItemRefresh();
|
|
1230
|
-
if (addItem && (addItem as AccordionItemModel).expanded) {
|
|
1231
|
-
this.expandItem(true, itemIndex);
|
|
1232
|
-
}
|
|
1233
|
-
});
|
|
1234
|
-
}
|
|
1235
|
-
if (this.isReact) {
|
|
1236
|
-
this.renderReactTemplates();
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
private expandedItemRefresh(): void {
|
|
1240
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1241
|
-
[].slice.call(itemEle).forEach((el: HTEle) => {
|
|
1242
|
-
if (el.classList.contains(CLS_SLCTED)) {
|
|
1243
|
-
this.expandedItemsPush(el);
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* Dynamically removes item from Accordion.
|
|
1249
|
-
*
|
|
1250
|
-
* @param {number} index - Number value that determines which item should be removed.
|
|
1251
|
-
* @returns {void}.
|
|
1252
|
-
*/
|
|
1253
|
-
public removeItem(index: number): void {
|
|
1254
|
-
if (this.isReact || this.isAngular) {
|
|
1255
|
-
const item: HTEle = <HTEle>selectAll('.' + CLS_ITEM, this.element)[parseInt(index.toString(), 10)];
|
|
1256
|
-
const header: HTEle = <HTEle>select('.' + CLS_HEADERCTN, item);
|
|
1257
|
-
const content: HTEle = <HTEle>select('.' + CLS_CTENT, item);
|
|
1258
|
-
this.clearAccordionTemplate(header, this.dataSource.length > 0 ? 'headerTemplate' : 'header', CLS_HEADERCTN);
|
|
1259
|
-
this.clearAccordionTemplate(content, this.dataSource.length > 0 ? 'itemTemplate' : 'content', CLS_CTENT);
|
|
1260
|
-
}
|
|
1261
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1262
|
-
const ele: HTEle = <HTEle>itemEle[parseInt(index.toString(), 10)];
|
|
1263
|
-
const items: Object[] = this.getItems();
|
|
1264
|
-
if (isNOU(ele)) {
|
|
1265
|
-
return;
|
|
1266
|
-
}
|
|
1267
|
-
this.restoreContent(index);
|
|
1268
|
-
detach(ele);
|
|
1269
|
-
items.splice(index, 1);
|
|
1270
|
-
this.expandedIndices = [];
|
|
1271
|
-
this.expandedItemRefresh();
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Sets focus to the specified index item header in Accordion.
|
|
1275
|
-
*
|
|
1276
|
-
* @param {number} index - Number value that determines which item should be focused.
|
|
1277
|
-
* @returns {void}.
|
|
1278
|
-
*/
|
|
1279
|
-
public select(index: number): void {
|
|
1280
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1281
|
-
const ele: HTEle = <HTEle>itemEle[parseInt(index.toString(), 10)];
|
|
1282
|
-
if (isNOU(ele) || isNOU(select('.' + CLS_HEADER, ele))) {
|
|
1283
|
-
return;
|
|
1284
|
-
}
|
|
1285
|
-
(<HTEle>ele.children[0]).focus();
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* Shows or hides the specified item from Accordion.
|
|
1289
|
-
*
|
|
1290
|
-
* @param {number} index - Number value that determines which item should be hidden/shown.
|
|
1291
|
-
* @param {boolean} isHidden - Boolean value that determines the action either hide (true) or show (false). Default value is false.
|
|
1292
|
-
* If the `isHidden` value is false, the item is shown or else item it is hidden.
|
|
1293
|
-
* @returns {void}.
|
|
1294
|
-
*/
|
|
1295
|
-
public hideItem(index: number, isHidden?: boolean): void {
|
|
1296
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1297
|
-
const ele: HTEle = <HTEle>itemEle[parseInt(index.toString(), 10)];
|
|
1298
|
-
if (isNOU(ele)) {
|
|
1299
|
-
return;
|
|
1300
|
-
}
|
|
1301
|
-
if (isNOU(isHidden)) {
|
|
1302
|
-
isHidden = true;
|
|
1303
|
-
}
|
|
1304
|
-
if (isHidden) {
|
|
1305
|
-
this.add(ele, CLS_ITEMHIDE);
|
|
1306
|
-
} else {
|
|
1307
|
-
this.remove(ele, CLS_ITEMHIDE);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
/**
|
|
1311
|
-
* Enables/Disables the specified Accordion item.
|
|
1312
|
-
*
|
|
1313
|
-
* @param {number} index - Number value that determines which item should be enabled/disabled.
|
|
1314
|
-
* @param {boolean} isEnable - Boolean value that determines the action as enable (true) or disable (false).
|
|
1315
|
-
* If the `isEnable` value is true, the item is enabled or else it is disabled.
|
|
1316
|
-
* @returns {void}.
|
|
1317
|
-
*/
|
|
1318
|
-
public enableItem(index: number, isEnable: boolean): void {
|
|
1319
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1320
|
-
const ele: HTEle = <HTEle>itemEle[parseInt(index.toString(), 10)];
|
|
1321
|
-
if (isNOU(ele)) {
|
|
1322
|
-
return;
|
|
1323
|
-
}
|
|
1324
|
-
const eleHeader: HTEle = <HTEle>ele.firstElementChild;
|
|
1325
|
-
if (isEnable) {
|
|
1326
|
-
this.remove(ele, CLS_DISABLE);
|
|
1327
|
-
attributes(eleHeader, { 'tabindex': '0', 'aria-disabled': 'false' });
|
|
1328
|
-
eleHeader.focus();
|
|
1329
|
-
} else {
|
|
1330
|
-
if (ele.classList.contains(CLS_ACTIVE)) {
|
|
1331
|
-
this.expandItem(false, index);
|
|
1332
|
-
this.eleMoveFocus('movedown', this.element, eleHeader);
|
|
1333
|
-
}
|
|
1334
|
-
this.add(ele, CLS_DISABLE);
|
|
1335
|
-
eleHeader.setAttribute('aria-disabled', 'true');
|
|
1336
|
-
eleHeader.removeAttribute('tabindex');
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
/**
|
|
1340
|
-
* Expands/Collapses the specified Accordion item.
|
|
1341
|
-
*
|
|
1342
|
-
* @param {boolean} isExpand - Boolean value that determines the action as expand or collapse.
|
|
1343
|
-
* @param {number} index - Number value that determines which item should be expanded/collapsed.`index` is optional parameter.
|
|
1344
|
-
* Without Specifying index, based on the `isExpand` value all Accordion item can be expanded or collapsed.
|
|
1345
|
-
* @returns {void}.
|
|
1346
|
-
*/
|
|
1347
|
-
public expandItem(isExpand: boolean, index?: number): void {
|
|
1348
|
-
const itemEle: HTEle[] = this.getItemElements();
|
|
1349
|
-
if (isNOU(index)) {
|
|
1350
|
-
if (this.expandMode === 'Single' && isExpand) {
|
|
1351
|
-
const ele: HTEle = <HTEle>itemEle[itemEle.length - 1];
|
|
1352
|
-
this.itemExpand(isExpand, ele, this.getIndexByItem(ele));
|
|
1353
|
-
} else {
|
|
1354
|
-
const item: HTMLElement = <HTMLElement>select('#' + this.lastActiveItemId, this.element);
|
|
1355
|
-
[].slice.call(itemEle).forEach((el: HTEle) => {
|
|
1356
|
-
this.itemExpand(isExpand, el, this.getIndexByItem(el));
|
|
1357
|
-
el.classList.remove(CLS_EXPANDSTATE);
|
|
1358
|
-
});
|
|
1359
|
-
const expandedItem: Element = select('.' + CLS_EXPANDSTATE, this.element);
|
|
1360
|
-
if (expandedItem) {
|
|
1361
|
-
expandedItem.classList.remove(CLS_EXPANDSTATE);
|
|
1362
|
-
}
|
|
1363
|
-
if (item) {
|
|
1364
|
-
item.classList.add(CLS_EXPANDSTATE);
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
} else {
|
|
1368
|
-
const ele: HTEle = <HTEle>itemEle[parseInt(index.toString(), 10)];
|
|
1369
|
-
if (isNOU(ele) || !ele.classList.contains(CLS_SLCT) || (ele.classList.contains(CLS_ACTIVE) && isExpand)) {
|
|
1370
|
-
return;
|
|
1371
|
-
} else {
|
|
1372
|
-
if (this.expandMode === 'Single') {
|
|
1373
|
-
this.expandItem(false);
|
|
1374
|
-
}
|
|
1375
|
-
this.itemExpand(isExpand, ele, index);
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
private itemExpand(isExpand: boolean, ele: HTEle, index: number): void {
|
|
1380
|
-
let ctn: HTEle = <HTEle>ele.children[1];
|
|
1381
|
-
if (ele.classList.contains(CLS_DISABLE)) {
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
if (isNOU(ctn) && isExpand) {
|
|
1385
|
-
ctn = this.contentRendering(index);
|
|
1386
|
-
ele.appendChild(ctn);
|
|
1387
|
-
this.ariaAttrUpdate(ele);
|
|
1388
|
-
this.expand(ctn);
|
|
1389
|
-
} else if (!isNOU(ctn)) {
|
|
1390
|
-
if (isExpand) {
|
|
1391
|
-
this.expand(ctn);
|
|
1392
|
-
} else {
|
|
1393
|
-
this.collapse(ctn);
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
if (this.isReact) {
|
|
1397
|
-
this.renderReactTemplates();
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
private destroyItems(): void {
|
|
1401
|
-
this.restoreContent(null);
|
|
1402
|
-
if (this.isReact || this.isAngular || this.isVue) {
|
|
1403
|
-
this.clearTemplate();
|
|
1404
|
-
}
|
|
1405
|
-
[].slice.call(this.element.querySelectorAll('.' + CLS_ITEM)).forEach((el: HTEle) => {
|
|
1406
|
-
detach(el);
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
private restoreContent(index: number): void {
|
|
1410
|
-
let ctnElePos: HTMLElement;
|
|
1411
|
-
if (isNOU(index)) {
|
|
1412
|
-
ctnElePos = this.element;
|
|
1413
|
-
} else {
|
|
1414
|
-
ctnElePos = <HTMLElement>this.element.querySelectorAll('.' + CLS_ITEM)[parseInt(index.toString(), 10)];
|
|
1415
|
-
}
|
|
1416
|
-
this.templateEle.forEach((eleStr: Str): void => {
|
|
1417
|
-
if (!isNOU(ctnElePos.querySelector(eleStr))) {
|
|
1418
|
-
(<HTEle>document.body.appendChild(ctnElePos.querySelector(eleStr))).style.display = 'none';
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
private updateItem(item: HTEle, index: number): void {
|
|
1423
|
-
if (!isNOU(item)) {
|
|
1424
|
-
const items: Object[] = this.getItems();
|
|
1425
|
-
const itemObj: Object = items[parseInt(index.toString(), 10)];
|
|
1426
|
-
items.splice(index, 1);
|
|
1427
|
-
this.restoreContent(index);
|
|
1428
|
-
const header: HTEle = <HTEle>select('.' + CLS_HEADERCTN, item);
|
|
1429
|
-
const content: HTEle = <HTEle>select('.' + CLS_CTENT, item);
|
|
1430
|
-
if (this.isReact || this.isAngular) {
|
|
1431
|
-
this.clearAccordionTemplate(header, 'header', CLS_HEADERCTN);
|
|
1432
|
-
this.clearAccordionTemplate(content, 'content', CLS_CTENT);
|
|
1433
|
-
}
|
|
1434
|
-
detach(item);
|
|
1435
|
-
this.addItem(itemObj, index);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
private setTemplate(template: string | HTMLElement, toElement: HTMLElement, index: number): void {
|
|
1439
|
-
this.fetchElement(toElement, template as string, index);
|
|
1440
|
-
if (this.isReact) {
|
|
1441
|
-
this.renderReactTemplates();
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
private clearAccordionTemplate(templateEle: HTMLElement, templateName: string, className: string): void {
|
|
1445
|
-
if ((this as Record<string, any>).registeredTemplate && (this as Record<string, any>).registeredTemplate[`${templateName}`]) {
|
|
1446
|
-
const registeredTemplates: Record<string, any> = (this as Record<string, any>).registeredTemplate;
|
|
1447
|
-
for (let index: number = 0; index < registeredTemplates[`${templateName}`].length; index++) {
|
|
1448
|
-
const registeredItem: Element = registeredTemplates[`${templateName}`][parseInt(index.toString(), 10)].rootNodes[0];
|
|
1449
|
-
const closestItem: Element = closest(registeredItem, '.' + className);
|
|
1450
|
-
if (!isNOU(closestItem) && closestItem === templateEle || isNOU(registeredItem.parentNode)) {
|
|
1451
|
-
this.clearTemplate([templateName], [registeredTemplates[`${templateName}`][parseInt(index.toString(), 10)]]);
|
|
1452
|
-
break;
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
} else if ((this as Record<string, any>).portals && (this as Record<string, any>).portals.length > 0) {
|
|
1456
|
-
const portals: Record<string, any>[] = (this as Record<string, any>).portals;
|
|
1457
|
-
for (let index: number = 0; index < portals.length; index++) {
|
|
1458
|
-
const portalItem: Record<string, any> = portals[parseInt(index.toString(), 10)];
|
|
1459
|
-
const closestItem: Element = closest(portalItem.containerInfo, '.' + className);
|
|
1460
|
-
if (!isNOU(closestItem) && closestItem === templateEle) {
|
|
1461
|
-
this.clearTemplate([templateName], index);
|
|
1462
|
-
break;
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
protected getPersistData(): string {
|
|
1468
|
-
const keyEntity: string[] = ['expandedIndices'];
|
|
1469
|
-
return this.addOnPersist(keyEntity);
|
|
1470
|
-
}
|
|
1471
|
-
/**
|
|
1472
|
-
* Gets called when the model property changes.The data that describes the old and new values of the property that changed.
|
|
1473
|
-
*
|
|
1474
|
-
* @param {AccordionModel} newProp - It contains the new value of data.
|
|
1475
|
-
* @param {AccordionModel} oldProp - It contains the old value of data.
|
|
1476
|
-
* @returns {void}
|
|
1477
|
-
* @private
|
|
1478
|
-
*/
|
|
1479
|
-
public onPropertyChanged(newProp: AccordionModel, oldProp: AccordionModel): void {
|
|
1480
|
-
const acrdn: HTEle = this.element;
|
|
1481
|
-
let isRefresh: boolean = false;
|
|
1482
|
-
for (const prop of Object.keys(newProp)) {
|
|
1483
|
-
switch (prop) {
|
|
1484
|
-
case 'items':
|
|
1485
|
-
if (!(newProp.items instanceof Array && oldProp.items instanceof Array)) {
|
|
1486
|
-
const changedProp: Object[] = Object.keys(newProp.items);
|
|
1487
|
-
for (let j: number = 0; j < changedProp.length; j++) {
|
|
1488
|
-
const index: number = parseInt(Object.keys(newProp.items)[parseInt(j.toString(), 10)], 10);
|
|
1489
|
-
const property: Str[] = Object.keys(newProp.items[parseInt(index.toString(), 10)]);
|
|
1490
|
-
for (let k: number = 0; k < property.length; k++) {
|
|
1491
|
-
const item: HTEle = <HTEle>selectAll('.' + CLS_ITEM, this.element)[parseInt(index.toString(), 10)];
|
|
1492
|
-
const oldVal: Str = Object(oldProp.items[parseInt(index.toString(), 10)])[`${property[parseInt(k.toString(), 10)]}`];
|
|
1493
|
-
const newVal: Str = Object(newProp.items[parseInt(index.toString(), 10)])[`${property[parseInt(k.toString(), 10)]}`];
|
|
1494
|
-
const temp: Str = property[parseInt(k.toString(), 10)];
|
|
1495
|
-
const content: HTEle = <HTEle>select('.' + CLS_CTENT, item);
|
|
1496
|
-
if (temp === 'header' || temp === 'iconCss' || temp === 'expanded' || ((temp === 'content') && (oldVal === ''))) {
|
|
1497
|
-
this.updateItem(item, index);
|
|
1498
|
-
}
|
|
1499
|
-
if (property[parseInt(k.toString(), 10)] === 'cssClass' && !isNOU(item)) {
|
|
1500
|
-
if (oldVal) { removeClass([item], oldVal.split(' ')); }
|
|
1501
|
-
if (newVal) { addClass([item], newVal.split(' ')); }
|
|
1502
|
-
}
|
|
1503
|
-
if (property[parseInt(k.toString(), 10)] === 'visible' && !isNOU(item)) {
|
|
1504
|
-
if (Object(newProp.items[parseInt(index.toString(), 10)])[`${property[parseInt(k.toString(), 10)]}`] === false) {
|
|
1505
|
-
item.classList.add(CLS_ITEMHIDE);
|
|
1506
|
-
} else {
|
|
1507
|
-
item.classList.remove(CLS_ITEMHIDE);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
if (property[parseInt(k.toString(), 10)] === 'disabled' && !isNOU(item)) {
|
|
1511
|
-
this.enableItem(index, !newVal);
|
|
1512
|
-
}
|
|
1513
|
-
if (property.indexOf('header') < 0 && property[parseInt(k.toString(), 10)] === 'content'
|
|
1514
|
-
&& !isNOU(item) && item.children.length === 2) {
|
|
1515
|
-
if (typeof newVal === 'function') {
|
|
1516
|
-
if (this.isAngular || this.isReact) {
|
|
1517
|
-
this.clearAccordionTemplate(content, property[parseInt(k.toString(), 10)], CLS_CTENT);
|
|
1518
|
-
}
|
|
1519
|
-
const activeContent: HTEle = item.querySelector('.' + CLS_CTENT);
|
|
1520
|
-
activeContent.innerHTML = '';
|
|
1521
|
-
this.setTemplate(newVal, activeContent, index);
|
|
1522
|
-
} else {
|
|
1523
|
-
if (item.classList.contains(CLS_SLCTED)) {
|
|
1524
|
-
this.expandItem(false, index);
|
|
1525
|
-
}
|
|
1526
|
-
detach(item.querySelector('.' + CLS_CONTENT));
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
} else {
|
|
1532
|
-
isRefresh = true;
|
|
1533
|
-
}
|
|
1534
|
-
break;
|
|
1535
|
-
case 'dataSource':
|
|
1536
|
-
case 'expandedIndices':
|
|
1537
|
-
if (this.expandedIndices === null) {
|
|
1538
|
-
this.expandedIndices = [];
|
|
1539
|
-
}
|
|
1540
|
-
isRefresh = true;
|
|
1541
|
-
break;
|
|
1542
|
-
case 'headerTemplate':
|
|
1543
|
-
this.initializeHeaderTemplate();
|
|
1544
|
-
isRefresh = true;
|
|
1545
|
-
break;
|
|
1546
|
-
case 'itemTemplate':
|
|
1547
|
-
this.initializeItemTemplate();
|
|
1548
|
-
isRefresh = true;
|
|
1549
|
-
break;
|
|
1550
|
-
case 'enableRtl':
|
|
1551
|
-
if (newProp.enableRtl) {
|
|
1552
|
-
this.add(acrdn, CLS_RTL);
|
|
1553
|
-
} else {
|
|
1554
|
-
this.remove(acrdn, CLS_RTL);
|
|
1555
|
-
}
|
|
1556
|
-
break;
|
|
1557
|
-
case 'height':
|
|
1558
|
-
setStyle(this.element, { 'height': formatUnit(newProp.height) });
|
|
1559
|
-
break;
|
|
1560
|
-
case 'width':
|
|
1561
|
-
setStyle(this.element, { 'width': formatUnit(newProp.width) });
|
|
1562
|
-
break;
|
|
1563
|
-
case 'expandMode':
|
|
1564
|
-
if (newProp.expandMode === 'Single' && !isNOU(this.expandedIndices) && this.expandedIndices.length > 1) {
|
|
1565
|
-
this.expandItem(false);
|
|
1566
|
-
}
|
|
1567
|
-
break;
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
if (isRefresh) {
|
|
1571
|
-
this.initExpand = [];
|
|
1572
|
-
if (!isNOU(this.expandedIndices) && this.expandedIndices.length > 0) {
|
|
1573
|
-
this.initExpand = this.expandedIndices;
|
|
1574
|
-
}
|
|
1575
|
-
this.destroyItems();
|
|
1576
|
-
this.renderItems();
|
|
1577
|
-
this.initItemExpand();
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}
|