Sha256: 1cd553ad10ff6f32656c567b2cabf3956ff17ba28a783e1b1d7bc2050793ec05

Contents?: true

Size: 800 Bytes

Versions: 7

Compression:

Stored size: 800 Bytes

Contents

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

export class RadioButton {
  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='radio' ${htmlAttributes(this.attributes)} value='${this.state[this.attribute] || ""}'/>`;
  }

  add_action(event: string, klass: string, fn: string, options: { debounce?: number } = {}): RadioButton {
    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/radio-button.ts
clapton-0.0.23 lib/clapton/javascripts/src/components/radio-button.ts
clapton-0.0.22 lib/clapton/javascripts/src/components/radio-button.ts
clapton-0.0.21 lib/clapton/javascripts/src/components/radio-button.ts
clapton-0.0.20 lib/clapton/javascripts/src/components/radio-button.ts
clapton-0.0.19 lib/clapton/javascripts/src/components/radio-button.ts
clapton-0.0.18 lib/clapton/javascripts/src/components/radio-button.ts