@thecb/components 11.4.0-beta.0 → 11.4.1-beta.1
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/index.cjs.js +29 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +29 -19
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/form-layouts/FormTextarea.js +0 -1
- package/src/components/molecules/tabs/Tabs.js +18 -9
- package/src/components/molecules/tabs/index.d.ts +21 -0
package/package.json
CHANGED
|
@@ -149,7 +149,6 @@ const FormTextarea = ({
|
|
|
149
149
|
(field.dirty && field.hasErrors) || (field.hasErrors && showErrors)
|
|
150
150
|
}
|
|
151
151
|
onChange={e => setValue(e.target.value)}
|
|
152
|
-
onBlur={e => handleOnBlur(e.target.value)}
|
|
153
152
|
value={field.rawValue}
|
|
154
153
|
field={field}
|
|
155
154
|
showErrors={showErrors}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, Fragment } from "react";
|
|
1
|
+
import React, { useState, Fragment, useEffect } from "react";
|
|
2
2
|
import { Stack, Box, Cluster } from "../../atoms/layouts";
|
|
3
3
|
import { themeComponent } from "../../../util/themeUtils";
|
|
4
4
|
import { fallbackValues } from "./Tabs.theme";
|
|
@@ -6,11 +6,20 @@ import Tab from "../../atoms/tab";
|
|
|
6
6
|
|
|
7
7
|
const HORIZONTAL = "horizontal";
|
|
8
8
|
|
|
9
|
-
const Tabs = ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const Tabs = ({ tabsConfig, tabsDisplayMode = HORIZONTAL, ...props }) => {
|
|
10
|
+
const [activeTab, toggleActiveTab] = useState(
|
|
11
|
+
tabsConfig.tabs[0]?.label || null
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const currentTabExists = tabsConfig.tabs.some(
|
|
16
|
+
tab => tab.label === activeTab
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (!activeTab || !currentTabExists) {
|
|
20
|
+
toggleActiveTab(tabsConfig.tabs[0]?.label || null);
|
|
21
|
+
}
|
|
22
|
+
}, [tabsConfig, activeTab]);
|
|
14
23
|
|
|
15
24
|
const createTabs = (tabConfig, activeTab) => {
|
|
16
25
|
return tabConfig.tabs.map(tab => {
|
|
@@ -25,7 +34,7 @@ const Tabs = ({
|
|
|
25
34
|
});
|
|
26
35
|
};
|
|
27
36
|
|
|
28
|
-
const
|
|
37
|
+
const showHorizontal = (tabsConfig, activeTab) => {
|
|
29
38
|
return (
|
|
30
39
|
<Cluster justify={"space-around"}>
|
|
31
40
|
{createTabs(tabsConfig, activeTab)}
|
|
@@ -38,10 +47,10 @@ const Tabs = ({
|
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
return (
|
|
41
|
-
<Box className="tabs">
|
|
50
|
+
<Box className="tabs" {...props}>
|
|
42
51
|
<Box className="tab-list">
|
|
43
52
|
{tabsDisplayMode == HORIZONTAL
|
|
44
|
-
?
|
|
53
|
+
? showHorizontal(tabsConfig, activeTab)
|
|
45
54
|
: showVertical(tabsConfig, activeTab)}
|
|
46
55
|
</Box>
|
|
47
56
|
<Box className="tab-content">
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Expand from "../../../util/expand";
|
|
3
|
+
|
|
4
|
+
export interface TabConfig {
|
|
5
|
+
label: string;
|
|
6
|
+
content: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TabsConfigObject {
|
|
10
|
+
tabs: TabConfig[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TabsProps {
|
|
14
|
+
tabsConfig: TabsConfigObject;
|
|
15
|
+
tabsDisplayMode?: "horizontal" | "vertical";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare const Tabs: React.FC<Expand<TabsProps> &
|
|
19
|
+
React.HTMLAttributes<HTMLElement>>;
|
|
20
|
+
|
|
21
|
+
export default Tabs;
|