@axa-fr/design-system-look-and-feel-react 0.2.0-beta.318 → 0.2.0-beta.319

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.
@@ -2,6 +2,8 @@ import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
2
2
  import React, { ComponentPropsWithRef, ReactNode } from "react";
3
3
  type RadioSelectProps = {
4
4
  type: "vertical" | "horizontal";
5
+ label?: string;
6
+ isRequired?: boolean;
5
7
  options: ({
6
8
  label: ReactNode;
7
9
  subtitle?: ReactNode;
@@ -5,12 +5,12 @@ import radioOutlineBlankIcon from "@material-symbols/svg-400/outlined/radio_butt
5
5
  import errorOutline from "@material-symbols/svg-400/outlined/error.svg";
6
6
  import { forwardRef, useId, } from "react";
7
7
  import { Svg } from "../../Svg";
8
- export const RadioSelect = forwardRef(({ id, options, errorMessage, onChange, type = "vertical", name, value, isDisabled, ...rest }, ref) => {
8
+ export const RadioSelect = forwardRef(({ id, label, options, errorMessage, onChange, type = "vertical", name, value, isDisabled, isRequired, ...rest }, ref) => {
9
9
  const generatedId = useId();
10
10
  const optionId = id || generatedId;
11
- return (_jsxs(_Fragment, { children: [_jsx("div", { ref: ref, ...rest, role: "radiogroup", className: `af-radio af-radio-select af-radio-select--${type}`, "aria-invalid": Boolean(errorMessage), children: options.map(({ label, description, subtitle, icon, disabled: inputDisabled, ...inputProps }) => (_jsxs("label", { htmlFor: `${optionId}-${label}`, children: [_jsx("input", { type: "radio", ...(isDisabled || inputDisabled ? { disabled: true } : null), ...inputProps, name: name, id: `${optionId}-${label}`, onChange: onChange, ...(value && {
11
+ return (_jsxs(_Fragment, { children: [label && (_jsxs("span", { className: "af-radio__label", id: optionId, children: [label, isRequired && _jsx("span", { "aria-hidden": "true", children: "\u00A0*" })] })), _jsx("div", { ref: ref, ...rest, role: "radiogroup", className: `af-radio af-radio-select af-radio-select--${type}`, "aria-invalid": Boolean(errorMessage), "aria-labelledby": optionId, children: options.map(({ label: inputLabel, description, subtitle, icon, disabled: inputDisabled, ...inputProps }) => (_jsxs("label", { htmlFor: `${optionId}-${inputLabel}`, children: [_jsx("input", { type: "radio", "aria-labelledby": optionId, ...(isDisabled || inputDisabled ? { disabled: true } : null), ...inputProps, name: name, id: `${optionId}-${inputLabel}`, onChange: onChange, ...(value && {
12
12
  "aria-checked": value === inputProps.value,
13
13
  checked: value === inputProps.value,
14
- }) }), _jsxs("div", { className: "af-radio__icons", children: [_jsx(Svg, { src: radioOutlineBlankIcon, className: "af-radio__unchecked" }), _jsx(Svg, { src: radioIcon, className: "af-radio__checked" })] }), _jsxs("div", { className: "af-radio__content", children: [icon, _jsxs("div", { className: "af-radio__content-description", children: [_jsx("span", { children: label }), description && _jsx("span", { children: description }), subtitle && _jsx("span", { children: subtitle })] })] })] }, label))) }), errorMessage && (_jsxs("div", { className: "af-radio__error", "aria-live": "assertive", children: [_jsx(Svg, { src: errorOutline }), errorMessage] }))] }));
14
+ }) }), _jsxs("div", { className: "af-radio__icons", children: [_jsx(Svg, { src: radioOutlineBlankIcon, className: "af-radio__unchecked" }), _jsx(Svg, { src: radioIcon, className: "af-radio__checked" })] }), _jsxs("div", { className: "af-radio__content", children: [icon, _jsxs("div", { className: "af-radio__content-description", children: [_jsx("span", { children: inputLabel }), description && _jsx("span", { children: description }), subtitle && _jsx("span", { children: subtitle })] })] })] }, inputLabel))) }), errorMessage && (_jsxs("div", { className: "af-radio__error", "aria-live": "assertive", children: [_jsx(Svg, { src: errorOutline }), errorMessage] }))] }));
15
15
  });
16
16
  RadioSelect.displayName = "RadioSelect";
@@ -5,3 +5,4 @@ declare const meta: Meta;
5
5
  export default meta;
6
6
  export declare const RadioSelectStory: StoryObj<ComponentProps<typeof RadioSelect>>;
7
7
  export declare const RadioSelectDisabledStory: StoryObj<ComponentProps<typeof RadioSelect>>;
8
+ export declare const RadioSelectWithLabel: StoryObj<ComponentProps<typeof RadioSelect>>;
@@ -8,6 +8,26 @@ const meta = {
8
8
  argTypes: {},
9
9
  };
10
10
  export default meta;
11
+ const storyOptions = [
12
+ {
13
+ label: "Paris",
14
+ description: "Capitale de la France",
15
+ subtitle: "Nord",
16
+ value: "paris",
17
+ icon: _jsx(Svg, { src: home }),
18
+ },
19
+ {
20
+ label: "Bruxelles",
21
+ description: "Capitale de la Belgique",
22
+ value: "bruxelles",
23
+ icon: _jsx(Svg, { src: home }),
24
+ },
25
+ {
26
+ label: "Lille",
27
+ value: "lille",
28
+ icon: _jsx(Svg, { src: home }),
29
+ },
30
+ ];
11
31
  export const RadioSelectStory = {
12
32
  name: "Select",
13
33
  render: ({ ...args }) => _jsx(RadioSelect, { ...args }),
@@ -15,26 +35,7 @@ export const RadioSelectStory = {
15
35
  type: "vertical",
16
36
  "aria-label": "Quelle ville ?",
17
37
  name: "cities",
18
- options: [
19
- {
20
- label: "Paris",
21
- description: "Capitale de la France",
22
- subtitle: "Nord",
23
- value: "paris",
24
- icon: _jsx(Svg, { src: home }),
25
- },
26
- {
27
- label: "Bruxelles",
28
- description: "Capitale de la Belgique",
29
- value: "bruxelles",
30
- icon: _jsx(Svg, { src: home }),
31
- },
32
- {
33
- label: "Lille",
34
- value: "lille",
35
- icon: _jsx(Svg, { src: home }),
36
- },
37
- ],
38
+ options: storyOptions,
38
39
  },
39
40
  argTypes: {
40
41
  type: {
@@ -88,3 +89,24 @@ export const RadioSelectDisabledStory = {
88
89
  onChange: { action: "onChange" },
89
90
  },
90
91
  };
92
+ export const RadioSelectWithLabel = {
93
+ name: "SelectWithLabel",
94
+ render: ({ ...args }) => _jsx(RadioSelect, { ...args }),
95
+ args: {
96
+ type: "vertical",
97
+ label: "Quelle ville ?",
98
+ isRequired: true,
99
+ name: "cities",
100
+ options: storyOptions,
101
+ },
102
+ argTypes: {
103
+ type: {
104
+ control: { type: "inline-radio" },
105
+ options: ["vertical", "horizontal"],
106
+ },
107
+ errorMessage: {
108
+ control: { type: "text" },
109
+ },
110
+ onChange: { action: "onChange" },
111
+ },
112
+ };
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.318",
3
+ "version": "0.2.0-beta.319",
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.318",
44
+ "@axa-fr/design-system-look-and-feel-css": "0.2.0-beta.319",
45
45
  "@material-symbols/svg-400": ">= 0.19.0",
46
46
  "react": ">= 18"
47
47
  },