@axa-fr/design-system-apollo-react 2.0.4-alpha.83 → 2.0.4-alpha.87

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.
@@ -2,7 +2,7 @@ import { type ComponentType, type MouseEventHandler, type ReactNode } from "reac
2
2
  import type { ButtonProps } from "../../Button/ButtonCommon";
3
3
  export type ItemLabelProps = {
4
4
  label?: ReactNode;
5
- description?: string;
5
+ description?: ReactNode;
6
6
  required?: boolean;
7
7
  inputId: string;
8
8
  sideButtonLabel?: string;
@@ -1,2 +1,2 @@
1
1
  import "@axa-fr/design-system-apollo-css/dist/ItemTabBar/ItemTabBarApollo.css";
2
- export { ItemTabBar, itemTabBarVariants, type ItemTabBarVariants, } from "./ItemTabBarCommon";
2
+ export { ItemTabBar, type ItemTabBarProps } from "./ItemTabBarCommon";
@@ -1,2 +1,2 @@
1
1
  import "@axa-fr/design-system-apollo-css/dist/ItemTabBar/ItemTabBarApollo.css";
2
- export { ItemTabBar, itemTabBarVariants, } from "./ItemTabBarCommon";
2
+ export { ItemTabBar } from "./ItemTabBarCommon";
@@ -1,14 +1,6 @@
1
- import { ComponentPropsWithRef, ReactNode } from "react";
2
- export declare const itemTabBarVariants: {
3
- readonly tabBar: "tabBar";
4
- readonly header: "header";
5
- };
6
- export type ItemTabBarVariants = keyof typeof itemTabBarVariants;
7
- type ItemTabBarProps = ComponentPropsWithRef<"button"> & {
8
- variant?: ItemTabBarVariants;
1
+ import { ComponentPropsWithRef } from "react";
2
+ export type ItemTabBarProps = ComponentPropsWithRef<"button"> & {
9
3
  isActive?: boolean;
10
- icon?: ReactNode;
11
4
  title: string;
12
5
  };
13
6
  export declare const ItemTabBar: import("react").ForwardRefExoticComponent<Omit<ItemTabBarProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
14
- export {};
@@ -1,12 +1,8 @@
1
- import { jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { getComponentClassName } from "../utilities/getComponentClassName";
4
- export const itemTabBarVariants = {
5
- tabBar: "tabBar",
6
- header: "header",
7
- };
8
- export const ItemTabBar = forwardRef(({ variant = "tabBar", isActive = false, icon, title, className, ...props }, ref) => {
9
- const classNames = getComponentClassName("af-item-tab-bar", className, variant);
10
- return (_jsxs("button", { ref: ref, type: "button", role: "tab", "aria-selected": isActive, className: classNames, ...props, children: [icon, title] }));
4
+ export const ItemTabBar = forwardRef(({ isActive = false, title, className, ...props }, ref) => {
5
+ const classNames = getComponentClassName("af-item-tab-bar", className);
6
+ return (_jsx("button", { ref: ref, type: "button", role: "tab", "aria-selected": isActive, className: classNames, ...props, children: title }));
11
7
  });
12
8
  ItemTabBar.displayName = "ItemTabBar";
@@ -1,2 +1,2 @@
1
1
  import "@axa-fr/design-system-apollo-css/dist/ItemTabBar/ItemTabBarLF.css";
2
- export { ItemTabBar, itemTabBarVariants, type ItemTabBarVariants, } from "./ItemTabBarCommon";
2
+ export { ItemTabBar, type ItemTabBarProps } from "./ItemTabBarCommon";
@@ -1,2 +1,2 @@
1
1
  import "@axa-fr/design-system-apollo-css/dist/ItemTabBar/ItemTabBarLF.css";
2
- export { ItemTabBar, itemTabBarVariants, } from "./ItemTabBarCommon";
2
+ export { ItemTabBar } from "./ItemTabBarCommon";
@@ -1,4 +1,4 @@
1
- import { type ComponentType, type ReactNode } from "react";
1
+ import { type ComponentProps, type ComponentType, type ReactNode } from "react";
2
2
  import type { ButtonProps } from "../../Button/ButtonCommon";
3
3
  export type ContentItemDuoProps = {
4
4
  label: string;
@@ -8,9 +8,9 @@ export type ContentItemDuoProps = {
8
8
  classModifier?: string;
9
9
  buttonText?: string;
10
10
  onButtonClick?: () => void;
11
- };
11
+ } & ComponentProps<"div">;
12
12
  type ContentItemDuoCommonProps = ContentItemDuoProps & {
13
13
  ButtonComponent: ComponentType<ButtonProps>;
14
14
  };
15
- export declare const ContentItemDuoCommon: ({ label, value, isVertical, className, classModifier, buttonText, onButtonClick, ButtonComponent, }: ContentItemDuoCommonProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const ContentItemDuoCommon: ({ label, value, isVertical, className, classModifier, buttonText, onButtonClick, ButtonComponent, ...containerProps }: ContentItemDuoCommonProps) => import("react/jsx-runtime").JSX.Element;
16
16
  export {};
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from "react";
2
+ import { useMemo, } from "react";
3
3
  import { getComponentClassName } from "../../utilities/getComponentClassName";
4
- export const ContentItemDuoCommon = ({ label, value, isVertical = false, className, classModifier, buttonText, onButtonClick, ButtonComponent, }) => {
4
+ export const ContentItemDuoCommon = ({ label, value, isVertical = false, className, classModifier, buttonText, onButtonClick, ButtonComponent, ...containerProps }) => {
5
5
  const componentClassName = useMemo(() => {
6
6
  const classModifiers = [classModifier];
7
7
  if (isVertical) {
@@ -9,5 +9,5 @@ export const ContentItemDuoCommon = ({ label, value, isVertical = false, classNa
9
9
  }
10
10
  return getComponentClassName("af-content-item-duo", className, classModifiers.filter(Boolean).join(" "));
11
11
  }, [classModifier, className, isVertical]);
12
- return (_jsxs("div", { className: componentClassName, children: [_jsx("p", { className: "af-content-item-duo__label", children: label }), typeof value === "string" ? (_jsx("p", { className: "af-content-item-duo__value", children: value })) : (_jsx("div", { className: "af-content-item-duo__value", children: value })), buttonText ? (_jsx("div", { className: "af-content-item-duo__button", children: _jsx(ButtonComponent, { variant: "ghost", onClick: onButtonClick, children: buttonText }) })) : null] }));
12
+ return (_jsxs("div", { className: componentClassName, ...containerProps, children: [_jsx("p", { className: "af-content-item-duo__label", children: label }), typeof value === "string" ? (_jsx("p", { className: "af-content-item-duo__value", children: value })) : (_jsx("div", { className: "af-content-item-duo__value", children: value })), buttonText ? (_jsx("div", { className: "af-content-item-duo__button", children: _jsx(ButtonComponent, { variant: "ghost", onClick: onButtonClick, children: buttonText }) })) : null] }));
13
13
  };
@@ -0,0 +1,4 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/TabBar/TabBarApollo.css";
2
+ import { type TabBarProps } from "./TabBarCommon";
3
+ export { tabBarDirection, type TabBarProps, type TabBarDirection, } from "./TabBarCommon";
4
+ export declare const TabBar: (props: TabBarProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "@axa-fr/design-system-apollo-css/dist/TabBar/TabBarApollo.css";
3
+ import { ItemTabBar } from "../ItemTabBar/ItemTabBarApollo";
4
+ import { TabBarCommon } from "./TabBarCommon";
5
+ export { tabBarDirection, } from "./TabBarCommon";
6
+ export const TabBar = (props) => (_jsx(TabBarCommon, { ...props, ItemTabBarComponent: ItemTabBar }));
@@ -0,0 +1,19 @@
1
+ import { ComponentProps, ComponentType, ReactNode } from "react";
2
+ import { ItemTabBar, type ItemTabBarProps } from "../ItemTabBar/ItemTabBarCommon";
3
+ export declare const tabBarDirection: {
4
+ readonly center: "center";
5
+ readonly left: "left";
6
+ };
7
+ export type TabBarDirection = keyof typeof tabBarDirection;
8
+ export type TabBarProps = {
9
+ items: ({
10
+ content: ReactNode;
11
+ } & Omit<ItemTabBarProps, "content">)[];
12
+ preSelectedTabIndex?: number;
13
+ direction?: TabBarDirection;
14
+ };
15
+ type TabBarPropsCommon = TabBarProps & {
16
+ ItemTabBarComponent: ComponentType<ComponentProps<typeof ItemTabBar>>;
17
+ };
18
+ export declare const TabBarCommon: ({ items, preSelectedTabIndex, direction, ItemTabBarComponent, }: TabBarPropsCommon) => import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useRef, useState, } from "react";
3
+ import classNames from "classnames";
4
+ export const tabBarDirection = {
5
+ center: "center",
6
+ left: "left",
7
+ };
8
+ const CLASS_NAME = "af-tabbar";
9
+ export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", ItemTabBarComponent, }) => {
10
+ const [selectedTabIndex, setSelectedTabIndex] = useState(preSelectedTabIndex || 0);
11
+ const buttonRefs = useRef([]);
12
+ const tablistRef = useRef(null);
13
+ const totalTabs = items.length;
14
+ const isActive = (index) => index === selectedTabIndex;
15
+ const onChangeTab = useCallback((e) => {
16
+ const firstTabIndex = 0;
17
+ const lastTabIndex = totalTabs - 1;
18
+ const goToNextTab = (nextTabIndex) => {
19
+ setSelectedTabIndex(nextTabIndex);
20
+ buttonRefs.current[nextTabIndex].focus();
21
+ e.stopPropagation();
22
+ e.preventDefault();
23
+ };
24
+ switch (e.key) {
25
+ case "ArrowRight":
26
+ goToNextTab(selectedTabIndex < lastTabIndex
27
+ ? selectedTabIndex + 1
28
+ : firstTabIndex);
29
+ break;
30
+ case "ArrowLeft":
31
+ goToNextTab(selectedTabIndex > firstTabIndex
32
+ ? selectedTabIndex - 1
33
+ : lastTabIndex);
34
+ break;
35
+ case "Home":
36
+ goToNextTab(firstTabIndex);
37
+ break;
38
+ case "End":
39
+ goToNextTab(lastTabIndex);
40
+ break;
41
+ default:
42
+ break;
43
+ }
44
+ }, [selectedTabIndex, totalTabs]);
45
+ 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: () => setSelectedTabIndex(index), ref: (element) => {
46
+ buttonRefs.current[index] = element;
47
+ }, 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}`)))] }));
48
+ };
@@ -0,0 +1,4 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/TabBar/TabBarLF.css";
2
+ import { type TabBarProps } from "./TabBarCommon";
3
+ export { tabBarDirection, type TabBarProps, type TabBarDirection, } from "./TabBarCommon";
4
+ export declare const TabBar: (props: TabBarProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "@axa-fr/design-system-apollo-css/dist/TabBar/TabBarLF.css";
3
+ import { ItemTabBar } from "../ItemTabBar/ItemTabBarLF";
4
+ import { TabBarCommon } from "./TabBarCommon";
5
+ export { tabBarDirection, } from "./TabBarCommon";
6
+ export const TabBar = (props) => (_jsx(TabBarCommon, { ...props, ItemTabBarComponent: ItemTabBar }));
package/dist/index.d.ts CHANGED
@@ -33,7 +33,8 @@ export { TextArea } from "./Form/TextArea/TextAreaApollo";
33
33
  export { DebugGrid } from "./Grid/DebugGridApollo";
34
34
  export { Heading, type HeadingLevel } from "./Heading/HeadingApollo";
35
35
  export { Icon, iconSizeVariants, iconVariants, type IconSizeVariants, type IconVariants, } from "./Icon/IconApollo";
36
- export { ItemTabBar, itemTabBarVariants, type ItemTabBarVariants, } from "./ItemTabBar/ItemTabBarApollo";
36
+ export { ItemTabBar, type ItemTabBarProps, } from "./ItemTabBar/ItemTabBarApollo";
37
+ export { TabBar, type TabBarProps, tabBarDirection, type TabBarDirection, } from "./TabBar/TabBarApollo";
37
38
  export { Footer, type FooterProps } from "./Layout/Footer/FooterApollo";
38
39
  export { Link, linkVariants, type LinkVariants } from "./Link/LinkApollo";
39
40
  export { ClickItem, clickItemStates, clickItemVariants, type ClickItemStates, type ClickItemVariants, } from "./List/ClickItem/ClickItemApollo";
package/dist/index.js CHANGED
@@ -32,7 +32,8 @@ export { TextArea } from "./Form/TextArea/TextAreaApollo";
32
32
  export { DebugGrid } from "./Grid/DebugGridApollo";
33
33
  export { Heading } from "./Heading/HeadingApollo";
34
34
  export { Icon, iconSizeVariants, iconVariants, } from "./Icon/IconApollo";
35
- export { ItemTabBar, itemTabBarVariants, } from "./ItemTabBar/ItemTabBarApollo";
35
+ export { ItemTabBar, } from "./ItemTabBar/ItemTabBarApollo";
36
+ export { TabBar, tabBarDirection, } from "./TabBar/TabBarApollo";
36
37
  export { Footer } from "./Layout/Footer/FooterApollo";
37
38
  export { Link, linkVariants } from "./Link/LinkApollo";
38
39
  export { ClickItem, clickItemStates, clickItemVariants, } from "./List/ClickItem/ClickItemApollo";
package/dist/indexLF.d.ts CHANGED
@@ -37,7 +37,8 @@ export { TextArea } from "./Form/TextArea/TextAreaLF";
37
37
  export { DebugGrid } from "./Grid/DebugGridLF";
38
38
  export { Heading, type HeadingLevel } from "./Heading/HeadingLF";
39
39
  export { Icon, iconSizeVariants, iconVariants, type IconSizeVariants, type IconVariants, } from "./Icon/IconLF";
40
- export { ItemTabBar, itemTabBarVariants, type ItemTabBarVariants, } from "./ItemTabBar/ItemTabBarLF";
40
+ export { ItemTabBar, type ItemTabBarProps } from "./ItemTabBar/ItemTabBarLF";
41
+ export { TabBar, type TabBarProps, tabBarDirection, type TabBarDirection, } from "./TabBar/TabBarLF";
41
42
  export { Footer, type FooterProps } from "./Layout/Footer/FooterLF";
42
43
  export { Link, linkVariants, type LinkVariants } from "./Link/LinkLF";
43
44
  export { ClickItem, clickItemStates, clickItemVariants, type ClickItemStates, type ClickItemVariants, } from "./List/ClickItem/ClickItemLF";
package/dist/indexLF.js CHANGED
@@ -36,7 +36,8 @@ export { TextArea } from "./Form/TextArea/TextAreaLF";
36
36
  export { DebugGrid } from "./Grid/DebugGridLF";
37
37
  export { Heading } from "./Heading/HeadingLF";
38
38
  export { Icon, iconSizeVariants, iconVariants, } from "./Icon/IconLF";
39
- export { ItemTabBar, itemTabBarVariants, } from "./ItemTabBar/ItemTabBarLF";
39
+ export { ItemTabBar } from "./ItemTabBar/ItemTabBarLF";
40
+ export { TabBar, tabBarDirection, } from "./TabBar/TabBarLF";
40
41
  export { Footer } from "./Layout/Footer/FooterLF";
41
42
  export { Link, linkVariants } from "./Link/LinkLF";
42
43
  export { ClickItem, clickItemStates, clickItemVariants, } from "./List/ClickItem/ClickItemLF";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-apollo-react",
3
- "version": "2.0.4-alpha.83",
3
+ "version": "2.0.4-alpha.87",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "homepage": "https://github.com/AxaFrance/design-system#readme",
48
48
  "peerDependencies": {
49
- "@axa-fr/design-system-apollo-css": "2.0.4-alpha.83",
50
- "@axa-fr/design-system-look-and-feel-css": "2.0.4-alpha.83",
49
+ "@axa-fr/design-system-apollo-css": "2.0.4-alpha.87",
50
+ "@axa-fr/design-system-look-and-feel-css": "2.0.4-alpha.87",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },