UNPKG

@deepkit/desktop-ui

Version:

Library for desktop UI widgets in Angular 10+

976 lines (968 loc) 39.8 MB
import * as i0 from '@angular/core'; import { EventEmitter, ElementRef, HostListener, Input, Directive, ChangeDetectorRef, ApplicationRef, Injectable, QueryList, ContentChildren, Output, forwardRef, EmbeddedViewRef, TemplateRef, ViewContainerRef, Component, InjectionToken, Pipe, ɵNG_COMP_DEF as _NG_COMP_DEF, inject, NgModule, Injector, HostBinding, Renderer2, RendererFactory2, Inject, Optional, ContentChild, SkipSelf, ChangeDetectionStrategy, NgZone, ViewChild, ComponentRef, ComponentFactoryResolver, ViewChildren } from '@angular/core'; import * as i2 from '@angular/forms'; import { NgControl, FormGroup, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { nextTick, arrayRemoveItem, arrayHasItem, humanBytes, getClassName, throttleTime, __ΩTypeAnnotation as ___TypeAnnotation, __ΩClassType as ___ClassType, getClassTypeFromInstance, getPathValue, setPathValue, clearTick, isArray, isNumber, arrayClear, eachPair, empty, first, indexOf } from '@deepkit/core'; import { Observable, Subscription, BehaviorSubject, Subject, isObservable } from 'rxjs'; import * as i1$1 from '@angular/common'; import { DOCUMENT, CommonModule, DatePipe } from '@angular/common'; import * as i3 from '@angular/router'; import { Router, ResolveEnd, NavigationEnd, ActivationEnd, UrlTree, ActivatedRoute } from '@angular/router'; import * as i1 from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser'; import { EventDispatcher, EventToken } from '@deepkit/event'; import { ReflectionClass, ReflectionKind, __ΩExcluded as ___Excluded, resolveTypeMembers, typeAnnotation, Serializer, deserialize, serialize } from '@deepkit/type'; import onChange from 'on-change'; import { TemplatePortal, ComponentPortal, DomPortalHost } from '@angular/cdk/portal'; import * as i1$2 from '@angular/cdk/overlay'; import { OverlayRef, Overlay, OverlayModule } from '@angular/cdk/overlay'; import * as i5 from '@angular/cdk/scrolling'; import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling'; import { ProgressTracker } from '@deepkit/core-rxjs'; /* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ /** * @reflection never */ const electron = 'undefined' === typeof window ? undefined : window.electron || (window.require ? window.require('electron') : undefined); async function getHammer() { if ('undefined' === typeof window) return; //@ts-ignore const hammer = await import('hammerjs'); return hammer.default; } class Electron { static getRemote() { if (!electron) { throw new Error('No Electron available.'); } return electron.remote; } static getIpc() { if (!electron) { throw new Error('No Electron available.'); } return electron.ipcRenderer; } static isAvailable() { return !!electron; } static getRemoteOrUndefined() { return electron ? electron.remote : undefined; } static getProcess() { return Electron.getRemote().process; } } class AsyncEventEmitter extends EventEmitter { emit(value) { super.emit(value); } subscribe(generatorOrNext, error, complete) { return super.subscribe(generatorOrNext, error, complete); } } class ExecutionState { constructor(cd, func) { this.cd = cd; this.func = func; this.running = false; this.error = ''; } async execute(...args) { if (this.running) { throw new Error('Executor still running'); } this.running = true; this.error = ''; this.cd.detectChanges(); try { return await this.func(...args); } catch (error) { this.error = error.message || error.toString(); throw error; } finally { this.running = false; this.cd.detectChanges(); } } } /** * Checks if `target` is children of `parent` or if `target` is `parent`. */ function isTargetChildOf(target, parent) { if (!target) return false; if (target === parent) return true; if (target instanceof HTMLElement) { let targetElement = target; while (targetElement.parentElement) { if (targetElement.parentElement === parent) { return true; } targetElement = targetElement.parentElement; } } return false; } function isMacOs() { if ('undefined' === typeof navigator) return false; return navigator.platform.indexOf('Mac') > -1; } function isWindows() { if ('undefined' === typeof navigator) return false; return navigator.platform.indexOf('Win') > -1; } /** * Checks if `target` is children of `parent` or if `target` is `parent`. */ function findParentWithClass(start, className) { let current = start; do { if (current.classList.contains(className)) return current; current = current.parentElement; } while (current); return undefined; } function triggerResize() { if ('undefined' === typeof window) return; nextTick(() => { window.dispatchEvent(new Event('resize')); }); } function focusWatcher(target, allowedFocuses = [], customChecker) { if (target.ownerDocument.body.tabIndex === -1) target.ownerDocument.body.tabIndex = 1; return (Observable.Ω = [undefined], new Observable((observer) => { let currentlyFocused = target; function isFocusAllowed() { if (!currentlyFocused) { return false; } if (isTargetChildOf(currentlyFocused, target)) { return true; } for (const focus of allowedFocuses) { if (isTargetChildOf(currentlyFocused, focus)) { return true; } } return customChecker ? customChecker(currentlyFocused) : false; } function check() { if (!currentlyFocused) { //shouldn't be possible to have no element at all with focus. //this means usually that the item that had previously focus was deleted. currentlyFocused = target; } if (!isFocusAllowed()) { observer.next(); observer.complete(); } } function onFocusOut() { currentlyFocused = null; check(); } function onFocusIn(event) { currentlyFocused = event.target; check(); } function onMouseDown(event) { currentlyFocused = event.target; check(); } target.ownerDocument.addEventListener('mousedown', onMouseDown, true); target.ownerDocument.addEventListener('focusin', onFocusIn); target.ownerDocument.addEventListener('focusout', onFocusOut); function unsubscribe() { target.ownerDocument.removeEventListener('mousedown', onMouseDown); target.ownerDocument.removeEventListener('focusin', onFocusIn); target.ownerDocument.removeEventListener('focusout', onFocusOut); } return { unsubscribe: unsubscribe }; })); } focusWatcher.__type = ['target', 'allowedFocuses', () => [], 'customChecker', () => Observable, 'focusWatcher', 'P!2!!F2">#"2$8P$7%/&']; function isRouteActive(route) { if (!route.router) return false; if ('string' === typeof route.routerLink) { return route.router.isActive(route.routerLink, route.routerLinkExact === true); } else if (Array.isArray(route.routerLink)) { return route.router.isActive(route.router.createUrlTree(route.routerLink, { queryParams: route.queryParams, relativeTo: route.activatedRoute, }), route.routerLinkExact === true); } else { return route.router.isActive(route.routerLink, route.routerLinkExact === true); } } function redirectScrollableParentsToWindowResize(node, passive = true) { const parents = getScrollableParents(node); function redirect() { window.dispatchEvent(new Event('resize')); } for (const parent of parents) { parent.addEventListener('scroll', redirect, { passive }); } return () => { for (const parent of parents) { parent.removeEventListener('scroll', redirect); } }; } function getScrollableParents(node) { const scrollableParents = []; let parent = node.parentNode; while (parent) { if (!(parent instanceof Element)) { parent = parent.parentNode; continue; } const computedStyle = window.getComputedStyle(parent); const overflow = computedStyle.getPropertyValue('overflow'); if (overflow === 'overlay' || overflow === 'scroll' || overflow === 'auto') { scrollableParents.push(parent); } parent = parent.parentNode; } return scrollableParents; } function trackByIndex(index) { return index; } /* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ class OpenExternalDirective { constructor(element) { this.element = element; this.openExternal = ''; this.href = ''; // this.element.nativeElement.href = '#'; } ngOnChanges() { // this.element.nativeElement.href = this.getLink(); if (this.element.nativeElement instanceof HTMLAnchorElement) { this.element.nativeElement.setAttribute('href', this.getLink()); } } getLink() { return this.openExternal || this.href; } onClick(event) { event.stopPropagation(); event.preventDefault(); if (Electron.isAvailable()) { event.preventDefault(); Electron.getRemote().shell.openExternal(this.getLink()); } else { window.open(this.getLink(), '_blank'); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: OpenExternalDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: OpenExternalDirective, isStandalone: false, selector: "[openExternal], a[href]", inputs: { openExternal: "openExternal", href: "href" }, host: { listeners: { "click": "onClick($event)" } }, usesOnChanges: true, ngImport: i0 }); } static { this.__type = ['openExternal', function () { return ''; }, 'href', function () { return ''; }, () => ElementRef, 'element', 'constructor', 'ngOnChanges', 'getLink', 'event', 'onClick', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: OpenExternalDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: OpenExternalDirective, isStandalone: false, selector: "[openExternal], a[href]", inputs: { openExternal: "openExternal", href: "href" }, host: { listeners: { "click": "onClick($event)" } }, usesOnChanges: true, ngImport: i0 }); }, 'OnChanges', 'OpenExternalDirective', '&3!>"&3#>$PP7%2&;"0\'P$0(P"0)P!2*"0+!3,s>-!3.s>/5"w0x"w1']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: OpenExternalDirective, decorators: [{ type: Directive, args: [{ selector: '[openExternal], a[href]', standalone: false, }] }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { openExternal: [{ type: Input, args: ['openExternal'] }], href: [{ type: Input, args: ['href'] }], onClick: [{ type: HostListener, args: ['click', ['$event']] }] } }); let lastScheduleResize; function scheduleWindowResizeEvent() { if (lastScheduleResize) cancelAnimationFrame(lastScheduleResize); lastScheduleResize = nextTick(() => { window.dispatchEvent(new Event('resize')); lastScheduleResize = undefined; }); } scheduleWindowResizeEvent.__type = ['scheduleWindowResizeEvent', 'P"/!']; let lastFrameRequest; let lastFrameRequestStack = (Set.Ω = [[() => ChangeDetectorRef, 'P7!']], new Set()); let lastFrameRequestStackDoneCb = []; class ZonelessChangeDetector { static { this.app = undefined; } static getApp() { if (!ZonelessChangeDetector.app) { throw new Error('ZonelessChangeDetector.app not set yet'); } return ZonelessChangeDetector.app; } static { this.__type = [() => ApplicationRef, 'app', function () { return undefined; }, 'getApp', 'ZonelessChangeDetector', 'PP7!-J3"s>#P"0$s5w%']; } } /** * This handy function makes sure that in the next animation frame the given ChangeDetectorRef is called. * It makes automatically sure that it is only called once per frame. */ function detectChangesNextFrame(cd, done) { if (cd) { if (lastFrameRequestStack.has(cd)) return; lastFrameRequestStack.add(cd); if (done) lastFrameRequestStackDoneCb.push(done); } if (lastFrameRequest) { return; } lastFrameRequest = nextTick(() => { lastFrameRequest = undefined; for (const i of lastFrameRequestStack) { i.detectChanges(); } for (const i of lastFrameRequestStackDoneCb) { i(); } //since ivy we have to use tick() and can not use i.detectChanges(). lastFrameRequestStackDoneCb = []; lastFrameRequestStack.clear(); ZonelessChangeDetector.getApp().tick(); }); } detectChangesNextFrame.__type = [() => ChangeDetectorRef, 'cd', '', 'done', 'detectChangesNextFrame', 'PP7!2"8P"/#2$8"/%']; /* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ class WindowMenuState { constructor() { this.menus = []; this.focused = true; this.subscriptions = (Map.Ω = [[() => MenuDirective, 'P7!'], [() => Subscription, 'P7!']], new Map()); } addMenu(menu) { this.menus.push(menu); this.subscriptions.set(menu, menu.change.subscribe(() => { this.build(); })); this.build(); } removeMenu(menu) { this.subscriptions.get(menu).unsubscribe(); this.subscriptions.delete(menu); arrayRemoveItem(this.menus, menu); this.build(); } build() { nextTick(() => { this._build(); }); } _build() { const template = []; //todo, merge menus with same id(), id falls back to role+label // then we can use fileMenu in sub views and add sub menu items as we want for (const menu of this.menus) { if (menu.validOs()) { template.push(menu.buildTemplate()); } } if (!template.length) { template.push(...[ { role: 'appMenu' }, { role: 'fileMenu' }, { role: 'editMenu' }, { role: 'viewMenu' }, { role: 'windowMenu' }, ]); } if (Electron.isAvailable()) { const remote = Electron.getRemote(); if (remote) { try { const menu = remote.Menu.buildFromTemplate(template); remote.Menu.setApplicationMenu(menu); } catch (error) { console.error('Could not buildFromTemplate', template); console.error(error); } } else { console.warn('Not in electron environment'); } } } focus() { //set our electron menu //Menu.setApplicationMenu() this.build(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowMenuState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowMenuState }); } static { this.__type = [() => MenuDirective, 'menus', function () { return []; }, 'focused', function () { return true; }, 'subscriptions', function () { return (Map.Ω = [[() => MenuDirective, 'P7!'], [() => Subscription, 'P7!']], new Map()); }, () => MenuDirective, 'menu', 'addMenu', () => MenuDirective, 'removeMenu', 'build', '_build', 'focus', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowMenuState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }, '\u0275prov', function () { return i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowMenuState }); }, 'WindowMenuState', 'P7!F3">#)3$>%!3&>\'PP7(2)"0*PP7+2)"0,P"0-P"0.<P"0/!30s>1!32s>35w4']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowMenuState, decorators: [{ type: Injectable }] }); function __assignType$l(fn, args) { fn.__type = args; return fn; } class MenuBase { constructor() { this.enabled = true; this.visible = true; this.onlyMacOs = false; this.noMacOs = false; this.click = new EventEmitter(); this.change = new EventEmitter; this.type = ''; this.registered = (Set.Ω = [[() => MenuBase, 'P7!']], new Set()); this.subscriptions = (Map.Ω = [[() => MenuBase, 'P7!'], [() => Subscription, 'P7!']], new Map()); } buildTemplate() { const submenu = []; if (this.child) { for (const item of this.child.toArray()) { if (item === this) continue; if (!item.validOs()) { continue; } submenu.push(item.buildTemplate()); } } const result = { click: () => { this.click.emit(); }, }; if (this.label) result['label'] = this.label; if (this.sublabel) result['sublabel'] = this.sublabel; if (!this.enabled) result['enabled'] = false; if (this.type) result['type'] = this.type; if (this.accelerator) result['accelerator'] = this.accelerator; if (this.role) result['role'] = this.role; if (this.type) result['type'] = this.type; if (this.accelerator) result['accelerator'] = this.accelerator; if (submenu.length) result['submenu'] = submenu; return result; } validOs() { if (Electron.isAvailable()) { if (this.onlyMacOs !== false && Electron.getProcess().platform !== 'darwin') { return false; } if (this.noMacOs !== false && Electron.getProcess().platform === 'darwin') { return false; } } return true; } ngAfterViewInit() { if (this.child) { this.child.changes.subscribe(__assignType$l((items) => { for (const item of items) { if (!this.registered.has(item)) { this.registered.add(item); this.subscriptions.set(item, item.change.subscribe(() => { this.change.emit(); })); } } for (const item of this.registered) { if (!arrayHasItem(items, item)) { //got removed this.registered.delete(item); this.subscriptions.get(item).unsubscribe(); this.subscriptions.delete(item); } } this.change.emit(); }, [() => MenuBase, 'items', '', 'PP7!F2""/#'])); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuBase, isStandalone: true, inputs: { label: "label", sublabel: "sublabel", icon: "icon", enabled: "enabled", accelerator: "accelerator", role: "role", visible: "visible", onlyMacOs: "onlyMacOs", noMacOs: "noMacOs", id: "id", before: "before", after: "after", beforeGroupContaining: "beforeGroupContaining", afterGroupContaining: "afterGroupContaining" }, outputs: { click: "click", change: "change" }, queries: [{ propertyName: "child", predicate: MenuBase }], ngImport: i0 }); } static { this.__type = ['label', 'sublabel', 'icon', 'enabled', function () { return true; }, 'accelerator', 'role', 'visible', function () { return true; }, "", 'onlyMacOs', function () { return false; }, "", 'noMacOs', function () { return false; }, 'id', 'before', 'after', 'beforeGroupContaining', 'afterGroupContaining', 'click', function () { return new EventEmitter(); }, 'change', function () { return new EventEmitter; }, 'type', function () { return ''; }, 'registered', function () { return (Set.Ω = [[() => MenuBase, 'P7!']], new Set()); }, 'subscriptions', function () { return (Map.Ω = [[() => MenuBase, 'P7!'], [() => Subscription, 'P7!']], new Map()); }, () => MenuBase, () => QueryList, 'child', 'constructor', 'buildTemplate', 'validOs', 'ngAfterViewInit', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuBase, isStandalone: true, inputs: { label: "label", sublabel: "sublabel", icon: "icon", enabled: "enabled", accelerator: "accelerator", role: "role", visible: "visible", onlyMacOs: "onlyMacOs", noMacOs: "noMacOs", id: "id", before: "before", after: "after", beforeGroupContaining: "beforeGroupContaining", afterGroupContaining: "afterGroupContaining" }, outputs: { click: "click", change: "change" }, queries: [{ propertyName: "child", predicate: MenuBase }], ngImport: i0 }); }, 'AfterViewInit', 'MenuBase', '&3!8&3"8&3#8)3$>%&3&8&3\'8)3(>)P).*J3+>,P).-J3.>/&308&318&328&338&348!35>6!37>8&39>:!3;<><!3=<>>PP7?7@3A8P"0BP"0CP)0DP"0E!3Fs>G!3Hs>I5"wJx"wK']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuBase, decorators: [{ type: Directive }], ctorParameters: () => [], propDecorators: { label: [{ type: Input }], sublabel: [{ type: Input }], icon: [{ type: Input }], enabled: [{ type: Input }], accelerator: [{ type: Input }], role: [{ type: Input }], visible: [{ type: Input }], onlyMacOs: [{ type: Input }], noMacOs: [{ type: Input }], id: [{ type: Input }], before: [{ type: Input }], after: [{ type: Input }], beforeGroupContaining: [{ type: Input }], afterGroupContaining: [{ type: Input }], click: [{ type: Output }], change: [{ type: Output }], child: [{ type: ContentChildren, args: [MenuBase] }] } }); class MenuItemDirective extends MenuBase { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuItemDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuItemDirective, isStandalone: false, selector: "dui-menu-item", providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuItemDirective) }], usesInheritance: true, ngImport: i0 }); } static { this.__type = [() => MenuBase, '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuItemDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuItemDirective, isStandalone: false, selector: "dui-menu-item", providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuItemDirective) }], usesInheritance: true, ngImport: i0 }); }, 'MenuItemDirective', 'P7!!3"s>#!3$s>%5w&']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuItemDirective, decorators: [{ type: Directive, args: [{ selector: 'dui-menu-item', standalone: false, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuItemDirective) }] }] }] }); class MenuCheckboxDirective extends MenuBase { constructor() { super(...arguments); this.checked = false; this.type = 'checkbox'; } buildTemplate() { return { ...super.buildTemplate(), checked: this.checked }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuCheckboxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuCheckboxDirective, isStandalone: false, selector: "dui-menu-checkbox", inputs: { checked: "checked" }, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuCheckboxDirective) }], usesInheritance: true, ngImport: i0 }); } static { this.__type = [() => MenuBase, 'checked', function () { return false; }, 'type', function () { return 'checkbox'; }, 'buildTemplate', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuCheckboxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuCheckboxDirective, isStandalone: false, selector: "dui-menu-checkbox", inputs: { checked: "checked" }, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuCheckboxDirective) }], usesInheritance: true, ngImport: i0 }); }, 'MenuCheckboxDirective', 'P7!)3">#&3$>%P"0&!3\'s>(!3)s>*5w+']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuCheckboxDirective, decorators: [{ type: Directive, args: [{ selector: 'dui-menu-checkbox', standalone: false, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuCheckboxDirective) }] }] }], propDecorators: { checked: [{ type: Input }] } }); class MenuRadioDirective extends MenuBase { constructor() { super(...arguments); this.checked = false; this.type = 'radio'; } buildTemplate() { return { ...super.buildTemplate(), checked: this.checked }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuRadioDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuRadioDirective, isStandalone: false, selector: "dui-menu-radio", inputs: { checked: "checked" }, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuRadioDirective) }], usesInheritance: true, ngImport: i0 }); } static { this.__type = [() => MenuBase, 'checked', function () { return false; }, 'type', function () { return 'radio'; }, 'buildTemplate', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuRadioDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuRadioDirective, isStandalone: false, selector: "dui-menu-radio", inputs: { checked: "checked" }, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuRadioDirective) }], usesInheritance: true, ngImport: i0 }); }, 'MenuRadioDirective', 'P7!)3">#&3$>%P"0&!3\'s>(!3)s>*5w+']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuRadioDirective, decorators: [{ type: Directive, args: [{ selector: 'dui-menu-radio', standalone: false, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuRadioDirective) }] }] }], propDecorators: { checked: [{ type: Input }] } }); class MenuSeparatorDirective extends MenuBase { constructor() { super(...arguments); this.type = 'separator'; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuSeparatorDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuSeparatorDirective, isStandalone: false, selector: "dui-menu-separator", providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuSeparatorDirective) }], usesInheritance: true, ngImport: i0 }); } static { this.__type = [() => MenuBase, 'type', function () { return 'separator'; }, '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuSeparatorDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuSeparatorDirective, isStandalone: false, selector: "dui-menu-separator", providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuSeparatorDirective) }], usesInheritance: true, ngImport: i0 }); }, 'MenuSeparatorDirective', 'P7!&3">#!3$s>%!3&s>\'5w(']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuSeparatorDirective, decorators: [{ type: Directive, args: [{ selector: 'dui-menu-separator', standalone: false, providers: [{ provide: MenuBase, useExisting: forwardRef(() => MenuSeparatorDirective) }] }] }] }); class MenuDirective extends MenuBase { constructor(windowMenuState) { super(); this.windowMenuState = windowMenuState; this.position = 0; } ngAfterViewInit() { super.ngAfterViewInit(); this.windowMenuState.addMenu(this); } ngOnDestroy() { this.windowMenuState.removeMenu(this); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuDirective, deps: [{ token: WindowMenuState }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuDirective, isStandalone: false, selector: "dui-menu", inputs: { position: "position" }, usesInheritance: true, ngImport: i0 }); } static { this.__type = [() => MenuBase, 'position', function () { return 0; }, () => WindowMenuState, 'windowMenuState', 'constructor', 'ngAfterViewInit', 'ngOnDestroy', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuDirective, deps: [{ token: WindowMenuState }], target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: MenuDirective, isStandalone: false, selector: "dui-menu", inputs: { position: "position" }, usesInheritance: true, ngImport: i0 }); }, 'OnDestroy', 'AfterViewInit', 'MenuDirective', 'P7!\'3">#PP7$2%<"0&P"0\'P"0(!3)s>*!3+s>,5"w-"w.x#w/']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: MenuDirective, decorators: [{ type: Directive, args: [{ selector: 'dui-menu', standalone: false, }] }], ctorParameters: () => [{ type: WindowMenuState }], propDecorators: { position: [{ type: Input }] } }); function __assignType$k(fn, args) { fn.__type = args; return fn; } let i = 0; let currentViewDirective; class ViewState { constructor() { this.id = i++; this.viewDirective = currentViewDirective; } get attached() { return this.viewDirective ? this.viewDirective.isVisible() : true; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewState }); } static { this.__type = ['id', function () { return i++; }, () => ViewDirective, 'viewDirective', function () { return currentViewDirective; }, '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewState, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }, '\u0275prov', function () { return i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewState }); }, 'ViewState', '!3!>"P7#3$8>%!!3&s>\'!3(s>)5w*']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewState, decorators: [{ type: Injectable }] }); class ViewDirective { constructor(template, viewContainer) { this.template = template; this.viewContainer = viewContainer; this.visible = false; this.parentViewDirective = currentViewDirective; } isVisible() { if (this.view) { for (const node of this.view.rootNodes) { if (node.style && node.offsetParent !== null) { return true; } } return false; } return this.visible; } set duiView(v) { if (this.visible === v) return; this.visible = v; if (this.visible) { if (this.view) { this.view.rootNodes.map(__assignType$k(element => { if (element.style) { element.style.display = ''; } }, ['element', '', 'P"2!"/"'])); this.view.reattach(); this.view.markForCheck(); scheduleWindowResizeEvent(); return; } const old = currentViewDirective; currentViewDirective = this; this.view = this.viewContainer.createEmbeddedView(this.template); currentViewDirective = old; } else { if (this.view) { this.view.rootNodes.map(__assignType$k(element => { if (element.style) { element.style.display = 'none'; } }, ['element', '', 'P"2!"/"'])); //let the last change detection run so ViewState have correct state this.view.detectChanges(); this.view.detach(); this.view.markForCheck(); detectChangesNextFrame(this.view); } } } ngOnDestroy() { if (this.view) { this.view.destroy(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: ViewDirective, isStandalone: false, selector: "[duiView]", inputs: { duiView: "duiView" }, providers: [{ provide: ViewState, useClass: ViewState }], ngImport: i0 }); } static { this.__type = [() => EmbeddedViewRef, 'view', 'visible', function () { return false; }, () => ViewDirective, 'parentViewDirective', () => TemplateRef, 'template', () => ViewContainerRef, 'viewContainer', 'constructor', 'isVisible', 'ngOnDestroy', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: ViewDirective, isStandalone: false, selector: "[duiView]", inputs: { duiView: "duiView" }, providers: [{ provide: ViewState, useClass: ViewState }], ngImport: i0 }); }, 'OnDestroy', 'ViewDirective', 'P"7!3"8<)3#<>$PP7%-J3&9PP"7\'2(<P7)2*<"0+P"0,!P"0-!3.s>/!30s>15"w2x"w3']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: ViewDirective, decorators: [{ type: Directive, args: [{ selector: '[duiView]', standalone: false, providers: [{ provide: ViewState, useClass: ViewState }] }] }], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }], propDecorators: { duiView: [{ type: Input }] } }); /* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ class CdCounterComponent { constructor() { this.i = 0; } get counter() { this.i++; return this.i; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: CdCounterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.6", type: CdCounterComponent, isStandalone: false, selector: "dui-cd-counter", inputs: { name: "name" }, ngImport: i0, template: `{{counter}}`, isInline: true }); } static { this.__type = ['i', function () { return 0; }, 'name', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: CdCounterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }, '\u0275cmp', function () { return i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.6", type: CdCounterComponent, isStandalone: false, selector: "dui-cd-counter", inputs: { name: "name" }, ngImport: i0, template: `{{counter}}`, isInline: true }); }, 'CdCounterComponent', '\'3!;>"&3#8!!3$s>%!3&s>\'5w(']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: CdCounterComponent, decorators: [{ type: Component, args: [{ selector: 'dui-cd-counter', standalone: false, template: `{{counter}}` }] }], propDecorators: { name: [{ type: Input }] } }); /* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ class DuiResponsiveDirective { constructor(element) { this.element = element; this.clazz = {}; this.duiClassMin = {}; } ngOnInit() { this.onResize(); } onResize() { if (this.lastRequest) { cancelAnimationFrame(this.lastRequest); } this.lastRequest = nextTick(() => { const element = this.element.nativeElement; for (const [name, number] of Object.entries(this.duiClassMin)) { const valid = element.offsetWidth > number; if (this.clazz[name] !== valid) { this.clazz[name] = valid; if (valid) { element.classList.add(name); } else { element.classList.remove(name); } } } }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: DuiResponsiveDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: DuiResponsiveDirective, isStandalone: false, selector: "[duiClassMin]", inputs: { duiClassMin: "duiClassMin" }, host: { listeners: { "window:resize": "onResize()" } }, ngImport: i0 }); } static { this.__type = ['clazz', function () { return {}; }, 'lastRequest', 'duiClassMin', function () { return {}; }, () => ElementRef, 'element', 'constructor', 'ngOnInit', 'onResize', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: DuiResponsiveDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }, '\u0275dir', function () { return i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: DuiResponsiveDirective, isStandalone: false, selector: "[duiClassMin]", inputs: { duiClassMin: "duiClassMin" }, host: { listeners: { "window:resize": "onResize()" } }, ngImport: i0 }); }, 'OnInit', 'DuiResponsiveDirective', 'P&)LM3!>""3#<P&\'LM3$>%PP7&2\';"0(P"0)P"0*!3+s>,!3-s>.5"w/x"w0']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: DuiResponsiveDirective, decorators: [{ type: Directive, args: [{ selector: '[duiClassMin]', standalone: false, }] }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { duiClassMin: [{ type: Input }], onResize: [{ type: HostListener, args: ['window:resize'] }] } }); function __assignType$j(fn, args) { fn.__type = args; return fn; } const __ΩWinHeader = ['getBottomPosition', 'WinHeader', 'PP\'1!Mw"y']; const __ΩWin = ['id', 'electronWindow', 0, 'getClosestNonDialogWindow', () => __ΩWinHeader, 'header', () => ViewContainerRef, 'viewContainerRef', 'Win', 'P\'4!"4"8PPn#-J1$n%4&8P7\'4(Mw)y']; class WindowRegistry { constructor() { this.id = 0; this.registry = (Map.Ω = [[() => __ΩWin, 'n!'], [() => WindowState, 'state', () => WindowMenuState, 'menu', () => ChangeDetectorRef, 'cd', () => ViewContainerRef, 'viewContainerRef', 'PP7!4"P7#4$P7%4&P7\'4(M']], new Map()); this.windowHistory = []; /** * When BrowserWindow of electron is focused. */ this.focused = new BehaviorSubject(false); this.focused.subscribe(__assignType$j((v) => { for (const win of this.registry.values()) { win.state.focus.next(v); } detectChangesNextFrame(); }, ['v', '', 'P"2!"/"'])); } getAllElectronWindows() { return [...this.registry.keys()].filter(__assignType$j(v => !!v.electronWindow, ['v', '', 'P"2!"/"'])).map(__assignType$j(v => v.electronWindow, ['v', '', 'P"2!"/"'])); } register(win, cd, state, menu, viewContainerRef) { this.id++; win.id = this.id; this.registry.set(win, { state, menu, cd, viewContainerRef, }); } /** * Finds the activeWindow and returns its most outer parent. */ getOuterActiveWindow() { if (this.activeWindow) return this.activeWindow.getClosestNonDialogWindow(); } getCurrentViewContainerRef() { if (this.activeWindow) { return this.activeWindow.viewContainerRef; // const reg = this.registry.get(this.activeWindow); // if (reg) { // return reg.viewContainerRef; // } } throw new Error('No active window'); } focus(win) { if (this.activeWindow === win) return; const reg = this.registry.get(win); if (!reg) throw new Error('Window not registered'); this.activeWindow = win; arrayRemoveItem(this.windowHistory, win); this.windowHistory.push(win); reg.state.focus.next(true); reg.menu.focus(); detectChangesNextFrame(); } blur(win) { const reg = this.registry.get(win); if (reg) { reg.state.focus.next(false); } if (this.activeWindow === win) { delete this.activeWindow; } detectChangesNextFrame(); } unregister(win) { const reg = this.registry.get(win); if (reg) { reg.state.focus.next(false); } this.registry.delete(win); arrayRemoveItem(this.windowHistory, win); if (this.windowHistory.length) { this.focus(this.windowHistory[this.windowHistory.length - 1]); } detectChangesNextFrame(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowRegistry }); } static { this.__type = ['id', function () { return 0; }, 'registry', function () { return (Map.Ω = [[() => __ΩWin, 'n!'], [() => WindowState, 'state', () => WindowMenuState, 'menu', () => ChangeDetectorRef, 'cd', () => ViewContainerRef, 'viewContainerRef', 'PP7!4"P7#4$P7%4&P7\'4(M']], new Map()); }, () => __ΩWin, 'windowHistory', function () { return []; }, () => __ΩWin, 'activeWindow', 'focused', function () { return new BehaviorSubject(false); }, 'constructor', 'getAllElectronWindows', () => __ΩWin, 'win', () => ChangeDetectorRef, 'cd', () => WindowState, 'state', () => WindowMenuState, 'menu', () => ViewContainerRef, 'viewContainerRef', 'register', () => __ΩWin, 'getOuterActiveWindow', () => ViewContainerRef, 'getCurrentViewContainerRef', () => __ΩWin, 'focus', () => __ΩWin, 'blur', () => __ΩWin, 'unregister', '\u0275fac', function () { return i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }, '\u0275prov', function () { return i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowRegistry }); }, 'WindowRegistry', '\'3!>"!3#>$n%F3&>\'n(3)8!3*>+P"0,P"F0-Pn.2/P7021P7223P7425P7627"08PPn9-J0:PP7;0<Pn=2/"0>Pn?2/"0@PnA2/"0B!3Cs>D!3Es>F5wG']; } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: WindowRegistry, decorators: [{ type: Injectable }], ctorParameters: () => [] }); const __ΩAlignedButtonGroup = ['', 'sidebarMoved', 'activateOneTimeAnimation', 'AlignedButtonGroup', 'PP$/!4"P$/!4#Mw$y']; class WindowState { constructor() { this.focus = (BehaviorSubject.Ω = [[')']], new BehaviorSubject(false)); this.disableInputs = (BehaviorSubject.Ω = [[')']], new BehaviorSubject(false)); this.toolbars = {}; this.toolbarContainers = {}; this.closable = true; this.maximizable = true; this.minimizable = true; } addToolbarContainer(forName, template) { if (!this.toolbars[forName]) { this.toolbars[forName] = []; } this.toolbars[forName].push(template); if (this.toolbarContainers[forName]) { this.toolbarContainers[forName].toolbarsUpdated(); } } removeToolbarContainer(forName, template) { arrayRemoveItem(this.toolbars[forName], template); if (this.toolbarContainers[forName]) { this.toolbarContainers[forName].toolbarsUpdated(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImpo