Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -14,30 +14,31 @@
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { HTMLAttributes, InputHTMLAttributes, ReactHTML, ReactNode } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import React, { HTMLAttributes, InputHTMLAttributes, ReactHTML, ReactNode } from "react";
|
||||
import classnames from "classnames";
|
||||
|
||||
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
|
||||
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
||||
|
||||
export type ButtonEvent = React.MouseEvent<Element> | React.KeyboardEvent<Element> | React.FormEvent<Element>;
|
||||
|
||||
type AccessibleButtonKind = | 'primary'
|
||||
| 'primary_outline'
|
||||
| 'primary_sm'
|
||||
| 'secondary'
|
||||
| 'secondary_content'
|
||||
| 'content_inline'
|
||||
| 'danger'
|
||||
| 'danger_outline'
|
||||
| 'danger_sm'
|
||||
| 'danger_inline'
|
||||
| 'link'
|
||||
| 'link_inline'
|
||||
| 'link_sm'
|
||||
| 'confirm_sm'
|
||||
| 'cancel_sm'
|
||||
| 'icon';
|
||||
type AccessibleButtonKind =
|
||||
| "primary"
|
||||
| "primary_outline"
|
||||
| "primary_sm"
|
||||
| "secondary"
|
||||
| "secondary_content"
|
||||
| "content_inline"
|
||||
| "danger"
|
||||
| "danger_outline"
|
||||
| "danger_sm"
|
||||
| "danger_inline"
|
||||
| "link"
|
||||
| "link_inline"
|
||||
| "link_sm"
|
||||
| "confirm_sm"
|
||||
| "cancel_sm"
|
||||
| "icon";
|
||||
|
||||
/**
|
||||
* This type construct allows us to specifically pass those props down to the element we’re creating that the element
|
||||
|
@ -49,9 +50,10 @@ type AccessibleButtonKind = | 'primary'
|
|||
*/
|
||||
type DynamicHtmlElementProps<T extends keyof JSX.IntrinsicElements> =
|
||||
JSX.IntrinsicElements[T] extends HTMLAttributes<{}> ? DynamicElementProps<T> : DynamicElementProps<"div">;
|
||||
type DynamicElementProps<T extends keyof JSX.IntrinsicElements> =
|
||||
Partial<Omit<JSX.IntrinsicElements[T], 'ref' | 'onClick' | 'onMouseDown' | 'onKeyUp' | 'onKeyDown'>>
|
||||
& Omit<InputHTMLAttributes<Element>, 'onClick'>;
|
||||
type DynamicElementProps<T extends keyof JSX.IntrinsicElements> = Partial<
|
||||
Omit<JSX.IntrinsicElements[T], "ref" | "onClick" | "onMouseDown" | "onKeyUp" | "onKeyDown">
|
||||
> &
|
||||
Omit<InputHTMLAttributes<Element>, "onClick">;
|
||||
|
||||
/**
|
||||
* children: React's magic prop. Represents all children given to the element.
|
||||
|
@ -156,23 +158,19 @@ export default function AccessibleButton<T extends keyof JSX.IntrinsicElements>(
|
|||
// Pass through the ref - used for keyboard shortcut access to some buttons
|
||||
newProps.ref = inputRef;
|
||||
|
||||
newProps.className = classnames(
|
||||
"mx_AccessibleButton",
|
||||
className,
|
||||
{
|
||||
"mx_AccessibleButton_hasKind": kind,
|
||||
[`mx_AccessibleButton_kind_${kind}`]: kind,
|
||||
"mx_AccessibleButton_disabled": disabled,
|
||||
},
|
||||
);
|
||||
newProps.className = classnames("mx_AccessibleButton", className, {
|
||||
mx_AccessibleButton_hasKind: kind,
|
||||
[`mx_AccessibleButton_kind_${kind}`]: kind,
|
||||
mx_AccessibleButton_disabled: disabled,
|
||||
});
|
||||
|
||||
// React.createElement expects InputHTMLAttributes
|
||||
return React.createElement(element, newProps, children);
|
||||
}
|
||||
|
||||
AccessibleButton.defaultProps = {
|
||||
element: 'div' as keyof ReactHTML,
|
||||
role: 'button',
|
||||
element: "div" as keyof ReactHTML,
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue