@axa-fr/design-system-look-and-feel-react 1.0.5-ci.66 → 1.0.5-ci.67
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/Select/Select.d.ts +2 -16
- package/dist/Form/Select/Select.js +4 -20
- package/package.json +3 -4
- package/dist/Form/Select/CustomOption.d.ts +0 -4
- package/dist/Form/Select/CustomOption.js +0 -8
- package/dist/Form/Select/DropdownIndicator.d.ts +0 -4
- package/dist/Form/Select/DropdownIndicator.js +0 -11
- package/dist/Form/Select/arialiveMessagesDefault.d.ts +0 -7
- package/dist/Form/Select/arialiveMessagesDefault.js +0 -53
@@ -1,24 +1,10 @@
|
|
1
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Select/Select.scss";
|
2
|
-
import ReactSelect, { ActionMeta, GroupBase, SelectInstance, SingleValue } from "react-select";
|
3
2
|
import { ComponentPropsWithRef } from "react";
|
4
|
-
type
|
5
|
-
label: string;
|
6
|
-
value: string | number;
|
7
|
-
};
|
8
|
-
type Props = Omit<ComponentPropsWithRef<ReactSelect>, "placeholder" | "noOptionsMessage"> & {
|
3
|
+
type Props = ComponentPropsWithRef<"select"> & {
|
9
4
|
id?: string;
|
10
5
|
label?: string;
|
11
|
-
options: {
|
12
|
-
label: string;
|
13
|
-
value?: string | number | readonly string[];
|
14
|
-
}[];
|
15
|
-
value: Option | null;
|
16
6
|
errorLabel?: string;
|
17
7
|
placeholder?: string;
|
18
|
-
noOptionsMessage?: string;
|
19
|
-
onChange: (newValue: SingleValue<Option>, actionMeta: ActionMeta<string>) => void;
|
20
|
-
disabled?: boolean;
|
21
|
-
required?: boolean;
|
22
8
|
};
|
23
|
-
declare const Select: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<
|
9
|
+
declare const Select: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLSelectElement>>;
|
24
10
|
export { Select };
|
@@ -1,31 +1,15 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Select/Select.scss";
|
3
|
-
import ReactSelect from "react-select";
|
4
3
|
import { forwardRef, useId } from "react";
|
5
4
|
import classNames from "classnames";
|
6
|
-
import { DropdownIndicator } from "./DropdownIndicator";
|
7
|
-
import { CustomOption } from "./CustomOption";
|
8
|
-
import { defaultAriaLiveMessages } from "./arialiveMessagesDefault";
|
9
5
|
import { InputError } from "../InputError";
|
10
|
-
const Select = forwardRef(({ id, required,
|
6
|
+
const Select = forwardRef(({ id, required, label, errorLabel, placeholder, children, ...otherProps }, inputRef) => {
|
11
7
|
const idError = useId();
|
12
8
|
let inputId = useId();
|
13
9
|
inputId = id || inputId;
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}, classNames: {
|
18
|
-
control: () => "af-form__input-select",
|
19
|
-
menu: () => "af-form__input-select-menu",
|
20
|
-
menuList: () => "af-form__select-menu-list",
|
21
|
-
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 &&
|
22
|
-
!isFocused &&
|
23
|
-
!menuIsOpen &&
|
24
|
-
"af-form__input-select-container-error"),
|
25
|
-
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"),
|
26
|
-
singleValue: ({ isDisabled, }) => classNames("af-form__select-single-value", isDisabled && "af-form__select-single-value-disabled"),
|
27
|
-
dropdownIndicator: () => "af-form__select-dropdown-indicator",
|
28
|
-
}, className: "af-form__input-select", ...otherProps, ref: inputRef }), errorLabel && _jsx(InputError, { id: idError, message: errorLabel })] }));
|
10
|
+
const isShowingPlaceholder = otherProps.value === "";
|
11
|
+
const classname = classNames("af-form__select-input", errorLabel && "af-form__select-input--error", isShowingPlaceholder && "af-form__select-input-placeholder");
|
12
|
+
return (_jsxs("div", { children: [label && (_jsxs("label", { htmlFor: inputId, className: "af-form__select-label", children: [label, required && _jsx("span", { "aria-hidden": "true", children: " *" })] })), _jsxs("select", { className: classname, ...otherProps, ref: inputRef, id: inputId, children: [Boolean(placeholder) && (_jsx("option", { disabled: true, value: "", children: placeholder })), children] }), errorLabel && _jsx(InputError, { id: idError, message: errorLabel })] }));
|
29
13
|
});
|
30
14
|
Select.displayName = "Select";
|
31
15
|
export { Select };
|
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.
|
3
|
+
"version": "1.0.5-ci.67",
|
4
4
|
"description": "",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
},
|
45
45
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
46
46
|
"peerDependencies": {
|
47
|
-
"@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.
|
47
|
+
"@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.67",
|
48
48
|
"@material-symbols/svg-400": ">= 0.19.0",
|
49
49
|
"react": ">= 18"
|
50
50
|
},
|
@@ -58,8 +58,7 @@
|
|
58
58
|
"@tanem/svg-injector": "^10.1.68",
|
59
59
|
"classnames": "^2.5.1",
|
60
60
|
"dompurify": "^3.1.5",
|
61
|
-
"rc-slider": "^11.1.7"
|
62
|
-
"react-select": "^5.9.0"
|
61
|
+
"rc-slider": "^11.1.7"
|
63
62
|
},
|
64
63
|
"lint-staged": {
|
65
64
|
"*.(js|jsx|ts|tsx)": "eslint --fix",
|
@@ -1,8 +0,0 @@
|
|
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 };
|
@@ -1,11 +0,0 @@
|
|
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 };
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { AriaGuidanceProps, AriaOnChangeProps, AriaOnFilterProps, AriaOnFocusProps, GroupBase } from "react-select";
|
2
|
-
export declare const defaultAriaLiveMessages: {
|
3
|
-
guidance: (props: AriaGuidanceProps) => string;
|
4
|
-
onChange: <Option, IsMulti extends boolean>(props: AriaOnChangeProps<Option, IsMulti>) => string;
|
5
|
-
onFocus: <Option, Group extends GroupBase<Option>>(props: AriaOnFocusProps<Option, Group>) => string;
|
6
|
-
onFilter: (props: AriaOnFilterProps) => string;
|
7
|
-
};
|
@@ -1,53 +0,0 @@
|
|
1
|
-
export const defaultAriaLiveMessages = {
|
2
|
-
guidance: (props) => {
|
3
|
-
const { isSearchable, isMulti, tabSelectsValue, context, isInitialFocus } = props;
|
4
|
-
switch (context) {
|
5
|
-
case "menu":
|
6
|
-
return `Utilisez les flèches Haut et Bas pour choisir des options, appuyez sur Entrée pour sélectionner l'option actuellement mise au point, appuyez sur Échap pour quitter le menu${tabSelectsValue ? ", appuyez sur Tab pour sélectionner l'option et quitter le menu" : ""}.`;
|
7
|
-
case "input":
|
8
|
-
return isInitialFocus
|
9
|
-
? `${props["aria-label"] || "Sélectionner"} est sélectionné ${isSearchable ? ", tapez du texte pour affiner la liste" : ""}, appuyez sur Bas pour ouvrir le menu, ${isMulti ? " appuyez sur Gauche pour mettre au point les valeurs sélectionnées" : ""}`
|
10
|
-
: "";
|
11
|
-
case "value":
|
12
|
-
return "Utilisez les flèches Gauche et Droite pour basculer entre les valeurs sélectionnées, appuyez sur Retour arrière pour supprimer la valeur actuellement sélectionnée.";
|
13
|
-
default:
|
14
|
-
return "";
|
15
|
-
}
|
16
|
-
},
|
17
|
-
onChange: (props) => {
|
18
|
-
const { action, label = "", labels, isDisabled } = props;
|
19
|
-
switch (action) {
|
20
|
-
case "deselect-option":
|
21
|
-
case "pop-value":
|
22
|
-
case "remove-value":
|
23
|
-
return `option ${label}, désélectionnée.`;
|
24
|
-
case "clear":
|
25
|
-
return "Toutes les options sélectionnées ont été effacées.";
|
26
|
-
case "initial-input-focus":
|
27
|
-
return `${labels.length > 1 ? "les " : "l'"}option${labels.length > 1 ? "s" : ""} ${labels.join(",")} ${labels.length > 1 ? "sont" : "est"} sélectionnée${labels.length > 1 ? "s" : ""}.`;
|
28
|
-
case "select-option":
|
29
|
-
return isDisabled
|
30
|
-
? `l'option ${label} est désactivée. Sélectionnez une autre option.`
|
31
|
-
: `l'option ${label} est sélectionnée.`;
|
32
|
-
default:
|
33
|
-
return "";
|
34
|
-
}
|
35
|
-
},
|
36
|
-
onFocus: (props) => {
|
37
|
-
const { context, focused, options, label = "", selectValue, isDisabled, isSelected, isAppleDevice, } = props;
|
38
|
-
const getArrayIndex = (arr, item) => arr && arr.length ? `${arr.indexOf(item) + 1} sur ${arr.length}` : "";
|
39
|
-
if (context === "value" && selectValue) {
|
40
|
-
return `la valeur ${label} est sélectionnée, ${getArrayIndex(selectValue, focused)}.`;
|
41
|
-
}
|
42
|
-
if (context === "menu" && isAppleDevice) {
|
43
|
-
const disabled = isDisabled ? " désactivé" : "";
|
44
|
-
const status = `${isSelected ? " sélectionné" : ""}${disabled}`;
|
45
|
-
return `${label}${status}, ${getArrayIndex(options, focused)}.`;
|
46
|
-
}
|
47
|
-
return "";
|
48
|
-
},
|
49
|
-
onFilter: (props) => {
|
50
|
-
const { inputValue, resultsMessage } = props;
|
51
|
-
return `${resultsMessage}${inputValue ? ` pour le terme de recherche : ${inputValue}` : ""}.`;
|
52
|
-
},
|
53
|
-
};
|