@axa-fr/design-system-apollo-react 1.0.5-alpha.463 → 1.0.5-alpha.465

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.
@@ -10,6 +10,7 @@ export declare const InputDate: import("react").ForwardRefExoticComponent<Omit<O
10
10
  helper?: string;
11
11
  error?: string;
12
12
  success?: string;
13
+ hidePicker?: boolean;
13
14
  label: ComponentProps<typeof import("../ItemLabel/ItemLabelCommon").ItemLabel>["label"];
14
15
  ItemLabelComponent: import("react").ComponentType<Omit<ComponentProps<typeof import("../ItemLabel/ItemLabelCommon").ItemLabel>, "ButtonComponent">>;
15
16
  ItemMessageComponent: import("react").ComponentType<ComponentProps<typeof ItemMessage>>;
@@ -10,6 +10,7 @@ type InputDateProps = Omit<ComponentPropsWithRef<"input">, "value" | "min" | "ma
10
10
  helper?: string;
11
11
  error?: string;
12
12
  success?: string;
13
+ hidePicker?: boolean;
13
14
  label: ComponentProps<typeof ItemLabel>["label"];
14
15
  ItemLabelComponent: ComponentType<Omit<ComponentProps<typeof ItemLabel>, "ButtonComponent">>;
15
16
  ItemMessageComponent: ComponentType<ComponentProps<typeof ItemMessage>>;
@@ -1,14 +1,33 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useId, } from "react";
2
+ import { forwardRef, useEffect, useId, } from "react";
3
3
  import { getComponentClassName } from "../../utilities/getComponentClassName";
4
4
  import { formatInputDateValue } from "./InputDate.helper";
5
- const InputDate = forwardRef(({ className, classModifier = "", defaultValue, value, helper, error, success, label, description, buttonLabel, onButtonClick, ItemLabelComponent, ItemMessageComponent, required, "aria-errormessage": ariaErrormessage, min, max, ...otherProps }, inputRef) => {
6
- const componentClassName = getComponentClassName("af-form__input-date", className ?? "", classModifier + (error || ariaErrormessage ? " error" : ""));
5
+ const InputDate = forwardRef(({ className, classModifier = "", defaultValue, value, helper, error, success, label, description, buttonLabel, onButtonClick, ItemLabelComponent, ItemMessageComponent, required, "aria-errormessage": ariaErrormessage, min, max, hidePicker, ...otherProps }, inputRef) => {
6
+ const componentClassName = getComponentClassName("af-form__input-date", className ?? "", `${classModifier}${hidePicker ? " no-picker" : ""}`);
7
7
  let inputId = useId();
8
8
  inputId = otherProps.id ?? inputId;
9
9
  const idMessage = useId();
10
10
  const idHelp = useId();
11
11
  const ariaDescribedby = [helper && idHelp, success && idMessage].filter(Boolean);
12
+ /* Stop keydown (space and enter) and click events for Firefox when picker is disabled */
13
+ useEffect(() => {
14
+ function handleKeydown(event) {
15
+ if (hidePicker && (event.keyCode === 13 || event.keyCode === 32)) {
16
+ event.preventDefault();
17
+ }
18
+ }
19
+ function handleClick(event) {
20
+ if (hidePicker) {
21
+ event.preventDefault();
22
+ }
23
+ }
24
+ window.addEventListener("keydown", handleKeydown);
25
+ window.addEventListener("click", handleClick);
26
+ return () => {
27
+ window.removeEventListener("keydown", handleKeydown);
28
+ window.removeEventListener("click", handleClick);
29
+ };
30
+ }, [hidePicker]);
12
31
  return (_jsxs("div", { className: "af-form__input-container", children: [_jsx(ItemLabelComponent, { label: label, description: description, buttonLabel: buttonLabel, onButtonClick: onButtonClick, required: required, inputId: inputId }), _jsx("input", { ...otherProps, id: inputId, className: componentClassName, type: "date", ref: inputRef, defaultValue: formatInputDateValue(defaultValue), value: formatInputDateValue(value), "aria-errormessage": ariaErrormessage ?? (error ? idMessage : undefined), "aria-invalid": Boolean(error ?? ariaErrormessage), "aria-describedby": ariaDescribedby.length > 0 ? ariaDescribedby.join(" ") : undefined, required: required, min: formatInputDateValue(min), max: formatInputDateValue(max) }), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: error || success, messageType: error ? "error" : "success" })] }));
13
32
  });
14
33
  InputDate.displayName = "InputDate";
@@ -10,6 +10,7 @@ export declare const InputDate: import("react").ForwardRefExoticComponent<Omit<O
10
10
  helper?: string;
11
11
  error?: string;
12
12
  success?: string;
13
+ hidePicker?: boolean;
13
14
  label: ComponentProps<typeof import("../ItemLabel/ItemLabelCommon").ItemLabel>["label"];
14
15
  ItemLabelComponent: import("react").ComponentType<Omit<ComponentProps<typeof import("../ItemLabel/ItemLabelCommon").ItemLabel>, "ButtonComponent">>;
15
16
  ItemMessageComponent: import("react").ComponentType<ComponentProps<typeof ItemMessage>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-apollo-react",
3
- "version": "1.0.5-alpha.463",
3
+ "version": "1.0.5-alpha.465",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "homepage": "https://github.com/AxaFrance/design-system#readme",
48
48
  "peerDependencies": {
49
- "@axa-fr/design-system-apollo-css": "1.0.5-alpha.463",
50
- "@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.463",
49
+ "@axa-fr/design-system-apollo-css": "1.0.5-alpha.465",
50
+ "@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.465",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },