@befe/brick-comp-tabs 0.2.127 → 0.2.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { Component, ContextType, ReactNode } from 'react';
2
- import { TabPaneId, TabsContext } from './tabs-context';
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ import { TabPaneId } from './tabs-context';
3
3
  export interface TabPaneProps {
4
4
  /**
5
5
  * 自定义 class
@@ -25,18 +25,16 @@ export interface TabPaneProps {
25
25
  * tab 标签页的状态
26
26
  * - 仅 type card 支持
27
27
  * - 暂时只有 'normal' | 'error'
28
+ * @default 'normal'
28
29
  */
29
30
  status?: 'normal' | 'error';
30
31
  }
31
- export declare class TabPane extends Component<TabPaneProps> {
32
- static displayName: string;
33
- static defaultProps: {
34
- className: string;
35
- status: string;
36
- };
37
- static contextType: import("react").Context<import("./tabs-context").TabsContextValue>;
38
- context: ContextType<typeof TabsContext>;
39
- get className(): string;
40
- get isActive(): boolean;
41
- render(): import("react/jsx-runtime").JSX.Element;
32
+ /**
33
+ * TabPane `status` 默认值;父组件 `Tabs.getTabsAll` 读取 `child.props.status` 时也用它兜底
34
+ * (默认参数不进 element.props,故父子两处共用此常量,避免字面量各写一份而漂移)
35
+ */
36
+ export declare const TAB_PANE_DEFAULT_STATUS: NonNullable<TabPaneProps['status']>;
37
+ export declare function TabPane(props: PropsWithChildren<TabPaneProps>): import("react/jsx-runtime").JSX.Element;
38
+ export declare namespace TabPane {
39
+ var displayName: string;
42
40
  }
package/types/tabs.d.ts CHANGED
@@ -1,11 +1,7 @@
1
- import { Component, ContextType, ReactNode, MouseEvent, ReactComponentElement } from 'react';
2
- import { EventListenerHandler } from '@befe/brick-utils';
3
- import { ConfigContext } from '@befe/brick-core';
1
+ import { MouseEvent, ReactNode, PropsWithChildren } from 'react';
4
2
  import { MenuPopperProps } from '@befe/brick-comp-menu';
5
- import { RadioGroupProps } from '@befe/brick-comp-radio';
6
- import { TabPane, TabPaneProps } from './tab-pane';
7
- import { TabPaneId, TabsContextValue } from './tabs-context';
8
- type ButtonGroupProps = Pick<RadioGroupProps, 'value' | 'options'>;
3
+ import { TabPaneProps } from './tab-pane';
4
+ import { TabPaneId } from './tabs-context';
9
5
  interface TabItem extends TabPaneProps {
10
6
  /**
11
7
  * tab 页内容
@@ -72,68 +68,8 @@ export interface TabsProps {
72
68
  */
73
69
  ellipsisDropdownPlacement?: MenuPopperProps['placement'];
74
70
  }
75
- interface TabsState {
76
- activeId?: TabPaneId | null;
77
- visibleFrom: number;
78
- visibleTo: number;
79
- isEllipsisPopperVisible: boolean;
80
- }
81
- export declare class Tabs extends Component<TabsProps, TabsState> {
82
- static displayName: string;
83
- static defaultProps: {
84
- className: string;
85
- type: string;
86
- defaultActiveId: null;
87
- shouldDestroyInactivePane: boolean;
88
- ellipsisDropdownPlacement: string;
89
- };
90
- static contextType: import("react").Context<import("@befe/brick-core").ConfigContextValue>;
91
- context: ContextType<typeof ConfigContext>;
92
- windowResizeHandler: EventListenerHandler | null;
93
- tabsWheelHandler: EventListenerHandler | null;
94
- static getDerivedStateFromProps(nextProps: TabsProps): Partial<TabsProps> | null;
95
- state: TabsState;
96
- refTabsWrap: import("react").RefObject<HTMLDivElement>;
97
- refTabs: import("react").RefObject<HTMLUListElement>;
98
- tabsWrapWidth: number;
99
- tabsWidth: number[];
100
- tabsWrapMaxScrollLeft: number;
101
- tabsWrapScrollLeft: number;
102
- get className(): string;
103
- get size(): "sm" | "md";
104
- get contextValue(): TabsContextValue;
105
- get validChildren(): ReactComponentElement<typeof TabPane, Pick<TabPaneProps, keyof TabPaneProps>>[] | null;
106
- get tabsAll(): TabItem[];
107
- get tabsEllipsis(): TabItem[];
108
- get canEllipsis(): boolean;
109
- get withEllipsis(): boolean;
110
- isTabPaneDisabled(id: TabPaneId): boolean;
111
- updateWidth(): void;
112
- updateEllipsis(): void;
113
- changeActive(id: TabPaneId): void;
114
- deleteTab(id: TabPaneId): void;
115
- scrollTabsWrap(scrollLeftTo?: number): void;
116
- scrollTabsWrapToTab(id: TabPaneId, force?: boolean): void;
117
- scrollTabsWrapToActive(force?: boolean): void;
118
- handleClickAdd: (e: MouseEvent) => void;
119
- handleClickTab: (e: MouseEvent, id: TabPaneId) => void;
120
- handleChangeRadioGroup: (value: ButtonGroupProps['value']) => void;
121
- handleMenuPopperChange: (status: boolean) => void;
122
- handleWheelTabsWrap: (e: WheelEvent) => void;
123
- renderTabDelete(tab: TabItem): import("react/jsx-runtime").JSX.Element | null;
124
- renderTabStatus(tab: TabItem): false | import("react/jsx-runtime").JSX.Element | null;
125
- renderTab: (tab: TabItem) => import("react/jsx-runtime").JSX.Element;
126
- renderTabs(): import("react/jsx-runtime").JSX.Element;
127
- renderTabsEllipsisMenu(): import("react/jsx-runtime").JSX.Element;
128
- renderTabsEllipsis(): import("react/jsx-runtime").JSX.Element | null;
129
- renderAddButton(): import("react/jsx-runtime").JSX.Element | null;
130
- renderButtonGroupTabs(): import("react/jsx-runtime").JSX.Element;
131
- renderTabsContainer(): import("react/jsx-runtime").JSX.Element;
132
- renderTabPanes(): import("react/jsx-runtime").JSX.Element[] | null;
133
- renderTabPanesContainer(): import("react/jsx-runtime").JSX.Element | null;
134
- componentDidMount(): void;
135
- componentWillUnmount(): void;
136
- componentDidUpdate(prevProps: Readonly<TabsProps>, prevState: Readonly<TabsState>): void;
137
- render(): import("react/jsx-runtime").JSX.Element;
71
+ export declare function Tabs(props: PropsWithChildren<TabsProps>): import("react/jsx-runtime").JSX.Element;
72
+ export declare namespace Tabs {
73
+ var displayName: string;
138
74
  }
139
75
  export {};