libs/ngx-pfe/schematics/ng-update/v51-input-signal-reads/input-signal-targets.ts

Description

A published component/directive whose @Input() properties were replaced with the signal input() / input.required() functions in ngx-pfe v51.0.0.

Index

Properties

Properties

className
className: string
Type : string
functionValuedMembers
functionValuedMembers: string[]
Type : string[]

The subset whose value is itself a function (input<() => void>(...)). Reading the signal and invoking the value are two separate calls, so the old this.x() — which called the callback — must become this.x()(). That makes them indistinguishable from an already-migrated read, which is why this migration is not idempotent.

members
members: string[]
Type : string[]
module
module: string
Type : string
selectors
selectors: string[]
Type : string[]

Element selectors, for reads through a template reference variable.

export interface TargetComponent {
  module: string;
  className: string;
  members: string[];
  /**
   * The subset whose *value* is itself a function (`input<() => void>(...)`). Reading the
   * signal and invoking the value are two separate calls, so the old `this.x()` — which
   * called the callback — must become `this.x()()`. That makes them indistinguishable from an
   * already-migrated read, which is why this migration is not idempotent.
   */
  functionValuedMembers: string[];
  /** Element selectors, for reads through a template reference variable. */
  selectors: string[];
}

/** Only components a consumer can reach through a published entry point are listed. */
export const TARGET_COMPONENTS: TargetComponent[] = [
  {
    module: '@allianz/ngx-pfe',
    className: 'PfeMasterPageComponent',
    members: ['nextClickedCallback'],
    functionValuedMembers: ['nextClickedCallback'],
    selectors: ['pfe-master-page'],
  },
  {
    // Extends PfeMasterPageComponent, so it inherits the same input.
    module: '@allianz/ngx-pfe-ndbx',
    className: 'PfeNdbxMasterPageComponent',
    members: ['nextClickedCallback'],
    functionValuedMembers: ['nextClickedCallback'],
    selectors: ['pfe-ndbx-master-page'],
  },
  {
    // An attribute directive without `exportAs` cannot be grabbed via a ref var.
    module: '@allianz/ngx-pfe/util/i18n-from-state',
    className: 'PfeI18nFromStateDirective',
    members: ['pfeI18nFromState'],
    functionValuedMembers: [],
    selectors: [],
  },
  {
    module: '@allianz/ngx-pfe-ndbx',
    className: 'PfeNavButtonsContainerComponent',
    members: [
      'nxNextType',
      'nxBackType',
      'nxBackLabel',
      'nxNextLabel',
      'nxNextHidden',
      'nxBackHidden',
      'nxDisableNext',
      'nxDisableBack',
      'nxNextOptionalLabel',
      'nxEnableNextOptionalLabel',
      'nxBackLink',
      'nxNextLink',
      'nxNextAction',
      'nxBackAction',
    ],
    functionValuedMembers: ['nxNextAction', 'nxBackAction'],
    selectors: ['pfe-nav-buttons-container'],
  },
  {
    module: '@allianz/ngx-pfe-ndbx',
    className: 'PfeErrorMessageComponent',
    members: ['hideError', 'message', 'hideClose'],
    functionValuedMembers: [],
    selectors: ['pfe-error-message'],
  },
  {
    module: '@allianz/ngx-pfe-devtools',
    className: 'PfeDevToolsComponent',
    members: ['devToolsActive'],
    functionValuedMembers: [],
    selectors: ['pfe-devtools'],
  },
];

export const TARGET_MODULE_PREFIXES = ['@allianz/ngx-pfe'];

/**
 * Scopes template reference-variable reads to the correct owner — names such as `message` are
 * not unique across targets, so a read may only be migrated once its owner is known.
 */
export const MEMBERS_BY_SELECTOR: ReadonlyMap<string, ReadonlySet<string>> = (() => {
  const bySelector = new Map<string, Set<string>>();
  for (const target of TARGET_COMPONENTS) {
    for (const selector of target.selectors) {
      const members = bySelector.get(selector) ?? new Set<string>();
      target.members.forEach((member) => members.add(member));
      bySelector.set(selector, members);
    }
  }
  return bySelector;
})();

export const FUNCTION_VALUED_MEMBERS: ReadonlySet<string> = new Set(TARGET_COMPONENTS.flatMap((target) => target.functionValuedMembers));

export const ALL_MEMBER_NAMES: ReadonlySet<string> = new Set(TARGET_COMPONENTS.flatMap((target) => target.members));

results matching ""

    No results matching ""