@axa-fr/canopee-react 2.0.0-alpha.80 → 2.0.0-alpha.81

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import classNames from "classnames";
3
- import { useCallback, useRef, useState, } from "react";
3
+ import { useCallback, useId, useRef, useState, } from "react";
4
4
  import { ItemTabBar, } from "../ItemTabBar/ItemTabBarCommon";
5
5
  export const tabBarDirection = {
6
6
  center: "center",
@@ -10,6 +10,9 @@ const CLASS_NAME = "af-tabbar";
10
10
  export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", ItemTabBarComponent, }) => {
11
11
  const [selectedTabIndex, setSelectedTabIndex] = useState(preSelectedTabIndex || 0);
12
12
  const buttonRefs = useRef([]);
13
+ const baseId = useId();
14
+ const getTabId = (index) => `${baseId}-tab-${index}`;
15
+ const getTabPanelId = (index) => `${baseId}-tabpanel-${index}`;
13
16
  const tablistRef = useRef(null);
14
17
  const totalTabs = items.length;
15
18
  const isActive = (index) => index === selectedTabIndex;
@@ -48,7 +51,7 @@ export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", I
48
51
  break;
49
52
  }
50
53
  }, [selectedTabIndex, totalTabs]);
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) => {
54
+ 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: getTabId(index), "aria-selected": isActive(index), "aria-controls": getTabPanelId(index), onKeyDown: onChangeTab, onClick: () => handleClickFn(index), ref: (element) => {
52
55
  buttonRefs.current[index] = element;
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}`)))] }));
56
+ }, tabIndex: isActive(index) ? 0 : -1, title: title }, `tab-${title}`))) }), items.map((item, index) => (_jsx("div", { role: "tabpanel", "aria-hidden": !isActive(index), id: getTabPanelId(index), "aria-labelledby": getTabId(index), children: item.content }, `tabpanel-${item.title}`)))] }));
54
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/canopee-react",
3
- "version": "2.0.0-alpha.80",
3
+ "version": "2.0.0-alpha.81",
4
4
  "description": "Package React - Design System Canopée",
5
5
  "exports": {
6
6
  "./distributeur": {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "homepage": "https://github.com/AxaFrance/design-system#readme",
55
55
  "peerDependencies": {
56
- "@axa-fr/canopee-css": "2.0.0-alpha.80",
56
+ "@axa-fr/canopee-css": "2.0.0-alpha.81",
57
57
  "@material-symbols/svg-400": ">= 0.19.0",
58
58
  "@material-symbols/svg-700": ">= 0.19.0",
59
59
  "react": ">= 19"