UNPKG

4.16 kBTypeScriptView Raw
1import type * as React from "react";
2import type { IconName } from "@blueprintjs/icons";
3import type { Intent } from "./intent";
4export declare const DISPLAYNAME_PREFIX = "Blueprint5";
5/**
6 * Alias for all valid HTML props for `<div>` element.
7 * Does not include React's `ref` or `key`.
8 */
9export type HTMLDivProps = React.HTMLAttributes<HTMLDivElement>;
10/**
11 * Alias for all valid HTML props for `<input>` element.
12 * Does not include React's `ref` or `key`.
13 */
14export type HTMLInputProps = React.InputHTMLAttributes<HTMLInputElement>;
15/**
16 * Alias for a `React.JSX.Element` or a value that renders nothing.
17 *
18 * In React, `boolean`, `null`, and `undefined` do not produce any output.
19 */
20export type MaybeElement = React.JSX.Element | false | null | undefined;
21/**
22 * A shared base interface for all Blueprint component props.
23 */
24export interface Props {
25 /** A space-delimited list of class names to pass along to a child element. */
26 className?: string;
27}
28export interface IntentProps {
29 /** Visual intent color to apply to element. */
30 intent?: Intent;
31}
32/**
33 * Interface for a clickable action, such as a button or menu item.
34 * These props can be spready directly to a `<Button>` or `<MenuItem>` element.
35 *
36 * @template T type of the DOM element rendered by this component
37 */
38export interface ActionProps<T extends HTMLElement = HTMLElement> extends IntentProps, Props {
39 /** Whether this action is non-interactive. */
40 disabled?: boolean;
41 /** Name of a Blueprint UI icon (or an icon element) to render before the text. */
42 icon?: IconName | MaybeElement;
43 /** Click event handler. */
44 onClick?: (event: React.MouseEvent<T>) => void;
45 /** Focus event handler. */
46 onFocus?: (event: React.FocusEvent<T>) => void;
47 /** Action text. Can be any single React renderable. */
48 text?: React.ReactNode;
49}
50/** Interface for a link, with support for customizing target window. */
51export interface LinkProps {
52 /** Link URL. */
53 href?: string;
54 /** Link target attribute. Use `"_blank"` to open in a new window. */
55 target?: React.HTMLAttributeAnchorTarget;
56}
57/**
58 * Interface for a controlled or uncontrolled component, typically a form control.
59 */
60export interface ControlledValueProps<T, E extends HTMLElement = HTMLElement> {
61 /**
62 * Initial value for uncontrolled usage. Mutually exclusive with `value` prop.
63 */
64 defaultValue?: T;
65 /**
66 * Controlled value. Mutually exclusive with `defaultValue` prop.
67 */
68 value?: T;
69 /**
70 * Callback invoked when the component value changes, typically via user interaction, in both controlled and
71 * uncontrolled mode.
72 *
73 * Using this prop instead of `onChange` can help avoid common bugs in React 16 related to Event Pooling
74 * where developers forget to save the text value from a change event or call `event.persist()`.
75 *
76 * @see https://legacy.reactjs.org/docs/legacy-event-pooling.html
77 */
78 onValueChange?: (value: T, targetElement: E | null) => void;
79}
80/** @deprecated use `ControlledValueProps` */
81export type ControlledProps = Omit<ControlledValueProps<string, HTMLInputElement>, "onChange">;
82export interface OptionProps<T extends string | number = string | number> extends Props {
83 /** Whether this option is non-interactive. */
84 disabled?: boolean;
85 /** Label text for this option. If omitted, `value` is used as the label. */
86 label?: string;
87 /** Value of this option. */
88 value: T;
89}
90/**
91 * Typically applied to HTMLElements to filter out disallowed props. When applied to a Component,
92 * can filter props from being passed down to the children. Can also filter by a combined list of
93 * supplied prop keys and the denylist (only appropriate for HTMLElements).
94 *
95 * @param props The original props object to filter down.
96 * @param {string[]} invalidProps If supplied, overwrites the default denylist.
97 * @param {boolean} shouldMerge If true, will merge supplied invalidProps and denylist together.
98 */
99export declare function removeNonHTMLProps(props: {
100 [key: string]: any;
101}, invalidProps?: string[], shouldMerge?: boolean): {
102 [key: string]: any;
103};