/** * Copyright 2019, SumUp Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type ButtonHTMLAttributes, type AnchorHTMLAttributes, type ReactNode } from 'react'; import type { IconComponentType } from '@sumup-oss/icons'; import type { ClickEvent } from '../../types/events.js'; import type { AsPropType } from '../../types/prop-types.js'; import type { Locale } from '../../util/i18n.js'; type LinkElProps = Omit, 'onClick'>; type ButtonElProps = Omit, 'onClick'>; export type SharedButtonProps = LinkElProps & ButtonElProps & { /** * Choose from 3 style variants. Default: 'secondary'. */ 'variant'?: 'primary' | 'secondary' | 'tertiary'; /** * Choose from 2 sizes. Default: 'm'. */ 'size'?: 's' | 'm' /** * @deprecated */ | 'kilo' /** * @deprecated */ | 'giga'; /** * Visually and functionally disable the button. */ 'disabled'?: boolean; /** * Change the color from accent to danger to signal to the user that the action * is irreversible or otherwise dangerous. */ 'destructive'?: boolean; /** * The HTML button type */ 'type'?: 'button' | 'submit' | 'reset' | undefined; /** * Function that's called when the button is clicked. */ 'onClick'?: (event: ClickEvent) => void; 'data-testid'?: string; /** * Visually disables the button and shows a loading spinner. */ 'isLoading'?: boolean; /** * Visually hidden label to communicate the loading state to visually * impaired users. */ 'loadingLabel'?: string; /** * Render the Button using any element. */ 'as'?: AsPropType; /** * One or more [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) * locale identifiers such as `'de-DE'` or `['GB', 'en-US']`. * When passing an array, the first supported locale is used. * Defaults to `navigator.language` in supported environments. */ locale?: Locale; }; type CreateButtonComponentProps = SharedButtonProps & { /** * Communicates the action that will be performed when the user interacts * with the button. Use one strong, clear imperative verb and follow with a * one-word object if needed to clarify. */ children: ReactNode; /** * Choose from 2 sizes. Default: 'm'. */ size?: 's' | 'm'; /** * An icon provides additional context for the button, such as a “search” * icon next to the label for a search field submission. */ icon?: IconComponentType; /** * A navigation icon hints that the button will perform an unexpected action, * such as opening a dropdown or navigating the user to a new tab, so make * sure you use them only when necessary. Navigation icons are not an * alternative to leading icons and should not be used to provide additional * context for the button. */ navigationIcon?: IconComponentType; }; export declare const legacyButtonSizeMap: Record; export declare function createButtonComponent(componentName: string, mapProps: (props: Props) => CreateButtonComponentProps): import("react").ForwardRefExoticComponent & import("react").RefAttributes>; export {};