@axa-fr/design-system-look-and-feel-react 1.0.5-ci.66 → 1.0.5-ci.68

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.
@@ -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 Option = {
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<SelectInstance<unknown, boolean, GroupBase<unknown>>>>;
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, disabled, label, errorLabel, noOptionsMessage, ...otherProps }, inputRef) => {
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
- return (_jsxs("div", { children: [label && (_jsxs("label", { htmlFor: inputId, className: "af-form__select-label", children: [label, required && _jsx("span", { "aria-hidden": "true", children: " *" })] })), _jsx(ReactSelect, { inputId: inputId, "aria-errormessage": idError, "aria-invalid": Boolean(errorLabel), ariaLiveMessages: defaultAriaLiveMessages, screenReaderStatus: ({ count }) => `${count} résultat${count > 1 ? "s" : ""} disponible${count > 1 ? "s" : ""}`, unstyled: true, isDisabled: disabled, noOptionsMessage: () => noOptionsMessage || "Aucun résultat", components: {
15
- DropdownIndicator,
16
- Option: CustomOption,
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 };
@@ -1,6 +1,7 @@
1
+ import { type ReactNode } from "react";
1
2
  type ContentItemDuoProps = {
2
3
  label: string;
3
- value: string;
4
+ value: ReactNode;
4
5
  isVertical?: boolean;
5
6
  className?: string;
6
7
  classModifier?: string;
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import checkIcon from "@material-symbols/svg-400/outlined/check.svg";
3
3
  import closeIcon from "@material-symbols/svg-400/outlined/close.svg";
4
4
  import { useMemo } from "react";
5
+ import { Button, Svg } from "../..";
5
6
  import { Variants } from "../../Button/Button";
6
7
  import { getComponentClassName } from "../../utilities";
7
- import { Button, Svg } from "../..";
8
8
  export const ContentItemDuo = ({ label, value, isVertical = false, className, classModifier, isShowingDoneIcon = false, isShowingCloseIcon = false, buttonText, onButtonClick, }) => {
9
9
  const componentClassName = useMemo(() => {
10
10
  const classModifiers = [classModifier];
@@ -14,5 +14,5 @@ export const ContentItemDuo = ({ label, value, isVertical = false, className, cl
14
14
  return getComponentClassName("af-content-item-duo", className, classModifiers.filter(Boolean).join(" "));
15
15
  }, [classModifier, className, isVertical]);
16
16
  const iconContainerModifier = useMemo(() => ` af-content-item-duo__icon--${isShowingDoneIcon ? "done" : "close"}`, [isShowingDoneIcon]);
17
- return (_jsxs("div", { className: componentClassName, children: [(isShowingDoneIcon || isShowingCloseIcon) && (_jsxs("div", { className: `af-content-item-duo__icon${iconContainerModifier}`, children: [isShowingDoneIcon && _jsx(Svg, { src: checkIcon }), isShowingCloseIcon && _jsx(Svg, { src: closeIcon })] })), _jsx("p", { className: "af-content-item-duo__label", children: label }), _jsx("p", { className: "af-content-item-duo__value", children: value }), buttonText && (_jsx("div", { className: "af-content-item-duo__button", children: _jsx(Button, { variant: Variants.ghost, onClick: onButtonClick, children: buttonText }) }))] }));
17
+ return (_jsxs("div", { className: componentClassName, children: [(isShowingDoneIcon || isShowingCloseIcon) && (_jsxs("div", { className: `af-content-item-duo__icon${iconContainerModifier}`, children: [isShowingDoneIcon && _jsx(Svg, { src: checkIcon }), isShowingCloseIcon && _jsx(Svg, { src: closeIcon })] })), _jsx("p", { className: "af-content-item-duo__label", children: label }), typeof value === "string" ? (_jsx("p", { className: "af-content-item-duo__value", children: value })) : (_jsx("div", { className: "af-content-item-duo__value", children: value })), buttonText && (_jsx("div", { className: "af-content-item-duo__button", children: _jsx(Button, { variant: Variants.ghost, onClick: onButtonClick, children: buttonText }) }))] }));
18
18
  };
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.66",
3
+ "version": "1.0.5-ci.68",
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.66",
47
+ "@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.68",
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,4 +0,0 @@
1
- import React from "react";
2
- import { OptionProps } from "react-select";
3
- declare const CustomOption: React.FC<OptionProps>;
4
- export { CustomOption };
@@ -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,4 +0,0 @@
1
- import React from "react";
2
- import { DropdownIndicatorProps } from "react-select";
3
- declare const DropdownIndicator: React.FC<DropdownIndicatorProps>;
4
- export { DropdownIndicator };
@@ -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
- };