@syncfusion/ej2-dropdowns 20.2.40 → 20.2.43-3197
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 +16 -1
- package/CHANGELOG.md +116 -3
- package/{README.md → ReadMe.md} +1 -1
- package/dist/ej2-dropdowns.min.js +1 -0
- 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 +2232 -468
- package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
- package/dist/es6/ej2-dropdowns.es5.js +2273 -480
- 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/mention.d.ts +4 -0
- package/mention.js +4 -0
- package/package.json +76 -76
- package/src/auto-complete/auto-complete-model.d.ts +12 -11
- package/src/auto-complete/auto-complete.d.ts +20 -18
- package/src/auto-complete/auto-complete.js +67 -37
- package/src/combo-box/combo-box-model.d.ts +17 -17
- package/src/combo-box/combo-box.d.ts +33 -33
- package/src/combo-box/combo-box.js +33 -29
- package/src/common/incremental-search.d.ts +3 -4
- package/src/common/incremental-search.js +22 -7
- package/src/drop-down-base/drop-down-base-model.d.ts +13 -31
- package/src/drop-down-base/drop-down-base.d.ts +22 -41
- package/src/drop-down-base/drop-down-base.js +75 -59
- package/src/drop-down-list/drop-down-list-model.d.ts +19 -1
- package/src/drop-down-list/drop-down-list.d.ts +35 -11
- package/src/drop-down-list/drop-down-list.js +194 -109
- package/src/drop-down-tree/drop-down-tree-model.d.ts +16 -2
- package/src/drop-down-tree/drop-down-tree.d.ts +15 -1
- package/src/drop-down-tree/drop-down-tree.js +49 -14
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/list-box/list-box-model.d.ts +18 -0
- package/src/list-box/list-box.d.ts +23 -1
- package/src/list-box/list-box.js +78 -35
- package/src/mention/index.d.ts +5 -0
- package/src/mention/index.js +4 -0
- package/src/mention/mention-model.d.ts +285 -0
- package/src/mention/mention.d.ts +457 -0
- package/src/mention/mention.js +1465 -0
- package/src/multi-select/checkbox-selection.js +11 -12
- package/src/multi-select/float-label.js +4 -2
- package/src/multi-select/multi-select-model.d.ts +1 -1
- package/src/multi-select/multi-select.d.ts +9 -5
- package/src/multi-select/multi-select.js +295 -188
- package/styles/auto-complete/_all.scss +1 -1
- package/styles/auto-complete/_bootstrap-dark-definition.scss +1 -1
- package/styles/auto-complete/_bootstrap-definition.scss +1 -1
- package/styles/auto-complete/_bootstrap4-definition.scss +2 -2
- package/styles/auto-complete/_bootstrap5-definition.scss +1 -1
- package/styles/auto-complete/_fabric-dark-definition.scss +1 -1
- package/styles/auto-complete/_fabric-definition.scss +1 -1
- package/styles/auto-complete/_fluent-definition.scss +1 -1
- package/styles/auto-complete/_fusionnew-definition.scss +1 -1
- package/styles/auto-complete/_highcontrast-definition.scss +1 -1
- package/styles/auto-complete/_highcontrast-light-definition.scss +1 -1
- package/styles/auto-complete/_material-dark-definition.scss +1 -1
- package/styles/auto-complete/_material-definition.scss +1 -1
- package/styles/auto-complete/_material3-definition.scss +1 -1
- package/styles/auto-complete/_tailwind-definition.scss +1 -1
- package/styles/auto-complete/bootstrap-dark.css +3 -1
- package/styles/auto-complete/bootstrap.css +3 -1
- package/styles/auto-complete/bootstrap4.css +3 -1
- package/styles/auto-complete/bootstrap5-dark.css +3 -1
- package/styles/auto-complete/bootstrap5.css +3 -1
- package/styles/auto-complete/fabric-dark.css +3 -1
- package/styles/auto-complete/fabric.css +3 -1
- package/styles/auto-complete/fluent-dark.css +3 -1
- package/styles/auto-complete/fluent.css +3 -1
- package/styles/auto-complete/highcontrast-light.css +3 -1
- package/styles/auto-complete/highcontrast.css +3 -1
- package/styles/auto-complete/material-dark.css +3 -1
- package/styles/auto-complete/material.css +3 -1
- package/styles/auto-complete/tailwind-dark.css +3 -1
- package/styles/auto-complete/tailwind.css +3 -1
- package/styles/bootstrap-dark.css +121 -44
- package/styles/bootstrap-dark.scss +1 -0
- package/styles/bootstrap.css +121 -44
- package/styles/bootstrap.scss +1 -0
- package/styles/bootstrap4.css +134 -55
- package/styles/bootstrap4.scss +1 -0
- package/styles/bootstrap5-dark.css +135 -50
- package/styles/bootstrap5-dark.scss +1 -0
- package/styles/bootstrap5.css +135 -50
- package/styles/bootstrap5.scss +1 -0
- package/styles/combo-box/_all.scss +1 -1
- package/styles/combo-box/_bootstrap-dark-definition.scss +1 -1
- package/styles/combo-box/_bootstrap-definition.scss +1 -1
- package/styles/combo-box/_bootstrap4-definition.scss +2 -2
- package/styles/combo-box/_bootstrap5-definition.scss +1 -1
- package/styles/combo-box/_fabric-dark-definition.scss +1 -1
- package/styles/combo-box/_fabric-definition.scss +1 -1
- package/styles/combo-box/_fluent-definition.scss +1 -1
- package/styles/combo-box/_fusionnew-definition.scss +1 -1
- package/styles/combo-box/_highcontrast-definition.scss +1 -1
- package/styles/combo-box/_highcontrast-light-definition.scss +1 -1
- package/styles/combo-box/_material-dark-definition.scss +1 -1
- package/styles/combo-box/_material-definition.scss +1 -1
- package/styles/combo-box/_material3-definition.scss +1 -1
- package/styles/combo-box/_tailwind-definition.scss +1 -1
- package/styles/combo-box/bootstrap-dark.css +3 -1
- package/styles/combo-box/bootstrap.css +3 -1
- package/styles/combo-box/bootstrap4.css +3 -1
- package/styles/combo-box/bootstrap5-dark.css +3 -1
- package/styles/combo-box/bootstrap5.css +3 -1
- package/styles/combo-box/fabric-dark.css +3 -1
- package/styles/combo-box/fabric.css +3 -1
- package/styles/combo-box/fluent-dark.css +3 -1
- package/styles/combo-box/fluent.css +3 -1
- package/styles/combo-box/highcontrast-light.css +3 -1
- package/styles/combo-box/highcontrast.css +3 -1
- package/styles/combo-box/material-dark.css +3 -1
- package/styles/combo-box/material.css +3 -1
- package/styles/combo-box/tailwind-dark.css +3 -1
- package/styles/combo-box/tailwind.css +3 -1
- package/styles/drop-down-base/_all.scss +1 -1
- package/styles/drop-down-base/_bootstrap-dark-definition.scss +9 -2
- package/styles/drop-down-base/_bootstrap-definition.scss +7 -1
- package/styles/drop-down-base/_bootstrap4-definition.scss +7 -1
- package/styles/drop-down-base/_bootstrap5-definition.scss +9 -3
- package/styles/drop-down-base/_fabric-dark-definition.scss +7 -1
- package/styles/drop-down-base/_fabric-definition.scss +7 -1
- package/styles/drop-down-base/_fluent-definition.scss +9 -2
- package/styles/drop-down-base/_fusionnew-definition.scss +9 -3
- package/styles/drop-down-base/_highcontrast-definition.scss +17 -6
- package/styles/drop-down-base/_highcontrast-light-definition.scss +19 -7
- package/styles/drop-down-base/_layout.scss +44 -3
- package/styles/drop-down-base/_material-dark-definition.scss +8 -1
- package/styles/drop-down-base/_material-definition.scss +7 -0
- package/styles/drop-down-base/_material3-definition.scss +9 -3
- package/styles/drop-down-base/_tailwind-definition.scss +9 -3
- package/styles/drop-down-base/_theme.scss +4 -4
- package/styles/drop-down-base/bootstrap-dark.css +42 -1
- package/styles/drop-down-base/bootstrap.css +42 -1
- package/styles/drop-down-base/bootstrap4.css +42 -1
- package/styles/drop-down-base/bootstrap5-dark.css +42 -1
- package/styles/drop-down-base/bootstrap5.css +42 -1
- package/styles/drop-down-base/fabric-dark.css +42 -1
- package/styles/drop-down-base/fabric.css +42 -1
- package/styles/drop-down-base/fluent-dark.css +42 -1
- package/styles/drop-down-base/fluent.css +42 -1
- package/styles/drop-down-base/highcontrast-light.css +42 -1
- package/styles/drop-down-base/highcontrast.css +42 -1
- package/styles/drop-down-base/material-dark.css +42 -1
- package/styles/drop-down-base/material.css +42 -1
- package/styles/drop-down-base/tailwind-dark.css +42 -1
- package/styles/drop-down-base/tailwind.css +42 -1
- package/styles/drop-down-list/_all.scss +2 -1
- package/styles/drop-down-list/_bootstrap-dark-definition.scss +2 -1
- package/styles/drop-down-list/_bootstrap-definition.scss +2 -1
- package/styles/drop-down-list/_bootstrap4-definition.scss +3 -1
- package/styles/drop-down-list/_bootstrap5-definition.scss +3 -3
- package/styles/drop-down-list/_fabric-dark-definition.scss +2 -1
- package/styles/drop-down-list/_fabric-definition.scss +2 -0
- package/styles/drop-down-list/_fluent-definition.scss +2 -1
- package/styles/drop-down-list/_fusionnew-definition.scss +3 -3
- package/styles/drop-down-list/_highcontrast-definition.scss +21 -10
- package/styles/drop-down-list/_highcontrast-light-definition.scss +22 -11
- package/styles/drop-down-list/_layout.scss +11 -9
- package/styles/drop-down-list/_material-dark-definition.scss +2 -2
- package/styles/drop-down-list/_material-definition.scss +1 -0
- package/styles/drop-down-list/_material3-definition.scss +3 -3
- package/styles/drop-down-list/_tailwind-definition.scss +1 -0
- package/styles/drop-down-list/_theme.scss +3 -3
- package/styles/drop-down-list/bootstrap-dark.css +8 -0
- package/styles/drop-down-list/bootstrap.css +8 -0
- package/styles/drop-down-list/bootstrap4.css +8 -0
- package/styles/drop-down-list/bootstrap5-dark.css +9 -0
- package/styles/drop-down-list/bootstrap5.css +9 -0
- package/styles/drop-down-list/fabric-dark.css +8 -0
- package/styles/drop-down-list/fabric.css +8 -0
- package/styles/drop-down-list/fluent-dark.css +9 -0
- package/styles/drop-down-list/fluent.css +9 -0
- package/styles/drop-down-list/highcontrast-light.css +8 -0
- package/styles/drop-down-list/highcontrast.css +8 -0
- package/styles/drop-down-list/icons/_bootstrap.scss +0 -1
- package/styles/drop-down-list/icons/_fabric.scss +0 -1
- package/styles/drop-down-list/icons/_material.scss +0 -1
- package/styles/drop-down-list/material-dark.css +8 -0
- package/styles/drop-down-list/material.css +8 -0
- package/styles/drop-down-list/tailwind-dark.css +9 -0
- package/styles/drop-down-list/tailwind.css +9 -0
- package/styles/drop-down-tree/_all.scss +1 -1
- package/styles/drop-down-tree/_bootstrap-dark-definition.scss +1 -1
- package/styles/drop-down-tree/_bootstrap-definition.scss +1 -1
- package/styles/drop-down-tree/_bootstrap4-definition.scss +1 -1
- package/styles/drop-down-tree/_bootstrap5-definition.scss +2 -2
- package/styles/drop-down-tree/_fabric-dark-definition.scss +1 -1
- package/styles/drop-down-tree/_fabric-definition.scss +2 -2
- package/styles/drop-down-tree/_fluent-definition.scss +2 -2
- package/styles/drop-down-tree/_fusionnew-definition.scss +2 -2
- package/styles/drop-down-tree/_highcontrast-definition.scss +1 -1
- package/styles/drop-down-tree/_highcontrast-light-definition.scss +1 -1
- package/styles/drop-down-tree/_layout.scss +10 -3
- package/styles/drop-down-tree/_material-dark-definition.scss +2 -2
- package/styles/drop-down-tree/_material-definition.scss +2 -2
- package/styles/drop-down-tree/_material3-definition.scss +2 -2
- package/styles/drop-down-tree/_tailwind-definition.scss +2 -2
- 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 +9 -1
- package/styles/drop-down-tree/bootstrap5.css +9 -1
- 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 +5 -0
- package/styles/drop-down-tree/fluent.css +5 -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.scss +0 -1
- package/styles/drop-down-tree/icons/_bootstrap4.scss +0 -1
- package/styles/drop-down-tree/icons/_fabric.scss +0 -1
- package/styles/drop-down-tree/icons/_highcontrast-light.scss +0 -1
- package/styles/drop-down-tree/icons/_highcontrast.scss +0 -1
- package/styles/drop-down-tree/icons/_material-dark.scss +0 -1
- package/styles/drop-down-tree/icons/_material.scss +0 -1
- package/styles/drop-down-tree/material-dark.css +4 -0
- package/styles/drop-down-tree/material.css +4 -0
- package/styles/drop-down-tree/tailwind-dark.css +5 -0
- package/styles/drop-down-tree/tailwind.css +5 -0
- package/styles/fabric-dark.css +129 -52
- package/styles/fabric-dark.scss +1 -0
- package/styles/fabric.css +129 -52
- package/styles/fabric.scss +1 -0
- package/styles/fluent-dark.css +129 -47
- package/styles/fluent-dark.scss +1 -0
- package/styles/fluent.css +129 -47
- package/styles/fluent.scss +1 -0
- package/styles/highcontrast-light.css +124 -44
- package/styles/highcontrast-light.scss +1 -0
- package/styles/highcontrast.css +133 -53
- package/styles/highcontrast.scss +1 -0
- package/styles/list-box/_all.scss +1 -1
- package/styles/list-box/_bootstrap-dark-definition.scss +2 -0
- package/styles/list-box/_bootstrap-definition.scss +1 -0
- package/styles/list-box/_bootstrap4-definition.scss +1 -0
- package/styles/list-box/_bootstrap5-definition.scss +3 -0
- package/styles/list-box/_fabric-dark-definition.scss +3 -1
- package/styles/list-box/_fabric-definition.scss +1 -0
- package/styles/list-box/_fluent-definition.scss +3 -0
- package/styles/list-box/_fusionnew-definition.scss +1 -0
- package/styles/list-box/_highcontrast-definition.scss +1 -0
- package/styles/list-box/_highcontrast-light-definition.scss +3 -1
- package/styles/list-box/_layout.scss +8 -17
- package/styles/list-box/_material-dark-definition.scss +2 -0
- package/styles/list-box/_material-definition.scss +1 -0
- package/styles/list-box/_material3-definition.scss +1 -0
- package/styles/list-box/_tailwind-definition.scss +3 -0
- package/styles/list-box/_theme.scss +11 -25
- package/styles/list-box/bootstrap-dark.css +12 -33
- package/styles/list-box/bootstrap.css +14 -35
- package/styles/list-box/bootstrap4.css +14 -35
- package/styles/list-box/bootstrap5-dark.css +15 -36
- package/styles/list-box/bootstrap5.css +15 -36
- package/styles/list-box/fabric-dark.css +12 -33
- package/styles/list-box/fabric.css +14 -35
- package/styles/list-box/fluent-dark.css +15 -36
- package/styles/list-box/fluent.css +15 -36
- package/styles/list-box/highcontrast-light.css +12 -33
- package/styles/list-box/highcontrast.css +14 -35
- package/styles/list-box/icons/_bootstrap-dark.scss +2 -2
- package/styles/list-box/icons/_bootstrap.scss +1 -1
- package/styles/list-box/icons/_bootstrap4.scss +1 -1
- package/styles/list-box/icons/_bootstrap5.scss +1 -1
- package/styles/list-box/icons/_fabric-dark.scss +1 -1
- package/styles/list-box/icons/_fabric.scss +1 -1
- package/styles/list-box/icons/_fluent.scss +1 -1
- package/styles/list-box/icons/_fusionnew.scss +1 -1
- package/styles/list-box/icons/_highcontrast-light.scss +1 -1
- package/styles/list-box/icons/_highcontrast.scss +1 -1
- package/styles/list-box/icons/_material-dark.scss +1 -1
- package/styles/list-box/icons/_material.scss +2 -2
- package/styles/list-box/icons/_material3.scss +1 -1
- package/styles/list-box/icons/_tailwind-dark.scss +1 -1
- package/styles/list-box/icons/_tailwind.scss +1 -1
- package/styles/list-box/material-dark.css +12 -33
- package/styles/list-box/material.css +14 -35
- package/styles/list-box/tailwind-dark.css +15 -36
- package/styles/list-box/tailwind.css +15 -36
- package/styles/material-dark.css +120 -43
- package/styles/material-dark.scss +1 -0
- package/styles/material.css +120 -43
- package/styles/material.scss +1 -0
- package/styles/mention/_all.scss +1 -0
- package/styles/mention/_bootstrap-dark-definition.scss +3 -0
- package/styles/mention/_bootstrap-definition.scss +3 -0
- package/styles/mention/_bootstrap4-definition.scss +3 -0
- package/styles/mention/_bootstrap5-dark-definition.scss +1 -0
- package/styles/mention/_bootstrap5-definition.scss +1 -0
- package/styles/mention/_fabric-dark-definition.scss +2 -0
- package/styles/mention/_fabric-definition.scss +3 -0
- package/styles/mention/_fluent-dark-definition.scss +1 -0
- package/styles/mention/_fluent-definition.scss +1 -0
- package/styles/mention/_fusionnew-definition.scss +1 -0
- package/styles/mention/_highcontrast-definition.scss +3 -0
- package/styles/mention/_highcontrast-light-definition.scss +3 -0
- package/styles/mention/_layout.scss +6 -0
- package/styles/mention/_material-dark-definition.scss +3 -0
- package/styles/mention/_material-definition.scss +3 -0
- package/styles/mention/_material3-definition.scss +1 -0
- package/styles/mention/_tailwind-dark-definition.scss +1 -0
- package/styles/mention/_tailwind-definition.scss +1 -0
- package/styles/mention/bootstrap-dark.css +29 -0
- package/styles/mention/bootstrap-dark.scss +6 -0
- package/styles/mention/bootstrap.css +29 -0
- package/styles/mention/bootstrap.scss +6 -0
- package/styles/mention/bootstrap4.css +47 -0
- package/styles/mention/bootstrap4.scss +6 -0
- package/styles/mention/bootstrap5-dark.css +58 -0
- package/styles/mention/bootstrap5-dark.scss +6 -0
- package/styles/mention/bootstrap5.css +58 -0
- package/styles/mention/bootstrap5.scss +6 -0
- package/styles/mention/fabric-dark.css +29 -0
- package/styles/mention/fabric-dark.scss +6 -0
- package/styles/mention/fabric.css +29 -0
- package/styles/mention/fabric.scss +6 -0
- package/styles/mention/fluent-dark.css +58 -0
- package/styles/mention/fluent-dark.scss +6 -0
- package/styles/mention/fluent.css +58 -0
- package/styles/mention/fluent.scss +6 -0
- package/styles/mention/highcontrast-light.css +43 -0
- package/styles/mention/highcontrast-light.scss +6 -0
- package/styles/mention/highcontrast.css +43 -0
- package/styles/mention/highcontrast.scss +6 -0
- package/styles/mention/material-dark.css +29 -0
- package/styles/mention/material-dark.scss +6 -0
- package/styles/mention/material.css +29 -0
- package/styles/mention/material.scss +6 -0
- package/styles/mention/tailwind-dark.css +68 -0
- package/styles/mention/tailwind-dark.scss +6 -0
- package/styles/mention/tailwind.css +68 -0
- package/styles/mention/tailwind.scss +6 -0
- package/styles/multi-select/_all.scss +1 -1
- package/styles/multi-select/_bootstrap-dark-definition.scss +11 -1
- package/styles/multi-select/_bootstrap-definition.scss +9 -0
- package/styles/multi-select/_bootstrap4-definition.scss +20 -9
- package/styles/multi-select/_bootstrap5-definition.scss +11 -3
- package/styles/multi-select/_fabric-dark-definition.scss +16 -7
- package/styles/multi-select/_fabric-definition.scss +15 -6
- package/styles/multi-select/_fluent-definition.scss +11 -2
- package/styles/multi-select/_fusionnew-definition.scss +10 -2
- package/styles/multi-select/_highcontrast-definition.scss +59 -29
- package/styles/multi-select/_highcontrast-light-definition.scss +55 -25
- package/styles/multi-select/_layout.scss +91 -78
- package/styles/multi-select/_material-dark-definition.scss +10 -1
- package/styles/multi-select/_material-definition.scss +8 -0
- package/styles/multi-select/_material3-definition.scss +9 -2
- package/styles/multi-select/_tailwind-definition.scss +11 -4
- package/styles/multi-select/_theme.scss +20 -21
- package/styles/multi-select/bootstrap-dark.css +34 -8
- package/styles/multi-select/bootstrap.css +34 -8
- package/styles/multi-select/bootstrap4.css +46 -19
- package/styles/multi-select/bootstrap5-dark.css +38 -11
- package/styles/multi-select/bootstrap5.css +38 -11
- package/styles/multi-select/fabric-dark.css +42 -16
- package/styles/multi-select/fabric.css +42 -16
- package/styles/multi-select/fluent-dark.css +36 -9
- package/styles/multi-select/fluent.css +36 -9
- package/styles/multi-select/highcontrast-light.css +37 -8
- package/styles/multi-select/highcontrast.css +46 -17
- package/styles/multi-select/icons/_bootstrap5.scss +0 -1
- package/styles/multi-select/icons/_fluent.scss +0 -1
- package/styles/multi-select/icons/_fusionnew.scss +0 -1
- package/styles/multi-select/icons/_material-dark.scss +53 -54
- package/styles/multi-select/icons/_material.scss +53 -54
- package/styles/multi-select/icons/_material3.scss +0 -1
- package/styles/multi-select/icons/_tailwind.scss +0 -1
- package/styles/multi-select/material-dark.css +33 -7
- package/styles/multi-select/material.css +33 -7
- package/styles/multi-select/tailwind-dark.css +38 -9
- package/styles/multi-select/tailwind.css +38 -9
- package/styles/tailwind-dark.css +132 -47
- package/styles/tailwind-dark.scss +1 -0
- package/styles/tailwind.css +132 -47
- package/styles/tailwind.scss +1 -0
|
@@ -0,0 +1,1465 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
15
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
};
|
|
20
|
+
import { KeyboardEvents, compile, Property, EventHandler, Animation, formatUnit, append, attributes } from '@syncfusion/ej2-base';
|
|
21
|
+
import { isNullOrUndefined, detach, Event, Complex, addClass, removeClass, closest, isUndefined, getValue, NotifyPropertyChanges, Browser } from '@syncfusion/ej2-base';
|
|
22
|
+
import { FieldSettings } from '../drop-down-base/drop-down-base';
|
|
23
|
+
import { DropDownBase, dropDownBaseClasses } from '../drop-down-base/drop-down-base';
|
|
24
|
+
import { DataManager, Query } from '@syncfusion/ej2-data';
|
|
25
|
+
import { Popup, isCollide, createSpinner, showSpinner, hideSpinner, getZindexPartial } from '@syncfusion/ej2-popups';
|
|
26
|
+
import { highlightSearch, revertHighlightSearch } from '../common/highlight-search';
|
|
27
|
+
/**
|
|
28
|
+
* The Mention component is used to list someone or something based on user input in textarea, input,
|
|
29
|
+
* or any other editable element from which the user can select.
|
|
30
|
+
*/
|
|
31
|
+
var Mention = /** @class */ (function (_super) {
|
|
32
|
+
__extends(Mention, _super);
|
|
33
|
+
/**
|
|
34
|
+
* * Constructor for creating the widget
|
|
35
|
+
*
|
|
36
|
+
* @param {MentionModel} options - Specifies the MentionComponent model.
|
|
37
|
+
* @param {string | HTMLElement} element - Specifies the element to render as component.
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
function Mention(options, element) {
|
|
41
|
+
return _super.call(this, options, element) || this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* When property value changes happened, then onPropertyChanged method will execute the respective changes in this component.
|
|
45
|
+
*
|
|
46
|
+
* @param {MentionModel} newProp - Returns the dynamic property value of the component.
|
|
47
|
+
* @param {MentionModel} oldProp - Returns the previous property value of the component.
|
|
48
|
+
* @private
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
+
Mention.prototype.onPropertyChanged = function (newProp, oldProp) {
|
|
53
|
+
for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
|
|
54
|
+
var prop = _a[_i];
|
|
55
|
+
switch (prop) {
|
|
56
|
+
case 'minLength':
|
|
57
|
+
this.minLength = newProp.minLength;
|
|
58
|
+
break;
|
|
59
|
+
case 'suffixText':
|
|
60
|
+
this.suffixText = newProp.suffixText;
|
|
61
|
+
break;
|
|
62
|
+
case 'allowSpaces':
|
|
63
|
+
this.allowSpaces = newProp.allowSpaces;
|
|
64
|
+
break;
|
|
65
|
+
case 'mentionChar':
|
|
66
|
+
this.mentionChar = newProp.mentionChar;
|
|
67
|
+
break;
|
|
68
|
+
case 'showMentionChar':
|
|
69
|
+
this.showMentionChar = newProp.showMentionChar;
|
|
70
|
+
break;
|
|
71
|
+
case 'cssClass':
|
|
72
|
+
this.updateCssClass(newProp.cssClass, oldProp.cssClass);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
Mention.prototype.updateCssClass = function (newClass, oldClass) {
|
|
78
|
+
if (!isNullOrUndefined(oldClass)) {
|
|
79
|
+
oldClass = (oldClass.replace(/\s+/g, ' ')).trim();
|
|
80
|
+
}
|
|
81
|
+
if (!isNullOrUndefined(newClass)) {
|
|
82
|
+
newClass = (newClass.replace(/\s+/g, ' ')).trim();
|
|
83
|
+
}
|
|
84
|
+
this.setCssClass(newClass, [this.inputElement], oldClass);
|
|
85
|
+
if (this.popupObj) {
|
|
86
|
+
this.setCssClass(newClass, [this.popupObj.element], oldClass);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
Mention.prototype.setCssClass = function (cssClass, elements, oldClass) {
|
|
90
|
+
if (!isNullOrUndefined(oldClass) && oldClass !== '') {
|
|
91
|
+
removeClass(elements, oldClass.split(' '));
|
|
92
|
+
}
|
|
93
|
+
if (!isNullOrUndefined(cssClass) && cssClass !== '') {
|
|
94
|
+
addClass(elements, cssClass.split(' '));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
Mention.prototype.initializeData = function () {
|
|
98
|
+
this.isSelected = false;
|
|
99
|
+
this.isFiltered = false;
|
|
100
|
+
this.beforePopupOpen = false;
|
|
101
|
+
this.initRemoteRender = false;
|
|
102
|
+
this.isListResetted = false;
|
|
103
|
+
this.isPopupOpen = false;
|
|
104
|
+
this.isCollided = false;
|
|
105
|
+
this.lineBreak = false;
|
|
106
|
+
this.keyConfigure = {
|
|
107
|
+
tab: 'tab',
|
|
108
|
+
enter: '13',
|
|
109
|
+
escape: '27',
|
|
110
|
+
end: '35',
|
|
111
|
+
home: '36',
|
|
112
|
+
down: '40',
|
|
113
|
+
up: '38',
|
|
114
|
+
pageUp: '33',
|
|
115
|
+
pageDown: '34',
|
|
116
|
+
open: 'alt+40',
|
|
117
|
+
close: 'shift+tab',
|
|
118
|
+
hide: 'alt+38',
|
|
119
|
+
space: '32'
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Execute before render the list items
|
|
124
|
+
*
|
|
125
|
+
* @private
|
|
126
|
+
* @returns {void}
|
|
127
|
+
*/
|
|
128
|
+
Mention.prototype.preRender = function () {
|
|
129
|
+
this.initializeData();
|
|
130
|
+
_super.prototype.preRender.call(this);
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* To Initialize the control rendering
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
* @returns {void}
|
|
137
|
+
*/
|
|
138
|
+
Mention.prototype.render = function () {
|
|
139
|
+
this.inputElement = !isNullOrUndefined(this.target) ? ((typeof this.target) === 'string') ?
|
|
140
|
+
document.querySelector(this.target) : this.target : this.element;
|
|
141
|
+
if (this.isContentEditable(this.inputElement)) {
|
|
142
|
+
this.inputElement.setAttribute('contenteditable', 'true');
|
|
143
|
+
addClass([this.inputElement], ['e-mention']);
|
|
144
|
+
if (isNullOrUndefined(this.target)) {
|
|
145
|
+
addClass([this.inputElement], ['e-editable-element']);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.queryString = this.elementValue();
|
|
149
|
+
this.wireEvent();
|
|
150
|
+
};
|
|
151
|
+
Mention.prototype.wireEvent = function () {
|
|
152
|
+
EventHandler.add(this.inputElement, 'keyup', this.onKeyUp, this);
|
|
153
|
+
this.bindCommonEvent();
|
|
154
|
+
};
|
|
155
|
+
Mention.prototype.unWireEvent = function () {
|
|
156
|
+
EventHandler.remove(this.inputElement, 'keyup', this.onKeyUp);
|
|
157
|
+
this.unBindCommonEvent();
|
|
158
|
+
};
|
|
159
|
+
Mention.prototype.bindCommonEvent = function () {
|
|
160
|
+
if (!Browser.isDevice) {
|
|
161
|
+
this.keyboardModule = new KeyboardEvents(this.inputElement, {
|
|
162
|
+
keyAction: this.keyActionHandler.bind(this), keyConfigs: this.keyConfigure, eventName: 'keydown'
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Hides the spinner loader.
|
|
168
|
+
*
|
|
169
|
+
* @private
|
|
170
|
+
* @returns {void}
|
|
171
|
+
*/
|
|
172
|
+
Mention.prototype.hideSpinner = function () {
|
|
173
|
+
this.hideWaitingSpinner();
|
|
174
|
+
};
|
|
175
|
+
Mention.prototype.hideWaitingSpinner = function () {
|
|
176
|
+
if (!isNullOrUndefined(this.spinnerElement)) {
|
|
177
|
+
hideSpinner(this.spinnerElement);
|
|
178
|
+
}
|
|
179
|
+
if (!isNullOrUndefined(this.spinnerTemplate) && !isNullOrUndefined(this.spinnerTemplateElement)) {
|
|
180
|
+
detach(this.spinnerTemplateElement);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Shows the spinner loader.
|
|
185
|
+
*
|
|
186
|
+
* @returns {void}
|
|
187
|
+
*/
|
|
188
|
+
Mention.prototype.showWaitingSpinner = function () {
|
|
189
|
+
if (!isNullOrUndefined(this.popupObj)) {
|
|
190
|
+
if (isNullOrUndefined(this.spinnerTemplate) && isNullOrUndefined(this.spinnerElement)) {
|
|
191
|
+
this.spinnerElement = this.popupObj.element;
|
|
192
|
+
createSpinner({
|
|
193
|
+
target: this.spinnerElement,
|
|
194
|
+
width: Browser.isDevice ? '16px' : '14px'
|
|
195
|
+
}, this.createElement);
|
|
196
|
+
showSpinner(this.spinnerElement);
|
|
197
|
+
}
|
|
198
|
+
if (!isNullOrUndefined(this.spinnerTemplate)) {
|
|
199
|
+
this.setSpinnerTemplate();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
Mention.prototype.keyActionHandler = function (e) {
|
|
204
|
+
var isNavigation = (e.action === 'down' || e.action === 'up' || e.action === 'pageUp' || e.action === 'pageDown'
|
|
205
|
+
|| e.action === 'home' || e.action === 'end');
|
|
206
|
+
var isTabAction = e.action === 'tab' || e.action === 'close';
|
|
207
|
+
if (this.list === undefined && !this.isRequested && !isTabAction && e.action !== 'escape' && e.action !== 'space') {
|
|
208
|
+
this.renderList();
|
|
209
|
+
}
|
|
210
|
+
if (isNullOrUndefined(this.list) || (!isNullOrUndefined(this.liCollections) &&
|
|
211
|
+
isNavigation && this.liCollections.length === 0) || this.isRequested) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (e.action === 'escape') {
|
|
215
|
+
e.preventDefault();
|
|
216
|
+
}
|
|
217
|
+
this.isSelected = e.action === 'escape' ? false : this.isSelected;
|
|
218
|
+
switch (e.action) {
|
|
219
|
+
case 'down':
|
|
220
|
+
case 'up':
|
|
221
|
+
this.updateUpDownAction(e);
|
|
222
|
+
break;
|
|
223
|
+
case 'tab':
|
|
224
|
+
if (this.isPopupOpen) {
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
var li = this.list.querySelector('.' + dropDownBaseClasses.selected);
|
|
227
|
+
if (li) {
|
|
228
|
+
this.setSelection(li, e);
|
|
229
|
+
}
|
|
230
|
+
if (this.isPopupOpen) {
|
|
231
|
+
this.hidePopup(e);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case 'enter':
|
|
236
|
+
if (this.isPopupOpen) {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
if (this.popupObj && this.popupObj.element.contains(this.selectedLI)) {
|
|
239
|
+
this.setValue(e);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
case 'escape':
|
|
244
|
+
if (this.isPopupOpen) {
|
|
245
|
+
this.hidePopup(e);
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
Mention.prototype.updateUpDownAction = function (e) {
|
|
251
|
+
var focusEle = this.list.querySelector('.' + dropDownBaseClasses.focus);
|
|
252
|
+
if (this.isSelectFocusItem(focusEle)) {
|
|
253
|
+
this.setSelection(focusEle, e);
|
|
254
|
+
}
|
|
255
|
+
else if (!isNullOrUndefined(this.liCollections)) {
|
|
256
|
+
var li = this.list.querySelector('.' + dropDownBaseClasses.selected);
|
|
257
|
+
if (!isNullOrUndefined(li)) {
|
|
258
|
+
var value = this.getFormattedValue(li.getAttribute('data-value'));
|
|
259
|
+
this.activeIndex = this.getIndexByValue(value);
|
|
260
|
+
}
|
|
261
|
+
var index = e.action === 'down' ? this.activeIndex + 1 : this.activeIndex - 1;
|
|
262
|
+
var startIndex = 0;
|
|
263
|
+
startIndex = e.action === 'down' && isNullOrUndefined(this.activeIndex) ? 0 : this.liCollections.length - 1;
|
|
264
|
+
index = index < 0 ? this.liCollections.length - 1 : index === this.liCollections.length ? 0 : index;
|
|
265
|
+
var nextItem = isNullOrUndefined(this.activeIndex) ?
|
|
266
|
+
this.liCollections[startIndex] : this.liCollections[index];
|
|
267
|
+
if (!isNullOrUndefined(nextItem)) {
|
|
268
|
+
this.setSelection(nextItem, e);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (this.isPopupOpen) {
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
Mention.prototype.isSelectFocusItem = function (element) {
|
|
276
|
+
return !isNullOrUndefined(element);
|
|
277
|
+
};
|
|
278
|
+
Mention.prototype.unBindCommonEvent = function () {
|
|
279
|
+
if (!Browser.isDevice) {
|
|
280
|
+
this.keyboardModule.destroy();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
Mention.prototype.onKeyUp = function (e) {
|
|
284
|
+
var rangetextContent;
|
|
285
|
+
if (this.isContentEditable(this.inputElement)) {
|
|
286
|
+
this.range = this.getCurrentRange();
|
|
287
|
+
rangetextContent = this.range.startContainer.textContent.split('');
|
|
288
|
+
}
|
|
289
|
+
var currentRange = this.getTextRange();
|
|
290
|
+
var lastWordRange = this.getLastLetter(currentRange);
|
|
291
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
292
|
+
var Regex = new RegExp(this.mentionChar, 'g');
|
|
293
|
+
var charRegex = new RegExp('[a-zA-Z]', 'g');
|
|
294
|
+
if (e.key === 'Shift' || e.keyCode === 37 || e.keyCode === 39) {
|
|
295
|
+
if ((e.keyCode === 37 || e.keyCode === 39) && !isNullOrUndefined(currentRange) &&
|
|
296
|
+
currentRange.indexOf(this.mentionChar) === -1 && this.isPopupOpen) {
|
|
297
|
+
this.hidePopup();
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if ((!currentRange || !lastWordRange) || e.code === 'Enter' || e.keyCode === 27 ||
|
|
302
|
+
(lastWordRange.match(Regex) && lastWordRange.match(Regex).length > 1) ||
|
|
303
|
+
(this.isContentEditable(this.inputElement) && this.range.startContainer &&
|
|
304
|
+
this.range.startContainer.previousElementSibling && this.range.startContainer.textContent.split('').length > 0 &&
|
|
305
|
+
(rangetextContent.length === 1 || rangetextContent[rangetextContent.length - 2].indexOf('') === -1 ||
|
|
306
|
+
this.range.startContainer.nodeType === 1))) {
|
|
307
|
+
if (this.allowSpaces && currentRange && currentRange.trim() !== '' && charRegex.test(currentRange) && currentRange.indexOf(this.mentionChar) !== -1
|
|
308
|
+
&& !this.isMatchedText() && (currentRange.length > 1 && currentRange.replace(/\u00A0/g, ' ').charAt(currentRange.length - 2) !== ' ') &&
|
|
309
|
+
(this.list && this.list.querySelectorAll('ul').length > 0)) {
|
|
310
|
+
this.queryString = currentRange.substring(currentRange.lastIndexOf(this.mentionChar) + 1).replace('\u00a0', ' ');
|
|
311
|
+
this.searchLists(e);
|
|
312
|
+
}
|
|
313
|
+
else if (this.isPopupOpen && (!this.allowSpaces || !lastWordRange)) {
|
|
314
|
+
this.hidePopup();
|
|
315
|
+
this.lineBreak = true;
|
|
316
|
+
}
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
this.queryString = lastWordRange.replace(this.mentionChar, '');
|
|
320
|
+
if (this.mentionChar.charCodeAt(0) === lastWordRange.charCodeAt(0) &&
|
|
321
|
+
this.queryString !== '' && e.keyCode !== 38 && e.keyCode !== 40 && !this.lineBreak) {
|
|
322
|
+
this.searchLists(e);
|
|
323
|
+
if (!this.isPopupOpen && this.queryString.length >= this.minLength) {
|
|
324
|
+
if (!this.isContentEditable(this.inputElement)) {
|
|
325
|
+
this.showPopup();
|
|
326
|
+
}
|
|
327
|
+
else if (this.isContentEditable(this.inputElement) && this.range && this.range.startContainer !== this.inputElement && e.keyCode !== 9) {
|
|
328
|
+
this.showPopup();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else if (lastWordRange.indexOf(this.mentionChar) === 0 && !this.isPopupOpen && e.keyCode !== 8 && (!this.popupObj ||
|
|
333
|
+
(isNullOrUndefined(this.target) && !document.body.contains(this.popupObj.element) ||
|
|
334
|
+
!isNullOrUndefined(this.target) && document.body.contains(this.popupObj.element)))) {
|
|
335
|
+
if (this.initRemoteRender && this.list && this.list.classList.contains('e-nodata')) {
|
|
336
|
+
this.searchLists(e);
|
|
337
|
+
}
|
|
338
|
+
this.resetList(this.dataSource, this.fields);
|
|
339
|
+
if (isNullOrUndefined(this.list)) {
|
|
340
|
+
this.initValue();
|
|
341
|
+
}
|
|
342
|
+
if (!this.isPopupOpen && e.keyCode !== 38 && e.keyCode !== 40) {
|
|
343
|
+
this.showPopup();
|
|
344
|
+
if (this.initRemoteRender && this.list.querySelectorAll('li').length === 0) {
|
|
345
|
+
this.showWaitingSpinner();
|
|
346
|
+
}
|
|
347
|
+
this.lineBreak = false;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else if (this.allowSpaces && this.queryString !== '' && currentRange && currentRange.trim() !== '' && currentRange.replace('\u00a0', ' ').lastIndexOf(' ') < currentRange.length - 1 &&
|
|
351
|
+
e.keyCode !== 38 && e.keyCode !== 40 && e.keyCode !== 8 && this.mentionChar.charCodeAt(0) === lastWordRange.charCodeAt(0)) {
|
|
352
|
+
this.queryString = currentRange.substring(currentRange.lastIndexOf(this.mentionChar) + 1).replace('\u00a0', ' ');
|
|
353
|
+
this.searchLists(e);
|
|
354
|
+
}
|
|
355
|
+
else if (this.queryString === '' && this.isPopupOpen && e.keyCode !== 38 && e.keyCode !== 40 && this.mentionChar.charCodeAt(0) === lastWordRange.charCodeAt(0)) {
|
|
356
|
+
this.searchLists(e);
|
|
357
|
+
if (!this.isListResetted) {
|
|
358
|
+
this.resetList(this.dataSource, this.fields);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
this.isListResetted = false;
|
|
362
|
+
};
|
|
363
|
+
Mention.prototype.isMatchedText = function () {
|
|
364
|
+
var isMatched = false;
|
|
365
|
+
for (var i = 0; i < (this.liCollections && this.liCollections.length); i++) {
|
|
366
|
+
if (this.getTextRange() &&
|
|
367
|
+
this.getTextRange().substring(this.getTextRange().lastIndexOf(this.mentionChar) + 1).replace('\u00a0', ' ').trim() === this.liCollections[i].getAttribute('data-value').toLowerCase()) {
|
|
368
|
+
isMatched = true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return isMatched;
|
|
372
|
+
};
|
|
373
|
+
Mention.prototype.getCurrentRange = function () {
|
|
374
|
+
this.range = this.inputElement.ownerDocument.getSelection().getRangeAt(0);
|
|
375
|
+
return this.range;
|
|
376
|
+
};
|
|
377
|
+
Mention.prototype.searchLists = function (e) {
|
|
378
|
+
var _this = this;
|
|
379
|
+
this.isDataFetched = false;
|
|
380
|
+
if (isNullOrUndefined(this.list)) {
|
|
381
|
+
_super.prototype.render.call(this);
|
|
382
|
+
this.unWireListEvents();
|
|
383
|
+
this.wireListEvents();
|
|
384
|
+
}
|
|
385
|
+
if (e.type !== 'mousedown' && (e.keyCode === 40 || e.keyCode === 38)) {
|
|
386
|
+
this.queryString = this.queryString === '' ? null : this.queryString;
|
|
387
|
+
this.beforePopupOpen = true;
|
|
388
|
+
this.resetList(this.dataSource, this.fields);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
this.isSelected = false;
|
|
392
|
+
this.activeIndex = null;
|
|
393
|
+
var eventArgs = {
|
|
394
|
+
preventDefaultAction: false,
|
|
395
|
+
text: this.queryString,
|
|
396
|
+
updateData: function (dataSource, query, fields) {
|
|
397
|
+
if (eventArgs.cancel) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
_this.isFiltered = true;
|
|
401
|
+
_this.filterAction(dataSource, query, fields);
|
|
402
|
+
},
|
|
403
|
+
cancel: false
|
|
404
|
+
};
|
|
405
|
+
this.trigger('filtering', eventArgs, function (eventArgs) {
|
|
406
|
+
if (!eventArgs.cancel && !_this.isFiltered && !eventArgs.preventDefaultAction) {
|
|
407
|
+
_this.filterAction(_this.dataSource, null, _this.fields);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
Mention.prototype.filterAction = function (dataSource, query, fields) {
|
|
412
|
+
this.beforePopupOpen = true;
|
|
413
|
+
if (this.queryString.length >= this.minLength) {
|
|
414
|
+
this.resetList(dataSource, fields, query);
|
|
415
|
+
this.isListResetted = true;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
if (this.isPopupOpen) {
|
|
419
|
+
this.hidePopup();
|
|
420
|
+
}
|
|
421
|
+
this.beforePopupOpen = false;
|
|
422
|
+
}
|
|
423
|
+
this.setDataIndex();
|
|
424
|
+
this.renderReactTemplates();
|
|
425
|
+
};
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
427
|
+
Mention.prototype.onActionComplete = function (ulElement, list, e, isUpdated) {
|
|
428
|
+
_super.prototype.onActionComplete.call(this, ulElement, list, e);
|
|
429
|
+
if (this.isActive) {
|
|
430
|
+
if (!isNullOrUndefined(ulElement)) {
|
|
431
|
+
attributes(ulElement, { 'id': this.inputElement.id + '_options', 'role': 'listbox', 'aria-hidden': 'false' });
|
|
432
|
+
}
|
|
433
|
+
var focusItem = ulElement.querySelector('.' + dropDownBaseClasses.li);
|
|
434
|
+
if (focusItem) {
|
|
435
|
+
focusItem.classList.add(dropDownBaseClasses.selected);
|
|
436
|
+
this.selectedLI = focusItem;
|
|
437
|
+
var value = this.getFormattedValue(focusItem.getAttribute('data-value'));
|
|
438
|
+
this.selectEventCallback(focusItem, this.getDataByValue(value), value, true);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
Mention.prototype.setDataIndex = function () {
|
|
443
|
+
for (var i = 0; this.liCollections && i < this.liCollections.length; i++) {
|
|
444
|
+
this.liCollections[i].setAttribute('data-index', i.toString());
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
Mention.prototype.listOption = function (dataSource, fieldsSettings) {
|
|
448
|
+
var _this = this;
|
|
449
|
+
var fields = _super.prototype.listOption.call(this, dataSource, fieldsSettings);
|
|
450
|
+
if (isNullOrUndefined(fields.itemCreated)) {
|
|
451
|
+
fields.itemCreated = function (e) {
|
|
452
|
+
if (_this.highlight) {
|
|
453
|
+
if (_this.inputElement.tagName === _this.getNgDirective() && _this.itemTemplate) {
|
|
454
|
+
setTimeout(function () {
|
|
455
|
+
highlightSearch(e.item, _this.queryString, _this.ignoreCase, _this.filterType);
|
|
456
|
+
}, 0);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
highlightSearch(e.item, _this.queryString, _this.ignoreCase, _this.filterType);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
var itemCreated_1 = fields.itemCreated;
|
|
466
|
+
fields.itemCreated = function (e) {
|
|
467
|
+
if (_this.highlight) {
|
|
468
|
+
highlightSearch(e.item, _this.queryString, _this.ignoreCase, _this.filterType);
|
|
469
|
+
}
|
|
470
|
+
itemCreated_1.apply(_this, [e]);
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
return fields;
|
|
474
|
+
};
|
|
475
|
+
Mention.prototype.elementValue = function () {
|
|
476
|
+
if (!this.isContentEditable(this.inputElement)) {
|
|
477
|
+
return this.inputElement.value.replace(this.mentionChar, '');
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
return this.inputElement.textContent.replace(this.mentionChar, '');
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
Mention.prototype.getQuery = function (query) {
|
|
484
|
+
var filterQuery = query ? query.clone() : this.query ? this.query.clone() : new Query();
|
|
485
|
+
var filterType = (this.queryString === '' && !isNullOrUndefined(this.elementValue())) ? 'equal' : this.filterType;
|
|
486
|
+
var queryString = (this.queryString === '' && !isNullOrUndefined(this.elementValue())) ?
|
|
487
|
+
this.elementValue() : this.queryString;
|
|
488
|
+
if (this.isFiltered) {
|
|
489
|
+
return filterQuery;
|
|
490
|
+
}
|
|
491
|
+
if (this.queryString !== null && this.queryString !== '') {
|
|
492
|
+
var dataType = this.typeOfData(this.dataSource).typeof;
|
|
493
|
+
if (!(this.dataSource instanceof DataManager) && dataType === 'string' || dataType === 'number') {
|
|
494
|
+
filterQuery.where('', filterType, queryString, this.ignoreCase, this.ignoreAccent);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
var mapping = !isNullOrUndefined(this.fields.text) ? this.fields.text : '';
|
|
498
|
+
filterQuery.where(mapping, filterType, queryString, this.ignoreCase, this.ignoreAccent);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (!isNullOrUndefined(this.suggestionCount)) {
|
|
502
|
+
// Since defualt value of suggestioncount is 25, checked the condition
|
|
503
|
+
if (this.suggestionCount !== 25) {
|
|
504
|
+
for (var queryElements = 0; queryElements < filterQuery.queries.length; queryElements++) {
|
|
505
|
+
if (filterQuery.queries[queryElements].fn === 'onTake') {
|
|
506
|
+
filterQuery.queries.splice(queryElements, 1);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
filterQuery.take(this.suggestionCount);
|
|
511
|
+
}
|
|
512
|
+
return filterQuery;
|
|
513
|
+
};
|
|
514
|
+
Mention.prototype.renderHightSearch = function () {
|
|
515
|
+
if (this.highlight) {
|
|
516
|
+
for (var i = 0; i < this.liCollections.length; i++) {
|
|
517
|
+
var isHighlight = this.ulElement.querySelector('.e-active');
|
|
518
|
+
if (!isHighlight) {
|
|
519
|
+
revertHighlightSearch(this.liCollections[i]);
|
|
520
|
+
highlightSearch(this.liCollections[i], this.queryString, this.ignoreCase, this.filterType);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
Mention.prototype.getTextRange = function () {
|
|
526
|
+
var text;
|
|
527
|
+
if (!this.isContentEditable(this.inputElement)) {
|
|
528
|
+
var component = this.inputElement;
|
|
529
|
+
if (!isNullOrUndefined(component)) {
|
|
530
|
+
var startPos = component.selectionStart;
|
|
531
|
+
if (component.value && startPos >= 0) {
|
|
532
|
+
text = component.value.substring(0, startPos);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
if (this.range) {
|
|
538
|
+
var selectedElem = this.range.startContainer;
|
|
539
|
+
if (!isNullOrUndefined(selectedElem)) {
|
|
540
|
+
var workingNodeContent = selectedElem.textContent;
|
|
541
|
+
var selectStartOffset = this.range.startOffset;
|
|
542
|
+
if (workingNodeContent && selectStartOffset >= 0) {
|
|
543
|
+
text = workingNodeContent.substring(0, selectStartOffset);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return text;
|
|
549
|
+
};
|
|
550
|
+
Mention.prototype.getLastLetter = function (text) {
|
|
551
|
+
if (isNullOrUndefined(text)) {
|
|
552
|
+
return '';
|
|
553
|
+
}
|
|
554
|
+
var textValue = text.replace(/\u00A0/g, ' ');
|
|
555
|
+
var words = textValue.split(/\s+/);
|
|
556
|
+
var wordCnt = words.length - 1;
|
|
557
|
+
return words[wordCnt].trim();
|
|
558
|
+
};
|
|
559
|
+
Mention.prototype.isContentEditable = function (element) {
|
|
560
|
+
return element && element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA';
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* Opens the popup that displays the list of items.
|
|
564
|
+
*
|
|
565
|
+
* @returns {void}
|
|
566
|
+
*/
|
|
567
|
+
Mention.prototype.showPopup = function () {
|
|
568
|
+
this.beforePopupOpen = true;
|
|
569
|
+
if (isNullOrUndefined(this.list)) {
|
|
570
|
+
this.initValue();
|
|
571
|
+
}
|
|
572
|
+
this.renderPopup();
|
|
573
|
+
attributes(this.inputElement, { 'aria-activedescendant': this.selectedElementID });
|
|
574
|
+
if (this.selectedElementID == null) {
|
|
575
|
+
this.inputElement.removeAttribute('aria-activedescendant');
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
/* eslint-disable valid-jsdoc, jsdoc/require-param */
|
|
579
|
+
/**
|
|
580
|
+
* Hides the popup if it is in an open state.
|
|
581
|
+
*
|
|
582
|
+
* @returns {void}
|
|
583
|
+
*/
|
|
584
|
+
Mention.prototype.hidePopup = function (e) {
|
|
585
|
+
this.removeSelection();
|
|
586
|
+
this.closePopup(0, e);
|
|
587
|
+
};
|
|
588
|
+
Mention.prototype.closePopup = function (delay, e) {
|
|
589
|
+
var _this = this;
|
|
590
|
+
if (!(this.popupObj && document.body.contains(this.popupObj.element) && this.beforePopupOpen)) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
EventHandler.remove(document, 'mousedown', this.onDocumentClick);
|
|
594
|
+
this.inputElement.removeAttribute('aria-owns');
|
|
595
|
+
this.inputElement.removeAttribute('aria-activedescendant');
|
|
596
|
+
this.beforePopupOpen = false;
|
|
597
|
+
var animModel = {
|
|
598
|
+
name: 'FadeOut',
|
|
599
|
+
duration: 100,
|
|
600
|
+
delay: delay ? delay : 0
|
|
601
|
+
};
|
|
602
|
+
var popupInstance = this.popupObj;
|
|
603
|
+
var eventArgs = { popup: popupInstance, cancel: false, animation: animModel, event: e || null };
|
|
604
|
+
this.trigger('closed', eventArgs, function (eventArgs) {
|
|
605
|
+
if (!eventArgs.cancel && _this.popupObj) {
|
|
606
|
+
if (_this.isPopupOpen) {
|
|
607
|
+
_this.popupObj.hide(new Animation(eventArgs.animation));
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
_this.destroyPopup();
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
Mention.prototype.renderPopup = function () {
|
|
616
|
+
var _this = this;
|
|
617
|
+
var args = { cancel: false };
|
|
618
|
+
this.trigger('beforeOpen', args, function (args) {
|
|
619
|
+
if (!args.cancel) {
|
|
620
|
+
var popupEle_1;
|
|
621
|
+
if (isNullOrUndefined(_this.target)) {
|
|
622
|
+
popupEle_1 = _this.createElement('div', {
|
|
623
|
+
id: _this.inputElement.id + '_popup', className: 'e-mention e-popup ' + (_this.cssClass != null ? _this.cssClass : '')
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
popupEle_1 = _this.element;
|
|
628
|
+
if (_this.cssClass != null) {
|
|
629
|
+
addClass([popupEle_1], _this.cssClass.split(' '));
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
if (!isNullOrUndefined(_this.target)) {
|
|
633
|
+
popupEle_1.id = _this.inputElement.id + '_popup';
|
|
634
|
+
addClass([popupEle_1], ['e-mention', 'e-popup', 'e-popup-close']);
|
|
635
|
+
}
|
|
636
|
+
_this.listHeight = formatUnit(_this.popupHeight);
|
|
637
|
+
if (!isNullOrUndefined(_this.list.querySelector('li')) && !_this.initRemoteRender) {
|
|
638
|
+
var li = _this.list.querySelector('.' + dropDownBaseClasses.focus);
|
|
639
|
+
if (!isNullOrUndefined(li)) {
|
|
640
|
+
_this.selectedLI = li;
|
|
641
|
+
var value = _this.getFormattedValue(li.getAttribute('data-value'));
|
|
642
|
+
_this.selectEventCallback(li, _this.getDataByValue(value), value, true);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
append([_this.list], popupEle_1);
|
|
646
|
+
if ((!_this.popupObj || !document.body.contains(_this.popupObj.element)) ||
|
|
647
|
+
!document.contains(popupEle_1) && isNullOrUndefined(_this.target)) {
|
|
648
|
+
document.body.appendChild(popupEle_1);
|
|
649
|
+
}
|
|
650
|
+
var coordinates_1;
|
|
651
|
+
popupEle_1.style.visibility = 'hidden';
|
|
652
|
+
_this.setHeight(popupEle_1);
|
|
653
|
+
var offsetValue = 0;
|
|
654
|
+
var left = 0;
|
|
655
|
+
_this.initializePopup(popupEle_1, offsetValue, left);
|
|
656
|
+
_this.checkCollision(popupEle_1);
|
|
657
|
+
popupEle_1.style.visibility = 'visible';
|
|
658
|
+
if (!isNullOrUndefined(_this.list)) {
|
|
659
|
+
_this.unWireListEvents();
|
|
660
|
+
_this.wireListEvents();
|
|
661
|
+
}
|
|
662
|
+
_this.selectedElementID = _this.selectedLI ? _this.selectedLI.id : null;
|
|
663
|
+
attributes(_this.inputElement, { 'aria-owns': _this.inputElement.id + '_options', 'aria-activedescendant': _this.selectedElementID });
|
|
664
|
+
if (_this.selectedElementID == null) {
|
|
665
|
+
_this.inputElement.removeAttribute('aria-activedescendant');
|
|
666
|
+
}
|
|
667
|
+
var animModel = { name: 'FadeIn', duration: 100 };
|
|
668
|
+
_this.beforePopupOpen = true;
|
|
669
|
+
var popupInstance = _this.popupObj;
|
|
670
|
+
var eventArgs = { popup: popupInstance, cancel: false, animation: animModel };
|
|
671
|
+
_this.trigger('opened', eventArgs, function (eventArgs) {
|
|
672
|
+
if (!eventArgs.cancel) {
|
|
673
|
+
_this.renderReactTemplates();
|
|
674
|
+
_this.popupObj.show(new Animation(eventArgs.animation), (_this.zIndex === 1000) ? _this.inputElement : null);
|
|
675
|
+
if (isNullOrUndefined(_this.getTriggerCharPosition())) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
coordinates_1 = _this.getCoordinates(_this.inputElement, _this.getTriggerCharPosition());
|
|
679
|
+
if (!_this.isCollided) {
|
|
680
|
+
popupEle_1.style.cssText = 'top: '.concat(coordinates_1.top.toString(), 'px;\n left: ').concat(coordinates_1.left.toString(), 'px;\nposition: absolute;\n display: block;');
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
popupEle_1.style.left = formatUnit(coordinates_1.left);
|
|
684
|
+
_this.isCollided = false;
|
|
685
|
+
}
|
|
686
|
+
popupEle_1.style.width = _this.popupWidth !== '100%' && !isNullOrUndefined(_this.popupWidth) ? formatUnit(_this.popupWidth) : 'auto';
|
|
687
|
+
_this.setHeight(popupEle_1);
|
|
688
|
+
popupEle_1.style.zIndex = _this.zIndex === 1000 ? getZindexPartial(popupEle_1).toString() : _this.zIndex.toString();
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
_this.beforePopupOpen = false;
|
|
692
|
+
_this.destroyPopup();
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
_this.beforePopupOpen = false;
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
Mention.prototype.setHeight = function (popupEle) {
|
|
702
|
+
if (this.popupHeight !== 'auto') {
|
|
703
|
+
this.list.style.maxHeight = (parseInt(this.listHeight, 10) - 2).toString() + 'px'; // due to box-sizing property
|
|
704
|
+
popupEle.style.maxHeight = formatUnit(this.popupHeight);
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
popupEle.style.height = 'auto';
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
Mention.prototype.checkCollision = function (popupEle) {
|
|
711
|
+
if (!Browser.isDevice || (Browser.isDevice && !(this.getModuleName() === 'mention'))) {
|
|
712
|
+
var collision = isCollide(popupEle);
|
|
713
|
+
if (collision.length > 0) {
|
|
714
|
+
popupEle.style.marginTop = -parseInt(getComputedStyle(popupEle).marginTop, 10) + 'px';
|
|
715
|
+
this.isCollided = true;
|
|
716
|
+
}
|
|
717
|
+
this.popupObj.resolveCollision();
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
Mention.prototype.getTriggerCharPosition = function () {
|
|
721
|
+
var mostRecentTriggerCharPos;
|
|
722
|
+
var currentRange = this.getTextRange();
|
|
723
|
+
if (currentRange !== undefined && currentRange !== null) {
|
|
724
|
+
mostRecentTriggerCharPos = 0;
|
|
725
|
+
var idx = currentRange.lastIndexOf(this.mentionChar);
|
|
726
|
+
if (idx >= mostRecentTriggerCharPos) {
|
|
727
|
+
mostRecentTriggerCharPos = idx;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return mostRecentTriggerCharPos;
|
|
731
|
+
};
|
|
732
|
+
Mention.prototype.initializePopup = function (element, offsetValue, left) {
|
|
733
|
+
var _this = this;
|
|
734
|
+
this.popupObj = new Popup(element, {
|
|
735
|
+
width: this.setWidth(), targetType: 'relative',
|
|
736
|
+
relateTo: this.inputElement, collision: { X: 'flip', Y: 'flip' }, offsetY: offsetValue,
|
|
737
|
+
enableRtl: this.enableRtl, offsetX: left, position: { X: 'top', Y: 'left' }, actionOnScroll: 'hide',
|
|
738
|
+
zIndex: this.zIndex,
|
|
739
|
+
close: function () {
|
|
740
|
+
_this.destroyPopup();
|
|
741
|
+
},
|
|
742
|
+
open: function () {
|
|
743
|
+
EventHandler.add(document, 'mousedown', _this.onDocumentClick, _this);
|
|
744
|
+
_this.isPopupOpen = true;
|
|
745
|
+
_this.setDataIndex();
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
};
|
|
749
|
+
Mention.prototype.setWidth = function () {
|
|
750
|
+
var width = formatUnit(this.popupWidth);
|
|
751
|
+
if (width.indexOf('%') > -1) {
|
|
752
|
+
var inputWidth = this.inputElement.offsetWidth * parseFloat(width) / 100;
|
|
753
|
+
width = inputWidth.toString() + 'px';
|
|
754
|
+
}
|
|
755
|
+
return width;
|
|
756
|
+
};
|
|
757
|
+
Mention.prototype.destroyPopup = function () {
|
|
758
|
+
this.isPopupOpen = false;
|
|
759
|
+
this.popupObj.destroy();
|
|
760
|
+
if (isNullOrUndefined(this.target)) {
|
|
761
|
+
detach(this.popupObj.element);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
this.popupObj.element.innerHTML = '';
|
|
765
|
+
this.popupObj.element.removeAttribute('style');
|
|
766
|
+
this.popupObj.element.removeAttribute('aria-disabled');
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
Mention.prototype.onDocumentClick = function (e) {
|
|
770
|
+
var target = e.target;
|
|
771
|
+
if (!(!isNullOrUndefined(this.popupObj) && closest(target, '#' + this.popupObj.element.id))) {
|
|
772
|
+
this.hidePopup(e);
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
Mention.prototype.getCoordinates = function (element, position) {
|
|
776
|
+
var properties = ['direction', 'boxSizing', 'width', 'height', 'overflowX', 'overflowY', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', 'letterSpacing', 'wordSpacing'];
|
|
777
|
+
var div;
|
|
778
|
+
var span;
|
|
779
|
+
var range;
|
|
780
|
+
var globalRange;
|
|
781
|
+
var coordinates;
|
|
782
|
+
var computed;
|
|
783
|
+
var rect;
|
|
784
|
+
if (!this.isContentEditable(this.inputElement)) {
|
|
785
|
+
div = this.createElement('div', { className: 'e-form-mirror-div' });
|
|
786
|
+
document.body.appendChild(div);
|
|
787
|
+
computed = getComputedStyle(element);
|
|
788
|
+
div.style.position = 'absolute';
|
|
789
|
+
div.style.visibility = 'hidden';
|
|
790
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
791
|
+
properties.forEach(function (prop) {
|
|
792
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
793
|
+
div.style[prop] = computed[prop];
|
|
794
|
+
});
|
|
795
|
+
div.textContent = element.value.substring(0, position);
|
|
796
|
+
if (this.inputElement.nodeName === 'INPUT') {
|
|
797
|
+
div.textContent = div.textContent.replace(/\s/g, '\u00a0');
|
|
798
|
+
}
|
|
799
|
+
span = this.createElement('span');
|
|
800
|
+
span.textContent = element.value.substring(position) || '.';
|
|
801
|
+
div.appendChild(span);
|
|
802
|
+
rect = element.getBoundingClientRect();
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
var selectedNodePosition = this.getTriggerCharPosition();
|
|
806
|
+
globalRange = this.range;
|
|
807
|
+
range = document.createRange();
|
|
808
|
+
range.setStart(globalRange.startContainer, selectedNodePosition);
|
|
809
|
+
range.setEnd(globalRange.startContainer, selectedNodePosition);
|
|
810
|
+
range.collapse(false);
|
|
811
|
+
rect = range.getBoundingClientRect();
|
|
812
|
+
}
|
|
813
|
+
var doc = document.documentElement;
|
|
814
|
+
var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
|
|
815
|
+
var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
|
816
|
+
if (!this.isContentEditable(this.inputElement)) {
|
|
817
|
+
coordinates = {
|
|
818
|
+
top: rect.top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth, 10) +
|
|
819
|
+
parseInt(computed.fontSize, 10) + 3 - element.scrollTop,
|
|
820
|
+
left: rect.left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth, 10)
|
|
821
|
+
};
|
|
822
|
+
document.body.removeChild(div);
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
coordinates = {
|
|
826
|
+
top: rect.top + windowTop + parseInt(getComputedStyle(this.inputElement).fontSize, 10),
|
|
827
|
+
left: rect.left + windowLeft
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
return coordinates;
|
|
831
|
+
};
|
|
832
|
+
Mention.prototype.initValue = function () {
|
|
833
|
+
this.renderList();
|
|
834
|
+
if (this.dataSource instanceof DataManager) {
|
|
835
|
+
this.initRemoteRender = true;
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
this.updateValues();
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
Mention.prototype.updateValues = function () {
|
|
842
|
+
var li = this.list.querySelector('.' + dropDownBaseClasses.focus);
|
|
843
|
+
if (!isNullOrUndefined(li)) {
|
|
844
|
+
this.setSelection(li, null);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
Mention.prototype.renderList = function () {
|
|
848
|
+
_super.prototype.render.call(this);
|
|
849
|
+
this.unWireListEvents();
|
|
850
|
+
this.wireListEvents();
|
|
851
|
+
};
|
|
852
|
+
/**
|
|
853
|
+
* Event binding for list
|
|
854
|
+
*
|
|
855
|
+
* @returns {void}
|
|
856
|
+
*/
|
|
857
|
+
Mention.prototype.wireListEvents = function () {
|
|
858
|
+
EventHandler.add(this.list, 'click', this.onMouseClick, this);
|
|
859
|
+
EventHandler.add(this.list, 'mouseover', this.onMouseOver, this);
|
|
860
|
+
EventHandler.add(this.list, 'mouseout', this.onMouseLeave, this);
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* Event un binding for list items.
|
|
864
|
+
*
|
|
865
|
+
* @returns {void}
|
|
866
|
+
*/
|
|
867
|
+
Mention.prototype.unWireListEvents = function () {
|
|
868
|
+
EventHandler.remove(this.list, 'click', this.onMouseClick);
|
|
869
|
+
EventHandler.remove(this.list, 'mouseover', this.onMouseOver);
|
|
870
|
+
EventHandler.remove(this.list, 'mouseout', this.onMouseLeave);
|
|
871
|
+
};
|
|
872
|
+
Mention.prototype.onMouseClick = function (e) {
|
|
873
|
+
var target = e.target;
|
|
874
|
+
var li = closest(target, '.' + dropDownBaseClasses.li);
|
|
875
|
+
if (!this.isValidLI(li)) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
this.setSelection(li, e);
|
|
879
|
+
var delay = 100;
|
|
880
|
+
this.closePopup(delay, e);
|
|
881
|
+
this.inputElement.focus();
|
|
882
|
+
};
|
|
883
|
+
Mention.prototype.updateSelectedItem = function (li, e, preventSelect, isSelection) {
|
|
884
|
+
var _this = this;
|
|
885
|
+
this.removeSelection();
|
|
886
|
+
li.classList.add(dropDownBaseClasses.selected);
|
|
887
|
+
this.removeHover();
|
|
888
|
+
var value = this.getFormattedValue(li.getAttribute('data-value'));
|
|
889
|
+
var selectedData = this.getDataByValue(value);
|
|
890
|
+
if (!preventSelect && !isNullOrUndefined(e)) {
|
|
891
|
+
var items = this.detachChanges(selectedData);
|
|
892
|
+
this.isSelected = true;
|
|
893
|
+
var eventArgs = {
|
|
894
|
+
e: e,
|
|
895
|
+
item: li,
|
|
896
|
+
itemData: items,
|
|
897
|
+
isInteracted: e ? true : false,
|
|
898
|
+
cancel: false
|
|
899
|
+
};
|
|
900
|
+
this.trigger('select', eventArgs, function (eventArgs) {
|
|
901
|
+
if (eventArgs.cancel) {
|
|
902
|
+
li.classList.remove(dropDownBaseClasses.selected);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
_this.selectEventCallback(li, selectedData, value);
|
|
906
|
+
if (isSelection) {
|
|
907
|
+
_this.setSelectOptions(li, e);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
this.selectEventCallback(li, selectedData, value);
|
|
914
|
+
if (isSelection) {
|
|
915
|
+
this.setSelectOptions(li, e);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
Mention.prototype.setSelection = function (li, e) {
|
|
920
|
+
if (this.isValidLI(li) && (!li.classList.contains(dropDownBaseClasses.selected) || (this.isPopupOpen && this.isSelected
|
|
921
|
+
&& li.classList.contains(dropDownBaseClasses.selected)))) {
|
|
922
|
+
this.updateSelectedItem(li, e, false, true);
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
this.setSelectOptions(li, e);
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
Mention.prototype.setSelectOptions = function (li, e) {
|
|
929
|
+
if (this.list) {
|
|
930
|
+
this.removeHover();
|
|
931
|
+
}
|
|
932
|
+
this.previousSelectedLI = (!isNullOrUndefined(this.selectedLI)) ? this.selectedLI : null;
|
|
933
|
+
this.selectedLI = li;
|
|
934
|
+
if (this.isPopupOpen && !isNullOrUndefined(this.selectedLI)) {
|
|
935
|
+
this.setScrollPosition(e);
|
|
936
|
+
}
|
|
937
|
+
if (e && (e.keyCode === 38 || e.keyCode === 40)) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if (isNullOrUndefined(e) || this.setValue(e)) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
Mention.prototype.setScrollPosition = function (e) {
|
|
945
|
+
if (!isNullOrUndefined(e)) {
|
|
946
|
+
switch (e.action) {
|
|
947
|
+
case 'pageDown':
|
|
948
|
+
case 'down':
|
|
949
|
+
case 'end':
|
|
950
|
+
this.scrollBottom();
|
|
951
|
+
break;
|
|
952
|
+
default:
|
|
953
|
+
this.scrollTop();
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
this.scrollBottom(true);
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
Mention.prototype.scrollBottom = function (isInitial) {
|
|
962
|
+
if (!isNullOrUndefined(this.selectedLI)) {
|
|
963
|
+
var currentOffset = this.list.offsetHeight;
|
|
964
|
+
var nextBottom = this.selectedLI.offsetTop + this.selectedLI.offsetHeight - this.list.scrollTop;
|
|
965
|
+
var nextOffset = this.list.scrollTop + nextBottom - currentOffset;
|
|
966
|
+
nextOffset = isInitial ? nextOffset + parseInt(getComputedStyle(this.list).paddingTop, 10) * 2 : nextOffset;
|
|
967
|
+
var boxRange = this.selectedLI.offsetTop + this.selectedLI.offsetHeight - this.list.scrollTop;
|
|
968
|
+
if (this.activeIndex === 0) {
|
|
969
|
+
this.list.scrollTop = 0;
|
|
970
|
+
}
|
|
971
|
+
else if (nextBottom > currentOffset || !(boxRange > 0 && this.list.offsetHeight > boxRange)) {
|
|
972
|
+
this.list.scrollTop = nextOffset;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
Mention.prototype.scrollTop = function () {
|
|
977
|
+
if (!isNullOrUndefined(this.selectedLI)) {
|
|
978
|
+
var nextOffset = this.selectedLI.offsetTop - this.list.scrollTop;
|
|
979
|
+
nextOffset = this.fields.groupBy && nextOffset;
|
|
980
|
+
var boxRange = (this.selectedLI.offsetTop + this.selectedLI.offsetHeight - this.list.scrollTop);
|
|
981
|
+
if (this.activeIndex === 0) {
|
|
982
|
+
this.list.scrollTop = 0;
|
|
983
|
+
}
|
|
984
|
+
else if (nextOffset < 0) {
|
|
985
|
+
this.list.scrollTop = this.list.scrollTop + nextOffset;
|
|
986
|
+
}
|
|
987
|
+
else if (!(boxRange > 0 && this.list.offsetHeight > boxRange)) {
|
|
988
|
+
this.list.scrollTop = this.selectedLI.offsetTop;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
Mention.prototype.selectEventCallback = function (li, selectedData, value, selectLi) {
|
|
993
|
+
this.previousItemData = (!isNullOrUndefined(this.itemData)) ? this.itemData : null;
|
|
994
|
+
this.item = li;
|
|
995
|
+
this.itemData = selectedData;
|
|
996
|
+
var focusedItem = this.list.querySelector('.' + dropDownBaseClasses.focus);
|
|
997
|
+
if (focusedItem) {
|
|
998
|
+
removeClass([focusedItem], dropDownBaseClasses.focus);
|
|
999
|
+
}
|
|
1000
|
+
if (selectLi) {
|
|
1001
|
+
addClass([li], dropDownBaseClasses.selected);
|
|
1002
|
+
}
|
|
1003
|
+
li.setAttribute('aria-selected', 'true');
|
|
1004
|
+
this.activeIndex = this.getIndexByValue(value);
|
|
1005
|
+
};
|
|
1006
|
+
Mention.prototype.detachChanges = function (value) {
|
|
1007
|
+
var items;
|
|
1008
|
+
if (typeof value === 'string' ||
|
|
1009
|
+
typeof value === 'boolean' ||
|
|
1010
|
+
typeof value === 'number') {
|
|
1011
|
+
items = Object.defineProperties({}, {
|
|
1012
|
+
value: {
|
|
1013
|
+
value: value,
|
|
1014
|
+
enumerable: true
|
|
1015
|
+
},
|
|
1016
|
+
text: {
|
|
1017
|
+
value: value,
|
|
1018
|
+
enumerable: true
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
items = value;
|
|
1024
|
+
}
|
|
1025
|
+
return items;
|
|
1026
|
+
};
|
|
1027
|
+
Mention.prototype.setValue = function (e) {
|
|
1028
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1029
|
+
if (!this.isReact) {
|
|
1030
|
+
if (!isNullOrUndefined(this.displayTemplate)) {
|
|
1031
|
+
this.setDisplayTemplate();
|
|
1032
|
+
}
|
|
1033
|
+
this.updateMentionValue(e);
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
if (!isNullOrUndefined(this.displayTemplate)) {
|
|
1038
|
+
this.setDisplayTemplate(e);
|
|
1039
|
+
}
|
|
1040
|
+
else {
|
|
1041
|
+
this.updateMentionValue(e);
|
|
1042
|
+
}
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
Mention.prototype.updateMentionValue = function (e) {
|
|
1047
|
+
var dataItem = this.getItemData();
|
|
1048
|
+
var textSuffix;
|
|
1049
|
+
var value;
|
|
1050
|
+
var endPos;
|
|
1051
|
+
var range;
|
|
1052
|
+
var globalRange;
|
|
1053
|
+
var selection = this.inputElement.ownerDocument.getSelection();
|
|
1054
|
+
var startPos = this.getTriggerCharPosition();
|
|
1055
|
+
textSuffix = typeof this.suffixText === 'string' ? this.suffixText : '';
|
|
1056
|
+
if (dataItem.text !== null) {
|
|
1057
|
+
value = this.mentionVal(dataItem.text);
|
|
1058
|
+
}
|
|
1059
|
+
if (!this.isContentEditable(this.inputElement)) {
|
|
1060
|
+
var myField = this.inputElement;
|
|
1061
|
+
var currentTriggerSnippet = this.getTextRange().substring(startPos + this.mentionChar.length, this.getTextRange().length);
|
|
1062
|
+
value += textSuffix;
|
|
1063
|
+
endPos = startPos + this.mentionChar.length;
|
|
1064
|
+
endPos += currentTriggerSnippet.length;
|
|
1065
|
+
myField.value = myField.value.substring(0, startPos) + value + myField.value.substring(endPos, myField.value.length);
|
|
1066
|
+
myField.selectionStart = startPos + value.length;
|
|
1067
|
+
myField.selectionEnd = startPos + value.length;
|
|
1068
|
+
if (this.isPopupOpen) {
|
|
1069
|
+
this.hidePopup();
|
|
1070
|
+
}
|
|
1071
|
+
this.onChangeEvent(e);
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
endPos = this.getTriggerCharPosition() + this.mentionChar.length;
|
|
1075
|
+
if (this.range && (this.range.startContainer.textContent.trim() !== this.mentionChar)) {
|
|
1076
|
+
endPos = this.range.endOffset;
|
|
1077
|
+
}
|
|
1078
|
+
globalRange = this.range;
|
|
1079
|
+
range = document.createRange();
|
|
1080
|
+
range.setStart(globalRange.startContainer, startPos);
|
|
1081
|
+
range.setEnd(globalRange.startContainer, endPos);
|
|
1082
|
+
range.deleteContents();
|
|
1083
|
+
var element = this.createElement('div');
|
|
1084
|
+
element.innerHTML = value;
|
|
1085
|
+
var frag = document.createDocumentFragment();
|
|
1086
|
+
var node = void 0;
|
|
1087
|
+
var lastNode = void 0;
|
|
1088
|
+
// eslint-disable-next-line no-cond-assign
|
|
1089
|
+
while (node = element.firstChild) {
|
|
1090
|
+
lastNode = frag.appendChild(node);
|
|
1091
|
+
}
|
|
1092
|
+
range.insertNode(frag);
|
|
1093
|
+
if (lastNode) {
|
|
1094
|
+
range = range.cloneRange();
|
|
1095
|
+
range.setStartAfter(lastNode);
|
|
1096
|
+
range.collapse(true);
|
|
1097
|
+
selection.removeAllRanges();
|
|
1098
|
+
selection.addRange(range);
|
|
1099
|
+
}
|
|
1100
|
+
if (this.isPopupOpen) {
|
|
1101
|
+
this.hidePopup();
|
|
1102
|
+
}
|
|
1103
|
+
this.onChangeEvent(e);
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
Mention.prototype.mentionVal = function (value) {
|
|
1107
|
+
var showChar = this.showMentionChar ? this.mentionChar : '';
|
|
1108
|
+
if (!isNullOrUndefined(this.displayTemplate) && !isNullOrUndefined(this.displayTempElement)) {
|
|
1109
|
+
value = this.displayTempElement.innerHTML;
|
|
1110
|
+
}
|
|
1111
|
+
if (this.isContentEditable(this.inputElement)) {
|
|
1112
|
+
return '<span contenteditable="false" class="e-mention-chip">' + showChar + value + '</span>'.concat(typeof this.suffixText === 'string' ? this.suffixText : ' ');
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
return showChar + value;
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
Mention.prototype.setDisplayTemplate = function (e) {
|
|
1119
|
+
var _this = this;
|
|
1120
|
+
var compiledString;
|
|
1121
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1122
|
+
if (this.isReact) {
|
|
1123
|
+
this.clearTemplate(['displayTemplate']);
|
|
1124
|
+
if (this.displayTempElement) {
|
|
1125
|
+
detach(this.displayTempElement);
|
|
1126
|
+
this.displayTempElement = null;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
if (!this.displayTempElement) {
|
|
1130
|
+
this.displayTempElement = this.createElement('div');
|
|
1131
|
+
}
|
|
1132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1133
|
+
if (!this.isReact) {
|
|
1134
|
+
this.displayTempElement.innerHTML = '';
|
|
1135
|
+
}
|
|
1136
|
+
compiledString = compile(this.displayTemplate);
|
|
1137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1138
|
+
var displayCompTemp = compiledString(this.itemData, this, 'displayTemplate', this.displayTemplateId, this.isStringTemplate, null, this.displayTempElement);
|
|
1139
|
+
if (displayCompTemp && displayCompTemp.length > 0) {
|
|
1140
|
+
for (var i = 0; i < displayCompTemp.length; i++) {
|
|
1141
|
+
this.displayTempElement.appendChild(displayCompTemp[i]);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1145
|
+
if (!this.isReact) {
|
|
1146
|
+
this.renderTemplates();
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
this.renderTemplates(function () {
|
|
1150
|
+
_this.updateMentionValue(e);
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1155
|
+
Mention.prototype.renderTemplates = function (callBack) {
|
|
1156
|
+
this.renderReactTemplates(callBack);
|
|
1157
|
+
};
|
|
1158
|
+
Mention.prototype.setSpinnerTemplate = function () {
|
|
1159
|
+
var _this = this;
|
|
1160
|
+
var compiledString;
|
|
1161
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1162
|
+
if (this.isReact) {
|
|
1163
|
+
this.clearTemplate(['spinnerTemplate']);
|
|
1164
|
+
if (this.spinnerTemplateElement) {
|
|
1165
|
+
detach(this.spinnerTemplateElement);
|
|
1166
|
+
this.spinnerTemplateElement = null;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
if (!this.spinnerTemplateElement) {
|
|
1170
|
+
this.spinnerTemplateElement = this.createElement('div');
|
|
1171
|
+
}
|
|
1172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1173
|
+
if (!this.isReact) {
|
|
1174
|
+
this.spinnerTemplateElement.innerHTML = '';
|
|
1175
|
+
}
|
|
1176
|
+
compiledString = compile(this.spinnerTemplate);
|
|
1177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1178
|
+
var spinnerCompTemp = compiledString(null, this, 'spinnerTemplate', this.spinnerTemplateId, this.isStringTemplate, null, this.spinnerTemplateElement);
|
|
1179
|
+
if (spinnerCompTemp && spinnerCompTemp.length > 0) {
|
|
1180
|
+
for (var i = 0; i < spinnerCompTemp.length; i++) {
|
|
1181
|
+
this.spinnerTemplateElement.appendChild(spinnerCompTemp[i]);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1185
|
+
if (!this.isReact) {
|
|
1186
|
+
this.renderTemplates();
|
|
1187
|
+
this.popupObj.element.appendChild(this.spinnerTemplateElement);
|
|
1188
|
+
}
|
|
1189
|
+
else {
|
|
1190
|
+
this.renderTemplates(function () {
|
|
1191
|
+
_this.popupObj.element.appendChild(_this.spinnerTemplateElement);
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
Mention.prototype.onChangeEvent = function (eve) {
|
|
1196
|
+
this.isSelected = false;
|
|
1197
|
+
var items = this.detachMentionChanges(this.itemData);
|
|
1198
|
+
var preItems;
|
|
1199
|
+
if (typeof this.previousItemData === 'string' ||
|
|
1200
|
+
typeof this.previousItemData === 'boolean' ||
|
|
1201
|
+
typeof this.previousItemData === 'number') {
|
|
1202
|
+
preItems = Object.defineProperties({}, {
|
|
1203
|
+
value: {
|
|
1204
|
+
value: this.previousItemData,
|
|
1205
|
+
enumerable: true
|
|
1206
|
+
},
|
|
1207
|
+
text: {
|
|
1208
|
+
value: this.previousItemData,
|
|
1209
|
+
enumerable: true
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
else {
|
|
1214
|
+
preItems = this.previousItemData;
|
|
1215
|
+
}
|
|
1216
|
+
var eventArgs = {
|
|
1217
|
+
e: eve,
|
|
1218
|
+
item: this.item,
|
|
1219
|
+
itemData: items,
|
|
1220
|
+
previousItem: this.previousSelectedLI,
|
|
1221
|
+
previousItemData: preItems,
|
|
1222
|
+
isInteracted: eve ? true : false,
|
|
1223
|
+
value: this.item.innerHTML,
|
|
1224
|
+
element: this.inputElement
|
|
1225
|
+
};
|
|
1226
|
+
this.trigger('change', eventArgs);
|
|
1227
|
+
};
|
|
1228
|
+
Mention.prototype.detachMentionChanges = function (value) {
|
|
1229
|
+
var items;
|
|
1230
|
+
if (typeof value === 'string' ||
|
|
1231
|
+
typeof value === 'boolean' ||
|
|
1232
|
+
typeof value === 'number') {
|
|
1233
|
+
items = Object.defineProperties({}, {
|
|
1234
|
+
value: {
|
|
1235
|
+
value: value,
|
|
1236
|
+
enumerable: true
|
|
1237
|
+
},
|
|
1238
|
+
text: {
|
|
1239
|
+
value: value,
|
|
1240
|
+
enumerable: true
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
else {
|
|
1245
|
+
items = value;
|
|
1246
|
+
}
|
|
1247
|
+
return items;
|
|
1248
|
+
};
|
|
1249
|
+
Mention.prototype.getItemData = function () {
|
|
1250
|
+
var fields = this.fields;
|
|
1251
|
+
var dataItem = null;
|
|
1252
|
+
dataItem = this.itemData;
|
|
1253
|
+
var dataValue;
|
|
1254
|
+
var dataText;
|
|
1255
|
+
if (!isNullOrUndefined(dataItem)) {
|
|
1256
|
+
dataValue = getValue(fields.value, dataItem);
|
|
1257
|
+
dataText = getValue(fields.text, dataItem);
|
|
1258
|
+
}
|
|
1259
|
+
var value = (!isNullOrUndefined(dataItem) &&
|
|
1260
|
+
!isUndefined(dataValue) ? dataValue : dataItem);
|
|
1261
|
+
var text = (!isNullOrUndefined(dataItem) &&
|
|
1262
|
+
!isUndefined(dataValue) ? dataText : dataItem);
|
|
1263
|
+
return { value: value, text: text };
|
|
1264
|
+
};
|
|
1265
|
+
Mention.prototype.removeSelection = function () {
|
|
1266
|
+
if (this.list) {
|
|
1267
|
+
var selectedItems = this.list.querySelectorAll('.' + dropDownBaseClasses.selected);
|
|
1268
|
+
if (selectedItems.length) {
|
|
1269
|
+
removeClass(selectedItems, dropDownBaseClasses.selected);
|
|
1270
|
+
selectedItems[0].removeAttribute('aria-selected');
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
Mention.prototype.onMouseOver = function (e) {
|
|
1275
|
+
var currentLi = closest(e.target, '.' + dropDownBaseClasses.li);
|
|
1276
|
+
this.setHover(currentLi);
|
|
1277
|
+
};
|
|
1278
|
+
Mention.prototype.setHover = function (li) {
|
|
1279
|
+
if (this.isValidLI(li) && !li.classList.contains(dropDownBaseClasses.hover)) {
|
|
1280
|
+
this.removeHover();
|
|
1281
|
+
addClass([li], dropDownBaseClasses.hover);
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
Mention.prototype.removeHover = function () {
|
|
1285
|
+
if (this.list) {
|
|
1286
|
+
var hoveredItem = this.list.querySelectorAll('.' + dropDownBaseClasses.hover);
|
|
1287
|
+
if (hoveredItem && hoveredItem.length) {
|
|
1288
|
+
removeClass(hoveredItem, dropDownBaseClasses.hover);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
Mention.prototype.isValidLI = function (li) {
|
|
1293
|
+
return (li && li.hasAttribute('role') && li.getAttribute('role') === 'option');
|
|
1294
|
+
};
|
|
1295
|
+
Mention.prototype.onMouseLeave = function () {
|
|
1296
|
+
this.removeHover();
|
|
1297
|
+
};
|
|
1298
|
+
/**
|
|
1299
|
+
* Search the entered text and show it in the suggestion list if available.
|
|
1300
|
+
*
|
|
1301
|
+
* @returns {void}
|
|
1302
|
+
*/
|
|
1303
|
+
Mention.prototype.search = function (text, positionX, positionY) {
|
|
1304
|
+
if (this.isContentEditable(this.inputElement)) {
|
|
1305
|
+
this.range = this.getCurrentRange();
|
|
1306
|
+
}
|
|
1307
|
+
var currentRange = this.getTextRange();
|
|
1308
|
+
var lastWordRange = this.getLastLetter(currentRange);
|
|
1309
|
+
if ((this.ignoreCase && (text === lastWordRange || text === lastWordRange.toLowerCase()))
|
|
1310
|
+
|| !this.ignoreCase && text === lastWordRange) {
|
|
1311
|
+
this.resetList(this.dataSource, this.fields);
|
|
1312
|
+
}
|
|
1313
|
+
else {
|
|
1314
|
+
if (this.isPopupOpen) {
|
|
1315
|
+
this.hidePopup();
|
|
1316
|
+
}
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
if (isNullOrUndefined(this.list)) {
|
|
1320
|
+
this.renderList();
|
|
1321
|
+
this.renderPopup();
|
|
1322
|
+
}
|
|
1323
|
+
else {
|
|
1324
|
+
this.showPopup();
|
|
1325
|
+
}
|
|
1326
|
+
this.popupObj.element.style.left = formatUnit(positionX);
|
|
1327
|
+
this.popupObj.element.style.top = formatUnit(positionY);
|
|
1328
|
+
};
|
|
1329
|
+
/**
|
|
1330
|
+
* Removes the component from the DOM and detaches all its related event handlers. Also it removes the attributes and classes.
|
|
1331
|
+
*
|
|
1332
|
+
* @method destroy
|
|
1333
|
+
* @returns {void}
|
|
1334
|
+
*/
|
|
1335
|
+
Mention.prototype.destroy = function () {
|
|
1336
|
+
this.hidePopup();
|
|
1337
|
+
this.unWireEvent();
|
|
1338
|
+
if (this.list) {
|
|
1339
|
+
this.unWireListEvents();
|
|
1340
|
+
}
|
|
1341
|
+
if (this.inputElement && !this.inputElement.classList.contains('e-' + this.getModuleName())) {
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
_super.prototype.destroy.call(this);
|
|
1345
|
+
};
|
|
1346
|
+
Mention.prototype.getLocaleName = function () {
|
|
1347
|
+
return 'mention';
|
|
1348
|
+
};
|
|
1349
|
+
Mention.prototype.getNgDirective = function () {
|
|
1350
|
+
return 'EJS-MENTION';
|
|
1351
|
+
};
|
|
1352
|
+
/**
|
|
1353
|
+
* Return the module name of this component.
|
|
1354
|
+
*
|
|
1355
|
+
* @private
|
|
1356
|
+
* @returns {string} Return the module name of this component.
|
|
1357
|
+
*/
|
|
1358
|
+
Mention.prototype.getModuleName = function () {
|
|
1359
|
+
return 'mention';
|
|
1360
|
+
};
|
|
1361
|
+
__decorate([
|
|
1362
|
+
Property(null)
|
|
1363
|
+
], Mention.prototype, "cssClass", void 0);
|
|
1364
|
+
__decorate([
|
|
1365
|
+
Property('@')
|
|
1366
|
+
], Mention.prototype, "mentionChar", void 0);
|
|
1367
|
+
__decorate([
|
|
1368
|
+
Property(false)
|
|
1369
|
+
], Mention.prototype, "showMentionChar", void 0);
|
|
1370
|
+
__decorate([
|
|
1371
|
+
Property(false)
|
|
1372
|
+
], Mention.prototype, "allowSpaces", void 0);
|
|
1373
|
+
__decorate([
|
|
1374
|
+
Property(null)
|
|
1375
|
+
], Mention.prototype, "suffixText", void 0);
|
|
1376
|
+
__decorate([
|
|
1377
|
+
Property(25)
|
|
1378
|
+
], Mention.prototype, "suggestionCount", void 0);
|
|
1379
|
+
__decorate([
|
|
1380
|
+
Property(0)
|
|
1381
|
+
], Mention.prototype, "minLength", void 0);
|
|
1382
|
+
__decorate([
|
|
1383
|
+
Property('None')
|
|
1384
|
+
], Mention.prototype, "sortOrder", void 0);
|
|
1385
|
+
__decorate([
|
|
1386
|
+
Property(true)
|
|
1387
|
+
], Mention.prototype, "ignoreCase", void 0);
|
|
1388
|
+
__decorate([
|
|
1389
|
+
Property(false)
|
|
1390
|
+
], Mention.prototype, "highlight", void 0);
|
|
1391
|
+
__decorate([
|
|
1392
|
+
Property()
|
|
1393
|
+
], Mention.prototype, "locale", void 0);
|
|
1394
|
+
__decorate([
|
|
1395
|
+
Property('auto')
|
|
1396
|
+
], Mention.prototype, "popupWidth", void 0);
|
|
1397
|
+
__decorate([
|
|
1398
|
+
Property('300px')
|
|
1399
|
+
], Mention.prototype, "popupHeight", void 0);
|
|
1400
|
+
__decorate([
|
|
1401
|
+
Property(null)
|
|
1402
|
+
], Mention.prototype, "displayTemplate", void 0);
|
|
1403
|
+
__decorate([
|
|
1404
|
+
Property(null)
|
|
1405
|
+
], Mention.prototype, "itemTemplate", void 0);
|
|
1406
|
+
__decorate([
|
|
1407
|
+
Property('No records found')
|
|
1408
|
+
], Mention.prototype, "noRecordsTemplate", void 0);
|
|
1409
|
+
__decorate([
|
|
1410
|
+
Property(null)
|
|
1411
|
+
], Mention.prototype, "spinnerTemplate", void 0);
|
|
1412
|
+
__decorate([
|
|
1413
|
+
Property()
|
|
1414
|
+
], Mention.prototype, "target", void 0);
|
|
1415
|
+
__decorate([
|
|
1416
|
+
Property([])
|
|
1417
|
+
], Mention.prototype, "dataSource", void 0);
|
|
1418
|
+
__decorate([
|
|
1419
|
+
Property(null)
|
|
1420
|
+
], Mention.prototype, "query", void 0);
|
|
1421
|
+
__decorate([
|
|
1422
|
+
Property('Contains')
|
|
1423
|
+
], Mention.prototype, "filterType", void 0);
|
|
1424
|
+
__decorate([
|
|
1425
|
+
Complex({ text: null, value: null, iconCss: null, groupBy: null }, FieldSettings)
|
|
1426
|
+
], Mention.prototype, "fields", void 0);
|
|
1427
|
+
__decorate([
|
|
1428
|
+
Event()
|
|
1429
|
+
], Mention.prototype, "actionBegin", void 0);
|
|
1430
|
+
__decorate([
|
|
1431
|
+
Event()
|
|
1432
|
+
], Mention.prototype, "actionComplete", void 0);
|
|
1433
|
+
__decorate([
|
|
1434
|
+
Event()
|
|
1435
|
+
], Mention.prototype, "actionFailure", void 0);
|
|
1436
|
+
__decorate([
|
|
1437
|
+
Event()
|
|
1438
|
+
], Mention.prototype, "change", void 0);
|
|
1439
|
+
__decorate([
|
|
1440
|
+
Event()
|
|
1441
|
+
], Mention.prototype, "beforeOpen", void 0);
|
|
1442
|
+
__decorate([
|
|
1443
|
+
Event()
|
|
1444
|
+
], Mention.prototype, "opened", void 0);
|
|
1445
|
+
__decorate([
|
|
1446
|
+
Event()
|
|
1447
|
+
], Mention.prototype, "closed", void 0);
|
|
1448
|
+
__decorate([
|
|
1449
|
+
Event()
|
|
1450
|
+
], Mention.prototype, "select", void 0);
|
|
1451
|
+
__decorate([
|
|
1452
|
+
Event()
|
|
1453
|
+
], Mention.prototype, "filtering", void 0);
|
|
1454
|
+
__decorate([
|
|
1455
|
+
Event()
|
|
1456
|
+
], Mention.prototype, "created", void 0);
|
|
1457
|
+
__decorate([
|
|
1458
|
+
Event()
|
|
1459
|
+
], Mention.prototype, "destroyed", void 0);
|
|
1460
|
+
Mention = __decorate([
|
|
1461
|
+
NotifyPropertyChanges
|
|
1462
|
+
], Mention);
|
|
1463
|
+
return Mention;
|
|
1464
|
+
}(DropDownBase));
|
|
1465
|
+
export { Mention };
|