Created
October 24, 2016 13:33
-
-
Save dcoblentz/b16e97bc5671a8c31ab65add8c88b041 to your computer and use it in GitHub Desktop.
AOT elements for Polymer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* tslint:disable */ | |
import { | |
Injector, | |
Directive, | |
ElementRef, | |
Renderer, | |
NgZone, | |
Output, | |
Type, | |
KeyValueDiffers, | |
IterableDiffers, | |
} from '@angular/core'; | |
import { | |
ChangeEventsAdapterDirective, | |
NotifyForDiffersDirective, | |
ValidationDirective, | |
FormElementDirective, | |
ReloadConfigurationDirective | |
} from './polymer-directives'; | |
import { NG_VALUE_ACCESSOR } from '@angular/forms'; | |
@Directive({ | |
selector: 'paper-tabs', | |
host: { | |
'(selected-changed)': '_emitChangeEvent("selected", $event)', | |
'(selected-item-changed)': '_emitChangeEvent("selectedItem", $event)', | |
'(items-changed)': '_emitChangeEvent("items", $event)', | |
'(selected-values-changed)': '_emitChangeEvent("selectedValues", $event)', | |
'(selected-items-changed)': '_emitChangeEvent("selectedItems", $event)' | |
} | |
}) | |
export class PaperTabsChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() selectedChange: any; | |
@Output() selectedItemChange: any; | |
@Output() itemsChange: any; | |
@Output() selectedValuesChange: any; | |
@Output() selectedItemsChange: any; | |
constructor() { | |
super(['selectedChange', 'selectedItemChange', 'itemsChange', 'selectedValuesChange', 'selectedItemsChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-tabs', | |
inputs: ['selectedValues','keyEventTarget'], | |
host: { | |
'(selected-values-changed)': '_setValueFromElement("selectedValues", $event)', | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperTabsNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['selectedValues','keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-tabs', | |
}) | |
export class PaperTabsValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperTabsForwardRefFormElement() { | |
return PaperTabsFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-tabs', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperTabsForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperTabsFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-tabs', | |
}) | |
export class PaperTabsReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperTabs = [PaperTabsChangeEventsAdapterDirective,PaperTabsNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-tab', | |
host: { | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)', | |
'(active-changed)': '_emitChangeEvent("active", $event)' | |
} | |
}) | |
export class PaperTabChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
@Output() activeChange: any; | |
constructor() { | |
super(['focusedChange', 'disabledChange', 'activeChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-tab', | |
inputs: ['keyEventTarget'], | |
host: { | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperTabNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-tab', | |
}) | |
export class PaperTabValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperTabForwardRefFormElement() { | |
return PaperTabFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-tab', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperTabForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperTabFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-tab', | |
}) | |
export class PaperTabReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperTab = [PaperTabChangeEventsAdapterDirective,PaperTabNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-input', | |
host: { | |
'(value-changed)': '_emitChangeEvent("value", $event)', | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)', | |
'(invalid-changed)': '_emitChangeEvent("invalid", $event)' | |
} | |
}) | |
export class PaperInputChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() valueChange: any; | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
@Output() invalidChange: any; | |
constructor() { | |
super(['valueChange', 'focusedChange', 'disabledChange', 'valueChange', 'invalidChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-input', | |
inputs: ['keyEventTarget'], | |
host: { | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperInputNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-input', | |
}) | |
export class PaperInputValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperInputForwardRefFormElement() { | |
return PaperInputFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-input', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperInputForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperInputFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-input', | |
}) | |
export class PaperInputReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperInput = [PaperInputChangeEventsAdapterDirective,PaperInputNotifyForDiffersDirective,PaperInputFormElementDirective,PaperInputValidationDirective]; | |
@Directive({ | |
selector: 'paper-input-container', | |
host: { | |
'(focused-changed)': '_emitChangeEvent("focused", $event)' | |
} | |
}) | |
export class PaperInputContainerChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() focusedChange: any; | |
constructor() { | |
super(['focusedChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-input-container', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class PaperInputContainerNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-input-container', | |
}) | |
export class PaperInputContainerValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperInputContainerForwardRefFormElement() { | |
return PaperInputContainerFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-input-container', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperInputContainerForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperInputContainerFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-input-container', | |
}) | |
export class PaperInputContainerReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperInputContainer = [PaperInputContainerChangeEventsAdapterDirective,PaperInputContainerNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-card', | |
host: { | |
} | |
}) | |
export class PaperCardChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
constructor() { | |
super([]); | |
} | |
} | |
@Directive({ | |
selector: 'paper-card', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class PaperCardNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-card', | |
}) | |
export class PaperCardValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperCardForwardRefFormElement() { | |
return PaperCardFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-card', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperCardForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperCardFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-card', | |
}) | |
export class PaperCardReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperCard = [PaperCardChangeEventsAdapterDirective,PaperCardNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-toolbar', | |
host: { | |
} | |
}) | |
export class PaperToolbarChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
constructor() { | |
super([]); | |
} | |
} | |
@Directive({ | |
selector: 'paper-toolbar', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class PaperToolbarNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-toolbar', | |
}) | |
export class PaperToolbarValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperToolbarForwardRefFormElement() { | |
return PaperToolbarFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-toolbar', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperToolbarForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperToolbarFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-toolbar', | |
}) | |
export class PaperToolbarReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperToolbar = [PaperToolbarChangeEventsAdapterDirective,PaperToolbarNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-button', | |
host: { | |
'(active-changed)': '_emitChangeEvent("active", $event)', | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)' | |
} | |
}) | |
export class PaperButtonChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() activeChange: any; | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
constructor() { | |
super(['activeChange', 'focusedChange', 'disabledChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-button', | |
inputs: ['keyEventTarget'], | |
host: { | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperButtonNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-button', | |
}) | |
export class PaperButtonValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperButtonForwardRefFormElement() { | |
return PaperButtonFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-button', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperButtonForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperButtonFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-button', | |
}) | |
export class PaperButtonReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperButton = [PaperButtonChangeEventsAdapterDirective,PaperButtonNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-dropdown-menu', | |
host: { | |
'(active-changed)': '_emitChangeEvent("active", $event)', | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)', | |
'(value-changed)': '_emitChangeEvent("value", $event)', | |
'(invalid-changed)': '_emitChangeEvent("invalid", $event)', | |
'(selected-item-label-changed)': '_emitChangeEvent("selectedItemLabel", $event)', | |
'(selected-item-changed)': '_emitChangeEvent("selectedItem", $event)', | |
'(opened-changed)': '_emitChangeEvent("opened", $event)' | |
} | |
}) | |
export class PaperDropdownMenuChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() activeChange: any; | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
@Output() valueChange: any; | |
@Output() invalidChange: any; | |
@Output() selectedItemLabelChange: any; | |
@Output() selectedItemChange: any; | |
@Output() openedChange: any; | |
constructor() { | |
super(['activeChange', 'focusedChange', 'disabledChange', 'valueChange', 'invalidChange', 'selectedItemLabelChange', 'selectedItemChange', 'valueChange', 'openedChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-dropdown-menu', | |
inputs: ['keyEventTarget'], | |
host: { | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperDropdownMenuNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-dropdown-menu', | |
}) | |
export class PaperDropdownMenuValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperDropdownMenuForwardRefFormElement() { | |
return PaperDropdownMenuFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-dropdown-menu', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperDropdownMenuForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperDropdownMenuFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-dropdown-menu', | |
}) | |
export class PaperDropdownMenuReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperDropdownMenu = [PaperDropdownMenuChangeEventsAdapterDirective,PaperDropdownMenuNotifyForDiffersDirective,PaperDropdownMenuFormElementDirective,PaperDropdownMenuValidationDirective]; | |
@Directive({ | |
selector: 'paper-menu', | |
host: { | |
'(selected-changed)': '_emitChangeEvent("selected", $event)', | |
'(selected-item-changed)': '_emitChangeEvent("selectedItem", $event)', | |
'(items-changed)': '_emitChangeEvent("items", $event)', | |
'(selected-values-changed)': '_emitChangeEvent("selectedValues", $event)', | |
'(selected-items-changed)': '_emitChangeEvent("selectedItems", $event)' | |
} | |
}) | |
export class PaperMenuChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() selectedChange: any; | |
@Output() selectedItemChange: any; | |
@Output() itemsChange: any; | |
@Output() selectedValuesChange: any; | |
@Output() selectedItemsChange: any; | |
constructor() { | |
super(['selectedChange', 'selectedItemChange', 'itemsChange', 'selectedValuesChange', 'selectedItemsChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-menu', | |
inputs: ['selectedValues','keyEventTarget'], | |
host: { | |
'(selected-values-changed)': '_setValueFromElement("selectedValues", $event)', | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperMenuNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['selectedValues','keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-menu', | |
}) | |
export class PaperMenuValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperMenuForwardRefFormElement() { | |
return PaperMenuFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-menu', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperMenuForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperMenuFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-menu', | |
}) | |
export class PaperMenuReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperMenu = [PaperMenuChangeEventsAdapterDirective,PaperMenuNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-submenu', | |
host: { | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)', | |
'(opened-changed)': '_emitChangeEvent("opened", $event)' | |
} | |
}) | |
export class PaperSubmenuChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
@Output() openedChange: any; | |
constructor() { | |
super(['focusedChange', 'disabledChange', 'openedChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-submenu', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class PaperSubmenuNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-submenu', | |
}) | |
export class PaperSubmenuValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperSubmenuForwardRefFormElement() { | |
return PaperSubmenuFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-submenu', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperSubmenuForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperSubmenuFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-submenu', | |
}) | |
export class PaperSubmenuReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperSubmenu = [PaperSubmenuChangeEventsAdapterDirective,PaperSubmenuNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-item', | |
host: { | |
'(active-changed)': '_emitChangeEvent("active", $event)', | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)' | |
} | |
}) | |
export class PaperItemChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() activeChange: any; | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
constructor() { | |
super(['activeChange', 'focusedChange', 'disabledChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-item', | |
inputs: ['keyEventTarget'], | |
host: { | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperItemNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-item', | |
}) | |
export class PaperItemValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperItemForwardRefFormElement() { | |
return PaperItemFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-item', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperItemForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperItemFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-item', | |
}) | |
export class PaperItemReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperItem = [PaperItemChangeEventsAdapterDirective,PaperItemNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-dialog', | |
host: { | |
'(horizontal-offset-changed)': '_emitChangeEvent("horizontalOffset", $event)', | |
'(vertical-offset-changed)': '_emitChangeEvent("verticalOffset", $event)', | |
'(opened-changed)': '_emitChangeEvent("opened", $event)' | |
} | |
}) | |
export class PaperDialogChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() horizontalOffsetChange: any; | |
@Output() verticalOffsetChange: any; | |
@Output() openedChange: any; | |
constructor() { | |
super(['horizontalOffsetChange', 'verticalOffsetChange', 'openedChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-dialog', | |
inputs: ['sizingTarget','fitInto','closingReason','animationConfig'], | |
host: { | |
'(sizing-target-changed)': '_setValueFromElement("sizingTarget", $event)', | |
'(fit-into-changed)': '_setValueFromElement("fitInto", $event)', | |
'(closing-reason-changed)': '_setValueFromElement("closingReason", $event)', | |
'(animation-config-changed)': '_setValueFromElement("animationConfig", $event)' | |
} | |
}) | |
export class PaperDialogNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['sizingTarget','fitInto','closingReason','animationConfig'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-dialog', | |
}) | |
export class PaperDialogValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperDialogForwardRefFormElement() { | |
return PaperDialogFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-dialog', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperDialogForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperDialogFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-dialog', | |
}) | |
export class PaperDialogReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperDialog = [PaperDialogChangeEventsAdapterDirective,PaperDialogNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'paper-icon-button', | |
host: { | |
'(active-changed)': '_emitChangeEvent("active", $event)', | |
'(focused-changed)': '_emitChangeEvent("focused", $event)', | |
'(disabled-changed)': '_emitChangeEvent("disabled", $event)' | |
} | |
}) | |
export class PaperIconButtonChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() activeChange: any; | |
@Output() focusedChange: any; | |
@Output() disabledChange: any; | |
constructor() { | |
super(['activeChange', 'focusedChange', 'disabledChange']); | |
} | |
} | |
@Directive({ | |
selector: 'paper-icon-button', | |
inputs: ['keyEventTarget'], | |
host: { | |
'(key-event-target-changed)': '_setValueFromElement("keyEventTarget", $event)' | |
} | |
}) | |
export class PaperIconButtonNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['keyEventTarget'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-icon-button', | |
}) | |
export class PaperIconButtonValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function PaperIconButtonForwardRefFormElement() { | |
return PaperIconButtonFormElementDirective; | |
} | |
@Directive({ | |
selector: 'paper-icon-button', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: PaperIconButtonForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class PaperIconButtonFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'paper-icon-button', | |
}) | |
export class PaperIconButtonReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const PaperIconButton = [PaperIconButtonChangeEventsAdapterDirective,PaperIconButtonNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'app-drawer-layout', | |
host: { | |
'(narrow-changed)': '_emitChangeEvent("narrow", $event)' | |
} | |
}) | |
export class AppDrawerLayoutChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() narrowChange: any; | |
constructor() { | |
super(['narrowChange']); | |
} | |
} | |
@Directive({ | |
selector: 'app-drawer-layout', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class AppDrawerLayoutNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-drawer-layout', | |
}) | |
export class AppDrawerLayoutValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function AppDrawerLayoutForwardRefFormElement() { | |
return AppDrawerLayoutFormElementDirective; | |
} | |
@Directive({ | |
selector: 'app-drawer-layout', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: AppDrawerLayoutForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class AppDrawerLayoutFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-drawer-layout', | |
}) | |
export class AppDrawerLayoutReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const AppDrawerLayout = [AppDrawerLayoutChangeEventsAdapterDirective,AppDrawerLayoutNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'app-drawer', | |
host: { | |
'(opened-changed)': '_emitChangeEvent("opened", $event)' | |
} | |
}) | |
export class AppDrawerChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() openedChange: any; | |
constructor() { | |
super(['openedChange']); | |
} | |
} | |
@Directive({ | |
selector: 'app-drawer', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class AppDrawerNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-drawer', | |
}) | |
export class AppDrawerValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function AppDrawerForwardRefFormElement() { | |
return AppDrawerFormElementDirective; | |
} | |
@Directive({ | |
selector: 'app-drawer', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: AppDrawerForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class AppDrawerFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-drawer', | |
}) | |
export class AppDrawerReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const AppDrawer = [AppDrawerChangeEventsAdapterDirective,AppDrawerNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'app-header-layout', | |
host: { | |
} | |
}) | |
export class AppHeaderLayoutChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
constructor() { | |
super([]); | |
} | |
} | |
@Directive({ | |
selector: 'app-header-layout', | |
inputs: [], | |
host: { | |
} | |
}) | |
export class AppHeaderLayoutNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-header-layout', | |
}) | |
export class AppHeaderLayoutValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function AppHeaderLayoutForwardRefFormElement() { | |
return AppHeaderLayoutFormElementDirective; | |
} | |
@Directive({ | |
selector: 'app-header-layout', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: AppHeaderLayoutForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class AppHeaderLayoutFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-header-layout', | |
}) | |
export class AppHeaderLayoutReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const AppHeaderLayout = [AppHeaderLayoutChangeEventsAdapterDirective,AppHeaderLayoutNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'app-header', | |
host: { | |
'(threshold-triggered-changed)': '_emitChangeEvent("thresholdTriggered", $event)' | |
} | |
}) | |
export class AppHeaderChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() thresholdTriggeredChange: any; | |
constructor() { | |
super(['thresholdTriggeredChange']); | |
} | |
} | |
@Directive({ | |
selector: 'app-header', | |
inputs: ['effectsConfig'], | |
host: { | |
'(effects-config-changed)': '_setValueFromElement("effectsConfig", $event)' | |
} | |
}) | |
export class AppHeaderNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['effectsConfig'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-header', | |
}) | |
export class AppHeaderValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function AppHeaderForwardRefFormElement() { | |
return AppHeaderFormElementDirective; | |
} | |
@Directive({ | |
selector: 'app-header', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: AppHeaderForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class AppHeaderFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'app-header', | |
}) | |
export class AppHeaderReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const AppHeader = [AppHeaderChangeEventsAdapterDirective,AppHeaderNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'iron-data-table', | |
host: { | |
'(filter-changed)': '_emitChangeEvent("filter", $event)', | |
'(selected-item-changed)': '_emitChangeEvent("selectedItem", $event)', | |
'(selected-items-changed)': '_emitChangeEvent("selectedItems", $event)', | |
'(size-changed)': '_emitChangeEvent("size", $event)', | |
'(sort-order-changed)': '_emitChangeEvent("sortOrder", $event)', | |
'(columns-changed)': '_emitChangeEvent("columns", $event)', | |
'(data-source-changed)': '_emitChangeEvent("dataSource", $event)', | |
'(loading-changed)': '_emitChangeEvent("loading", $event)' | |
} | |
}) | |
export class IronDataTableChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() filterChange: any; | |
@Output() selectedItemChange: any; | |
@Output() selectedItemsChange: any; | |
@Output() sizeChange: any; | |
@Output() sortOrderChange: any; | |
@Output() columnsChange: any; | |
@Output() dataSourceChange: any; | |
@Output() loadingChange: any; | |
constructor() { | |
super(['filterChange', 'selectedItemChange', 'selectedItemsChange', 'sizeChange', 'sortOrderChange', 'columnsChange', 'dataSourceChange', 'loadingChange']); | |
} | |
} | |
@Directive({ | |
selector: 'iron-data-table', | |
inputs: ['beforeCellBind','beforeDetailsBind','beforeRowBind','items','filter','sortOrder','columns','dataSource'], | |
host: { | |
'(before-cell-bind-changed)': '_setValueFromElement("beforeCellBind", $event)', | |
'(before-details-bind-changed)': '_setValueFromElement("beforeDetailsBind", $event)', | |
'(before-row-bind-changed)': '_setValueFromElement("beforeRowBind", $event)', | |
'(items-changed)': '_setValueFromElement("items", $event)', | |
'(filter-changed)': '_setValueFromElement("filter", $event)', | |
'(sort-order-changed)': '_setValueFromElement("sortOrder", $event)', | |
'(columns-changed)': '_setValueFromElement("columns", $event)', | |
'(data-source-changed)': '_setValueFromElement("dataSource", $event)' | |
} | |
}) | |
export class IronDataTableNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['beforeCellBind','beforeDetailsBind','beforeRowBind','items','filter','sortOrder','columns','dataSource'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'iron-data-table', | |
}) | |
export class IronDataTableValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function IronDataTableForwardRefFormElement() { | |
return IronDataTableFormElementDirective; | |
} | |
@Directive({ | |
selector: 'iron-data-table', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: IronDataTableForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class IronDataTableFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'iron-data-table', | |
}) | |
export class IronDataTableReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const IronDataTable = [IronDataTableChangeEventsAdapterDirective,IronDataTableNotifyForDiffersDirective]; | |
@Directive({ | |
selector: 'data-table-column', | |
host: { | |
'(order-changed)': '_emitChangeEvent("order", $event)' | |
} | |
}) | |
export class DataTableColumnChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
@Output() orderChange: any; | |
constructor() { | |
super(['orderChange']); | |
} | |
} | |
@Directive({ | |
selector: 'data-table-column', | |
inputs: ['table'], | |
host: { | |
'(table-changed)': '_setValueFromElement("table", $event)' | |
} | |
}) | |
export class DataTableColumnNotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super(['table'], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: 'data-table-column', | |
}) | |
export class DataTableColumnValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function DataTableColumnForwardRefFormElement() { | |
return DataTableColumnFormElementDirective; | |
} | |
@Directive({ | |
selector: 'data-table-column', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: DataTableColumnForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: { '(valueChange)': 'onValueChanged($event)' } | |
}) | |
export class DataTableColumnFormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(false, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: 'data-table-column', | |
}) | |
export class DataTableColumnReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const DataTableColumn = [DataTableColumnChangeEventsAdapterDirective,DataTableColumnNotifyForDiffersDirective]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Injector, | |
DoCheck, | |
ElementRef, | |
EventEmitter, | |
Renderer, | |
NgZone, | |
OnInit, | |
KeyValueDiffers, | |
IterableDiffers, | |
DefaultIterableDiffer | |
} from '@angular/core'; | |
import { FormControlName } from '@angular/forms'; | |
const Polymer: any = (<any>window).Polymer; | |
export class ChangeEventsAdapterDirective { | |
protected _eventNameForProperty = (property: string) => `${property}Change`; | |
constructor(props: string[]) { | |
props | |
.forEach(property => this[property] = new EventEmitter<any>(false)); | |
} | |
_emitChangeEvent(property: string, event: any) { | |
// Event is a notification for a sub-property when `path` exists and the | |
// event.detail.value holds a value for a sub-property. | |
// For sub-property changes we don't need to explicitly emit events, | |
// since all interested parties are bound to the same object and Angular | |
// takes care of updating sub-property bindings on changes. | |
if (!event.detail.path) { | |
this[this._eventNameForProperty(property)].emit(event.detail.value); | |
} | |
} | |
} | |
export class NotifyForDiffersDirective implements OnInit, DoCheck { | |
_element: Element; | |
_differs: Object; | |
_arrayDiffs: Object; | |
constructor( | |
private arrayAndObjectProperties: string[], | |
private _iterableDiffers: IterableDiffers, | |
private _keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
this._element = el.nativeElement; | |
this._differs = {}; | |
this._arrayDiffs = {}; | |
} | |
ngOnInit() { | |
const elm = (<any>this)._element; | |
// In case the element has a default value and the directive doesn't have any value set for a property, | |
// we need to make sure the element value is set to the directive. | |
this.arrayAndObjectProperties.filter(property => elm[property] && !this[property]) | |
.forEach(property => { | |
this[property] = elm[property]; | |
}); | |
} | |
_setValueFromElement(property: string, event: Event) { | |
// Properties in this directive need to be kept synced manually with the element properties. | |
// Don't use event.detail.value here because it might contain changes for a sub-property. | |
const target: any = event.target; | |
if (this[property] !== target[property]) { | |
this[property] = target[property]; | |
(<any>this)._differs[property] = this._createDiffer(this[property]); | |
} | |
} | |
_createDiffer(value: string) { | |
let differ = Array.isArray(value) ? | |
(<any>this)._iterableDiffers.find(value).create(null) : (<any>this)._keyValueDiffers.find(value || {}).create(null); | |
// initial diff with the current value to make sure the differ is synced | |
// and doesn't report any outdated changes on the next ngDoCheck call. | |
differ.diff(value); | |
return differ; | |
} | |
_handleArrayDiffs(property: string, diff: any) { | |
if (diff) { | |
diff.forEachRemovedItem((item: any) => this._notifyArray(property, item.previousIndex)); | |
diff.forEachAddedItem((item: any) => this._notifyArray(property, item.currentIndex)); | |
diff.forEachMovedItem((item: any) => this._notifyArray(property, item.currentIndex)); | |
} | |
} | |
_handleObjectDiffs(property: string, diff: any) { | |
if (diff) { | |
const notify = (item: any) => this._notifyPath(property + '.' + item.key, item.currentValue); | |
diff.forEachRemovedItem(notify); | |
diff.forEachAddedItem(notify); | |
diff.forEachChangedItem(notify); | |
} | |
} | |
_notifyArray(property: string, index: number) { | |
this._notifyPath(property + '.' + index, this[property][index]); | |
} | |
_notifyPath(path: string, value: any) { | |
(<any>this)._element.notifyPath(path, value); | |
} | |
ngDoCheck() { | |
this.arrayAndObjectProperties.forEach(property => { | |
let elm = (<any>this)._element; | |
let _differs = (<any>this)._differs; | |
if (elm[property] !== this[property]) { | |
elm[property] = this[property]; | |
_differs[property] = this._createDiffer(this[property]); | |
} else if (_differs[property]) { | |
// TODO: these differs won't pickup any changes in need properties like items[0].foo | |
let diff = _differs[property].diff(this[property]); | |
if (diff instanceof DefaultIterableDiffer) { | |
this._handleArrayDiffs(property, diff); | |
} else { | |
this._handleObjectDiffs(property, diff); | |
} | |
} | |
}); | |
} | |
}; | |
export class ValidationDirective implements DoCheck { | |
_element: any; | |
_injector: Injector; | |
constructor(el: ElementRef, injector: Injector) { | |
this._element = el.nativeElement; | |
this._injector = injector; | |
} | |
ngDoCheck() { | |
const control = this._injector.get(FormControlName, null); | |
if (control) { | |
this._element.invalid = !control.pristine && !control.valid; | |
} | |
} | |
} | |
export class FormElementDirective { | |
_renderer: Renderer; | |
_element: Element; | |
_isCheckedElement: boolean; | |
constructor(_isCheckedElement: boolean, renderer: Renderer, el: ElementRef) { | |
this._isCheckedElement = _isCheckedElement; | |
this._renderer = renderer; | |
this._element = el.nativeElement; | |
this._element.addEventListener('blur', () => this.onTouched(), true); | |
} | |
onChange(_: any) { } | |
onTouched() { } | |
writeValue(value: any): void { | |
this._renderer.setElementProperty(this._element, (this._isCheckedElement ? 'checked' : 'value'), value); | |
} | |
registerOnChange(fn: (_: any) => void): void { this.onChange = fn; } | |
registerOnTouched(fn: () => void): void { this.onTouched = fn; } | |
onValueChanged(value: any) { | |
this.onChange(value); | |
} | |
} | |
export class ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
if (!Polymer.Settings.useShadow) { | |
el.nativeElement.async(() => { | |
if (el.nativeElement.isInitialized()) { | |
// Reload outside of Angular to prevent unnecessary ngDoCheck calls | |
zone.runOutsideAngular(() => { | |
el.nativeElement.reloadConfiguration(); | |
}); | |
} | |
}); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Polymer: any = (<any>window).Polymer; | |
export const PolymerElementTemplate = (name) => { | |
const propertiesWithNotify: Array<any> = []; | |
const arrayAndObjectProperties: Array<any> = []; | |
const proto: any = Object.getPrototypeOf(document.createElement(name)); | |
if (proto.is !== name) { | |
throw new Error(`The Polymer element "${name}" has not been registered. Please check that the element is imported correctly.`); | |
} | |
const isFormElement: boolean = Polymer && Polymer.IronFormElementBehavior && | |
proto.behaviors.indexOf(Polymer.IronFormElementBehavior) > -1; | |
const isCheckedElement: boolean = Polymer && Polymer.IronCheckedElementBehaviorImpl && | |
proto.behaviors.indexOf(Polymer.IronCheckedElementBehaviorImpl) > -1; | |
proto.behaviors.forEach((behavior: any) => configureProperties(behavior.properties)); | |
configureProperties(proto.properties); | |
function configureProperties(properties: any) { | |
if (properties) { | |
Object.getOwnPropertyNames(properties) | |
.filter(prop => prop.indexOf('_') !== 0) | |
.forEach(prop => configureProperty(prop, properties)); | |
} | |
} | |
function configureProperty(prop: string, properties: any) { | |
let info = properties[prop]; | |
if (typeof info === 'function') { | |
info = { | |
type: info | |
}; | |
} | |
if (info.type && !info.readOnly && (info.type === Object || info.type === Array)) { | |
arrayAndObjectProperties.push(prop); | |
} | |
if (info && info.notify) { | |
propertiesWithNotify.push(prop); | |
} | |
} | |
const eventNameForProperty = (property: string) => `${property}Change`; | |
const propsAsString = (property: string) => `'${property}'`; | |
let className = Polymer.CaseMap.dashToCamelCase(name); | |
className = className.slice(0, 1).toUpperCase() + className.slice(1); | |
const outputsBindings = propertiesWithNotify.map(eventNameForProperty) | |
.reduce( (outputJs, property) => { | |
return outputJs + ` @Output() ${property}: any;\n`; | |
}, ''); | |
const outputList = propertiesWithNotify.map(eventNameForProperty) | |
.map(propsAsString) | |
.join(', '); | |
const hostChangeEvents = propertiesWithNotify.map((property) => { | |
const dashCase: string = Polymer.CaseMap.camelToDashCase(property); | |
return ` '(${dashCase}-changed)': '_emitChangeEvent("${property}", $event)'`; | |
}, {}).join(',\n'); | |
const arrayAndObjectProps = arrayAndObjectProperties.map(propsAsString) | |
.join(','); | |
const setValueFromElement = arrayAndObjectProperties.map((property) => { | |
const dashCase: string = Polymer.CaseMap.camelToDashCase(property); | |
return ` '(${dashCase}-changed)': '_setValueFromElement("${property}", $event)'`; | |
}, {}).join(',\n'); | |
const hostIsChecked = isCheckedElement ? `{ '(checkedChange)': 'onValueChanged($event)' }` : | |
` { '(valueChange)': 'onValueChanged($event)' }`; | |
const directives = [`${className}ChangeEventsAdapterDirective`, `${className}NotifyForDiffersDirective`]; | |
if (isFormElement) { | |
directives.push(`${className}FormElementDirective`); | |
directives.push(`${className}ValidationDirective`); | |
} | |
// If the element has isInitialized and reloadConfiguration methods (e.g., Charts) | |
if (typeof proto.isInitialized === 'function' && | |
typeof proto.reloadConfiguration === 'function') { | |
directives.push(`${className}ReloadConfigurationDirective`); | |
} | |
directives.map(propsAsString).join(','); | |
return ` | |
@Directive({ | |
selector: '${name}', | |
host: { | |
${hostChangeEvents} | |
} | |
}) | |
export class ${className}ChangeEventsAdapterDirective extends ChangeEventsAdapterDirective { | |
${outputsBindings} | |
constructor() { | |
super([${outputList}]); | |
} | |
} | |
@Directive({ | |
selector: '${name}', | |
inputs: [${arrayAndObjectProps}], | |
host: { | |
${setValueFromElement} | |
} | |
}) | |
export class ${className}NotifyForDiffersDirective extends NotifyForDiffersDirective { | |
constructor( | |
_iterableDiffers: IterableDiffers, | |
_keyValueDiffers: KeyValueDiffers, | |
el: ElementRef) { | |
super([${arrayAndObjectProps}], _iterableDiffers, _keyValueDiffers, el); | |
} | |
} | |
@Directive({ | |
selector: '${name}', | |
}) | |
export class ${className}ValidationDirective extends ValidationDirective { | |
constructor(el: ElementRef, injector: Injector) { | |
super(el, injector); | |
} | |
} | |
export function ${className}ForwardRefFormElement() { | |
return ${className}FormElementDirective; | |
} | |
@Directive({ | |
selector: '${name}', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: ${className}ForwardRefFormElement(), | |
multi: true | |
} | |
], | |
host: ${hostIsChecked} | |
}) | |
export class ${className}FormElementDirective extends FormElementDirective { | |
constructor(renderer: Renderer, el: ElementRef) { | |
super(${isCheckedElement ? 'true' : 'false'}, renderer, el); | |
} | |
} | |
@Directive({ | |
selector: '${name}', | |
}) | |
export class ${className}ReloadConfigurationDirective extends ReloadConfigurationDirective { | |
constructor(el: ElementRef, zone: NgZone) { | |
super(el, zone); | |
} | |
} | |
export const ${className} = [${directives}]; | |
`; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment