How to use the hyperview/src/services.getBehaviorElements function in hyperview

To help you get started, we’ve selected a few hyperview 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 Instawork / hyperview / src / core / hyper-ref / index.js View on Github external
render() {
    const { refreshing, pressed } = this.state;
    const { element, stylesheets, onUpdate, options } = this.props;
    const behaviorElements = getBehaviorElements(element);
    const pressBehaviors = behaviorElements.filter(
      e =>
        PRESS_TRIGGERS.indexOf(
          e.getAttribute(ATTRIBUTES.TRIGGER) || TRIGGERS.PRESS,
        ) >= 0,
    );
    const visibleBehaviors = behaviorElements.filter(
      e => e.getAttribute(ATTRIBUTES.TRIGGER) === TRIGGERS.VISIBLE,
    );
    const refreshBehaviors = behaviorElements.filter(
      e => e.getAttribute(ATTRIBUTES.TRIGGER) === TRIGGERS.REFRESH,
    );

    // Render the component based on the XML element. Depending on the applied behaviors,
    // this component will be wrapped with others to provide the necessary interaction.
    let renderedComponent = Render.renderElement(
github Instawork / hyperview / src / components / hv-list / index.js View on Github external
refresh = () => {
    const { element, onUpdate } = this.props;
    this.setState({ refreshing: true });

    getBehaviorElements(element)
      .filter(e => e.getAttribute('trigger') === 'refresh')
      .forEach((e, i) => {
        const path = e.getAttribute('href');
        const action = e.getAttribute('action') || 'append';
        const targetId = e.getAttribute('target');
        const showIndicatorIds = e.getAttribute('show-during-load');
        const hideIndicatorIds = e.getAttribute('hide-during-load');
        const delay = e.getAttribute('delay');
        const once = e.getAttribute('once');
        const onEnd =
          i === 0 ? () => this.setState({ refreshing: false }) : null;
        onUpdate(path, action, element, {
          targetId,
          showIndicatorIds,
          hideIndicatorIds,
          delay,
github Instawork / hyperview / src / core / hyper-ref / index.js View on Github external
triggerLoadBehaviors = () => {
    const behaviorElements = getBehaviorElements(this.props.element);
    const loadBehaviors = behaviorElements.filter(
      e => e.getAttribute(ATTRIBUTES.TRIGGER) === TRIGGERS.LOAD,
    );

    loadBehaviors.forEach(behaviorElement => {
      const handler = this.createActionHandler(
        this.props.element,
        behaviorElement,
        this.props.onUpdate,
      );
      setTimeout(handler, 0);
    });
  };
github Instawork / hyperview / src / components / hv-option / index.js View on Github external
triggerSelectBehaviors = () => {
    const { element, onUpdate } = this.props;
    const behaviorElements = getBehaviorElements(element);
    const selectBehaviors = behaviorElements.filter(
      e => e.getAttribute('trigger') === 'select',
    );
    selectBehaviors.forEach(behaviorElement => {
      const href = behaviorElement.getAttribute('href');
      const action = behaviorElement.getAttribute('action');
      const verb = behaviorElement.getAttribute('verb');
      const targetId = behaviorElement.getAttribute('target');
      const showIndicatorIds = behaviorElement.getAttribute('show-during-load');
      const hideIndicatorIds = behaviorElement.getAttribute('hide-during-load');
      const delay = behaviorElement.getAttribute('delay');
      const once = behaviorElement.getAttribute('once');
      onUpdate(href, action, element, {
        verb,
        targetId,
        showIndicatorIds,