@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.
@@ -10,6 +10,7 @@ type Tab = {
10
10
  };
11
11
  type TabsProps = {
12
12
  tabs: Tab[];
13
+ value?: number;
13
14
  initialTab?: number;
14
15
  tabBarSize?: number;
15
16
  tabMode?: "start" | "justify";
@@ -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
+ };
@@ -5,7 +5,7 @@ import "./Tabs.css";
5
5
  import ActionButton from "../ActionButton/ActionButton";
6
6
  import Icon from "../Icon/Icon";
7
7
  import { Loading } from "@/index";
8
- const Tabs = ({ tabs = [], initialTab = 0, tabBarSize = 38, enableBorderLine = true, enableAddTabButton = false, keepIconSpace = true, disabled = false, tabMode = "start", className, tabBarClassName, tabBarContainerClassName, tabBarWrapperClassName, tabButtonClassName, tabButtonActiveClassName, tabContentClassName, addTabButtonWrapperClassName, borderSliderClassName, leftAction, rightAction, onAddTab, onTabChange, }) => {
8
+ const Tabs = ({ tabs = [], value, initialTab = 0, tabBarSize = 38, enableBorderLine = true, enableAddTabButton = false, keepIconSpace = true, disabled = false, tabMode = "start", className, tabBarClassName, tabBarContainerClassName, tabBarWrapperClassName, tabButtonClassName, tabButtonActiveClassName, tabContentClassName, addTabButtonWrapperClassName, borderSliderClassName, leftAction, rightAction, onAddTab, onTabChange, }) => {
9
9
  var _a;
10
10
  const [activeTab, setActiveTab] = useState(initialTab);
11
11
  const [sliderStyle, setSliderStyle] = useState({
@@ -14,6 +14,11 @@ const Tabs = ({ tabs = [], initialTab = 0, tabBarSize = 38, enableBorderLine = t
14
14
  });
15
15
  const tabRefs = useRef([]);
16
16
  const isInitialMount = useRef(true);
17
+ useEffect(() => {
18
+ if (value !== undefined) {
19
+ setActiveTab(value);
20
+ }
21
+ }, [value]);
17
22
  const updateSliderStyle = () => {
18
23
  const activeTabElement = tabRefs.current[activeTab];
19
24
  if (activeTabElement) {
@@ -4,6 +4,7 @@ import { ChevronDownIcon, ArchiveBoxIcon } from "@heroicons/react/16/solid";
4
4
  import ActionButton from "../ActionButton/ActionButton";
5
5
  import Icon from "../Icon/Icon";
6
6
  import { useArgs } from "@storybook/preview-api";
7
+ import { Button } from "@/index";
7
8
  const meta = {
8
9
  title: "Components/Tabs",
9
10
  component: Tabs,
@@ -114,3 +115,26 @@ export const Disabled = {
114
115
  return (_jsxs("div", { className: "flex flex-row gap-4", children: [_jsx(Tabs, Object.assign({ tabs: tabs }, props)), _jsx(Tabs, Object.assign({ tabs: tabs }, props, { disabled: true }))] }));
115
116
  },
116
117
  };
118
+ export const Controller = {
119
+ args: {
120
+ initialTab: 1,
121
+ value: 0,
122
+ tabs,
123
+ enableAddTabButton: true,
124
+ },
125
+ render: (args) => {
126
+ const props = Object.assign({}, args);
127
+ const [, setArgs] = useArgs();
128
+ return (_jsxs("div", { className: "flex flex-col gap-4 w-[500px]", children: [_jsxs("div", { className: "flex flex-row gap-2", children: [_jsx(Button, { onClick: () => setArgs(Object.assign(Object.assign({}, props.tabs), { value: 0 })), children: "Set active tab 0" }), _jsx(Button, { onClick: () => setArgs(Object.assign(Object.assign({}, props.tabs), { value: 1 })), children: "Set active tab 1" }), _jsx(Button, { onClick: () => setArgs(Object.assign(Object.assign({}, props.tabs), { value: 2 })), children: "Set active tab 2" })] }), _jsx(Tabs, Object.assign({ tabs: tabs }, props, { tabMode: "start", onAddTab: () => {
129
+ setArgs({
130
+ tabs: [
131
+ ...props.tabs,
132
+ {
133
+ label: "Tab" + (props.tabs.length + 1),
134
+ content: _jsxs("p", { children: ["Tab ", props.tabs.length + 1, " content"] }),
135
+ },
136
+ ],
137
+ });
138
+ } }))] }));
139
+ },
140
+ };