@cloudtower/eagle 0.34.17 → 0.34.18

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.
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { TabProps } from "./Tab.type";
3
+ export declare const Tab: (props: TabProps) => React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const TabMenuWrapper: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
3
+ export declare const TabTitleElStyle: import("@linaria/core").LinariaClassName;
4
+ export declare const MoreThanTooltipStyle: import("@linaria/core").LinariaClassName;
5
+ export declare const IconStyle: import("@linaria/core").LinariaClassName;
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ /**
3
+ * Tab 项的数据结构
4
+ */
5
+ export type TabItem = {
6
+ /** Tab 的唯一标识符 */
7
+ key: string;
8
+ /** Tab 的标题,可以是字符串、ReactNode 或函数 */
9
+ title: string | React.ReactNode | ((props: {
10
+ isActive: boolean;
11
+ }) => React.ReactNode);
12
+ /** Tab 的内容 */
13
+ children: React.ReactNode;
14
+ };
15
+ /**
16
+ * Tab 组件的属性
17
+ */
18
+ export type TabProps = {
19
+ /** 外层容器的类名 */
20
+ className?: string;
21
+ /** 内容区域的类名 */
22
+ contentClassName?: string;
23
+ /** 当前选中的 Tab 的 key */
24
+ selectedKey: string;
25
+ /** Tab 列表 */
26
+ tabs: TabItem[];
27
+ /** Tab 切换时的回调 */
28
+ onChange?: (key: string) => void;
29
+ /** 额外的插槽内容,显示在 tab bar 的右侧 */
30
+ extraSlot?: React.ReactNode;
31
+ /** Tab 的大小 */
32
+ size?: "small" | "medium";
33
+ };
34
+ /**
35
+ * 激活 Tab 的类型枚举
36
+ */
37
+ export declare enum ActiveTabType {
38
+ /** 普通类型的 Tab */
39
+ Common = 0,
40
+ /** 在更多菜单中的 Tab */
41
+ More = 1
42
+ }
@@ -0,0 +1 @@
1
+ export * from "./Tab";
@@ -0,0 +1,23 @@
1
+ import { TabItem } from "../../core/Tab/Tab.type";
2
+ import { RefObject } from "react";
3
+ /**
4
+ * Tab 自适应布局 Hook
5
+ *
6
+ * 根据可用空间自动计算哪些 tab 需要隐藏到"更多"菜单中。
7
+ * 当容器尺寸变化、tabs 列表变化或 selectedKey 变化时,会自动重新计算布局。
8
+ *
9
+ * @param tabs - Tab 列表
10
+ * @param tabsRef - Tab 容器的 ref
11
+ * @param extraSlotRef - 额外插槽的 ref(用于计算可用宽度)
12
+ * @param selectedKey - 当前选中的 tab key(用于触发重新计算,当选中项在"更多"菜单中时会影响按钮宽度)
13
+ *
14
+ * @returns moreTabs - 需要隐藏到"更多"菜单的 tabs 列表
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const tabsRef = useRef<HTMLDivElement>(null);
19
+ * const extraSlotRef = useRef<HTMLDivElement>(null);
20
+ * const moreTabs = useTabAdaptiveLayout(tabs, tabsRef, extraSlotRef, selectedKey);
21
+ * ```
22
+ */
23
+ export declare const useTabAdaptiveLayout: (tabs: TabItem[], tabsRef: RefObject<HTMLDivElement>, extraSlotRef: RefObject<HTMLDivElement>, selectedKey?: string) => TabItem[];
@@ -76,6 +76,7 @@ export * from "./StepProgress";
76
76
  export * from "./Steps";
77
77
  export * from "./Styled";
78
78
  export * from "./Switch";
79
+ export * from "./Tab";
79
80
  export * from "./Table";
80
81
  export * from "./TableForm";
81
82
  export * from "./Tag";
@@ -0,0 +1,65 @@
1
+ import { Tab } from "../../../src/core/Tab/Tab";
2
+ import type { StoryObj } from "@storybook/react";
3
+ import React from "react";
4
+ /**
5
+ * Tab 是一个标签页组件,支持多个标签页之间的切换。
6
+ *
7
+ * ### 参数说明
8
+ *
9
+ * | 参数 | 说明 | 类型 | 默认值 |
10
+ * | --- | --- | --- | --- |
11
+ * | className | 自定义类名 | string | - |
12
+ * | contentClassName | 内容区域的类名 | string | - |
13
+ * | selectedKey | 当前选中的标签页 key | string | - |
14
+ * | tabs | 标签页配置数组 | TabItem[] | [] |
15
+ * | onChange | 切换标签页时的回调 | (key: string) => void | - |
16
+ * | extraSlot | 额外的插槽内容,显示在标签栏右侧 | React.ReactNode | - |
17
+ *
18
+ * ### TabItem 参数说明
19
+ *
20
+ * | 参数 | 说明 | 类型 | 默认值 |
21
+ * | --- | --- | --- | --- |
22
+ * | key | 唯一标识符 | string | - |
23
+ * | title | 标签页标题,可以是字符串、ReactNode 或函数 | string \| ReactNode \| ((props: { isActive: boolean }) => ReactNode) | - |
24
+ * | onClick | 点击标签页时的回调 | () => void | - |
25
+ * | children | 标签页内容 | React.ReactNode | - |
26
+ *
27
+ * ### 特性
28
+ * - 支持响应式布局,当空间不够时自动将多余的标签页放入下拉菜单
29
+ * - 支持自定义标题(可通过函数形式获取激活状态)
30
+ * - 支持在标签栏右侧添加额外内容
31
+ * - 支持自定义内容区域的样式
32
+ */
33
+ declare const meta: {
34
+ component: (props: import("../../../src/core/Tab/Tab.type").TabProps) => React.JSX.Element;
35
+ title: "Core/Tab | 标签页";
36
+ };
37
+ export default meta;
38
+ type Story = StoryObj<typeof Tab>;
39
+ /**
40
+ * 基础的标签页用法,展示如何创建和使用标签页组件
41
+ */
42
+ export declare const Basic: Story;
43
+ /**
44
+ * 当有大量标签页时,组件会自动计算可用空间,将无法完整显示的标签页放入下拉菜单中
45
+ */
46
+ export declare const ResponsiveLayout: Story;
47
+ /**
48
+ * 标签页标题支持函数形式,可以接收 isActive 参数来判断当前是否激活
49
+ */
50
+ export declare const CustomTitle: Story;
51
+ /**
52
+ * extraSlot 可以在标签栏右侧添加额外的内容,如按钮、图标等
53
+ */
54
+ export declare const WithExtraSlot: Story;
55
+ /**
56
+ * 展示实际业务场景中的使用方式,包含复杂的标签内容和操作
57
+ */
58
+ export declare const ComplexContent: Story;
59
+ /**
60
+ * 支持动态添加和删除标签页的场景。
61
+ * - 在 extraSlot 中提供"新增标签"按钮
62
+ * - 每个标签页标题右侧显示删除图标
63
+ * - 可以动态添加和删除标签页
64
+ */
65
+ export declare const DynamicTabs: Story;