mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Removed package "autobind-decorator" and @boundMethod in favour of "auto-bind" util for constructors-only. (#5218)
This commit is contained in:
1 parent
5f145e69e5
commit
06e7dfce5e
45 files changed
+150
-180
No files matched your search
@@ -6,7 +6,7 @@
|
||||
import "./tabs.scss";
|
||||
import type { DOMAttributes } from "react";
|
||||
import React from "react";
|
||||
import { boundMethod, cssNames } from "../../utils";
|
||||
import { autoBind, cssNames } from "../../utils";
|
||||
import { Icon } from "../icon";
|
||||
|
||||
const TabsContext = React.createContext<TabsContextValue>({});
|
||||
@@ -28,10 +28,7 @@ export interface TabsProps<D = any> extends TabsContextValue<D>, Omit<DOMAttribu
|
||||
export class Tabs extends React.PureComponent<TabsProps> {
|
||||
public elem: HTMLElement;
|
||||
|
||||
@boundMethod
|
||||
protected bindRef(elem: HTMLElement) {
|
||||
this.elem = elem;
|
||||
}
|
||||
bindRef = (elem: HTMLElement) => this.elem = elem;
|
||||
|
||||
render() {
|
||||
const { center, wrap, onChange, value, autoFocus, scrollable = true, withBorder, ...elemProps } = this.props;
|
||||
@@ -69,6 +66,11 @@ export class Tab extends React.PureComponent<TabProps> {
|
||||
declare context: TabsContextValue;
|
||||
public ref = React.createRef<HTMLDivElement>();
|
||||
|
||||
constructor(props: TabProps) {
|
||||
super(props);
|
||||
autoBind(this);
|
||||
}
|
||||
|
||||
get isActive() {
|
||||
const { active, value } = this.props;
|
||||
|
||||
@@ -84,7 +86,6 @@ export class Tab extends React.PureComponent<TabProps> {
|
||||
this.ref.current?.scrollIntoViewIfNeeded?.();
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
onClick(evt: React.MouseEvent<HTMLElement>) {
|
||||
const { value, active, disabled, onClick } = this.props;
|
||||
|
||||
@@ -96,13 +97,11 @@ export class Tab extends React.PureComponent<TabProps> {
|
||||
this.context.onChange?.(value);
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
onFocus(evt: React.FocusEvent<HTMLElement>) {
|
||||
this.props.onFocus?.(evt);
|
||||
this.scrollIntoView();
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
onKeyDown(evt: React.KeyboardEvent<HTMLElement>) {
|
||||
if (evt.key === " " || evt.key === "Enter") {
|
||||
this.ref.current?.click();
|
||||
|
||||
Reference in new issue
Block a user