@ng-select/ng-select
Version:
Angular ng-select - All in One UI Select, Multiselect and Autocomplete
1 lines • 207 kB
Source Map (JSON)
{"version":3,"file":"ng-select-ng-select.mjs","sources":["../../../src/ng-select/lib/value-utils.ts","../../../src/ng-select/lib/ng-templates.directive.ts","../../../src/ng-select/lib/id.ts","../../../src/ng-select/lib/search-helper.ts","../../../src/ng-select/lib/items-list.ts","../../../src/ng-select/lib/ng-select.types.ts","../../../src/ng-select/lib/ng-dropdown-panel.service.ts","../../../src/ng-select/lib/ng-dropdown-panel.component.ts","../../../src/ng-select/lib/ng-option.component.ts","../../../src/ng-select/lib/config.service.ts","../../../src/ng-select/lib/console.service.ts","../../../src/ng-select/lib/ng-select.component.ts","../../../src/ng-select/lib/ng-select.component.html","../../../src/ng-select/lib/selection-model.ts","../../../src/ng-select/lib/ng-select.module.ts","../../../src/ng-select/public-api.ts","../../../src/ng-select/ng-select-ng-select.ts"],"sourcesContent":["const unescapedHTMLExp = /[&<>\"']/g;\nconst hasUnescapedHTMLExp = RegExp(unescapedHTMLExp.source);\nconst htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n '\\'': '''\n};\n\nexport function escapeHTML(value: string) {\n return (value && hasUnescapedHTMLExp.test(value)) ?\n value.replace(unescapedHTMLExp, chr => htmlEscapes[chr]) :\n value;\n}\n\nexport function isDefined(value: any) {\n return value !== undefined && value !== null;\n}\n\nexport function isObject(value: any) {\n return typeof value === 'object' && isDefined(value);\n}\n\nexport function isPromise(value: any) {\n return value instanceof Promise;\n}\n\nexport function isFunction(value: any) {\n return value instanceof Function;\n}\n","import { Directive, ElementRef, Input, OnChanges, SimpleChanges, TemplateRef } from '@angular/core';\nimport { escapeHTML } from './value-utils';\n\n@Directive({ selector: '[ngItemLabel]' })\nexport class NgItemLabelDirective implements OnChanges {\n @Input() ngItemLabel: string;\n @Input() escape = true;\n\n constructor(private element: ElementRef<HTMLElement>) { }\n\n ngOnChanges(changes: SimpleChanges) {\n this.element.nativeElement.innerHTML = this.escape ?\n escapeHTML(this.ngItemLabel) :\n this.ngItemLabel;\n }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-option-tmp]' })\nexport class NgOptionTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-optgroup-tmp]' })\nexport class NgOptgroupTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-label-tmp]' })\nexport class NgLabelTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-multi-label-tmp]' })\nexport class NgMultiLabelTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-header-tmp]' })\nexport class NgHeaderTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-footer-tmp]' })\nexport class NgFooterTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-notfound-tmp]' })\nexport class NgNotFoundTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-typetosearch-tmp]' })\nexport class NgTypeToSearchTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-loadingtext-tmp]' })\nexport class NgLoadingTextTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-tag-tmp]' })\nexport class NgTagTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n\n// eslint-disable-next-line @angular-eslint/directive-selector\n@Directive({ selector: '[ng-loadingspinner-tmp]' })\nexport class NgLoadingSpinnerTemplateDirective {\n constructor(public template: TemplateRef<any>) { }\n}\n","export function newId() {\n // First character is an 'a', it's good practice to tag id to begin with a letter\n return 'axxxxxxxxxxx'.replace(/[x]/g, () => {\n // eslint-disable-next-line no-bitwise\n const val = Math.random() * 16 | 0;\n return val.toString(16);\n });\n}\n","const diacritics = {\n '\\u24B6': 'A',\n '\\uFF21': 'A',\n '\\u00C0': 'A',\n '\\u00C1': 'A',\n '\\u00C2': 'A',\n '\\u1EA6': 'A',\n '\\u1EA4': 'A',\n '\\u1EAA': 'A',\n '\\u1EA8': 'A',\n '\\u00C3': 'A',\n '\\u0100': 'A',\n '\\u0102': 'A',\n '\\u1EB0': 'A',\n '\\u1EAE': 'A',\n '\\u1EB4': 'A',\n '\\u1EB2': 'A',\n '\\u0226': 'A',\n '\\u01E0': 'A',\n '\\u00C4': 'A',\n '\\u01DE': 'A',\n '\\u1EA2': 'A',\n '\\u00C5': 'A',\n '\\u01FA': 'A',\n '\\u01CD': 'A',\n '\\u0200': 'A',\n '\\u0202': 'A',\n '\\u1EA0': 'A',\n '\\u1EAC': 'A',\n '\\u1EB6': 'A',\n '\\u1E00': 'A',\n '\\u0104': 'A',\n '\\u023A': 'A',\n '\\u2C6F': 'A',\n '\\uA732': 'AA',\n '\\u00C6': 'AE',\n '\\u01FC': 'AE',\n '\\u01E2': 'AE',\n '\\uA734': 'AO',\n '\\uA736': 'AU',\n '\\uA738': 'AV',\n '\\uA73A': 'AV',\n '\\uA73C': 'AY',\n '\\u24B7': 'B',\n '\\uFF22': 'B',\n '\\u1E02': 'B',\n '\\u1E04': 'B',\n '\\u1E06': 'B',\n '\\u0243': 'B',\n '\\u0182': 'B',\n '\\u0181': 'B',\n '\\u24B8': 'C',\n '\\uFF23': 'C',\n '\\u0106': 'C',\n '\\u0108': 'C',\n '\\u010A': 'C',\n '\\u010C': 'C',\n '\\u00C7': 'C',\n '\\u1E08': 'C',\n '\\u0187': 'C',\n '\\u023B': 'C',\n '\\uA73E': 'C',\n '\\u24B9': 'D',\n '\\uFF24': 'D',\n '\\u1E0A': 'D',\n '\\u010E': 'D',\n '\\u1E0C': 'D',\n '\\u1E10': 'D',\n '\\u1E12': 'D',\n '\\u1E0E': 'D',\n '\\u0110': 'D',\n '\\u018B': 'D',\n '\\u018A': 'D',\n '\\u0189': 'D',\n '\\uA779': 'D',\n '\\u01F1': 'DZ',\n '\\u01C4': 'DZ',\n '\\u01F2': 'Dz',\n '\\u01C5': 'Dz',\n '\\u24BA': 'E',\n '\\uFF25': 'E',\n '\\u00C8': 'E',\n '\\u00C9': 'E',\n '\\u00CA': 'E',\n '\\u1EC0': 'E',\n '\\u1EBE': 'E',\n '\\u1EC4': 'E',\n '\\u1EC2': 'E',\n '\\u1EBC': 'E',\n '\\u0112': 'E',\n '\\u1E14': 'E',\n '\\u1E16': 'E',\n '\\u0114': 'E',\n '\\u0116': 'E',\n '\\u00CB': 'E',\n '\\u1EBA': 'E',\n '\\u011A': 'E',\n '\\u0204': 'E',\n '\\u0206': 'E',\n '\\u1EB8': 'E',\n '\\u1EC6': 'E',\n '\\u0228': 'E',\n '\\u1E1C': 'E',\n '\\u0118': 'E',\n '\\u1E18': 'E',\n '\\u1E1A': 'E',\n '\\u0190': 'E',\n '\\u018E': 'E',\n '\\u24BB': 'F',\n '\\uFF26': 'F',\n '\\u1E1E': 'F',\n '\\u0191': 'F',\n '\\uA77B': 'F',\n '\\u24BC': 'G',\n '\\uFF27': 'G',\n '\\u01F4': 'G',\n '\\u011C': 'G',\n '\\u1E20': 'G',\n '\\u011E': 'G',\n '\\u0120': 'G',\n '\\u01E6': 'G',\n '\\u0122': 'G',\n '\\u01E4': 'G',\n '\\u0193': 'G',\n '\\uA7A0': 'G',\n '\\uA77D': 'G',\n '\\uA77E': 'G',\n '\\u24BD': 'H',\n '\\uFF28': 'H',\n '\\u0124': 'H',\n '\\u1E22': 'H',\n '\\u1E26': 'H',\n '\\u021E': 'H',\n '\\u1E24': 'H',\n '\\u1E28': 'H',\n '\\u1E2A': 'H',\n '\\u0126': 'H',\n '\\u2C67': 'H',\n '\\u2C75': 'H',\n '\\uA78D': 'H',\n '\\u24BE': 'I',\n '\\uFF29': 'I',\n '\\u00CC': 'I',\n '\\u00CD': 'I',\n '\\u00CE': 'I',\n '\\u0128': 'I',\n '\\u012A': 'I',\n '\\u012C': 'I',\n '\\u0130': 'I',\n '\\u00CF': 'I',\n '\\u1E2E': 'I',\n '\\u1EC8': 'I',\n '\\u01CF': 'I',\n '\\u0208': 'I',\n '\\u020A': 'I',\n '\\u1ECA': 'I',\n '\\u012E': 'I',\n '\\u1E2C': 'I',\n '\\u0197': 'I',\n '\\u24BF': 'J',\n '\\uFF2A': 'J',\n '\\u0134': 'J',\n '\\u0248': 'J',\n '\\u24C0': 'K',\n '\\uFF2B': 'K',\n '\\u1E30': 'K',\n '\\u01E8': 'K',\n '\\u1E32': 'K',\n '\\u0136': 'K',\n '\\u1E34': 'K',\n '\\u0198': 'K',\n '\\u2C69': 'K',\n '\\uA740': 'K',\n '\\uA742': 'K',\n '\\uA744': 'K',\n '\\uA7A2': 'K',\n '\\u24C1': 'L',\n '\\uFF2C': 'L',\n '\\u013F': 'L',\n '\\u0139': 'L',\n '\\u013D': 'L',\n '\\u1E36': 'L',\n '\\u1E38': 'L',\n '\\u013B': 'L',\n '\\u1E3C': 'L',\n '\\u1E3A': 'L',\n '\\u0141': 'L',\n '\\u023D': 'L',\n '\\u2C62': 'L',\n '\\u2C60': 'L',\n '\\uA748': 'L',\n '\\uA746': 'L',\n '\\uA780': 'L',\n '\\u01C7': 'LJ',\n '\\u01C8': 'Lj',\n '\\u24C2': 'M',\n '\\uFF2D': 'M',\n '\\u1E3E': 'M',\n '\\u1E40': 'M',\n '\\u1E42': 'M',\n '\\u2C6E': 'M',\n '\\u019C': 'M',\n '\\u24C3': 'N',\n '\\uFF2E': 'N',\n '\\u01F8': 'N',\n '\\u0143': 'N',\n '\\u00D1': 'N',\n '\\u1E44': 'N',\n '\\u0147': 'N',\n '\\u1E46': 'N',\n '\\u0145': 'N',\n '\\u1E4A': 'N',\n '\\u1E48': 'N',\n '\\u0220': 'N',\n '\\u019D': 'N',\n '\\uA790': 'N',\n '\\uA7A4': 'N',\n '\\u01CA': 'NJ',\n '\\u01CB': 'Nj',\n '\\u24C4': 'O',\n '\\uFF2F': 'O',\n '\\u00D2': 'O',\n '\\u00D3': 'O',\n '\\u00D4': 'O',\n '\\u1ED2': 'O',\n '\\u1ED0': 'O',\n '\\u1ED6': 'O',\n '\\u1ED4': 'O',\n '\\u00D5': 'O',\n '\\u1E4C': 'O',\n '\\u022C': 'O',\n '\\u1E4E': 'O',\n '\\u014C': 'O',\n '\\u1E50': 'O',\n '\\u1E52': 'O',\n '\\u014E': 'O',\n '\\u022E': 'O',\n '\\u0230': 'O',\n '\\u00D6': 'O',\n '\\u022A': 'O',\n '\\u1ECE': 'O',\n '\\u0150': 'O',\n '\\u01D1': 'O',\n '\\u020C': 'O',\n '\\u020E': 'O',\n '\\u01A0': 'O',\n '\\u1EDC': 'O',\n '\\u1EDA': 'O',\n '\\u1EE0': 'O',\n '\\u1EDE': 'O',\n '\\u1EE2': 'O',\n '\\u1ECC': 'O',\n '\\u1ED8': 'O',\n '\\u01EA': 'O',\n '\\u01EC': 'O',\n '\\u00D8': 'O',\n '\\u01FE': 'O',\n '\\u0186': 'O',\n '\\u019F': 'O',\n '\\uA74A': 'O',\n '\\uA74C': 'O',\n '\\u01A2': 'OI',\n '\\uA74E': 'OO',\n '\\u0222': 'OU',\n '\\u24C5': 'P',\n '\\uFF30': 'P',\n '\\u1E54': 'P',\n '\\u1E56': 'P',\n '\\u01A4': 'P',\n '\\u2C63': 'P',\n '\\uA750': 'P',\n '\\uA752': 'P',\n '\\uA754': 'P',\n '\\u24C6': 'Q',\n '\\uFF31': 'Q',\n '\\uA756': 'Q',\n '\\uA758': 'Q',\n '\\u024A': 'Q',\n '\\u24C7': 'R',\n '\\uFF32': 'R',\n '\\u0154': 'R',\n '\\u1E58': 'R',\n '\\u0158': 'R',\n '\\u0210': 'R',\n '\\u0212': 'R',\n '\\u1E5A': 'R',\n '\\u1E5C': 'R',\n '\\u0156': 'R',\n '\\u1E5E': 'R',\n '\\u024C': 'R',\n '\\u2C64': 'R',\n '\\uA75A': 'R',\n '\\uA7A6': 'R',\n '\\uA782': 'R',\n '\\u24C8': 'S',\n '\\uFF33': 'S',\n '\\u1E9E': 'S',\n '\\u015A': 'S',\n '\\u1E64': 'S',\n '\\u015C': 'S',\n '\\u1E60': 'S',\n '\\u0160': 'S',\n '\\u1E66': 'S',\n '\\u1E62': 'S',\n '\\u1E68': 'S',\n '\\u0218': 'S',\n '\\u015E': 'S',\n '\\u2C7E': 'S',\n '\\uA7A8': 'S',\n '\\uA784': 'S',\n '\\u24C9': 'T',\n '\\uFF34': 'T',\n '\\u1E6A': 'T',\n '\\u0164': 'T',\n '\\u1E6C': 'T',\n '\\u021A': 'T',\n '\\u0162': 'T',\n '\\u1E70': 'T',\n '\\u1E6E': 'T',\n '\\u0166': 'T',\n '\\u01AC': 'T',\n '\\u01AE': 'T',\n '\\u023E': 'T',\n '\\uA786': 'T',\n '\\uA728': 'TZ',\n '\\u24CA': 'U',\n '\\uFF35': 'U',\n '\\u00D9': 'U',\n '\\u00DA': 'U',\n '\\u00DB': 'U',\n '\\u0168': 'U',\n '\\u1E78': 'U',\n '\\u016A': 'U',\n '\\u1E7A': 'U',\n '\\u016C': 'U',\n '\\u00DC': 'U',\n '\\u01DB': 'U',\n '\\u01D7': 'U',\n '\\u01D5': 'U',\n '\\u01D9': 'U',\n '\\u1EE6': 'U',\n '\\u016E': 'U',\n '\\u0170': 'U',\n '\\u01D3': 'U',\n '\\u0214': 'U',\n '\\u0216': 'U',\n '\\u01AF': 'U',\n '\\u1EEA': 'U',\n '\\u1EE8': 'U',\n '\\u1EEE': 'U',\n '\\u1EEC': 'U',\n '\\u1EF0': 'U',\n '\\u1EE4': 'U',\n '\\u1E72': 'U',\n '\\u0172': 'U',\n '\\u1E76': 'U',\n '\\u1E74': 'U',\n '\\u0244': 'U',\n '\\u24CB': 'V',\n '\\uFF36': 'V',\n '\\u1E7C': 'V',\n '\\u1E7E': 'V',\n '\\u01B2': 'V',\n '\\uA75E': 'V',\n '\\u0245': 'V',\n '\\uA760': 'VY',\n '\\u24CC': 'W',\n '\\uFF37': 'W',\n '\\u1E80': 'W',\n '\\u1E82': 'W',\n '\\u0174': 'W',\n '\\u1E86': 'W',\n '\\u1E84': 'W',\n '\\u1E88': 'W',\n '\\u2C72': 'W',\n '\\u24CD': 'X',\n '\\uFF38': 'X',\n '\\u1E8A': 'X',\n '\\u1E8C': 'X',\n '\\u24CE': 'Y',\n '\\uFF39': 'Y',\n '\\u1EF2': 'Y',\n '\\u00DD': 'Y',\n '\\u0176': 'Y',\n '\\u1EF8': 'Y',\n '\\u0232': 'Y',\n '\\u1E8E': 'Y',\n '\\u0178': 'Y',\n '\\u1EF6': 'Y',\n '\\u1EF4': 'Y',\n '\\u01B3': 'Y',\n '\\u024E': 'Y',\n '\\u1EFE': 'Y',\n '\\u24CF': 'Z',\n '\\uFF3A': 'Z',\n '\\u0179': 'Z',\n '\\u1E90': 'Z',\n '\\u017B': 'Z',\n '\\u017D': 'Z',\n '\\u1E92': 'Z',\n '\\u1E94': 'Z',\n '\\u01B5': 'Z',\n '\\u0224': 'Z',\n '\\u2C7F': 'Z',\n '\\u2C6B': 'Z',\n '\\uA762': 'Z',\n '\\u24D0': 'a',\n '\\uFF41': 'a',\n '\\u1E9A': 'a',\n '\\u00E0': 'a',\n '\\u00E1': 'a',\n '\\u00E2': 'a',\n '\\u1EA7': 'a',\n '\\u1EA5': 'a',\n '\\u1EAB': 'a',\n '\\u1EA9': 'a',\n '\\u00E3': 'a',\n '\\u0101': 'a',\n '\\u0103': 'a',\n '\\u1EB1': 'a',\n '\\u1EAF': 'a',\n '\\u1EB5': 'a',\n '\\u1EB3': 'a',\n '\\u0227': 'a',\n '\\u01E1': 'a',\n '\\u00E4': 'a',\n '\\u01DF': 'a',\n '\\u1EA3': 'a',\n '\\u00E5': 'a',\n '\\u01FB': 'a',\n '\\u01CE': 'a',\n '\\u0201': 'a',\n '\\u0203': 'a',\n '\\u1EA1': 'a',\n '\\u1EAD': 'a',\n '\\u1EB7': 'a',\n '\\u1E01': 'a',\n '\\u0105': 'a',\n '\\u2C65': 'a',\n '\\u0250': 'a',\n '\\uA733': 'aa',\n '\\u00E6': 'ae',\n '\\u01FD': 'ae',\n '\\u01E3': 'ae',\n '\\uA735': 'ao',\n '\\uA737': 'au',\n '\\uA739': 'av',\n '\\uA73B': 'av',\n '\\uA73D': 'ay',\n '\\u24D1': 'b',\n '\\uFF42': 'b',\n '\\u1E03': 'b',\n '\\u1E05': 'b',\n '\\u1E07': 'b',\n '\\u0180': 'b',\n '\\u0183': 'b',\n '\\u0253': 'b',\n '\\u24D2': 'c',\n '\\uFF43': 'c',\n '\\u0107': 'c',\n '\\u0109': 'c',\n '\\u010B': 'c',\n '\\u010D': 'c',\n '\\u00E7': 'c',\n '\\u1E09': 'c',\n '\\u0188': 'c',\n '\\u023C': 'c',\n '\\uA73F': 'c',\n '\\u2184': 'c',\n '\\u24D3': 'd',\n '\\uFF44': 'd',\n '\\u1E0B': 'd',\n '\\u010F': 'd',\n '\\u1E0D': 'd',\n '\\u1E11': 'd',\n '\\u1E13': 'd',\n '\\u1E0F': 'd',\n '\\u0111': 'd',\n '\\u018C': 'd',\n '\\u0256': 'd',\n '\\u0257': 'd',\n '\\uA77A': 'd',\n '\\u01F3': 'dz',\n '\\u01C6': 'dz',\n '\\u24D4': 'e',\n '\\uFF45': 'e',\n '\\u00E8': 'e',\n '\\u00E9': 'e',\n '\\u00EA': 'e',\n '\\u1EC1': 'e',\n '\\u1EBF': 'e',\n '\\u1EC5': 'e',\n '\\u1EC3': 'e',\n '\\u1EBD': 'e',\n '\\u0113': 'e',\n '\\u1E15': 'e',\n '\\u1E17': 'e',\n '\\u0115': 'e',\n '\\u0117': 'e',\n '\\u00EB': 'e',\n '\\u1EBB': 'e',\n '\\u011B': 'e',\n '\\u0205': 'e',\n '\\u0207': 'e',\n '\\u1EB9': 'e',\n '\\u1EC7': 'e',\n '\\u0229': 'e',\n '\\u1E1D': 'e',\n '\\u0119': 'e',\n '\\u1E19': 'e',\n '\\u1E1B': 'e',\n '\\u0247': 'e',\n '\\u025B': 'e',\n '\\u01DD': 'e',\n '\\u24D5': 'f',\n '\\uFF46': 'f',\n '\\u1E1F': 'f',\n '\\u0192': 'f',\n '\\uA77C': 'f',\n '\\u24D6': 'g',\n '\\uFF47': 'g',\n '\\u01F5': 'g',\n '\\u011D': 'g',\n '\\u1E21': 'g',\n '\\u011F': 'g',\n '\\u0121': 'g',\n '\\u01E7': 'g',\n '\\u0123': 'g',\n '\\u01E5': 'g',\n '\\u0260': 'g',\n '\\uA7A1': 'g',\n '\\u1D79': 'g',\n '\\uA77F': 'g',\n '\\u24D7': 'h',\n '\\uFF48': 'h',\n '\\u0125': 'h',\n '\\u1E23': 'h',\n '\\u1E27': 'h',\n '\\u021F': 'h',\n '\\u1E25': 'h',\n '\\u1E29': 'h',\n '\\u1E2B': 'h',\n '\\u1E96': 'h',\n '\\u0127': 'h',\n '\\u2C68': 'h',\n '\\u2C76': 'h',\n '\\u0265': 'h',\n '\\u0195': 'hv',\n '\\u24D8': 'i',\n '\\uFF49': 'i',\n '\\u00EC': 'i',\n '\\u00ED': 'i',\n '\\u00EE': 'i',\n '\\u0129': 'i',\n '\\u012B': 'i',\n '\\u012D': 'i',\n '\\u00EF': 'i',\n '\\u1E2F': 'i',\n '\\u1EC9': 'i',\n '\\u01D0': 'i',\n '\\u0209': 'i',\n '\\u020B': 'i',\n '\\u1ECB': 'i',\n '\\u012F': 'i',\n '\\u1E2D': 'i',\n '\\u0268': 'i',\n '\\u0131': 'i',\n '\\u24D9': 'j',\n '\\uFF4A': 'j',\n '\\u0135': 'j',\n '\\u01F0': 'j',\n '\\u0249': 'j',\n '\\u24DA': 'k',\n '\\uFF4B': 'k',\n '\\u1E31': 'k',\n '\\u01E9': 'k',\n '\\u1E33': 'k',\n '\\u0137': 'k',\n '\\u1E35': 'k',\n '\\u0199': 'k',\n '\\u2C6A': 'k',\n '\\uA741': 'k',\n '\\uA743': 'k',\n '\\uA745': 'k',\n '\\uA7A3': 'k',\n '\\u24DB': 'l',\n '\\uFF4C': 'l',\n '\\u0140': 'l',\n '\\u013A': 'l',\n '\\u013E': 'l',\n '\\u1E37': 'l',\n '\\u1E39': 'l',\n '\\u013C': 'l',\n '\\u1E3D': 'l',\n '\\u1E3B': 'l',\n '\\u017F': 'l',\n '\\u0142': 'l',\n '\\u019A': 'l',\n '\\u026B': 'l',\n '\\u2C61': 'l',\n '\\uA749': 'l',\n '\\uA781': 'l',\n '\\uA747': 'l',\n '\\u01C9': 'lj',\n '\\u24DC': 'm',\n '\\uFF4D': 'm',\n '\\u1E3F': 'm',\n '\\u1E41': 'm',\n '\\u1E43': 'm',\n '\\u0271': 'm',\n '\\u026F': 'm',\n '\\u24DD': 'n',\n '\\uFF4E': 'n',\n '\\u01F9': 'n',\n '\\u0144': 'n',\n '\\u00F1': 'n',\n '\\u1E45': 'n',\n '\\u0148': 'n',\n '\\u1E47': 'n',\n '\\u0146': 'n',\n '\\u1E4B': 'n',\n '\\u1E49': 'n',\n '\\u019E': 'n',\n '\\u0272': 'n',\n '\\u0149': 'n',\n '\\uA791': 'n',\n '\\uA7A5': 'n',\n '\\u01CC': 'nj',\n '\\u24DE': 'o',\n '\\uFF4F': 'o',\n '\\u00F2': 'o',\n '\\u00F3': 'o',\n '\\u00F4': 'o',\n '\\u1ED3': 'o',\n '\\u1ED1': 'o',\n '\\u1ED7': 'o',\n '\\u1ED5': 'o',\n '\\u00F5': 'o',\n '\\u1E4D': 'o',\n '\\u022D': 'o',\n '\\u1E4F': 'o',\n '\\u014D': 'o',\n '\\u1E51': 'o',\n '\\u1E53': 'o',\n '\\u014F': 'o',\n '\\u022F': 'o',\n '\\u0231': 'o',\n '\\u00F6': 'o',\n '\\u022B': 'o',\n '\\u1ECF': 'o',\n '\\u0151': 'o',\n '\\u01D2': 'o',\n '\\u020D': 'o',\n '\\u020F': 'o',\n '\\u01A1': 'o',\n '\\u1EDD': 'o',\n '\\u1EDB': 'o',\n '\\u1EE1': 'o',\n '\\u1EDF': 'o',\n '\\u1EE3': 'o',\n '\\u1ECD': 'o',\n '\\u1ED9': 'o',\n '\\u01EB': 'o',\n '\\u01ED': 'o',\n '\\u00F8': 'o',\n '\\u01FF': 'o',\n '\\u0254': 'o',\n '\\uA74B': 'o',\n '\\uA74D': 'o',\n '\\u0275': 'o',\n '\\u01A3': 'oi',\n '\\u0223': 'ou',\n '\\uA74F': 'oo',\n '\\u24DF': 'p',\n '\\uFF50': 'p',\n '\\u1E55': 'p',\n '\\u1E57': 'p',\n '\\u01A5': 'p',\n '\\u1D7D': 'p',\n '\\uA751': 'p',\n '\\uA753': 'p',\n '\\uA755': 'p',\n '\\u24E0': 'q',\n '\\uFF51': 'q',\n '\\u024B': 'q',\n '\\uA757': 'q',\n '\\uA759': 'q',\n '\\u24E1': 'r',\n '\\uFF52': 'r',\n '\\u0155': 'r',\n '\\u1E59': 'r',\n '\\u0159': 'r',\n '\\u0211': 'r',\n '\\u0213': 'r',\n '\\u1E5B': 'r',\n '\\u1E5D': 'r',\n '\\u0157': 'r',\n '\\u1E5F': 'r',\n '\\u024D': 'r',\n '\\u027D': 'r',\n '\\uA75B': 'r',\n '\\uA7A7': 'r',\n '\\uA783': 'r',\n '\\u24E2': 's',\n '\\uFF53': 's',\n '\\u00DF': 's',\n '\\u015B': 's',\n '\\u1E65': 's',\n '\\u015D': 's',\n '\\u1E61': 's',\n '\\u0161': 's',\n '\\u1E67': 's',\n '\\u1E63': 's',\n '\\u1E69': 's',\n '\\u0219': 's',\n '\\u015F': 's',\n '\\u023F': 's',\n '\\uA7A9': 's',\n '\\uA785': 's',\n '\\u1E9B': 's',\n '\\u24E3': 't',\n '\\uFF54': 't',\n '\\u1E6B': 't',\n '\\u1E97': 't',\n '\\u0165': 't',\n '\\u1E6D': 't',\n '\\u021B': 't',\n '\\u0163': 't',\n '\\u1E71': 't',\n '\\u1E6F': 't',\n '\\u0167': 't',\n '\\u01AD': 't',\n '\\u0288': 't',\n '\\u2C66': 't',\n '\\uA787': 't',\n '\\uA729': 'tz',\n '\\u24E4': 'u',\n '\\uFF55': 'u',\n '\\u00F9': 'u',\n '\\u00FA': 'u',\n '\\u00FB': 'u',\n '\\u0169': 'u',\n '\\u1E79': 'u',\n '\\u016B': 'u',\n '\\u1E7B': 'u',\n '\\u016D': 'u',\n '\\u00FC': 'u',\n '\\u01DC': 'u',\n '\\u01D8': 'u',\n '\\u01D6': 'u',\n '\\u01DA': 'u',\n '\\u1EE7': 'u',\n '\\u016F': 'u',\n '\\u0171': 'u',\n '\\u01D4': 'u',\n '\\u0215': 'u',\n '\\u0217': 'u',\n '\\u01B0': 'u',\n '\\u1EEB': 'u',\n '\\u1EE9': 'u',\n '\\u1EEF': 'u',\n '\\u1EED': 'u',\n '\\u1EF1': 'u',\n '\\u1EE5': 'u',\n '\\u1E73': 'u',\n '\\u0173': 'u',\n '\\u1E77': 'u',\n '\\u1E75': 'u',\n '\\u0289': 'u',\n '\\u24E5': 'v',\n '\\uFF56': 'v',\n '\\u1E7D': 'v',\n '\\u1E7F': 'v',\n '\\u028B': 'v',\n '\\uA75F': 'v',\n '\\u028C': 'v',\n '\\uA761': 'vy',\n '\\u24E6': 'w',\n '\\uFF57': 'w',\n '\\u1E81': 'w',\n '\\u1E83': 'w',\n '\\u0175': 'w',\n '\\u1E87': 'w',\n '\\u1E85': 'w',\n '\\u1E98': 'w',\n '\\u1E89': 'w',\n '\\u2C73': 'w',\n '\\u24E7': 'x',\n '\\uFF58': 'x',\n '\\u1E8B': 'x',\n '\\u1E8D': 'x',\n '\\u24E8': 'y',\n '\\uFF59': 'y',\n '\\u1EF3': 'y',\n '\\u00FD': 'y',\n '\\u0177': 'y',\n '\\u1EF9': 'y',\n '\\u0233': 'y',\n '\\u1E8F': 'y',\n '\\u00FF': 'y',\n '\\u1EF7': 'y',\n '\\u1E99': 'y',\n '\\u1EF5': 'y',\n '\\u01B4': 'y',\n '\\u024F': 'y',\n '\\u1EFF': 'y',\n '\\u24E9': 'z',\n '\\uFF5A': 'z',\n '\\u017A': 'z',\n '\\u1E91': 'z',\n '\\u017C': 'z',\n '\\u017E': 'z',\n '\\u1E93': 'z',\n '\\u1E95': 'z',\n '\\u01B6': 'z',\n '\\u0225': 'z',\n '\\u0240': 'z',\n '\\u2C6C': 'z',\n '\\uA763': 'z',\n '\\u0386': '\\u0391',\n '\\u0388': '\\u0395',\n '\\u0389': '\\u0397',\n '\\u038A': '\\u0399',\n '\\u03AA': '\\u0399',\n '\\u038C': '\\u039F',\n '\\u038E': '\\u03A5',\n '\\u03AB': '\\u03A5',\n '\\u038F': '\\u03A9',\n '\\u03AC': '\\u03B1',\n '\\u03AD': '\\u03B5',\n '\\u03AE': '\\u03B7',\n '\\u03AF': '\\u03B9',\n '\\u03CA': '\\u03B9',\n '\\u0390': '\\u03B9',\n '\\u03CC': '\\u03BF',\n '\\u03CD': '\\u03C5',\n '\\u03CB': '\\u03C5',\n '\\u03B0': '\\u03C5',\n '\\u03C9': '\\u03C9',\n '\\u03C2': '\\u03C3'\n};\n\nexport function stripSpecialChars(text: string): string {\n const match = (a: string): string => diacritics[a] || a;\n return text.replace(/[^\\u0000-\\u007E]/g, match);\n}\n","import { newId } from './id';\nimport { NgSelectComponent } from './ng-select.component';\nimport { NgOption } from './ng-select.types';\nimport * as searchHelper from './search-helper';\nimport { SelectionModel } from './selection-model';\nimport { isDefined, isFunction, isObject } from './value-utils';\n\ntype OptionGroups = Map<string | NgOption, NgOption[]>;\n\nexport class ItemsList {\n private _groups: OptionGroups;\n\n constructor(\n private _ngSelect: NgSelectComponent,\n private _selectionModel: SelectionModel) {\n }\n\n private _items: NgOption[] = [];\n\n get items(): NgOption[] {\n return this._items;\n }\n\n private _filteredItems: NgOption[] = [];\n\n get filteredItems(): NgOption[] {\n return this._filteredItems;\n }\n\n private _markedIndex = -1;\n\n get markedIndex(): number {\n return this._markedIndex;\n }\n\n get selectedItems() {\n return this._selectionModel.value;\n }\n\n get markedItem(): NgOption {\n return this._filteredItems[this._markedIndex];\n }\n\n get noItemsToSelect(): boolean {\n return this._ngSelect.hideSelected && this._items.length === this.selectedItems.length;\n }\n\n get maxItemsSelected(): boolean {\n return this._ngSelect.multiple && this._ngSelect.maxSelectedItems <= this.selectedItems.length;\n }\n\n get lastSelectedItem() {\n let i = this.selectedItems.length - 1;\n for (; i >= 0; i--) {\n const item = this.selectedItems[i];\n if (!item.disabled) {\n return item;\n }\n }\n return null;\n }\n\n setItems(items: readonly any[]) {\n this._items = items.map((item, index) => this.mapItem(item, index));\n if (this._ngSelect.groupBy) {\n this._groups = this._groupBy(this._items, this._ngSelect.groupBy);\n this._items = this._flatten(this._groups);\n } else {\n this._groups = new Map();\n this._groups.set(undefined, this._items)\n }\n this._filteredItems = [...this._items];\n }\n\n select(item: NgOption) {\n if (item.selected || this.maxItemsSelected) {\n return;\n }\n const multiple = this._ngSelect.multiple;\n if (!multiple) {\n this.clearSelected();\n }\n\n this._selectionModel.select(item, multiple, this._ngSelect.selectableGroupAsModel);\n if (this._ngSelect.hideSelected) {\n this._hideSelected(item);\n }\n }\n\n unselect(item: NgOption) {\n if (!item.selected) {\n return;\n }\n this._selectionModel.unselect(item, this._ngSelect.multiple);\n if (this._ngSelect.hideSelected && isDefined(item.index) && this._ngSelect.multiple) {\n this._showSelected(item);\n }\n }\n\n findItem(value: any): NgOption {\n let findBy: (item: NgOption) => boolean;\n if (this._ngSelect.compareWith) {\n findBy = item => this._ngSelect.compareWith(item.value, value)\n } else if (this._ngSelect.bindValue) {\n findBy = item => !item.children && this.resolveNested(item.value, this._ngSelect.bindValue) === value\n } else {\n findBy = item => item.value === value ||\n !item.children && item.label && item.label === this.resolveNested(value, this._ngSelect.bindLabel)\n }\n return this._items.find(item => findBy(item));\n }\n\n addItem(item: any) {\n const option = this.mapItem(item, this._items.length);\n this._items.push(option);\n this._filteredItems.push(option);\n return option;\n }\n\n clearSelected(keepDisabled = false) {\n this._selectionModel.clear(keepDisabled);\n this._items.forEach(item => {\n item.selected = keepDisabled && item.selected && item.disabled;\n item.marked = false;\n });\n if (this._ngSelect.hideSelected) {\n this.resetFilteredItems();\n }\n }\n\n findByLabel(term: string) {\n term = searchHelper.stripSpecialChars(term).toLocaleLowerCase();\n return this.filteredItems.find(item => {\n const label = searchHelper.stripSpecialChars(item.label).toLocaleLowerCase();\n return label.substr(0, term.length) === term;\n });\n }\n\n filter(term: string): void {\n if (!term) {\n this.resetFilteredItems();\n return;\n }\n\n this._filteredItems = [];\n term = this._ngSelect.searchFn ? term : searchHelper.stripSpecialChars(term).toLocaleLowerCase();\n const match = this._ngSelect.searchFn || this._defaultSearchFn;\n const hideSelected = this._ngSelect.hideSelected;\n\n for (const key of Array.from(this._groups.keys())) {\n const matchedItems = [];\n for (const item of this._groups.get(key)) {\n if (hideSelected && (item.parent && item.parent.selected || item.selected)) {\n continue;\n }\n const searchItem = this._ngSelect.searchFn ? item.value : item;\n if (match(term, searchItem)) {\n matchedItems.push(item);\n }\n }\n if (matchedItems.length > 0) {\n const [last] = matchedItems.slice(-1);\n if (last.parent) {\n const head = this._items.find(x => x === last.parent);\n this._filteredItems.push(head);\n }\n this._filteredItems.push(...matchedItems);\n }\n }\n }\n\n resetFilteredItems() {\n if (this._filteredItems.length === this._items.length) {\n return;\n }\n\n if (this._ngSelect.hideSelected && this.selectedItems.length > 0) {\n this._filteredItems = this._items.filter(x => !x.selected);\n } else {\n this._filteredItems = this._items;\n }\n }\n\n unmarkItem() {\n this._markedIndex = -1;\n }\n\n markNextItem() {\n this._stepToItem(+1);\n }\n\n markPreviousItem() {\n this._stepToItem(-1);\n }\n\n markItem(item: NgOption) {\n this._markedIndex = this._filteredItems.indexOf(item);\n }\n\n markSelectedOrDefault(markDefault?: boolean) {\n if (this._filteredItems.length === 0) {\n return;\n }\n\n const lastMarkedIndex = this._getLastMarkedIndex();\n if (lastMarkedIndex > -1) {\n this._markedIndex = lastMarkedIndex;\n } else {\n this._markedIndex = markDefault ? this.filteredItems.findIndex(x => !x.disabled) : -1;\n }\n }\n\n resolveNested(option: any, key: string): any {\n if (!isObject(option)) {\n return option;\n }\n if (key.indexOf('.') === -1) {\n return option[key];\n } else {\n const keys: string[] = key.split('.');\n let value = option;\n for (let i = 0, len = keys.length; i < len; ++i) {\n if (value == null) {\n return null;\n }\n value = value[keys[i]];\n }\n return value;\n }\n }\n\n mapItem(item: any, index: number): NgOption {\n const label = isDefined(item.$ngOptionLabel) ? item.$ngOptionLabel : this.resolveNested(item, this._ngSelect.bindLabel);\n const value = isDefined(item.$ngOptionValue) ? item.$ngOptionValue : item;\n return {\n index,\n label: isDefined(label) ? label.toString() : '',\n value,\n disabled: item.disabled,\n htmlId: `${this._ngSelect.dropdownId}-${index}`,\n };\n }\n\n mapSelectedItems() {\n const multiple = this._ngSelect.multiple;\n for (const selected of this.selectedItems) {\n const value = this._ngSelect.bindValue ? this.resolveNested(selected.value, this._ngSelect.bindValue) : selected.value;\n const item = isDefined(value) ? this.findItem(value) : null;\n this._selectionModel.unselect(selected, multiple);\n this._selectionModel.select(item || selected, multiple, this._ngSelect.selectableGroupAsModel);\n }\n\n if (this._ngSelect.hideSelected) {\n this._filteredItems = this.filteredItems.filter(x => this.selectedItems.indexOf(x) === -1);\n }\n }\n\n private _showSelected(item: NgOption) {\n this._filteredItems.push(item);\n if (item.parent) {\n const parent = item.parent;\n const parentExists = this._filteredItems.find(x => x === parent);\n if (!parentExists) {\n this._filteredItems.push(parent);\n }\n } else if (item.children) {\n for (const child of item.children) {\n child.selected = false;\n this._filteredItems.push(child);\n }\n }\n this._filteredItems = [...this._filteredItems.sort((a, b) => (a.index - b.index))];\n }\n\n private _hideSelected(item: NgOption) {\n this._filteredItems = this._filteredItems.filter(x => x !== item);\n if (item.parent) {\n const children = item.parent.children;\n if (children.every(x => x.selected)) {\n this._filteredItems = this._filteredItems.filter(x => x !== item.parent);\n }\n } else if (item.children) {\n this._filteredItems = this.filteredItems.filter(x => x.parent !== item);\n }\n }\n\n private _defaultSearchFn(search: string, opt: NgOption) {\n const label = searchHelper.stripSpecialChars(opt.label).toLocaleLowerCase();\n return label.indexOf(search) > -1\n }\n\n private _getNextItemIndex(steps: number) {\n if (steps > 0) {\n return (this._markedIndex >= this._filteredItems.length - 1) ? 0 : (this._markedIndex + 1);\n }\n return (this._markedIndex <= 0) ? (this._filteredItems.length - 1) : (this._markedIndex - 1);\n }\n\n private _stepToItem(steps: number) {\n if (this._filteredItems.length === 0 || this._filteredItems.every(x => x.disabled)) {\n return;\n }\n\n this._markedIndex = this._getNextItemIndex(steps);\n if (this.markedItem.disabled) {\n this._stepToItem(steps);\n }\n }\n\n private _getLastMarkedIndex() {\n if (this._ngSelect.hideSelected) {\n return -1;\n }\n\n if (this._markedIndex > -1 && this.markedItem === undefined) {\n return -1;\n }\n\n const selectedIndex = this._filteredItems.indexOf(this.lastSelectedItem);\n if (this.lastSelectedItem && selectedIndex < 0) {\n return -1;\n }\n\n return Math.max(this.markedIndex, selectedIndex);\n }\n\n private _groupBy(items: NgOption[], prop: string | ((value: any) => any)): OptionGroups {\n const groups = new Map<string | NgOption, NgOption[]>();\n if (items.length === 0) {\n return groups;\n }\n\n // Check if items are already grouped by given key.\n if (Array.isArray(items[0].value[<string>prop])) {\n for (const item of items) {\n const children = (item.value[<string>prop] || []).map((x, index) => this.mapItem(x, index));\n groups.set(item, children);\n }\n return groups;\n }\n\n const isFnKey = isFunction(this._ngSelect.groupBy);\n const keyFn = (item: NgOption) => {\n const key = isFnKey ? (<(value: any) => any>prop)(item.value) : item.value[<string>prop];\n return isDefined(key) ? key : undefined;\n };\n\n // Group items by key.\n for (const item of items) {\n const key = keyFn(item);\n const group = groups.get(key);\n if (group) {\n group.push(item);\n } else {\n groups.set(key, [item]);\n }\n }\n return groups;\n }\n\n private _flatten(groups: OptionGroups) {\n const isGroupByFn = isFunction(this._ngSelect.groupBy);\n const items = [];\n for (const key of Array.from(groups.keys())) {\n let i = items.length;\n if (key === undefined) {\n const withoutGroup = groups.get(undefined) || [];\n items.push(...withoutGroup.map(x => {\n x.index = i++;\n return x;\n }));\n continue;\n }\n\n const isObjectKey = isObject(key);\n const parent: NgOption = {\n label: isObjectKey ? '' : String(key),\n children: undefined,\n parent: null,\n index: i++,\n disabled: !this._ngSelect.selectableGroup,\n htmlId: newId(),\n };\n const groupKey = isGroupByFn ? this._ngSelect.bindLabel : <string>this._ngSelect.groupBy;\n const groupValue = this._ngSelect.groupValue || (() => {\n if (isObjectKey) {\n return (<NgOption>key).value;\n }\n return { [groupKey]: key };\n });\n const children = groups.get(key).map(x => {\n x.parent = parent;\n x.children = undefined;\n x.index = i++;\n return x;\n });\n parent.children = children;\n parent.value = groupValue(key, children.map(x => x.value));\n items.push(parent);\n items.push(...children);\n }\n return items;\n }\n}\n","export interface NgOption {\n [name: string]: any;\n\n index?: number;\n htmlId?: string;\n selected?: boolean;\n disabled?: boolean;\n marked?: boolean;\n label?: string;\n value?: string | any;\n parent?: NgOption;\n children?: NgOption[];\n}\n\nexport enum KeyCode {\n Tab = 9,\n Enter = 13,\n Esc = 27,\n Space = 32,\n ArrowUp = 38,\n ArrowDown = 40,\n Backspace = 8\n}\n\nexport type DropdownPosition = 'top' | 'right' | 'bottom' | 'left' | 'auto';\n","import { Injectable } from '@angular/core';\nexport interface ItemsRangeResult {\n scrollHeight: number;\n topPadding: number;\n start: number;\n end: number;\n}\n\nexport interface PanelDimensions {\n itemHeight: number;\n panelHeight: number;\n itemsPerViewport: number;\n}\n\n@Injectable()\nexport class NgDropdownPanelService {\n\n private _dimensions: PanelDimensions = {\n itemHeight: 0,\n panelHeight: 0,\n itemsPerViewport: 0\n };\n\n get dimensions() {\n return this._dimensions;\n }\n\n calculateItems(scrollPos: number, itemsLength: number, buffer: number): ItemsRangeResult {\n const d = this._dimensions;\n const scrollHeight = d.itemHeight * itemsLength;\n\n const scrollTop = Math.max(0, scrollPos);\n const indexByScrollTop = scrollTop / scrollHeight * itemsLength;\n let end = Math.min(itemsLength, Math.ceil(indexByScrollTop) + (d.itemsPerViewport + 1));\n\n const maxStartEnd = end;\n const maxStart = Math.max(0, maxStartEnd - d.itemsPerViewport);\n let start = Math.min(maxStart, Math.floor(indexByScrollTop));\n\n let topPadding = d.itemHeight * Math.ceil(start) - (d.itemHeight * Math.min(start, buffer));\n topPadding = !isNaN(topPadding) ? topPadding : 0;\n start = !isNaN(start) ? start : -1;\n end = !isNaN(end) ? end : -1;\n start -= buffer;\n start = Math.max(0, start);\n end += buffer;\n end = Math.min(itemsLength, end);\n\n return {\n topPadding,\n scrollHeight,\n start,\n end\n }\n }\n\n setDimensions(itemHeight: number, panelHeight: number) {\n const itemsPerViewport = Math.max(1, Math.floor(panelHeight / itemHeight));\n this._dimensions = {\n itemHeight,\n panelHeight,\n itemsPerViewport\n };\n }\n\n getScrollTo(itemTop: number, itemHeight: number, lastScroll: number) {\n const { panelHeight } = this.dimensions;\n const itemBottom = itemTop + itemHeight;\n const top = lastScroll;\n const bottom = top + panelHeight;\n\n if (panelHeight >= itemBottom && lastScroll === itemTop) {\n return null;\n }\n\n if (itemBottom > bottom) {\n return top + itemBottom - bottom;\n } else if (itemTop <= top) {\n return itemTop;\n }\n\n return null;\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n EventEmitter,\n Inject,\n Input,\n NgZone,\n OnChanges,\n OnDestroy,\n OnInit,\n Optional,\n Output,\n Renderer2,\n SimpleChanges,\n TemplateRef,\n ViewChild,\n ViewEncapsulation\n} from '@angular/core';\nimport { animationFrameScheduler, asapScheduler, fromEvent, merge, Subject } from 'rxjs';\nimport { auditTime, takeUntil } from 'rxjs/operators';\nimport { NgDropdownPanelService, PanelDimensions } from './ng-dropdown-panel.service';\n\nimport { DropdownPosition } from './ng-select.types';\nimport { NgOption } from './ng-select.types';\nimport { isDefined } from './value-utils';\n\nconst CSS_POSITIONS: Readonly<string[]> = ['top', 'right', 'bottom', 'left'];\nconst SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n selector: 'ng-dropdown-panel',\n template: `\n @if (headerTemplate) {\n <div class=\"ng-dropdown-header\">\n <ng-container [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ searchTerm: filterValue }\"></ng-container>\n </div>\n }\n <div #scroll role=\"listbox\" class=\"ng-dropdown-panel-items scroll-host\">\n <div #padding [class.total-padding]=\"virtualScroll\"></div>\n <div #content [class.scrollable-content]=\"virtualScroll && items.length\">\n <ng-content></ng-content>\n </div>\n </div>\n @if (footerTemplate) {\n <div class=\"ng-dropdown-footer\">\n <ng-container [ngTemplateOutlet]=\"footerTemplate\" [ngTemplateOutletContext]=\"{ searchTerm: filterValue }\"></ng-container>\n </div>\n }\n `\n })\nexport class NgDropdownPanelComponent implements OnInit, OnChanges, OnDestroy {\n\n @Input() items: NgOption[] = [];\n @Input() markedItem: NgOption;\n @Input() position: DropdownPosition = 'auto';\n @Input() appendTo: string;\n @Input() bufferAmount;\n @Input({transform: booleanAttribute}) virtualScroll = false;\n @Input() headerTemplate: TemplateRef<any>;\n @Input() footerTemplate: TemplateRef<any>;\n @Input() filterValue: string = null;\n\n @Output() update = new EventEmitter<any[]>();\n @Output() scroll = new EventEmitter<{ start: number; end: number }>();\n @Output() scrollToEnd = new EventEmitter<void>();\n @Output() outsideClick = new EventEmitter<void>();\n\n @ViewChild('content', { read: ElementRef, static: true }) contentElementRef: ElementRef;\n @ViewChild('scroll', { read: ElementRef, static: true }) scrollElementRef: ElementRef;\n @ViewChild('padding', { read: ElementRef, static: true }) paddingElementRef: ElementRef;\n\n private readonly _destroy$ = new Subject<void>();\n private readonly _dropdown: HTMLElement;\n private _virtualPadding: HTMLElement;\n private _scrollablePanel: HTMLElement;\n private _contentPanel: HTMLElement;\n private _select: HTMLElement;\n private _parent: HTMLElement;\n private _scrollToEndFired = false;\n private _updateScrollHeight = false;\n private _lastScrollPosition = 0;\n\n constructor(\n private _renderer: Renderer2,\n private _zone: NgZone,\n private _panelService: NgDropdownPanelService,\n _elementRef: ElementRef,\n @Optional() @Inject(DOCUMENT) private _document: any\n ) {\n this._dropdown = _elementRef.nativeElement;\n }\n\n private _currentPosition: DropdownPosition;\n\n get currentPosition(): DropdownPosition {\n return this._currentPosition;\n }\n\n private _itemsLength: number;\n\n private get itemsLength() {\n return this._itemsLength;\n }\n\n private set itemsLength(value: number) {\n if (value !== this._itemsLength) {\n this._itemsLength = value;\n this._onItemsLengthChanged();\n }\n }\n\n private get _startOffset() {\n if (this.markedItem) {\n const { itemHeight, panelHeight } = this._panelService.dimensions;\n const offset = this.markedItem.index * itemHeight;\n return panelHeight > offset ? 0 : offset;\n }\n return 0;\n }\n\n ngOnInit() {\n this._select = this._dropdown.parentElement;\n this._virtualPadding = this.paddingElementRef.nativeElement;\n this._scrollablePanel = this.scrollElementRef.nativeElement;\n this._contentPanel = this.contentElementRef.nativeElement;\n this._handleScroll();\n this._handleOutsideClick();\n this._appendDropdown();\n this._setupMousedownListener();\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (changes.items) {\n const change = changes.items;\n this._onItemsChange(change.currentValue, change.firstChange);\n }\n }\n\n ngOnDestroy() {\n this._destroy$.next();\n this._destroy$.complete();\n this._destroy$.unsubscribe();\n if (this.appendTo) {\n this._renderer.removeChild(this._dropdown.parentNode, this._dropdown);\n }\n }\n\n scrollTo(option: NgOption, startFromOption = false) {\n if (!option) {\n return;\n }\n\n const index = this.items.indexOf(option);\n if (index < 0 || index >= this.itemsLength) {\n return;\n }\n\n let scrollTo;\n if (this.virtualScroll) {\n const itemHeight = this._panelService.dimensions.itemHeight;\n scrollTo = this._panelService.getScrollTo(index * itemHeight, itemHeight, this._lastScrollPosition);\n } else {\n const item: HTMLElement = this._dropdown.querySelector(`#${option.htmlId}`);\n const lastScroll = startFromOption ? item.offsetTop : this._lastScrollPosition;\n scrollTo = this._panelService.getScrollTo(item.offsetTop, item.clientHeight, lastScroll);\n }\n\n if (isDefined(scrollTo)) {\n this._scrollablePanel.scrollTop = scrollTo;\n }\n }\n\n scrollToTag() {\n const panel = this._scrollablePanel;\n panel.scrollTop = panel.scrollHeight - panel.clientHeight;\n }\n\n adjustPosition() {\n this._updateYPosition();\n }\n\n private _handleDropdownPosition() {\n this._currentPosition = this._calculateCurrentPosition(this._dropdown);\n if (CSS_POSITIONS.includes(this._currentPosition)) {\n this._updateDropdownClass(this._currentPosition);\n } else {\n this._updateDropdownClass('bottom');\n }\n\n if (this.appendTo) {\n this._updateYPosition();\n }\n\n this._dropdown.style.opacity = '1';\n }\n\n private _updateDropdownClass(currentPosition: string) {\n CSS_POSITIONS.forEach((position) => {\n const REMOVE_CSS_CLASS = `ng-select-${position}`;\n this._renderer.removeClass(this._dropdown, REMOVE_CSS_CLASS);\n this._renderer.removeClass(this._select, REMOVE_CSS_CLASS);\n });\n\n const ADD_CSS_CLASS = `ng-select-${currentPosition}`;\n this._renderer.addClass(this._dropdown, ADD_CSS_CLASS);\n this._renderer.addClass(this._select, ADD_CSS_CLASS);\n }\n\n private _handleScroll() {\n this._zone.runOutsideAngular(() => {\n fromEvent(this.scrollElementRef.nativeElement, 'scroll')\n .pipe(takeUntil(this._destroy$), auditTime(0, SCROLL_SCHEDULER))\n .subscribe((e: { path, composedPath, target }) => {\n const path = e.path || (e.composedPath && e.composedPath());\n if (!path || path.length === 0 && !e.target) {return;}\n const scrollTop = !path || path.length === 0 ? e.target.scrollTop : path[0].scrollTop\n this._onContentScrolled(scrollTop);\n });\n });\n }\n\n private _handleOutsideClick() {\n if (!this._document) {\n return;\n }\n\n this._zone.runOutsideAngular(() => {\n merge(\n fromEvent(this._document, 'touchstart', { capture: true }),\n fromEvent(this._document, 'click', { capture: true })\n ).pipe(takeUntil(this._destroy$))\n .subscribe($event => this._checkToClose($event));\n });\n }\n\n private _checkToClose($event: any) {\n if (this._select.contains($event.target) || this._dropdown.contains($event.target)) {\n return;\n }\n\n const path = $event.path || ($event.composedPath && $event.composedPath());\n if ($event.target && $event.target.shadowRoot && path && path[0] && this._select.contains(path[0])) {\n return;\n }\n\n this._zone.run(() => this.outsideClick.emit());\n }\n\n private _onItemsChange(items: NgOption[], firstChange: boolean) {\n this.items = items || [];\n this._scrollToEndFired = false;\n this.itemsLength = items.length;\n\n if (this.virtualScroll) {\n this._updateItemsRange(firstChange);\n } else {\n this._setVirtualHeight();\n this._updateItems(firstChange);\n }\n }\n\n private _updateItems(firstChange: boolean) {\n this.update.emit(this.items);\n if (firstChange === false) {\n return;\n }\n\n this._zone.runOutsideAngular(() => {\n Promise.resolve().then(() => {\n const panelHeight = this._scrollablePanel.clientHeight;\n this._panelService.setDimensions(0, panelHeight);\n this._handleDropdownPosition();\n this.scrollTo(this.markedItem, firstChange);\n });\n });\n }\n\n private _updateItemsRange(firstChange: boolean) {\n this._zone.runOutsideAngular(() => {\n this._measureDimensions().