-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsrc_app_custom-elements_api_api-list_module_ts.e324e516146b6cda.js.map
executable file
·1 lines (1 loc) · 22 KB
/
src_app_custom-elements_api_api-list_module_ts.e324e516146b6cda.js.map
1
{"version":3,"file":"src_app_custom-elements_api_api-list_module_ts.e324e516146b6cda.js","mappings":"sSA2BM,MAAOA,EA+BXC,YAAoBC,EAA0BC,GAA1BC,YAA0BA,cA7BtCA,aAAUC,KAAyB,OACnCD,wBAAqB,gBACrBA,gBAAY,EACZA,eAAY,IAAIE,IAChBF,qBAAkB,IAAIG,IAA4B,GAClDH,eAAYA,KAAKI,gBAAgBC,QAAKC,KAAUN,KAAKO,WAwBG,CAlB5DC,eAEF,OAAIR,KAAKS,YACPT,KAAKS,WAAY,EACjBT,KAAKU,gBAGLV,KAAKW,UAAUC,UAAUJ,GAAYR,KAAKD,OAAOc,IAAI,sBAAsBL,EAASM,uBAG/Ed,KAAKW,UAAUN,QAAKU,KAAIP,IAC7BA,EAASQ,QAAQC,IACfA,EAAQC,aAAeD,EAAQE,OAC3BF,EAAQE,MAAMC,MAAMC,GAA2B,eAAnBA,EAAKC,UAA0B,EAChE,GAEL,CAIAC,cACEvB,KAAKO,UAAUiB,MACjB,CASAd,cAAce,GAEZ,MAAMC,EAAM1B,KAAK2B,SAAWF,GAAOzB,KAAK4B,oBACxC5B,KAAKF,KAAK+B,IAAkBH,GACzBrB,QACCC,KAAUN,KAAKO,YAAS,EACxBQ,KAAI,IAAMf,KAAKD,OAAOc,IAAI,yBAAyBa,OAEpDd,UAAU,CACTY,KAAMhB,GAAYR,KAAKI,gBAAgBoB,KAAKhB,GAC5CsB,MAAQC,IAEN,WAAKhC,OAAO+B,MAAMC,GACZA,IAGd,CAACC,kDA5DUpC,GAAUqC,+DAAVrC,EAAUsC,QAAVtC,EAAU,mECbjBuC,8BAYEA,6GAPJA,gBAMIA,kEAASA,kBAAS,GAClBA,gCACJA,oEANIA,iCAAsC,kCAGtCA,q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BAAoC,kBAEtBA,kCAAUsC,mBAAsB,GAK5CtC,QAEAA,wBAAYA,kCAAUsC,qBAAwB,GAK9CtC,QAEAA,iBAAyB,eACSA,iCAASsC,0BAAmC,GAA5EtC,QACAA,eAA0BA,kBAAMA,YAIpCA,qBACEA,yCAaFA,eAjCcA,kCAAiB,kBAAjBA,CAAiB,iBAOjBA,qCAAoB,oBAApBA,CAAoB,qCAaPA,6GEVrB,MAAOuF,EALb7H,cAMEG,4BAAoC2E,EACrC3C,kDAFY0F,EAAa,sCAAbA,IAAa1F,yCAFb,CAAEpC,GAAY+H,SAFdC,KAAcC,IAAcC","names":["ApiService","constructor","http","logger","this","DOC_CONTENT_URL_PREFIX","Subject","ReplaySubject","sectionsSubject","pipe","takeUntil","onDestroy","sections","firstTime","fetchSections","_sections","subscribe","log","length","tap","forEach","section","deprecated","items","every","item","stability","ngOnDestroy","next","src","url","apiBase","apiListJsonDefault","get","error","err","static","core","factory","i0","SelectComponent","hostElement","EventEmitter","instancesCounter","showOptions","_showOptions","disabled","optionsToggled","emit","ngOnInit","label","toggleOptions","hideOptions","select","index","option","options","selected","change","onClick","eventTarget","nativeElement","contains","handleKeydown","event","runOrOpenOptions","fn","indexOfSelected","indexOf","currentOptionIdx","key","Math","min","max","preventDefault","selectors","ElementRef","ctx","SearchCriteria","ApiListComponent","apiService","locationService","value","title","filteredSections","combineLatest","criteriaSubject","map","results","criteria","filterSection","initializeSearchCriteria","setQuery","query","setSearchCriteria","toLowerCase","trim","setStatus","status","toggleStatusMenu","setType","type","toggleTypeMenu","showStatusMenu","showTypeMenu","sectionNameMatches","name","filter","docType","matchesType","securityRisk","matchesStatus","matchesQuery","search","q","queryEl","statuses","find","x","types","searchCriteria","setLocationSearch","setSearch","undefined","Object","assign","ApiListModule","imports","CommonModule","SharedModule","HttpClientModule"],"sourceRoot":"webpack:///","sources":["./src/app/custom-elements/api/api.service.ts","./src/app/shared/select/select.component.html","./src/app/shared/select/select.component.ts","./src/app/custom-elements/api/api-list.component.html","./src/app/custom-elements/api/api-list.component.ts","./src/app/custom-elements/api/api-list.module.ts"],"sourcesContent":["import { Injectable, OnDestroy } from '@angular/core';\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\n\nimport { ReplaySubject, Subject } from 'rxjs';\nimport { takeUntil, tap } from 'rxjs/operators';\n\nimport { Logger } from 'app/shared/logger.service';\nimport { DOC_CONTENT_URL_PREFIX } from 'app/documents/document.service';\n\nexport interface ApiItem {\n name: string;\n title: string;\n path: string;\n docType: string;\n stability: string;\n securityRisk: boolean;\n}\n\nexport interface ApiSection {\n path: string;\n name: string;\n title: string;\n deprecated: boolean;\n items: ApiItem[]|null;\n}\n\n@Injectable()\nexport class ApiService implements OnDestroy {\n\n private apiBase = DOC_CONTENT_URL_PREFIX + 'api/';\n private apiListJsonDefault = 'api-list.json';\n private firstTime = true;\n private onDestroy = new Subject<void>();\n private sectionsSubject = new ReplaySubject<ApiSection[]>(1);\n private _sections = this.sectionsSubject.pipe(takeUntil(this.onDestroy));\n\n /**\n * Return a cached observable of API sections from a JSON file.\n * API sections is an array of Angular top modules and metadata about their API documents (items).\n */\n get sections() {\n\n if (this.firstTime) {\n this.firstTime = false;\n this.fetchSections(); // TODO: get URL for fetchSections by configuration?\n\n // makes sectionsSubject hot; subscribe ensures stays alive (always refCount > 0);\n this._sections.subscribe(sections => this.logger.log(`ApiService got API ${sections.length} section(s)`));\n }\n\n return this._sections.pipe(tap(sections => {\n sections.forEach(section => {\n section.deprecated = !!section.items &&\n section.items.every(item => item.stability === 'deprecated');\n });\n }));\n }\n\n constructor(private http: HttpClient, private logger: Logger) { }\n\n ngOnDestroy() {\n this.onDestroy.next();\n }\n\n /**\n * Fetch API sections from a JSON file.\n * API sections is an array of Angular top modules and metadata about their API documents (items).\n * Updates `sections` observable\n *\n * @param [src] - Name of the api list JSON file\n */\n fetchSections(src?: string) {\n // TODO: get URL by configuration?\n const url = this.apiBase + (src || this.apiListJsonDefault);\n this.http.get<ApiSection[]>(url)\n .pipe(\n takeUntil(this.onDestroy),\n tap(() => this.logger.log(`Got API sections from ${url}`)),\n )\n .subscribe({\n next: sections => this.sectionsSubject.next(sections),\n error: (err: HttpErrorResponse) => {\n // TODO: handle error\n this.logger.error(err);\n throw err; // rethrow for now.\n },\n });\n }\n}\n","<div class=\"form-select-menu\">\n <div class=\"form-select-button\"\n role=\"combobox\"\n [attr.aria-controls]=\"listBoxId\"\n aria-haspopup=\"listbox\"\n (click)=\"toggleOptions()\"\n (keydown)=\"handleKeydown($event)\"\n [attr.aria-expanded]=\"showOptions\"\n [attr.aria-activedescendant]=\"currentOptionIdx > -1 && showOptions ? listBoxId + '-option-' + currentOptionIdx : null\"\n [attr.aria-label]=\"label + (selected?.title ?? '')\"\n [class.disabled]=\"disabled\"\n tabindex=\"0\"\n >\n <div aria-hidden=\"true\">\n <ng-container *ngTemplateOutlet=\"optionTemplate; context: { showLabel: true, value: selected?.value, title: selected?.title }\"></ng-container>\n </div>\n </div>\n <ul class=\"form-select-dropdown\" *ngIf=\"showOptions\" [id]=\"listBoxId\" role=\"listbox\" tabIndex=\"-1\" #listBox>\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events -- the key events are handled in the ts class -->\n <li *ngFor=\"let option of options; index as i\"\n role=\"option\"\n [class.selected]=\"option === selected\"\n [attr.aria-selected]=\"option === selected\"\n [class.current]=\"currentOptionIdx === i\"\n [id]=\"listBoxId + '-option-' + i\"\n (click)=\"select(i)\">\n <ng-container *ngTemplateOutlet=\"optionTemplate; context: { showLabel: false, value: option.value, title: option.title }\"></ng-container>\n </li>\n </ul>\n</div>\n<ng-template #optionTemplate let-showLabel=\"showLabel\" let-value=\"value\" let-title=\"title\">\n <span *ngIf=\"showLabel\"><strong>{{label}}</strong></span><span *ngIf=\"showSymbol\" class=\"symbol {{value}}\"></span><span>{{title}}</span>\n</ng-template>\n","import { Component, ElementRef, EventEmitter, HostListener, Input, Output, OnInit, ViewChild } from '@angular/core';\n\nexport interface Option {\n title: string;\n value?: any;\n}\n\n@Component({\n selector: 'aio-select',\n templateUrl: 'select.component.html'\n})\nexport class SelectComponent implements OnInit {\n static instancesCounter = 0;\n\n @Input() selected: Option | undefined;\n\n @Input() options: Option[];\n\n // eslint-disable-next-line @angular-eslint/no-output-native\n @Output() change = new EventEmitter<{option: Option, index: number}>();\n\n @Output() optionsToggled = new EventEmitter<boolean>();\n\n @Input() showSymbol = false;\n\n @Input() label = '';\n\n @Input() disabled: boolean;\n\n @ViewChild('listBox', { read: ElementRef }) listBox: ElementRef;\n\n private _showOptions = false;\n\n get showOptions() {\n return this._showOptions;\n }\n\n set showOptions(showOptions: boolean) {\n if(!this.disabled) {\n if(this.showOptions !== showOptions) {\n this.optionsToggled.emit(showOptions);\n }\n this._showOptions = showOptions;\n }\n }\n\n listBoxId = `aio-select-list-box-${SelectComponent.instancesCounter++}`;\n\n currentOptionIdx = 0;\n\n constructor(private hostElement: ElementRef) {}\n\n ngOnInit() {\n this.label = this.label || '';\n }\n\n toggleOptions() {\n this.showOptions = !this.showOptions;\n }\n\n hideOptions() {\n this.showOptions = false;\n }\n\n select(index: number) {\n const option = this.options[index];\n this.selected = option;\n this.change.emit({option, index});\n this.hideOptions();\n }\n\n @HostListener('document:click', ['$event.target'])\n onClick(eventTarget: HTMLElement) {\n // Hide the options if we clicked outside the component\n if (!this.hostElement.nativeElement.contains(eventTarget)) {\n this.hideOptions();\n }\n }\n\n handleKeydown(event: KeyboardEvent) {\n const runOrOpenOptions = (fn: () => void): void => {\n if(!this.showOptions) {\n this.showOptions = true;\n const indexOfSelected = (!this.options || !this.selected) ? -1 : this.options.indexOf(this.selected);\n this.currentOptionIdx = indexOfSelected > 0 ? indexOfSelected : 0;\n } else {\n fn();\n }\n };\n switch(event.key) {\n case 'ArrowDown':\n runOrOpenOptions(() =>\n this.currentOptionIdx = Math.min(this.currentOptionIdx + 1, (this.options?.length ?? 0) - 1)\n );\n break;\n case 'ArrowUp':\n runOrOpenOptions(() => this.currentOptionIdx = Math.max(this.currentOptionIdx - 1, 0));\n break;\n case 'Escape':\n this.hideOptions();\n break;\n case 'Tab':\n if(this.showOptions) {\n this.select(this.currentOptionIdx);\n }\n break;\n case 'Enter':\n case 'Space':\n case ' ':\n runOrOpenOptions(() => this.select(this.currentOptionIdx));\n break;\n }\n if(event.key !== 'Tab') {\n event.preventDefault();\n }\n }\n}\n","<div class=\"l-flex-wrap api-filter\">\n\n <aio-select (change)=\"setType($event.option)\"\n [options]=\"types\"\n [selected]=\"type\"\n [showSymbol]=\"true\"\n label=\"类型:\">\n </aio-select>\n\n <aio-select (change)=\"setStatus($event.option)\"\n [options]=\"statuses\"\n [selected]=\"status\"\n [disabled]=\"type.value === 'package'\"\n label=\"状态:\">\n </aio-select>\n\n <div class=\"form-search\">\n <input #filter placeholder=\"过滤\" (input)=\"setQuery($any($event.target).value)\" aria-label=\"Filter Search\">\n <i class=\"material-icons\">search</i>\n </div>\n</div>\n\n<article class=\"api-list-container\">\n <div *ngFor=\"let section of filteredSections | async\" >\n <h2 *ngIf=\"section.items\"><a [href]=\"section.path\" [class.deprecated-api-item]=\"section.deprecated\">{{section.title}}</a></h2>\n <ul class=\"api-list\" *ngIf=\"section.items && section.items.length\">\n <ng-container *ngFor=\"let item of section.items\">\n <li class=\"api-item\">\n <a [href]=\"item.path\" [class.deprecated-api-item]=\"item.stability === 'deprecated'\">\n <span class=\"symbol {{item.docType}}\"></span>\n {{item.title}}\n </a>\n </li>\n </ng-container>\n </ul>\n </div>\n</article>\n","/*\n* API List & Filter Component\n*\n* A page that displays a formatted list of the public Angular API entities.\n* Clicking on a list item triggers navigation to the corresponding API entity document.\n* Can add/remove API entity links based on filter settings.\n*/\n\nimport { Component, ElementRef, OnInit, ViewChild } from '@angular/core';\n\nimport { combineLatest, Observable, ReplaySubject } from 'rxjs';\n\nimport { LocationService } from 'app/shared/location.service';\nimport { ApiItem, ApiSection, ApiService } from './api.service';\n\nimport { Option } from 'app/shared/select/select.component';\nimport { map } from 'rxjs/operators';\n\nclass SearchCriteria {\n query = '';\n status = 'all';\n type = 'all';\n}\n\n@Component({\n selector: 'aio-api-list',\n templateUrl: './api-list.component.html',\n})\nexport class ApiListComponent implements OnInit {\n\n filteredSections: Observable<ApiSection[]>;\n\n showStatusMenu = false;\n showTypeMenu = false;\n\n private criteriaSubject = new ReplaySubject<SearchCriteria>(1);\n private searchCriteria = new SearchCriteria();\n\n status: Option;\n type: Option;\n\n // API types\n types: Option[] = [\n { value: 'all', title: '全部' },\n { value: 'class', title: '类' },\n { value: 'const', title: '常量'},\n { value: 'decorator', title: '装饰器' },\n { value: 'directive', title: '指令' },\n { value: 'element', title: 'Element'},\n { value: 'enum', title: '枚举' },\n { value: 'function', title: '函数' },\n { value: 'interface', title: '接口' },\n { value: 'package', title: 'Package'},\n { value: 'pipe', title: '管道'},\n { value: 'ngmodule', title: 'NgModule'},\n { value: 'type-alias', title: '类型别名' },\n ];\n\n statuses: Option[] = [\n { value: 'all', title: '全部' },\n { value: 'stable', title: '稳定'},\n { value: 'deprecated', title: '弃用' },\n { value: 'security-risk', title: '安全风险' }\n ];\n\n @ViewChild('filter', { static: true }) queryEl: ElementRef;\n\n constructor(\n private apiService: ApiService,\n private locationService: LocationService) { }\n\n ngOnInit() {\n this.filteredSections =\n combineLatest([\n this.apiService.sections,\n this.criteriaSubject,\n ]).pipe(\n map( results => ({ sections: results[0], criteria: results[1]})),\n map( results => (\n results.sections\n .map(section => ({ ...section, items: this.filterSection(section, results.criteria) }))\n ))\n );\n\n this.initializeSearchCriteria();\n }\n\n // TODO: may need to debounce as the original did\n // although there shouldn't be any perf consequences if we don't\n setQuery(query: string) {\n this.setSearchCriteria({query: (query || '').toLowerCase().trim() });\n }\n\n setStatus(status: Option) {\n this.toggleStatusMenu();\n this.status = status;\n this.setSearchCriteria({status: status.value});\n }\n\n setType(type: Option) {\n this.toggleTypeMenu();\n this.type = type;\n this.setSearchCriteria({type: type.value});\n }\n\n toggleStatusMenu() {\n this.showStatusMenu = !this.showStatusMenu;\n }\n\n toggleTypeMenu() {\n this.showTypeMenu = !this.showTypeMenu;\n }\n\n //////// Private //////////\n\n private filterSection(section: ApiSection, { query, status, type }: SearchCriteria) {\n const sectionNameMatches = !query || section.name.indexOf(query) !== -1;\n\n const matchesQuery = (item: ApiItem) =>\n sectionNameMatches || item.name.indexOf(query) !== -1;\n const matchesStatus = (item: ApiItem) =>\n status === 'all' || status === item.stability || (status === 'security-risk' && item.securityRisk);\n const matchesType = (item: ApiItem) =>\n type === 'all' || type === item.docType;\n\n const items: ApiItem[] = (section.items || []).filter(item =>\n matchesType(item) && matchesStatus(item) && matchesQuery(item));\n\n // If there are no items we still return an empty array if the section name matches and the type is 'package'\n return items.length ? items : (sectionNameMatches && type === 'package') ? [] : null;\n }\n\n // Get initial search criteria from URL search params\n private initializeSearchCriteria() {\n const {query, status, type} = this.locationService.search();\n\n const q = (query || '').toLowerCase();\n // Hack: can't bind to query because input cursor always forced to end-of-line.\n this.queryEl.nativeElement.value = q;\n\n this.status = this.statuses.find(x => x.value === status) || this.statuses[0];\n this.type = this.types.find(x => x.value === type) || this.types[0];\n\n this.searchCriteria = {\n query: q,\n status: this.status.value,\n type: this.type.value\n };\n\n this.criteriaSubject.next(this.searchCriteria);\n }\n\n private setLocationSearch() {\n const {query, status, type} = this.searchCriteria;\n const params = {\n query: query ? query : undefined,\n status: status !== 'all' ? status : undefined,\n type: type !== 'all' ? type : undefined\n };\n\n this.locationService.setSearch('API 搜索', params);\n }\n\n private setSearchCriteria(criteria: Partial<SearchCriteria>) {\n this.criteriaSubject.next(Object.assign(this.searchCriteria, criteria));\n this.setLocationSearch();\n }\n}\n","import { NgModule, Type } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { SharedModule } from '../../shared/shared.module';\nimport { ApiListComponent } from './api-list.component';\nimport { ApiService } from './api.service';\nimport { WithCustomElementComponent } from '../element-registry';\n\n@NgModule({\n imports: [ CommonModule, SharedModule, HttpClientModule ],\n declarations: [ ApiListComponent ],\n providers: [ ApiService ]\n})\nexport class ApiListModule implements WithCustomElementComponent {\n customElementComponent: Type<any> = ApiListComponent;\n}\n"],"x_google_ignoreList":[]}