@availity/mui-tabs 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.1.1](https://github.com/Availity/element/compare/@availity/mui-tabs@0.1.0...@availity/mui-tabs@0.1.1) (2023-08-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **mui-tabs:** fix invalid ARIA attributes in Tab stories ([483b1ad](https://github.com/Availity/element/commit/483b1ad0fd30025cbce96e03dec0e496467f75ef))
11
+
5
12
  ## 0.1.0 (2023-07-14)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-tabs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Availity MUI Tabs Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { useState } from 'react';
4
4
  import type { Meta, StoryObj } from '@storybook/react';
5
+ import { Box, Typography } from '@mui/material';
5
6
  import { Tabs } from './Tabs';
6
7
  import { Tab, TabProps } from './Tab';
7
8
 
@@ -22,17 +23,46 @@ function a11yProps(index: number) {
22
23
 
23
24
  export const _Tab: StoryObj<typeof Tab> = {
24
25
  render: (args: TabProps) => {
26
+ interface TabPanelProps {
27
+ children?: React.ReactNode;
28
+ index: number;
29
+ value: number;
30
+ }
25
31
  const [value, setValue] = useState(0);
26
32
 
27
33
  const handleChange = (event: React.SyntheticEvent, newValue: number) => {
28
34
  setValue(newValue);
29
35
  };
36
+ function CustomTabPanel(props: TabPanelProps) {
37
+ const { value, index, ...other } = props;
38
+
39
+ return (
40
+ <div
41
+ role="tabpanel"
42
+ hidden={value !== index}
43
+ id={`simple-tabpanel-${index}`}
44
+ aria-labelledby={`simple-tab-${index}`}
45
+ {...other}
46
+ >
47
+ {value === index && (
48
+ <Box sx={{ p: 3 }}>
49
+ <Typography>Hello from panel {index}</Typography>
50
+ </Box>
51
+ )}
52
+ </div>
53
+ );
54
+ }
30
55
  return (
31
- <Tabs value={value} onChange={handleChange}>
32
- <Tab label="Item One" {...args} {...a11yProps(0)} />
33
- <Tab label="Item Two" {...args} {...a11yProps(1)} />
34
- <Tab label="Item Three" {...args} {...a11yProps(2)} disabled />
35
- </Tabs>
56
+ <>
57
+ <Tabs value={value} onChange={handleChange}>
58
+ <Tab label="Item One" {...args} {...a11yProps(0)} />
59
+ <Tab label="Item Two" {...args} {...a11yProps(1)} />
60
+ <Tab label="Item Three" {...args} {...a11yProps(2)} disabled />
61
+ </Tabs>
62
+ <CustomTabPanel value={value} index={0} />
63
+ <CustomTabPanel value={value} index={1} />
64
+ <CustomTabPanel value={value} index={2} />
65
+ </>
36
66
  );
37
67
  },
38
68
  args: {},
@@ -5,6 +5,7 @@ import type { Meta, StoryObj } from '@storybook/react';
5
5
  import { TabList, TabListProps } from './TabList';
6
6
  import { Tab } from './Tab';
7
7
  import { TabContext } from './TabContext';
8
+ import { TabPanel } from './TabPanel';
8
9
 
9
10
  const meta: Meta<typeof TabList> = {
10
11
  title: 'Components/Tabs/TabList',
@@ -28,6 +29,9 @@ export const _TabList: StoryObj<typeof TabList> = {
28
29
  <Tab label="Item Two" value="2" />
29
30
  <Tab label="Item Three" value="3" />
30
31
  </TabList>
32
+ <TabPanel value="1" children={`Hello from Panel ${value}`} />
33
+ <TabPanel value="2" children={`Hello from Panel ${value}`} />
34
+ <TabPanel value="3" children={`Hello from Panel ${value}`} />
31
35
  </TabContext>
32
36
  );
33
37
  },
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { useState } from 'react';
4
4
  import type { Meta, StoryObj } from '@storybook/react';
5
+ import { Box, Typography } from '@mui/material';
5
6
  import { Tabs, TabsProps } from './Tabs';
6
7
  import { Tab } from './Tab';
7
8
 
@@ -22,17 +23,46 @@ function a11yProps(index: number) {
22
23
 
23
24
  export const _Tabs: StoryObj<typeof Tabs> = {
24
25
  render: (args: TabsProps) => {
26
+ interface TabPanelProps {
27
+ children?: React.ReactNode;
28
+ index: number;
29
+ value: number;
30
+ }
25
31
  const [value, setValue] = useState(0);
26
32
 
27
33
  const handleChange = (event: React.SyntheticEvent, newValue: number) => {
28
34
  setValue(newValue);
29
35
  };
36
+ function CustomTabPanel(props: TabPanelProps) {
37
+ const { value, index, ...other } = props;
38
+
39
+ return (
40
+ <div
41
+ role="tabpanel"
42
+ hidden={value !== index}
43
+ id={`simple-tabpanel-${index}`}
44
+ aria-labelledby={`simple-tab-${index}`}
45
+ {...other}
46
+ >
47
+ {value === index && (
48
+ <Box sx={{ p: 3 }}>
49
+ <Typography>Hello from panel {index}</Typography>
50
+ </Box>
51
+ )}
52
+ </div>
53
+ );
54
+ }
30
55
  return (
31
- <Tabs {...args} value={value} onChange={handleChange}>
32
- <Tab label="Item One" {...a11yProps(0)} />
33
- <Tab label="Item Two" {...a11yProps(1)} />
34
- <Tab label="Item Three" {...a11yProps(2)} />
35
- </Tabs>
56
+ <>
57
+ <Tabs value={value} onChange={handleChange} {...args}>
58
+ <Tab label="Item One" {...a11yProps(0)} />
59
+ <Tab label="Item Two" {...a11yProps(1)} />
60
+ <Tab label="Item Three" {...a11yProps(2)} disabled />
61
+ </Tabs>
62
+ <CustomTabPanel value={value} index={0} />
63
+ <CustomTabPanel value={value} index={1} />
64
+ <CustomTabPanel value={value} index={2} />
65
+ </>
36
66
  );
37
67
  },
38
68
  };