@axa-fr/design-system-apollo-react 2.0.4-alpha.92 → 3.0.0-RC.1
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/Form/FileUpload/FileUpload/FileUploadApollo.d.ts +3 -0
- package/dist/Form/FileUpload/FileUpload/FileUploadApollo.js +7 -0
- package/dist/Form/FileUpload/FileUpload/FileUploadCommon.d.ts +18 -0
- package/dist/Form/FileUpload/FileUpload/FileUploadCommon.js +7 -0
- package/dist/Form/FileUpload/FileUpload/FileUploadLF.d.ts +3 -0
- package/dist/Form/FileUpload/FileUpload/FileUploadLF.js +7 -0
- package/dist/Form/FileUpload/InputFile/InputFileApollo.d.ts +4 -0
- package/dist/Form/FileUpload/InputFile/InputFileApollo.js +11 -0
- package/dist/Form/FileUpload/InputFile/InputFileCommon.d.ts +60 -0
- package/dist/Form/FileUpload/InputFile/InputFileCommon.js +34 -0
- package/dist/Form/FileUpload/InputFile/InputFileLF.d.ts +4 -0
- package/dist/Form/FileUpload/InputFile/InputFileLF.js +9 -0
- package/dist/Form/FileUpload/ItemFile/ItemFileApollo.d.ts +3 -0
- package/dist/Form/FileUpload/ItemFile/ItemFileApollo.js +10 -0
- package/dist/Form/FileUpload/ItemFile/ItemFileCommon.d.ts +54 -0
- package/dist/Form/FileUpload/ItemFile/ItemFileCommon.js +23 -0
- package/dist/Form/FileUpload/ItemFile/ItemFileLF.d.ts +3 -0
- package/dist/Form/FileUpload/ItemFile/ItemFileLF.js +10 -0
- package/dist/Form/ItemLabel/ItemLabelCommon.d.ts +93 -6
- package/dist/Form/ItemLabel/ItemLabelCommon.js +47 -3
- package/dist/Spinner/SpinnerCommon.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/indexLF.d.ts +3 -1
- package/dist/indexLF.js +3 -1
- package/dist/utilities/generateId.d.ts +1 -0
- package/dist/utilities/generateId.js +10 -0
- package/package.json +3 -3
- package/dist/Form/ItemFile/ItemFileApollo.d.ts +0 -4
- package/dist/Form/ItemFile/ItemFileApollo.js +0 -11
- package/dist/Form/ItemFile/ItemFileCommon.d.ts +0 -34
- package/dist/Form/ItemFile/ItemFileCommon.js +0 -13
- package/dist/Form/ItemFile/ItemFileLF.d.ts +0 -4
- package/dist/Form/ItemFile/ItemFileLF.js +0 -11
- package/dist/Form/ItemFile/ItemStateIcon.d.ts +0 -11
- package/dist/Form/ItemFile/ItemStateIcon.js +0 -9
- package/dist/Form/ItemFile/types.d.ts +0 -6
- package/dist/Form/ItemFile/types.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type FileUploadProps } from "./FileUploadCommon";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/FileUpload/FileUploadApollo.css";
|
|
3
|
+
export declare const FileUpload: import("react").ForwardRefExoticComponent<Omit<FileUploadProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { InputFile } from "../InputFile/InputFileApollo";
|
|
4
|
+
import { FileUploadCommon } from "./FileUploadCommon";
|
|
5
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/FileUpload/FileUploadApollo.css";
|
|
6
|
+
export const FileUpload = forwardRef((props, ref) => (_jsx(FileUploadCommon, { ...props, ref: ref, InputFileComponent: InputFile })));
|
|
7
|
+
FileUpload.displayName = "FileUpload";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ComponentType, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { InputFileProps } from "../InputFile/InputFileCommon";
|
|
3
|
+
import type { ItemFileProps } from "../ItemFile/ItemFileCommon";
|
|
4
|
+
export type FileUploadProps = Omit<InputFileProps, "children"> & {
|
|
5
|
+
/**
|
|
6
|
+
* List of ItemFile components representing uploaded files.
|
|
7
|
+
*/
|
|
8
|
+
children?: ReactElement<ItemFileProps> | ReactElement<ItemFileProps>[];
|
|
9
|
+
/**
|
|
10
|
+
* Custom label for the uploaded files list. Defaults to "Vos fichiers importés :".
|
|
11
|
+
*/
|
|
12
|
+
fileListLabel?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
type FileUploadCommonProps = FileUploadProps & {
|
|
15
|
+
InputFileComponent: ComponentType<InputFileProps>;
|
|
16
|
+
};
|
|
17
|
+
export declare const FileUploadCommon: import("react").ForwardRefExoticComponent<Omit<FileUploadCommonProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, forwardRef, } from "react";
|
|
3
|
+
import { generateId } from "../../../utilities/generateId";
|
|
4
|
+
export const FileUploadCommon = forwardRef(({ InputFileComponent, className, children, fileListLabel = "Vos fichiers importés :", ...props }, ref) => {
|
|
5
|
+
return (_jsx(InputFileComponent, { ...props, className: ["af-file-upload", className].filter(Boolean).join(" "), ref: ref, children: children ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "af-file-list__title", children: fileListLabel }), _jsx("ul", { className: "af-file-list", children: Children.map(children, (child) => (_jsx("li", { className: "af-file-list__item", children: child }, generateId(child)))) })] })) : null }));
|
|
6
|
+
});
|
|
7
|
+
FileUploadCommon.displayName = "FileUploadCommon";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type FileUploadProps } from "./FileUploadCommon";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/FileUpload/FileUploadLF.css";
|
|
3
|
+
export declare const FileUpload: import("react").ForwardRefExoticComponent<Omit<FileUploadProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { InputFile } from "../InputFile/InputFileLF";
|
|
4
|
+
import { FileUploadCommon } from "./FileUploadCommon";
|
|
5
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/FileUpload/FileUploadLF.css";
|
|
6
|
+
export const FileUpload = forwardRef((props, ref) => (_jsx(FileUploadCommon, { ...props, ref: ref, InputFileComponent: InputFile })));
|
|
7
|
+
FileUpload.displayName = "FileUpload";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type InputFileProps } from "./InputFileCommon";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/InputFile/InputFileApollo.css";
|
|
3
|
+
declare const InputFile: import("react").ForwardRefExoticComponent<Omit<InputFileProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
4
|
+
export { InputFile };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ItemLabel } from "../../ItemLabel/ItemLabelApollo";
|
|
4
|
+
import { ItemMessage } from "../../ItemMessage/ItemMessageApollo";
|
|
5
|
+
import { InputFileCommon } from "./InputFileCommon";
|
|
6
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/InputFile/InputFileApollo.css";
|
|
7
|
+
const InputFile = forwardRef((props, ref) => {
|
|
8
|
+
return (_jsx(InputFileCommon, { ...props, ref: ref, ItemLabelComponent: ItemLabel, ItemMessageComponent: ItemMessage }));
|
|
9
|
+
});
|
|
10
|
+
InputFile.displayName = "InputFile";
|
|
11
|
+
export { InputFile };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type ComponentType, type MouseEventHandler, type ReactNode } from "react";
|
|
2
|
+
import { type ItemLabelProps } from "../../ItemLabel/ItemLabelCommon";
|
|
3
|
+
import { type ItemMessageProps } from "../../ItemMessage/ItemMessageCommon";
|
|
4
|
+
type LabelProps = Partial<Omit<ItemLabelProps, "children" | "label" | "description" | "sideButtonLabel" | "onSideButtonClick" | "moreButtonLabel" | "onMoreButtonClick">>;
|
|
5
|
+
export type InputFileProps = Omit<ComponentPropsWithRef<"input">, "type"> & {
|
|
6
|
+
/**
|
|
7
|
+
* Label text content
|
|
8
|
+
*/
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Additional description text that enriches the label.
|
|
12
|
+
* @example "Phone bill, EDF receipt, etc."
|
|
13
|
+
*/
|
|
14
|
+
description?: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Label content for the side action button.
|
|
17
|
+
* When provided, renders a secondary button next to the main label.
|
|
18
|
+
*/
|
|
19
|
+
sideButtonLabel?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Click handler for the side button
|
|
22
|
+
*/
|
|
23
|
+
onSideButtonClick?: MouseEventHandler<HTMLButtonElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Label content for the more button
|
|
26
|
+
* When provided, renders an more button with an info icon.
|
|
27
|
+
*/
|
|
28
|
+
moreButtonLabel?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Click handler for the more button
|
|
31
|
+
*/
|
|
32
|
+
onMoreButtonClick?: MouseEventHandler<HTMLButtonElement>;
|
|
33
|
+
/**
|
|
34
|
+
* Props forwarded to the label component to customize its appearance and behavior.
|
|
35
|
+
* Accepts a subset of ItemLabelProps (see LabelProps type). Use this to override
|
|
36
|
+
* visual or behavioral options for the label (e.g., size, tone, visibility of helpers).
|
|
37
|
+
*/
|
|
38
|
+
labelProps?: LabelProps;
|
|
39
|
+
/**
|
|
40
|
+
* Help text displayed below the control. This text is associated with the input via
|
|
41
|
+
* `aria-describedby` when provided. Keep the content concise and actionable; avoid
|
|
42
|
+
* using color alone to convey meaning.
|
|
43
|
+
*/
|
|
44
|
+
helper?: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Labels for the dropzone UI. Each field is optional and will fall back to defaults.
|
|
47
|
+
* Example: { dropzone: 'Glisser...', or: 'ou', button: 'Importer fichier' }
|
|
48
|
+
*/
|
|
49
|
+
dropzoneLabels?: {
|
|
50
|
+
dropzone?: ReactNode;
|
|
51
|
+
or?: ReactNode;
|
|
52
|
+
button?: ReactNode;
|
|
53
|
+
};
|
|
54
|
+
} & Omit<ItemMessageProps, "id">;
|
|
55
|
+
type InputFileCommonProps = InputFileProps & {
|
|
56
|
+
ItemLabelComponent: ComponentType<ItemLabelProps>;
|
|
57
|
+
ItemMessageComponent: ComponentType<ItemMessageProps>;
|
|
58
|
+
};
|
|
59
|
+
export declare const InputFileCommon: import("react").ForwardRefExoticComponent<Omit<InputFileCommonProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, } from "react";
|
|
3
|
+
import addCircleIcon from "@material-symbols/svg-400/rounded/add_circle-fill.svg";
|
|
4
|
+
import { Svg } from "../../../Svg/Svg";
|
|
5
|
+
const DEFAULT_DROPZONE_LABELS = {
|
|
6
|
+
dropzone: "Glisser et déposer un fichier",
|
|
7
|
+
or: "ou",
|
|
8
|
+
button: "Importer fichier",
|
|
9
|
+
};
|
|
10
|
+
export const InputFileCommon = forwardRef(({ ItemLabelComponent, ItemMessageComponent, id, label, description, sideButtonLabel, onSideButtonClick, moreButtonLabel, onMoreButtonClick, labelProps, helper, required, message, messageType = "error", className, style, dropzoneLabels = {}, children, ...props }, ref) => {
|
|
11
|
+
const generatedId = useId();
|
|
12
|
+
const inputId = id || generatedId;
|
|
13
|
+
const messageId = `${inputId}-message`;
|
|
14
|
+
const helpId = `${inputId}-help`;
|
|
15
|
+
const ariaDescribedby = [
|
|
16
|
+
helper && helpId,
|
|
17
|
+
message && messageType === "success" && messageId,
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
const hasError = Boolean(message && messageType === "error");
|
|
20
|
+
const resolvedDropzoneLabels = {
|
|
21
|
+
dropzone: dropzoneLabels.dropzone || DEFAULT_DROPZONE_LABELS.dropzone,
|
|
22
|
+
or: dropzoneLabels.or || DEFAULT_DROPZONE_LABELS.or,
|
|
23
|
+
button: dropzoneLabels.button || DEFAULT_DROPZONE_LABELS.button,
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs("div", { className: ["af-input-file", className].filter(Boolean).join(" "), style: style, children: [_jsx(ItemLabelComponent, { htmlFor: inputId, description: description, sideButtonLabel: sideButtonLabel, onSideButtonClick: onSideButtonClick, moreButtonLabel: moreButtonLabel, onMoreButtonClick: onMoreButtonClick, required: required, ...labelProps, children: label }), _jsxs("div", { className: "af-input-file__container", children: [_jsxs("span", { className: [
|
|
26
|
+
"af-input-file__dropzone",
|
|
27
|
+
hasError && "af-input-file__dropzone--error",
|
|
28
|
+
]
|
|
29
|
+
.filter(Boolean)
|
|
30
|
+
.join(" "), children: [_jsx("input", { ref: ref, type: "file", id: inputId, required: required, "aria-invalid": hasError || undefined, "aria-errormessage": hasError ? messageId : undefined, "aria-describedby": ariaDescribedby.length > 0
|
|
31
|
+
? ariaDescribedby.join(" ")
|
|
32
|
+
: undefined, ...props }), _jsx("span", { children: resolvedDropzoneLabels.dropzone }), _jsx("span", { children: resolvedDropzoneLabels.or }), _jsxs("span", { className: "af-btn-client af-btn-client--tertiary", children: [_jsx(Svg, { src: addCircleIcon, role: "presentation" }), resolvedDropzoneLabels.button] })] }), helper ? (_jsx("span", { id: helpId, className: "af-input-file__help", children: helper })) : null, _jsx(ItemMessageComponent, { id: messageId, message: message, messageType: messageType })] }), children] }));
|
|
33
|
+
});
|
|
34
|
+
InputFileCommon.displayName = "InputFileCommon";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type InputFileProps } from "./InputFileCommon";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/InputFile/InputFileLF.css";
|
|
3
|
+
declare const InputFile: import("react").ForwardRefExoticComponent<Omit<InputFileProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
4
|
+
export { InputFile };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ItemLabel } from "../../ItemLabel/ItemLabelLF";
|
|
4
|
+
import { ItemMessage } from "../../ItemMessage/ItemMessageLF";
|
|
5
|
+
import { InputFileCommon } from "./InputFileCommon";
|
|
6
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/InputFile/InputFileLF.css";
|
|
7
|
+
const InputFile = forwardRef((props, ref) => (_jsx(InputFileCommon, { ...props, ref: ref, ItemLabelComponent: ItemLabel, ItemMessageComponent: ItemMessage })));
|
|
8
|
+
InputFile.displayName = "InputFile";
|
|
9
|
+
export { InputFile };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import deleteIcon from "@material-symbols/svg-400/outlined/delete.svg";
|
|
3
|
+
import visibilityIcon from "@material-symbols/svg-400/outlined/visibility-fill.svg";
|
|
4
|
+
import { ClickIcon } from "../../../ClickIcon/ClickIconApollo";
|
|
5
|
+
import { Icon } from "../../../Icon/IconApollo";
|
|
6
|
+
import { Spinner } from "../../../Spinner/SpinnerApollo";
|
|
7
|
+
import { ItemMessage } from "../../ItemMessage/ItemMessageApollo";
|
|
8
|
+
import { ItemFileCommon } from "./ItemFileCommon";
|
|
9
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/ItemFile/ItemFileApollo.css";
|
|
10
|
+
export const ItemFile = (props) => (_jsx(ItemFileCommon, { ItemMessageComponent: ItemMessage, ItemIconComponent: Icon, ItemSpinnerComponent: Spinner, ClickIconComponent: ClickIcon, removeIcon: deleteIcon, previewIcon: visibilityIcon, ...props }));
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ComponentType, type MouseEvent } from "react";
|
|
2
|
+
import type { ClickIconProps } from "../../../ClickIcon/ClickIconCommon";
|
|
3
|
+
import type { IconProps } from "../../../Icon/IconCommon";
|
|
4
|
+
import type { SpinnerProps } from "../../../Spinner/SpinnerCommon";
|
|
5
|
+
import type { ItemMessageProps } from "../../ItemMessage/ItemMessageCommon";
|
|
6
|
+
export type ItemFileProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The JavaScript File object representing the uploaded file.
|
|
9
|
+
* (required)
|
|
10
|
+
*/
|
|
11
|
+
file: File;
|
|
12
|
+
/**
|
|
13
|
+
* When true, a spinner is shown instead of the validation icon and actions
|
|
14
|
+
* may be disabled.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* An optional error message shown below the file. If present, the item is
|
|
20
|
+
* rendered in an error state.
|
|
21
|
+
*/
|
|
22
|
+
errorMessage?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Callback invoked when the remove action is triggered. Receives the file
|
|
25
|
+
* and the click event.
|
|
26
|
+
*/
|
|
27
|
+
onRemove?: (file: File, event: MouseEvent<HTMLButtonElement>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Callback invoked when the preview action is triggered. Receives the file
|
|
30
|
+
* and the click event.
|
|
31
|
+
*/
|
|
32
|
+
onPreview?: (file: File, event: MouseEvent<HTMLButtonElement>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Optional props forwarded to the preview icon button (except `src` and
|
|
35
|
+
* `onClick`).
|
|
36
|
+
* @default {}
|
|
37
|
+
*/
|
|
38
|
+
previewProps?: Partial<Omit<ClickIconProps, "src" | "onClick">>;
|
|
39
|
+
/**
|
|
40
|
+
* Optional props forwarded to the remove icon button (except `src` and
|
|
41
|
+
* `onClick`).
|
|
42
|
+
* @default {}
|
|
43
|
+
*/
|
|
44
|
+
removeProps?: Partial<Omit<ClickIconProps, "src" | "onClick">>;
|
|
45
|
+
} & Omit<ComponentPropsWithoutRef<"section">, "children">;
|
|
46
|
+
export type ItemFileCommonProps = ItemFileProps & {
|
|
47
|
+
ItemMessageComponent: ComponentType<ItemMessageProps>;
|
|
48
|
+
ItemIconComponent: ComponentType<IconProps>;
|
|
49
|
+
ItemSpinnerComponent: ComponentType<SpinnerProps>;
|
|
50
|
+
ClickIconComponent: ComponentType<ClickIconProps>;
|
|
51
|
+
removeIcon: string;
|
|
52
|
+
previewIcon: string;
|
|
53
|
+
};
|
|
54
|
+
export declare const ItemFileCommon: ({ file, isLoading, errorMessage, className, onRemove, onPreview, previewProps, removeProps, removeIcon, previewIcon, ItemSpinnerComponent, ItemIconComponent, ItemMessageComponent, ClickIconComponent, ...props }: ItemFileCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import validationIcon from "@material-symbols/svg-400/outlined/check_circle-fill.svg";
|
|
3
|
+
import errorIcon from "@material-symbols/svg-400/outlined/error-fill.svg";
|
|
4
|
+
const BASE_UNIT = 1000;
|
|
5
|
+
const BYTE_UNITS = ["Ko", "Mo", "Go"];
|
|
6
|
+
const getReadableFileSizeString = (fileSizeInBytes) => {
|
|
7
|
+
let i = -1;
|
|
8
|
+
let fileSizeInBytesCopy = fileSizeInBytes;
|
|
9
|
+
do {
|
|
10
|
+
fileSizeInBytesCopy /= BASE_UNIT;
|
|
11
|
+
i += 1;
|
|
12
|
+
} while (fileSizeInBytesCopy > BASE_UNIT);
|
|
13
|
+
return `${Math.max(fileSizeInBytesCopy, 0.1).toFixed(1)} ${BYTE_UNITS[i]}`;
|
|
14
|
+
};
|
|
15
|
+
export const ItemFileCommon = ({ file, isLoading, errorMessage, className, onRemove = () => { }, onPreview = () => { }, previewProps = {}, removeProps = {}, removeIcon, previewIcon, ItemSpinnerComponent, ItemIconComponent, ItemMessageComponent, ClickIconComponent, ...props }) => {
|
|
16
|
+
const hasError = Boolean(errorMessage);
|
|
17
|
+
const handleClick = (callback) => (e) => {
|
|
18
|
+
callback(file, e);
|
|
19
|
+
};
|
|
20
|
+
return (_jsxs("section", { className: ["af-item-file", hasError && "af-item-file--error", className]
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join(" "), "aria-busy": isLoading ? true : undefined, "aria-live": "polite", ...props, children: [_jsxs("div", { className: "af-item-file__body", children: [isLoading && !hasError ? (_jsx(ItemSpinnerComponent, { size: 24 })) : (_jsx(ItemIconComponent, { size: "S", src: hasError ? errorIcon : validationIcon })), _jsx("p", { className: "af-item-file__file-name", children: file.name }), _jsx("p", { className: "af-item-file__file-size", children: getReadableFileSizeString(file.size) }), _jsxs("div", { className: "af-item-file__actions", children: [!isLoading && !hasError && (_jsx(ClickIconComponent, { src: previewIcon, onClick: handleClick(onPreview), "aria-label": `Previsualiser le fichier ${file.name}`, ...previewProps })), _jsx(ClickIconComponent, { src: removeIcon, onClick: handleClick(onRemove), "aria-label": `Suppression du fichier ${file.name}`, ...removeProps })] })] }), _jsx(ItemMessageComponent, { message: errorMessage })] }));
|
|
23
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import deleteIconFilled from "@material-symbols/svg-400/outlined/delete-fill.svg";
|
|
3
|
+
import visibilityIcon from "@material-symbols/svg-400/outlined/visibility-fill.svg";
|
|
4
|
+
import { ClickIcon } from "../../../ClickIcon/ClickIconLF";
|
|
5
|
+
import { Icon } from "../../../Icon/IconLF";
|
|
6
|
+
import { Spinner } from "../../../Spinner/SpinnerLF";
|
|
7
|
+
import { ItemMessage } from "../../ItemMessage/ItemMessageLF";
|
|
8
|
+
import { ItemFileCommon } from "./ItemFileCommon";
|
|
9
|
+
import "@axa-fr/design-system-apollo-css/dist/Form/FileUpload/ItemFile/ItemFileLF.css";
|
|
10
|
+
export const ItemFile = (props) => (_jsx(ItemFileCommon, { ItemMessageComponent: ItemMessage, ItemIconComponent: Icon, ItemSpinnerComponent: Spinner, ClickIconComponent: ClickIcon, removeIcon: deleteIconFilled, previewIcon: visibilityIcon, ...props }));
|
|
@@ -1,16 +1,103 @@
|
|
|
1
|
-
import { type ComponentType, type MouseEventHandler, type ReactNode } from "react";
|
|
1
|
+
import { type ComponentType, type MouseEventHandler, type ReactNode, type ComponentProps } from "react";
|
|
2
2
|
import type { ButtonProps } from "../../Button/ButtonCommon";
|
|
3
|
-
export type ItemLabelProps = {
|
|
3
|
+
export type ItemLabelProps = ComponentProps<"label"> & {
|
|
4
|
+
/**
|
|
5
|
+
* Label text content
|
|
6
|
+
* @deprecated use `children` instead.
|
|
7
|
+
*/
|
|
4
8
|
label?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Additional description text that enriches the label.
|
|
11
|
+
* @example "Phone bill, EDF receipt, etc."
|
|
12
|
+
*/
|
|
5
13
|
description?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Shows a visual asterisk (*) indicator next to the label.
|
|
16
|
+
*/
|
|
6
17
|
required?: boolean;
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
/**
|
|
19
|
+
* ID of the associated input element
|
|
20
|
+
* @deprecated use `htmlFor` instead.
|
|
21
|
+
*/
|
|
22
|
+
inputId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Label content for the side action button.
|
|
25
|
+
* When provided, renders a secondary button next to the main label.
|
|
26
|
+
*/
|
|
27
|
+
sideButtonLabel?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Click handler for the side button
|
|
30
|
+
*/
|
|
9
31
|
onSideButtonClick?: MouseEventHandler<HTMLButtonElement>;
|
|
10
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Additional props to pass to the side button component.
|
|
34
|
+
*/
|
|
35
|
+
sideButtonProps?: Omit<Partial<ButtonProps>, "children" | "onClick" | "variant" | "className">;
|
|
36
|
+
/**
|
|
37
|
+
* Label content for the more button
|
|
38
|
+
* @deprecated use `moreButtonLabel` instead.
|
|
39
|
+
*/
|
|
40
|
+
buttonLabel?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Click handler for the info button
|
|
43
|
+
* @deprecated use `onInfoButtonClick` instead.
|
|
44
|
+
*/
|
|
11
45
|
onButtonClick?: MouseEventHandler<HTMLButtonElement>;
|
|
46
|
+
/**
|
|
47
|
+
* Label content for the more button
|
|
48
|
+
* When provided, renders an more button with an info icon.
|
|
49
|
+
*/
|
|
50
|
+
moreButtonLabel?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Click handler for the more button
|
|
53
|
+
*/
|
|
54
|
+
onMoreButtonClick?: MouseEventHandler<HTMLButtonElement>;
|
|
55
|
+
/**
|
|
56
|
+
* Additional props to pass to the more button component.
|
|
57
|
+
*/
|
|
58
|
+
moreButtonProps?: Omit<Partial<ButtonProps>, "children" | "onClick" | "variant" | "className">;
|
|
12
59
|
};
|
|
13
60
|
export type ItemLabelCommonProps = ItemLabelProps & {
|
|
14
61
|
ButtonComponent: ComponentType<ButtonProps>;
|
|
15
62
|
};
|
|
16
|
-
|
|
63
|
+
/**
|
|
64
|
+
* A comprehensive label component for form items with support for descriptions and action buttons.
|
|
65
|
+
*
|
|
66
|
+
* This component provides an accessible label that can be enhanced with:
|
|
67
|
+
* - Visual required field indicator (asterisk)
|
|
68
|
+
* - Optional description text
|
|
69
|
+
* - Optional side action button
|
|
70
|
+
* - Optional more button with icon
|
|
71
|
+
*
|
|
72
|
+
* The component ensures proper accessibility by:
|
|
73
|
+
* - Associating the label with form controls via htmlFor
|
|
74
|
+
* - Providing appropriate ARIA attributes for screen readers
|
|
75
|
+
* - Supporting keyboard navigation for interactive elements
|
|
76
|
+
*
|
|
77
|
+
* @example Basic usage
|
|
78
|
+
* ```tsx
|
|
79
|
+
* <ItemLabelCommon
|
|
80
|
+
* htmlFor="email-input"
|
|
81
|
+
* required
|
|
82
|
+
* ButtonComponent={Button}
|
|
83
|
+
* >
|
|
84
|
+
* Email Address
|
|
85
|
+
* </ItemLabelCommon>
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example With description and action buttons
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <ItemLabelCommon
|
|
91
|
+
* htmlFor="document-upload"
|
|
92
|
+
* description="Accepted: PDF, JPG, PNG (max 5MB)"
|
|
93
|
+
* sideButtonLabel="Browse"
|
|
94
|
+
* onSideButtonClick={handleBrowse}
|
|
95
|
+
* moreButton="Help"
|
|
96
|
+
* onMoreButtonClick={handleShowHelp}
|
|
97
|
+
* ButtonComponent={Button}
|
|
98
|
+
* >
|
|
99
|
+
* Proof of residence
|
|
100
|
+
* </ItemLabelCommon>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare const ItemLabelCommon: ({ label, children, description, required, inputId, htmlFor, className, style, "aria-describedby": ariaDescribedby, sideButtonLabel, onSideButtonClick, sideButtonProps, buttonLabel, onButtonClick, moreButtonLabel, onMoreButtonClick, ButtonComponent, moreButtonProps, ...props }: ItemLabelCommonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -2,10 +2,54 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useId, } from "react";
|
|
3
3
|
import infoIcon from "@material-symbols/svg-400/outlined/info.svg";
|
|
4
4
|
import { Svg } from "../../Svg/Svg";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A comprehensive label component for form items with support for descriptions and action buttons.
|
|
7
|
+
*
|
|
8
|
+
* This component provides an accessible label that can be enhanced with:
|
|
9
|
+
* - Visual required field indicator (asterisk)
|
|
10
|
+
* - Optional description text
|
|
11
|
+
* - Optional side action button
|
|
12
|
+
* - Optional more button with icon
|
|
13
|
+
*
|
|
14
|
+
* The component ensures proper accessibility by:
|
|
15
|
+
* - Associating the label with form controls via htmlFor
|
|
16
|
+
* - Providing appropriate ARIA attributes for screen readers
|
|
17
|
+
* - Supporting keyboard navigation for interactive elements
|
|
18
|
+
*
|
|
19
|
+
* @example Basic usage
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <ItemLabelCommon
|
|
22
|
+
* htmlFor="email-input"
|
|
23
|
+
* required
|
|
24
|
+
* ButtonComponent={Button}
|
|
25
|
+
* >
|
|
26
|
+
* Email Address
|
|
27
|
+
* </ItemLabelCommon>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example With description and action buttons
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <ItemLabelCommon
|
|
33
|
+
* htmlFor="document-upload"
|
|
34
|
+
* description="Accepted: PDF, JPG, PNG (max 5MB)"
|
|
35
|
+
* sideButtonLabel="Browse"
|
|
36
|
+
* onSideButtonClick={handleBrowse}
|
|
37
|
+
* moreButton="Help"
|
|
38
|
+
* onMoreButtonClick={handleShowHelp}
|
|
39
|
+
* ButtonComponent={Button}
|
|
40
|
+
* >
|
|
41
|
+
* Proof of residence
|
|
42
|
+
* </ItemLabelCommon>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const ItemLabelCommon = ({ label, children, description, required, inputId, htmlFor, className, style, "aria-describedby": ariaDescribedby, sideButtonLabel, onSideButtonClick, sideButtonProps, buttonLabel, onButtonClick, moreButtonLabel, onMoreButtonClick, ButtonComponent, moreButtonProps, ...props }) => {
|
|
6
46
|
const idDescription = useId();
|
|
7
|
-
|
|
47
|
+
const contentLabel = children ?? label;
|
|
48
|
+
const describedByIds = [description ? idDescription : null, ariaDescribedby]
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join(" ");
|
|
51
|
+
if (!contentLabel) {
|
|
8
52
|
return null;
|
|
9
53
|
}
|
|
10
|
-
return (_jsxs("div", { className: "af-item-label", children: [
|
|
54
|
+
return (_jsxs("div", { className: ["af-item-label", className].filter(Boolean).join(" "), style: style, children: [_jsxs("label", { htmlFor: htmlFor || inputId, className: "af-item-label__label", "aria-describedby": describedByIds || undefined, ...props, children: [contentLabel, required ? _jsx("span", { "aria-hidden": true, children: "*" }) : null] }), sideButtonLabel ? (_jsx(ButtonComponent, { ...sideButtonProps, variant: "ghost", onClick: onSideButtonClick, className: "af-item-label__sidebutton", children: sideButtonLabel })) : null, description ? (_jsx("span", { id: idDescription, className: "af-item-label__description", children: description })) : null, moreButtonLabel || buttonLabel ? (_jsx(ButtonComponent, { iconLeft: _jsx(Svg, { src: infoIcon, role: "presentation" }), ...moreButtonProps, variant: "ghost", className: "af-item-label__more", onClick: onMoreButtonClick || onButtonClick, children: moreButtonLabel || buttonLabel })) : null] }));
|
|
11
55
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export { type OptionType } from "./Form/InputPhone/InputPhone.types";
|
|
|
23
23
|
export { InputPhone } from "./Form/InputPhone/InputPhoneApollo";
|
|
24
24
|
export { InputText } from "./Form/InputText/InputTextApollo";
|
|
25
25
|
export { InputTextAtom } from "./Form/InputTextAtom/InputTextAtomApollo";
|
|
26
|
-
export { ItemFile, itemFileVariants } from "./Form/ItemFile/ItemFileApollo";
|
|
27
26
|
export { ItemLabel } from "./Form/ItemLabel/ItemLabelApollo";
|
|
28
27
|
export { ItemMessage, itemMessageVariants, type ItemMessageVariants, } from "./Form/ItemMessage/ItemMessageApollo";
|
|
29
28
|
export { CardRadio } from "./Form/Radio/CardRadio/CardRadioApollo";
|
|
@@ -50,3 +49,6 @@ export { Svg } from "./Svg/Svg";
|
|
|
50
49
|
export { Tag, tagVariants, type TagVariants } from "./Tag/TagApollo";
|
|
51
50
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalApollo";
|
|
52
51
|
export { Toggle } from "./Toggle/ToggleApollo";
|
|
52
|
+
export { InputFile } from "./Form/FileUpload/InputFile/InputFileApollo";
|
|
53
|
+
export { ItemFile } from "./Form/FileUpload/ItemFile/ItemFileApollo";
|
|
54
|
+
export { FileUpload } from "./Form/FileUpload/FileUpload/FileUploadApollo";
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ export { InputDate } from "./Form/InputDate/InputDateApollo";
|
|
|
22
22
|
export { InputPhone } from "./Form/InputPhone/InputPhoneApollo";
|
|
23
23
|
export { InputText } from "./Form/InputText/InputTextApollo";
|
|
24
24
|
export { InputTextAtom } from "./Form/InputTextAtom/InputTextAtomApollo";
|
|
25
|
-
export { ItemFile, itemFileVariants } from "./Form/ItemFile/ItemFileApollo";
|
|
26
25
|
export { ItemLabel } from "./Form/ItemLabel/ItemLabelApollo";
|
|
27
26
|
export { ItemMessage, itemMessageVariants, } from "./Form/ItemMessage/ItemMessageApollo";
|
|
28
27
|
export { CardRadio } from "./Form/Radio/CardRadio/CardRadioApollo";
|
|
@@ -49,3 +48,6 @@ export { Svg } from "./Svg/Svg";
|
|
|
49
48
|
export { Tag, tagVariants } from "./Tag/TagApollo";
|
|
50
49
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalApollo";
|
|
51
50
|
export { Toggle } from "./Toggle/ToggleApollo";
|
|
51
|
+
export { InputFile } from "./Form/FileUpload/InputFile/InputFileApollo";
|
|
52
|
+
export { ItemFile } from "./Form/FileUpload/ItemFile/ItemFileApollo";
|
|
53
|
+
export { FileUpload } from "./Form/FileUpload/FileUpload/FileUploadApollo";
|
package/dist/indexLF.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export { InputText,
|
|
|
27
27
|
/** @deprecated Use `InputText` instead. */
|
|
28
28
|
InputText as TextInput, } from "./Form/InputText/InputTextLF";
|
|
29
29
|
export { InputTextAtom } from "./Form/InputTextAtom/InputTextAtomLF";
|
|
30
|
-
export { ItemFile, itemFileVariants } from "./Form/ItemFile/ItemFileLF";
|
|
31
30
|
export { ItemLabel } from "./Form/ItemLabel/ItemLabelLF";
|
|
32
31
|
export { ItemMessage, itemMessageVariants, type ItemMessageVariants, } from "./Form/ItemMessage/ItemMessageLF";
|
|
33
32
|
export { CardRadio } from "./Form/Radio/CardRadio/CardRadioLF";
|
|
@@ -54,3 +53,6 @@ export { Svg } from "./Svg/Svg";
|
|
|
54
53
|
export { Tag, tagVariants, type TagVariants } from "./Tag/TagLF";
|
|
55
54
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalLF";
|
|
56
55
|
export { Toggle } from "./Toggle/ToggleLF";
|
|
56
|
+
export { InputFile } from "./Form/FileUpload/InputFile/InputFileLF";
|
|
57
|
+
export { ItemFile } from "./Form/FileUpload/ItemFile/ItemFileLF";
|
|
58
|
+
export { FileUpload } from "./Form/FileUpload/FileUpload/FileUploadLF";
|
package/dist/indexLF.js
CHANGED
|
@@ -26,7 +26,6 @@ export { InputText,
|
|
|
26
26
|
/** @deprecated Use `InputText` instead. */
|
|
27
27
|
InputText as TextInput, } from "./Form/InputText/InputTextLF";
|
|
28
28
|
export { InputTextAtom } from "./Form/InputTextAtom/InputTextAtomLF";
|
|
29
|
-
export { ItemFile, itemFileVariants } from "./Form/ItemFile/ItemFileLF";
|
|
30
29
|
export { ItemLabel } from "./Form/ItemLabel/ItemLabelLF";
|
|
31
30
|
export { ItemMessage, itemMessageVariants, } from "./Form/ItemMessage/ItemMessageLF";
|
|
32
31
|
export { CardRadio } from "./Form/Radio/CardRadio/CardRadioLF";
|
|
@@ -53,3 +52,6 @@ export { Svg } from "./Svg/Svg";
|
|
|
53
52
|
export { Tag, tagVariants } from "./Tag/TagLF";
|
|
54
53
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalLF";
|
|
55
54
|
export { Toggle } from "./Toggle/ToggleLF";
|
|
55
|
+
export { InputFile } from "./Form/FileUpload/InputFile/InputFileLF";
|
|
56
|
+
export { ItemFile } from "./Form/FileUpload/ItemFile/ItemFileLF";
|
|
57
|
+
export { FileUpload } from "./Form/FileUpload/FileUpload/FileUploadLF";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateId: (item: object) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-apollo-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-RC.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@axa-fr/design-system-apollo-css": "
|
|
49
|
+
"@axa-fr/design-system-apollo-css": "3.0.0-RC.1",
|
|
50
50
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
51
51
|
"react": ">= 18",
|
|
52
|
-
"@axa-fr/design-system-look-and-feel-css": "
|
|
52
|
+
"@axa-fr/design-system-look-and-feel-css": "3.0.0-RC.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@material-symbols/svg-400": {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import "@axa-fr/design-system-apollo-css/dist/Form/ItemFile/ItemFileApollo.css";
|
|
2
|
-
import type { ItemFileProps } from "./types";
|
|
3
|
-
export { itemFileVariants } from "./ItemFileCommon";
|
|
4
|
-
export declare const ItemFile: ({ onDeleteClick, onVisibilityClick, ariaLabelVisibility, ariaLabelDelete, filename, ...props }: ItemFileProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import "@axa-fr/design-system-apollo-css/dist/Form/ItemFile/ItemFileApollo.css";
|
|
3
|
-
import deleteIcon from "@material-symbols/svg-400/outlined/delete.svg";
|
|
4
|
-
import visibilityIcon from "@material-symbols/svg-400/outlined/visibility-fill.svg";
|
|
5
|
-
import { ClickIcon } from "../../ClickIcon/ClickIconApollo";
|
|
6
|
-
import { Icon } from "../../Icon/IconApollo";
|
|
7
|
-
import { Spinner } from "../../Spinner/SpinnerApollo";
|
|
8
|
-
import { ItemMessage } from "../ItemMessage/ItemMessageApollo";
|
|
9
|
-
import { ItemFileCommon } from "./ItemFileCommon";
|
|
10
|
-
export { itemFileVariants } from "./ItemFileCommon";
|
|
11
|
-
export const ItemFile = ({ onDeleteClick, onVisibilityClick, ariaLabelVisibility, ariaLabelDelete, filename, ...props }) => (_jsx(ItemFileCommon, { ItemMessageComponent: ItemMessage, ItemIconComponent: Icon, ItemSpinnerComponent: Spinner, deleteIcon: _jsx(ClickIcon, { src: deleteIcon, onClick: onDeleteClick, "aria-label": ariaLabelDelete || `Suppression du fichier ${filename}` }), visibilityIcon: _jsx(ClickIcon, { src: visibilityIcon, onClick: onVisibilityClick, "aria-label": ariaLabelVisibility || `Observer le fichier ${filename}` }), ...props }));
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ReactNode, type ComponentProps, type ComponentPropsWithoutRef, type ComponentType } from "react";
|
|
2
|
-
import type { IconProps } from "../../Icon/IconCommon";
|
|
3
|
-
import { Spinner } from "../../Spinner/SpinnerCommon";
|
|
4
|
-
import { ItemMessage, type ItemMessageProps } from "../ItemMessage/ItemMessageCommon";
|
|
5
|
-
export declare const itemFileVariants: {
|
|
6
|
-
readonly success: "success";
|
|
7
|
-
readonly error: "error";
|
|
8
|
-
readonly loading: "loading";
|
|
9
|
-
};
|
|
10
|
-
export type ItemFileState = keyof typeof itemFileVariants;
|
|
11
|
-
export type ItemFileProps = {
|
|
12
|
-
state: ItemFileState;
|
|
13
|
-
ariaLabelVisibility?: string;
|
|
14
|
-
ariaLabelDelete?: string;
|
|
15
|
-
filename?: string;
|
|
16
|
-
title: string;
|
|
17
|
-
subTitle: string;
|
|
18
|
-
deleteIcon: ReactNode;
|
|
19
|
-
visibilityIcon?: ReactNode;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `message` and messageType instead.
|
|
22
|
-
*/
|
|
23
|
-
errorMessage?: string;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Use `message` and messageType instead.
|
|
26
|
-
*/
|
|
27
|
-
success?: string;
|
|
28
|
-
} & Omit<ComponentPropsWithoutRef<"section">, "children"> & Partial<ItemMessageProps>;
|
|
29
|
-
export type ItemFileCommonProps = ItemFileProps & {
|
|
30
|
-
ItemMessageComponent: ComponentType<ComponentProps<typeof ItemMessage>>;
|
|
31
|
-
ItemIconComponent: ComponentType<IconProps>;
|
|
32
|
-
ItemSpinnerComponent: ComponentType<ComponentProps<typeof Spinner>>;
|
|
33
|
-
};
|
|
34
|
-
export declare const ItemFileCommon: ({ className, state, title, subTitle, errorMessage, deleteIcon, visibilityIcon, success, message, messageType, ItemSpinnerComponent, ItemIconComponent, ItemMessageComponent, ...props }: ItemFileCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { ItemStateIcon } from "./ItemStateIcon";
|
|
4
|
-
export const itemFileVariants = {
|
|
5
|
-
success: "success",
|
|
6
|
-
error: "error",
|
|
7
|
-
loading: "loading",
|
|
8
|
-
};
|
|
9
|
-
export const ItemFileCommon = ({ className, state, title, subTitle, errorMessage, deleteIcon, visibilityIcon, success, message, messageType, ItemSpinnerComponent, ItemIconComponent, ItemMessageComponent, ...props }) => {
|
|
10
|
-
const hasError = (Boolean(message) && messageType === "error") || Boolean(errorMessage);
|
|
11
|
-
const classname = classNames("af-item-file", hasError && "af-item-file--error", className);
|
|
12
|
-
return (_jsxs("section", { className: classname, ...props, children: [_jsxs("div", { className: "af-item-file__body", children: [_jsx(ItemStateIcon, { state: state, ItemIconComponent: ItemIconComponent, ItemSpinnerComponent: ItemSpinnerComponent }), _jsx("p", { className: "af-item-file__title", children: title }), _jsx("p", { className: "af-item-file__subtitle", children: subTitle }), _jsxs("div", { className: "af-item-file__actions", children: [state === "success" && visibilityIcon, deleteIcon] })] }), _jsx(ItemMessageComponent, { message: message || errorMessage || success, messageType: messageType || (errorMessage ? "error" : "success") })] }));
|
|
13
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import "@axa-fr/design-system-apollo-css/dist/Form/ItemFile/ItemFileLF.css";
|
|
2
|
-
import type { ItemFileProps } from "./types";
|
|
3
|
-
export { itemFileVariants } from "./ItemFileCommon";
|
|
4
|
-
export declare const ItemFile: ({ onDeleteClick, onVisibilityClick, ariaLabelVisibility, ariaLabelDelete, filename, ...props }: ItemFileProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import "@axa-fr/design-system-apollo-css/dist/Form/ItemFile/ItemFileLF.css";
|
|
3
|
-
import deleteIconFilled from "@material-symbols/svg-400/outlined/delete-fill.svg";
|
|
4
|
-
import visibilityIcon from "@material-symbols/svg-400/outlined/visibility-fill.svg";
|
|
5
|
-
import { ClickIcon } from "../../ClickIcon/ClickIconLF";
|
|
6
|
-
import { Icon } from "../../Icon/IconLF";
|
|
7
|
-
import { Spinner } from "../../Spinner/SpinnerLF";
|
|
8
|
-
import { ItemMessage } from "../ItemMessage/ItemMessageLF";
|
|
9
|
-
import { ItemFileCommon } from "./ItemFileCommon";
|
|
10
|
-
export { itemFileVariants } from "./ItemFileCommon";
|
|
11
|
-
export const ItemFile = ({ onDeleteClick, onVisibilityClick, ariaLabelVisibility, ariaLabelDelete, filename, ...props }) => (_jsx(ItemFileCommon, { ItemMessageComponent: ItemMessage, ItemIconComponent: Icon, ItemSpinnerComponent: Spinner, deleteIcon: _jsx(ClickIcon, { src: deleteIconFilled, onClick: onDeleteClick, "aria-label": ariaLabelDelete || `Suppression du fichier ${filename}` }), visibilityIcon: _jsx(ClickIcon, { src: visibilityIcon, onClick: onVisibilityClick, "aria-label": ariaLabelVisibility || `Observer le fichier ${filename}` }), ...props }));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, ComponentProps } from "react";
|
|
2
|
-
import type { IconProps } from "../../Icon/IconCommon";
|
|
3
|
-
import { Spinner } from "../../Spinner/SpinnerCommon";
|
|
4
|
-
import type { ItemFileState } from "./ItemFileCommon";
|
|
5
|
-
interface ItemStateIconProps {
|
|
6
|
-
state: ItemFileState;
|
|
7
|
-
ItemIconComponent: ComponentType<IconProps>;
|
|
8
|
-
ItemSpinnerComponent: ComponentType<ComponentProps<typeof Spinner>>;
|
|
9
|
-
}
|
|
10
|
-
declare const ItemStateIcon: ({ state, ItemIconComponent, ItemSpinnerComponent, }: ItemStateIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export { ItemStateIcon };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import validationIcon from "@material-symbols/svg-400/outlined/check_circle-fill.svg";
|
|
3
|
-
import errorIcon from "@material-symbols/svg-400/outlined/error-fill.svg";
|
|
4
|
-
import { getComponentClassName } from "../../utilities/getComponentClassName";
|
|
5
|
-
const ItemStateIcon = ({ state, ItemIconComponent, ItemSpinnerComponent, }) => {
|
|
6
|
-
const componentClassName = getComponentClassName("af-icon", `af-icon__${state}`);
|
|
7
|
-
return state === "loading" ? (_jsx(ItemSpinnerComponent, { size: 24, className: "af-item-file__spinner" })) : (_jsx(ItemIconComponent, { className: componentClassName, size: "S", src: state === "success" ? validationIcon : errorIcon }));
|
|
8
|
-
};
|
|
9
|
-
export { ItemStateIcon };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type MouseEvent } from "react";
|
|
2
|
-
import type { ItemFileCommonProps } from "./ItemFileCommon";
|
|
3
|
-
export type ItemFileProps = Omit<ItemFileCommonProps, "ItemMessageComponent" | "ItemIconComponent" | "ItemClickIconComponent" | "ItemSpinnerComponent" | "deleteIcon" | "visibilityIcon"> & {
|
|
4
|
-
onDeleteClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
5
|
-
onVisibilityClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
6
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|