How to use @stencil/core - 10 common examples

To help you get started, we’ve selected a few @stencil/core 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 Esri / global-nav / src / components / esri-footer / esri-footer.tsx View on Github external
) : null}
            
          
        
      
    );
  }

  //--------------------------------------------------------------------------
  //
  //  Event Listeners
  //
  //--------------------------------------------------------------------------

  @Listen("click") onClick(e: Event) {
    console.log(e);
  }

  //--------------------------------------------------------------------------
  //
  //  Events
  //
  //--------------------------------------------------------------------------

  @Event() open: EventEmitter;

  /**
   * If using the header programatically, you can pass in the data structure
   * to the init method, and it will create all sub elements for you.
   */
  @Method() async init(detail): Promise {
github Esri / calcite-app-components / src / components / calcite-pick-list-item / calcite-pick-list-item.tsx View on Github external
/**
   * An optional description for this item.  This will appear below the label text.
   */
  @Prop({ reflect: true }) textDescription?: string;

  @Watch("textDescription") textDescriptionWatchHandler() {
    this.calciteListItemPropsUpdated.emit();
  }

  /**
   * The main label for this item. This will appear next to the icon.
   */
  @Prop({ reflect: true }) textLabel: string;

  @Watch("textLabel") textLabelWatchHandler() {
    this.calciteListItemPropsUpdated.emit();
  }

  /**
   * A unique value used to identify this item - similar to the value attribute on an <input>.
   */
  @Prop({ reflect: true }) value!: string;

  // --------------------------------------------------------------------------
  //
  //  Private Properties
  //
  // --------------------------------------------------------------------------

  @Element() el: HTMLCalcitePickListItemElement;
github ionic-team / ionic / packages / core / src / components / split-pane / split-pane.tsx View on Github external
const detail = { visible };
    this.ionChange.emit(detail);
    this.ionSplitPaneVisible.emit(detail);
  }

  componentDidLoad() {
    this._styleChildren();
    this.whenChanged();
  }

  componentDidUnload() {
    this.rmL && this.rmL();
    this.rmL = null;
  }

  @Watch('when')
  protected whenChanged() {
    this.rmL && this.rmL();
    this.rmL = null;

    // Check if the split-pane is disabled
    if (this.disabled) {
      this.visible = false;
      return;
    }

    // When query is a boolean
    const query = this.when;
    if (typeof query === 'boolean') {
      this.visible = query;
      return;
    }
github ionic-team / ionic / packages / core / src / components / router / router.tsx View on Github external
componentDidLoad() {
    const tree = readRoutes(this.el);
    this.routes = flattenRouterTree(tree);
    this.redirects = readRedirects(this.el);

    if (Build.isDev) {
      console.debug('%c[@ionic/core]', 'font-weight: bold', `ion-router registered ${this.routes.length} routes`);
      for (const chain of this.routes) {
        const path: string[] = [];
        chain.forEach(r => path.push(...r.path));
        const ids = chain.map(r => r.id);
        console.debug(`%c ${generatePath(path)}`, 'font-weight: bold; padding-left: 20px', '=>\t', `(${ids.join(', ')})`);
      }
    }

    // perform first write
    this.dom.raf(() => {
      console.debug('[OUT] page load -> write nav state');
      this.onPopState();
    });
  }
github arquivo / pwa-technologies / PwaArchive-access / projects / nutchwax / nutchwax-webapp / src / main / webapp / @ionic / core / dist / collection / components / menu-controller / menu-controller.js View on Github external
async get(menu) {
        if (Build.isDev) {
            if (menu === 'left') {
                console.error('menu.side=left is deprecated, use "start" instead');
                return undefined;
            }
            if (menu === 'right') {
                console.error('menu.side=right is deprecated, use "end" instead');
                return undefined;
            }
        }
        await this.waitUntilReady();
        if (menu === 'start' || menu === 'end') {
            // there could be more than one menu on the same side
            // so first try to get the enabled one
            const menuRef = this.find(m => m.side === menu && !m.disabled);
            if (menuRef) {
                return menuRef;
github ionic-team / ionic / packages / core / src / components / radio / radio-group.tsx View on Github external
/*
   * @input {boolean} If true, the radios can be deselected. Default false.
   */
  @Prop() allowEmptySelection: boolean = false;

  /*
   * @input {boolean} If true, the user cannot interact with the radio group. Default false.
   */
  @Prop({ mutable: true }) disabled: boolean = false;

  /**
   * @input {string} the value of the radio group.
   */
  @Prop({ mutable: true }) value: string;

  @PropDidChange('value')
  protected valueChanged() {
    this.update();
    this.ionChange.emit(this);
  }

  @Listen('ionRadioDidLoad')
  protected radioDidLoad(ev: RadioEvent) {
    const radio = ev.detail.radio;
    this.radios.push(radio);
    radio.radioId = 'rb-' + this.radioGroupId + '-' + (++this.ids);

    // if the value is not defined then use its unique id
    radio.value = !radio.value ? radio.radioId : radio.value;

    if (radio.checked && !this.value) {
      this.value = radio.value;
github deckgo / deckdeckgo / webcomponents / core / src / components / deck / deckdeckgo-deck / deckdeckgo-deck.tsx View on Github external
resolve();
    });
  }

  private lazyLoadAllContent(): Promise {
    const promises = [];

    for (let i = 0; i &lt; this.length; i++) {
      promises.push(this.lazyLoadContent(i));
    }

    return Promise.all(promises);
  }

  @Method()
  isMobile(): Promise {
    return new Promise((resolve) =&gt; {
      resolve(isMobile());
    });
  }

  /* END: Utils */

  /* BEGIN: Reveal */

  @Watch('reveal')
  async onRevealChange() {
    if (!this.reveal) {
      await this.revealAllContent();
    } else {
      await this.redoRevealContent();
github ionic-team / ionic / packages / core / src / components / menu-controller / menu-controller.ts View on Github external
}

  /**
   * @hidden
   */
  @Method()
  _register(menu: Menu) {
    if (this.menus.indexOf(menu) &lt; 0) {
      this.menus.push(menu);
    }
  }

  /**
   * @hidden
   */
  @Method()
  _unregister(menu: Menu) {
    const index = this.menus.indexOf(menu);
    if (index &gt; -1) {
      this.menus.splice(index, 1);
    }
  }

  /**
   * @hidden
   */
  @Method()
  _setActiveMenu(menu: Menu) {
    // if this menu should be enabled
    // then find all the other menus on this same side
    // and automatically disable other same side menus
    const side = menu.side;
github ionic-team / ionic / core / src / components / radio-group / radio-group.tsx View on Github external
radio.name = this.name;

    // add radio to internal list
    this.radios.push(radio);

    // this radio-group does not have a value
    // but this radio is checked, so let's set the
    // radio-group's value from the checked radio
    if (this.value == null && radio.checked) {
      this.value = radio.value;
    } else {
      this.updateRadios();
    }
  }

  @Listen('ionRadioDidUnload')
  onRadioDidUnload(ev: Event) {
    const index = this.radios.indexOf(ev.target as HTMLIonRadioElement);
    if (index > -1) {
      this.radios.splice(index, 1);
    }
  }

  @Listen('ionSelect')
  onRadioSelect(ev: Event) {
    const selectedRadio = ev.target as HTMLIonRadioElement | null;
    if (selectedRadio) {
      this.value = selectedRadio.value;
    }
  }

  @Listen('ionDeselect')
github ionic-team / ionic / packages / core / src / components / events / events.tsx View on Github external
subscriptions.set(topic, handlers);
  }

  @Method()
  unsubscribe(topic: string, handler: (event?: any) =&gt; void) {
    const handlers = subscriptions.get(topic) || [];
    const newHandlers = handlers.filter(fun =&gt; fun !== handler);
    subscriptions.set(topic, newHandlers);
  }

  @Method()
  publish(topic: string, event?: any) {
    return publishImpl(topic, event);
  }

  @Listen('window:online')
  @Listen('window:offline')
  @Listen('window:orientationchange')
  online(event: Event) {
   return publishImpl(`app:${event.type}`, event);
  }

  @Listen('window:statusTap')
  statusTap(event: Event) {
    return publishImpl(`app:${event.type}`, event);
  }

}

// make this method async just to give the browser a chance to chill and do what it needs to do before firing this off
function publishImpl(topic: string, event: any): Promise {
  return Promise.resolve().then(() =&gt; {