@axa-fr/design-system-apollo-react 1.0.3-alpha.144

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,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Button/ButtonApollo.scss";
2
+ export { Button, buttonVariants, type ButtonVariants } from "./ButtonCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Button/ButtonApollo.scss";
2
+ export { Button, buttonVariants } from "./ButtonCommon";
@@ -0,0 +1,19 @@
1
+ import type { ComponentPropsWithoutRef, PropsWithChildren, ReactNode } from "react";
2
+ export declare const buttonVariants: {
3
+ readonly primary: "primary";
4
+ readonly "primary-business": "primary-business";
5
+ readonly "primary-inverse": "primary-inverse";
6
+ readonly secondary: "secondary";
7
+ readonly "secondary-inverse": "secondary-inverse";
8
+ readonly tertiary: "tertiary";
9
+ readonly ghost: "ghost";
10
+ };
11
+ export type ButtonVariants = keyof typeof buttonVariants;
12
+ type ButtonProps = {
13
+ variant?: ButtonVariants;
14
+ iconLeft?: ReactNode;
15
+ iconRight?: ReactNode;
16
+ loading?: boolean;
17
+ } & ComponentPropsWithoutRef<"button">;
18
+ export declare const Button: ({ children, className, variant, iconLeft, iconRight, disabled, loading, ...args }: PropsWithChildren<ButtonProps>) => import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Spinner } from "../Spinner/SpinnerCommon";
3
+ export const buttonVariants = {
4
+ primary: "primary",
5
+ "primary-business": "primary-business",
6
+ "primary-inverse": "primary-inverse",
7
+ secondary: "secondary",
8
+ "secondary-inverse": "secondary-inverse",
9
+ tertiary: "tertiary",
10
+ ghost: "ghost",
11
+ };
12
+ export const Button = ({ children, className, variant = "primary", iconLeft, iconRight, disabled, loading, ...args }) => (_jsxs("button", { className: ["af-btn-client", `af-btn-client--${variant}`, className]
13
+ .filter(Boolean)
14
+ .join(" "), disabled: disabled || loading, type: "button", ...args, children: [iconLeft, children, iconRight, loading && _jsx(Spinner, { size: 24, variant: "gray" })] }));
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Button/ButtonLF.scss";
2
+ export { Button, buttonVariants, type ButtonVariants } from "./ButtonCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Button/ButtonLF.scss";
2
+ export { Button, buttonVariants } from "./ButtonCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Form/ItemMessage/ItemMessageApollo.scss";
2
+ export { ItemMessage } from "./ItemMessageCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Form/ItemMessage/ItemMessageApollo.scss";
2
+ export { ItemMessage } from "./ItemMessageCommon";
@@ -0,0 +1,7 @@
1
+ type ItemMessageProps = {
2
+ message: string;
3
+ id?: string;
4
+ type?: "error" | "success";
5
+ };
6
+ export declare const ItemMessage: ({ message, id, type, }: ItemMessageProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import errorIcon from "@material-symbols/svg-400/outlined/error-fill.svg";
3
+ import successIcon from "@material-symbols/svg-400/outlined/check_circle-fill.svg";
4
+ import { Svg } from "../../Svg/Svg";
5
+ export const ItemMessage = ({ message, id, type = "error", }) => (_jsxs("div", { className: `af-item-message af-item-message--${type}`, children: [_jsx(Svg, { src: type === "error" ? errorIcon : successIcon, className: "af-item-message__icon" }), _jsx("span", { id: id, "aria-live": "assertive", className: "af-item-message__message", children: message })] }));
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Form/ItemMessage/ItemMessageLF.scss";
2
+ export { ItemMessage } from "./ItemMessageCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Form/ItemMessage/ItemMessageLF.scss";
2
+ export { ItemMessage } from "./ItemMessageCommon";
@@ -0,0 +1,5 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Grid/DebugGrid.scss";
2
+ export declare const DebugGrid: ({ cols, isCheckedByDefault, }: {
3
+ cols?: number;
4
+ isCheckedByDefault?: boolean;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import "@axa-fr/design-system-apollo-css/dist/Grid/DebugGrid.scss";
3
+ import { useState } from "react";
4
+ export const DebugGrid = ({ cols = 12, isCheckedByDefault = false, }) => {
5
+ const [checked, setChecked] = useState(isCheckedByDefault);
6
+ const handleChecked = () => setChecked(!checked);
7
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "af-checkbox af-checkbox-select af-checkbox-select--debuggrid", children: _jsxs("label", { htmlFor: "debuggrid", children: [_jsx("input", { type: "checkbox", className: "af-checkbox af-checkbox-select af-checkbox-select--debuggrid", name: "debuggrid", checked: checked, onClick: handleChecked, id: "debuggrid" }), "Grid"] }) }), _jsx("div", { className: "debug-grid", children: _jsx("div", { className: "grid", children: [...Array(cols).keys()].map((col) => (_jsx("div", { className: "cols" }, col))) }) })] }));
8
+ };
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Spinner/SpinnerApollo.scss";
2
+ export { Spinner, spinnerVariants, type SpinnerVariants, } from "./SpinnerCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Spinner/SpinnerApollo.scss";
2
+ export { Spinner, spinnerVariants, } from "./SpinnerCommon";
@@ -0,0 +1,16 @@
1
+ export declare const spinnerVariants: {
2
+ readonly blue: "blue";
3
+ readonly gray: "gray";
4
+ readonly white: "white";
5
+ };
6
+ export type SpinnerVariants = keyof typeof spinnerVariants;
7
+ type SpinnerProps = {
8
+ size?: 24 | 32 | 40;
9
+ variant?: SpinnerVariants;
10
+ text?: string;
11
+ };
12
+ declare const Spinner: {
13
+ ({ size, variant, text, }: SpinnerProps): import("react/jsx-runtime").JSX.Element;
14
+ displayName: string;
15
+ };
16
+ export { Spinner };
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const spinnerVariants = {
3
+ blue: "blue",
4
+ gray: "gray",
5
+ white: "white",
6
+ };
7
+ const DEFAULT_CLASSNAME = "af-spinner";
8
+ const Spinner = ({ size = 40, variant = "blue", text = "Chargement en cours", }) => (_jsx("div", { role: "alert", "aria-busy": true, "aria-label": text, "aria-live": "assertive", className: [
9
+ DEFAULT_CLASSNAME,
10
+ `${DEFAULT_CLASSNAME}--${variant}`,
11
+ `${DEFAULT_CLASSNAME}--${size}`,
12
+ ]
13
+ .filter(Boolean)
14
+ .join(" "), style: {
15
+ "--spinner-size": size,
16
+ } }));
17
+ Spinner.displayName = "Spinner";
18
+ export { Spinner };
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Spinner/SpinnerLF.scss";
2
+ export { Spinner, spinnerVariants, type SpinnerVariants, } from "./SpinnerCommon";
@@ -0,0 +1,2 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/Spinner/SpinnerLF.scss";
2
+ export { Spinner, spinnerVariants, } from "./SpinnerCommon";
@@ -0,0 +1,7 @@
1
+ import { type SVGAttributes } from "react";
2
+ type SvgProps = SVGAttributes<SVGSVGElement> & {
3
+ src: string;
4
+ alt?: string;
5
+ };
6
+ export declare const Svg: ({ src, alt, width, height, ...props }: SvgProps) => import("react/jsx-runtime").JSX.Element | null;
7
+ export {};
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ 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
+ export const Svg = ({ src, alt, width = 24, height = 24, ...props }) => {
11
+ const rootRef = React.useRef(null);
12
+ const [hasError, setHasError] = React.useState(false);
13
+ React.useLayoutEffect(() => {
14
+ if (hasError) {
15
+ setHasError(false);
16
+ }
17
+ }, [src]);
18
+ React.useLayoutEffect(() => {
19
+ if (hasError) {
20
+ return;
21
+ }
22
+ const root = rootRef.current;
23
+ if (root) {
24
+ const parent = document.createElement("div");
25
+ const svg = document.createElement("svg");
26
+ parent.appendChild(svg);
27
+ cloneAttributes(root, svg);
28
+ svg.setAttribute("width", width.toString());
29
+ svg.setAttribute("height", height.toString());
30
+ svgInjector(svg, {
31
+ afterEach: (error, svgInject) => {
32
+ if (error) {
33
+ setHasError(true);
34
+ }
35
+ if (svgInject) {
36
+ root.innerHTML = svgInject.innerHTML;
37
+ cloneAttributes(svgInject, root);
38
+ }
39
+ },
40
+ });
41
+ }
42
+ }, [src, width, height, hasError]);
43
+ if (hasError) {
44
+ return alt ? (_jsx("span", { ...props, children: alt })) : null;
45
+ }
46
+ return (_jsx("svg", { ref: rootRef, "data-src": src, width: width, height: height, ...props }));
47
+ };
@@ -0,0 +1,12 @@
1
+ import { type AfterAll, type BeforeEach, type Errback, type EvalScripts } from "@tanem/svg-injector";
2
+ type Options = {
3
+ afterAll?: AfterAll;
4
+ afterEach?: Errback;
5
+ beforeEach?: BeforeEach;
6
+ cacheRequests?: boolean;
7
+ evalScripts?: EvalScripts;
8
+ httpRequestWithCredentials?: boolean;
9
+ renumerateIRIElements?: boolean;
10
+ };
11
+ export declare const svgInjector: (element: HTMLElement | SVGSVGElement | null, { beforeEach, ...options }?: Options) => void;
12
+ export {};
@@ -0,0 +1,31 @@
1
+ import { SVGInjector, } from "@tanem/svg-injector";
2
+ import DOMPurify from "dompurify";
3
+ const attributesToRestore = ["fill", "stroke"];
4
+ const restoreAttributes = (element, svg) => {
5
+ const attributes = {};
6
+ element?.getAttributeNames().forEach((attribute) => {
7
+ if (attribute.startsWith("aria-") ||
8
+ attributesToRestore.includes(attribute)) {
9
+ attributes[attribute] = element.getAttribute(attribute);
10
+ }
11
+ });
12
+ Object.keys(attributes).forEach((attribute) => {
13
+ svg.setAttribute(attribute, attributes[attribute]);
14
+ });
15
+ };
16
+ export const svgInjector = (element, { beforeEach = () => { }, ...options } = {}) => {
17
+ if (!element) {
18
+ return;
19
+ }
20
+ SVGInjector(element, {
21
+ ...options,
22
+ beforeEach: (svg) => {
23
+ DOMPurify.sanitize(svg, {
24
+ USE_PROFILES: { svg: true, svgFilters: true },
25
+ IN_PLACE: true,
26
+ });
27
+ restoreAttributes(element, svg);
28
+ beforeEach(svg);
29
+ },
30
+ });
31
+ };
@@ -0,0 +1,8 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/common/tokens.scss";
2
+ import "@axa-fr/design-system-apollo-css/dist/Grid/Grid.scss";
3
+ import "@fontsource/source-sans-pro";
4
+ export { Button, buttonVariants, type ButtonVariants, } from "./Button/ButtonApollo";
5
+ export { Svg } from "./Svg/Svg";
6
+ export { Spinner, spinnerVariants, type SpinnerVariants, } from "./Spinner/SpinnerApollo";
7
+ export { DebugGrid } from "./Grid/DebugGrid";
8
+ export { ItemMessage } from "./Form/ItemMessage/ItemMessageApollo";
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import "@axa-fr/design-system-apollo-css/dist/common/tokens.scss";
2
+ import "@axa-fr/design-system-apollo-css/dist/Grid/Grid.scss";
3
+ import "@fontsource/source-sans-pro";
4
+ export { Button, buttonVariants, } from "./Button/ButtonApollo";
5
+ export { Svg } from "./Svg/Svg";
6
+ export { Spinner, spinnerVariants, } from "./Spinner/SpinnerApollo";
7
+ export { DebugGrid } from "./Grid/DebugGrid";
8
+ export { ItemMessage } from "./Form/ItemMessage/ItemMessageApollo";
@@ -0,0 +1,8 @@
1
+ import "@axa-fr/design-system-look-and-feel-css/dist/common/tokens.scss";
2
+ import "@axa-fr/design-system-apollo-css/dist/Grid/Grid.scss";
3
+ import "@fontsource/source-sans-pro";
4
+ export { Button, buttonVariants, type ButtonVariants } from "./Button/ButtonLF";
5
+ export { Svg } from "./Svg/Svg";
6
+ export { Spinner, spinnerVariants, type SpinnerVariants, } from "./Spinner/SpinnerLF";
7
+ export { DebugGrid } from "./Grid/DebugGrid";
8
+ export { ItemMessage } from "./Form/ItemMessage/ItemMessageLF";
@@ -0,0 +1,8 @@
1
+ import "@axa-fr/design-system-look-and-feel-css/dist/common/tokens.scss";
2
+ import "@axa-fr/design-system-apollo-css/dist/Grid/Grid.scss";
3
+ import "@fontsource/source-sans-pro";
4
+ export { Button, buttonVariants } from "./Button/ButtonLF";
5
+ export { Svg } from "./Svg/Svg";
6
+ export { Spinner, spinnerVariants, } from "./Spinner/SpinnerLF";
7
+ export { DebugGrid } from "./Grid/DebugGrid";
8
+ export { ItemMessage } from "./Form/ItemMessage/ItemMessageLF";
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@axa-fr/design-system-apollo-react",
3
+ "version": "1.0.3-alpha.144",
4
+ "description": "",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "default": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "./lf": {
15
+ "default": {
16
+ "import": "./dist/indexLF.js",
17
+ "types": "./dist/indexLF.d.ts"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "prebuild": "rimraf dist",
26
+ "build": "tsc -p tsconfig.build.json",
27
+ "eslint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
28
+ "eslint:fix": "eslint src --ext js,jsx,ts,tsx --fix",
29
+ "prettier": "prettier \"src/**/*.!(js|jsx|ts|tsx|svg)\" --check --ignore-unknown",
30
+ "prettier:fix": "prettier \"src/**/*.!(js|jsx|ts|tsx|svg)\" --write --ignore-unknown",
31
+ "check-types": "tsc --noEmit",
32
+ "test": "vitest",
33
+ "test:ui": "vitest --ui",
34
+ "test:ci": "vitest run --coverage"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/AxaFrance/design-system.git"
39
+ },
40
+ "author": {
41
+ "name": "AxaFrance"
42
+ },
43
+ "license": "MIT",
44
+ "bugs": {
45
+ "url": "https://github.com/AxaFrance/design-system/issues"
46
+ },
47
+ "homepage": "https://github.com/AxaFrance/design-system#readme",
48
+ "peerDependencies": {
49
+ "@axa-fr/design-system-apollo-css": "1.0.3-alpha.144",
50
+ "@axa-fr/design-system-look-and-feel-css": "1.0.3-alpha.144",
51
+ "@material-symbols/svg-400": ">= 0.19.0",
52
+ "react": ">= 18"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@material-symbols/svg-400": {
56
+ "optional": true
57
+ }
58
+ },
59
+ "dependencies": {
60
+ "@fontsource/source-sans-pro": "^5.0.8",
61
+ "@tanem/svg-injector": "^10.1.68",
62
+ "classnames": "^2.5.1",
63
+ "dompurify": "^3.1.5"
64
+ },
65
+ "devDependencies": {
66
+ "@axa-fr/design-system-apollo-css": "*",
67
+ "@axa-fr/design-system-look-and-feel-css": "*",
68
+ "@axa-fr/eslint-config-design-system": "*",
69
+ "@axa-fr/prettier-config-design-system": "*",
70
+ "@testing-library/dom": "^10.4.0",
71
+ "@testing-library/jest-dom": "^6.6.3",
72
+ "@testing-library/react": "^16.2.0",
73
+ "@testing-library/user-event": "^14.6.1",
74
+ "@types/dompurify": "^3.0.5",
75
+ "@types/jest": "^29.5.14",
76
+ "@types/jest-axe": "^3.5.9",
77
+ "@vitest/coverage-v8": "^3.0.7",
78
+ "@vitest/ui": "^3.0.7",
79
+ "copyfiles": "^2.4.1",
80
+ "jest-axe": "^9.0.0",
81
+ "jsdom": "^25.0.1",
82
+ "react": "^19.0.0",
83
+ "rimraf": "^6.0.1",
84
+ "vitest": "^3.0.7"
85
+ },
86
+ "lint-staged": {
87
+ "*.(js|jsx|ts|tsx)": "eslint --fix",
88
+ "*.(ts|tsx)": "tsc-files --noEmit"
89
+ },
90
+ "prettier": "@axa-fr/prettier-config-design-system",
91
+ "volta": {
92
+ "extends": "../../../package.json"
93
+ }
94
+ }