@restart/ui
Advanced tools
Comparing version 0.2.1 to 0.2.2
import * as React from 'react'; | ||
export declare function isTrivialHref(href?: string): boolean; | ||
export interface AnchorProps extends React.HTMLAttributes<HTMLElement> { | ||
@@ -3,0 +4,0 @@ href?: string; |
"use strict"; | ||
exports.__esModule = true; | ||
exports.isTrivialHref = isTrivialHref; | ||
exports.default = void 0; | ||
@@ -22,2 +23,6 @@ | ||
function isTrivialHref(href) { | ||
return !href || href.trim() === '#'; | ||
} | ||
/** | ||
@@ -41,3 +46,3 @@ * An generic `<a>` component that covers a few A11y cases, ensuring that | ||
if ((0, _Button.isTrivialHref)(props.href) && !props.role || props.role === 'button') { | ||
if (isTrivialHref(props.href) && !props.role || props.role === 'button') { | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", Object.assign({ | ||
@@ -44,0 +49,0 @@ ref: ref |
@@ -54,3 +54,3 @@ "use strict"; | ||
const handleClick = event => { | ||
if (disabled || isTrivialHref(href)) { | ||
if (disabled || tagName === 'a' && isTrivialHref(href)) { | ||
event.preventDefault(); | ||
@@ -57,0 +57,0 @@ } |
import * as React from 'react'; | ||
export declare function isTrivialHref(href?: string): boolean; | ||
export interface AnchorProps extends React.HTMLAttributes<HTMLElement> { | ||
@@ -3,0 +4,0 @@ href?: string; |
@@ -10,4 +10,7 @@ const _excluded = ["onKeyDown"]; | ||
import { useEventCallback } from '@restart/hooks'; | ||
import { useButtonProps, isTrivialHref } from './Button'; | ||
import { useButtonProps } from './Button'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
export function isTrivialHref(href) { | ||
return !href || href.trim() === '#'; | ||
} | ||
@@ -14,0 +17,0 @@ /** |
@@ -40,3 +40,3 @@ const _excluded = ["as", "disabled"]; | ||
const handleClick = event => { | ||
if (disabled || isTrivialHref(href)) { | ||
if (disabled || tagName === 'a' && isTrivialHref(href)) { | ||
event.preventDefault(); | ||
@@ -43,0 +43,0 @@ } |
{ | ||
"name": "@restart/ui", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Utilities for creating robust overlay components", | ||
@@ -5,0 +5,0 @@ "author": { |
318753
7619