Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected createAdapter(): MDCSnackbarAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
// We handle announce ourselves with the accessible directive.
announce: () => {},
notifyClosed: (reason: string) => {
this.dispatchEvent(new CustomEvent(
CLOSED_EVENT,
{bubbles: true, cancelable: true, detail: {reason: reason}}));
},
notifyClosing: (reason: string) => {
this.isOpen = false;
this.dispatchEvent(new CustomEvent(
CLOSING_EVENT,
{bubbles: true, cancelable: true, detail: {reason: reason}}));
},
notifyOpened: () => {
this.dispatchEvent(
new CustomEvent(OPENED_EVENT, {bubbles: true, cancelable: true}));
protected createAdapter(): MDCDrawerAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
elementHasClass: (element: HTMLElement, className: string) =>
element.classList.contains(className),
saveFocus: () => {
// Note, casting to avoid cumbersome runtime check.
this._previousFocus =
(this.getRootNode() as ShadowRoot).activeElement as HTMLElement;
},
restoreFocus: () => {
const previousFocus = this._previousFocus && this._previousFocus.focus;
if (previousFocus) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this._previousFocus!.focus();
}
},
notifyClose: () => {
this.open = false;
protected createAdapter(): MDCLinearProgressAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
forceLayout: () => this.mdcRoot.offsetWidth,
getPrimaryBar: () => this.primaryBar,
getBuffer: () => this.bufferElement,
setStyle: (el: HTMLElement, property: string, value: string) => {
// TODO(aomarks) Consider moving this type to the
// MDCLinearProgressAdapter parameter type, but note that the "-webkit"
// prefixed CSS properties are not declared in CSSStyleDeclaration.
//
// Exclude read-only properties.
el.style[property as Exclude] =
value;
},
};
}
protected createAdapter(): MDCIconButtonToggleAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
setAttr: (name: string, value: string) => {
this.mdcRoot.setAttribute(name, value);
},
notifyChange: (evtData: {isOn: boolean}) => {
this.dispatchEvent(new CustomEvent(
'MDCIconButtonToggle:change', {detail: evtData, bubbles: true}));
},
};
}
protected createAdapter(): MDCTabIndicatorAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
computeContentClientRect: () =>
this.contentElement.getBoundingClientRect(),
setContentStyleProperty: (prop: string, value: string) =>
this.contentElement.style.setProperty(prop, value),
};
}
protected createAdapter(): MDCDialogAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
addBodyClass: () => document.body.style.overflow = 'hidden',
removeBodyClass: () => document.body.style.overflow = '',
areButtonsStacked: () => this.stacked,
clickDefaultButton: () => {
const primary = this.primaryButton;
if (primary) {
primary.click();
}
},
eventTargetMatches: (target, selector) =>
target ? matches(target as Element, selector) : false,
getActionFromEvent: (e: Event) => {
if (!e.target) {
return '';
}
protected createAdapter(): MDCTabAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
setAttr: (attr: string, value: string) =>
this.mdcRoot.setAttribute(attr, value),
activateIndicator: (previousIndicatorClientRect: ClientRect) =>
(this._tabIndicator as TabIndicator)
.activate(previousIndicatorClientRect),
deactivateIndicator: () =>
(this._tabIndicator as TabIndicator).deactivate(),
notifyInteracted: () => this.dispatchEvent(
new CustomEvent(MDCTabFoundation.strings.INTERACTED_EVENT, {
detail: {tabId: this.id},
bubbles: true,
composed: true,
cancelable: true,
})),
getOffsetLeft: () => this.offsetLeft,
getOffsetWidth: () => this.mdcRoot.offsetWidth,