@availity/mui-tabs 1.0.0 → 1.1.0
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.js +63 -12
- package/dist/index.mjs +63 -12
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/lib/Tab.tsx +1 -0
- package/src/lib/TabList.stories.tsx +6 -0
- package/src/lib/TabList.tsx +19 -9
- package/src/lib/Tabs.stories.tsx +41 -1
- package/src/lib/Tabs.tsx +46 -5
- package/tsconfig.spec.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/Availity/element/compare/@availity/mui-tabs@1.0.1...@availity/mui-tabs@1.1.0) (2025-03-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-tabs:** add secondary tabs ([8cfca7c](https://github.com/Availity/element/commit/8cfca7ce2d8b1dd6b8ccd7bbed2ddb506b159f38))
|
|
11
|
+
|
|
12
|
+
## [1.0.1](https://github.com/Availity/element/compare/@availity/mui-tabs@1.0.0...@availity/mui-tabs@1.0.1) (2025-03-07)
|
|
13
|
+
|
|
14
|
+
### Dependency Updates
|
|
15
|
+
|
|
16
|
+
* `mui-divider` updated to version `1.0.0`
|
|
5
17
|
## [1.0.0](https://github.com/Availity/element/compare/@availity/mui-tabs@1.0.0-alpha.0...@availity/mui-tabs@1.0.0) (2025-02-25)
|
|
6
18
|
|
|
7
19
|
### Dependency Updates
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TabProps as TabProps$1 } from '@mui/material/Tab';
|
|
2
2
|
import { TabContextProps as TabContextProps$1 } from '@mui/lab/TabContext';
|
|
3
3
|
import { TabListProps as TabListProps$1 } from '@mui/lab/TabList';
|
|
4
|
-
import { TabPanelProps as TabPanelProps$1 } from '@mui/lab/TabPanel';
|
|
5
4
|
import { TabsProps as TabsProps$1 } from '@mui/material/Tabs';
|
|
5
|
+
import { TabPanelProps as TabPanelProps$1 } from '@mui/lab/TabPanel';
|
|
6
6
|
|
|
7
|
-
type TabProps = Omit<TabProps$1, 'centerRipple' | 'disableFocusRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'icon' | 'iconPosition' | 'TouchRippleProps'>;
|
|
7
|
+
type TabProps = Omit<TabProps$1, 'centerRipple' | 'disableFocusRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'icon' | 'iconPosition' | 'touchRippleRef' | 'TouchRippleProps'>;
|
|
8
8
|
declare const Tab: (props: TabProps) => JSX.Element;
|
|
9
9
|
|
|
10
10
|
interface TabContextProps extends TabContextProps$1 {
|
|
@@ -12,19 +12,18 @@ interface TabContextProps extends TabContextProps$1 {
|
|
|
12
12
|
}
|
|
13
13
|
declare const TabContext: ({ children, ...rest }: TabContextProps) => JSX.Element;
|
|
14
14
|
|
|
15
|
-
interface
|
|
16
|
-
|
|
15
|
+
interface TabsProps extends Omit<TabsProps$1, 'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'> {
|
|
16
|
+
/** The hierarchy level of the tabs, i.e. `primary` for top level tabs, `secondary` for inner tabs. */
|
|
17
|
+
level?: "primary" | "secondary";
|
|
17
18
|
}
|
|
18
|
-
declare const
|
|
19
|
+
declare const Tabs: ({ level, ...rest }: TabsProps) => JSX.Element;
|
|
20
|
+
|
|
21
|
+
type TabListProps = Omit<TabListProps$1, 'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'> & Pick<TabsProps, 'level'>;
|
|
22
|
+
declare const TabList: ({ level, ...rest }: TabListProps) => JSX.Element;
|
|
19
23
|
|
|
20
24
|
interface TabPanelProps extends TabPanelProps$1 {
|
|
21
25
|
children?: React.ReactNode;
|
|
22
26
|
}
|
|
23
27
|
declare const TabPanel: ({ children, ...rest }: TabPanelProps) => JSX.Element;
|
|
24
28
|
|
|
25
|
-
interface TabsProps extends Omit<TabsProps$1, 'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'> {
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
}
|
|
28
|
-
declare const Tabs: ({ children, ...rest }: TabsProps) => JSX.Element;
|
|
29
|
-
|
|
30
29
|
export { Tab, TabContext, type TabContextProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TabProps as TabProps$1 } from '@mui/material/Tab';
|
|
2
2
|
import { TabContextProps as TabContextProps$1 } from '@mui/lab/TabContext';
|
|
3
3
|
import { TabListProps as TabListProps$1 } from '@mui/lab/TabList';
|
|
4
|
-
import { TabPanelProps as TabPanelProps$1 } from '@mui/lab/TabPanel';
|
|
5
4
|
import { TabsProps as TabsProps$1 } from '@mui/material/Tabs';
|
|
5
|
+
import { TabPanelProps as TabPanelProps$1 } from '@mui/lab/TabPanel';
|
|
6
6
|
|
|
7
|
-
type TabProps = Omit<TabProps$1, 'centerRipple' | 'disableFocusRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'icon' | 'iconPosition' | 'TouchRippleProps'>;
|
|
7
|
+
type TabProps = Omit<TabProps$1, 'centerRipple' | 'disableFocusRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'icon' | 'iconPosition' | 'touchRippleRef' | 'TouchRippleProps'>;
|
|
8
8
|
declare const Tab: (props: TabProps) => JSX.Element;
|
|
9
9
|
|
|
10
10
|
interface TabContextProps extends TabContextProps$1 {
|
|
@@ -12,19 +12,18 @@ interface TabContextProps extends TabContextProps$1 {
|
|
|
12
12
|
}
|
|
13
13
|
declare const TabContext: ({ children, ...rest }: TabContextProps) => JSX.Element;
|
|
14
14
|
|
|
15
|
-
interface
|
|
16
|
-
|
|
15
|
+
interface TabsProps extends Omit<TabsProps$1, 'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'> {
|
|
16
|
+
/** The hierarchy level of the tabs, i.e. `primary` for top level tabs, `secondary` for inner tabs. */
|
|
17
|
+
level?: "primary" | "secondary";
|
|
17
18
|
}
|
|
18
|
-
declare const
|
|
19
|
+
declare const Tabs: ({ level, ...rest }: TabsProps) => JSX.Element;
|
|
20
|
+
|
|
21
|
+
type TabListProps = Omit<TabListProps$1, 'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'> & Pick<TabsProps, 'level'>;
|
|
22
|
+
declare const TabList: ({ level, ...rest }: TabListProps) => JSX.Element;
|
|
19
23
|
|
|
20
24
|
interface TabPanelProps extends TabPanelProps$1 {
|
|
21
25
|
children?: React.ReactNode;
|
|
22
26
|
}
|
|
23
27
|
declare const TabPanel: ({ children, ...rest }: TabPanelProps) => JSX.Element;
|
|
24
28
|
|
|
25
|
-
interface TabsProps extends Omit<TabsProps$1, 'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'> {
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
}
|
|
28
|
-
declare const Tabs: ({ children, ...rest }: TabsProps) => JSX.Element;
|
|
29
|
-
|
|
30
29
|
export { Tab, TabContext, type TabContextProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps };
|
package/dist/index.js
CHANGED
|
@@ -84,26 +84,77 @@ var TabContext = (_a) => {
|
|
|
84
84
|
|
|
85
85
|
// src/lib/TabList.tsx
|
|
86
86
|
var import_TabList = __toESM(require("@mui/lab/TabList"));
|
|
87
|
+
|
|
88
|
+
// src/lib/Tabs.tsx
|
|
89
|
+
var import_styles = require("@mui/material/styles");
|
|
90
|
+
var import_Tabs = __toESM(require("@mui/material/Tabs"));
|
|
87
91
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
var secondaryTabStyling = ({ theme }) => ({
|
|
93
|
+
".MuiTabs-indicator": {
|
|
94
|
+
display: "none"
|
|
95
|
+
},
|
|
96
|
+
".MuiTab-root": {
|
|
97
|
+
borderTopLeftRadius: ".25rem",
|
|
98
|
+
borderTopRightRadius: ".25rem",
|
|
99
|
+
border: "1px solid",
|
|
100
|
+
borderColor: "transparent",
|
|
101
|
+
marginBottom: "-1px",
|
|
102
|
+
"&:hover, &:hover.Mui-selected": {
|
|
103
|
+
backgroundColor: theme.palette.action.hover
|
|
104
|
+
},
|
|
105
|
+
"&.Mui-focusVisible": {
|
|
106
|
+
outline: `2px solid ${theme.palette.primary.main}`,
|
|
107
|
+
backgroundColor: "inherit",
|
|
108
|
+
outlineOffset: "-2px"
|
|
109
|
+
},
|
|
110
|
+
"&.Mui-selected": {
|
|
111
|
+
backgroundColor: theme.palette.background.paper,
|
|
112
|
+
borderColor: theme.palette.divider,
|
|
113
|
+
borderBottomColor: theme.palette.background.paper
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
var PrimaryTabs = (0, import_styles.styled)(import_Tabs.default, {
|
|
118
|
+
name: "MuiTabs",
|
|
119
|
+
slot: "AvPrimary",
|
|
120
|
+
overridesResolver: (props, styles) => styles.avPrimary
|
|
121
|
+
})({});
|
|
122
|
+
var SecondaryTabs = (0, import_styles.styled)(import_Tabs.default, {
|
|
123
|
+
name: "MuiTabs",
|
|
124
|
+
slot: "AvSecondary",
|
|
125
|
+
overridesResolver: (props, styles) => styles.avSecondary
|
|
126
|
+
})(secondaryTabStyling);
|
|
127
|
+
var Tabs = (_a) => {
|
|
128
|
+
var _b = _a, { level = "primary" } = _b, rest = __objRest(_b, ["level"]);
|
|
129
|
+
const LevelledTabs = level === "primary" ? PrimaryTabs : SecondaryTabs;
|
|
130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LevelledTabs, __spreadProps(__spreadValues({}, rest), { orientation: "horizontal", centered: false }));
|
|
91
131
|
};
|
|
92
132
|
|
|
93
|
-
// src/lib/
|
|
94
|
-
var
|
|
133
|
+
// src/lib/TabList.tsx
|
|
134
|
+
var import_styles2 = require("@mui/material/styles");
|
|
95
135
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
136
|
+
var PrimaryTabs2 = (0, import_styles2.styled)(import_TabList.default, {
|
|
137
|
+
name: "MuiTabs",
|
|
138
|
+
slot: "AvPrimary",
|
|
139
|
+
overridesResolver: (props, styles) => styles.avPrimary
|
|
140
|
+
})({});
|
|
141
|
+
var SecondaryTabs2 = (0, import_styles2.styled)(import_TabList.default, {
|
|
142
|
+
name: "MuiTabs",
|
|
143
|
+
slot: "AvSecondary",
|
|
144
|
+
overridesResolver: (props, styles) => styles.avSecondary
|
|
145
|
+
})(secondaryTabStyling);
|
|
146
|
+
var TabList = (_a) => {
|
|
147
|
+
var _b = _a, { level = "primary" } = _b, rest = __objRest(_b, ["level"]);
|
|
148
|
+
const LevelledTabs = level === "primary" ? PrimaryTabs2 : SecondaryTabs2;
|
|
149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LevelledTabs, __spreadProps(__spreadValues({}, rest), { orientation: "horizontal", centered: false }));
|
|
99
150
|
};
|
|
100
151
|
|
|
101
|
-
// src/lib/
|
|
102
|
-
var
|
|
152
|
+
// src/lib/TabPanel.tsx
|
|
153
|
+
var import_TabPanel = __toESM(require("@mui/lab/TabPanel"));
|
|
103
154
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
104
|
-
var
|
|
155
|
+
var TabPanel = (_a) => {
|
|
105
156
|
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
106
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_TabPanel.default, __spreadProps(__spreadValues({}, rest), { children }));
|
|
107
158
|
};
|
|
108
159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
160
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -47,26 +47,77 @@ var TabContext = (_a) => {
|
|
|
47
47
|
|
|
48
48
|
// src/lib/TabList.tsx
|
|
49
49
|
import { default as MuiTabList } from "@mui/lab/TabList";
|
|
50
|
+
|
|
51
|
+
// src/lib/Tabs.tsx
|
|
52
|
+
import { styled } from "@mui/material/styles";
|
|
53
|
+
import { default as MuiTabs } from "@mui/material/Tabs";
|
|
50
54
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
var secondaryTabStyling = ({ theme }) => ({
|
|
56
|
+
".MuiTabs-indicator": {
|
|
57
|
+
display: "none"
|
|
58
|
+
},
|
|
59
|
+
".MuiTab-root": {
|
|
60
|
+
borderTopLeftRadius: ".25rem",
|
|
61
|
+
borderTopRightRadius: ".25rem",
|
|
62
|
+
border: "1px solid",
|
|
63
|
+
borderColor: "transparent",
|
|
64
|
+
marginBottom: "-1px",
|
|
65
|
+
"&:hover, &:hover.Mui-selected": {
|
|
66
|
+
backgroundColor: theme.palette.action.hover
|
|
67
|
+
},
|
|
68
|
+
"&.Mui-focusVisible": {
|
|
69
|
+
outline: `2px solid ${theme.palette.primary.main}`,
|
|
70
|
+
backgroundColor: "inherit",
|
|
71
|
+
outlineOffset: "-2px"
|
|
72
|
+
},
|
|
73
|
+
"&.Mui-selected": {
|
|
74
|
+
backgroundColor: theme.palette.background.paper,
|
|
75
|
+
borderColor: theme.palette.divider,
|
|
76
|
+
borderBottomColor: theme.palette.background.paper
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
var PrimaryTabs = styled(MuiTabs, {
|
|
81
|
+
name: "MuiTabs",
|
|
82
|
+
slot: "AvPrimary",
|
|
83
|
+
overridesResolver: (props, styles) => styles.avPrimary
|
|
84
|
+
})({});
|
|
85
|
+
var SecondaryTabs = styled(MuiTabs, {
|
|
86
|
+
name: "MuiTabs",
|
|
87
|
+
slot: "AvSecondary",
|
|
88
|
+
overridesResolver: (props, styles) => styles.avSecondary
|
|
89
|
+
})(secondaryTabStyling);
|
|
90
|
+
var Tabs = (_a) => {
|
|
91
|
+
var _b = _a, { level = "primary" } = _b, rest = __objRest(_b, ["level"]);
|
|
92
|
+
const LevelledTabs = level === "primary" ? PrimaryTabs : SecondaryTabs;
|
|
93
|
+
return /* @__PURE__ */ jsx3(LevelledTabs, __spreadProps(__spreadValues({}, rest), { orientation: "horizontal", centered: false }));
|
|
54
94
|
};
|
|
55
95
|
|
|
56
|
-
// src/lib/
|
|
57
|
-
import {
|
|
96
|
+
// src/lib/TabList.tsx
|
|
97
|
+
import { styled as styled2 } from "@mui/material/styles";
|
|
58
98
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
99
|
+
var PrimaryTabs2 = styled2(MuiTabList, {
|
|
100
|
+
name: "MuiTabs",
|
|
101
|
+
slot: "AvPrimary",
|
|
102
|
+
overridesResolver: (props, styles) => styles.avPrimary
|
|
103
|
+
})({});
|
|
104
|
+
var SecondaryTabs2 = styled2(MuiTabList, {
|
|
105
|
+
name: "MuiTabs",
|
|
106
|
+
slot: "AvSecondary",
|
|
107
|
+
overridesResolver: (props, styles) => styles.avSecondary
|
|
108
|
+
})(secondaryTabStyling);
|
|
109
|
+
var TabList = (_a) => {
|
|
110
|
+
var _b = _a, { level = "primary" } = _b, rest = __objRest(_b, ["level"]);
|
|
111
|
+
const LevelledTabs = level === "primary" ? PrimaryTabs2 : SecondaryTabs2;
|
|
112
|
+
return /* @__PURE__ */ jsx4(LevelledTabs, __spreadProps(__spreadValues({}, rest), { orientation: "horizontal", centered: false }));
|
|
62
113
|
};
|
|
63
114
|
|
|
64
|
-
// src/lib/
|
|
65
|
-
import { default as
|
|
115
|
+
// src/lib/TabPanel.tsx
|
|
116
|
+
import { default as MuiTabPanel } from "@mui/lab/TabPanel";
|
|
66
117
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
67
|
-
var
|
|
118
|
+
var TabPanel = (_a) => {
|
|
68
119
|
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
69
|
-
return /* @__PURE__ */ jsx5(
|
|
120
|
+
return /* @__PURE__ */ jsx5(MuiTabPanel, __spreadProps(__spreadValues({}, rest), { children }));
|
|
70
121
|
};
|
|
71
122
|
export {
|
|
72
123
|
Tab,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-tabs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Availity MUI Tabs Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@mui/lab": "6.0.0-beta.12"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@availity/mui-divider": "^1.0.
|
|
46
|
+
"@availity/mui-divider": "^1.0.1",
|
|
47
47
|
"@mui/material": "^6.4.5",
|
|
48
48
|
"react": "18.2.0",
|
|
49
49
|
"react-dom": "18.2.0",
|
package/src/index.ts
CHANGED
package/src/lib/Tab.tsx
CHANGED
|
@@ -10,6 +10,12 @@ import { TabPanel } from './TabPanel';
|
|
|
10
10
|
const meta: Meta<typeof TabList> = {
|
|
11
11
|
title: 'Components/Tabs/TabList',
|
|
12
12
|
component: TabList,
|
|
13
|
+
argTypes: {
|
|
14
|
+
level: {
|
|
15
|
+
options: ['primary', 'secondary'],
|
|
16
|
+
control: { type: 'radio' },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
13
19
|
tags: ['autodocs'],
|
|
14
20
|
};
|
|
15
21
|
|
package/src/lib/TabList.tsx
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { default as MuiTabList, TabListProps as MuiTabListProps } from '@mui/lab/TabList';
|
|
2
|
+
import { TabsProps, secondaryTabStyling } from './Tabs';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
2
4
|
|
|
3
|
-
export
|
|
4
|
-
extends Omit<
|
|
5
|
+
export type TabListProps = Omit<
|
|
5
6
|
MuiTabListProps,
|
|
6
7
|
'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'
|
|
7
|
-
>
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
}
|
|
8
|
+
> & Pick<TabsProps, 'level'>
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
const PrimaryTabs = styled(MuiTabList, {
|
|
11
|
+
name: 'MuiTabs',
|
|
12
|
+
slot: 'AvPrimary',
|
|
13
|
+
overridesResolver: (props, styles) => styles.avPrimary,
|
|
14
|
+
})({});
|
|
15
|
+
|
|
16
|
+
const SecondaryTabs = styled(MuiTabList, {
|
|
17
|
+
name: 'MuiTabs',
|
|
18
|
+
slot: 'AvSecondary',
|
|
19
|
+
overridesResolver: (props, styles) => styles.avSecondary,
|
|
20
|
+
})<{ ownerState: MuiTabListProps }>(secondaryTabStyling);
|
|
21
|
+
|
|
22
|
+
export const TabList = ({ level = 'primary', ...rest }: TabListProps): JSX.Element => {
|
|
23
|
+
const LevelledTabs = level === 'primary' ? PrimaryTabs : SecondaryTabs;
|
|
12
24
|
return (
|
|
13
|
-
<
|
|
14
|
-
{children}
|
|
15
|
-
</MuiTabList>
|
|
25
|
+
<LevelledTabs {...rest} orientation="horizontal" centered={false}/>
|
|
16
26
|
);
|
|
17
27
|
};
|
package/src/lib/Tabs.stories.tsx
CHANGED
|
@@ -10,6 +10,12 @@ import { Tab } from './Tab';
|
|
|
10
10
|
const meta: Meta<typeof Tabs> = {
|
|
11
11
|
title: 'Components/Tabs/Tabs',
|
|
12
12
|
component: Tabs,
|
|
13
|
+
argTypes: {
|
|
14
|
+
level: {
|
|
15
|
+
options: ['primary', 'secondary'],
|
|
16
|
+
control: { type: 'radio' },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
13
19
|
tags: ['autodocs'],
|
|
14
20
|
};
|
|
15
21
|
|
|
@@ -40,7 +46,7 @@ function CustomTabPanel(props: TabPanelProps) {
|
|
|
40
46
|
>
|
|
41
47
|
{value === index && (
|
|
42
48
|
<Box sx={{ p: 3 }}>
|
|
43
|
-
<Typography>Hello from panel {index}</Typography>
|
|
49
|
+
<Typography>Hello from panel {index + 1}</Typography>
|
|
44
50
|
</Box>
|
|
45
51
|
)}
|
|
46
52
|
</div>
|
|
@@ -94,3 +100,37 @@ export const _TabsScrollable: StoryObj<typeof Tabs> = {
|
|
|
94
100
|
variant: 'scrollable',
|
|
95
101
|
},
|
|
96
102
|
};
|
|
103
|
+
|
|
104
|
+
/** There is a hierarchy for tab styling. Most tabs will have the primary level styling while nested tabs have the secondary level styling. */
|
|
105
|
+
export const _Levels: StoryObj<typeof Tabs> = {
|
|
106
|
+
render: () => {
|
|
107
|
+
return (
|
|
108
|
+
<Box sx={{ p: 3, backgroundColor: 'background.paper' }}>
|
|
109
|
+
<Tabs level="primary" value={0} onChange={() => {}}>
|
|
110
|
+
<Tab label="Item One" {...a11yProps(0)} />
|
|
111
|
+
<Tab label="Item Two" {...a11yProps(1)} />
|
|
112
|
+
<Tab label="Item Three" {...a11yProps(2)} disabled />
|
|
113
|
+
</Tabs>
|
|
114
|
+
<div
|
|
115
|
+
role="tabpanel"
|
|
116
|
+
id={`simple-tabpanel-0`}
|
|
117
|
+
aria-labelledby={`simple-tab-0`}
|
|
118
|
+
>
|
|
119
|
+
<Box sx={{ p: 3 }}>
|
|
120
|
+
<Typography sx={{mb: 2}}>Hello from panel 1</Typography>
|
|
121
|
+
<Tabs level="secondary" value={1} onChange={()=> {}} >
|
|
122
|
+
<Tab label="Item Four" {...a11yProps(3)} />
|
|
123
|
+
<Tab label="Item Five" {...a11yProps(4)} />
|
|
124
|
+
<Tab label="Item Six" {...a11yProps(5)} disabled />
|
|
125
|
+
</Tabs>
|
|
126
|
+
<CustomTabPanel value={4} index={3} />
|
|
127
|
+
<CustomTabPanel value={4} index={4} />
|
|
128
|
+
<CustomTabPanel value={4} index={5} />
|
|
129
|
+
</Box>
|
|
130
|
+
</div>
|
|
131
|
+
<CustomTabPanel value={0} index={1} />
|
|
132
|
+
<CustomTabPanel value={0} index={2} />
|
|
133
|
+
</Box>
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
};
|
package/src/lib/Tabs.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
|
+
import type { Theme } from '@mui/material/styles';
|
|
1
3
|
import { default as MuiTabs, TabsProps as MuiTabsProps } from '@mui/material/Tabs';
|
|
2
4
|
|
|
3
5
|
export interface TabsProps
|
|
@@ -5,13 +7,52 @@ export interface TabsProps
|
|
|
5
7
|
MuiTabsProps,
|
|
6
8
|
'centered' | 'centerRipple' | 'focusRipple' | 'orientation' | 'TouchRippleProps' | 'touchRippleRef'
|
|
7
9
|
> {
|
|
8
|
-
|
|
10
|
+
/** The hierarchy level of the tabs, i.e. `primary` for top level tabs, `secondary` for inner tabs. */
|
|
11
|
+
level?: "primary" | "secondary";
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
export const
|
|
14
|
+
export const secondaryTabStyling = ({theme}: {theme:Theme} ) => ({
|
|
15
|
+
'.MuiTabs-indicator': {
|
|
16
|
+
display: 'none'
|
|
17
|
+
},
|
|
18
|
+
'.MuiTab-root': {
|
|
19
|
+
borderTopLeftRadius: '.25rem',
|
|
20
|
+
borderTopRightRadius: '.25rem',
|
|
21
|
+
border: '1px solid',
|
|
22
|
+
borderColor: 'transparent',
|
|
23
|
+
marginBottom: '-1px',
|
|
24
|
+
'&:hover, &:hover.Mui-selected': {
|
|
25
|
+
backgroundColor: theme.palette.action.hover,
|
|
26
|
+
},
|
|
27
|
+
'&.Mui-focusVisible': {
|
|
28
|
+
outline: `2px solid ${theme.palette.primary.main}`,
|
|
29
|
+
backgroundColor: 'inherit',
|
|
30
|
+
outlineOffset: '-2px',
|
|
31
|
+
},
|
|
32
|
+
'&.Mui-selected': {
|
|
33
|
+
backgroundColor: theme.palette.background.paper,
|
|
34
|
+
borderColor: theme.palette.divider,
|
|
35
|
+
borderBottomColor: theme.palette.background.paper,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const PrimaryTabs = styled(MuiTabs, {
|
|
41
|
+
name: 'MuiTabs',
|
|
42
|
+
slot: 'AvPrimary',
|
|
43
|
+
overridesResolver: (props, styles) => styles.avPrimary,
|
|
44
|
+
})({});
|
|
45
|
+
|
|
46
|
+
const SecondaryTabs = styled(MuiTabs, {
|
|
47
|
+
name: 'MuiTabs',
|
|
48
|
+
slot: 'AvSecondary',
|
|
49
|
+
overridesResolver: (props, styles) => styles.avSecondary,
|
|
50
|
+
})<{ ownerState: MuiTabsProps }>(secondaryTabStyling);
|
|
51
|
+
|
|
52
|
+
export const Tabs = ({level = "primary", ...rest}: TabsProps): JSX.Element => {
|
|
53
|
+
const LevelledTabs = level === 'primary' ? PrimaryTabs : SecondaryTabs;
|
|
54
|
+
|
|
12
55
|
return (
|
|
13
|
-
<
|
|
14
|
-
{children}
|
|
15
|
-
</MuiTabs>
|
|
56
|
+
<LevelledTabs {...rest} orientation="horizontal" centered={false}/>
|
|
16
57
|
);
|
|
17
58
|
};
|
package/tsconfig.spec.json
CHANGED