@rovula/ui 0.0.55 → 0.0.57
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.
- package/dist/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Tabs/Tabs.d.ts +2 -0
- package/dist/cjs/types/components/Tabs/Tabs.stories.d.ts +16 -0
- package/dist/cjs/types/components/Tree/type.d.ts +1 -1
- package/dist/components/Tabs/Tabs.js +8 -3
- package/dist/components/Tabs/Tabs.stories.js +24 -0
- package/dist/components/Tree/Tree.js +1 -1
- package/dist/esm/bundle.js +2 -2
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Tabs/Tabs.d.ts +2 -0
- package/dist/esm/types/components/Tabs/Tabs.stories.d.ts +16 -0
- package/dist/esm/types/components/Tree/type.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +48 -0
- package/src/components/Tabs/Tabs.tsx +12 -1
- package/src/components/Tree/Tree.tsx +1 -1
- package/src/components/Tree/type.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./Tabs.css";
|
|
3
3
|
type Tab = {
|
|
4
|
+
id?: string;
|
|
4
5
|
label: string;
|
|
5
6
|
startTabContent?: React.ReactElement;
|
|
6
7
|
endTabContent?: React.ReactElement;
|
|
@@ -10,6 +11,7 @@ type Tab = {
|
|
|
10
11
|
};
|
|
11
12
|
type TabsProps = {
|
|
12
13
|
tabs: Tab[];
|
|
14
|
+
value?: number;
|
|
13
15
|
initialTab?: number;
|
|
14
16
|
tabBarSize?: number;
|
|
15
17
|
tabMode?: "start" | "justify";
|
|
@@ -3,6 +3,7 @@ declare const meta: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
component: React.FC<{
|
|
5
5
|
tabs: {
|
|
6
|
+
id?: string | undefined;
|
|
6
7
|
label: string;
|
|
7
8
|
startTabContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
8
9
|
endTabContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
@@ -10,6 +11,7 @@ declare const meta: {
|
|
|
10
11
|
disabled?: boolean | undefined;
|
|
11
12
|
isLoading?: boolean | undefined;
|
|
12
13
|
}[];
|
|
14
|
+
value?: number | undefined;
|
|
13
15
|
initialTab?: number | undefined;
|
|
14
16
|
tabBarSize?: number | undefined;
|
|
15
17
|
tabMode?: "start" | "justify" | undefined;
|
|
@@ -37,6 +39,7 @@ declare const meta: {
|
|
|
37
39
|
};
|
|
38
40
|
decorators: ((Story: import("@storybook/types").PartialStoryFn<import("@storybook/react").ReactRenderer, {
|
|
39
41
|
tabs: {
|
|
42
|
+
id?: string | undefined;
|
|
40
43
|
label: string;
|
|
41
44
|
startTabContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
42
45
|
endTabContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
@@ -44,6 +47,7 @@ declare const meta: {
|
|
|
44
47
|
disabled?: boolean | undefined;
|
|
45
48
|
isLoading?: boolean | undefined;
|
|
46
49
|
}[];
|
|
50
|
+
value?: number | undefined;
|
|
47
51
|
initialTab?: number | undefined;
|
|
48
52
|
tabBarSize?: number | undefined;
|
|
49
53
|
tabMode?: "start" | "justify" | undefined;
|
|
@@ -144,3 +148,15 @@ export declare const Disabled: {
|
|
|
144
148
|
};
|
|
145
149
|
render: (args: {}) => import("react/jsx-runtime").JSX.Element;
|
|
146
150
|
};
|
|
151
|
+
export declare const Controller: {
|
|
152
|
+
args: {
|
|
153
|
+
initialTab: number;
|
|
154
|
+
value: number;
|
|
155
|
+
tabs: {
|
|
156
|
+
label: string;
|
|
157
|
+
content: import("react/jsx-runtime").JSX.Element;
|
|
158
|
+
}[];
|
|
159
|
+
enableAddTabButton: boolean;
|
|
160
|
+
};
|
|
161
|
+
render: (args: {}) => import("react/jsx-runtime").JSX.Element;
|
|
162
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ type TextProps = {
|
|
|
106
106
|
declare const Text: React__default.ForwardRefExoticComponent<TextProps & React__default.RefAttributes<unknown>>;
|
|
107
107
|
|
|
108
108
|
type Tab = {
|
|
109
|
+
id?: string;
|
|
109
110
|
label: string;
|
|
110
111
|
startTabContent?: React__default.ReactElement;
|
|
111
112
|
endTabContent?: React__default.ReactElement;
|
|
@@ -115,6 +116,7 @@ type Tab = {
|
|
|
115
116
|
};
|
|
116
117
|
type TabsProps = {
|
|
117
118
|
tabs: Tab[];
|
|
119
|
+
value?: number;
|
|
118
120
|
initialTab?: number;
|
|
119
121
|
tabBarSize?: number;
|
|
120
122
|
tabMode?: "start" | "justify";
|
|
@@ -705,7 +707,7 @@ interface TreeProps extends Pick<TreeItemProps, "renderIcon" | "renderRightSecti
|
|
|
705
707
|
hierarchicalCheck?: boolean;
|
|
706
708
|
checkable?: boolean;
|
|
707
709
|
maxLevel?: number;
|
|
708
|
-
mode
|
|
710
|
+
mode?: "checkbox" | "radio";
|
|
709
711
|
autoDisabled?: boolean;
|
|
710
712
|
}
|
|
711
713
|
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { ChevronDownIcon, ArchiveBoxIcon } from "@heroicons/react/16/solid";
|
|
|
5
5
|
import ActionButton from "../ActionButton/ActionButton";
|
|
6
6
|
import Icon from "../Icon/Icon";
|
|
7
7
|
import { useArgs } from "@storybook/preview-api";
|
|
8
|
+
import { Button } from "@/index";
|
|
8
9
|
|
|
9
10
|
const meta = {
|
|
10
11
|
title: "Components/Tabs",
|
|
@@ -209,3 +210,50 @@ export const Disabled = {
|
|
|
209
210
|
);
|
|
210
211
|
},
|
|
211
212
|
} satisfies StoryObj;
|
|
213
|
+
|
|
214
|
+
export const Controller = {
|
|
215
|
+
args: {
|
|
216
|
+
initialTab: 1,
|
|
217
|
+
value: 0,
|
|
218
|
+
tabs,
|
|
219
|
+
enableAddTabButton: true,
|
|
220
|
+
},
|
|
221
|
+
render: (args) => {
|
|
222
|
+
const props: any = {
|
|
223
|
+
...args,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const [, setArgs] = useArgs();
|
|
227
|
+
return (
|
|
228
|
+
<div className="flex flex-col gap-4 w-[500px]">
|
|
229
|
+
<div className="flex flex-row gap-2">
|
|
230
|
+
<Button onClick={() => setArgs({ ...props.tabs, value: 0 })}>
|
|
231
|
+
Set active tab 0
|
|
232
|
+
</Button>
|
|
233
|
+
<Button onClick={() => setArgs({ ...props.tabs, value: 1 })}>
|
|
234
|
+
Set active tab 1
|
|
235
|
+
</Button>
|
|
236
|
+
<Button onClick={() => setArgs({ ...props.tabs, value: 2 })}>
|
|
237
|
+
Set active tab 2
|
|
238
|
+
</Button>
|
|
239
|
+
</div>
|
|
240
|
+
<Tabs
|
|
241
|
+
tabs={tabs}
|
|
242
|
+
{...props}
|
|
243
|
+
tabMode="start"
|
|
244
|
+
onAddTab={() => {
|
|
245
|
+
setArgs({
|
|
246
|
+
tabs: [
|
|
247
|
+
...props.tabs,
|
|
248
|
+
{
|
|
249
|
+
label: "Tab" + (props.tabs.length + 1),
|
|
250
|
+
content: <p>Tab {props.tabs.length + 1} content</p>,
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
}}
|
|
255
|
+
/>
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
},
|
|
259
|
+
} satisfies StoryObj;
|
|
@@ -6,6 +6,7 @@ import Icon from "../Icon/Icon";
|
|
|
6
6
|
import { Loading } from "@/index";
|
|
7
7
|
|
|
8
8
|
type Tab = {
|
|
9
|
+
id?: string;
|
|
9
10
|
label: string;
|
|
10
11
|
startTabContent?: React.ReactElement;
|
|
11
12
|
endTabContent?: React.ReactElement;
|
|
@@ -16,6 +17,7 @@ type Tab = {
|
|
|
16
17
|
|
|
17
18
|
type TabsProps = {
|
|
18
19
|
tabs: Tab[];
|
|
20
|
+
value?: number;
|
|
19
21
|
initialTab?: number;
|
|
20
22
|
tabBarSize?: number;
|
|
21
23
|
tabMode?: "start" | "justify";
|
|
@@ -40,6 +42,7 @@ type TabsProps = {
|
|
|
40
42
|
|
|
41
43
|
const Tabs: React.FC<TabsProps> = ({
|
|
42
44
|
tabs = [],
|
|
45
|
+
value,
|
|
43
46
|
initialTab = 0,
|
|
44
47
|
tabBarSize = 38,
|
|
45
48
|
enableBorderLine = true,
|
|
@@ -69,6 +72,12 @@ const Tabs: React.FC<TabsProps> = ({
|
|
|
69
72
|
const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);
|
|
70
73
|
const isInitialMount = useRef(true);
|
|
71
74
|
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (value !== undefined) {
|
|
77
|
+
setActiveTab(value);
|
|
78
|
+
}
|
|
79
|
+
}, [value]);
|
|
80
|
+
|
|
72
81
|
const updateSliderStyle = () => {
|
|
73
82
|
const activeTabElement = tabRefs.current[activeTab];
|
|
74
83
|
if (activeTabElement) {
|
|
@@ -224,7 +233,9 @@ const Tabs: React.FC<TabsProps> = ({
|
|
|
224
233
|
id={`tab-content-${activeTab}`}
|
|
225
234
|
aria-labelledby={`tab-${activeTab}`}
|
|
226
235
|
>
|
|
227
|
-
{tabs[activeTab]
|
|
236
|
+
<div key={tabs[activeTab].label + tabs[activeTab].id ?? Math.random()}>
|
|
237
|
+
{tabs[activeTab]?.content}
|
|
238
|
+
</div>
|
|
228
239
|
</div>
|
|
229
240
|
</div>
|
|
230
241
|
);
|