UNPKG

@taiga-ui/kit

Version:

Taiga UI Angular main components kit

1 lines 9.2 kB
{"version":3,"file":"taiga-ui-kit-components-pdf-viewer.mjs","sources":["../../../projects/kit/components/pdf-viewer/pdf-viewer.component.ts","../../../projects/kit/components/pdf-viewer/pdf-viewer.template.html","../../../projects/kit/components/pdf-viewer/pdf-viewer.options.ts","../../../projects/kit/components/pdf-viewer/pdf-viewer.service.ts","../../../projects/kit/components/pdf-viewer/pdf-viewer.directive.ts","../../../projects/kit/components/pdf-viewer/taiga-ui-kit-components-pdf-viewer.ts"],"sourcesContent":["import {AsyncPipe} from '@angular/common';\nimport {ChangeDetectionStrategy, Component, inject} from '@angular/core';\nimport type {TuiPopover} from '@taiga-ui/cdk/services';\nimport {tuiFadeIn, tuiSlideInTop} from '@taiga-ui/core/animations';\nimport {TuiButton} from '@taiga-ui/core/components/button';\nimport {\n TUI_ANIMATIONS_SPEED,\n TUI_CLOSE_WORD,\n TUI_COMMON_ICONS,\n} from '@taiga-ui/core/tokens';\nimport {tuiToAnimationOptions} from '@taiga-ui/core/utils/miscellaneous';\nimport {\n injectContext,\n PolymorpheusOutlet,\n PolymorpheusTemplate,\n} from '@taiga-ui/polymorpheus';\n\nimport type {TuiPdfViewerOptions} from './pdf-viewer.options';\n\n@Component({\n standalone: true,\n selector: 'tui-pdf-viewer',\n imports: [AsyncPipe, PolymorpheusOutlet, PolymorpheusTemplate, TuiButton],\n templateUrl: './pdf-viewer.template.html',\n styleUrls: ['./pdf-viewer.style.less'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n animations: [tuiSlideInTop, tuiFadeIn],\n host: {\n '[@tuiFadeIn]': 'options',\n '[@tuiSlideInTop]': 'options',\n '(document:keydown.esc)': 'onKeyDownEsc()',\n },\n})\nexport class TuiPdfViewerComponent<I, O> {\n protected readonly options = tuiToAnimationOptions(inject(TUI_ANIMATIONS_SPEED));\n protected readonly closeWord$ = inject(TUI_CLOSE_WORD);\n protected readonly icons = inject(TUI_COMMON_ICONS);\n protected readonly context = injectContext<TuiPopover<TuiPdfViewerOptions<I>, O>>();\n\n protected onKeyDownEsc(): void {\n this.context.$implicit.complete();\n }\n}\n","<header class=\"t-header\">\n <h2\n automation-id=\"tui-pdf-viewer__label\"\n class=\"t-title\"\n >\n {{ context.label }}\n </h2>\n <div class=\"t-actions\">\n <ng-container *polymorpheusOutlet=\"context.actions as text; context: context\">\n {{ text }}\n </ng-container>\n </div>\n <button\n appearance=\"\"\n size=\"s\"\n tuiIconButton\n type=\"button\"\n class=\"t-close\"\n [iconStart]=\"icons.close\"\n [style.border-radius.%]=\"100\"\n (click)=\"context.$implicit.complete()\"\n >\n {{ closeWord$ | async }}\n </button>\n</header>\n<section class=\"t-content\">\n <iframe\n *polymorpheusOutlet=\"context.content as content; context: context\"\n title=\"pdf\"\n class=\"t-iframe\"\n [src]=\"content\"\n ></iframe>\n</section>\n","import type {Provider} from '@angular/core';\nimport {tuiCreateToken, tuiProvideOptions} from '@taiga-ui/cdk/utils/miscellaneous';\nimport type {PolymorpheusContent} from '@taiga-ui/polymorpheus';\n\nexport const TUI_PDF_VIEWER_DEFAULT_OPTIONS: TuiPdfViewerOptions = {\n label: '',\n actions: '',\n data: undefined,\n};\n\n/**\n * Default parameters for PdfViewer component\n */\nexport const TUI_PDF_VIEWER_OPTIONS = tuiCreateToken(TUI_PDF_VIEWER_DEFAULT_OPTIONS);\n\nexport function tuiPdfViewerOptionsProvider(\n options: Partial<TuiPdfViewerOptions>,\n): Provider {\n return tuiProvideOptions(\n TUI_PDF_VIEWER_OPTIONS,\n options,\n TUI_PDF_VIEWER_DEFAULT_OPTIONS,\n );\n}\n\nexport interface TuiPdfViewerOptions<I = undefined> {\n readonly actions: PolymorpheusContent<TuiPdfViewerOptions<I>>;\n readonly data: I;\n readonly label: string;\n}\n","import {inject, Injectable} from '@angular/core';\nimport type {SafeResourceUrl} from '@angular/platform-browser';\nimport type {TuiPopoverContext} from '@taiga-ui/cdk/services';\nimport {TuiPopoverService} from '@taiga-ui/cdk/services';\nimport {TUI_DIALOGS} from '@taiga-ui/core/components/dialog';\nimport type {PolymorpheusContent} from '@taiga-ui/polymorpheus';\nimport type {Observable} from 'rxjs';\n\nimport {TuiPdfViewerComponent} from './pdf-viewer.component';\nimport type {TuiPdfViewerOptions} from './pdf-viewer.options';\nimport {TUI_PDF_VIEWER_OPTIONS} from './pdf-viewer.options';\n\ntype Content<G> = PolymorpheusContent<\n TuiPdfViewerOptions<unknown> & TuiPopoverContext<G>\n>;\n\n@Injectable({\n providedIn: 'root',\n useFactory: () =>\n new TuiPdfViewerService(\n TUI_DIALOGS,\n TuiPdfViewerComponent,\n inject(TUI_PDF_VIEWER_OPTIONS),\n ),\n})\nexport class TuiPdfViewerService extends TuiPopoverService<TuiPdfViewerOptions<unknown>> {\n public override open<G>(\n content: Content<G> | SafeResourceUrl,\n options: Partial<TuiPdfViewerOptions<any>> = {},\n ): Observable<G> {\n return super.open(content as Content<G>, options);\n }\n}\n","import {Directive} from '@angular/core';\nimport {TuiPopoverDirective} from '@taiga-ui/cdk/directives/popover';\nimport {tuiAsPopover} from '@taiga-ui/cdk/services';\n\nimport type {TuiPdfViewerOptions} from './pdf-viewer.options';\nimport {TuiPdfViewerService} from './pdf-viewer.service';\n\n@Directive({\n standalone: true,\n selector: 'ng-template[tuiPdfViewer]',\n inputs: ['options: tuiPdfViewerOptions', 'open: tuiPdfViewer'],\n outputs: ['openChange: tuiPdfViewerChange'],\n providers: [tuiAsPopover(TuiPdfViewerService)],\n})\nexport class TuiPdfViewerDirective<T> extends TuiPopoverDirective<\n TuiPdfViewerOptions<T>\n> {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;AAmBA,MAca,qBAAqB,CAAA;AAdlC,IAAA,WAAA,GAAA;QAeuB,IAAO,CAAA,OAAA,GAAG,qBAAqB,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAC9D,QAAA,IAAA,CAAA,U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