How to use the @aurelia/runtime.customElement function in @aurelia/runtime

To help you get started, we’ve selected a few @aurelia/runtime 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 aurelia / aurelia / test / navigation-skeleton / app / src / child-router.ts View on Github external
import { IRouter } from '@aurelia/router';
import { customElement } from '@aurelia/runtime';

import * as template from './child-router.html';

@customElement({ name: 'child-router', template })
export class ChildRouter {
  // public reentryBehavior: ReentryBehavior = ReentryBehavior.refresh;

  public heading: string = 'Child Router';

  public constructor(
    @IRouter public readonly router: IRouter,
  ) {}

  public binding() {
    this.router.setNav('child-menu', [
      { title: 'Welcome', route: 'welcome' },
      { title: 'Users', route: 'users' },
      { title: 'Child router', route: 'child-router' },
    ]);
  }
github aurelia-v-grid / vGrid / src / aurelia-v-grid / grid / v-grid-col.ts View on Github external
import { inject } from '@aurelia/kernel';
// import { VGrid } from './v-grid';
import {
  ColConfigInterface,
  BindingContextInterface,
  OverrideContextInterface
} from '../interfaces';



/**
 * Custom element 
 * This is used for creating the simple html columns
 *
 */
@customElement({
  name: 'v-grid-col',
  templateOrNode: '',
  build: {
    required: true,
    compiler: 'default'
  },
  instructions: []
})
@inject(Element /*, VGrid*/)
export class VGridElementColConfig {
  // private vGrid: VGrid;
  private element: Element;
  private colRowTemplate: string;
  private colHeaderTemplate: string;
  private colCss: string;
  private bindingContext: BindingContextInterface;
github aurelia / aurelia / packages / __tests__ / integration / app / molecules / specs-viewer / specs-viewer.ts View on Github external
import { bindable, customElement, valueConverter } from '@aurelia/runtime';
import { Thing, ThingViewer } from './thing-viewer';
import { Camera, CameraSpecsViewer } from './camera-specs-viewer';
import { Laptop, LaptopSpecsViewer } from './laptop-specs-viewer';
import template from './specs-viewer.html';

@customElement({ name: 'specs-viewer', template })
export class SpecsViewer {
  @bindable public things: Thing[];
  private pairs: { vm: typeof ThingViewer; thing: Thing }[];

  public beforeBind() {
    const toVm = (thing: Thing) => {
      switch (true) {
        case thing instanceof Camera: return CameraSpecsViewer;
        case thing instanceof Laptop: return LaptopSpecsViewer;
        case thing instanceof Thing: return ThingViewer;
        default: throw new Error(`Unsupported type ${thing.constructor.prototype}`);
      }
    };
    this.pairs = this.things.map((thing) => ({ thing, vm: toVm(thing) }));
  }
}
github aurelia / aurelia / packages / __tests__ / router / e2e / doc-example / app / src / components / books / redirect-information.ts View on Github external
import { customElement } from '@aurelia/runtime';

@customElement({ name: 'redirect-information', template: `<template>
<p>This just redirects to information.</p>
</template>` })
export class RedirectInformation {
  public canEnter() {
    return 'information';
  }
}
github aurelia / aurelia / packages / __tests__ / router / e2e / doc-example / app / src / components / chat / chat.ts View on Github external
import { customElement } from '@aurelia/runtime';

@customElement({
  name: 'chat', template: `<template>
<h3>Chat <a class="close" href="-@chat" data-test="chat-element-close">X</a></h3>


</template>` })
export class Chat { }
github aurelia / aurelia / test / wdio / cases / dev / jit-webpack-ts / src / app.ts View on Github external
import { customElement } from '@aurelia/runtime';
import template from './app.html';

@customElement({ name: 'app', template })
export class App {
  message = 'Hello World!';
}
github aurelia / aurelia / packages / __tests__ / router / e2e / nav / src / app.ts View on Github external
import { inject } from '@aurelia/kernel';
import { customElement } from '@aurelia/runtime';
import { Router } from '../../../../../router/src/index';

@inject(Router)
@customElement({
  name: 'app', template:
    `<template>
  <div style="padding: 20px;">
    <p>A layout test, with game and lobby "layouts".</p>
    <a href="lobby">Lobby</a>
    <a href="game">Game</a>
    <a href="lobby@app+contacts@lobby+contact@contact(123)">Lobby + contacts + 123</a>
    <a href="lobby@app+contact@contact(123)+contacts@lobby">Lobby + 123 + contacts</a>
    <a href="game+board@game">Game + board (5 + 5, parent-child)</a>
    <a href="game+delayed">Game + delayed (5 + 5, siblings)</a>
    <a href="cancel">Cancel</a>
    
    
  </div>
</template>
` })
github aurelia / aurelia / packages / examples / test-jit / app.ts View on Github external
import { customElement } from '@aurelia/runtime';
import view from 'view!./app.html';

class Todo {
  done = false;
  public constructor(public description: string) {}
}

@customElement(view)
export class App {
  message = 'Hello World';
  duplicateMessage = true;
  todos: Todo[] = [];

  get computedMessage() {
    let value = `
      ${this.message} Computed:
      Todo Count ${this.todos.length}
      Descriptions:
      ${this.todos.map(x => x.description).join('\n')}
    `;

    return value;
  }
github aurelia / aurelia / packages / __tests__ / router / e2e / nav / src / components / contact.ts View on Github external
import { inject } from '@aurelia//kernel';
import { customElement } from '@aurelia/runtime';
import { ContactList } from '../contact-list';

@customElement({
  name: 'contact', template: `<template>CONTACT <input>
<p>Id: \${contact.id}</p>
<p>Name: \${contact.name}</p>
</template>` })
@inject(ContactList)
export class Contact {
  public static parameters = ['id'];

  public contact = {};
  public constructor(private readonly contactList: ContactList) { }

  public enter(parameters) {
    if (parameters.id) {
      this.contact = this.contactList.contact(parameters.id);
    }
  }
github aurelia / aurelia / test / wdio / cases / latest / jit-parcel-ts / src / app.ts View on Github external
import { customElement } from '@aurelia/runtime';
import template from './app.html';

@customElement({ name: 'app', template })
export class App {
  message = 'Hello World!';
}