@axa-fr/canopee-react 2.0.0-alpha.93 → 2.0.1-alpha.2

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,27 @@
1
+ import type { SVGAttributes } from "react";
2
+ type AccessibilityInput = Pick<SVGAttributes<SVGSVGElement>, "aria-label" | "aria-labelledby"> & {
3
+ alt?: string;
4
+ };
5
+ /**
6
+ * An icon with a non-empty alt is an image named by it; an icon without alt,
7
+ * aria-label or aria-labelledby is decorative and hidden from assistive
8
+ * technologies. Explicit props are spread afterwards and take precedence.
9
+ */
10
+ export declare const getAccessibilityProps: ({ alt, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: AccessibilityInput) => {
11
+ role: string;
12
+ "aria-label": string;
13
+ "aria-hidden"?: undefined;
14
+ focusable?: undefined;
15
+ } | {
16
+ role?: undefined;
17
+ "aria-label"?: undefined;
18
+ "aria-hidden"?: undefined;
19
+ focusable?: undefined;
20
+ } | {
21
+ role: string;
22
+ "aria-hidden": boolean;
23
+ focusable: boolean;
24
+ "aria-label"?: undefined;
25
+ };
26
+ export declare const cloneAttributes: (from: HTMLElement | SVGSVGElement, to: HTMLElement | SVGSVGElement) => void;
27
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * An icon with a non-empty alt is an image named by it; an icon without alt,
3
+ * aria-label or aria-labelledby is decorative and hidden from assistive
4
+ * technologies. Explicit props are spread afterwards and take precedence.
5
+ */
6
+ export const getAccessibilityProps = ({ alt, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }) => {
7
+ if (alt) {
8
+ return { role: "img", "aria-label": alt };
9
+ }
10
+ if (ariaLabel || ariaLabelledBy) {
11
+ return {};
12
+ }
13
+ return { role: "presentation", "aria-hidden": true, focusable: false };
14
+ };
15
+ export const cloneAttributes = (from, to) => {
16
+ const attributes = from.getAttributeNames();
17
+ attributes.forEach((attribute) => {
18
+ to.setAttribute(attribute, from.getAttribute(attribute));
19
+ });
20
+ };
@@ -1,12 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useLayoutEffect, useRef, useState, } from "react";
3
+ import { cloneAttributes, getAccessibilityProps } from "./Svg.helpers";
3
4
  import { svgInjector } from "./svgInjector";
4
- const cloneAttributes = (from, to) => {
5
- const attributes = from.getAttributeNames();
6
- attributes.forEach((attribute) => {
7
- to.setAttribute(attribute, from.getAttribute(attribute));
8
- });
9
- };
10
5
  export const Svg = ({ src, alt, width = 24, height = 24, ...props }) => {
11
6
  const rootRef = useRef(null);
12
7
  const [hasError, setHasError] = useState(false);
@@ -46,5 +41,5 @@ export const Svg = ({ src, alt, width = 24, height = 24, ...props }) => {
46
41
  if (hasError) {
47
42
  return alt ? (_jsx("span", { ...props, children: alt })) : null;
48
43
  }
49
- return _jsx("svg", { ref: rootRef, "data-src": src, role: "presentation", ...props });
44
+ return (_jsx("svg", { ref: rootRef, "data-src": src, ...getAccessibilityProps({ alt, ...props }), ...props }));
50
45
  };
@@ -0,0 +1,7 @@
1
+ import "@axa-fr/canopee-css/distributeur/VisuallyHidden/VisuallyHidden.css";
2
+ import type { ComponentProps } from "react";
3
+ /**
4
+ * Text announced by assistive technologies but not displayed.
5
+ * Internal helper: not exported by the package entry points.
6
+ */
7
+ export declare const VisuallyHidden: (props: Omit<ComponentProps<"span">, "className" | "style">) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "@axa-fr/canopee-css/distributeur/VisuallyHidden/VisuallyHidden.css";
3
+ /**
4
+ * Text announced by assistive technologies but not displayed.
5
+ * Internal helper: not exported by the package entry points.
6
+ */
7
+ export const VisuallyHidden = (props) => _jsx("span", { className: "af-visually-hidden", ...props });
@@ -1,7 +1,5 @@
1
1
  import { type ComponentProps } from "react";
2
2
  export type CheckboxProps = {
3
- /** @deprecated Use `aria-errormessage` instead */
4
- errorId?: string;
5
3
  variant?: "error" | "warning";
6
4
  } & Omit<ComponentProps<"input">, "disabled" | "type">;
7
- export declare const Checkbox: ({ errorId, variant, className, ref, ...inputProps }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Checkbox: ({ variant, className, ref, ...inputProps }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import {} from "react";
3
3
  import { getClassName } from "../../../utilities/getClassName";
4
- export const Checkbox = ({ errorId, variant, className, ref, ...inputProps }) => (_jsx("input", { "aria-errormessage": errorId, "aria-invalid": variant === "error" || undefined, ...inputProps, className: getClassName({
4
+ export const Checkbox = ({ variant, className, ref, ...inputProps }) => (_jsx("input", { "aria-invalid": variant === "error" || undefined, ...inputProps, className: getClassName({
5
5
  baseClassName: "af-checkbox",
6
6
  modifiers: [variant],
7
7
  className,
@@ -0,0 +1,27 @@
1
+ import type { SVGAttributes } from "react";
2
+ type AccessibilityInput = Pick<SVGAttributes<SVGSVGElement>, "aria-label" | "aria-labelledby"> & {
3
+ alt?: string;
4
+ };
5
+ /**
6
+ * An icon with a non-empty alt is an image named by it; an icon without alt,
7
+ * aria-label or aria-labelledby is decorative and hidden from assistive
8
+ * technologies. Explicit props are spread afterwards and take precedence.
9
+ */
10
+ export declare const getAccessibilityProps: ({ alt, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: AccessibilityInput) => {
11
+ role: string;
12
+ "aria-label": string;
13
+ "aria-hidden"?: undefined;
14
+ focusable?: undefined;
15
+ } | {
16
+ role?: undefined;
17
+ "aria-label"?: undefined;
18
+ "aria-hidden"?: undefined;
19
+ focusable?: undefined;
20
+ } | {
21
+ "aria-hidden": boolean;
22
+ focusable: boolean;
23
+ role?: undefined;
24
+ "aria-label"?: undefined;
25
+ };
26
+ export declare const cloneAttributes: (from: HTMLElement | SVGSVGElement, to: HTMLElement | SVGSVGElement) => void;
27
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * An icon with a non-empty alt is an image named by it; an icon without alt,
3
+ * aria-label or aria-labelledby is decorative and hidden from assistive
4
+ * technologies. Explicit props are spread afterwards and take precedence.
5
+ */
6
+ export const getAccessibilityProps = ({ alt, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }) => {
7
+ if (alt) {
8
+ return { role: "img", "aria-label": alt };
9
+ }
10
+ if (ariaLabel || ariaLabelledBy) {
11
+ return {};
12
+ }
13
+ return { "aria-hidden": true, focusable: false };
14
+ };
15
+ export const cloneAttributes = (from, to) => {
16
+ const attributes = from.getAttributeNames();
17
+ attributes.forEach((attribute) => {
18
+ to.setAttribute(attribute, from.getAttribute(attribute));
19
+ });
20
+ };
@@ -1,13 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import "@axa-fr/canopee-css/prospect/Svg/Svg.css";
3
3
  import React, {} from "react";
4
+ import { cloneAttributes, getAccessibilityProps } from "./Svg.helpers";
4
5
  import { svgInjector } from "./svgInjector";
5
- const cloneAttributes = (from, to) => {
6
- const attributes = from.getAttributeNames();
7
- attributes.forEach((attribute) => {
8
- to.setAttribute(attribute, from.getAttribute(attribute));
9
- });
10
- };
11
6
  /**
12
7
  * @deprecated Use Icon instead
13
8
  */
@@ -50,5 +45,5 @@ export const Svg = ({ className, src, alt, width = 24, height = 24, ...props })
50
45
  if (hasError) {
51
46
  return alt ? (_jsx("span", { ...props, children: alt })) : null;
52
47
  }
53
- return (_jsx("svg", { ref: rootRef, className: ["af-svg", className].filter(Boolean).join(" "), "data-src": src, width: width, height: height, ...props }));
48
+ return (_jsx("svg", { ref: rootRef, className: ["af-svg", className].filter(Boolean).join(" "), "data-src": src, width: width, height: height, ...getAccessibilityProps({ alt, ...props }), ...props }));
54
49
  };
@@ -0,0 +1,7 @@
1
+ import "@axa-fr/canopee-css/client/VisuallyHidden/VisuallyHiddenAll.css";
2
+ import type { ComponentProps } from "react";
3
+ /**
4
+ * Text announced by assistive technologies but not displayed.
5
+ * Internal helper: not exported by the package entry points.
6
+ */
7
+ export declare const VisuallyHidden: (props: Omit<ComponentProps<"span">, "className" | "style">) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "@axa-fr/canopee-css/client/VisuallyHidden/VisuallyHiddenAll.css";
3
+ /**
4
+ * Text announced by assistive technologies but not displayed.
5
+ * Internal helper: not exported by the package entry points.
6
+ */
7
+ export const VisuallyHidden = (props) => _jsx("span", { className: "af-visually-hidden", ...props });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/canopee-react",
3
- "version": "2.0.0-alpha.93",
3
+ "version": "2.0.1-alpha.2",
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.93",
56
+ "@axa-fr/canopee-css": "2.0.1-alpha.2",
57
57
  "@material-symbols/svg-400": ">= 0.19.0",
58
58
  "@material-symbols/svg-700": ">= 0.19.0",
59
59
  "react": ">= 19"