react-popper#Manager TypeScript Examples

The following examples show how to use react-popper#Manager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PopperWrapper.tsx    From design-system with MIT License 6 votes vote down vote up
render() {
    const { placement, appendToBody, hide, boundaryElement } = this.props;
    const { animationKeyframe, isOpen } = this.state;

    return (
      <Manager>
        <style>{animationKeyframe}</style>
        <Reference innerRef={this.triggerRef}>{({ ref }) => this.getTriggerElement(ref)}</Reference>
        {isOpen &&
          appendToBody &&
          ReactDOM.createPortal(
            <Popper
              placement={placement}
              innerRef={this.popupRef}
              modifiers={{
                preventOverflow: { boundariesElement: boundaryElement || document.body },
                hide: { enabled: hide },
              }}
            >
              {this.getPopperChildren}
            </Popper>,
            document.body
          )}
        {isOpen && !appendToBody && (
          <Popper placement={placement} innerRef={this.popupRef}>
            {this.getPopperChildren}
          </Popper>
        )}
      </Manager>
    );
  }
Example #2
Source File: Popover.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
render() {
    const {
      content,
      show,
      placement,
      onMouseEnter,
      onMouseLeave,
      className,
      wrapperClassName,
      renderArrow,
      referenceElement,
      eventsEnabled,
    } = this.props;

    return (
      <Manager>
        <Transition in={show} timeout={100} mountOnEnter={true} unmountOnExit={true}>
          {transitionState => {
            return (
              <Portal>
                <ReactPopper
                  placement={placement}
                  referenceElement={referenceElement}
                  eventsEnabled={eventsEnabled}
                  // TODO: move modifiers config to popper controller
                  modifiers={{ preventOverflow: { enabled: true, boundariesElement: 'window' } }}
                >
                  {({ ref, style, placement, arrowProps, scheduleUpdate }) => {
                    return (
                      <div
                        onMouseEnter={onMouseEnter}
                        onMouseLeave={onMouseLeave}
                        ref={ref}
                        style={{
                          ...style,
                          ...defaultTransitionStyles,
                          ...transitionStyles[transitionState],
                        }}
                        data-placement={placement}
                        className={`${wrapperClassName}`}
                      >
                        <div className={className}>
                          {typeof content === 'string' && content}
                          {React.isValidElement(content) && React.cloneElement(content)}
                          {typeof content === 'function' &&
                            content({
                              updatePopperPosition: scheduleUpdate,
                            })}
                          {renderArrow &&
                            renderArrow({
                              arrowProps,
                              placement,
                            })}
                        </div>
                      </div>
                    );
                  }}
                </ReactPopper>
              </Portal>
            );
          }}
        </Transition>
      </Manager>
    );
  }