File

projects/i-components/src/lib/directives/ribbonGroupItemsDirective.directive.ts

Description

Interface to be implemented on all RibbonGroupComponents

import {
  ComponentRef,
  Directive,
  ElementRef,
  Inject,
  InjectionToken,
  Input,
  Optional,
  TemplateRef,
  ViewContainerRef,
} from '@angular/core';

/**
 * Injection token used to access to components
 *
 * @export
 * @class InjectionToken
 */
export const D_COMPATIBLE_COMPONENT = new InjectionToken<RibbonComponentData>(
  'D_COMPATIBLE_COMPONENT'
);

/**
 * RibbonGroupDirective
 *
 * @export
 * @class RibbonGroupDirective
 */
@Directive({
  selector: '[wmRibbonGroupItem]',
})
export class RibbonGroupDirective {
  /**
   * Creates an instance of RibbonGroupDirective.
   *
   * @param {TemplateRef<any>} template
   * @memberof RibbonGroupDirective
   */
  constructor(public template: TemplateRef<any>) {}
}

/**
 * This is a directive in charge of get component instance since it was not possible to read InjectionToken on structural directive
 *
 * @export
 * @class RibbonInstanceDirective
 */
@Directive({
  selector: '[wmRibbonItemInstance]',
})
export class RibbonInstanceDirective {
  /**
   * Component instance
   *
   * @type {*}
   * @memberof RibbonInstanceDirective
   */
  public component: any;

  /**
   * Creates an instance of RibbonInstanceDirective.
   *
   * @param {(RibbonComponentData | null)} component
   * @memberof RibbonInstanceDirective
   */
  constructor(
    @Optional()
    @Inject(D_COMPATIBLE_COMPONENT)
    component: RibbonComponentData | null
  ) {
    this.component = component;
  }
}

/**
 * Interface to be implemented on all RibbonGroupComponents
 *
 * @export
 * @interface RibbonComponentData
 */
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RibbonComponentData {}

result-matching ""

    No results matching ""