@axa-fr/design-system-look-and-feel-react 0.2.0-beta.306
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/Accordion/Accordion.d.ts +8 -0
- package/dist/Accordion/Accordion.js +7 -0
- package/dist/Accordion/Accordion.stories.d.ts +8 -0
- package/dist/Accordion/Accordion.stories.js +24 -0
- package/dist/Accordion/AccordionItem.d.ts +6 -0
- package/dist/Accordion/AccordionItem.js +10 -0
- package/dist/Alert/Alert.d.ts +12 -0
- package/dist/Alert/Alert.js +26 -0
- package/dist/Alert/Alert.stories.d.ts +5 -0
- package/dist/Alert/Alert.stories.js +26 -0
- package/dist/Button/Button.d.ts +17 -0
- package/dist/Button/Button.js +15 -0
- package/dist/Button/Button.stories.d.ts +22 -0
- package/dist/Button/Button.stories.js +99 -0
- package/dist/Card/Card.d.ts +6 -0
- package/dist/Card/Card.js +9 -0
- package/dist/Card/Card.stories.d.ts +6 -0
- package/dist/Card/Card.stories.js +40 -0
- package/dist/Card/__tests__/Card.test.d.ts +1 -0
- package/dist/Card/__tests__/Card.test.js +27 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/Card/index.js +2 -0
- package/dist/Form/Checkbox/Checkbox.d.ts +7 -0
- package/dist/Form/Checkbox/Checkbox.js +15 -0
- package/dist/Form/Checkbox/Checkbox.stories.d.ts +6 -0
- package/dist/Form/Checkbox/Checkbox.stories.js +38 -0
- package/dist/Form/Checkbox/CheckboxSelect.d.ts +15 -0
- package/dist/Form/Checkbox/CheckboxSelect.js +7 -0
- package/dist/Form/Checkbox/CheckboxSelect.stories.d.ts +6 -0
- package/dist/Form/Checkbox/CheckboxSelect.stories.js +55 -0
- package/dist/Form/Checkbox/index.d.ts +2 -0
- package/dist/Form/Checkbox/index.js +2 -0
- package/dist/Form/FileUpload/FIleUpload.stories.d.ts +6 -0
- package/dist/Form/FileUpload/FIleUpload.stories.js +54 -0
- package/dist/Form/FileUpload/FileUpload.d.ts +32 -0
- package/dist/Form/FileUpload/FileUpload.js +51 -0
- package/dist/Form/FileUpload/index.d.ts +1 -0
- package/dist/Form/FileUpload/index.js +1 -0
- package/dist/Form/InputError/InputError.d.ts +7 -0
- package/dist/Form/InputError/InputError.js +5 -0
- package/dist/Form/InputError/InputError.stories.d.ts +5 -0
- package/dist/Form/InputError/InputError.stories.js +12 -0
- package/dist/Form/InputError/index.d.ts +1 -0
- package/dist/Form/InputError/index.js +1 -0
- package/dist/Form/Radio/Radio.d.ts +7 -0
- package/dist/Form/Radio/Radio.js +14 -0
- package/dist/Form/Radio/Radio.stories.d.ts +6 -0
- package/dist/Form/Radio/Radio.stories.js +38 -0
- package/dist/Form/Radio/RadioSelect.d.ts +18 -0
- package/dist/Form/Radio/RadioSelect.js +16 -0
- package/dist/Form/Radio/RadioSelect.stories.d.ts +7 -0
- package/dist/Form/Radio/RadioSelect.stories.js +90 -0
- package/dist/Form/Radio/index.d.ts +2 -0
- package/dist/Form/Radio/index.js +2 -0
- package/dist/Form/Select/CustomOption.d.ts +4 -0
- package/dist/Form/Select/CustomOption.js +8 -0
- package/dist/Form/Select/DropdownIndicator.d.ts +4 -0
- package/dist/Form/Select/DropdownIndicator.js +11 -0
- package/dist/Form/Select/Select.d.ts +27 -0
- package/dist/Form/Select/Select.js +27 -0
- package/dist/Form/Select/Select.stories.d.ts +10 -0
- package/dist/Form/Select/Select.stories.js +31 -0
- package/dist/Form/Select/index.d.ts +1 -0
- package/dist/Form/Select/index.js +1 -0
- package/dist/Form/Text/Text.d.ts +12 -0
- package/dist/Form/Text/Text.js +12 -0
- package/dist/Form/Text/Text.stories.d.ts +8 -0
- package/dist/Form/Text/Text.stories.js +46 -0
- package/dist/Form/Text/index.d.ts +1 -0
- package/dist/Form/Text/index.js +1 -0
- package/dist/Form/core/Field.d.ts +16 -0
- package/dist/Form/core/Field.js +12 -0
- package/dist/Form/core/FieldError.d.ts +7 -0
- package/dist/Form/core/FieldError.js +8 -0
- package/dist/Form/core/FieldForm.d.ts +59 -0
- package/dist/Form/core/FieldForm.js +151 -0
- package/dist/Form/core/FieldInput.d.ts +9 -0
- package/dist/Form/core/FieldInput.js +9 -0
- package/dist/Form/core/FormClassManager.d.ts +7 -0
- package/dist/Form/core/FormClassManager.js +33 -0
- package/dist/Form/core/HelpMessage.d.ts +7 -0
- package/dist/Form/core/HelpMessage.js +2 -0
- package/dist/Form/core/InputList.d.ts +8 -0
- package/dist/Form/core/InputList.js +4 -0
- package/dist/Form/core/MessageTypes.d.ts +5 -0
- package/dist/Form/core/MessageTypes.js +6 -0
- package/dist/Form/core/getComponentClassName.d.ts +1 -0
- package/dist/Form/core/getComponentClassName.js +27 -0
- package/dist/Form/core/getFirstId.d.ts +2 -0
- package/dist/Form/core/getFirstId.js +1 -0
- package/dist/Form/core/getOptionClassName.d.ts +1 -0
- package/dist/Form/core/getOptionClassName.js +10 -0
- package/dist/Form/core/index.d.ts +31 -0
- package/dist/Form/core/index.js +13 -0
- package/dist/Form/core/useInputClassModifier.d.ts +4 -0
- package/dist/Form/core/useInputClassModifier.js +12 -0
- package/dist/Form/core/useOptionsWithId.d.ts +2 -0
- package/dist/Form/core/useOptionsWithId.js +13 -0
- package/dist/IconBg/IconBg.d.ts +9 -0
- package/dist/IconBg/IconBg.js +13 -0
- package/dist/IconBg/IconBg.stories.d.ts +5 -0
- package/dist/IconBg/IconBg.stories.js +23 -0
- package/dist/IconBg/__tests__/IconBg.test.d.ts +1 -0
- package/dist/IconBg/__tests__/IconBg.test.js +22 -0
- package/dist/IconBg/index.d.ts +2 -0
- package/dist/IconBg/index.js +2 -0
- package/dist/Layout/Footer/DynamicIcons.d.ts +4 -0
- package/dist/Layout/Footer/DynamicIcons.js +20 -0
- package/dist/Layout/Footer/Footer.d.ts +14 -0
- package/dist/Layout/Footer/Footer.js +16 -0
- package/dist/Layout/Footer/Footer.stories.d.ts +14 -0
- package/dist/Layout/Footer/Footer.stories.js +48 -0
- package/dist/Layout/Footer/MenuIcons.d.ts +9 -0
- package/dist/Layout/Footer/MenuIcons.js +8 -0
- package/dist/Layout/Footer/MenuLink.d.ts +11 -0
- package/dist/Layout/Footer/MenuLink.js +11 -0
- package/dist/Layout/Header/Header.d.ts +9 -0
- package/dist/Layout/Header/Header.js +11 -0
- package/dist/Layout/Header/Header.stories.d.ts +10 -0
- package/dist/Layout/Header/Header.stories.js +52 -0
- package/dist/Layout/Header/NavBar/NavBar.d.ts +8 -0
- package/dist/Layout/Header/NavBar/NavBar.js +13 -0
- package/dist/Layout/Header/NavBar/NavBar.stories.d.ts +8 -0
- package/dist/Layout/Header/NavBar/NavBar.stories.js +17 -0
- package/dist/Layout/Header/NavBar/index.d.ts +1 -0
- package/dist/Layout/Header/NavBar/index.js +1 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.d.ts +7 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.js +14 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.stories.d.ts +8 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.stories.js +16 -0
- package/dist/Layout/Header/PreviousLink/index.d.ts +1 -0
- package/dist/Layout/Header/PreviousLink/index.js +1 -0
- package/dist/Layout/Header/index.d.ts +1 -0
- package/dist/Layout/Header/index.js +1 -0
- package/dist/Link/Link.d.ts +7 -0
- package/dist/Link/Link.js +11 -0
- package/dist/Link/Link.stories.d.ts +5 -0
- package/dist/Link/Link.stories.js +14 -0
- package/dist/List/ClickList/ClickList.d.ts +11 -0
- package/dist/List/ClickList/ClickList.js +6 -0
- package/dist/List/ClickList/ClickList.stories.d.ts +6 -0
- package/dist/List/ClickList/ClickList.stories.js +60 -0
- package/dist/List/ClickList/__tests__/ClickList.client.test.d.ts +1 -0
- package/dist/List/ClickList/__tests__/ClickList.client.test.js +18 -0
- package/dist/List/ClickList/index.d.ts +1 -0
- package/dist/List/ClickList/index.js +1 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.d.ts +13 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.js +18 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.stories.d.ts +28 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.stories.js +86 -0
- package/dist/List/ContentItemDuo/__tests__/ContentItemDuo.test.d.ts +1 -0
- package/dist/List/ContentItemDuo/__tests__/ContentItemDuo.test.js +40 -0
- package/dist/List/ContentItemDuo/index.d.ts +2 -0
- package/dist/List/ContentItemDuo/index.js +2 -0
- package/dist/List/ContentItemMono/ContentItemMono.d.ts +16 -0
- package/dist/List/ContentItemMono/ContentItemMono.js +16 -0
- package/dist/List/ContentItemMono/ContentItemMono.stories.d.ts +16 -0
- package/dist/List/ContentItemMono/ContentItemMono.stories.js +99 -0
- package/dist/List/ContentItemMono/__tests__/ContentItemMono.test.d.ts +1 -0
- package/dist/List/ContentItemMono/__tests__/ContentItemMono.test.js +45 -0
- package/dist/List/ContentItemMono/constants.d.ts +4 -0
- package/dist/List/ContentItemMono/constants.js +5 -0
- package/dist/List/ContentItemMono/index.d.ts +3 -0
- package/dist/List/ContentItemMono/index.js +3 -0
- package/dist/List/ContentTabList/ContentTabItem/ContentTabItem.d.ts +6 -0
- package/dist/List/ContentTabList/ContentTabItem/ContentTabItem.js +6 -0
- package/dist/List/ContentTabList/ContentTabItem/__tests__/ContentTabItem.test.d.ts +1 -0
- package/dist/List/ContentTabList/ContentTabItem/__tests__/ContentTabItem.test.js +100 -0
- package/dist/List/ContentTabList/ContentTabItem/index.d.ts +2 -0
- package/dist/List/ContentTabList/ContentTabItem/index.js +1 -0
- package/dist/List/ContentTabList/ContentTabList.d.ts +8 -0
- package/dist/List/ContentTabList/ContentTabList.js +10 -0
- package/dist/List/ContentTabList/ContentTabList.stories.d.ts +7 -0
- package/dist/List/ContentTabList/ContentTabList.stories.js +78 -0
- package/dist/List/ContentTabList/__tests__/ContentTabList.test.d.ts +1 -0
- package/dist/List/ContentTabList/__tests__/ContentTabList.test.js +57 -0
- package/dist/List/ContentTabList/index.d.ts +1 -0
- package/dist/List/ContentTabList/index.js +1 -0
- package/dist/List/List.d.ts +6 -0
- package/dist/List/List.js +9 -0
- package/dist/List/List.stories.d.ts +8 -0
- package/dist/List/List.stories.js +56 -0
- package/dist/List/__tests__/List.test.d.ts +1 -0
- package/dist/List/__tests__/List.test.js +30 -0
- package/dist/List/index.d.ts +1 -0
- package/dist/List/index.js +1 -0
- package/dist/Loader/Loader.d.ts +11 -0
- package/dist/Loader/Loader.js +10 -0
- package/dist/Loader/Loader.stories.d.ts +6 -0
- package/dist/Loader/Loader.stories.js +15 -0
- package/dist/Loader/index.d.ts +1 -0
- package/dist/Loader/index.js +1 -0
- package/dist/ModalClient/Modal.d.ts +23 -0
- package/dist/ModalClient/Modal.js +44 -0
- package/dist/ModalClient/Modal.stories.d.ts +20 -0
- package/dist/ModalClient/Modal.stories.js +37 -0
- package/dist/Pagination/Pagination.d.ts +9 -0
- package/dist/Pagination/Pagination.js +15 -0
- package/dist/Pagination/Pagination.stories.d.ts +11 -0
- package/dist/Pagination/Pagination.stories.js +19 -0
- package/dist/Pagination/PaginationDesktop.d.ts +9 -0
- package/dist/Pagination/PaginationDesktop.js +31 -0
- package/dist/Pagination/PaginationMobile.d.ts +9 -0
- package/dist/Pagination/PaginationMobile.js +10 -0
- package/dist/Stepper/Stepper.d.ts +12 -0
- package/dist/Stepper/Stepper.js +22 -0
- package/dist/Stepper/Stepper.stories.d.ts +16 -0
- package/dist/Stepper/Stepper.stories.js +23 -0
- package/dist/Svg/Svg.d.ts +7 -0
- package/dist/Svg/Svg.js +47 -0
- package/dist/Svg/Svg.stories.d.ts +7 -0
- package/dist/Svg/Svg.stories.js +40 -0
- package/dist/Svg/__tests__/Svg.test.d.ts +1 -0
- package/dist/Svg/__tests__/Svg.test.js +38 -0
- package/dist/Svg/index.d.ts +1 -0
- package/dist/Svg/index.js +1 -0
- package/dist/Svg/svgInjector.d.ts +12 -0
- package/dist/Svg/svgInjector.js +28 -0
- package/dist/Tabs/Tabs.d.ts +16 -0
- package/dist/Tabs/Tabs.js +48 -0
- package/dist/Tabs/Tabs.stories.d.ts +17 -0
- package/dist/Tabs/Tabs.stories.js +89 -0
- package/dist/Tag/Tag.d.ts +6 -0
- package/dist/Tag/Tag.js +7 -0
- package/dist/Tag/Tag.stories.d.ts +5 -0
- package/dist/Tag/Tag.stories.js +22 -0
- package/dist/Tag/__test__/Tag.test.d.ts +1 -0
- package/dist/Tag/__test__/Tag.test.js +18 -0
- package/dist/Tag/index.d.ts +2 -0
- package/dist/Tag/index.js +2 -0
- package/dist/Title/Title.d.ts +13 -0
- package/dist/Title/Title.js +11 -0
- package/dist/Title/Title.stories.d.ts +6 -0
- package/dist/Title/Title.stories.js +45 -0
- package/dist/Title/TitleWithSubtitles.d.ts +8 -0
- package/dist/Title/TitleWithSubtitles.js +2 -0
- package/dist/Title/__tests__/Title.test.d.ts +1 -0
- package/dist/Title/__tests__/Title.test.js +28 -0
- package/dist/Title/__tests__/TitleWithSubtitles.test.d.ts +1 -0
- package/dist/Title/__tests__/TitleWithSubtitles.test.js +14 -0
- package/dist/Title/constants.d.ts +4 -0
- package/dist/Title/constants.js +5 -0
- package/dist/Title/index.d.ts +3 -0
- package/dist/Title/index.js +3 -0
- package/dist/assets/svg/facebook.svg +1 -0
- package/dist/assets/svg/linkedin.svg +1 -0
- package/dist/assets/svg/twitterx.svg +1 -0
- package/dist/assets/svg/youtube.svg +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +27 -0
- package/dist/utilities/helpers/getComponentClassName.d.ts +1 -0
- package/dist/utilities/helpers/getComponentClassName.js +27 -0
- package/dist/utilities/hooks/useIsSmallScreen.d.ts +1 -0
- package/dist/utilities/hooks/useIsSmallScreen.js +14 -0
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +2 -0
- package/package.json +119 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { FileUpload } from "./FileUpload";
|
3
|
+
const meta = {
|
4
|
+
title: "Components/Form/Input/FileUpload",
|
5
|
+
};
|
6
|
+
export default meta;
|
7
|
+
export const FileUploadStory = {
|
8
|
+
name: "FileUpload",
|
9
|
+
render: ({ onChange, onView, onDelete, ...args }) => (_jsx(FileUpload, { onChange: onChange, onView: onView, onDelete: onDelete, ...args })),
|
10
|
+
args: {
|
11
|
+
id: "file-input",
|
12
|
+
className: "",
|
13
|
+
label: "Label",
|
14
|
+
files: [
|
15
|
+
{
|
16
|
+
id: "1",
|
17
|
+
name: " IMG_8904587880.jpg",
|
18
|
+
size: 109936,
|
19
|
+
isLoading: false,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
id: "2",
|
23
|
+
name: " IMG_465510680.jpg",
|
24
|
+
size: 5010,
|
25
|
+
isLoading: true,
|
26
|
+
},
|
27
|
+
{
|
28
|
+
id: "3",
|
29
|
+
name: " IMG_8904587880.jpg",
|
30
|
+
size: 23000000,
|
31
|
+
isLoading: true,
|
32
|
+
},
|
33
|
+
],
|
34
|
+
globalError: "Erreur",
|
35
|
+
errors: [
|
36
|
+
{
|
37
|
+
id: "3",
|
38
|
+
message: "Votre fichier fait plus de 19 Mo.",
|
39
|
+
},
|
40
|
+
],
|
41
|
+
accept: "image/jpeg, image/png, application/*",
|
42
|
+
buttonLabel: "Importer fichier",
|
43
|
+
instructions: "2 fichiers max. / pdf, png, jpg, jpeg, gif / 19 Mo par fichier",
|
44
|
+
dropzoneDescription: "Glissez/déposez vos fichiers",
|
45
|
+
required: false,
|
46
|
+
isMobile: false,
|
47
|
+
multiple: false,
|
48
|
+
},
|
49
|
+
argTypes: {
|
50
|
+
onChange: { action: "onChange" },
|
51
|
+
onView: { action: "onView" },
|
52
|
+
onDelete: { action: "onDelete" },
|
53
|
+
},
|
54
|
+
};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/FileUpload/FileUpload.scss";
|
3
|
+
type Props = Omit<ComponentPropsWithRef<"input">, "required"> & {
|
4
|
+
id: string;
|
5
|
+
label?: string;
|
6
|
+
buttonLabel?: string;
|
7
|
+
dropzoneDescription?: string;
|
8
|
+
instructions?: string;
|
9
|
+
required?: boolean;
|
10
|
+
globalError: string;
|
11
|
+
errors: Array<{
|
12
|
+
id?: string | undefined;
|
13
|
+
message: string;
|
14
|
+
}>;
|
15
|
+
files: Array<{
|
16
|
+
id: string;
|
17
|
+
name: string;
|
18
|
+
size: number;
|
19
|
+
isLoading: boolean;
|
20
|
+
}>;
|
21
|
+
accept: string;
|
22
|
+
isMobile?: boolean;
|
23
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
24
|
+
onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
|
25
|
+
onView?: (id: string) => void;
|
26
|
+
onDelete?: (id: string) => void;
|
27
|
+
};
|
28
|
+
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
|
+
displayName: string;
|
31
|
+
};
|
32
|
+
export { FileUpload };
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/FileUpload/FileUpload.scss";
|
3
|
+
import visibility from "@material-symbols/svg-400/outlined/visibility-fill.svg";
|
4
|
+
import close from "@material-symbols/svg-400/outlined/close-fill.svg";
|
5
|
+
import check from "@material-symbols/svg-400/outlined/check_circle-fill.svg";
|
6
|
+
import error from "@material-symbols/svg-400/outlined/error-fill.svg";
|
7
|
+
import errorO from "@material-symbols/svg-400/outlined/error.svg";
|
8
|
+
import plus from "@material-symbols/svg-400/outlined/add_circle-fill.svg";
|
9
|
+
import classNames from "classnames";
|
10
|
+
import { Svg } from "../../Svg";
|
11
|
+
import { Loader } from "../../Loader";
|
12
|
+
import { Button } from "../..";
|
13
|
+
import { Variants } from "../../Button/Button";
|
14
|
+
import { InputError } from "../InputError";
|
15
|
+
function getReadableFileSizeString(fileSizeInBytes) {
|
16
|
+
let i = -1;
|
17
|
+
let fileSizeInBytesCopy = fileSizeInBytes;
|
18
|
+
const byteUnits = [" Ko", " Mo", " Go"];
|
19
|
+
do {
|
20
|
+
fileSizeInBytesCopy /= 1024;
|
21
|
+
i += 1;
|
22
|
+
} while (fileSizeInBytesCopy > 1024);
|
23
|
+
return Math.max(fileSizeInBytesCopy, 0.1).toFixed(1) + byteUnits[i];
|
24
|
+
}
|
25
|
+
const FileUpload = ({ id, label, buttonLabel, instructions, dropzoneDescription, required, files, errors, globalError, isMobile, onView, onDelete, ...otherProps }) => {
|
26
|
+
const getIcon = (isInError, isLoading) => {
|
27
|
+
if (isInError) {
|
28
|
+
return (_jsx(Svg, { src: error, className: "af-form__file-title-container-icon-error" }));
|
29
|
+
}
|
30
|
+
if (isLoading) {
|
31
|
+
return _jsx(Loader, { size: 18, border: 2 });
|
32
|
+
}
|
33
|
+
return (_jsx(Svg, { src: check, className: "af-form__file-title-container-icon-success" }));
|
34
|
+
};
|
35
|
+
return (_jsxs(_Fragment, { 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, ...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, { 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 }) => {
|
36
|
+
const effectiveSize = getReadableFileSizeString(size);
|
37
|
+
const isInError = errors.some((fileError) => fileError.id === fileId);
|
38
|
+
const errorMessage = errors.find((fileError) => fileError.id === fileId)?.message;
|
39
|
+
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) => {
|
40
|
+
if (e.key === "Enter") {
|
41
|
+
onView(fileId);
|
42
|
+
}
|
43
|
+
}, className: "af-form__file-actions-icon", src: visibility })), onDelete && (_jsx(Svg, { tabIndex: 0, role: "button", "aria-label": "Supprimer", onClick: () => onDelete(fileId), onKeyDown: (e) => {
|
44
|
+
if (e.key === "Enter") {
|
45
|
+
onDelete(fileId);
|
46
|
+
}
|
47
|
+
}, className: "af-form__file-actions-icon", src: close }))] })] }), isInError && (_jsxs("small", { className: "af-form__file-error", children: [_jsx(Svg, { src: errorO, className: "af-form__file-error-icon", width: 18 }), errorMessage] }))] }, fileId));
|
48
|
+
}) }) })] }));
|
49
|
+
};
|
50
|
+
FileUpload.displayName = "FileUpload";
|
51
|
+
export { FileUpload };
|
@@ -0,0 +1 @@
|
|
1
|
+
export { FileUpload } from "./FileUpload";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { FileUpload } from "./FileUpload";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/InputError/InputError.scss";
|
2
|
+
type InputErrorProps = {
|
3
|
+
message: string;
|
4
|
+
id?: string;
|
5
|
+
};
|
6
|
+
export declare const InputError: ({ message, id }: InputErrorProps) => import("react/jsx-runtime").JSX.Element;
|
7
|
+
export {};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import errorIcon from "@material-symbols/svg-400/outlined/error.svg";
|
3
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/InputError/InputError.scss";
|
4
|
+
import { Svg } from "../../Svg";
|
5
|
+
export const InputError = ({ message, id }) => (_jsxs("div", { className: "af-input-error", children: [_jsx(Svg, { src: errorIcon, className: "af-input-error__icon" }), _jsx("span", { id: id, "aria-live": "assertive", className: "af-input-error__message", children: message })] }));
|
@@ -0,0 +1 @@
|
|
1
|
+
export { InputError } from "./InputError";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { InputError } from "./InputError";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
|
2
|
+
import React, { ReactNode } from "react";
|
3
|
+
declare const Radio: React.ForwardRefExoticComponent<{
|
4
|
+
label: string | ReactNode;
|
5
|
+
errorMessage?: string;
|
6
|
+
} & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
|
7
|
+
export { Radio };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
|
3
|
+
import radioIcon from "@material-symbols/svg-400/outlined/radio_button_checked.svg";
|
4
|
+
import radioOutlineBlankIcon from "@material-symbols/svg-400/outlined/radio_button_unchecked.svg";
|
5
|
+
import errorOutline from "@material-symbols/svg-400/outlined/error.svg";
|
6
|
+
import { forwardRef, useId } from "react";
|
7
|
+
import { Svg } from "../../Svg";
|
8
|
+
const Radio = forwardRef(({ label, errorMessage, ...inputProps }, ref) => {
|
9
|
+
let inputId = useId();
|
10
|
+
inputId = inputProps.id || inputId;
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "af-radio", role: "radiogroup", "aria-invalid": Boolean(errorMessage), children: _jsxs("label", { htmlFor: inputId, children: [_jsx("input", { ref: ref, ...inputProps, type: "radio", id: inputId }), _jsxs("div", { className: "af-radio__icons", children: [_jsx(Svg, { src: radioOutlineBlankIcon, className: "af-radio__unchecked" }), _jsx(Svg, { src: radioIcon, className: "af-radio__checked" })] }), label] }, inputProps.name) }), errorMessage && (_jsxs("div", { className: "af-radio__error", "aria-live": "assertive", children: [_jsx(Svg, { src: errorOutline }), errorMessage] }))] }));
|
12
|
+
});
|
13
|
+
Radio.displayName = "Radio";
|
14
|
+
export { Radio };
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Radio } from "./Radio";
|
3
|
+
const meta = {
|
4
|
+
title: "Components/Form/Input/Radio",
|
5
|
+
component: Radio,
|
6
|
+
argTypes: {},
|
7
|
+
};
|
8
|
+
export default meta;
|
9
|
+
export const RadioStory = {
|
10
|
+
name: "Basic",
|
11
|
+
render: ({ ...args }) => _jsx(Radio, { ...args }),
|
12
|
+
args: {
|
13
|
+
label: "J'accepte de fournir à AXA mes coordonnées ainsi que les données relatives à mon projet et ma situation. Ces dernières seront transmises à mon conseiller AXA qui pourra me contacter pour m'accompagner.",
|
14
|
+
name: "option1",
|
15
|
+
value: "option1",
|
16
|
+
},
|
17
|
+
argTypes: {
|
18
|
+
label: {
|
19
|
+
control: { type: "text" },
|
20
|
+
},
|
21
|
+
name: {
|
22
|
+
control: { type: "text" },
|
23
|
+
},
|
24
|
+
value: {
|
25
|
+
control: { type: "text" },
|
26
|
+
},
|
27
|
+
errorMessage: {
|
28
|
+
control: { type: "text" },
|
29
|
+
},
|
30
|
+
disabled: {
|
31
|
+
control: { type: "boolean" },
|
32
|
+
},
|
33
|
+
checked: {
|
34
|
+
control: { type: "boolean" },
|
35
|
+
},
|
36
|
+
onChange: { action: "onChange" },
|
37
|
+
},
|
38
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
|
2
|
+
import React, { ComponentPropsWithRef, ReactNode } from "react";
|
3
|
+
type RadioSelectProps = {
|
4
|
+
type: "vertical" | "horizontal";
|
5
|
+
options: ({
|
6
|
+
label: ReactNode;
|
7
|
+
subtitle?: ReactNode;
|
8
|
+
description?: ReactNode;
|
9
|
+
icon?: ReactNode;
|
10
|
+
} & React.InputHTMLAttributes<HTMLInputElement>)[];
|
11
|
+
name: string;
|
12
|
+
errorMessage?: string;
|
13
|
+
onChange?: React.ChangeEventHandler;
|
14
|
+
value?: string;
|
15
|
+
isDisabled?: boolean;
|
16
|
+
} & Omit<ComponentPropsWithRef<"div">, "className" | "aria-invalid">;
|
17
|
+
export declare const RadioSelect: React.ForwardRefExoticComponent<Omit<RadioSelectProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
18
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
|
3
|
+
import radioIcon from "@material-symbols/svg-400/outlined/radio_button_checked.svg";
|
4
|
+
import radioOutlineBlankIcon from "@material-symbols/svg-400/outlined/radio_button_unchecked.svg";
|
5
|
+
import errorOutline from "@material-symbols/svg-400/outlined/error.svg";
|
6
|
+
import { forwardRef, useId, } from "react";
|
7
|
+
import { Svg } from "../../Svg";
|
8
|
+
export const RadioSelect = forwardRef(({ id, options, errorMessage, onChange, type = "vertical", name, value, isDisabled, ...rest }, ref) => {
|
9
|
+
const generatedId = useId();
|
10
|
+
const optionId = id || generatedId;
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { ref: ref, ...rest, role: "radiogroup", className: `af-radio af-radio-select af-radio-select--${type}`, "aria-invalid": Boolean(errorMessage), children: options.map(({ label, description, subtitle, icon, disabled: inputDisabled, ...inputProps }) => (_jsxs("label", { htmlFor: `${optionId}-${label}`, children: [_jsx("input", { type: "radio", ...(isDisabled || inputDisabled ? { disabled: true } : null), ...inputProps, name: name, id: `${optionId}-${label}`, onChange: onChange, ...(value && {
|
12
|
+
"aria-checked": value === inputProps.value,
|
13
|
+
checked: value === inputProps.value,
|
14
|
+
}) }), _jsxs("div", { className: "af-radio__icons", children: [_jsx(Svg, { src: radioOutlineBlankIcon, className: "af-radio__unchecked" }), _jsx(Svg, { src: radioIcon, className: "af-radio__checked" })] }), _jsxs("div", { className: "af-radio__content", children: [icon, _jsxs("div", { className: "af-radio__content-description", children: [_jsx("span", { children: label }), description && _jsx("span", { children: description }), subtitle && _jsx("span", { children: subtitle })] })] })] }, label))) }), errorMessage && (_jsxs("div", { className: "af-radio__error", "aria-live": "assertive", children: [_jsx(Svg, { src: errorOutline }), errorMessage] }))] }));
|
15
|
+
});
|
16
|
+
RadioSelect.displayName = "RadioSelect";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import { ComponentProps } from "react";
|
3
|
+
import { RadioSelect } from "./RadioSelect";
|
4
|
+
declare const meta: Meta;
|
5
|
+
export default meta;
|
6
|
+
export declare const RadioSelectStory: StoryObj<ComponentProps<typeof RadioSelect>>;
|
7
|
+
export declare const RadioSelectDisabledStory: StoryObj<ComponentProps<typeof RadioSelect>>;
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import home from "@material-symbols/svg-400/outlined/home.svg";
|
3
|
+
import { Svg } from "../../Svg";
|
4
|
+
import { RadioSelect } from "./RadioSelect";
|
5
|
+
const meta = {
|
6
|
+
title: "Components/Form/Input/Radio/Select",
|
7
|
+
component: RadioSelect,
|
8
|
+
argTypes: {},
|
9
|
+
};
|
10
|
+
export default meta;
|
11
|
+
export const RadioSelectStory = {
|
12
|
+
name: "Select",
|
13
|
+
render: ({ ...args }) => _jsx(RadioSelect, { ...args }),
|
14
|
+
args: {
|
15
|
+
type: "vertical",
|
16
|
+
"aria-label": "Quelle ville ?",
|
17
|
+
name: "cities",
|
18
|
+
options: [
|
19
|
+
{
|
20
|
+
label: "Paris",
|
21
|
+
description: "Capitale de la France",
|
22
|
+
subtitle: "Nord",
|
23
|
+
value: "paris",
|
24
|
+
icon: _jsx(Svg, { src: home }),
|
25
|
+
},
|
26
|
+
{
|
27
|
+
label: "Bruxelles",
|
28
|
+
description: "Capitale de la Belgique",
|
29
|
+
value: "bruxelles",
|
30
|
+
icon: _jsx(Svg, { src: home }),
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: "Lille",
|
34
|
+
value: "lille",
|
35
|
+
icon: _jsx(Svg, { src: home }),
|
36
|
+
},
|
37
|
+
],
|
38
|
+
},
|
39
|
+
argTypes: {
|
40
|
+
type: {
|
41
|
+
control: { type: "inline-radio" },
|
42
|
+
options: ["vertical", "horizontal"],
|
43
|
+
},
|
44
|
+
errorMessage: {
|
45
|
+
control: { type: "text" },
|
46
|
+
},
|
47
|
+
onChange: { action: "onChange" },
|
48
|
+
},
|
49
|
+
};
|
50
|
+
export const RadioSelectDisabledStory = {
|
51
|
+
name: "SelectDisabled",
|
52
|
+
render: ({ ...args }) => _jsx(RadioSelect, { ...args }),
|
53
|
+
args: {
|
54
|
+
type: "vertical",
|
55
|
+
"aria-label": "Quelle ville ?",
|
56
|
+
name: "cities",
|
57
|
+
options: [
|
58
|
+
{
|
59
|
+
label: "Paris",
|
60
|
+
description: "Capitale de la France",
|
61
|
+
subtitle: "Nord",
|
62
|
+
value: "paris",
|
63
|
+
icon: _jsx(Svg, { src: home }),
|
64
|
+
},
|
65
|
+
{
|
66
|
+
label: "Bruxelles",
|
67
|
+
description: "Capitale de la Belgique",
|
68
|
+
value: "bruxelles",
|
69
|
+
icon: _jsx(Svg, { src: home }),
|
70
|
+
},
|
71
|
+
{
|
72
|
+
label: "Lille",
|
73
|
+
value: "lille",
|
74
|
+
icon: _jsx(Svg, { src: home }),
|
75
|
+
checked: true,
|
76
|
+
},
|
77
|
+
],
|
78
|
+
isDisabled: true,
|
79
|
+
},
|
80
|
+
argTypes: {
|
81
|
+
type: {
|
82
|
+
control: { type: "inline-radio" },
|
83
|
+
options: ["vertical", "horizontal"],
|
84
|
+
},
|
85
|
+
errorMessage: {
|
86
|
+
control: { type: "text" },
|
87
|
+
},
|
88
|
+
onChange: { action: "onChange" },
|
89
|
+
},
|
90
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useMemo } from "react";
|
3
|
+
import { components } from "react-select";
|
4
|
+
const CustomOption = ({ getValue, ...otherProps }) => {
|
5
|
+
const value = useMemo(() => getValue(), [getValue]);
|
6
|
+
return (_jsx(components.Option, { ...otherProps, getValue: getValue, "data-value": value }));
|
7
|
+
};
|
8
|
+
export { CustomOption };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import arrowDropDown from "@material-symbols/svg-400/outlined/arrow_drop_down.svg";
|
3
|
+
import arrowDropUp from "@material-symbols/svg-400/outlined/arrow_drop_up.svg";
|
4
|
+
import { components } from "react-select";
|
5
|
+
import classNames from "classnames";
|
6
|
+
import { Svg } from "../../Svg";
|
7
|
+
const DropdownIndicator = (props) => {
|
8
|
+
const { selectProps: { menuIsOpen, isDisabled }, } = props;
|
9
|
+
return (_jsx(components.DropdownIndicator, { ...props, children: _jsx(Svg, { src: menuIsOpen ? arrowDropUp : arrowDropDown, className: classNames(isDisabled && "af-form__input-select-container-icon-disabled") }) }));
|
10
|
+
};
|
11
|
+
export { DropdownIndicator };
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Select/Select.scss";
|
2
|
+
import ReactSelect, { ActionMeta, SingleValue } from "react-select";
|
3
|
+
import { ComponentPropsWithoutRef, PropsWithChildren } from "react";
|
4
|
+
type Option = {
|
5
|
+
label: string;
|
6
|
+
value: string | number;
|
7
|
+
};
|
8
|
+
type Props = Omit<ComponentPropsWithoutRef<ReactSelect>, "placeholder" | "noOptionsMessage"> & {
|
9
|
+
id: string;
|
10
|
+
label: string;
|
11
|
+
options: {
|
12
|
+
label: string;
|
13
|
+
value?: string | number | readonly string[];
|
14
|
+
}[];
|
15
|
+
value: Option | null;
|
16
|
+
errorLabel?: string;
|
17
|
+
placeholder?: string;
|
18
|
+
noOptionsMessage?: string;
|
19
|
+
onChange: (newValue: SingleValue<Option>, actionMeta: ActionMeta<string>) => void;
|
20
|
+
disabled?: boolean;
|
21
|
+
required?: boolean;
|
22
|
+
};
|
23
|
+
declare const Select: {
|
24
|
+
({ id, required, disabled, label, errorLabel, noOptionsMessage, ...otherProps }: PropsWithChildren<Props>): import("react/jsx-runtime").JSX.Element;
|
25
|
+
displayName: string;
|
26
|
+
};
|
27
|
+
export { Select };
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Select/Select.scss";
|
3
|
+
import ErrorOutline from "@material-symbols/svg-400/outlined/error.svg";
|
4
|
+
import ReactSelect from "react-select";
|
5
|
+
import classNames from "classnames";
|
6
|
+
import { DropdownIndicator } from "./DropdownIndicator";
|
7
|
+
import { Svg } from "../../Svg";
|
8
|
+
import { CustomOption } from "./CustomOption";
|
9
|
+
const Select = ({ id, required, disabled, label, errorLabel, noOptionsMessage, ...otherProps }) => {
|
10
|
+
return (_jsxs(_Fragment, { children: [label && (_jsxs("label", { id: `${id}__label`, htmlFor: `${id}__input`, className: "af-form__select-label", children: [label, required && _jsx("span", { children: " *" })] })), _jsx(ReactSelect, { inputId: `${id}__input`, "aria-labelledby": `${id}__label`, unstyled: true, isDisabled: disabled, noOptionsMessage: () => noOptionsMessage || "Aucun résultat", components: {
|
11
|
+
DropdownIndicator,
|
12
|
+
Option: CustomOption,
|
13
|
+
}, classNames: {
|
14
|
+
control: () => "af-form__input-select",
|
15
|
+
menu: () => "af-form__input-select-menu",
|
16
|
+
menuList: () => "af-form__select-menu-list",
|
17
|
+
container: ({ isFocused, isDisabled, selectProps: { menuIsOpen }, }) => classNames("af-form__input-select-container", isFocused && "af-form__input-select-container-focused", isDisabled && "af-form__input-select-container-disabled", errorLabel &&
|
18
|
+
!isFocused &&
|
19
|
+
!menuIsOpen &&
|
20
|
+
"af-form__input-select-container-error"),
|
21
|
+
option: ({ isSelected, isFocused, }) => classNames("af-form__input-select-menu-options", isSelected && "af-form__input-select-menu-options-selected", isFocused && "af-form__input-select-menu-options-focused"),
|
22
|
+
singleValue: ({ isDisabled, }) => classNames("af-form__select-single-value", isDisabled && "af-form__select-single-value-disabled"),
|
23
|
+
dropdownIndicator: () => "af-form__select-dropdown-indicator",
|
24
|
+
}, className: "af-form__input-select", ...otherProps }), errorLabel && (_jsxs("div", { className: "af-form__select-error", children: [_jsx(Svg, { src: ErrorOutline, width: 16, className: "af-form__select-error-icon" }), errorLabel] }))] }));
|
25
|
+
};
|
26
|
+
Select.displayName = "Select";
|
27
|
+
export { Select };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import { ComponentProps } from "react";
|
3
|
+
import { Select } from "./Select";
|
4
|
+
declare const meta: Meta<typeof Select>;
|
5
|
+
export default meta;
|
6
|
+
type StoryProps = ComponentProps<typeof Select>;
|
7
|
+
type Story = StoryObj<StoryProps> & {
|
8
|
+
required?: boolean;
|
9
|
+
};
|
10
|
+
export declare const SelectStory: Story;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Select } from "./Select";
|
3
|
+
const options = [
|
4
|
+
{ value: "fun", label: "For fun" },
|
5
|
+
{ value: "work", label: "For work" },
|
6
|
+
{ value: "drink", label: "For drink" },
|
7
|
+
];
|
8
|
+
const meta = {
|
9
|
+
component: Select,
|
10
|
+
title: "Components/Form/Input/Select",
|
11
|
+
};
|
12
|
+
export default meta;
|
13
|
+
export const SelectStory = {
|
14
|
+
name: "Select",
|
15
|
+
tags: ["Form", "Input"],
|
16
|
+
render: ({ onChange, ...args }) => (_jsx("div", { style: { width: 300 }, children: _jsx(Select, { onChange: onChange, ...args }) })),
|
17
|
+
args: {
|
18
|
+
className: "",
|
19
|
+
options,
|
20
|
+
label: "Label",
|
21
|
+
id: "nameid",
|
22
|
+
disabled: false,
|
23
|
+
required: false,
|
24
|
+
placeholder: "Placeholder",
|
25
|
+
noOptionsMessage: "Pas d'option",
|
26
|
+
errorLabel: "",
|
27
|
+
},
|
28
|
+
argTypes: {
|
29
|
+
onChange: { action: "onChange" },
|
30
|
+
},
|
31
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Select } from "./Select";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Select } from "./Select";
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Text/Text.scss";
|
2
|
+
import { ComponentPropsWithRef } from "react";
|
3
|
+
type Props = Omit<ComponentPropsWithRef<"input">, "required"> & {
|
4
|
+
classModifier?: string;
|
5
|
+
helper?: string;
|
6
|
+
error?: string;
|
7
|
+
description?: string;
|
8
|
+
label?: string;
|
9
|
+
required?: boolean;
|
10
|
+
};
|
11
|
+
declare const Text: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
12
|
+
export { Text };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Text/Text.scss";
|
3
|
+
import { forwardRef } from "react";
|
4
|
+
import { getComponentClassName } from "../../utilities";
|
5
|
+
import { InputError } from "../InputError";
|
6
|
+
const Text = forwardRef(({ className, classModifier = "", ...otherProps }, inputRef) => {
|
7
|
+
const componentClassName = getComponentClassName(className, classModifier, "af-form__input-text");
|
8
|
+
const { id, label, required, disabled, description, helper, error } = otherProps;
|
9
|
+
return (_jsxs("div", { className: "af-form__input-container", children: [_jsxs("label", { htmlFor: id, className: "af-form__input-label", children: [label, " ", required && _jsx("span", { children: " *" })] }), description && (_jsx("span", { className: "af-form__input-description", children: description })), _jsx("input", { className: componentClassName, type: "text", ref: inputRef, required: required, disabled: disabled, "aria-invalid": Boolean(error), "aria-describedby": error ? `${id}-error` : undefined, ...otherProps }), helper && _jsx("span", { className: "af-form__input-helper", children: helper }), error && _jsx(InputError, { id: `${id}-error`, message: error })] }));
|
10
|
+
});
|
11
|
+
Text.displayName = "Text";
|
12
|
+
export { Text };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import { Text } from "./Text";
|
3
|
+
declare const meta: Meta<typeof Text>;
|
4
|
+
export default meta;
|
5
|
+
type Story = StoryObj<typeof Text>;
|
6
|
+
export declare const TextStory: Story;
|
7
|
+
export declare const TextWithDescriptionStory: Story;
|
8
|
+
export declare const TextOnErrorStory: Story;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Text } from "./Text";
|
3
|
+
const meta = {
|
4
|
+
component: Text,
|
5
|
+
title: "Components/Form/Input/Text",
|
6
|
+
args: {
|
7
|
+
value: "John Doe",
|
8
|
+
label: "Label",
|
9
|
+
placeholder: "¨Placeholder",
|
10
|
+
helper: "Informations complémentaires",
|
11
|
+
name: "name",
|
12
|
+
id: "nameid",
|
13
|
+
disabled: false,
|
14
|
+
required: false,
|
15
|
+
className: "",
|
16
|
+
type: "text",
|
17
|
+
},
|
18
|
+
argTypes: {
|
19
|
+
type: {
|
20
|
+
control: { type: "text" },
|
21
|
+
onChange: { action: "onChange" },
|
22
|
+
},
|
23
|
+
onChange: { action: "onChange" },
|
24
|
+
},
|
25
|
+
};
|
26
|
+
export default meta;
|
27
|
+
export const TextStory = {
|
28
|
+
name: "Text",
|
29
|
+
render: ({ onChange, ...args }) => _jsx(Text, { onChange: onChange, ...args }),
|
30
|
+
};
|
31
|
+
export const TextWithDescriptionStory = {
|
32
|
+
name: "Text with description",
|
33
|
+
render: ({ onChange, ...args }) => _jsx(Text, { onChange: onChange, ...args }),
|
34
|
+
args: {
|
35
|
+
description: "Description",
|
36
|
+
},
|
37
|
+
};
|
38
|
+
export const TextOnErrorStory = {
|
39
|
+
name: "Text on error",
|
40
|
+
render: ({ onChange, ...args }) => _jsx(Text, { onChange: onChange, ...args }),
|
41
|
+
args: {
|
42
|
+
classModifier: "error",
|
43
|
+
description: "Description",
|
44
|
+
error: "Error Message",
|
45
|
+
},
|
46
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Text } from "./Text";
|