@axa-fr/canopee-react 1.7.1-alpha.18 → 1.7.1-alpha.20

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/client.d.ts CHANGED
@@ -53,6 +53,7 @@ export { ClickItem, clickItemStates, clickItemVariants, type ClickItemStates, ty
53
53
  export { ContentItemDuo } from "./prospect-client/List/ContentItemDuo/ContentItemDuoLF";
54
54
  export { List, type ListProps } from "./prospect-client/List/List/ListLF";
55
55
  export { Message, messageVariants, type MessageVariants, } from "./prospect-client/Message/MessageLF";
56
+ export { MultiMessage, type MultiMessageItem, type MultiMessageProps, } from "./prospect-client/MultiMessage/MultiMessageLF";
56
57
  export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./prospect-client/Modal/ModalLF";
57
58
  export { ItemPagination, type ItemPaginationProps, } from "./prospect-client/Pagination/ItemPagination/ItemPaginationLF";
58
59
  export { Pagination } from "./prospect-client/Pagination/PaginationLF";
package/dist/client.js CHANGED
@@ -53,6 +53,7 @@ export { ClickItem, clickItemStates, clickItemVariants, } from "./prospect-clien
53
53
  export { ContentItemDuo } from "./prospect-client/List/ContentItemDuo/ContentItemDuoLF";
54
54
  export { List } from "./prospect-client/List/List/ListLF";
55
55
  export { Message, messageVariants, } from "./prospect-client/Message/MessageLF";
56
+ export { MultiMessage, } from "./prospect-client/MultiMessage/MultiMessageLF";
56
57
  export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./prospect-client/Modal/ModalLF";
57
58
  export { ItemPagination, } from "./prospect-client/Pagination/ItemPagination/ItemPaginationLF";
58
59
  export { Pagination } from "./prospect-client/Pagination/PaginationLF";
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useId, } from "react";
3
+ import { getClassName } from "../../utilities/getClassName";
3
4
  import { ItemLabelCommon, } from "../ItemLabel/ItemLabelCommon";
4
5
  import { ItemMessage, } from "../ItemMessage/ItemMessageCommon";
5
6
  const TextAreaCommon = forwardRef(({ id, className, label, description, helper, error, message, messageType, buttonLabel, moreButtonLabel, onButtonClick, onMoreButtonClick, required, sideButtonLabel, ItemLabelComponent, ItemMessageComponent, onSideButtonClick, placeholder = " ", containerProps, ...inputProps }, inputRef) => {
@@ -8,9 +9,14 @@ const TextAreaCommon = forwardRef(({ id, className, label, description, helper,
8
9
  const helperId = `${inputId}-helper`;
9
10
  const messageId = `${inputId}-error`;
10
11
  const hasError = (Boolean(message) && messageType === "error") || Boolean(error);
12
+ const hasWarning = Boolean(message) && messageType === "warning" && !hasError;
13
+ const textareaClassName = getClassName({
14
+ baseClassName: "af-form__textarea",
15
+ modifiers: [hasWarning && "warning"],
16
+ });
11
17
  return (_jsxs("div", { className: ["af-form__input-container", className]
12
18
  .filter(Boolean)
13
- .join(" "), ...containerProps, children: [_jsx(ItemLabelComponent, { description: description, moreButtonLabel: moreButtonLabel ?? buttonLabel, onMoreButtonClick: onMoreButtonClick ?? onButtonClick, sideButtonLabel: sideButtonLabel, onSideButtonClick: onSideButtonClick, required: required, htmlFor: inputId, children: label }), _jsx("textarea", { id: inputId, className: "af-form__textarea", ref: inputRef, "aria-errormessage": hasError ? messageId : undefined, "aria-describedby": helper ? helperId : undefined, required: required, "aria-invalid": hasError || undefined, placeholder: placeholder, ...inputProps }), helper ? (_jsx("span", { id: helperId, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: messageId, message: message || error, messageType: messageType })] }));
19
+ .join(" "), ...containerProps, children: [_jsx(ItemLabelComponent, { description: description, moreButtonLabel: moreButtonLabel ?? buttonLabel, onMoreButtonClick: onMoreButtonClick ?? onButtonClick, sideButtonLabel: sideButtonLabel, onSideButtonClick: onSideButtonClick, required: required, htmlFor: inputId, children: label }), _jsx("textarea", { id: inputId, className: textareaClassName, ref: inputRef, "aria-errormessage": hasError ? messageId : undefined, "aria-describedby": helper ? helperId : undefined, required: required, "aria-invalid": hasError || undefined, placeholder: placeholder, ...inputProps }), helper ? (_jsx("span", { id: helperId, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: messageId, message: message || error, messageType: messageType })] }));
14
20
  });
15
21
  TextAreaCommon.displayName = "TextArea";
16
22
  export { TextAreaCommon };
@@ -0,0 +1 @@
1
+ export declare const clampIndex: (index: number, total: number) => number;
@@ -0,0 +1,7 @@
1
+ export const clampIndex = (index, total) => {
2
+ if (total <= 0 || index < 0)
3
+ return 0;
4
+ if (index >= total)
5
+ return total - 1;
6
+ return index;
7
+ };
@@ -0,0 +1,6 @@
1
+ import "@axa-fr/canopee-css/prospect/MultiMessage/MultiMessageApollo.css";
2
+ import { type MultiMessageProps } from "./MultiMessageCommon";
3
+ export { messageVariants, type MessageVariants, } from "../Message/MessageApollo";
4
+ export type { MultiMessageProps } from "./MultiMessageCommon";
5
+ export type { MultiMessageItem } from "./types";
6
+ export declare const MultiMessage: (props: MultiMessageProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "@axa-fr/canopee-css/prospect/MultiMessage/MultiMessageApollo.css";
3
+ import { Message } from "../Message/MessageApollo";
4
+ import { Pagination } from "../Pagination/PaginationApollo";
5
+ import { MultiMessageCommon, } from "./MultiMessageCommon";
6
+ export { messageVariants, } from "../Message/MessageApollo";
7
+ export const MultiMessage = (props) => (_jsx(MultiMessageCommon, { ...props, MessageComponent: Message, PaginationComponent: Pagination }));
@@ -0,0 +1,33 @@
1
+ import { type ComponentType } from "react";
2
+ import type { MessageProps } from "../Message/MessageCommon";
3
+ import type { PaginationProps } from "../Pagination/PaginationCommon";
4
+ import type { MultiMessageItem } from "./types";
5
+ type Headings = "h2" | "h3" | "h4" | "h5" | "h6";
6
+ export type MultiMessageProps = {
7
+ /** Messages displayed inside the carousel */
8
+ items: MultiMessageItem[];
9
+ /** Controlled active index (zero-based) */
10
+ activeIndex?: number;
11
+ /** Default active index (zero-based) when uncontrolled */
12
+ defaultActiveIndex?: number;
13
+ /** Called when the user navigates between messages */
14
+ onChangeActive?: (index: number) => void;
15
+ /** Icon size in pixels */
16
+ iconSize?: number;
17
+ /** HTML heading level used for each message title */
18
+ heading?: Headings;
19
+ /** ARIA label for the previous button */
20
+ prevLabel?: string;
21
+ /** ARIA label for the next button */
22
+ nextLabel?: string;
23
+ /** Optional override for the previous button props */
24
+ prevButtonProps?: PaginationProps["prevButtonProps"];
25
+ /** Optional override for the next button props */
26
+ nextButtonProps?: PaginationProps["nextButtonProps"];
27
+ } & Omit<MessageProps, "action" | "children" | "heading" | "iconSize" | "title" | "variant">;
28
+ type MultiMessageCommonProps = MultiMessageProps & {
29
+ MessageComponent: ComponentType<MessageProps>;
30
+ PaginationComponent: ComponentType<PaginationProps>;
31
+ };
32
+ export declare const MultiMessageCommon: ({ items, activeIndex, defaultActiveIndex, onChangeActive, iconSize, heading: Heading, prevLabel, nextLabel, prevButtonProps, nextButtonProps, className, MessageComponent, PaginationComponent, ...sectionProps }: MultiMessageCommonProps) => import("react/jsx-runtime").JSX.Element | null;
33
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { getClassName } from "../utilities/getClassName";
4
+ import { MultiMessageFooter } from "./MultiMessageFooter";
5
+ import { clampIndex } from "./MultiMessage.helpers";
6
+ const baseClassName = "af-multi-message";
7
+ export const MultiMessageCommon = ({ items, activeIndex, defaultActiveIndex = 0, onChangeActive, iconSize = 24, heading: Heading = "h4", prevLabel = "Message précédent", nextLabel = "Message suivant", prevButtonProps, nextButtonProps, className, MessageComponent, PaginationComponent, ...sectionProps }) => {
8
+ const total = items.length;
9
+ const isControlled = activeIndex !== undefined;
10
+ const [internalIndex, setInternalIndex] = useState(clampIndex(defaultActiveIndex, total));
11
+ const currentIndex = clampIndex(isControlled ? activeIndex : internalIndex, total);
12
+ if (total === 0)
13
+ return null;
14
+ const item = items[currentIndex];
15
+ const hasMultiple = total > 1;
16
+ const goTo = (next) => {
17
+ const clamped = clampIndex(next, total);
18
+ if (clamped === currentIndex)
19
+ return;
20
+ if (!isControlled)
21
+ setInternalIndex(clamped);
22
+ onChangeActive?.(clamped);
23
+ };
24
+ return (_jsxs(MessageComponent, { className: getClassName({
25
+ baseClassName,
26
+ className,
27
+ }), variant: item.variant, title: item.title, iconSize: iconSize, heading: Heading, ...sectionProps, children: [item.children, _jsx(MultiMessageFooter, { action: item.action, currentIndex: currentIndex, hasMultiple: hasMultiple, nextButtonProps: nextButtonProps, nextLabel: nextLabel, onChangePage: goTo, PaginationComponent: PaginationComponent, prevButtonProps: prevButtonProps, prevLabel: prevLabel, total: total })] }));
28
+ };
@@ -0,0 +1,17 @@
1
+ import type { ComponentType } from "react";
2
+ import type { PaginationProps } from "../Pagination/PaginationCommon";
3
+ import type { MultiMessageItem } from "./types";
4
+ type MultiMessageFooterProps = {
5
+ action: MultiMessageItem["action"];
6
+ currentIndex: number;
7
+ hasMultiple: boolean;
8
+ nextButtonProps: PaginationProps["nextButtonProps"];
9
+ nextLabel: string;
10
+ onChangePage: (page: number) => void;
11
+ PaginationComponent: ComponentType<PaginationProps>;
12
+ prevButtonProps: PaginationProps["prevButtonProps"];
13
+ prevLabel: string;
14
+ total: number;
15
+ };
16
+ export declare const MultiMessageFooter: ({ action, currentIndex, hasMultiple, nextButtonProps, nextLabel, onChangePage, PaginationComponent, prevButtonProps, prevLabel, total, }: MultiMessageFooterProps) => import("react/jsx-runtime").JSX.Element | null;
17
+ export {};
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const baseClassName = "af-multi-message";
3
+ export const MultiMessageFooter = ({ action, currentIndex, hasMultiple, nextButtonProps, nextLabel, onChangePage, PaginationComponent, prevButtonProps, prevLabel, total, }) => {
4
+ if (!hasMultiple && !action)
5
+ return null;
6
+ return (_jsxs("div", { className: `${baseClassName}__footer`, children: [hasMultiple ? (_jsx(PaginationComponent, { className: `${baseClassName}__pagination`, numberPages: total, currentPage: currentIndex + 1, onChangePage: (page) => onChangePage(page - 1), asItem: "button", "aria-label": "Pagination des messages", prevButtonProps: {
7
+ "aria-label": prevLabel,
8
+ ...prevButtonProps,
9
+ }, nextButtonProps: {
10
+ "aria-label": nextLabel,
11
+ ...nextButtonProps,
12
+ } })) : null, action ? (_jsx("div", { className: `${baseClassName}__action`, children: action })) : null] }));
13
+ };
@@ -0,0 +1,6 @@
1
+ import "@axa-fr/canopee-css/client/MultiMessage/MultiMessageLF.css";
2
+ import { type MultiMessageProps } from "./MultiMessageCommon";
3
+ export { messageVariants, type MessageVariants } from "../Message/MessageLF";
4
+ export type { MultiMessageProps } from "./MultiMessageCommon";
5
+ export type { MultiMessageItem } from "./types";
6
+ export declare const MultiMessage: (props: MultiMessageProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "@axa-fr/canopee-css/client/MultiMessage/MultiMessageLF.css";
3
+ import { Message } from "../Message/MessageLF";
4
+ import { Pagination } from "../Pagination/PaginationLF";
5
+ import { MultiMessageCommon, } from "./MultiMessageCommon";
6
+ export { messageVariants } from "../Message/MessageLF";
7
+ export const MultiMessage = (props) => (_jsx(MultiMessageCommon, { ...props, MessageComponent: Message, PaginationComponent: Pagination }));
@@ -0,0 +1,14 @@
1
+ import type { ReactElement, ReactNode, ComponentType } from "react";
2
+ import type { ButtonProps } from "../Button/ButtonCommon";
3
+ import type { Link } from "../Link/LinkCommon";
4
+ import type { MessageVariants } from "../Message/types";
5
+ export type MultiMessageItem = {
6
+ /** Variant of the individual message */
7
+ variant: MessageVariants;
8
+ /** Title of the message */
9
+ title?: string;
10
+ /** Body content of the message */
11
+ children?: ReactNode;
12
+ /** Action (link or button) shown alongside the message body */
13
+ action?: ReactElement<typeof Link | ComponentType<ButtonProps>>;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -4,8 +4,8 @@ import { ItemPaginationCommon } from "./ItemPagination/ItemPaginationCommon";
4
4
  import { type getItemsProps } from "./Pagination.helper";
5
5
  export type PaginationProps = getItemsProps & ComponentPropsWithoutRef<"nav"> & {
6
6
  hidePrevNext?: boolean;
7
- prevButtonProps?: ComponentProps<typeof ClickIcon>;
8
- nextButtonProps?: ComponentProps<typeof ClickIcon>;
7
+ prevButtonProps?: Partial<ComponentProps<typeof ClickIcon>>;
8
+ nextButtonProps?: Partial<ComponentProps<typeof ClickIcon>>;
9
9
  };
10
10
  type PaginationCommonProps = PaginationProps & {
11
11
  ItemPaginationComponent: ComponentType<ComponentProps<typeof ItemPaginationCommon>>;
@@ -49,6 +49,7 @@ export { ClickItem, clickItemStates, clickItemVariants, type ClickItemStates, ty
49
49
  export { ContentItemDuo } from "./prospect-client/List/ContentItemDuo/ContentItemDuoApollo";
50
50
  export { List, type ListProps } from "./prospect-client/List/List/ListApollo";
51
51
  export { Message, messageVariants, type MessageVariants, } from "./prospect-client/Message/MessageApollo";
52
+ export { MultiMessage, type MultiMessageItem, type MultiMessageProps, } from "./prospect-client/MultiMessage/MultiMessageApollo";
52
53
  export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./prospect-client/Modal/ModalApollo";
53
54
  export { ItemPagination, type ItemPaginationProps, } from "./prospect-client/Pagination/ItemPagination/ItemPaginationApollo";
54
55
  export { Pagination } from "./prospect-client/Pagination/PaginationApollo";
package/dist/prospect.js CHANGED
@@ -49,6 +49,7 @@ export { ClickItem, clickItemStates, clickItemVariants, } from "./prospect-clien
49
49
  export { ContentItemDuo } from "./prospect-client/List/ContentItemDuo/ContentItemDuoApollo";
50
50
  export { List } from "./prospect-client/List/List/ListApollo";
51
51
  export { Message, messageVariants, } from "./prospect-client/Message/MessageApollo";
52
+ export { MultiMessage, } from "./prospect-client/MultiMessage/MultiMessageApollo";
52
53
  export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./prospect-client/Modal/ModalApollo";
53
54
  export { ItemPagination, } from "./prospect-client/Pagination/ItemPagination/ItemPaginationApollo";
54
55
  export { Pagination } from "./prospect-client/Pagination/PaginationApollo";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/canopee-react",
3
- "version": "1.7.1-alpha.18",
3
+ "version": "1.7.1-alpha.20",
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.7.1-alpha.18",
52
+ "@axa-fr/canopee-css": "1.7.1-alpha.20",
53
53
  "@material-symbols/svg-400": ">= 0.19.0",
54
54
  "@material-symbols/svg-700": ">= 0.19.0",
55
55
  "react": ">= 18"