@axa-fr/design-system-look-and-feel-react 1.0.5-ci.58 → 1.0.5-ci.59

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.
@@ -7,8 +7,8 @@ type Props = Omit<ComponentPropsWithRef<"input">, "required"> & {
7
7
  dropzoneDescription?: string;
8
8
  instructions?: string;
9
9
  required?: boolean;
10
- globalError: string;
11
- errors: Array<{
10
+ globalError?: string;
11
+ errors?: Array<{
12
12
  id?: string | undefined;
13
13
  message: string;
14
14
  }>;
@@ -18,15 +18,16 @@ type Props = Omit<ComponentPropsWithRef<"input">, "required"> & {
18
18
  size: number;
19
19
  isLoading: boolean;
20
20
  }>;
21
- accept: string;
21
+ accept?: string;
22
22
  isMobile?: boolean;
23
+ withPadding?: boolean;
23
24
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
24
25
  onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
25
26
  onView?: (id: string) => void;
26
27
  onDelete?: (id: string) => void;
27
28
  };
28
29
  declare const FileUpload: {
29
- ({ id, label, buttonLabel, instructions, dropzoneDescription, required, files, errors, globalError, isMobile, onView, onDelete, ...otherProps }: Props): import("react/jsx-runtime").JSX.Element;
30
+ ({ id, label, buttonLabel, instructions, dropzoneDescription, required, files, errors, globalError, isMobile, withPadding, onView, onDelete, ...otherProps }: Props): import("react/jsx-runtime").JSX.Element;
30
31
  displayName: string;
31
32
  };
32
33
  export { FileUpload };
@@ -23,7 +23,7 @@ function getReadableFileSizeString(fileSizeInBytes) {
23
23
  } while (fileSizeInBytesCopy > 1024);
24
24
  return Math.max(fileSizeInBytesCopy, 0.1).toFixed(1) + byteUnits[i];
25
25
  }
26
- const FileUpload = ({ id, label, buttonLabel, instructions, dropzoneDescription, required, files, errors, globalError, isMobile, onView, onDelete, ...otherProps }) => {
26
+ const FileUpload = ({ id, label, buttonLabel, instructions, dropzoneDescription, required, files, errors, globalError, isMobile, withPadding = false, onView, onDelete, ...otherProps }) => {
27
27
  const idError = useId();
28
28
  const getIcon = (isInError, isLoading) => {
29
29
  if (isInError) {
@@ -34,10 +34,12 @@ const FileUpload = ({ id, label, buttonLabel, instructions, dropzoneDescription,
34
34
  }
35
35
  return (_jsx(Svg, { src: check, className: "af-form__file-title-container-icon-success" }));
36
36
  };
37
- return (_jsxs("div", { children: [_jsxs("label", { className: "af-form__group--label", htmlFor: id, children: [label, " ", required ? "*" : ""] }), _jsxs("div", { className: classNames("af-form__file-input", globalError && "af-form__file-input--error", (isMobile || !dropzoneDescription) && "is-mobile"), children: [_jsx("input", { type: "file", name: "file-input", id: id, "aria-errormessage": idError, "aria-invalid": Boolean(globalError), ...otherProps }), dropzoneDescription && (_jsxs("div", { className: "af-form__file-input-dropdown-text", children: [_jsx("p", { children: dropzoneDescription }), _jsx("p", { children: "ou" })] })), _jsx(Button, { variant: Variants.tertiary, onClick: () => document.getElementById(id)?.click(), iconLeft: _jsx(Svg, { src: plus, className: "af-form__file-input-icon" }), children: buttonLabel })] }), globalError && _jsx(InputError, { id: idError, message: globalError }), _jsx("small", { className: "af-form__file-input-help", children: instructions }), _jsx("div", { className: "custom-table-file af-file-table", children: _jsx("ul", { className: "af-form__file-list", children: files.map(({ id: fileId, name, size, isLoading }) => {
37
+ return (_jsxs("div", { children: [_jsxs("label", { className: "af-form__group--label", htmlFor: id, children: [label, " ", required ? "*" : ""] }), _jsxs("div", { className: classNames("af-form__file-input", globalError && "af-form__file-input--error", (isMobile || (!withPadding && !dropzoneDescription)) && "is-mobile"), children: [_jsx("input", { type: "file", name: "file-input", id: id, "aria-errormessage": idError, "aria-invalid": Boolean(globalError), ...otherProps }), dropzoneDescription && (_jsxs("div", { className: "af-form__file-input-dropdown-text", children: [_jsx("p", { children: dropzoneDescription }), _jsx("p", { children: "ou" })] })), _jsx(Button, { variant: Variants.tertiary, onClick: () => document.getElementById(id)?.click(), iconLeft: _jsx(Svg, { src: plus, className: "af-form__file-input-icon" }), children: buttonLabel })] }), globalError && _jsx(InputError, { id: idError, message: globalError }), _jsx("small", { className: "af-form__file-input-help", children: instructions }), _jsx("div", { className: "custom-table-file af-file-table", children: _jsx("ul", { className: "af-form__file-list", children: files.map(({ id: fileId, name, size, isLoading }) => {
38
38
  const effectiveSize = getReadableFileSizeString(size);
39
- const isInError = errors.some((fileError) => fileError.id === fileId);
40
- const errorMessage = errors.find((fileError) => fileError.id === fileId)?.message;
39
+ const isInError = errors
40
+ ? errors.some((fileError) => fileError.id === fileId)
41
+ : false;
42
+ const errorMessage = errors?.find((fileError) => fileError.id === fileId)?.message;
41
43
  return (_jsxs("li", { className: "af-form__file-line", children: [_jsxs("div", { className: `af-form__file-line-container ${isInError ? "af-form__file-line-container--error" : ""}`, children: [_jsxs("div", { className: "af-form__file-title", children: [getIcon(isInError, isLoading), _jsxs("div", { children: [_jsx("span", { className: "af-form__file-name", children: name }), _jsx("span", { className: "af-form__file-size", children: effectiveSize })] })] }), _jsxs("div", { className: "af-form__file-actions", children: [onView && (_jsx(Svg, { tabIndex: 0, role: "button", "aria-label": "Visualiser", onClick: () => onView(fileId), onKeyDown: (e) => {
42
44
  if (e.key === "Enter") {
43
45
  onView(fileId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-look-and-feel-react",
3
- "version": "1.0.5-ci.58",
3
+ "version": "1.0.5-ci.59",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "homepage": "https://github.com/AxaFrance/design-system#readme",
49
49
  "peerDependencies": {
50
- "@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.58",
50
+ "@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.59",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },