@axa-fr/canopee-react 2.0.0-alpha.73 → 2.0.0-alpha.75
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/distributeur/Accordion/Accordion.d.ts +1 -3
- package/dist/distributeur/Accordion/Accordion.js +2 -5
- package/dist/distributeur/Accordion/CollapseCard.d.ts +1 -3
- package/dist/distributeur/Accordion/CollapseCard.js +2 -4
- package/dist/distributeur/Accordion/Header.d.ts +1 -3
- package/dist/distributeur/Accordion/Header.js +1 -2
- package/dist/distributeur/Action/Action.d.ts +1 -3
- package/dist/distributeur/Action/Action.js +2 -3
- package/dist/distributeur/Form/Checkbox/CheckboxInput.js +2 -2
- package/dist/distributeur/Form/Checkbox/CheckboxItem.d.ts +1 -3
- package/dist/distributeur/Form/Checkbox/CheckboxItem.js +2 -2
- package/dist/distributeur/Form/Choice/Choice.d.ts +0 -2
- package/dist/distributeur/Form/Choice/ChoiceInput.js +1 -1
- package/dist/distributeur/Form/Date/Date.d.ts +2 -3
- package/dist/distributeur/Form/Date/Date.js +3 -3
- package/dist/distributeur/Form/Date/DateInput.js +1 -1
- package/dist/distributeur/Form/File/File.d.ts +1 -3
- package/dist/distributeur/Form/File/File.js +1 -2
- package/dist/distributeur/Form/File/FileInput.d.ts +3 -1
- package/dist/distributeur/Form/File/FileInput.js +2 -2
- package/dist/distributeur/Form/File/FileLine.d.ts +1 -2
- package/dist/distributeur/Form/File/FileLine.js +6 -3
- package/dist/distributeur/Form/File/FileTable.d.ts +1 -2
- package/dist/distributeur/Form/File/FileTable.js +6 -3
- package/dist/distributeur/Form/MultiSelect/MultiSelectInput.js +1 -1
- package/dist/distributeur/Form/NestedQuestion/NestedQuestion.js +6 -3
- package/dist/distributeur/Form/Number/Number.d.ts +2 -5
- package/dist/distributeur/Form/Number/Number.js +2 -3
- package/dist/distributeur/Form/Number/NumberInput.js +1 -1
- package/dist/distributeur/Form/Radio/Radio.d.ts +1 -1
- package/dist/distributeur/Form/Radio/RadioInput.js +1 -1
- package/dist/distributeur/Form/Radio/RadioItem.d.ts +1 -3
- package/dist/distributeur/Form/Radio/RadioItem.js +2 -2
- package/dist/distributeur/Form/Select/Select.d.ts +3 -19
- package/dist/distributeur/Form/Select/Select.js +3 -4
- package/dist/distributeur/Form/Select/SelectBase.d.ts +3 -24
- package/dist/distributeur/Form/Select/SelectBase.js +2 -7
- package/dist/distributeur/Form/Select/SelectDefault.d.ts +3 -3
- package/dist/distributeur/Form/Select/SelectInput.js +1 -1
- package/dist/distributeur/Form/Select/index.d.ts +0 -1
- package/dist/distributeur/Form/Select/index.js +0 -1
- package/dist/distributeur/Form/Text/Text.d.ts +2 -3
- package/dist/distributeur/Form/Text/Text.js +3 -3
- package/dist/distributeur/Form/Text/TextInput.js +1 -1
- package/dist/distributeur/Form/Textarea/Textarea.d.ts +2 -3
- package/dist/distributeur/Form/Textarea/Textarea.js +3 -3
- package/dist/distributeur/Form/Textarea/TextareaInput.js +1 -1
- package/dist/distributeur/Form/core/Field.d.ts +4 -23
- package/dist/distributeur/Form/core/Field.js +25 -16
- package/dist/distributeur/Form/core/FieldError.js +5 -2
- package/dist/distributeur/Form/core/getOptionClassName.d.ts +1 -1
- package/dist/distributeur/Form/core/getOptionClassName.js +2 -6
- package/dist/distributeur/Form/core/index.d.ts +0 -8
- package/dist/distributeur/Form/core/index.js +0 -4
- package/dist/distributeur/HelpButton/index.d.ts +1 -1
- package/dist/distributeur/HelpButton/index.js +4 -6
- package/dist/distributeur/Layout/Header/Header.d.ts +1 -3
- package/dist/distributeur/Layout/Header/Header.js +1 -2
- package/dist/distributeur/Layout/Header/HeaderTitle/HeaderTitle.d.ts +1 -2
- package/dist/distributeur/Layout/Header/HeaderTitle/HeaderTitle.js +7 -4
- package/dist/distributeur/Layout/Header/Infos/Infos.d.ts +1 -3
- package/dist/distributeur/Layout/Header/Infos/Infos.js +1 -2
- package/dist/distributeur/Layout/Header/Name/Name.d.ts +1 -3
- package/dist/distributeur/Layout/Header/Name/Name.js +1 -2
- package/dist/distributeur/Layout/Header/NavBar/NavBar.js +1 -6
- package/dist/distributeur/Layout/Header/NavBar/NavBarBase.d.ts +1 -3
- package/dist/distributeur/Layout/Header/NavBar/NavBarBase.js +7 -3
- package/dist/distributeur/Layout/Header/NavBar/NavBarItem/NavBarItem.d.ts +2 -2
- package/dist/distributeur/Layout/Header/NavBar/NavBarItem/NavBarItem.js +10 -3
- package/dist/distributeur/Layout/Header/NavBar/NavBarItem/NavBarItemBase.d.ts +1 -2
- package/dist/distributeur/Layout/Header/NavBar/NavBarItem/NavBarItemBase.js +6 -3
- package/dist/distributeur/Layout/Header/User/User.d.ts +1 -11
- package/dist/distributeur/Layout/Header/User/User.js +1 -2
- package/dist/distributeur/Messages/Message.d.ts +2 -6
- package/dist/distributeur/Messages/Message.js +3 -14
- package/dist/distributeur/ModalAgent/BooleanModal.d.ts +1 -6
- package/dist/distributeur/ModalAgent/BooleanModal.js +7 -4
- package/dist/distributeur/ModalAgent/Modal.d.ts +2 -7
- package/dist/distributeur/ModalAgent/Modal.js +7 -16
- package/dist/distributeur/ModalAgent/components/Body.d.ts +2 -5
- package/dist/distributeur/ModalAgent/components/Body.js +1 -2
- package/dist/distributeur/ModalAgent/components/Footer.d.ts +2 -5
- package/dist/distributeur/ModalAgent/components/Footer.js +1 -2
- package/dist/distributeur/ModalAgent/components/Header.d.ts +1 -11
- package/dist/distributeur/ModalAgent/components/Header.js +2 -3
- package/dist/distributeur/ModalAgent/components/HeaderBase.d.ts +2 -5
- package/dist/distributeur/ModalAgent/components/HeaderBase.js +1 -2
- package/dist/distributeur/Popover/AnimatedPopover.d.ts +1 -3
- package/dist/distributeur/Popover/AnimatedPopover.js +1 -2
- package/dist/distributeur/Popover/Popover.d.ts +1 -3
- package/dist/distributeur/Popover/Popover.js +2 -2
- package/dist/distributeur/Popover/Popover.types.d.ts +0 -2
- package/dist/distributeur/Popover/PopoverBase.d.ts +1 -3
- package/dist/distributeur/Popover/PopoverBase.js +2 -2
- package/dist/distributeur/Popover/PopoverClick.d.ts +1 -1
- package/dist/distributeur/Popover/PopoverClick.js +2 -2
- package/dist/distributeur/Popover/PopoverOver.d.ts +1 -1
- package/dist/distributeur/Popover/PopoverOver.js +2 -2
- package/dist/distributeur/Restitution/ArticleRestitution.d.ts +2 -5
- package/dist/distributeur/Restitution/ArticleRestitution.js +1 -2
- package/dist/distributeur/Restitution/HeaderRestitution.d.ts +1 -3
- package/dist/distributeur/Restitution/HeaderRestitution.js +1 -2
- package/dist/distributeur/Restitution/Restitution.d.ts +1 -3
- package/dist/distributeur/Restitution/Restitution.js +2 -2
- package/dist/distributeur/Restitution/SectionRestitution.d.ts +1 -3
- package/dist/distributeur/Restitution/SectionRestitution.js +1 -2
- package/dist/distributeur/Restitution/SectionRestitutionColumn.d.ts +1 -3
- package/dist/distributeur/Restitution/SectionRestitutionColumn.js +1 -2
- package/dist/distributeur/Restitution/SectionRestitutionRow.d.ts +1 -3
- package/dist/distributeur/Restitution/SectionRestitutionRow.js +5 -9
- package/dist/distributeur/Restitution/SectionRestitutionTitle.d.ts +1 -3
- package/dist/distributeur/Restitution/SectionRestitutionTitle.js +1 -2
- package/dist/distributeur/Steps/Step.d.ts +1 -1
- package/dist/distributeur/Steps/Step.js +4 -4
- package/dist/distributeur/Steps/StepBase.d.ts +1 -3
- package/dist/distributeur/Steps/StepBase.js +1 -2
- package/dist/distributeur/Steps/Steps.d.ts +1 -3
- package/dist/distributeur/Steps/Steps.js +1 -2
- package/dist/distributeur/Summary/index.d.ts +1 -1
- package/dist/distributeur/Summary/index.js +1 -2
- package/dist/distributeur/Table/Pagination/Items.d.ts +1 -2
- package/dist/distributeur/Table/Pagination/Items.js +8 -8
- package/dist/distributeur/Table/Pagination/Pager.d.ts +1 -2
- package/dist/distributeur/Table/Pagination/Pager.js +6 -3
- package/dist/distributeur/Table/Pagination/Paging.d.ts +1 -1
- package/dist/distributeur/Table/Pagination/Paging.js +6 -3
- package/dist/distributeur/Table/TBody.d.ts +1 -5
- package/dist/distributeur/Table/TBody.js +1 -2
- package/dist/distributeur/Table/THead.d.ts +2 -5
- package/dist/distributeur/Table/THead.js +2 -2
- package/dist/distributeur/Table/Table.d.ts +6 -33
- package/dist/distributeur/Table/Table.js +1 -10
- package/dist/distributeur/Table/Td.d.ts +1 -5
- package/dist/distributeur/Table/Td.js +1 -2
- package/dist/distributeur/Table/Th.d.ts +2 -4
- package/dist/distributeur/Table/Th.js +2 -2
- package/dist/distributeur/Table/Tr.d.ts +2 -5
- package/dist/distributeur/Table/Tr.js +2 -2
- package/dist/distributeur/Table/index.d.ts +1 -1
- package/dist/distributeur/Tabs/components/Tab.d.ts +0 -4
- package/dist/distributeur/Tabs/components/TabsStateless.d.ts +1 -5
- package/dist/distributeur/Tabs/components/TabsStateless.js +2 -2
- package/dist/distributeur/Tag/Tag.d.ts +1 -6
- package/dist/distributeur/Tag/Tag.js +2 -2
- package/dist/distributeur/Title/Title.d.ts +1 -3
- package/dist/distributeur/Title/Title.js +2 -2
- package/dist/distributeur/utilities.d.ts +1 -1
- package/dist/distributeur/utilities.js +1 -1
- package/dist/distributeur.d.ts +5 -24
- package/dist/distributeur.js +5 -17
- package/package.json +2 -2
- package/dist/distributeur/Form/Pass/Pass.d.ts +0 -15
- package/dist/distributeur/Form/Pass/Pass.js +0 -13
- package/dist/distributeur/Form/Pass/PassInput.d.ts +0 -13
- package/dist/distributeur/Form/Pass/PassInput.js +0 -34
- package/dist/distributeur/Form/Pass/index.d.ts +0 -2
- package/dist/distributeur/Form/Pass/index.js +0 -2
- package/dist/distributeur/Form/Select/SelectDefaultWithOptions.d.ts +0 -26
- package/dist/distributeur/Form/Select/SelectDefaultWithOptions.js +0 -32
- package/dist/distributeur/Form/Slider/Slider.d.ts +0 -28
- package/dist/distributeur/Form/Slider/Slider.js +0 -40
- package/dist/distributeur/Form/Slider/SliderInput.d.ts +0 -9
- package/dist/distributeur/Form/Slider/SliderInput.js +0 -11
- package/dist/distributeur/Form/Slider/index.d.ts +0 -3
- package/dist/distributeur/Form/Slider/index.js +0 -3
- package/dist/distributeur/Form/core/Deprecated/Field.d.ts +0 -21
- package/dist/distributeur/Form/core/Deprecated/Field.js +0 -20
- package/dist/distributeur/Form/core/Deprecated/FieldForm.d.ts +0 -103
- package/dist/distributeur/Form/core/Deprecated/FieldForm.js +0 -162
- package/dist/distributeur/Form/core/Deprecated/FieldInput.d.ts +0 -16
- package/dist/distributeur/Form/core/Deprecated/FieldInput.js +0 -14
- package/dist/distributeur/Form/core/useInputClassModifier.d.ts +0 -4
- package/dist/distributeur/Form/core/useInputClassModifier.js +0 -13
- package/dist/distributeur/Layout/Header/HeaderTitle/HeaderTitle.helpers.d.ts +0 -1
- package/dist/distributeur/Layout/Header/HeaderTitle/HeaderTitle.helpers.js +0 -6
- package/dist/distributeur/utilities/helpers/getComponentClassName.d.ts +0 -20
- package/dist/distributeur/utilities/helpers/getComponentClassName.js +0 -54
package/dist/distributeur.js
CHANGED
|
@@ -7,24 +7,20 @@ import "@axa-fr/canopee-css/distributeur/Form/core/FormCore.css";
|
|
|
7
7
|
import "@fontsource/source-sans-pro/400.css";
|
|
8
8
|
import "@fontsource/source-sans-pro/600.css";
|
|
9
9
|
import "@fontsource/source-sans-pro/700.css";
|
|
10
|
-
import { Message } from "./distributeur/Messages/Message";
|
|
11
|
-
import { Tag } from "./distributeur/Tag/Tag";
|
|
12
10
|
export { Action } from "./distributeur/Action/Action";
|
|
13
11
|
export { Button } from "./distributeur/Button/Button";
|
|
14
12
|
export { Card } from "./distributeur/Card/Card";
|
|
15
13
|
export { Divider } from "./distributeur/Divider/Divider";
|
|
16
14
|
export { Checkbox, CheckboxInput, CheckboxItem, CheckboxModes, } from "./distributeur/Form/Checkbox";
|
|
17
15
|
export { Choice, ChoiceInput } from "./distributeur/Form/Choice";
|
|
18
|
-
export {
|
|
16
|
+
export { Field, FieldError, FormClassManager, HelpMessage, InputList, MessageTypes, } from "./distributeur/Form/core";
|
|
19
17
|
export { Date, DateInput } from "./distributeur/Form/Date";
|
|
20
18
|
export { File, FileInput, FileTable, } from "./distributeur/Form/File";
|
|
21
19
|
export { MultiSelect, MultiSelectInput } from "./distributeur/Form/MultiSelect";
|
|
22
20
|
export { NestedQuestion } from "./distributeur/Form/NestedQuestion/NestedQuestion";
|
|
23
21
|
export { Number, NumberInput } from "./distributeur/Form/Number";
|
|
24
|
-
export { Pass, PassInput } from "./distributeur/Form/Pass";
|
|
25
22
|
export { Radio, RadioInput, RadioItem, RadioModes, } from "./distributeur/Form/Radio";
|
|
26
|
-
export { Select,
|
|
27
|
-
export { Slider, SliderInput } from "./distributeur/Form/Slider";
|
|
23
|
+
export { Select, SelectInput } from "./distributeur/Form/Select";
|
|
28
24
|
export { Text, TextInput } from "./distributeur/Form/Text";
|
|
29
25
|
export { Textarea, TextareaInput } from "./distributeur/Form/Textarea";
|
|
30
26
|
export { Footer } from "./distributeur/Layout/Footer";
|
|
@@ -40,24 +36,16 @@ export { Summary } from "./distributeur/Summary";
|
|
|
40
36
|
export { Svg } from "./distributeur/Svg";
|
|
41
37
|
export { Tabs } from "./distributeur/Tabs/Tabs";
|
|
42
38
|
export { Title } from "./distributeur/Title/Title";
|
|
43
|
-
export {
|
|
44
|
-
|
|
45
|
-
const Badge = Tag;
|
|
46
|
-
export { Badge, Tag };
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated `Alert` has been renamed `Message` in order to comply with UX naming of components. Use `Message` instead.
|
|
49
|
-
* @see {@link Message}
|
|
50
|
-
*/
|
|
51
|
-
const Alert = Message;
|
|
39
|
+
export { getClassName } from "./distributeur/utilities";
|
|
40
|
+
export { Tag } from "./distributeur/Tag/Tag";
|
|
52
41
|
export * from "./distributeur/Accordion";
|
|
53
42
|
export {} from "./distributeur/Messages/Message";
|
|
54
43
|
export * from "./distributeur/Popover";
|
|
55
44
|
export * from "./distributeur/Table";
|
|
56
|
-
export {
|
|
45
|
+
export { Message } from "./distributeur/Messages/Message";
|
|
57
46
|
export { HelpButton } from "./distributeur/HelpButton";
|
|
58
47
|
export { Loader } from "./distributeur/Loader/Loader";
|
|
59
48
|
export { ItemLoader, } from "./distributeur/Loader/ItemLoader";
|
|
60
|
-
export { SquareLoader } from "./distributeur/Loader/SquareLoader";
|
|
61
49
|
export { CardData } from "./distributeur/CardData/CardData";
|
|
62
50
|
export { EditorialMessage, } from "./distributeur/EditorialMessage/EditorialMessage";
|
|
63
51
|
export { Timeline, } from "./distributeur/Timeline/Timeline";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/canopee-react",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.75",
|
|
4
4
|
"description": "Package React - Design System Canopée",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./distributeur": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@axa-fr/canopee-css": "2.0.0-alpha.
|
|
56
|
+
"@axa-fr/canopee-css": "2.0.0-alpha.75",
|
|
57
57
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
58
58
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
59
59
|
"react": ">= 19"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithRef } from "react";
|
|
2
|
-
import "@axa-fr/canopee-css/distributeur/Form/Pass/Pass.css";
|
|
3
|
-
type Props = Omit<ComponentPropsWithRef<"input">, "type" | "role"> & {
|
|
4
|
-
type?: "text" | "password";
|
|
5
|
-
classModifier?: string;
|
|
6
|
-
onToggleType: () => void;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated The Pass component is deprecated and will be removed in a future release
|
|
10
|
-
*/
|
|
11
|
-
declare const Pass: {
|
|
12
|
-
({ onToggleType, type, className, classModifier, ...inputProps }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
displayName: string;
|
|
14
|
-
};
|
|
15
|
-
export { Pass };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {} from "react";
|
|
3
|
-
import { getComponentClassName } from "../../utilities";
|
|
4
|
-
import "@axa-fr/canopee-css/distributeur/Form/Pass/Pass.css";
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated The Pass component is deprecated and will be removed in a future release
|
|
7
|
-
*/
|
|
8
|
-
const Pass = ({ onToggleType, type = "password", className, classModifier, ...inputProps }) => {
|
|
9
|
-
const componentClassName = getComponentClassName(className, classModifier, "af-form__pass");
|
|
10
|
-
return (_jsxs("div", { className: componentClassName, children: [_jsx("div", { className: "af-form__pass-strength" }), _jsx("input", { ...inputProps, role: type === "password" ? "password" : "textbox", className: "af-form__input-text", type: type, required: classModifier?.includes("required") }), _jsx("button", { className: "af-form__pass-btn", type: "button", "aria-label": "show password", onClick: onToggleType, children: _jsx("i", { className: `glyphicon glyphicon-eye${type === "text" ? "-close" : "-open"}` }) })] }));
|
|
11
|
-
};
|
|
12
|
-
Pass.displayName = "Pass";
|
|
13
|
-
export { Pass };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
-
import { type ConsumerFieldProps } from "../core";
|
|
3
|
-
import { Pass } from "./Pass";
|
|
4
|
-
type PassProps = ComponentProps<typeof Pass>;
|
|
5
|
-
type Props = Omit<ConsumerFieldProps & PassProps & {
|
|
6
|
-
helpMessage?: ReactNode;
|
|
7
|
-
score?: string;
|
|
8
|
-
}, "onToggleType" | "type">;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated The PassInput component is deprecated and will be removed in a future release
|
|
11
|
-
*/
|
|
12
|
-
declare const PassInput: ({ children, score, classModifier, disabled, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export { PassInput };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Field } from "../core";
|
|
4
|
-
import { Pass } from "./Pass";
|
|
5
|
-
const strengthList = {
|
|
6
|
-
0: "bad",
|
|
7
|
-
1: "okay",
|
|
8
|
-
2: "good",
|
|
9
|
-
3: "verygood",
|
|
10
|
-
4: "excellent",
|
|
11
|
-
};
|
|
12
|
-
const calculateStrength = (score) => {
|
|
13
|
-
if (score === null || score === undefined) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const scoreToNumber = Number(score);
|
|
17
|
-
let strength = Number.isNaN(scoreToNumber) ? 0 : scoreToNumber;
|
|
18
|
-
if (strength > 4) {
|
|
19
|
-
strength = 4;
|
|
20
|
-
}
|
|
21
|
-
if (strength < 0) {
|
|
22
|
-
strength = 0;
|
|
23
|
-
}
|
|
24
|
-
return strengthList[strength];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated The PassInput component is deprecated and will be removed in a future release
|
|
28
|
-
*/
|
|
29
|
-
const PassInput = ({ children, score, classModifier, disabled, ...props }) => {
|
|
30
|
-
const strength = calculateStrength(score);
|
|
31
|
-
const [type, setType] = useState("password");
|
|
32
|
-
return (_jsx(Field, { ...props, classModifier: classModifier, renderInput: ({ id, classModifier: modifier, ariaInvalid, errorId, ...inputProps }) => (_jsxs(_Fragment, { children: [_jsx(Pass, { ...inputProps, type: type, id: id, disabled: disabled, classModifier: `${modifier} ${strength}`, "aria-describedby": errorId, "aria-invalid": ariaInvalid, onToggleType: () => setType(type === "password" ? "text" : "password") }), children] })) }));
|
|
33
|
-
};
|
|
34
|
-
export { PassInput };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithRef, type OptionHTMLAttributes } from "react";
|
|
2
|
-
import { SelectBase } from "./SelectBase";
|
|
3
|
-
type Props = ComponentPropsWithRef<typeof SelectBase> & {
|
|
4
|
-
options: OptionHTMLAttributes<HTMLOptionElement>[];
|
|
5
|
-
forceDisplayPlaceholder?: boolean;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use `SelectDefault` instead
|
|
10
|
-
* Instead of
|
|
11
|
-
* ```jsx
|
|
12
|
-
* <SelectDefaultWithOptions options={[{ value: "1", label: "Option 1" }]} />
|
|
13
|
-
* ```
|
|
14
|
-
* you can now do something like :
|
|
15
|
-
* ```jsx
|
|
16
|
-
* <SelectDefault>
|
|
17
|
-
* <option value="1">Option 1</option>
|
|
18
|
-
* </SelectDefault>
|
|
19
|
-
* ```
|
|
20
|
-
* It allows you to use the `optgroup` tag for example.
|
|
21
|
-
*/
|
|
22
|
-
export declare const SelectDefaultWithOptions: {
|
|
23
|
-
({ onChange, forceDisplayPlaceholder, value, defaultValue, required, placeholder, options, id, ...otherProps }: Props): import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
displayName: string;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useId, useMemo, useState, } from "react";
|
|
3
|
-
import { SelectBase } from "./SelectBase";
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use `SelectDefault` instead
|
|
6
|
-
* Instead of
|
|
7
|
-
* ```jsx
|
|
8
|
-
* <SelectDefaultWithOptions options={[{ value: "1", label: "Option 1" }]} />
|
|
9
|
-
* ```
|
|
10
|
-
* you can now do something like :
|
|
11
|
-
* ```jsx
|
|
12
|
-
* <SelectDefault>
|
|
13
|
-
* <option value="1">Option 1</option>
|
|
14
|
-
* </SelectDefault>
|
|
15
|
-
* ```
|
|
16
|
-
* It allows you to use the `optgroup` tag for example.
|
|
17
|
-
*/
|
|
18
|
-
export const SelectDefaultWithOptions = ({ onChange, forceDisplayPlaceholder = false, value, defaultValue, required, placeholder = "- Select -", options, id, ...otherProps }) => {
|
|
19
|
-
const [hasHandleChangeOnce, setHasHandleChangeOnce] = useState(false);
|
|
20
|
-
const generatedId = useId();
|
|
21
|
-
const inputId = id ?? generatedId;
|
|
22
|
-
const newOptions = useMemo(() => (hasHandleChangeOnce || defaultValue || value) && required
|
|
23
|
-
? options
|
|
24
|
-
: [{ value: "", label: placeholder }, ...options], [hasHandleChangeOnce, options, defaultValue, value, required, placeholder]);
|
|
25
|
-
return (_jsx(SelectBase, { ...otherProps, id: inputId, value: value, defaultValue: defaultValue, options: newOptions, onChange: (e) => {
|
|
26
|
-
if (onChange) {
|
|
27
|
-
onChange(e);
|
|
28
|
-
}
|
|
29
|
-
setHasHandleChangeOnce(!forceDisplayPlaceholder);
|
|
30
|
-
} }));
|
|
31
|
-
};
|
|
32
|
-
SelectDefaultWithOptions.displayName = "SelectDefaultWithOptions";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import RcSlider from "rc-slider";
|
|
2
|
-
import { type ComponentProps, type ReactNode } from "react";
|
|
3
|
-
type RcSliderProps = ComponentProps<typeof RcSlider>;
|
|
4
|
-
type Props = Omit<RcSliderProps, "marks" | "onChange" | "onChangeComplete"> & {
|
|
5
|
-
/** @deprecated Use `className` instead. */
|
|
6
|
-
classModifier?: string;
|
|
7
|
-
options: {
|
|
8
|
-
value: number;
|
|
9
|
-
label?: string | ReactNode;
|
|
10
|
-
}[];
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
onChange?: (selectedValue: {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
value: number;
|
|
17
|
-
}) => void;
|
|
18
|
-
onChangeComplete?: (selectedValue: {
|
|
19
|
-
id: string;
|
|
20
|
-
name: string;
|
|
21
|
-
value: number;
|
|
22
|
-
}) => void;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Slider is deprecated and will be removed in a future major release.
|
|
26
|
-
*/
|
|
27
|
-
declare const Slider: ({ options, value, defaultValue, className, classModifier, ...otherProps }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export { Slider };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import RcSlider from "rc-slider";
|
|
3
|
-
import { useCallback, useMemo, } from "react";
|
|
4
|
-
import { getClassName } from "../../utilities/helpers/getClassName";
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Slider is deprecated and will be removed in a future major release.
|
|
7
|
-
*/
|
|
8
|
-
const Slider = ({ options, value, defaultValue, className, classModifier, ...otherProps }) => {
|
|
9
|
-
const defaultValueIndex = useMemo(() => {
|
|
10
|
-
const newDefaultValueIndex = options.findIndex((opt) => opt.value === (defaultValue || value));
|
|
11
|
-
return newDefaultValueIndex !== -1 ? newDefaultValueIndex : undefined;
|
|
12
|
-
}, [defaultValue, options, value]);
|
|
13
|
-
const valueIndex = useMemo(() => {
|
|
14
|
-
const newValueIndex = options.findIndex((opt) => opt.value === value);
|
|
15
|
-
return newValueIndex !== -1 ? newValueIndex : undefined;
|
|
16
|
-
}, [value, options]);
|
|
17
|
-
const marks = useMemo(() => [...options]
|
|
18
|
-
.sort((optA, optB) => optA.value - optB.value)
|
|
19
|
-
.reduce((prevMarks, { value: optValue, label: optLabel }, index) => {
|
|
20
|
-
const newMarks = { ...prevMarks };
|
|
21
|
-
newMarks[index] = optLabel || optValue;
|
|
22
|
-
return newMarks;
|
|
23
|
-
}, {}), [options]);
|
|
24
|
-
const componentClassName = useMemo(() => getClassName({
|
|
25
|
-
baseClassName: "af-slider",
|
|
26
|
-
modifiers: classModifier?.split(" "),
|
|
27
|
-
className,
|
|
28
|
-
}), [className, classModifier]);
|
|
29
|
-
const formatOnChange = useCallback((newValueIndex, onChange) => {
|
|
30
|
-
if (onChange && !Array.isArray(newValueIndex)) {
|
|
31
|
-
onChange({
|
|
32
|
-
id: otherProps.id,
|
|
33
|
-
name: otherProps.name,
|
|
34
|
-
value: options[newValueIndex].value,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}, [options, otherProps.id, otherProps.name]);
|
|
38
|
-
return (_jsx(RcSlider, { ...otherProps, min: 0, max: options.length - 1, onChange: (newValueIndex) => formatOnChange(newValueIndex, otherProps.onChange), onChangeComplete: (newValueIndex) => formatOnChange(newValueIndex, otherProps.onChangeComplete), marks: marks, step: null, className: componentClassName, defaultValue: defaultValueIndex, value: valueIndex, disabled: otherProps.disabled || classModifier?.includes("disabled"), "aria-required": classModifier?.includes("required") }));
|
|
39
|
-
};
|
|
40
|
-
export { Slider };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps } from "react";
|
|
2
|
-
import { type ConsumerFieldProps } from "../core";
|
|
3
|
-
import { Slider } from "./Slider";
|
|
4
|
-
type Props = ConsumerFieldProps & ComponentProps<typeof Slider>;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated This component is deprecated and will be removed in a future major release.
|
|
7
|
-
*/
|
|
8
|
-
declare const SliderInput: ({ children, name, options, label, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export { SliderInput };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {} from "react";
|
|
3
|
-
import { Field } from "../core";
|
|
4
|
-
import { Slider } from "./Slider";
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated This component is deprecated and will be removed in a future major release.
|
|
7
|
-
*/
|
|
8
|
-
const SliderInput = ({ children, name, options, label, ...props }) => {
|
|
9
|
-
return (_jsx(Field, { label: label, ...props, renderInput: ({ id, classModifier, ...sliderProps }) => (_jsxs(_Fragment, { children: [_jsx(Slider, { id: id, classModifier: classModifier, name: name, options: options, ...sliderProps }), children] })) }));
|
|
10
|
-
};
|
|
11
|
-
export { SliderInput };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
|
-
import { FieldForm } from "./FieldForm";
|
|
3
|
-
type FieldProps = Omit<ComponentPropsWithoutRef<typeof FieldForm>, "children"> & {
|
|
4
|
-
label: ReactNode;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
id?: string;
|
|
7
|
-
classModifier?: string;
|
|
8
|
-
classNameContainerLabel?: string;
|
|
9
|
-
classNameContainerInput?: string;
|
|
10
|
-
isVisible?: boolean;
|
|
11
|
-
roleContainer?: string;
|
|
12
|
-
ariaLabelContainer?: string;
|
|
13
|
-
isLabelContainerLinkedToInput?: boolean;
|
|
14
|
-
errorId?: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated This component is deprecated and will be removed in future versions. Use components with labels instead, such as `TextInput`
|
|
18
|
-
* or `SelectInput`.
|
|
19
|
-
*/
|
|
20
|
-
export declare const LegacyField: ({ id, message, messageType, label, children, forceDisplayMessage, classModifier, className, classNameContainerLabel, classNameContainerInput, isVisible, roleContainer, ariaLabelContainer, isLabelContainerLinkedToInput, errorId, }: FieldProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import {} from "react";
|
|
4
|
-
import { getComponentClassName } from "../../../utilities";
|
|
5
|
-
import { FieldError } from "../FieldError";
|
|
6
|
-
import { MessageTypes } from "../MessageTypes";
|
|
7
|
-
import { FieldForm } from "./FieldForm";
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This component is deprecated and will be removed in future versions. Use components with labels instead, such as `TextInput`
|
|
10
|
-
* or `SelectInput`.
|
|
11
|
-
*/
|
|
12
|
-
export const LegacyField = ({ id = "", message = "", messageType = MessageTypes.error, label, children, forceDisplayMessage, classModifier = "", className, classNameContainerLabel = "col-md-2", classNameContainerInput = "col-md-10", isVisible = true, roleContainer, ariaLabelContainer, isLabelContainerLinkedToInput = true, errorId, }) => {
|
|
13
|
-
if (!isVisible) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const componentClassName = getComponentClassName(className, classModifier, "row af-form__group");
|
|
17
|
-
return (_jsxs("div", { className: componentClassName, role: roleContainer, "aria-label": ariaLabelContainer, children: [_jsx("div", { className: classNameContainerLabel, children: _jsx("label", { className: classNames({
|
|
18
|
-
"af-form__group-label--required": classModifier.includes("required"),
|
|
19
|
-
}, "af-form__group-label"), htmlFor: isLabelContainerLinkedToInput ? id : undefined, children: label }) }), _jsxs(FieldForm, { className: classNameContainerInput, message: message, messageType: messageType, forceDisplayMessage: forceDisplayMessage, children: [children, _jsx(FieldError, { message: message, messageType: messageType, errorId: errorId })] })] }));
|
|
20
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { type BaseSyntheticEvent, type Dispatch, type ReactElement, type ReactNode, type SetStateAction } from "react";
|
|
2
|
-
import { FormClassManager } from "../FormClassManager";
|
|
3
|
-
import { MessageTypes } from "../MessageTypes";
|
|
4
|
-
type TMessage = {
|
|
5
|
-
message?: string;
|
|
6
|
-
messageType?: MessageTypes;
|
|
7
|
-
};
|
|
8
|
-
declare const INITIAL_STATE: {
|
|
9
|
-
hasLostFocusOnce: boolean;
|
|
10
|
-
hasFocus: boolean;
|
|
11
|
-
hasChange: boolean;
|
|
12
|
-
memory: TMessage;
|
|
13
|
-
};
|
|
14
|
-
type EventFunction = {
|
|
15
|
-
onChange?: (event: BaseSyntheticEvent) => void;
|
|
16
|
-
onBlur?: (event: BaseSyntheticEvent) => void;
|
|
17
|
-
onFocus?: (event: BaseSyntheticEvent) => void;
|
|
18
|
-
};
|
|
19
|
-
type FieldFormProps = TMessage & {
|
|
20
|
-
className?: string;
|
|
21
|
-
classModifier?: string;
|
|
22
|
-
forceDisplayMessage?: boolean;
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
setStateMemoryFn?: typeof setStateMemory;
|
|
25
|
-
onChangeByStateFn?: typeof onChangeByState;
|
|
26
|
-
setStateOnBlurFn?: typeof setStateOnBlur;
|
|
27
|
-
setStateOnFocusFn?: typeof setStateOnFocus;
|
|
28
|
-
initialState?: typeof INITIAL_STATE;
|
|
29
|
-
};
|
|
30
|
-
type SetState = (prevState: typeof INITIAL_STATE) => typeof INITIAL_STATE;
|
|
31
|
-
export declare const setStateMemory: ({ message, messageType }: TMessage) => SetState;
|
|
32
|
-
export declare const setStateHasChange: () => SetState;
|
|
33
|
-
export declare const onChangeByState: (setState: Dispatch<SetStateAction<{
|
|
34
|
-
hasLostFocusOnce: boolean;
|
|
35
|
-
hasFocus: boolean;
|
|
36
|
-
hasChange: boolean;
|
|
37
|
-
memory: TMessage;
|
|
38
|
-
}>>, stateHasChange: boolean, setStateHasChangeFn?: () => SetState) => false | void;
|
|
39
|
-
export declare const setStateOnBlur: () => SetState;
|
|
40
|
-
export declare const setStateOnFocus: ({ message, messageType }: TMessage) => SetState;
|
|
41
|
-
type GetMessageInfoProps = typeof INITIAL_STATE & Required<Pick<FieldFormProps, "message" | "messageType" | "forceDisplayMessage">>;
|
|
42
|
-
export declare const getMessageInfo: ({ forceDisplayMessage, hasLostFocusOnce, hasFocus, memory, hasChange, message, messageType, }: GetMessageInfoProps) => Pick<FieldFormProps, "message" | "messageType">;
|
|
43
|
-
type EventWrapperProps = {
|
|
44
|
-
props: EventFunction;
|
|
45
|
-
} & Pick<AddPropsClone, "wrapper">;
|
|
46
|
-
export declare const eventWrapper: ({ wrapper, props }: EventWrapperProps) => {
|
|
47
|
-
onChange: (ev: BaseSyntheticEvent) => void;
|
|
48
|
-
onBlur: (ev: BaseSyntheticEvent) => void;
|
|
49
|
-
onFocus: (ev: BaseSyntheticEvent) => void;
|
|
50
|
-
};
|
|
51
|
-
type AddPropsClone = Omit<RenderChildrenProps, "children"> & {
|
|
52
|
-
child: ReactElement<Record<string, unknown>>;
|
|
53
|
-
classModifier: string;
|
|
54
|
-
name: string;
|
|
55
|
-
getMessageClassModifierFn?: typeof FormClassManager.getMessageClassModifier;
|
|
56
|
-
eventWrapperFn?: ({ wrapper, props }: EventWrapperProps) => {
|
|
57
|
-
onChange: (ev: BaseSyntheticEvent) => void;
|
|
58
|
-
onBlur: (ev: BaseSyntheticEvent) => void;
|
|
59
|
-
onFocus: (ev: BaseSyntheticEvent) => void;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export declare const addPropsClone: ({ message, messageType, classModifier, wrapper, child, name, getMessageClassModifierFn, eventWrapperFn, }: AddPropsClone) => {
|
|
63
|
-
isVisible: boolean;
|
|
64
|
-
message?: undefined;
|
|
65
|
-
classModifier?: undefined;
|
|
66
|
-
} | {
|
|
67
|
-
message: string | undefined;
|
|
68
|
-
isVisible?: undefined;
|
|
69
|
-
classModifier?: undefined;
|
|
70
|
-
} | {
|
|
71
|
-
classModifier: string;
|
|
72
|
-
isVisible?: undefined;
|
|
73
|
-
message?: undefined;
|
|
74
|
-
} | {
|
|
75
|
-
classModifier: string;
|
|
76
|
-
onChange: (ev: BaseSyntheticEvent) => void;
|
|
77
|
-
onBlur: (ev: BaseSyntheticEvent) => void;
|
|
78
|
-
onFocus: (ev: BaseSyntheticEvent) => void;
|
|
79
|
-
isVisible?: undefined;
|
|
80
|
-
message?: undefined;
|
|
81
|
-
} | {
|
|
82
|
-
onChange: (ev: BaseSyntheticEvent) => void;
|
|
83
|
-
onBlur: (ev: BaseSyntheticEvent) => void;
|
|
84
|
-
onFocus: (ev: BaseSyntheticEvent) => void;
|
|
85
|
-
isVisible?: undefined;
|
|
86
|
-
message?: undefined;
|
|
87
|
-
classModifier?: undefined;
|
|
88
|
-
} | {
|
|
89
|
-
isVisible?: undefined;
|
|
90
|
-
message?: undefined;
|
|
91
|
-
classModifier?: undefined;
|
|
92
|
-
};
|
|
93
|
-
type RenderChildrenProps = {
|
|
94
|
-
wrapper: EventFunction;
|
|
95
|
-
} & Partial<Pick<FieldFormProps, "children">> & ReturnType<typeof getMessageInfo>;
|
|
96
|
-
export declare const renderedChildren: ({ children, wrapper, message, messageType, }: RenderChildrenProps) => ReactNode;
|
|
97
|
-
/**
|
|
98
|
-
* @deprecated This component is deprecated and will be removed in future versions.
|
|
99
|
-
* This was an internal component used to manage the state of the form fields.
|
|
100
|
-
* It is not recommended to use it directly in your code as it is not a public API.
|
|
101
|
-
*/
|
|
102
|
-
export declare const FieldForm: ({ children, message, messageType, className, classModifier, forceDisplayMessage, setStateMemoryFn, onChangeByStateFn, setStateOnBlurFn, setStateOnFocusFn, initialState, }: FieldFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
103
|
-
export {};
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Children, cloneElement, isValidElement, useEffect, useRef, useState, } from "react";
|
|
3
|
-
import { getComponentClassName } from "../../../utilities";
|
|
4
|
-
import { FormClassManager } from "../FormClassManager";
|
|
5
|
-
import { MessageTypes } from "../MessageTypes";
|
|
6
|
-
const defaultClassName = "md-10";
|
|
7
|
-
const INITIAL_STATE = {
|
|
8
|
-
hasLostFocusOnce: false,
|
|
9
|
-
hasFocus: false,
|
|
10
|
-
hasChange: false,
|
|
11
|
-
memory: { message: "", messageType: MessageTypes.error },
|
|
12
|
-
};
|
|
13
|
-
export const setStateMemory = ({ message, messageType = MessageTypes.error }) => (prevState) => ({
|
|
14
|
-
...prevState,
|
|
15
|
-
memory: {
|
|
16
|
-
message,
|
|
17
|
-
messageType,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
export const setStateHasChange = () => (prevState) => ({
|
|
21
|
-
...prevState,
|
|
22
|
-
hasChange: true,
|
|
23
|
-
});
|
|
24
|
-
export const onChangeByState = (setState, stateHasChange, setStateHasChangeFn = setStateHasChange) => !stateHasChange && setState(setStateHasChangeFn());
|
|
25
|
-
export const setStateOnBlur = () => (prevState) => ({
|
|
26
|
-
...prevState,
|
|
27
|
-
hasLostFocusOnce: true,
|
|
28
|
-
hasFocus: false,
|
|
29
|
-
});
|
|
30
|
-
export const setStateOnFocus = ({ message, messageType = MessageTypes.error }) => (prevState) => ({
|
|
31
|
-
...prevState,
|
|
32
|
-
hasFocus: true,
|
|
33
|
-
memory: { message, messageType },
|
|
34
|
-
});
|
|
35
|
-
export const getMessageInfo = ({ forceDisplayMessage, hasLostFocusOnce, hasFocus, memory, hasChange, message, messageType, }) => {
|
|
36
|
-
const isDisplayMessage = hasLostFocusOnce || forceDisplayMessage || (hasChange && !hasFocus);
|
|
37
|
-
if (!isDisplayMessage) {
|
|
38
|
-
return {
|
|
39
|
-
message: "",
|
|
40
|
-
messageType: "",
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return hasFocus
|
|
44
|
-
? memory
|
|
45
|
-
: {
|
|
46
|
-
message,
|
|
47
|
-
messageType,
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export const eventWrapper = ({ wrapper, props }) => ({
|
|
51
|
-
onChange: (ev) => {
|
|
52
|
-
wrapper?.onChange?.(ev);
|
|
53
|
-
if (props.onChange) {
|
|
54
|
-
props.onChange(ev);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
onBlur: (ev) => {
|
|
58
|
-
wrapper?.onBlur?.(ev);
|
|
59
|
-
if (props.onBlur) {
|
|
60
|
-
props.onBlur(ev);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
onFocus: (ev) => {
|
|
64
|
-
wrapper?.onFocus?.(ev);
|
|
65
|
-
if (props.onFocus) {
|
|
66
|
-
props.onFocus(ev);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
export const addPropsClone = ({ message, messageType, classModifier, wrapper, child, name, getMessageClassModifierFn = FormClassManager.getMessageClassModifier, eventWrapperFn = eventWrapper, }) => {
|
|
71
|
-
const messageClassModifier = getMessageClassModifierFn(messageType, message, classModifier);
|
|
72
|
-
const displayName = child.type.displayName ?? name;
|
|
73
|
-
switch (displayName) {
|
|
74
|
-
case "HelpMessage":
|
|
75
|
-
return { isVisible: !message };
|
|
76
|
-
case "FieldError":
|
|
77
|
-
return { message };
|
|
78
|
-
case "FieldInput":
|
|
79
|
-
return { classModifier: messageClassModifier };
|
|
80
|
-
case "EnhancedInputRadio":
|
|
81
|
-
case "EnhancedInputCheckbox":
|
|
82
|
-
return {
|
|
83
|
-
...eventWrapperFn({ wrapper, props: child.props }),
|
|
84
|
-
classModifier: messageClassModifier,
|
|
85
|
-
};
|
|
86
|
-
case "EnhancedInput":
|
|
87
|
-
return {
|
|
88
|
-
...eventWrapperFn({ wrapper, props: child.props }),
|
|
89
|
-
};
|
|
90
|
-
default:
|
|
91
|
-
return {};
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
export const renderedChildren = ({ children, wrapper, message, messageType, }) => Children.map(children, (child) => {
|
|
95
|
-
if (!isValidElement(child) || typeof child.type === "string") {
|
|
96
|
-
return child;
|
|
97
|
-
}
|
|
98
|
-
const props = {
|
|
99
|
-
...child.props,
|
|
100
|
-
};
|
|
101
|
-
if (child.props.children) {
|
|
102
|
-
const subChildren = renderedChildren({
|
|
103
|
-
children: child.props
|
|
104
|
-
.children,
|
|
105
|
-
wrapper,
|
|
106
|
-
message,
|
|
107
|
-
messageType,
|
|
108
|
-
});
|
|
109
|
-
if (subChildren !== null) {
|
|
110
|
-
props.children = subChildren;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return cloneElement(child, {
|
|
114
|
-
...props,
|
|
115
|
-
...addPropsClone({
|
|
116
|
-
...child.type,
|
|
117
|
-
name: child.type.name,
|
|
118
|
-
message,
|
|
119
|
-
messageType,
|
|
120
|
-
classModifier: props.classModifier,
|
|
121
|
-
wrapper,
|
|
122
|
-
child: child,
|
|
123
|
-
}),
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated This component is deprecated and will be removed in future versions.
|
|
128
|
-
* This was an internal component used to manage the state of the form fields.
|
|
129
|
-
* It is not recommended to use it directly in your code as it is not a public API.
|
|
130
|
-
*/
|
|
131
|
-
export const FieldForm = ({ children, message = "", messageType = MessageTypes.error, className = defaultClassName, classModifier = "", forceDisplayMessage = false, setStateMemoryFn = setStateMemory, onChangeByStateFn = onChangeByState, setStateOnBlurFn = setStateOnBlur, setStateOnFocusFn = setStateOnFocus, initialState = INITIAL_STATE, }) => {
|
|
132
|
-
const [state, setState] = useState(initialState);
|
|
133
|
-
const previousForceDisplayMessage = useRef(forceDisplayMessage);
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
if (previousForceDisplayMessage.current !== forceDisplayMessage) {
|
|
136
|
-
setState(setStateMemoryFn({ message, messageType }));
|
|
137
|
-
}
|
|
138
|
-
}, [
|
|
139
|
-
forceDisplayMessage,
|
|
140
|
-
message,
|
|
141
|
-
messageType,
|
|
142
|
-
previousForceDisplayMessage,
|
|
143
|
-
setState,
|
|
144
|
-
setStateMemoryFn,
|
|
145
|
-
]);
|
|
146
|
-
// for particular case on particular browers which does not throw onFocus or onBlur event
|
|
147
|
-
const onChange = () => onChangeByStateFn(setState, state?.hasChange);
|
|
148
|
-
const onBlur = () => setState(setStateOnBlurFn());
|
|
149
|
-
const onFocus = () => setState(setStateOnFocusFn({ message, messageType }));
|
|
150
|
-
const childrenCloned = renderedChildren({
|
|
151
|
-
children,
|
|
152
|
-
wrapper: { onFocus, onChange, onBlur },
|
|
153
|
-
...getMessageInfo({
|
|
154
|
-
...state,
|
|
155
|
-
forceDisplayMessage,
|
|
156
|
-
message,
|
|
157
|
-
messageType,
|
|
158
|
-
}),
|
|
159
|
-
});
|
|
160
|
-
const subComponentClassName = getComponentClassName(className, classModifier, defaultClassName);
|
|
161
|
-
return _jsx("div", { className: subComponentClassName, children: childrenCloned });
|
|
162
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
type FieldProps = {
|
|
3
|
-
isVisible?: boolean;
|
|
4
|
-
className?: string;
|
|
5
|
-
classModifier?: string;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This component is deprecated and will be removed in future versions.
|
|
10
|
-
* This was an internal component and it is not recommended to use it directly in your code as it is not a public API.
|
|
11
|
-
*/
|
|
12
|
-
export declare const FieldInput: {
|
|
13
|
-
({ children, className, classModifier, isVisible, }: FieldProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
-
displayName: string;
|
|
15
|
-
};
|
|
16
|
-
export {};
|