UNPKG

@neo4j-ndl/react

Version:

React implementation of Neo4j Design System

70 lines (69 loc) 2.29 kB
/** * * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] * * This file is part of Neo4j. * * Neo4j is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import React from 'react'; import { type HtmlAttributes, type PolymorphicForwardRefExoticComponent } from '../_common/types'; /** * * * Types * * */ type ButtonTypes = 'submit' | 'button' | 'reset'; export type ButtonSizes = 'small' | 'medium' | 'large'; type BaseButtonProps = { children: string | React.ReactNode; /** If the button is doing something Async, it will display a loading spinner */ isLoading?: boolean; /** If the button is in disabled state */ isDisabled?: boolean; /** Type of button */ type?: ButtonTypes; /** Size of button */ size?: ButtonSizes; /** If the button is in floating state */ isFloating?: boolean; /** onClick callback*/ onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; /** OnKeyDown callback */ onKeyDown?: (e: React.KeyboardEvent<HTMLButtonElement>) => void; } & ({ as: 'a'; href: HtmlAttributes<'a'>['href']; target?: HtmlAttributes<'a'>['target']; } | { as?: React.ElementType; }); type OutlinedButtonProps = BaseButtonProps & { fill: 'outlined'; color?: 'primary' | 'danger' | 'neutral'; }; type TextButtonProps = BaseButtonProps & { fill: 'text'; color?: 'primary' | 'danger'; }; type FilledButtonProps = BaseButtonProps & { fill?: 'filled'; color?: 'primary' | 'danger'; }; export type ButtonProps = OutlinedButtonProps | TextButtonProps | FilledButtonProps; export declare const Button: PolymorphicForwardRefExoticComponent<'button', ButtonProps>; export {};