How to use the @zendeskgarden/react-theming.getDocument function in @zendeskgarden/react-theming

To help you get started, we’ve selected a few @zendeskgarden/react-theming 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 zendeskgarden / react-components / packages / selection / src / containers / SelectionContainer.js View on Github external
componentDidUpdate(prevProps, prevState) {
    const current = this.props.focusedKey === undefined ? this.state : this.props;
    const prev = prevProps.focusedKey === undefined ? prevState : prevProps;
    const doc = getDocument ? getDocument(this.props) : document;

    /**
     * We must programatically scroll the newly focused element into view.
     * Side-effect of the `aria-activedescendant` accessibility strategy.
     */
    if (typeof current.focusedKey !== 'undefined' && current.focusedKey !== prev.focusedKey) {
      const itemNode = doc.getElementById(this.getItemId(current.focusedKey));

      /* istanbul ignore if */
      if (itemNode) {
        scrollTo(itemNode);
      }
    }
  }
github zendeskgarden / react-components / packages / menus / src / containers / MenuContainer.js View on Github external
getDocuments = () => {
    const doc = getDocument ? getDocument(this.props) : document;
    const iframes = doc.querySelectorAll('iframe');

    return [...iframes].reduce(
      (documents, iframe) => {
        try {
          if (iframe.contentDocument) {
            return [...documents, iframe.contentDocument];
          }
        } catch (e) {} // eslint-disable-line no-empty

        return documents;
      },
      [doc]
    );
  };
github zendeskgarden / react-components / packages / autocomplete / src / containers / AutocompleteContainer.js View on Github external
componentDidUpdate(prevProps, prevState) {
    const { focusedKey } = this.getControlledState();
    const previousFocusedKey = this.isControlledProp('focusedKey')
      ? prevProps.focusedKey
      : prevState.focusedKey;

    /**
     * We must programatically scroll the newly focused element into view.
     * Side-effect of the `aria-activedescendant` accessibility strategy.
     */
    if (typeof focusedKey !== 'undefined' && focusedKey !== previousFocusedKey) {
      const doc = getDocument ? getDocument(this.props) : document;
      const itemNode = doc.getElementById(this.getItemId(focusedKey));

      /* istanbul ignore if */
      if (itemNode) {
        setTimeout(() => {
          scrollTo(itemNode);
        }, 0);
      }
    }
  }
github zendeskgarden / react-components / packages / modals / src / containers / FocusJailContainer.js View on Github external
getInitialFocusNode = () => {
    const doc = getDocument ? getDocument(this.props) : document;
    const activeElem = activeElement(doc);

    return this.container.contains(activeElem) ? activeElem : this.container;
  };
github zendeskgarden / react-components / packages / ranges / src / elements / MultiThumbRange.js View on Github external
addDragEvents = () => {
    const themedDocument = getDocument(this.props);

    themedDocument.addEventListener('mousemove', this.onDocumentMouseMove);
    themedDocument.addEventListener('mouseup', this.removeDragEvents);
  };
github zendeskgarden / react-components / packages / forms / src / fields / MultiThumbRange.js View on Github external
minValue,
  maxValue,
  disabled,
  step,
  onChange,
  ...otherProps
}) => {
  const [isMinThumbFocused, setIsMinThumbFocused] = useState(false);
  const [isMaxThumbFocused, setIsMaxThumbFocused] = useState(false);
  const [railWidthPx, setRailWidthPx] = useState(0);
  const [isMousedDown, setIsMousedDown] = useState(false);
  const trackRailRef = useRef();
  const minThumbRef = useRef();
  const maxThumbRef = useRef();

  const themedDocument = getDocument(otherProps);
  const rtl = isRtl(otherProps);

  /**
   * The window resize event is debounced to reduce unnecessary renders
   */
  const onWindowResize = useCallback(
    debounce(() => {
      setRailWidthPx(trackRailRef.current.getBoundingClientRect().width);
    }, 100),
    []
  );

  useEffect(() => {
    onWindowResize();

    window.addEventListener('resize', onWindowResize);
github zendeskgarden / react-components / packages / ranges / src / elements / MultiThumbRange.js View on Github external
removeDragEvents = () => {
    const themedDocument = getDocument(this.props);

    themedDocument.removeEventListener('mousemove', this.onDocumentMouseMove);
    themedDocument.removeEventListener('mouseup', this.removeDragEvents);
  };
github zendeskgarden / react-components / packages / tooltips / src / elements / Tooltip.js View on Github external
};
            const TooltipElem = type === TYPE.LIGHT ? LightTooltip : TooltipView;

            const tooltip = (
              
                {children}
              
            );

            if (appendToBody) {
              return createPortal(tooltip, getDocument(otherProps).body);
            }

            return tooltip;
          }}