Base class helpers for the updating state of a component.
433908
function ReactComponent(props, context, updater) {
  this.props = props;
  this.context = context;
  this.refs = emptyObject;
  // We initialize the default updater but the real one gets injected by the
  // renderer.
  this.updater = updater || ReactNoopUpdateQueue_1;
}
1154144
def _update_const_classes():
    """"""
    klasses = (bool, int, float, complex, str, bytes)
    for kls in klasses:
        CONST_CLS[kls] = Const
553324
def _on_state_changed(self):
        """"""
        raw_state, generation = self.state.raw_state_and_generation
        if generation != self._last_generation:
            self._last_generation = generation
            self._send_update(raw_state, generation)
561707
function componentUpdate(tag, data, expressions) {
      var __ = tag.__;
      var nextOpts = {};
      var canTrigger = tag.isMounted && !__.skipAnonymous;

      // inherit properties from the parent tag
      if (__.isAnonymous && __.parent) { extend(tag, __.parent); }
      extend(tag, data);

      updateOpts.apply(tag, [__.isLoop, __.parent, __.isAnonymous, nextOpts, __.instAttrs]);

      if (
        canTrigger &&
        tag.isMounted &&
        isFunction$1(tag.shouldUpdate) && !tag.shouldUpdate(data, nextOpts)
      ) {
        return tag
      }

      extend(tag.opts, nextOpts);

      if (canTrigger) { tag.trigger('update', data); }
      update.call(tag, expressions);
      if (canTrigger) { tag.trigger('updated'); }

      return tag
    }
652522
def ensure_state(default_getter, exc_class, default_msg=None):
    """"""
    def decorator(getter=default_getter, msg=default_msg):
        def ensure_decorator(f):
            @wraps(f)
            def inner(self, *args, **kwargs):
                if not getter(self):
                    raise exc_class(msg) if msg else exc_class()
                return f(self, *args, **kwargs)
            return inner
        return ensure_decorator
    return decorator
849072
function diffUpdateTriggers(props, oldProps) {
  if (oldProps === null) {
    return 'oldProps is null, initial diff';
  }

  // If the 'all' updateTrigger fires, ignore testing others
  if ('all' in props.updateTriggers) {
    const diffReason = diffUpdateTrigger(props, oldProps, 'all');
    if (diffReason) {
      return {all: true};
    }
  }

  const triggerChanged = {};
  let reason = false;
  // If the 'all' updateTrigger didn't fire, need to check all others
  for (const triggerName in props.updateTriggers) {
    if (triggerName !== 'all') {
      const diffReason = diffUpdateTrigger(props, oldProps, triggerName);
      if (diffReason) {
        triggerChanged[triggerName] = true;
        reason = triggerChanged;
      }
    }
  }

  return reason;
}
384120
function componentUpdated(el, _ref2) {
      var modifiers = _ref2.modifiers;

      var target;
      target = modifiers.children ? Array.from(el.children) : el;
      return balanceText(target);
    }
795708
function(publicInstance, partialProps) {
    var internalInstance = getInternalInstanceReadyForUpdate(
      publicInstance,
      'setProps'
    );

    if (!internalInstance) {
      return;
    }

    ("production" !== process.env.NODE_ENV ? invariant(
      internalInstance._isTopLevel,
      'setProps(...): You called `setProps` on a ' +
      'component with a parent. This is an anti-pattern since props will ' +
      'get reactively updated when rendered. Instead, change the owner\'s ' +
      '`render` method to pass the correct value as props to the component ' +
      'where it is created.'
    ) : invariant(internalInstance._isTopLevel));

    // Merge with the pending element if it exists, otherwise with existing
    // element props.
    var element = internalInstance._pendingElement ||
                  internalInstance._currentElement;
    var props = assign({}, element.props, partialProps);
    internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
      element,
      props
    );

    enqueueUpdate(internalInstance);
  }
95371
function( nextProps, nextState ) {
		this._container.setState( nextState );
		this._originalComponentWillUpdate.call( this._reactComponent, nextProps, nextState );
	}
720671
function() {
      var t = this;
      t.saveChanges();

      // Open the new component dialog if no components exist
      if (t.model.get('components').length === 0) {
        t.pageView.newComponent();
      }
    }
1266569
function _update (state, vel) {
  // NOTE: this method might look a bit monstrous because of the rather complex
  // branching structure. However, we want to avoid extra recursion or separation
  // into functions for sake of shorter stack-traces when debugging

  if (state.is(SKIPPED, vel)) return
  // console.log('... rendering', vel._ref)

  let comp = vel._comp

  // HACK: workaround for a problem found in DEBUG_RENDERING mode
  // situation: a grand-parent injects via props a child component into a parent
  // component, which does render the children only in certain states (e.g. showChild=true|false)
  // changing the state from hide to show on the parent component, caused errors here
  // It would be more consistent to do this during the capturing phase of
  // vel._preliminaryParent, i.e. the one that has appends injected component.
  // TODO: decide if this really a HACK
  if (!comp) {
    if (vel._ref && vel._preliminaryParent !== vel._owner) {
      _capture(state, vel)
    }
  }
  console.assert(comp && comp._isComponent, 'A captured VirtualElement must have a component instance attached.')

  // special handling of forwarding elements which don't have their own element
  // but are delegating to their child
  if (vel._isForwarding) {
    _update(state, vel._forwardedEl)
  } else {
    // render the element
    if (!comp.el) {
      comp.el = _createDOMElement(state, vel)
    } else {
      let el = comp.el
      console.assert(el, "Component's element should exist at this point.")
      _updateDOMElement(el, vel)
    }

    // TODO: to allow mounting a prerendered DOM element
    // we would need to allow to 'take ownership' instead of removing
    // the element. This being a special situation, we should only
    // do that when mounting

    // structural updates are necessary only for non-forwarding Components and HTML elements without innerHTML
    if ((vel._isVirtualComponent || vel._isVirtualHTMLElement) && !vel.hasInnerHTML()) {
      let newChildren = vel.children

      // remove all elements from the DOM which are not linked to a component
      // or which we know have been relocated
      // ATTENTION: removing the elements of relocated components
      // in advance, then the algorithm later becomes easier only considering
      // add and remove.
      let _childNodes = comp.el.getChildNodes()
      let oldChildren = _childNodes.map(child => {
        let childComp = child._comp
        // NOTE: don't know why, but sometimes it happens that there appear elements that are not rendered via Component.js
        if (!childComp) {
          comp.el.removeChild(child)
          return null
        }
        // EXPERIMENTAL: trying to get forwarding components right.
        // the problem is that on the DOMElement level, forwarding components are not
        // 'visible', as they do not have an own element.
        // Here we are taking the owner of an element when it isForwarded
        // bubbling up the parent hierarchy.
        if (childComp._isForwarded()) {
          childComp = _findForwardingChildOfComponent(comp, childComp)
        }
        // remove orphaned nodes and relocated components
        if (!childComp || state.is(RELOCATED, childComp)) {
          comp.el.removeChild(child)
          return null
        } else {
          return childComp
        }
      }).filter(Boolean)

      // TODO: it might be easier to understand to separate DOM analysis, i.e.
      // what to do with the DOM, from the actual DOM manipulation.
      // The former could be described as a set of DOM operations, which would then
      // interpreted by the latter
      let pos1 = 0; let pos2 = 0
      while (pos1 < oldChildren.length || pos2 < newChildren.length) {
        let oldComp
        // skip detached components
        // Note: components get detached when preserved nodes
        // are found in a swapped order. Then the only way is
        // to detach one of them from the DOM, and reinsert it later at the new
        // position
        do {
          oldComp = oldChildren[pos1++]
        } while (oldComp && (state.is(DETACHED, oldComp)))

        let newVel = newChildren[pos2++]
        // remove remaining old ones if no new one is left
        if (oldComp && !newVel) {
          while (oldComp) {
            _removeChild(state, comp, oldComp)
            oldComp = oldChildren[pos1++]
          }
          break
        }

        // reuse TextNodes to avoid unnecesary DOM manipulations
        if (oldComp && oldComp.el.isTextNode() &&
            newVel && newVel._isVirtualTextNode &&
            oldComp.el.textContent === newVel.text) {
          continue
        }

        // ATTENTION: here we are linking two HTML elements opportunistically on the fly
        // Note, that !state.is(MAPPED) means that both elements do not contain
        // any refs or components, and are thus save to be reused
        // TODO: we should find out if this is really something we want to do
        // or stick to primitive rendering for sake of performance
        if (oldComp && oldComp._isElementComponent &&
            newVel._isVirtualHTMLElement &&
            !state.is(MAPPED, oldComp) && !state.is(MAPPED, newVel) &&
            oldComp.tagName === newVel.tagName) {
          // linking
          newVel._comp = oldComp
          state.set(LINKED, newVel)
          state.set(LINKED, oldComp)
          _update(state, newVel)
          continue
        }

        // update virtual component recursively
        if (!state.is(RENDERED, newVel)) {
          _update(state, newVel)
        }

        let newComp = newVel._comp
        // nothing more to do if components are equal, i.e. component and virtual component have been linked during capturing
        if (newComp === oldComp) {
          continue
        }
        // update the parent for relocated components
        // ATTENTION: relocating a component does not update its context
        if (state.is(RELOCATED, newComp)) {
          newComp._setParent(comp)
        }
        console.assert(newComp, 'Component instance should now be available.')

        // append remaining new ones if no old one is left
        if (newVel && !oldComp) {
          _appendChild(state, comp, newComp)
          continue
        }

        // Differential update
        if (state.is(LINKED, newVel)) {
          if (state.is(LINKED, oldComp)) {
            // the order of elements with ref has changed
            state.set(DETACHED, oldComp)
            _removeChild(state, comp, oldComp)
            pos2--
          // the old one could not be mapped, thus can be removed
          } else {
            _removeChild(state, comp, oldComp)
            pos2--
          }
        } else if (state.is(LINKED, oldComp)) {
          _insertChildBefore(state, comp, newComp, oldComp)
          pos1--
        } else {
          // both elements are not mapped
          // TODO: we could try to reuse components if they are of same type
          // However, this needs a more involved mapping strategy, and/or a change
          // in the order of this iteration. At this point it is already too late
          // because the recursive update has already been done, not reusing the existing elements
          _replaceChild(state, comp, oldComp, newComp)
        }
      }
    }
  }

  if (vel._isVirtualComponent) {
    _storeInternalData(comp, vel)

    // using the element of the forwarded component as element for this component
    if (vel._forwardedEl) {
      let forwardedComp = vel._forwardedEl._comp
      // TODO: is this really the correct time to call didMount? shouldn't this
      // be called when processed by the parent?
      // TODO: this will not work with multiple forwarded components
      if (!comp.el) {
        comp.el = forwardedComp.el
        // forwardedComp.triggerDidMount()
        // comp.triggerDidMount()
      } else {
        // EXPERIMENTAL: the forwarded comp has been updated
        let oldForwardedComp = comp.el._comp
        if (oldForwardedComp !== forwardedComp) {
          oldForwardedComp.triggerDispose()
          comp.el.parentNode.replaceChild(comp.el, forwardedComp.el)
          comp.el = forwardedComp.el
          forwardedComp.triggerDidMount()
        }
      }
    }
  }

  state.set(RENDERED, vel)
  state.set(RENDERED, comp)
}
297948
function componentWrapper( WrappedComponent, keys = ALL_KEYS ) {

  class KeyBoardHelper extends React.Component {

    constructor( props ) {
      super( props );
      this.state = {
        event: null
      };
    }

    componentDidMount() {
      onMount( this );
    }

    componentWillUnmount() {
      onUnmount( this );
    }

    handleKeyDown( event ) {
      // to simulate a keypress, set the event and then clear it in the callback
      this.setState( { event }, () => this.setState( { event: null } ) );
    }

    render() {
      return <WrappedComponent {...this.props} keydown={this.state} />;
    }
  }

  store.setBinding( { keys: [].concat( keys ), fn: KeyBoardHelper.prototype.handleKeyDown, target: KeyBoardHelper.prototype } );

  return KeyBoardHelper;
}
733762
function ReactPureComponent(props, context, updater) {
  // Duplicated from ReactComponent.
  this.props = props;
  this.context = context;
  this.refs = emptyObject;
  // We initialize the default updater but the real one gets injected by the
  // renderer.
  this.updater = updater || ReactNoopUpdateQueue;
}
1034705
function(newProps) {
        if (this.getInitialState) {
            if (this.getInitialProps) {
                newProps = this.getInitialProps(newProps) || {};
            }
            var newState = this.getInitialState(newProps);
            this.replaceState(newState);
            return;
        }

        if (!this.__newProps) {
            updateManager.queueWidgetUpdate(this);
        }

        this.__newProps = newProps;
    }
868039
function(
    component,
    keys_to_watch_for_changes,
    additonal_callback = null
  ) {
    if (!Array.isArray(keys_to_watch_for_changes)) {
      throw keys_to_watch_for_changes + ' must be an array'
    }
    component.state = component.state || {} // initialize if not set

    // call this function whenever the store changes
    function _callback(changed_keys) {
      if (intersection(keys_to_watch_for_changes, changed_keys).length) {
        // only update the state if a key we care about has changed
        let state_update_obj = {}
        keys_to_watch_for_changes.forEach(k => (state_update_obj[k] = store._store[k]))
        this.setState(state_update_obj)

        // if some other custom callback is required by the component
        // call that function as well
        if (additonal_callback) {
          additonal_callback(changed_keys)
        }
      }
    }
    let callback_bound_to_component = _callback.bind(component)

    // add keys that map to the store's keys
    for (let k of keys_to_watch_for_changes) {
      if (!store._store.hasOwnProperty(k)) {
        throw 'Store does not have key ' + k
      }
      if (component.state.hasOwnProperty(k)) {
        console.warn('Overwriting existing state key ' + k)
      }
      component.state[k] = store._store[k]

      store._recordKeySubscriber(k, component.constructor.name)
    }
    return store.subscribe(callback_bound_to_component)
  }
900850
function (Class, descriptors) {
    ClassFactory.prototype.updateDynamicFunctions.call(this, Class, descriptors);
    if (!Class.cast || Class.cast.isAutoGenerated) {
      Class.cast = this.createStaticCast(Class, descriptors);
    }
    if (!Class.validate || Class.validate.isAutoGenerated) {
      Class.validate = this.createStaticValidate(Class, descriptors);
    }
    if (!Class.input || Class.input.isAutoGenerated) {
      Class.input = this.createStaticInput(Class, descriptors);
    }
    if (!Class.toJSON || Class.toJSON.isAutoGenerated) {
      Class.toJSON = this.createStaticToJSON(Class, descriptors);
    }
  }
1029819
def update(details)
      details.each do |k, v|
        send("#{k}=", v)
      end
      self.class.update(component_key, details)
    end