Sha256: b3e31578fc0d4a0fa6ec28a59850426d858ed29fe7ba07127139d9bf2aa6ac0e

Contents?: true

Size: 795 Bytes

Versions: 7

Compression:

Stored size: 795 Bytes

Contents

import { htmlAttributes } from "../html/html-attributes";

export class TextField {
  state: any;
  attribute: string;
  attributes: Record<string, any>;

  constructor(state: any, attribute: string, attributes: Record<string, any> = {}) {
    this.state = state;
    this.attributes = attributes;
    this.attribute = attribute;
    this.attributes["data-attribute"] = attribute;
  }

  get renderWrapper(): string {
    return `<input type='text' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
  }

  add_action(event: string, klass: string, fn: string, options: { debounce?: number } = {}): TextField {
    this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`;
    return this;
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clapton-0.0.24 lib/clapton/javascripts/src/components/text-field.ts
clapton-0.0.23 lib/clapton/javascripts/src/components/text-field.ts
clapton-0.0.22 lib/clapton/javascripts/src/components/text-field.ts
clapton-0.0.21 lib/clapton/javascripts/src/components/text-field.ts
clapton-0.0.20 lib/clapton/javascripts/src/components/text-field.ts
clapton-0.0.19 lib/clapton/javascripts/src/components/text-field.ts
clapton-0.0.18 lib/clapton/javascripts/src/components/text-field.ts