@rovula/ui 0.0.55 → 0.0.56
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 +1 -0
- package/dist/cjs/types/components/Tabs/Tabs.stories.d.ts +14 -0
- package/dist/components/Tabs/Tabs.js +6 -1
- package/dist/components/Tabs/Tabs.stories.js +24 -0
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Tabs/Tabs.d.ts +1 -0
- package/dist/esm/types/components/Tabs/Tabs.stories.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +48 -0
- package/src/components/Tabs/Tabs.tsx +8 -0
|
@@ -10,6 +10,7 @@ declare const meta: {
|
|
|
10
10
|
disabled?: boolean | undefined;
|
|
11
11
|
isLoading?: boolean | undefined;
|
|
12
12
|
}[];
|
|
13
|
+
value?: number | undefined;
|
|
13
14
|
initialTab?: number | undefined;
|
|
14
15
|
tabBarSize?: number | undefined;
|
|
15
16
|
tabMode?: "start" | "justify" | undefined;
|
|
@@ -44,6 +45,7 @@ declare const meta: {
|
|
|
44
45
|
disabled?: boolean | undefined;
|
|
45
46
|
isLoading?: boolean | undefined;
|
|
46
47
|
}[];
|
|
48
|
+
value?: number | undefined;
|
|
47
49
|
initialTab?: number | undefined;
|
|
48
50
|
tabBarSize?: number | undefined;
|
|
49
51
|
tabMode?: "start" | "justify" | undefined;
|
|
@@ -144,3 +146,15 @@ export declare const Disabled: {
|
|
|
144
146
|
};
|
|
145
147
|
render: (args: {}) => import("react/jsx-runtime").JSX.Element;
|
|
146
148
|
};
|
|
149
|
+
export declare const Controller: {
|
|
150
|
+
args: {
|
|
151
|
+
initialTab: number;
|
|
152
|
+
value: number;
|
|
153
|
+
tabs: {
|
|
154
|
+
label: string;
|
|
155
|
+
content: import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
}[];
|
|
157
|
+
enableAddTabButton: boolean;
|
|
158
|
+
};
|
|
159
|
+
render: (args: {}) => import("react/jsx-runtime").JSX.Element;
|
|
160
|
+
};
|
package/dist/index.d.ts
CHANGED
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;
|
|
@@ -16,6 +16,7 @@ type Tab = {
|
|
|
16
16
|
|
|
17
17
|
type TabsProps = {
|
|
18
18
|
tabs: Tab[];
|
|
19
|
+
value?: number;
|
|
19
20
|
initialTab?: number;
|
|
20
21
|
tabBarSize?: number;
|
|
21
22
|
tabMode?: "start" | "justify";
|
|
@@ -40,6 +41,7 @@ type TabsProps = {
|
|
|
40
41
|
|
|
41
42
|
const Tabs: React.FC<TabsProps> = ({
|
|
42
43
|
tabs = [],
|
|
44
|
+
value,
|
|
43
45
|
initialTab = 0,
|
|
44
46
|
tabBarSize = 38,
|
|
45
47
|
enableBorderLine = true,
|
|
@@ -69,6 +71,12 @@ const Tabs: React.FC<TabsProps> = ({
|
|
|
69
71
|
const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);
|
|
70
72
|
const isInitialMount = useRef(true);
|
|
71
73
|
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (value !== undefined) {
|
|
76
|
+
setActiveTab(value);
|
|
77
|
+
}
|
|
78
|
+
}, [value]);
|
|
79
|
+
|
|
72
80
|
const updateSliderStyle = () => {
|
|
73
81
|
const activeTabElement = tabRefs.current[activeTab];
|
|
74
82
|
if (activeTabElement) {
|