@axa-fr/design-system-apollo-react 2.0.4-alpha.15 → 2.0.4-alpha.16

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,4 +1,4 @@
1
- import { ComponentProps, ComponentPropsWithRef, ComponentType } from "react";
1
+ import { type ComponentProps, type ComponentPropsWithRef, type ComponentType } from "react";
2
2
  import { ItemLabelCommon, type ItemLabelProps } from "../ItemLabel/ItemLabelCommon";
3
3
  import { ItemMessage, type ItemMessageProps } from "../ItemMessage/ItemMessageCommon";
4
4
  export type InputDateProps = Omit<ComponentPropsWithRef<"input">, "value" | "min" | "max"> & {
@@ -1,23 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useId, } from "react";
2
+ import { forwardRef, useEffect, useId, useImperativeHandle, useRef, } from "react";
3
3
  import { getComponentClassName } from "../../utilities/getComponentClassName";
4
4
  import { formatInputDateValue } from "./InputDate.helper";
5
- const InputDateCommon = forwardRef(({ className, classModifier = "", defaultValue, value, helper, error, success, message, messageType, label, description, buttonLabel, onButtonClick, ItemLabelComponent, ItemMessageComponent, required, min, max, hidePicker, ...otherProps }, inputRef) => {
5
+ const InputDateCommon = forwardRef(({ className, classModifier = "", defaultValue, value, helper, error, success, message, messageType, label, description, buttonLabel, onButtonClick, ItemLabelComponent, ItemMessageComponent, required, min, max, hidePicker, ...otherProps }, ref) => {
6
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
+ const inputRef = useRef(null);
12
+ useImperativeHandle(ref, () => inputRef.current);
11
13
  const ariaDescribedby = [helper && idHelp, success && idMessage].filter(Boolean);
12
- /* Stop keydown (space and enter) and click events for Firefox when picker is disabled */
14
+ /* Stop space keydown, enter keydown for non webkit browsers and click events targeting the input element when picker is disabled */
13
15
  useEffect(() => {
14
16
  function handleKeydown(event) {
15
- if (hidePicker && (event.keyCode === 13 || event.keyCode === 32)) {
17
+ if (hidePicker &&
18
+ (event.keyCode === 32 ||
19
+ (event.keyCode === 13 &&
20
+ !window.navigator?.userAgent?.includes("WebKit"))) &&
21
+ event.target === inputRef.current) {
16
22
  event.preventDefault();
17
23
  }
18
24
  }
19
25
  function handleClick(event) {
20
- if (hidePicker) {
26
+ if (hidePicker && event.target === inputRef.current) {
21
27
  event.preventDefault();
22
28
  }
23
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-apollo-react",
3
- "version": "2.0.4-alpha.15",
3
+ "version": "2.0.4-alpha.16",
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": "2.0.4-alpha.15",
50
- "@axa-fr/design-system-look-and-feel-css": "2.0.4-alpha.15",
49
+ "@axa-fr/design-system-apollo-css": "2.0.4-alpha.16",
50
+ "@axa-fr/design-system-look-and-feel-css": "2.0.4-alpha.16",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },