@jobber/components 4.51.0 → 4.52.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/Tabs/Tabs.d.ts +12 -1
- package/dist/Tabs/index.js +6 -2
- package/package.json +4 -4
package/dist/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from "react";
|
|
2
2
|
interface TabsProps {
|
|
3
3
|
readonly children: ReactElement | ReactElement[];
|
|
4
|
+
/**
|
|
5
|
+
* Specifies the index of the tab that should be active on mount
|
|
6
|
+
*
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
readonly defaultTab?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Callback that fires when the active tab changes
|
|
12
|
+
* @param newTabIndex
|
|
13
|
+
*/
|
|
14
|
+
onTabChange?(newTabIndex: number): void;
|
|
4
15
|
}
|
|
5
|
-
export declare function Tabs({ children }: TabsProps): JSX.Element;
|
|
16
|
+
export declare function Tabs({ children, defaultTab, onTabChange }: TabsProps): JSX.Element;
|
|
6
17
|
interface TabProps {
|
|
7
18
|
readonly label: string;
|
|
8
19
|
readonly children: ReactNode | ReactNode[];
|
package/dist/Tabs/index.js
CHANGED
|
@@ -16,8 +16,9 @@ var css_248z = ":root {\n --tab--height: calc(var(--space-larger) + var(--space
|
|
|
16
16
|
var styles = {"tabs":"-kxlqXO5UN0-","overflow":"qI4lWMSNH40-","overflowRight":"xohIah5wcoE-","overflowLeft":"qnY4S9sz-8g-","tabRow":"wdW31G8Trag-","tab":"MO7CXQ8xJXo-","selected":"kqof65gyv7g-","tabContent":"AimQioztR1U-"};
|
|
17
17
|
styleInject_es.styleInject(css_248z);
|
|
18
18
|
|
|
19
|
-
function Tabs({ children }) {
|
|
20
|
-
const
|
|
19
|
+
function Tabs({ children, defaultTab = 0, onTabChange }) {
|
|
20
|
+
const activeTabInitialValue = defaultTab < React__default["default"].Children.count(children) ? defaultTab : 0;
|
|
21
|
+
const [activeTab, setActiveTab] = React.useState(activeTabInitialValue);
|
|
21
22
|
const [overflowRight, setOverflowRight] = React.useState(false);
|
|
22
23
|
const [overflowLeft, setOverflowLeft] = React.useState(false);
|
|
23
24
|
const tabRow = React.useRef();
|
|
@@ -28,6 +29,9 @@ function Tabs({ children }) {
|
|
|
28
29
|
const activateTab = (index) => {
|
|
29
30
|
return () => {
|
|
30
31
|
setActiveTab(index);
|
|
32
|
+
if (onTabChange) {
|
|
33
|
+
onTabChange(index);
|
|
34
|
+
}
|
|
31
35
|
};
|
|
32
36
|
};
|
|
33
37
|
const activeTabProps = React__default["default"].Children.toArray(children)[activeTab].props;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.52.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.46.0",
|
|
23
23
|
"@jobber/formatters": "*",
|
|
24
|
-
"@jobber/hooks": "^2.6.
|
|
24
|
+
"@jobber/hooks": "^2.6.2",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
27
27
|
"@tanstack/react-table": "8.5.13",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@testing-library/jest-dom": "^5.16.5",
|
|
57
57
|
"@testing-library/react": "^14.0.0",
|
|
58
58
|
"@testing-library/react-hooks": "^7.0.2",
|
|
59
|
-
"@testing-library/user-event": "^
|
|
59
|
+
"@testing-library/user-event": "^14.5.1",
|
|
60
60
|
"@types/glob": "^7.1.1",
|
|
61
61
|
"@types/react": "^18.0.28",
|
|
62
62
|
"@types/react-dom": "^18.0.11",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"> 1%",
|
|
85
85
|
"IE 10"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "1194eb4d0f37470aa801a35ee5b9f0b8f62604c3"
|
|
88
88
|
}
|