@syncfusion/ej2-dropdowns 24.1.43 → 24.1.45-12082
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/CHANGELOG.md +2101 -2058
- package/{README.md → ReadMe.md} +217 -217
- package/dist/ej2-dropdowns.min.js +1 -10
- package/dist/ej2-dropdowns.umd.min.js +1 -10
- package/dist/ej2-dropdowns.umd.min.js.map +1 -1
- package/dist/es6/ej2-dropdowns.es2015.js +94 -74
- package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
- package/dist/es6/ej2-dropdowns.es5.js +236 -216
- package/dist/es6/ej2-dropdowns.es5.js.map +1 -1
- package/dist/global/ej2-dropdowns.min.js +1 -10
- package/dist/global/ej2-dropdowns.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/dist/ts/auto-complete/auto-complete.ts +623 -0
- package/dist/ts/combo-box/combo-box.ts +1099 -0
- package/dist/ts/common/highlight-search.ts +57 -0
- package/dist/ts/common/incremental-search.ts +172 -0
- package/dist/ts/common/interface.ts +74 -0
- package/dist/ts/common/virtual-scroll.ts +388 -0
- package/dist/ts/drop-down-base/drop-down-base.ts +1986 -0
- package/dist/ts/drop-down-list/drop-down-list.ts +4261 -0
- package/dist/ts/drop-down-tree/drop-down-tree.ts +3747 -0
- package/dist/ts/list-box/list-box.ts +2772 -0
- package/dist/ts/mention/mention.ts +1875 -0
- package/dist/ts/multi-select/checkbox-selection.ts +550 -0
- package/dist/ts/multi-select/float-label.ts +176 -0
- package/dist/ts/multi-select/interface.ts +70 -0
- package/dist/ts/multi-select/multi-select.ts +4882 -0
- package/helpers/e2e/autocomplete.js +13 -13
- package/helpers/e2e/combobox.js +13 -13
- package/helpers/e2e/dropdownlist.js +13 -13
- package/helpers/e2e/index.js +3 -3
- package/helpers/e2e/listboxHelper.js +13 -13
- package/helpers/e2e/multiselect.js +13 -13
- package/license +2 -2
- package/package.json +80 -80
- package/src/auto-complete/auto-complete-model.d.ts +188 -188
- package/src/auto-complete/auto-complete.d.ts +12 -12
- package/src/auto-complete/auto-complete.js +21 -21
- package/src/combo-box/combo-box-model.d.ts +224 -224
- package/src/combo-box/combo-box.d.ts +27 -27
- package/src/combo-box/combo-box.js +29 -29
- package/src/common/virtual-scroll.js +46 -46
- package/src/drop-down-base/drop-down-base-model.d.ts +200 -200
- package/src/drop-down-base/drop-down-base.d.ts +16 -16
- package/src/drop-down-base/drop-down-base.js +20 -20
- package/src/drop-down-list/drop-down-list-model.d.ts +202 -202
- package/src/drop-down-list/drop-down-list.d.ts +5 -4
- package/src/drop-down-list/drop-down-list.js +31 -22
- package/src/drop-down-tree/drop-down-tree-model.d.ts +468 -468
- package/src/drop-down-tree/drop-down-tree.d.ts +0 -1
- package/src/drop-down-tree/drop-down-tree.js +20 -28
- package/src/list-box/list-box-model.d.ts +193 -193
- package/src/list-box/list-box.d.ts +2 -2
- package/src/list-box/list-box.js +34 -22
- package/src/mention/mention-model.d.ts +261 -261
- package/src/mention/mention.js +29 -22
- package/src/multi-select/multi-select-model.d.ts +512 -512
- package/src/multi-select/multi-select.js +20 -20
- package/styles/auto-complete/_all.scss +1 -1
- package/styles/auto-complete/_bds-definition.scss +2 -0
- package/styles/auto-complete/_bootstrap-dark-definition.scss +3 -3
- package/styles/auto-complete/_bootstrap-definition.scss +2 -2
- package/styles/auto-complete/_bootstrap4-definition.scss +11 -11
- package/styles/auto-complete/_bootstrap5-definition.scss +2 -2
- package/styles/auto-complete/_fabric-dark-definition.scss +2 -2
- package/styles/auto-complete/_fabric-definition.scss +2 -2
- package/styles/auto-complete/_fluent-definition.scss +2 -2
- package/styles/auto-complete/_fusionnew-definition.scss +2 -2
- package/styles/auto-complete/_highcontrast-definition.scss +2 -2
- package/styles/auto-complete/_highcontrast-light-definition.scss +2 -2
- package/styles/auto-complete/_material-dark-definition.scss +2 -2
- package/styles/auto-complete/_material-definition.scss +2 -2
- package/styles/auto-complete/_material3-definition.scss +2 -2
- package/styles/auto-complete/_tailwind-definition.scss +2 -2
- package/styles/auto-complete/material3-dark.scss +1 -1
- package/styles/auto-complete/material3.scss +1 -1
- package/styles/bootstrap-dark.css +9 -0
- package/styles/bootstrap.css +9 -0
- package/styles/bootstrap4.css +9 -0
- package/styles/bootstrap5-dark.css +9 -0
- package/styles/bootstrap5.css +9 -0
- package/styles/combo-box/_all.scss +1 -1
- package/styles/combo-box/_bds-definition.scss +2 -0
- package/styles/combo-box/_bootstrap-dark-definition.scss +2 -2
- package/styles/combo-box/_bootstrap-definition.scss +2 -2
- package/styles/combo-box/_bootstrap4-definition.scss +11 -11
- package/styles/combo-box/_bootstrap5-definition.scss +2 -2
- package/styles/combo-box/_fabric-dark-definition.scss +2 -2
- package/styles/combo-box/_fabric-definition.scss +2 -2
- package/styles/combo-box/_fluent-definition.scss +2 -2
- package/styles/combo-box/_fusionnew-definition.scss +2 -2
- package/styles/combo-box/_highcontrast-definition.scss +2 -2
- package/styles/combo-box/_highcontrast-light-definition.scss +3 -3
- package/styles/combo-box/_material-dark-definition.scss +2 -2
- package/styles/combo-box/_material-definition.scss +2 -2
- package/styles/combo-box/_material3-definition.scss +2 -2
- package/styles/combo-box/_tailwind-definition.scss +2 -2
- package/styles/combo-box/material3-dark.scss +1 -1
- package/styles/combo-box/material3.scss +1 -1
- package/styles/drop-down-base/_all.scss +2 -2
- package/styles/drop-down-base/_bds-definition.scss +129 -0
- package/styles/drop-down-base/_bootstrap-dark-definition.scss +83 -83
- package/styles/drop-down-base/_bootstrap-definition.scss +83 -83
- package/styles/drop-down-base/_bootstrap4-definition.scss +90 -90
- package/styles/drop-down-base/_bootstrap5-definition.scss +117 -117
- package/styles/drop-down-base/_definition.scss +23 -23
- package/styles/drop-down-base/_fabric-dark-definition.scss +86 -86
- package/styles/drop-down-base/_fabric-definition.scss +84 -84
- package/styles/drop-down-base/_fluent-definition.scss +121 -121
- package/styles/drop-down-base/_fusionnew-definition.scss +117 -117
- package/styles/drop-down-base/_highcontrast-definition.scss +105 -105
- package/styles/drop-down-base/_highcontrast-light-definition.scss +105 -105
- package/styles/drop-down-base/_layout.scss +192 -192
- package/styles/drop-down-base/_material-dark-definition.scss +86 -86
- package/styles/drop-down-base/_material-definition.scss +85 -85
- package/styles/drop-down-base/_material3-definition.scss +87 -87
- package/styles/drop-down-base/_tailwind-definition.scss +129 -129
- package/styles/drop-down-base/_theme.scss +391 -391
- package/styles/drop-down-base/material3-dark.scss +1 -1
- package/styles/drop-down-base/material3.scss +1 -1
- package/styles/drop-down-list/_all.scss +3 -3
- package/styles/drop-down-list/_bds-definition.scss +134 -0
- package/styles/drop-down-list/_bootstrap-dark-definition.scss +157 -157
- package/styles/drop-down-list/_bootstrap-definition.scss +156 -156
- package/styles/drop-down-list/_bootstrap4-definition.scss +202 -202
- package/styles/drop-down-list/_bootstrap5-definition.scss +201 -201
- package/styles/drop-down-list/_fabric-dark-definition.scss +128 -128
- package/styles/drop-down-list/_fabric-definition.scss +124 -124
- package/styles/drop-down-list/_fluent-definition.scss +185 -185
- package/styles/drop-down-list/_fusionnew-definition.scss +201 -201
- package/styles/drop-down-list/_highcontrast-definition.scss +142 -142
- package/styles/drop-down-list/_highcontrast-light-definition.scss +144 -144
- package/styles/drop-down-list/_layout.scss +315 -310
- package/styles/drop-down-list/_material-dark-definition.scss +143 -143
- package/styles/drop-down-list/_material-definition.scss +167 -167
- package/styles/drop-down-list/_material3-definition.scss +180 -180
- package/styles/drop-down-list/_tailwind-definition.scss +134 -134
- package/styles/drop-down-list/_theme.scss +10 -10
- package/styles/drop-down-list/bootstrap-dark.css +5 -0
- package/styles/drop-down-list/bootstrap.css +5 -0
- package/styles/drop-down-list/bootstrap4.css +5 -0
- package/styles/drop-down-list/bootstrap5-dark.css +5 -0
- package/styles/drop-down-list/bootstrap5.css +5 -0
- package/styles/drop-down-list/fabric-dark.css +5 -0
- package/styles/drop-down-list/fabric.css +5 -0
- package/styles/drop-down-list/fluent-dark.css +5 -0
- package/styles/drop-down-list/fluent.css +5 -0
- package/styles/drop-down-list/highcontrast-light.css +5 -0
- package/styles/drop-down-list/highcontrast.css +5 -0
- package/styles/drop-down-list/icons/_bootstrap-dark.scss +14 -14
- package/styles/drop-down-list/icons/_bootstrap.scss +14 -14
- package/styles/drop-down-list/icons/_bootstrap4.scss +14 -14
- package/styles/drop-down-list/icons/_bootstrap5.scss +14 -14
- package/styles/drop-down-list/icons/_fabric-dark.scss +14 -14
- package/styles/drop-down-list/icons/_fabric.scss +14 -14
- package/styles/drop-down-list/icons/_fluent.scss +14 -14
- package/styles/drop-down-list/icons/_fusionnew.scss +14 -14
- package/styles/drop-down-list/icons/_highcontrast-light.scss +14 -14
- package/styles/drop-down-list/icons/_highcontrast.scss +14 -14
- package/styles/drop-down-list/icons/_material-dark.scss +14 -14
- package/styles/drop-down-list/icons/_material.scss +14 -14
- package/styles/drop-down-list/icons/_material3.scss +14 -14
- package/styles/drop-down-list/icons/_tailwind.scss +14 -14
- package/styles/drop-down-list/material-dark.css +5 -0
- package/styles/drop-down-list/material.css +5 -0
- package/styles/drop-down-list/material3-dark.css +5 -0
- package/styles/drop-down-list/material3-dark.scss +1 -1
- package/styles/drop-down-list/material3.css +5 -0
- package/styles/drop-down-list/material3.scss +1 -1
- package/styles/drop-down-list/tailwind-dark.css +5 -0
- package/styles/drop-down-list/tailwind.css +5 -0
- package/styles/drop-down-tree/_all.scss +2 -2
- package/styles/drop-down-tree/_bds-definition.scss +61 -0
- package/styles/drop-down-tree/_bootstrap-dark-definition.scss +71 -71
- package/styles/drop-down-tree/_bootstrap-definition.scss +70 -70
- package/styles/drop-down-tree/_bootstrap4-definition.scss +71 -71
- package/styles/drop-down-tree/_bootstrap5-definition.scss +59 -59
- package/styles/drop-down-tree/_fabric-dark-definition.scss +71 -71
- package/styles/drop-down-tree/_fabric-definition.scss +71 -71
- package/styles/drop-down-tree/_fluent-definition.scss +65 -65
- package/styles/drop-down-tree/_fusionnew-definition.scss +59 -59
- package/styles/drop-down-tree/_highcontrast-definition.scss +71 -71
- package/styles/drop-down-tree/_highcontrast-light-definition.scss +71 -71
- package/styles/drop-down-tree/_layout.scss +1423 -1418
- package/styles/drop-down-tree/_material-dark-definition.scss +72 -72
- package/styles/drop-down-tree/_material-definition.scss +72 -72
- package/styles/drop-down-tree/_material3-definition.scss +76 -76
- package/styles/drop-down-tree/_tailwind-definition.scss +61 -61
- package/styles/drop-down-tree/_theme.scss +132 -132
- package/styles/drop-down-tree/bootstrap-dark.css +4 -0
- package/styles/drop-down-tree/bootstrap.css +4 -0
- package/styles/drop-down-tree/bootstrap4.css +4 -0
- package/styles/drop-down-tree/bootstrap5-dark.css +4 -0
- package/styles/drop-down-tree/bootstrap5.css +4 -0
- package/styles/drop-down-tree/fabric-dark.css +4 -0
- package/styles/drop-down-tree/fabric.css +4 -0
- package/styles/drop-down-tree/fluent-dark.css +4 -0
- package/styles/drop-down-tree/fluent.css +4 -0
- package/styles/drop-down-tree/highcontrast-light.css +4 -0
- package/styles/drop-down-tree/highcontrast.css +4 -0
- package/styles/drop-down-tree/icons/_bootstrap-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_bootstrap.scss +11 -11
- package/styles/drop-down-tree/icons/_bootstrap4.scss +11 -11
- package/styles/drop-down-tree/icons/_bootstrap5.scss +11 -11
- package/styles/drop-down-tree/icons/_fabric-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_fabric.scss +11 -11
- package/styles/drop-down-tree/icons/_fluent.scss +11 -11
- package/styles/drop-down-tree/icons/_fusionnew.scss +11 -11
- package/styles/drop-down-tree/icons/_highcontrast-light.scss +11 -11
- package/styles/drop-down-tree/icons/_highcontrast.scss +11 -11
- package/styles/drop-down-tree/icons/_material-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_material.scss +11 -11
- package/styles/drop-down-tree/icons/_material3.scss +11 -11
- package/styles/drop-down-tree/icons/_tailwind-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_tailwind.scss +11 -11
- package/styles/drop-down-tree/material-dark.css +4 -0
- package/styles/drop-down-tree/material.css +4 -0
- package/styles/drop-down-tree/material3-dark.css +4 -0
- package/styles/drop-down-tree/material3-dark.scss +1 -1
- package/styles/drop-down-tree/material3.css +4 -0
- package/styles/drop-down-tree/material3.scss +1 -1
- package/styles/drop-down-tree/tailwind-dark.css +4 -0
- package/styles/drop-down-tree/tailwind.css +4 -0
- package/styles/fabric-dark.css +9 -0
- package/styles/fabric.css +9 -0
- package/styles/fluent-dark.css +9 -0
- package/styles/fluent.css +9 -0
- package/styles/highcontrast-light.css +9 -0
- package/styles/highcontrast.css +9 -0
- package/styles/list-box/_all.scss +2 -2
- package/styles/list-box/_bds-definition.scss +119 -0
- package/styles/list-box/_bootstrap-dark-definition.scss +126 -126
- package/styles/list-box/_bootstrap-definition.scss +119 -119
- package/styles/list-box/_bootstrap4-definition.scss +124 -124
- package/styles/list-box/_bootstrap5-definition.scss +120 -120
- package/styles/list-box/_fabric-dark-definition.scss +126 -126
- package/styles/list-box/_fabric-definition.scss +119 -119
- package/styles/list-box/_fluent-definition.scss +120 -120
- package/styles/list-box/_fusionnew-definition.scss +111 -111
- package/styles/list-box/_highcontrast-definition.scss +119 -119
- package/styles/list-box/_highcontrast-light-definition.scss +126 -126
- package/styles/list-box/_layout.scss +542 -542
- package/styles/list-box/_material-dark-definition.scss +126 -126
- package/styles/list-box/_material-definition.scss +119 -119
- package/styles/list-box/_material3-definition.scss +119 -119
- package/styles/list-box/_tailwind-definition.scss +119 -119
- package/styles/list-box/_theme.scss +382 -382
- package/styles/list-box/icons/_bootstrap-dark.scss +25 -25
- package/styles/list-box/icons/_bootstrap.scss +25 -25
- package/styles/list-box/icons/_bootstrap4.scss +25 -25
- package/styles/list-box/icons/_bootstrap5.scss +25 -25
- package/styles/list-box/icons/_fabric-dark.scss +25 -25
- package/styles/list-box/icons/_fabric.scss +25 -25
- package/styles/list-box/icons/_fluent.scss +25 -25
- package/styles/list-box/icons/_fusionnew.scss +25 -25
- package/styles/list-box/icons/_highcontrast-light.scss +25 -25
- package/styles/list-box/icons/_highcontrast.scss +25 -25
- package/styles/list-box/icons/_material-dark.scss +25 -25
- package/styles/list-box/icons/_material.scss +25 -25
- package/styles/list-box/icons/_material3.scss +25 -25
- package/styles/list-box/icons/_tailwind-dark.scss +25 -25
- package/styles/list-box/icons/_tailwind.scss +25 -25
- package/styles/list-box/material3-dark.scss +1 -1
- package/styles/list-box/material3.scss +1 -1
- package/styles/material-dark.css +9 -0
- package/styles/material.css +9 -0
- package/styles/material3-dark.css +9 -0
- package/styles/material3-dark.scss +1 -1
- package/styles/material3.css +9 -0
- package/styles/material3.scss +1 -1
- package/styles/mention/_all.scss +1 -1
- package/styles/mention/_bds-definition.scss +1 -0
- package/styles/mention/_bootstrap-dark-definition.scss +3 -3
- package/styles/mention/_bootstrap-definition.scss +3 -3
- package/styles/mention/_bootstrap4-definition.scss +3 -3
- package/styles/mention/_bootstrap5-definition.scss +1 -1
- package/styles/mention/_fabric-dark-definition.scss +2 -2
- package/styles/mention/_fabric-definition.scss +3 -3
- package/styles/mention/_fluent-definition.scss +1 -1
- package/styles/mention/_fusionnew-definition.scss +1 -1
- package/styles/mention/_highcontrast-definition.scss +3 -3
- package/styles/mention/_highcontrast-light-definition.scss +3 -3
- package/styles/mention/_layout.scss +6 -6
- package/styles/mention/_material-dark-definition.scss +3 -3
- package/styles/mention/_material-definition.scss +3 -3
- package/styles/mention/_material3-definition.scss +1 -1
- package/styles/mention/_tailwind-definition.scss +1 -1
- package/styles/mention/material3-dark.scss +1 -1
- package/styles/mention/material3.scss +1 -1
- package/styles/multi-select/_all.scss +2 -2
- package/styles/multi-select/_bds-definition.scss +235 -0
- package/styles/multi-select/_bootstrap-dark-definition.scss +203 -203
- package/styles/multi-select/_bootstrap-definition.scss +192 -192
- package/styles/multi-select/_bootstrap4-definition.scss +278 -278
- package/styles/multi-select/_bootstrap5-definition.scss +230 -230
- package/styles/multi-select/_fabric-dark-definition.scss +192 -192
- package/styles/multi-select/_fabric-definition.scss +183 -183
- package/styles/multi-select/_fluent-definition.scss +241 -241
- package/styles/multi-select/_fusionnew-definition.scss +227 -227
- package/styles/multi-select/_highcontrast-definition.scss +303 -303
- package/styles/multi-select/_highcontrast-light-definition.scss +297 -297
- package/styles/multi-select/_layout.scss +2199 -2199
- package/styles/multi-select/_material-dark-definition.scss +230 -230
- package/styles/multi-select/_material-definition.scss +223 -223
- package/styles/multi-select/_material3-definition.scss +246 -246
- package/styles/multi-select/_tailwind-definition.scss +235 -235
- package/styles/multi-select/_theme.scss +586 -586
- package/styles/multi-select/icons/_bootstrap-dark.scss +26 -26
- package/styles/multi-select/icons/_bootstrap.scss +26 -26
- package/styles/multi-select/icons/_bootstrap4.scss +37 -37
- package/styles/multi-select/icons/_bootstrap5.scss +26 -26
- package/styles/multi-select/icons/_fabric-dark.scss +26 -26
- package/styles/multi-select/icons/_fabric.scss +26 -26
- package/styles/multi-select/icons/_fluent.scss +55 -55
- package/styles/multi-select/icons/_fusionnew.scss +26 -26
- package/styles/multi-select/icons/_highcontrast-light.scss +26 -26
- package/styles/multi-select/icons/_highcontrast.scss +26 -26
- package/styles/multi-select/icons/_material-dark.scss +693 -693
- package/styles/multi-select/icons/_material.scss +693 -693
- package/styles/multi-select/icons/_material3.scss +692 -692
- package/styles/multi-select/icons/_tailwind.scss +26 -26
- package/styles/multi-select/material3-dark.scss +1 -1
- package/styles/multi-select/material3.scss +1 -1
- package/styles/tailwind-dark.css +9 -0
- package/styles/tailwind.css +9 -0
- package/.eslintrc.json +0 -260
- package/tslint.json +0 -111
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type HightLightType = 'Contains' | 'StartsWith' | 'EndsWith';
|
|
2
|
+
/**
|
|
3
|
+
* Function helps to find which highlightSearch is to call based on your data.
|
|
4
|
+
*
|
|
5
|
+
* @param {HTMLElement} element - Specifies an li element.
|
|
6
|
+
* @param {string} query - Specifies the string to be highlighted.
|
|
7
|
+
* @param {boolean} ignoreCase - Specifies the ignoreCase option.
|
|
8
|
+
* @param {HightLightType} type - Specifies the type of highlight.
|
|
9
|
+
* @returns {void}
|
|
10
|
+
*/
|
|
11
|
+
export function highlightSearch(element: HTMLElement, query: string, ignoreCase: boolean, type?: HightLightType): void {
|
|
12
|
+
if (query === '') {
|
|
13
|
+
return;
|
|
14
|
+
} else {
|
|
15
|
+
const ignoreRegex: string = ignoreCase ? 'gim' : 'gm';
|
|
16
|
+
// eslint-disable-next-line
|
|
17
|
+
query = /^[a-zA-Z0-9- ]*$/.test(query) ? query : query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
18
|
+
const replaceQuery: string = type === 'StartsWith' ? '^(' + query + ')' : type === 'EndsWith' ?
|
|
19
|
+
'(' + query + ')$' : '(' + query + ')';
|
|
20
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
21
|
+
findTextNode(element, new RegExp(replaceQuery, ignoreRegex));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/* eslint-enable jsdoc/require-param, valid-jsdoc */
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {HTMLElement} element - Specifies the element.
|
|
28
|
+
* @param {RegExp} pattern - Specifies the regex to match the searched text.
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
function findTextNode(element: HTMLElement, pattern: RegExp): void {
|
|
32
|
+
for (let index: number = 0; element.childNodes && (index < element.childNodes.length); index++) {
|
|
33
|
+
if (element.childNodes[index as number].nodeType === 3 && element.childNodes[index as number].textContent.trim() !== '') {
|
|
34
|
+
const value: string = element.childNodes[index as number].nodeValue.trim().replace(pattern, '<span class="e-highlight">$1</span>');
|
|
35
|
+
element.childNodes[index as number].nodeValue = '';
|
|
36
|
+
element.innerHTML = element.innerHTML.trim() + value;
|
|
37
|
+
break;
|
|
38
|
+
} else {
|
|
39
|
+
findTextNode(element.childNodes[index as number] as HTMLElement, pattern);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Function helps to remove highlighted element based on your data.
|
|
46
|
+
*
|
|
47
|
+
* @param {HTMLElement} content - Specifies an content element.
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
export function revertHighlightSearch(content: HTMLElement): void {
|
|
51
|
+
const contentElement: NodeListOf<Element> = content.querySelectorAll('.e-highlight');
|
|
52
|
+
for (let i: number = contentElement.length - 1; i >= 0; i--) {
|
|
53
|
+
const parent: Node = contentElement[i as number].parentNode;
|
|
54
|
+
const text: Text = document.createTextNode(contentElement[i as number].textContent);
|
|
55
|
+
parent.replaceChild(text, contentElement[i as number]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IncrementalSearch module file
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
let queryString: string = '';
|
|
6
|
+
let prevString: string = '';
|
|
7
|
+
let tempQueryString: string = '';
|
|
8
|
+
let matches: Element[] = [];
|
|
9
|
+
const activeClass: string = 'e-active';
|
|
10
|
+
let prevElementId: string = '';
|
|
11
|
+
export type SearchType = 'StartsWith' | 'Equal' | 'EndsWith' | 'Contains';
|
|
12
|
+
/**
|
|
13
|
+
* Search and focus the list item based on key code matches with list text content
|
|
14
|
+
*
|
|
15
|
+
* @param { number } keyCode - Specifies the key code which pressed on keyboard events.
|
|
16
|
+
* @param { HTMLElement[]} items - Specifies an array of HTMLElement, from which matches find has done.
|
|
17
|
+
* @param { number } selectedIndex - Specifies the selected item in list item, so that search will happen
|
|
18
|
+
* after selected item otherwise it will do from initial.
|
|
19
|
+
* @param { boolean } ignoreCase - Specifies the case consideration when search has done.
|
|
20
|
+
* @param {string} elementId - Specifies the list element ID.
|
|
21
|
+
* @returns {Element} Returns list item based on key code matches with list text content.
|
|
22
|
+
*/
|
|
23
|
+
export function incrementalSearch(
|
|
24
|
+
keyCode: number, items: HTMLElement[], selectedIndex: number, ignoreCase: boolean, elementId: string, queryStringUpdated?: boolean, currentValue?: string, isVirtual?: boolean, refresh?: boolean): Element {
|
|
25
|
+
if (!queryStringUpdated || queryString === '') {
|
|
26
|
+
if(tempQueryString != ''){
|
|
27
|
+
queryString = tempQueryString + String.fromCharCode(keyCode);
|
|
28
|
+
tempQueryString = '';
|
|
29
|
+
}else{
|
|
30
|
+
queryString += String.fromCharCode(keyCode);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if(queryString == prevString){
|
|
34
|
+
tempQueryString = String.fromCharCode(keyCode);
|
|
35
|
+
}
|
|
36
|
+
if(isVirtual) {
|
|
37
|
+
setTimeout(function () {
|
|
38
|
+
tempQueryString = '';
|
|
39
|
+
}, 700);
|
|
40
|
+
setTimeout(function () {
|
|
41
|
+
queryString = '';
|
|
42
|
+
}, 3000);
|
|
43
|
+
}else{
|
|
44
|
+
setTimeout(function () {
|
|
45
|
+
queryString = '';
|
|
46
|
+
}, 1000);
|
|
47
|
+
}
|
|
48
|
+
let index: number;
|
|
49
|
+
queryString = ignoreCase ? queryString.toLowerCase() : queryString;
|
|
50
|
+
if (prevElementId === elementId && prevString === queryString && !refresh) {
|
|
51
|
+
for (let i: number = 0; i < matches.length; i++) {
|
|
52
|
+
if (matches[i as number].classList.contains(activeClass)) {
|
|
53
|
+
index = i; break;
|
|
54
|
+
}
|
|
55
|
+
if(currentValue && matches[i as number].textContent.toLowerCase() === currentValue.toLowerCase()) {
|
|
56
|
+
index = i;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
index = index + 1;
|
|
61
|
+
if(isVirtual){
|
|
62
|
+
return matches[index as number] && matches.length - 1 != index ? matches[index as number] : matches[matches.length as number];
|
|
63
|
+
}
|
|
64
|
+
return matches[index as number] ? matches[index as number] : matches[0];
|
|
65
|
+
} else {
|
|
66
|
+
const listItems: Element[] = items;
|
|
67
|
+
const strLength: number = queryString.length;
|
|
68
|
+
let text: string;
|
|
69
|
+
let item: HTMLElement;
|
|
70
|
+
selectedIndex = selectedIndex ? selectedIndex + 1 : 0;
|
|
71
|
+
let i: number = selectedIndex;
|
|
72
|
+
matches = [];
|
|
73
|
+
do {
|
|
74
|
+
if (i === listItems.length) {
|
|
75
|
+
i = -1;
|
|
76
|
+
}
|
|
77
|
+
if (i === -1) {
|
|
78
|
+
index = 0;
|
|
79
|
+
} else {
|
|
80
|
+
index = i;
|
|
81
|
+
}
|
|
82
|
+
item = listItems[index as number] as HTMLElement;
|
|
83
|
+
text = ignoreCase ? item.innerText.toLowerCase() : item.innerText;
|
|
84
|
+
if (text.substr(0, strLength) === queryString) {
|
|
85
|
+
matches.push(listItems[index as number]);
|
|
86
|
+
}
|
|
87
|
+
i++;
|
|
88
|
+
} while (i !== selectedIndex);
|
|
89
|
+
prevString = queryString;
|
|
90
|
+
prevElementId = elementId;
|
|
91
|
+
if(isVirtual) {
|
|
92
|
+
var indexUpdated:boolean = false;
|
|
93
|
+
for (let i: number = 0; i < matches.length; i++) {
|
|
94
|
+
if(currentValue && matches[i as number].textContent.toLowerCase() === currentValue.toLowerCase()) {
|
|
95
|
+
index = i;
|
|
96
|
+
indexUpdated = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if(currentValue && indexUpdated) {
|
|
101
|
+
index = index + 1;
|
|
102
|
+
}
|
|
103
|
+
return matches[index as number] ? matches[index as number] : matches[0];
|
|
104
|
+
}
|
|
105
|
+
return matches[0];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Search the list item based on given input value matches with search type.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} inputVal - Specifies the given input value.
|
|
113
|
+
* @param {HTMLElement[]} items - Specifies the list items.
|
|
114
|
+
* @param {SearchType} searchType - Specifies the filter type.
|
|
115
|
+
* @param {boolean} ignoreCase - Specifies the case sensitive option for search operation.
|
|
116
|
+
* @returns {Element | number} Returns the search matched items.
|
|
117
|
+
*/
|
|
118
|
+
export function Search(
|
|
119
|
+
inputVal: string, items: HTMLElement[], searchType: SearchType, ignoreCase?: boolean, dataSource?: string[] | number[] | boolean[] | {
|
|
120
|
+
[key: string]: Object
|
|
121
|
+
}[], fields?: any, type?: string): { [key: string]: Element | number } {
|
|
122
|
+
const listItems: HTMLElement[] = items;
|
|
123
|
+
ignoreCase = ignoreCase !== undefined && ignoreCase !== null ? ignoreCase : true;
|
|
124
|
+
const itemData: { [key: string]: Element | number } = { item: null, index: null };
|
|
125
|
+
if (inputVal && inputVal.length) {
|
|
126
|
+
const strLength: number = inputVal.length;
|
|
127
|
+
let queryStr: string = ignoreCase ? inputVal.toLocaleLowerCase() : inputVal;
|
|
128
|
+
queryStr = escapeCharRegExp(queryStr);
|
|
129
|
+
for (let i: number = 0, itemsData: Element[] = listItems; i < itemsData.length; i++) {
|
|
130
|
+
const item: Element = itemsData[i as number];
|
|
131
|
+
let text: string;
|
|
132
|
+
let filterValue: string;
|
|
133
|
+
if (items && dataSource) {
|
|
134
|
+
let checkField: Element = item;
|
|
135
|
+
let fieldValue = fields.text.split('.');
|
|
136
|
+
(dataSource as { [key: string]: Object }[]).filter(function (data: any) {
|
|
137
|
+
Array.prototype.slice.call(fieldValue).forEach(function (value: string | number) {
|
|
138
|
+
/* eslint-disable security/detect-object-injection */
|
|
139
|
+
if (type === 'object' && (!data.isHeader && checkField.textContent.toString().indexOf(data[value]) !== -1) && checkField.getAttribute('data-value') === data[fields.value].toString() || type === 'string' && checkField.textContent.toString().indexOf(data) !== -1) {
|
|
140
|
+
filterValue = type === 'object' ? data[value] : data;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
text = dataSource && filterValue ? (ignoreCase ? filterValue.toString().toLocaleLowerCase() : filterValue).replace(/^\s+|\s+$/g, '') : (ignoreCase ? item.textContent.toLocaleLowerCase() : item.textContent).replace(/^\s+|\s+$/g, '');
|
|
146
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
147
|
+
if ((searchType === 'Equal' && text === queryStr) || (searchType === 'StartsWith' && text.substr(0, strLength) === queryStr) || (searchType === 'EndsWith' && text.substr(text.length - queryStr.length) === queryStr) || (searchType === 'Contains' && new RegExp(queryStr, "g").test(text))) {
|
|
148
|
+
itemData.item = item;
|
|
149
|
+
itemData.index = i;
|
|
150
|
+
return { item: item, index: i };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return itemData;
|
|
154
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
return itemData;
|
|
158
|
+
}
|
|
159
|
+
/* eslint-enable security/detect-object-injection */
|
|
160
|
+
|
|
161
|
+
export function escapeCharRegExp(value: string) {
|
|
162
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function resetIncrementalSearchValues(elementId: string): void {
|
|
166
|
+
if (prevElementId === elementId) {
|
|
167
|
+
prevElementId = '';
|
|
168
|
+
prevString = '';
|
|
169
|
+
queryString = '';
|
|
170
|
+
matches = [];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Component, KeyboardEventArgs } from '@syncfusion/ej2-base';
|
|
2
|
+
import { Popup } from '@syncfusion/ej2-popups';
|
|
3
|
+
import { VirtualInfo } from '../common/virtual-scroll';
|
|
4
|
+
import { DataManager, Query } from '@syncfusion/ej2-data';
|
|
5
|
+
import { FieldSettingsModel } from '../drop-down-base/drop-down-base-model';
|
|
6
|
+
import { GeneratedData } from '../drop-down-list/drop-down-list';
|
|
7
|
+
/**
|
|
8
|
+
* Specifies virtual scroll interfaces.
|
|
9
|
+
*
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface IDropdownlist extends Component<HTMLElement> {
|
|
14
|
+
popupContentElement: HTMLElement;
|
|
15
|
+
isPreventScrollAction: boolean;
|
|
16
|
+
listHeight: string;
|
|
17
|
+
previousStartIndex: number;
|
|
18
|
+
previousEndIndex: number;
|
|
19
|
+
previousInfo: VirtualInfo;
|
|
20
|
+
startIndex: number;
|
|
21
|
+
currentPageNumber: number;
|
|
22
|
+
isMouseScrollAction: boolean;
|
|
23
|
+
isPreventKeyAction: boolean;
|
|
24
|
+
pageCount: number;
|
|
25
|
+
isKeyBoardAction: boolean;
|
|
26
|
+
viewPortInfo: VirtualInfo;
|
|
27
|
+
isUpwardScrolling: boolean;
|
|
28
|
+
queryString: string;
|
|
29
|
+
containerElementRect: ClientRect;
|
|
30
|
+
isScrollActionTriggered: boolean;
|
|
31
|
+
virtualListInfo: VirtualInfo;
|
|
32
|
+
selectedValueInfo: VirtualInfo;
|
|
33
|
+
value: number | string | boolean;
|
|
34
|
+
totalItemCount: number;
|
|
35
|
+
virtualItemCount: number;
|
|
36
|
+
virtualItemEndIndex: number;
|
|
37
|
+
virtualItemStartIndex: number;
|
|
38
|
+
popupObj: Popup;
|
|
39
|
+
listItemHeight: number;
|
|
40
|
+
scrollPreStartIndex: number;
|
|
41
|
+
list: HTMLElement;
|
|
42
|
+
liCollections: HTMLElement[];
|
|
43
|
+
typedString: string
|
|
44
|
+
isVirtualScrolling: boolean;
|
|
45
|
+
isCustomFilter: boolean;
|
|
46
|
+
allowFiltering: boolean;
|
|
47
|
+
isPopupOpen: boolean;
|
|
48
|
+
isTyped: boolean;
|
|
49
|
+
itemCount: number;
|
|
50
|
+
fields: FieldSettingsModel;
|
|
51
|
+
generatedDataObject: GeneratedData;
|
|
52
|
+
keyboardEvent: KeyboardEventArgs;
|
|
53
|
+
dataCount: number;
|
|
54
|
+
filterInput: HTMLInputElement;
|
|
55
|
+
dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[];
|
|
56
|
+
listData: { [key: string]: Object }[] | string[] | boolean[] | number[];
|
|
57
|
+
skeletonCount: number;
|
|
58
|
+
getSkeletonCount(retainSkeleton?: boolean): void;
|
|
59
|
+
getItems(): HTMLElement[];
|
|
60
|
+
getQuery(query: Query): Query;
|
|
61
|
+
getTransformValues(): string;
|
|
62
|
+
UpdateSkeleton(): void;
|
|
63
|
+
updateSelectionList(): void;
|
|
64
|
+
GetVirtualTrackHeight(): string;
|
|
65
|
+
getPageCount(returnExactCount?: boolean): number;
|
|
66
|
+
handleVirtualKeyboardActions(e: KeyboardEventArgs, pageCount: number): void;
|
|
67
|
+
renderItems(listData: { [key: string]: Object }[], fields: FieldSettingsModel): HTMLElement
|
|
68
|
+
resetList(
|
|
69
|
+
dataSource?: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
|
|
70
|
+
fields?: FieldSettingsModel, query?: Query, e?: MouseEvent | KeyboardEventArgs | TouchEvent): void
|
|
71
|
+
findListElement(list: HTMLElement, findNode: string, attribute: string, value: string | boolean | number): HTMLElement;
|
|
72
|
+
scrollStop(e?: Event): void;
|
|
73
|
+
}
|
|
74
|
+
|