qpp-style 9.39.2 → 9.41.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.
@@ -0,0 +1,5 @@
1
+ const TabPanel = ({ children }) => {
2
+ return children;
3
+ };
4
+
5
+ export default TabPanel;
@@ -0,0 +1,73 @@
1
+ import React, { Children } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { TabList, Tab, TabPanel, useTabState } from "ariakit/tab";
4
+
5
+ function Tabs({ defaultSelectedId, children, onChange, selected }) {
6
+ const tab = useTabState({
7
+ defaultSelectedId: selected ?? defaultSelectedId,
8
+ selectOnMove: false,
9
+ });
10
+
11
+ const onTabClick = (tabHref, id) => {
12
+ if (tabHref) {
13
+ const currentUrl = new URL(window.location.href);
14
+ const newParams = new URLSearchParams(tabHref);
15
+ newParams.forEach((value, key) => {
16
+ currentUrl.searchParams.set(key, value);
17
+ });
18
+ window.history.replaceState(null, "", currentUrl);
19
+ }
20
+
21
+ if (onChange) {
22
+ onChange(id);
23
+ }
24
+ };
25
+
26
+ return (
27
+ <>
28
+ <div className="qpp-c-tabs qpp-c-tabs--mui">
29
+ <TabList state={tab} aria-label="qpp tabs">
30
+ {Children.map(children, (child) => (
31
+ <Tab
32
+ key={child.props.id}
33
+ id={child.props.id}
34
+ className="qpp-c-tabs__item"
35
+ disabled={child.props.disabled}
36
+ onClick={() => onTabClick(child.props.tabHref, child.props.id)}
37
+ >
38
+ {child.props.tab}
39
+ </Tab>
40
+ ))}
41
+ </TabList>
42
+ </div>
43
+ <div className="qpp-c-tabs__panel">
44
+ {Children.map(children, (child) => (
45
+ <TabPanel
46
+ key={child.props.id}
47
+ state={tab}
48
+ tabId={child.props.id}
49
+ className={child.props.className}
50
+ disabled={child.props.disabled}
51
+ >
52
+ {child.props.children}
53
+ </TabPanel>
54
+ ))}
55
+ </div>
56
+ </>
57
+ );
58
+ }
59
+
60
+ Tabs.propTypes = {
61
+ defaultSelectedId: PropTypes.string,
62
+ children: PropTypes.node.isRequired,
63
+ onChange: PropTypes.func,
64
+ selected: PropTypes.string,
65
+ };
66
+
67
+ Tabs.defaultProps = {
68
+ defaultSelectedId: undefined,
69
+ onChange: undefined,
70
+ selected: undefined,
71
+ };
72
+
73
+ export default Tabs;
@@ -2,6 +2,9 @@ import Button, { TextButton } from "./Button";
2
2
  import Footer from "./Footer/FooterUI";
3
3
  import Header from "./Header/HeaderUI";
4
4
  import SideNav from "./SideNav/UI/SideNavUI";
5
+ import Dropdown from "./Dropdown";
6
+ import Tabs from "./Tabs/Tabs";
7
+ import TabPanel from "./Tabs/TabPanel";
5
8
  import Infotip from "./Infotip";
6
9
  import {
7
10
  MyApplicationsIcon,
@@ -87,4 +90,15 @@ const Icons = {
87
90
  WiManageGroupIcon,
88
91
  };
89
92
 
90
- export { Button, Footer, Header, Icons, Infotip, SideNav, TextButton };
93
+ export {
94
+ Button,
95
+ Dropdown,
96
+ Footer,
97
+ Header,
98
+ Icons,
99
+ Infotip,
100
+ SideNav,
101
+ TextButton,
102
+ Tabs,
103
+ TabPanel,
104
+ };