@axa-fr/canopee-react 1.5.0 → 1.5.1-alpha.10
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.
|
@@ -8,6 +8,7 @@ export type TabBarDirection = keyof typeof tabBarDirection;
|
|
|
8
8
|
export type TabBarProps = {
|
|
9
9
|
items: ({
|
|
10
10
|
content: ReactNode;
|
|
11
|
+
handleSelectTab?: () => void;
|
|
11
12
|
} & Omit<ItemTabBarProps, "content">)[];
|
|
12
13
|
preSelectedTabIndex?: number;
|
|
13
14
|
direction?: TabBarDirection;
|
|
@@ -13,11 +13,16 @@ export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", I
|
|
|
13
13
|
const tablistRef = useRef(null);
|
|
14
14
|
const totalTabs = items.length;
|
|
15
15
|
const isActive = (index) => index === selectedTabIndex;
|
|
16
|
+
const handleClickFn = (index) => {
|
|
17
|
+
setSelectedTabIndex(index);
|
|
18
|
+
items[index]?.handleSelectTab?.();
|
|
19
|
+
};
|
|
16
20
|
const onChangeTab = useCallback((e) => {
|
|
17
21
|
const firstTabIndex = 0;
|
|
18
22
|
const lastTabIndex = totalTabs - 1;
|
|
19
23
|
const goToNextTab = (nextTabIndex) => {
|
|
20
24
|
setSelectedTabIndex(nextTabIndex);
|
|
25
|
+
items[nextTabIndex]?.handleSelectTab?.();
|
|
21
26
|
buttonRefs.current[nextTabIndex].focus();
|
|
22
27
|
e.stopPropagation();
|
|
23
28
|
e.preventDefault();
|
|
@@ -43,7 +48,7 @@ export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", I
|
|
|
43
48
|
break;
|
|
44
49
|
}
|
|
45
50
|
}, [selectedTabIndex, totalTabs]);
|
|
46
|
-
return (_jsxs("div", { className: classNames(CLASS_NAME, direction === tabBarDirection.center ? `${CLASS_NAME}--center` : ""), children: [_jsx("div", { role: "tablist", ref: tablistRef, children: items.map(({ title }, index) => (_jsx(ItemTabBarComponent, { id: `tab-${index}`, "aria-selected": isActive(index), "aria-controls": `tabpanel-${index}`, onKeyDown: onChangeTab, onClick: () =>
|
|
51
|
+
return (_jsxs("div", { className: classNames(CLASS_NAME, direction === tabBarDirection.center ? `${CLASS_NAME}--center` : ""), children: [_jsx("div", { role: "tablist", ref: tablistRef, children: items.map(({ title }, index) => (_jsx(ItemTabBarComponent, { id: `tab-${index}`, "aria-selected": isActive(index), "aria-controls": `tabpanel-${index}`, onKeyDown: onChangeTab, onClick: () => handleClickFn(index), ref: (element) => {
|
|
47
52
|
buttonRefs.current[index] = element;
|
|
48
53
|
}, tabIndex: isActive(index) ? 0 : -1, title: title }, `tab-${title}`))) }), items.map((item, index) => (_jsx("div", { role: "tabpanel", "aria-hidden": !isActive(index), id: `tabpanel-${index}`, "aria-labelledby": `tab-${index}`, children: item.content }, `tabpanel-${item.title}`)))] }));
|
|
49
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/canopee-react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1-alpha.10",
|
|
4
4
|
"description": "Package React - Design System Canopée",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./distributeur": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@axa-fr/canopee-css": "1.5.
|
|
52
|
+
"@axa-fr/canopee-css": "1.5.1-alpha.10",
|
|
53
53
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
54
54
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
55
55
|
"react": ">= 18"
|