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