@axa-fr/design-system-look-and-feel-react 0.2.0-beta.313 → 0.2.0-beta.315

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,5 +1,5 @@
1
1
  import "@axa-fr/design-system-look-and-feel-css/dist/Form/Text/Text.scss";
2
- import { ComponentPropsWithRef } from "react";
2
+ import { ComponentPropsWithRef, MouseEventHandler } from "react";
3
3
  type Props = Omit<ComponentPropsWithRef<"input">, "required"> & {
4
4
  classModifier?: string;
5
5
  helper?: string;
@@ -7,6 +7,8 @@ type Props = Omit<ComponentPropsWithRef<"input">, "required"> & {
7
7
  description?: string;
8
8
  label?: string;
9
9
  required?: boolean;
10
+ buttonLabel?: string;
11
+ onButtonClick?: MouseEventHandler<HTMLButtonElement>;
10
12
  };
11
13
  declare const Text: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
12
14
  export { Text };
@@ -1,12 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import "@axa-fr/design-system-look-and-feel-css/dist/Form/Text/Text.scss";
3
3
  import { forwardRef } from "react";
4
+ import infoIcon from "@material-symbols/svg-400/outlined/info.svg";
5
+ import { Button } from "../..";
6
+ import { Variants } from "../../Button/Button";
7
+ import { Svg } from "../../Svg";
4
8
  import { getComponentClassName } from "../../utilities";
5
9
  import { InputError } from "../InputError";
6
10
  const Text = forwardRef(({ className, classModifier = "", ...otherProps }, inputRef) => {
7
11
  const componentClassName = getComponentClassName(className, classModifier, "af-form__input-text");
8
- const { id, label, required, disabled, description, helper, error } = otherProps;
9
- return (_jsxs("div", { className: "af-form__input-container", children: [_jsxs("label", { htmlFor: id, className: "af-form__input-label", children: [label, " ", required && _jsx("span", { children: " *" })] }), description && (_jsx("span", { className: "af-form__input-description", children: description })), _jsx("input", { className: componentClassName, type: "text", ref: inputRef, required: required, disabled: disabled, "aria-invalid": Boolean(error), "aria-describedby": error ? `${id}-error` : undefined, ...otherProps }), helper && _jsx("span", { className: "af-form__input-helper", children: helper }), error && _jsx(InputError, { id: `${id}-error`, message: error })] }));
12
+ const { id, label, required, disabled, description, helper, error, buttonLabel, onButtonClick, } = otherProps;
13
+ return (_jsxs("div", { className: "af-form__input-container", children: [_jsxs("label", { htmlFor: id, className: "af-form__input-label", children: [label, " ", required && _jsx("span", { children: " *" })] }), description && (_jsx("span", { className: "af-form__input-description", children: description })), buttonLabel && (_jsx(Button, { className: "af-form__input-more", variant: Variants.ghost, iconLeft: _jsx(Svg, { src: infoIcon }), onClick: onButtonClick, children: buttonLabel })), _jsx("input", { className: componentClassName, type: "text", ref: inputRef, required: required, disabled: disabled, "aria-invalid": Boolean(error), "aria-describedby": error ? `${id}-error` : undefined, ...otherProps }), helper && _jsx("span", { className: "af-form__input-helper", children: helper }), error && _jsx(InputError, { id: `${id}-error`, message: error })] }));
10
14
  });
11
15
  Text.displayName = "Text";
12
16
  export { Text };
@@ -6,3 +6,4 @@ type Story = StoryObj<typeof Text>;
6
6
  export declare const TextStory: Story;
7
7
  export declare const TextWithDescriptionStory: Story;
8
8
  export declare const TextOnErrorStory: Story;
9
+ export declare const TextWithButton: Story;
@@ -14,33 +14,38 @@ const meta = {
14
14
  required: false,
15
15
  className: "",
16
16
  type: "text",
17
+ buttonLabel: "",
17
18
  },
18
19
  argTypes: {
19
- type: {
20
- control: { type: "text" },
21
- onChange: { action: "onChange" },
22
- },
23
20
  onChange: { action: "onChange" },
24
21
  },
25
22
  };
26
23
  export default meta;
24
+ const render = ({ onChange, ...args }) => (_jsx(Text, { onChange: onChange, ...args }));
27
25
  export const TextStory = {
28
26
  name: "Text",
29
- render: ({ onChange, ...args }) => _jsx(Text, { onChange: onChange, ...args }),
27
+ render,
30
28
  };
31
29
  export const TextWithDescriptionStory = {
32
30
  name: "Text with description",
33
- render: ({ onChange, ...args }) => _jsx(Text, { onChange: onChange, ...args }),
31
+ render,
34
32
  args: {
35
33
  description: "Description",
36
34
  },
37
35
  };
38
36
  export const TextOnErrorStory = {
39
37
  name: "Text on error",
40
- render: ({ onChange, ...args }) => _jsx(Text, { onChange: onChange, ...args }),
38
+ render,
41
39
  args: {
42
40
  classModifier: "error",
43
41
  description: "Description",
44
42
  error: "Error Message",
45
43
  },
46
44
  };
45
+ export const TextWithButton = {
46
+ name: "Text with button",
47
+ render,
48
+ args: {
49
+ buttonLabel: "En savoir plus",
50
+ },
51
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-look-and-feel-react",
3
- "version": "0.2.0-beta.313",
3
+ "version": "0.2.0-beta.315",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "homepage": "https://github.com/AxaFrance/design-system#readme",
43
43
  "peerDependencies": {
44
- "@axa-fr/design-system-look-and-feel-css": "0.2.0-beta.313",
44
+ "@axa-fr/design-system-look-and-feel-css": "0.2.0-beta.315",
45
45
  "@material-symbols/svg-400": ">= 0.19.0",
46
46
  "react": ">= 18"
47
47
  },