How to use the reakit-system/createComponent.createComponent function in reakit-system

To help you get started, we’ve selected a few reakit-system 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 reakit / reakit / packages / reakit / src / Tab / TabList.tsx View on Github external
export const useTabList = createHook({
  name: "TabList",
  compose: unstable_useIdGroup,
  useState: useTabState,

  useProps(options, htmlProps) {
    return {
      role: "tablist",
      "aria-orientation": options.orientation,
      ...htmlProps
    };
  }
});

export const TabList = createComponent({
  as: "div",
  useHook: useTabList,
  useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/TabList]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/tab"
    );
    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / Menu / MenuSeparator.ts View on Github external
MenuSeparatorOptions,
  MenuSeparatorHTMLProps
>({
  name: "MenuSeparator",
  compose: useSeparator,
  useState: useMenuState,

  useOptions({ orientation = "vertical", ...options }) {
    return {
      orientation: orientation === "vertical" ? "horizontal" : "vertical",
      ...options
    };
  }
});

export const MenuSeparator = createComponent({
  as: "hr",
  useHook: useMenuSeparator
});
github reakit / reakit / packages / reakit / src / Button / Button.ts View on Github external
setRole("button");
        }
        setType(undefined);
      }
    }, []);

    return {
      ref: mergeRefs(ref, htmlRef),
      role,
      type,
      ...htmlProps
    };
  }
});

export const Button = createComponent({
  as: "button",
  useHook: useButton
});
github reakit / reakit / packages / reakit / src / Menu / MenuItemRadio.ts View on Github external
[options.unstable_setValue, options.name]
    );

    return {
      ...options,
      state: options.unstable_values[options.name],
      setState
    };
  },

  useProps(_, htmlProps) {
    return { role: "menuitemradio", ...htmlProps };
  }
});

export const MenuItemRadio = createComponent({
  as: "button",
  useHook: useMenuItemRadio
});
github reakit / reakit / packages / reakit / src / Toolbar / Toolbar.tsx View on Github external
export const useToolbar = createHook({
  name: "Toolbar",
  compose: unstable_useIdGroup,
  useState: useToolbarState,

  useProps(options, htmlProps) {
    return {
      role: "toolbar",
      "aria-orientation": options.orientation,
      ...htmlProps
    };
  }
});

export const Toolbar = createComponent({
  as: "div",
  useHook: useToolbar,
  useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/Toolbar]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/toolbar"
    );
    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / Dialog / DialogDisclosure.ts View on Github external
DialogDisclosureHTMLProps;

export const useDialogDisclosure = createHook<
  DialogDisclosureOptions,
  DialogDisclosureHTMLProps
>({
  name: "DialogDisclosure",
  compose: useHiddenDisclosure,
  useState: useDialogState,

  useProps(_, htmlProps) {
    return { "aria-haspopup": "dialog", ...htmlProps };
  }
});

export const DialogDisclosure = createComponent({
  as: "button",
  useHook: useDialogDisclosure
});
github reakit / reakit / packages / reakit / src / Popover / Popover.ts View on Github external
useState: usePopoverState,

  useOptions({ modal = false, ...options }) {
    return { modal, ...options };
  },

  useProps(options, { ref: htmlRef, style: htmlStyle, ...htmlProps }) {
    return {
      ref: mergeRefs(options.unstable_popoverRef, htmlRef),
      style: { ...options.unstable_popoverStyles, ...htmlStyle },
      ...htmlProps
    };
  }
});

export const Popover = createComponent({
  as: "div",
  useHook: usePopover,
  useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/Popover]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/popover"
    );
    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / Tooltip / TooltipReference.ts View on Github external
}
  ) {
    return {
      ref: mergeRefs(options.unstable_referenceRef, htmlRef),
      tabIndex: 0,
      onFocus: useAllCallbacks(options.show, htmlOnFocus),
      onBlur: useAllCallbacks(options.hide, htmlOnBlur),
      onMouseEnter: useAllCallbacks(options.show, htmlOnMouseEnter),
      onMouseLeave: useAllCallbacks(options.hide, htmlOnMouseLeave),
      "aria-describedby": options.baseId,
      ...htmlProps
    };
  }
});

export const TooltipReference = createComponent({
  as: "div",
  useHook: useTooltipReference
});
github reakit / reakit / packages / reakit / src / Id / Id.tsx View on Github external
options.baseId,
      generateId
    ]);

    const id = options.id || htmlProps.id || `${baseId}${suffix}`;

    return { ...options, id };
  },

  useProps(options, htmlProps) {
    const id = typeof htmlProps.id === "undefined" ? options.id : htmlProps.id;
    return { ...htmlProps, id };
  }
});

export const unstable_Id = createComponent({
  as: "div",
  useHook: unstable_useId
});
github reakit / reakit / packages / reakit / src / Menu / Menu.tsx View on Github external
: dir === "right" && options.hide
              }
            : {}
        }),
      [hasParent, ancestorIsHorizontal, next, previous, dir, options.hide]
    );

    return {
      role: "menu",
      onKeyDown: useAllCallbacks(rovingBindings, parentBindings, htmlOnKeyDown),
      ...htmlProps
    };
  }
});

export const Menu = createComponent({
  as: "div",
  useHook: useMenu,
  useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/Menu]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/menu"
    );
    return useCreateElement(type, props, children);
  }
});