@axa-fr/canopee-react 2.0.0-alpha.79 → 2.0.0-alpha.80

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.
@@ -0,0 +1,31 @@
1
+ import { type ComponentProps } from "react";
2
+ import { Input } from "./Input";
3
+ import type { InputBaseProps } from "./types";
4
+ export type DateInputProps = Omit<ComponentProps<typeof Input>, "children" | "type" | "value" | "defaultValue" | "min" | "max"> & InputBaseProps & {
5
+ /**
6
+ * The value of the date input, as a `Date` or an ISO date string (`YYYY-MM-DD`).
7
+ */
8
+ value?: Date | string;
9
+ /**
10
+ * The default value of the date input, as a `Date` or an ISO date string (`YYYY-MM-DD`).
11
+ */
12
+ defaultValue?: Date | string;
13
+ /**
14
+ * The earliest selectable date, as a `Date` or an ISO date string (`YYYY-MM-DD`).
15
+ */
16
+ min?: Date | string;
17
+ /**
18
+ * The latest selectable date, as a `Date` or an ISO date string (`YYYY-MM-DD`).
19
+ */
20
+ max?: Date | string;
21
+ };
22
+ /**
23
+ * This component renders a label, a date input field and optionnally help and error messages.
24
+ * It can be customized to render the label on top, or on the left of the input.
25
+ * It also supports adding a unit on the right of the input.
26
+ */
27
+ declare const DateInput: {
28
+ ({ contentRight, id, labelPosition, inputClassName: inputClassNameProp, labelClassName: labelClassNameProp, helpMessage, containerClassName, required, label, errorMessage, value, defaultValue, min, max, ...props }: DateInputProps): import("react/jsx-runtime").JSX.Element;
29
+ displayName: string;
30
+ };
31
+ export { DateInput };
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import {} from "react";
3
+ import { formatDateInputValue } from "../../utilities/helpers/date";
4
+ import { Input } from "./Input";
5
+ import { InputContainer } from "./InputContainer";
6
+ import { InputUnit } from "./InputUnit";
7
+ import { ItemMessage } from "./ItemMessage";
8
+ import { Label } from "./Label";
9
+ import { useInput } from "./useInput.hook";
10
+ /**
11
+ * This component renders a label, a date input field and optionnally help and error messages.
12
+ * It can be customized to render the label on top, or on the left of the input.
13
+ * It also supports adding a unit on the right of the input.
14
+ */
15
+ const DateInput = ({ contentRight, id, labelPosition, inputClassName: inputClassNameProp, labelClassName: labelClassNameProp, helpMessage, containerClassName, required, label, errorMessage, value, defaultValue, min, max, ...props }) => {
16
+ const { describedBy, errorId, helperId, inputClassName, inputId, isContainerVertical, isInvalid, labelClassName, } = useInput({
17
+ id,
18
+ labelPosition,
19
+ inputClassName: inputClassNameProp,
20
+ labelClassName: labelClassNameProp,
21
+ errorMessage,
22
+ helpMessage,
23
+ });
24
+ return (_jsxs(InputContainer, { vertical: isContainerVertical, className: containerClassName, children: [_jsx(Label, { htmlFor: inputId, required: required, className: labelClassName, children: label }), _jsx(Input, { ...props, type: "date", value: formatDateInputValue(value), defaultValue: formatDateInputValue(defaultValue), min: formatDateInputValue(min), max: formatDateInputValue(max), className: inputClassName, id: inputId, "aria-describedby": describedBy, "aria-invalid": isInvalid }), contentRight ? _jsx(InputUnit, { children: contentRight }) : null, helpMessage ? (_jsx(ItemMessage, { id: helperId, children: helpMessage })) : null, errorMessage ? (_jsx(ItemMessage, { variant: "error", id: errorId, children: errorMessage })) : null] }));
25
+ };
26
+ DateInput.displayName = "DateInput";
27
+ export { DateInput };
@@ -0,0 +1,8 @@
1
+ import "@axa-fr/canopee-css/distributeur/Form/Experimental/Input.css";
2
+ import "@axa-fr/canopee-css/distributeur/Form/Experimental/Select.css";
3
+ import { type ComponentPropsWithRef } from "react";
4
+ declare const Select: {
5
+ ({ className, children, ...otherProps }: ComponentPropsWithRef<"select">): import("react/jsx-runtime").JSX.Element;
6
+ displayName: string;
7
+ };
8
+ export { Select };
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import "@axa-fr/canopee-css/distributeur/Form/Experimental/Input.css";
3
+ import "@axa-fr/canopee-css/distributeur/Form/Experimental/Select.css";
4
+ import {} from "react";
5
+ import icon from "@material-symbols/svg-700/rounded/arrow_drop_down-fill.svg";
6
+ import { getClassName } from "../../utilities/helpers/getClassName";
7
+ import { Svg } from "../../Svg";
8
+ const Select = ({ className, children, ...otherProps }) => {
9
+ const componentClassName = getClassName({
10
+ baseClassName: "af-input__input",
11
+ className,
12
+ });
13
+ return (_jsxs(_Fragment, { children: [_jsx("select", { className: componentClassName, ...otherProps, children: children }), _jsx(Svg, { className: "af-input__select-icon", src: icon })] }));
14
+ };
15
+ Select.displayName = "Select";
16
+ export { Select };
@@ -0,0 +1,36 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ import { Select } from "./Select";
3
+ import type { InputBaseProps } from "./types";
4
+ export type SelectInputProps = Omit<ComponentProps<typeof Select>, "children"> & InputBaseProps & {
5
+ /**
6
+ * The content of the select, as JSX.
7
+ * This allows you to render `<option>` elements, and to group them with `<optgroup>`.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * options={
12
+ * <optgroup label="Europe">
13
+ * <option value="FR">France</option>
14
+ * <option value="ES">Spain</option>
15
+ * </optgroup>
16
+ * }
17
+ * ```
18
+ */
19
+ options: ReactNode;
20
+ /**
21
+ * The text of the empty option rendered before the options, when no value is selected.
22
+ * Pass `null` to not render any placeholder option.
23
+ * @default "- Select -"
24
+ */
25
+ placeholder?: string | null;
26
+ };
27
+ /**
28
+ * This component renders a label, a select field and optionnally help and error messages.
29
+ * It can be customized to render the label on top, or on the left of the select.
30
+ * It also supports adding a unit on the right of the select.
31
+ */
32
+ declare const SelectInput: {
33
+ ({ contentRight, id, labelPosition, inputClassName: inputClassNameProp, labelClassName: labelClassNameProp, helpMessage, containerClassName, required, label, errorMessage, options, placeholder, ...props }: SelectInputProps): import("react/jsx-runtime").JSX.Element;
34
+ displayName: string;
35
+ };
36
+ export { SelectInput };
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import {} from "react";
3
+ import { InputContainer } from "./InputContainer";
4
+ import { InputUnit } from "./InputUnit";
5
+ import { ItemMessage } from "./ItemMessage";
6
+ import { Label } from "./Label";
7
+ import { Select } from "./Select";
8
+ import { useInput } from "./useInput.hook";
9
+ /**
10
+ * This component renders a label, a select field and optionnally help and error messages.
11
+ * It can be customized to render the label on top, or on the left of the select.
12
+ * It also supports adding a unit on the right of the select.
13
+ */
14
+ const SelectInput = ({ contentRight, id, labelPosition, inputClassName: inputClassNameProp, labelClassName: labelClassNameProp, helpMessage, containerClassName, required, label, errorMessage, options, placeholder = "- Select -", ...props }) => {
15
+ const { describedBy, errorId, helperId, inputClassName, inputId, isContainerVertical, isInvalid, labelClassName, } = useInput({
16
+ id,
17
+ labelPosition,
18
+ inputClassName: inputClassNameProp,
19
+ labelClassName: labelClassNameProp,
20
+ errorMessage,
21
+ helpMessage,
22
+ });
23
+ return (_jsxs(InputContainer, { vertical: isContainerVertical, className: containerClassName, children: [_jsx(Label, { htmlFor: inputId, required: required, className: labelClassName, children: label }), _jsxs(Select, { ...props, className: inputClassName, id: inputId, "aria-describedby": describedBy, "aria-invalid": isInvalid, children: [placeholder === null ? null : _jsx("option", { value: "", children: placeholder }), options] }), contentRight ? _jsx(InputUnit, { children: contentRight }) : null, helpMessage ? (_jsx(ItemMessage, { id: helperId, children: helpMessage })) : null, errorMessage ? (_jsx(ItemMessage, { variant: "error", id: errorId, children: errorMessage })) : null] }));
24
+ };
25
+ SelectInput.displayName = "SelectInput";
26
+ export { SelectInput };
@@ -1,8 +1,13 @@
1
+ export { DateInput } from "./DateInput";
2
+ export type { DateInputProps } from "./DateInput";
1
3
  export { Input } from "./Input";
2
4
  export { InputContainer } from "./InputContainer";
3
5
  export { InputUnit } from "./InputUnit";
4
6
  export { ItemMessage } from "./ItemMessage";
5
7
  export { Label } from "./Label";
8
+ export { Select } from "./Select";
9
+ export { SelectInput } from "./SelectInput";
10
+ export type { SelectInputProps } from "./SelectInput";
6
11
  export { TextInput } from "./TextInput";
7
12
  export type { TextInputProps } from "./TextInput";
8
13
  export type { InputBaseProps, LabelPosition, SingleLineLabelPosition, } from "./types";
@@ -1,8 +1,11 @@
1
+ export { DateInput } from "./DateInput";
1
2
  export { Input } from "./Input";
2
3
  export { InputContainer } from "./InputContainer";
3
4
  export { InputUnit } from "./InputUnit";
4
5
  export { ItemMessage } from "./ItemMessage";
5
6
  export { Label } from "./Label";
7
+ export { Select } from "./Select";
8
+ export { SelectInput } from "./SelectInput";
6
9
  export { TextInput } from "./TextInput";
7
10
  export { useInput } from "./useInput.hook";
8
11
  export { RadioButton } from "./Radio/RadioButton";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/canopee-react",
3
- "version": "2.0.0-alpha.79",
3
+ "version": "2.0.0-alpha.80",
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.79",
56
+ "@axa-fr/canopee-css": "2.0.0-alpha.80",
57
57
  "@material-symbols/svg-400": ">= 0.19.0",
58
58
  "@material-symbols/svg-700": ">= 0.19.0",
59
59
  "react": ">= 19"