All files / dist/react VgButton.js

10% Statements 1/10
0% Branches 0/7
0% Functions 0/2
10% Lines 1/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40        7x                                                                      
import React, { forwardRef, useRef, useEffect } from "react";
import "../index.js";
import { useEventListener } from "./react-utils.js";
 
export const VgButton = forwardRef((props, forwardedRef) => {
  const ref = useRef(null);
  const { disabled, loading, variant, size, buttonType, ...filteredProps } =
    props;
 
  /** Event listeners - run once */
  useEventListener(ref, "vg-click", props.onVgClick);
 
  return React.createElement(
    "vg-button",
    {
      ref: (node) => {
        ref.current = node;
        if (typeof forwardedRef === "function") {
          forwardedRef(node);
        } else Iif (forwardedRef) {
          forwardedRef.current = node;
        }
      },
      ...filteredProps,
      variant: props.variant,
      size: props.size,
      buttonType: props.buttonType,
      class: props.className,
      exportparts: props.exportparts,
      for: props.htmlFor,
      part: props.part,
      tabindex: props.tabIndex,
      disabled: props.disabled ? "" : undefined,
      loading: props.loading ? "" : undefined,
      style: { ...props.style },
    },
    props.children
  );
});