@axa-fr/canopee-react 1.5.1-alpha.3 → 1.5.1-alpha.30

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.
@@ -11,11 +11,13 @@ export type DataAgentProps = {
11
11
  clickContents?: TupleMax3<ClickItemProps>;
12
12
  texteOrias?: string;
13
13
  isCompact?: boolean;
14
+ /** Display the compact layout (header only) regardless of screen size */
15
+ variant?: "default" | "compact";
14
16
  };
15
17
  type DataAgentCommonProps = DataAgentProps & {
16
18
  DividerComponent: ComponentType<ComponentProps<typeof Divider>>;
17
19
  ContentItemMonoComponent: ComponentType<ContentItemProps>;
18
20
  ClickItemComponent: ComponentType<ClickItemProps>;
19
21
  };
20
- export declare const DataAgentCommon: ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact, }: DataAgentCommonProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const DataAgentCommon: ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact, variant, }: DataAgentCommonProps) => import("react/jsx-runtime").JSX.Element;
21
23
  export {};
@@ -4,7 +4,7 @@ import { Divider } from "../Divider/DividerCommon";
4
4
  import { BREAKPOINT } from "../utilities/constants";
5
5
  import { getComponentClassName } from "../utilities/getComponentClassName";
6
6
  import { useIsSmallScreen } from "../utilities/hook/useIsSmallScreen";
7
- export const DataAgentCommon = ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact = true, }) => {
7
+ export const DataAgentCommon = ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact = true, variant = "default", }) => {
8
8
  const componentClassName = useMemo(() => getComponentClassName("af-data-agent", className), [className]);
9
9
  const isMobile = useIsSmallScreen(BREAKPOINT.SM);
10
10
  const renderForDefaultLayout = () => (_jsxs(_Fragment, { children: [_jsxs("section", { className: "af-data-agent__intro", children: [_jsx(ContentItemMonoComponent, { ...agentProps, type: "picture" }), agentContractProps ? (_jsx(ContentItemMonoComponent, { ...agentContractProps, type: "stick" })) : null] }), _jsx(DividerComponent, {}), contents && contents?.length > 0 ? (_jsx("section", { className: "af-data-agent__info-content", children: contents.map((content) => (_jsxs(Fragment, { children: [_jsx(ContentItemMonoComponent, { ...content, type: "icon" }), _jsx(DividerComponent, { className: "af-data-agent__line" })] }, `content--${crypto.randomUUID()}`))) })) : null, clickContents && clickContents?.length > 0 ? (_jsx("section", { className: "af-data-agent__info-click-content", children: clickContents.map((clickContent) => (_jsxs(Fragment, { children: [_jsx(ClickItemComponent, { ...clickContent, variant: "small" }), _jsx(DividerComponent, { className: "af-data-agent__line" })] }, `clickContent--${crypto.randomUUID()}`))) })) : null, Boolean(texteOrias) && (_jsx("p", { className: "af-data-agent__text-orias", children: texteOrias }))] }));
@@ -12,7 +12,7 @@ export const DataAgentCommon = ({ className, agentProps, agentContractProps, con
12
12
  src: agentProps.picture,
13
13
  alt: agentProps.title,
14
14
  }, variant: "agent" }) }));
15
- return (_jsx("section", { className: componentClassName, children: isMobile && isCompact
15
+ return (_jsx("section", { className: componentClassName, children: (isMobile && isCompact) || variant === "compact"
16
16
  ? renderForMobileLayout()
17
17
  : renderForDefaultLayout() }));
18
18
  };
@@ -6,11 +6,6 @@ import { ItemMessage, } from "../ItemMessage/ItemMessageCommon";
6
6
  import { InputDateAtom } from "./InputDateAtom";
7
7
  import { InputDateTextAtom } from "./InputDateTextAtom";
8
8
  const InputDateCommon = forwardRef(({ className, classModifier = "", helper, error, success, message, messageType, label, description, buttonLabel, moreButtonLabel, onButtonClick, onMoreButtonClick, ItemLabelComponent, ItemMessageComponent, required, hidePicker, max, min, containerProps, ...otherProps }, inputRef) => {
9
- const componentClassName = getClassName({
10
- baseClassName: "af-form__input-date",
11
- modifiers: classModifier.split(" "),
12
- className,
13
- });
14
9
  let inputId = useId();
15
10
  inputId = otherProps.id ?? inputId;
16
11
  const idMessage = useId();
@@ -26,6 +21,12 @@ const InputDateCommon = forwardRef(({ className, classModifier = "", helper, err
26
21
  const hasError = (Boolean(message) && messageType === "error") || Boolean(error);
27
22
  const ariaErrormessage = hasError ? idMessage : undefined;
28
23
  const ariaInvalid = hasError || undefined;
24
+ const hasWarning = Boolean(message) && messageType === "warning" && !hasError;
25
+ const componentClassName = getClassName({
26
+ baseClassName: "af-form__input-date",
27
+ modifiers: [...classModifier.split(" "), hasWarning && "warning"],
28
+ className,
29
+ });
29
30
  return (_jsxs("div", { className: "af-form__input-container", ...containerProps, children: [_jsx(ItemLabelComponent, { description: description, moreButtonLabel: moreButtonLabel ?? buttonLabel, onMoreButtonClick: onMoreButtonClick ?? onButtonClick, required: required, htmlFor: inputId, children: label }), hidePicker ? (_jsx(InputDateTextAtom, { ...otherProps, id: inputId, className: componentClassName, ref: inputRef, "aria-errormessage": ariaErrormessage, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedby, required: required })) : (_jsx(InputDateAtom, { ...otherProps, id: inputId, className: componentClassName, ref: inputRef, "aria-errormessage": ariaErrormessage, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedby, required: required, max: max, min: min })), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: message || error || success, messageType: messageType || (error ? "error" : "success") })] }));
30
31
  });
31
32
  InputDateCommon.displayName = "InputDate";
@@ -11,7 +11,7 @@ const InputTextCommon = forwardRef(({ unit, className, classModifier = "", helpe
11
11
  const ariaDescribedby = [helper && idHelp, success && idMessage].filter(Boolean);
12
12
  return (_jsxs("div", { className: "af-form__input-container", ...containerProps, children: [_jsx(ItemLabelComponent, { description: description, moreButtonLabel: moreButtonLabel ?? buttonLabel, onMoreButtonClick: onMoreButtonClick ?? onButtonClick, sideButtonLabel: sideButtonLabel, onSideButtonClick: onSideButtonClick, required: required, htmlFor: inputId, children: label }), _jsx(InputTextAtomComponent, { id: inputId, ref: inputRef, unit: unit, className: className, classModifier: classModifier, error: (message && messageType === "error") || Boolean(error)
13
13
  ? messageType || error
14
- : undefined, required: required, idMessage: message || error ? idMessage : undefined, idHelp: ariaDescribedby.length > 0 ? ariaDescribedby.join(" ") : undefined, ...otherProps }), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: message || error || success, messageType: messageType || (error ? "error" : "success") })] }));
14
+ : undefined, warning: message && messageType === "warning" ? messageType : undefined, required: required, idMessage: message || error ? idMessage : undefined, idHelp: ariaDescribedby.length > 0 ? ariaDescribedby.join(" ") : undefined, ...otherProps }), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: message || error || success, messageType: messageType || (error ? "error" : "success") })] }));
15
15
  });
16
16
  InputTextCommon.displayName = "InputText";
17
17
  export { InputTextCommon };
@@ -3,6 +3,7 @@ type InputTextAtomProps = ComponentPropsWithRef<"input"> & {
3
3
  unit?: ReactNode;
4
4
  classModifier?: string;
5
5
  error?: string;
6
+ warning?: string;
6
7
  idMessage?: string;
7
8
  idHelp?: string;
8
9
  };
@@ -1,10 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useId, } from "react";
3
3
  import { getClassName } from "../../utilities/getClassName";
4
- const InputTextAtom = forwardRef(({ unit, className, classModifier = "", error, required, idMessage, idHelp, "aria-errormessage": ariaErrormessage, "aria-describedby": ariaDescribedby, type = "text", ...otherProps }, inputRef) => {
4
+ const InputTextAtom = forwardRef(({ unit, className, classModifier = "", error, warning, required, idMessage, idHelp, "aria-errormessage": ariaErrormessage, "aria-describedby": ariaDescribedby, type = "text", ...otherProps }, inputRef) => {
5
5
  const componentClassName = getClassName({
6
6
  baseClassName: "af-form__input-text",
7
- modifiers: [classModifier, error || ariaErrormessage ? "error" : ""],
7
+ modifiers: [
8
+ classModifier,
9
+ error || ariaErrormessage ? "error" : "",
10
+ !error && !ariaErrormessage && warning ? "warning" : "",
11
+ ],
8
12
  className,
9
13
  });
10
14
  let inputId = useId();
@@ -6,10 +6,11 @@ export type HeadingCommonProps = PropsWithChildren<{
6
6
  level?: HeadingLevel;
7
7
  icon?: string;
8
8
  iconProps?: Omit<IconProps, "src">;
9
+ iconPosition?: "start" | "top";
9
10
  tag?: ReactNode;
10
11
  firstSubtitle?: ReactNode;
11
12
  secondSubtitle?: ReactNode;
12
13
  className?: string;
13
14
  }> & JSX.IntrinsicElements["div"];
14
15
  export declare const DEFAULT_TAG_PROPS: TagProps;
15
- export declare const HeadingCommon: ({ children: title, className, firstSubtitle, secondSubtitle, level, icon, iconProps, tag, ...props }: HeadingCommonProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const HeadingCommon: ({ children: title, className, firstSubtitle, secondSubtitle, level, icon, iconProps, iconPosition, tag, ...props }: HeadingCommonProps) => import("react/jsx-runtime").JSX.Element;
@@ -9,10 +9,11 @@ import { getClassName } from "../utilities/getClassName";
9
9
  export const DEFAULT_TAG_PROPS = {
10
10
  variant: "neutral",
11
11
  };
12
- export const HeadingCommon = ({ children: title, className, firstSubtitle, secondSubtitle, level = 1, icon, iconProps = {}, tag, ...props }) => {
12
+ export const HeadingCommon = ({ children: title, className, firstSubtitle, secondSubtitle, level = 1, icon, iconProps = {}, iconPosition = "start", tag, ...props }) => {
13
13
  const isMobile = useIsSmallScreen(BREAKPOINT.SM);
14
14
  return (_jsxs("div", { className: getClassName({
15
15
  baseClassName: "af-heading",
16
+ modifiers: [iconPosition === "top" && "icon-top"],
16
17
  className,
17
18
  }), ...props, children: [tag && level < 3 ? _jsx("div", { className: "af-heading__label", children: tag }) : null, icon ? (_jsx(Icon, { src: icon, size: isMobile
18
19
  ? headingLevelToIconSizeMobile[level]
@@ -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: () => setSelectedTabIndex(index), ref: (element) => {
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.1-alpha.3",
3
+ "version": "1.5.1-alpha.30",
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.1-alpha.3",
52
+ "@axa-fr/canopee-css": "1.5.1-alpha.30",
53
53
  "@material-symbols/svg-400": ">= 0.19.0",
54
54
  "@material-symbols/svg-700": ">= 0.19.0",
55
55
  "react": ">= 18"