Stabilise types
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
830aebd258
commit
f8ece0b57c
14 changed files with 77 additions and 87 deletions
|
@ -8,25 +8,24 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps, forwardRef, Ref } from "react";
|
import React, { forwardRef, Ref } from "react";
|
||||||
|
|
||||||
import AccessibleButton from "../../components/views/elements/AccessibleButton";
|
import AccessibleButton, { ButtonProps } from "../../components/views/elements/AccessibleButton";
|
||||||
|
|
||||||
type Props<T extends keyof JSX.IntrinsicElements> = ComponentProps<typeof AccessibleButton<T>> & {
|
type Props<T extends keyof HTMLElementTagNameMap> = ButtonProps<T> & {
|
||||||
label?: string;
|
label?: string;
|
||||||
// whether the context menu is currently open
|
// whether the context menu is currently open
|
||||||
isExpanded: boolean;
|
isExpanded: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Semantic component for representing the AccessibleButton which launches a <ContextMenu />
|
// Semantic component for representing the AccessibleButton which launches a <ContextMenu />
|
||||||
export const ContextMenuButton = forwardRef(function <T extends keyof JSX.IntrinsicElements>(
|
export const ContextMenuButton = forwardRef(function <T extends keyof HTMLElementTagNameMap>(
|
||||||
{ label, isExpanded, children, onClick, onContextMenu, element, ...props }: Props<T>,
|
{ label, isExpanded, children, onClick, onContextMenu, ...props }: Props<T>,
|
||||||
ref: Ref<HTMLElement>,
|
ref: Ref<HTMLElementTagNameMap[T]>,
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
{...props}
|
{...props}
|
||||||
element={element as keyof JSX.IntrinsicElements}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onContextMenu={onContextMenu ?? onClick ?? undefined}
|
onContextMenu={onContextMenu ?? onClick ?? undefined}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
|
|
|
@ -8,24 +8,23 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps, forwardRef, Ref } from "react";
|
import React, { forwardRef, Ref } from "react";
|
||||||
|
|
||||||
import AccessibleButton from "../../components/views/elements/AccessibleButton";
|
import AccessibleButton, { ButtonProps } from "../../components/views/elements/AccessibleButton";
|
||||||
|
|
||||||
type Props<T extends keyof JSX.IntrinsicElements> = ComponentProps<typeof AccessibleButton<T>> & {
|
type Props<T extends keyof HTMLElementTagNameMap> = ButtonProps<T> & {
|
||||||
// whether the context menu is currently open
|
// whether the context menu is currently open
|
||||||
isExpanded: boolean;
|
isExpanded: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Semantic component for representing the AccessibleButton which launches a <ContextMenu />
|
// Semantic component for representing the AccessibleButton which launches a <ContextMenu />
|
||||||
export const ContextMenuTooltipButton = forwardRef(function <T extends keyof JSX.IntrinsicElements>(
|
export const ContextMenuTooltipButton = forwardRef(function <T extends keyof HTMLElementTagNameMap>(
|
||||||
{ isExpanded, children, onClick, onContextMenu, element, ...props }: Props<T>,
|
{ isExpanded, children, onClick, onContextMenu, ...props }: Props<T>,
|
||||||
ref: Ref<HTMLElement>,
|
ref: Ref<HTMLElementTagNameMap[T]>,
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
{...props}
|
{...props}
|
||||||
element={element as keyof JSX.IntrinsicElements}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onContextMenu={onContextMenu ?? onClick ?? undefined}
|
onContextMenu={onContextMenu ?? onClick ?? undefined}
|
||||||
aria-haspopup={true}
|
aria-haspopup={true}
|
||||||
|
|
|
@ -6,39 +6,33 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps } from "react";
|
import React, { RefObject } from "react";
|
||||||
|
|
||||||
import AccessibleButton from "../../components/views/elements/AccessibleButton";
|
import AccessibleButton, { ButtonProps } from "../../components/views/elements/AccessibleButton";
|
||||||
import { useRovingTabIndex } from "../RovingTabIndex";
|
import { useRovingTabIndex } from "../RovingTabIndex";
|
||||||
import { Ref } from "./types";
|
|
||||||
|
|
||||||
type Props<T extends keyof JSX.IntrinsicElements> = Omit<
|
type Props<T extends keyof HTMLElementTagNameMap> = Omit<ButtonProps<T>, "tabIndex"> & {
|
||||||
ComponentProps<typeof AccessibleButton<T>>,
|
inputRef?: RefObject<HTMLElementTagNameMap[T]>;
|
||||||
"inputRef" | "tabIndex"
|
|
||||||
> & {
|
|
||||||
inputRef?: Ref;
|
|
||||||
focusOnMouseOver?: boolean;
|
focusOnMouseOver?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wrapper to allow use of useRovingTabIndex for simple AccessibleButtons outside of React Functional Components.
|
// Wrapper to allow use of useRovingTabIndex for simple AccessibleButtons outside of React Functional Components.
|
||||||
export const RovingAccessibleButton = <T extends keyof JSX.IntrinsicElements>({
|
export const RovingAccessibleButton = <T extends keyof HTMLElementTagNameMap>({
|
||||||
inputRef,
|
inputRef,
|
||||||
onFocus,
|
onFocus,
|
||||||
onMouseOver,
|
onMouseOver,
|
||||||
focusOnMouseOver,
|
focusOnMouseOver,
|
||||||
element,
|
|
||||||
...props
|
...props
|
||||||
}: Props<T>): JSX.Element => {
|
}: Props<T>): JSX.Element => {
|
||||||
const [onFocusInternal, isActive, ref] = useRovingTabIndex(inputRef);
|
const [onFocusInternal, isActive, ref] = useRovingTabIndex<HTMLElementTagNameMap[T]>(inputRef);
|
||||||
return (
|
return (
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
{...props}
|
{...props}
|
||||||
element={element as keyof JSX.IntrinsicElements}
|
onFocus={(event: React.FocusEvent<never, never>) => {
|
||||||
onFocus={(event: React.FocusEvent) => {
|
|
||||||
onFocusInternal();
|
onFocusInternal();
|
||||||
onFocus?.(event);
|
onFocus?.(event);
|
||||||
}}
|
}}
|
||||||
onMouseOver={(event: React.MouseEvent) => {
|
onMouseOver={(event: React.MouseEvent<never, never>) => {
|
||||||
if (focusOnMouseOver) onFocusInternal();
|
if (focusOnMouseOver) onFocusInternal();
|
||||||
onMouseOver?.(event);
|
onMouseOver?.(event);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -910,7 +910,7 @@ export class SSOAuthEntry extends React.Component<ISSOAuthEntryProps, ISSOAuthEn
|
||||||
|
|
||||||
export class FallbackAuthEntry<T = {}> extends React.Component<IAuthEntryProps & T> {
|
export class FallbackAuthEntry<T = {}> extends React.Component<IAuthEntryProps & T> {
|
||||||
protected popupWindow: Window | null;
|
protected popupWindow: Window | null;
|
||||||
protected fallbackButton = createRef<HTMLButtonElement>();
|
protected fallbackButton = createRef<HTMLDivElement>();
|
||||||
|
|
||||||
public constructor(props: IAuthEntryProps & T) {
|
public constructor(props: IAuthEntryProps & T) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
|
@ -13,15 +13,15 @@ import { useRovingTabIndex } from "../../../../accessibility/RovingTabIndex";
|
||||||
import AccessibleButton, { ButtonProps } from "../../elements/AccessibleButton";
|
import AccessibleButton, { ButtonProps } from "../../elements/AccessibleButton";
|
||||||
import { Ref } from "../../../../accessibility/roving/types";
|
import { Ref } from "../../../../accessibility/roving/types";
|
||||||
|
|
||||||
type TooltipOptionProps<T extends keyof JSX.IntrinsicElements> = ButtonProps<T> & {
|
type TooltipOptionProps<T extends keyof HTMLElementTagNameMap> = ButtonProps<T> & {
|
||||||
|
className?: string;
|
||||||
endAdornment?: ReactNode;
|
endAdornment?: ReactNode;
|
||||||
inputRef?: Ref;
|
inputRef?: Ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TooltipOption = <T extends keyof JSX.IntrinsicElements>({
|
export const TooltipOption = <T extends keyof HTMLElementTagNameMap>({
|
||||||
inputRef,
|
inputRef,
|
||||||
className,
|
className,
|
||||||
element,
|
|
||||||
...props
|
...props
|
||||||
}: TooltipOptionProps<T>): JSX.Element => {
|
}: TooltipOptionProps<T>): JSX.Element => {
|
||||||
const [onFocus, isActive, ref] = useRovingTabIndex(inputRef);
|
const [onFocus, isActive, ref] = useRovingTabIndex(inputRef);
|
||||||
|
@ -34,7 +34,6 @@ export const TooltipOption = <T extends keyof JSX.IntrinsicElements>({
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
aria-selected={isActive}
|
aria-selected={isActive}
|
||||||
role="option"
|
role="option"
|
||||||
element={element as keyof JSX.IntrinsicElements}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,15 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps, forwardRef, FunctionComponent, HTMLAttributes, InputHTMLAttributes, Ref } from "react";
|
import React, {
|
||||||
|
ComponentProps,
|
||||||
|
ComponentPropsWithoutRef,
|
||||||
|
forwardRef,
|
||||||
|
FunctionComponent,
|
||||||
|
ReactElement,
|
||||||
|
KeyboardEvent,
|
||||||
|
Ref,
|
||||||
|
} from "react";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import { Tooltip } from "@vector-im/compound-web";
|
import { Tooltip } from "@vector-im/compound-web";
|
||||||
|
|
||||||
|
@ -38,23 +46,8 @@ export type AccessibleButtonKind =
|
||||||
| "icon_primary"
|
| "icon_primary"
|
||||||
| "icon_primary_outline";
|
| "icon_primary_outline";
|
||||||
|
|
||||||
/**
|
type ElementType = keyof HTMLElementTagNameMap;
|
||||||
* This type construct allows us to specifically pass those props down to the element we’re creating that the element
|
const defaultElement = "div";
|
||||||
* actually supports.
|
|
||||||
*
|
|
||||||
* e.g., if element is set to "a", we’ll support href and target, if it’s set to "input", we support type.
|
|
||||||
*
|
|
||||||
* To remain compatible with existing code, we’ll continue to support InputHTMLAttributes<Element>
|
|
||||||
*/
|
|
||||||
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">
|
|
||||||
> &
|
|
||||||
Pick<
|
|
||||||
InputHTMLAttributes<Element>,
|
|
||||||
"onKeyDown" | "onKeyUp" | "onMouseOver" | "onFocus" | "alt" | "type" | "autoFocus" | "children"
|
|
||||||
>;
|
|
||||||
|
|
||||||
type TooltipProps = ComponentProps<typeof Tooltip>;
|
type TooltipProps = ComponentProps<typeof Tooltip>;
|
||||||
|
|
||||||
|
@ -63,7 +56,7 @@ type TooltipProps = ComponentProps<typeof Tooltip>;
|
||||||
*
|
*
|
||||||
* Extends props accepted by the underlying element specified using the `element` prop.
|
* Extends props accepted by the underlying element specified using the `element` prop.
|
||||||
*/
|
*/
|
||||||
type Props<T extends keyof JSX.IntrinsicElements> = DynamicHtmlElementProps<T> & {
|
type Props<T extends ElementType = "div"> = {
|
||||||
/**
|
/**
|
||||||
* The base element type. "div" by default.
|
* The base element type. "div" by default.
|
||||||
*/
|
*/
|
||||||
|
@ -108,14 +101,12 @@ type Props<T extends keyof JSX.IntrinsicElements> = DynamicHtmlElementProps<T> &
|
||||||
disableTooltip?: TooltipProps["disabled"];
|
disableTooltip?: TooltipProps["disabled"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ButtonProps<T extends keyof JSX.IntrinsicElements> = Props<T>;
|
export type ButtonProps<T extends ElementType> = Props<T> & Omit<ComponentPropsWithoutRef<T>, keyof Props<T>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of the props passed to the element that is rendered by AccessibleButton.
|
* Type of the props passed to the element that is rendered by AccessibleButton.
|
||||||
*/
|
*/
|
||||||
interface RenderedElementProps extends React.InputHTMLAttributes<Element> {
|
type RenderedElementProps<T extends ElementType> = React.InputHTMLAttributes<Element> & RefProp<T>;
|
||||||
ref?: React.Ref<Element>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccessibleButton is a generic wrapper for any element that should be treated
|
* AccessibleButton is a generic wrapper for any element that should be treated
|
||||||
|
@ -127,9 +118,9 @@ interface RenderedElementProps extends React.InputHTMLAttributes<Element> {
|
||||||
* @param {Object} props react element properties
|
* @param {Object} props react element properties
|
||||||
* @returns {Object} rendered react
|
* @returns {Object} rendered react
|
||||||
*/
|
*/
|
||||||
const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicElements>(
|
const AccessibleButton = forwardRef(function <T extends ElementType = typeof defaultElement>(
|
||||||
{
|
{
|
||||||
element = "div" as T,
|
element,
|
||||||
onClick,
|
onClick,
|
||||||
children,
|
children,
|
||||||
kind,
|
kind,
|
||||||
|
@ -144,10 +135,10 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
|
||||||
onTooltipOpenChange,
|
onTooltipOpenChange,
|
||||||
disableTooltip,
|
disableTooltip,
|
||||||
...restProps
|
...restProps
|
||||||
}: Props<T>,
|
}: ButtonProps<T>,
|
||||||
ref: Ref<HTMLElement>,
|
ref: Ref<HTMLElementTagNameMap[T]>,
|
||||||
): JSX.Element {
|
): JSX.Element {
|
||||||
const newProps: RenderedElementProps = restProps;
|
const newProps = restProps as RenderedElementProps<T>;
|
||||||
newProps["aria-label"] = newProps["aria-label"] ?? title;
|
newProps["aria-label"] = newProps["aria-label"] ?? title;
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
newProps["aria-disabled"] = true;
|
newProps["aria-disabled"] = true;
|
||||||
|
@ -165,7 +156,7 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
|
||||||
// And divs which we report as role button to assistive technologies.
|
// And divs which we report as role button to assistive technologies.
|
||||||
// Browsers handle space and enter key presses differently and we are only adjusting to the
|
// Browsers handle space and enter key presses differently and we are only adjusting to the
|
||||||
// inconsistencies here
|
// inconsistencies here
|
||||||
newProps.onKeyDown = (e) => {
|
newProps.onKeyDown = (e: KeyboardEvent<never>) => {
|
||||||
const action = getKeyBindingsManager().getAccessibilityAction(e);
|
const action = getKeyBindingsManager().getAccessibilityAction(e);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
@ -181,7 +172,7 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
|
||||||
onKeyDown?.(e);
|
onKeyDown?.(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
newProps.onKeyUp = (e) => {
|
newProps.onKeyUp = (e: KeyboardEvent<never>) => {
|
||||||
const action = getKeyBindingsManager().getAccessibilityAction(e);
|
const action = getKeyBindingsManager().getAccessibilityAction(e);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
@ -210,7 +201,7 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
|
||||||
});
|
});
|
||||||
|
|
||||||
// React.createElement expects InputHTMLAttributes
|
// React.createElement expects InputHTMLAttributes
|
||||||
const button = React.createElement(element, newProps, children);
|
const button = React.createElement(element ?? defaultElement, newProps, children);
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
return (
|
return (
|
||||||
|
@ -236,4 +227,15 @@ const AccessibleButton = forwardRef(function <T extends keyof JSX.IntrinsicEleme
|
||||||
};
|
};
|
||||||
(AccessibleButton as FunctionComponent).displayName = "AccessibleButton";
|
(AccessibleButton as FunctionComponent).displayName = "AccessibleButton";
|
||||||
|
|
||||||
export default AccessibleButton;
|
interface RefProp<T extends ElementType> {
|
||||||
|
ref?: Ref<HTMLElementTagNameMap[T]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ButtonComponent {
|
||||||
|
// With the explicit `element` prop
|
||||||
|
<C extends ElementType>(props: { element?: C } & ButtonProps<C> & RefProp<C>): ReactElement;
|
||||||
|
// Without the explicit `element` prop
|
||||||
|
(props: ButtonProps<"div"> & RefProp<"div">): ReactElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AccessibleButton as ButtonComponent;
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Emoji extends React.PureComponent<IProps> {
|
||||||
return (
|
return (
|
||||||
<RovingAccessibleButton
|
<RovingAccessibleButton
|
||||||
id={this.props.id}
|
id={this.props.id}
|
||||||
onClick={(ev) => onClick(ev, emoji)}
|
onClick={(ev: ButtonEvent) => onClick(ev, emoji)}
|
||||||
onMouseEnter={() => onMouseEnter(emoji)}
|
onMouseEnter={() => onMouseEnter(emoji)}
|
||||||
onMouseLeave={() => onMouseLeave(emoji)}
|
onMouseLeave={() => onMouseLeave(emoji)}
|
||||||
className="mx_EmojiPicker_item_wrapper"
|
className="mx_EmojiPicker_item_wrapper"
|
||||||
|
|
|
@ -90,7 +90,7 @@ export const MPollEndBody = React.forwardRef<any, IBodyProps>(({ mxEvent, ...pro
|
||||||
const { pollStartEvent, isLoadingPollStartEvent } = usePollStartEvent(mxEvent);
|
const { pollStartEvent, isLoadingPollStartEvent } = usePollStartEvent(mxEvent);
|
||||||
|
|
||||||
if (!pollStartEvent) {
|
if (!pollStartEvent) {
|
||||||
const pollEndFallbackMessage = M_TEXT.findIn(mxEvent.getContent()) || textForEvent(mxEvent, cli);
|
const pollEndFallbackMessage = M_TEXT.findIn<string>(mxEvent.getContent()) || textForEvent(mxEvent, cli);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PollIcon className="mx_MPollEndBody_icon" />
|
<PollIcon className="mx_MPollEndBody_icon" />
|
||||||
|
|
|
@ -435,7 +435,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
|
||||||
<RovingAccessibleButton
|
<RovingAccessibleButton
|
||||||
className="mx_MessageActionBar_iconButton"
|
className="mx_MessageActionBar_iconButton"
|
||||||
title={isPinned ? _t("action|unpin") : _t("action|pin")}
|
title={isPinned ? _t("action|unpin") : _t("action|pin")}
|
||||||
onClick={(e) => this.onPinClick(e, isPinned)}
|
onClick={(e: ButtonEvent) => this.onPinClick(e, isPinned)}
|
||||||
onContextMenu={(e: ButtonEvent) => this.onPinClick(e, isPinned)}
|
onContextMenu={(e: ButtonEvent) => this.onPinClick(e, isPinned)}
|
||||||
key="pin"
|
key="pin"
|
||||||
placement="left"
|
placement="left"
|
||||||
|
|
|
@ -7,23 +7,21 @@ Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import React, { ComponentProps } from "react";
|
import React from "react";
|
||||||
import { ChevronDownIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
import { ChevronDownIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||||
|
|
||||||
import { _t } from "../../../../languageHandler";
|
import { _t } from "../../../../languageHandler";
|
||||||
import AccessibleButton from "../../elements/AccessibleButton";
|
import AccessibleButton, { ButtonProps } from "../../elements/AccessibleButton";
|
||||||
|
|
||||||
type Props<T extends keyof JSX.IntrinsicElements> = Omit<
|
type Props<T extends keyof HTMLElementTagNameMap> = Omit<
|
||||||
ComponentProps<typeof AccessibleButton<T>>,
|
ButtonProps<T>,
|
||||||
"aria-label" | "title" | "kind" | "className" | "onClick" | "element"
|
"aria-label" | "title" | "kind" | "className" | "element"
|
||||||
> & {
|
> & {
|
||||||
isExpanded: boolean;
|
isExpanded: boolean;
|
||||||
onClick: () => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeviceExpandDetailsButton = <T extends keyof JSX.IntrinsicElements>({
|
export const DeviceExpandDetailsButton = <T extends keyof HTMLElementTagNameMap>({
|
||||||
isExpanded,
|
isExpanded,
|
||||||
onClick,
|
|
||||||
...rest
|
...rest
|
||||||
}: Props<T>): JSX.Element => {
|
}: Props<T>): JSX.Element => {
|
||||||
const label = isExpanded ? _t("settings|sessions|hide_details") : _t("settings|sessions|show_details");
|
const label = isExpanded ? _t("settings|sessions|hide_details") : _t("settings|sessions|show_details");
|
||||||
|
@ -36,7 +34,6 @@ export const DeviceExpandDetailsButton = <T extends keyof JSX.IntrinsicElements>
|
||||||
className={classNames("mx_DeviceExpandDetailsButton", {
|
className={classNames("mx_DeviceExpandDetailsButton", {
|
||||||
mx_DeviceExpandDetailsButton_expanded: isExpanded,
|
mx_DeviceExpandDetailsButton_expanded: isExpanded,
|
||||||
})}
|
})}
|
||||||
onClick={onClick}
|
|
||||||
>
|
>
|
||||||
<ChevronDownIcon className="mx_DeviceExpandDetailsButton_icon" />
|
<ChevronDownIcon className="mx_DeviceExpandDetailsButton_icon" />
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
|
|
|
@ -221,7 +221,7 @@ const CreateSpaceButton: React.FC<Pick<IInnerSpacePanelProps, "isPanelCollapsed"
|
||||||
isPanelCollapsed,
|
isPanelCollapsed,
|
||||||
setPanelCollapsed,
|
setPanelCollapsed,
|
||||||
}) => {
|
}) => {
|
||||||
const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu<HTMLElement>();
|
const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu<HTMLDivElement>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPanelCollapsed && menuDisplayed) {
|
if (!isPanelCollapsed && menuDisplayed) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||||
import { Action } from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
||||||
import { toRightOf, useContextMenu } from "../../structures/ContextMenu";
|
import { toRightOf, useContextMenu } from "../../structures/ContextMenu";
|
||||||
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent, ButtonProps as AccessibleButtonProps } from "../elements/AccessibleButton";
|
||||||
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
||||||
import { NotificationLevel } from "../../../stores/notifications/NotificationLevel";
|
import { NotificationLevel } from "../../../stores/notifications/NotificationLevel";
|
||||||
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
|
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
|
||||||
|
@ -39,8 +39,8 @@ import SpaceContextMenu from "../context_menus/SpaceContextMenu";
|
||||||
import { useRovingTabIndex } from "../../../accessibility/RovingTabIndex";
|
import { useRovingTabIndex } from "../../../accessibility/RovingTabIndex";
|
||||||
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
||||||
|
|
||||||
type ButtonProps<T extends keyof JSX.IntrinsicElements> = Omit<
|
type ButtonProps<T extends keyof HTMLElementTagNameMap> = Omit<
|
||||||
ComponentProps<typeof AccessibleButton<T>>,
|
AccessibleButtonProps<T>,
|
||||||
"title" | "onClick" | "size" | "element"
|
"title" | "onClick" | "size" | "element"
|
||||||
> & {
|
> & {
|
||||||
space?: Room;
|
space?: Room;
|
||||||
|
@ -52,12 +52,12 @@ type ButtonProps<T extends keyof JSX.IntrinsicElements> = Omit<
|
||||||
notificationState?: NotificationState;
|
notificationState?: NotificationState;
|
||||||
isNarrow?: boolean;
|
isNarrow?: boolean;
|
||||||
size: string;
|
size: string;
|
||||||
innerRef?: RefObject<HTMLElement>;
|
innerRef?: RefObject<HTMLDivElement>;
|
||||||
ContextMenuComponent?: ComponentType<ComponentProps<typeof SpaceContextMenu>>;
|
ContextMenuComponent?: ComponentType<ComponentProps<typeof SpaceContextMenu>>;
|
||||||
onClick?(ev?: ButtonEvent): void;
|
onClick?(ev?: ButtonEvent): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SpaceButton = <T extends keyof JSX.IntrinsicElements>({
|
export const SpaceButton = <T extends keyof HTMLElementTagNameMap>({
|
||||||
space,
|
space,
|
||||||
spaceKey: _spaceKey,
|
spaceKey: _spaceKey,
|
||||||
className,
|
className,
|
||||||
|
@ -72,8 +72,8 @@ export const SpaceButton = <T extends keyof JSX.IntrinsicElements>({
|
||||||
ContextMenuComponent,
|
ContextMenuComponent,
|
||||||
...props
|
...props
|
||||||
}: ButtonProps<T>): JSX.Element => {
|
}: ButtonProps<T>): JSX.Element => {
|
||||||
const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu<HTMLElement>(innerRef);
|
const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu<HTMLDivElement>(innerRef);
|
||||||
const [onFocus, isActive, ref] = useRovingTabIndex(handle);
|
const [onFocus, isActive, ref] = useRovingTabIndex<HTMLDivElement>(handle);
|
||||||
const tabIndex = isActive ? 0 : -1;
|
const tabIndex = isActive ? 0 : -1;
|
||||||
|
|
||||||
const spaceKey = _spaceKey ?? space?.roomId;
|
const spaceKey = _spaceKey ?? space?.roomId;
|
||||||
|
|
|
@ -69,7 +69,7 @@ interface IDropdownButtonProps extends ButtonProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const LegacyCallViewDropdownButton: React.FC<IDropdownButtonProps> = ({ state, deviceKinds, ...props }) => {
|
const LegacyCallViewDropdownButton: React.FC<IDropdownButtonProps> = ({ state, deviceKinds, ...props }) => {
|
||||||
const [menuDisplayed, buttonRef, openMenu, closeMenu] = useContextMenu();
|
const [menuDisplayed, buttonRef, openMenu, closeMenu] = useContextMenu<HTMLDivElement>();
|
||||||
const [hoveringDropdown, setHoveringDropdown] = useState(false);
|
const [hoveringDropdown, setHoveringDropdown] = useState(false);
|
||||||
|
|
||||||
const classes = classNames("mx_LegacyCallViewButtons_button", "mx_LegacyCallViewButtons_dropdownButton", {
|
const classes = classNames("mx_LegacyCallViewButtons_button", "mx_LegacyCallViewButtons_dropdownButton", {
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe("SetIntegrationManager", () => {
|
||||||
deleteThreePid: jest.fn(),
|
deleteThreePid: jest.fn(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let stores: SdkContextClass;
|
let stores!: SdkContextClass;
|
||||||
|
|
||||||
const getComponent = () => (
|
const getComponent = () => (
|
||||||
<MatrixClientContext.Provider value={mockClient}>
|
<MatrixClientContext.Provider value={mockClient}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue