Sha256: 68191d0fabe34bf695c1e33554c4bdd5f73e32bb2b2048f6e1f312d20b3b894f

Contents?: true

Size: 761 Bytes

Versions: 7

Compression:

Stored size: 761 Bytes

Contents

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

export class Box {
  attributes: Record<string, any>;
  children: any[];

  constructor(attributes: Record<string, any> = {}) {
    this.children = [];
    this.attributes = attributes;
  }

  add(child: any): this {
    this.children.push(child);
    return this;
  }

  get renderWrapper(): string {
    return `<div ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</div>`;
  }

  add_action(eventType: string, stateName: string, fnName: string, options: Record<string, any> = {}): this {
    this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${eventType}->${stateName}#${fnName}@${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/box.ts
clapton-0.0.23 lib/clapton/javascripts/src/components/box.ts
clapton-0.0.22 lib/clapton/javascripts/src/components/box.ts
clapton-0.0.21 lib/clapton/javascripts/src/components/box.ts
clapton-0.0.20 lib/clapton/javascripts/src/components/box.ts
clapton-0.0.19 lib/clapton/javascripts/src/components/box.ts
clapton-0.0.18 lib/clapton/javascripts/src/components/box.ts