How to use the @material/textfield/character-counter/foundation.js.MDCTextFieldCharacterCounterFoundation function in @material/textfield

To help you get started, we’ve selected a few @material/textfield examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github material-components / material-components-web-components / packages / textfield / src / character-counter / mwc-character-counter-directive.ts View on Github external
export const characterCounter = directive(() => (part: PropertyPart) => {
  const lastFoundation = partToFoundationMap.get(part);
  if (!lastFoundation) {
    const hostElement = part.committer.element as CharacterCounter;
    hostElement.classList.add('mdc-text-field-character-counter');
    const adapter = createAdapter(hostElement);
    const foundation = new MDCTextFieldCharacterCounterFoundation(adapter);
    foundation.init();
    part.setValue(foundation);
    partToFoundationMap.set(part, foundation);
  }
});