@agregio-solutions/design-system 2.1.0 → 2.2.0

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.
@@ -45,7 +45,8 @@ import DataTableCell from "@packages/components/DataTable/DataTableCell/DataTabl
45
45
  import DataTable from "@packages/components/DataTable/DataTable";
46
46
  import CheckboxGroup from "../CheckboxGroup/CheckboxGroup";
47
47
  import Checkbox from "../Checkbox/Checkbox";
48
- import Radio from "../Radio/Radio";
48
+ import RadioGroup from "../RadioGroup/RadioGroup";
49
+ import RadioGroupItem from "../RadioGroupItem/RadioGroupItem";
49
50
  import { I18nProvider } from "react-aria-components";
50
51
  import Select from "../Select/Select";
51
52
  import SelectItem from "../SelectItem/SelectItem";
@@ -213,18 +214,17 @@ export const WithReactTableFrontEndManaged: StoryObj<typeof DataTable> = {
213
214
  filterFn: "equals",
214
215
  meta: {
215
216
  FilterInDrawer: ({ column }) => (
216
- <div>
217
- <b>Filter by day:</b>
218
-
217
+ <RadioGroup
218
+ label="Filter by day"
219
+ value={
220
+ (column.getFilterValue() as string | undefined) ?? null
221
+ }
222
+ onChange={(day) => column.setFilterValue(day)}
223
+ >
219
224
  {DAYS.map((day) => (
220
- <Radio
221
- label={day}
222
- key={day}
223
- checked={column.getFilterValue() === day}
224
- onChange={() => column.setFilterValue(day)}
225
- />
225
+ <RadioGroupItem label={day} key={day} value={day} />
226
226
  ))}
227
- </div>
227
+ </RadioGroup>
228
228
  ),
229
229
  } satisfies TypeTableColumnWithFilter<
230
230
  typeof clientFeatures,
@@ -51,7 +51,8 @@ import {
51
51
  } from "@tanstack/react-table";
52
52
  import DataTableHeader from "../DataTable/DataTableHeader/DataTableHeader";
53
53
  import DataTableCell from "../DataTable/DataTableCell/DataTableCell";
54
- import Radio from "../Radio/Radio";
54
+ import RadioGroup from "../RadioGroup/RadioGroup";
55
+ import RadioGroupItem from "../RadioGroupItem/RadioGroupItem";
55
56
  import Filter, { TypeTableColumnWithFilter } from "../Filter/Filter";
56
57
  import CheckboxGroup from "../CheckboxGroup/CheckboxGroup";
57
58
  import Checkbox from "../Checkbox/Checkbox";
@@ -307,18 +308,17 @@ export const PageLayoutWithDataTable: Story = {
307
308
  filterFn: "equals",
308
309
  meta: {
309
310
  FilterInDrawer: ({ column }) => (
310
- <div>
311
- <b>Filter by day:</b>
312
-
311
+ <RadioGroup
312
+ label="Filter by day"
313
+ value={
314
+ (column.getFilterValue() as string | undefined) ?? null
315
+ }
316
+ onChange={(day) => column.setFilterValue(day)}
317
+ >
313
318
  {DAYS.map((day) => (
314
- <Radio
315
- label={day}
316
- key={day}
317
- checked={column.getFilterValue() === day}
318
- onChange={() => column.setFilterValue(day)}
319
- />
319
+ <RadioGroupItem label={day} key={day} value={day} />
320
320
  ))}
321
- </div>
321
+ </RadioGroup>
322
322
  ),
323
323
  } satisfies TypeTableColumnWithFilter<
324
324
  typeof tableFeaturesSet,
@@ -1,4 +1,7 @@
1
1
  import { default as React } from 'react';
2
+ /**
3
+ * @deprecated Use `RadioGroup` with `RadioGroupItem` instead.
4
+ */
2
5
  export type Props = Omit<React.HTMLProps<HTMLInputElement>, "label" | "type"> & {
3
6
  /**
4
7
  * The text to display next to the radio button.
@@ -13,5 +16,9 @@ export type Props = Omit<React.HTMLProps<HTMLInputElement>, "label" | "type"> &
13
16
  */
14
17
  wrapperProps?: React.HTMLProps<HTMLDivElement>;
15
18
  };
19
+ /**
20
+ * @deprecated Use `RadioGroup` with `RadioGroupItem` instead: it names the group,
21
+ * handles keyboard navigation and displays helper and error texts.
22
+ */
16
23
  declare const Radio: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLInputElement>>;
17
24
  export default Radio;
@@ -350,6 +350,10 @@ import * as RadioTests from "./tests/Radio.stories";
350
350
 
351
351
  # Radio
352
352
 
353
+ > **Deprecated** — use `RadioGroup` with `RadioGroupItem` instead. It names the group for
354
+ > assistive technologies, handles keyboard navigation (one tab stop, arrow keys) and displays
355
+ > helper and error texts. See the "Migrating from `Radio`" section of the `RadioGroup` docs.
356
+
353
357
  Use this component exactly like an `<input type="radio">` but with an added `label` prop.
354
358
 
355
359
  <Canvas of={Radio.WithLabel} />
@@ -0,0 +1,92 @@
1
+ import { default as React } from 'react';
2
+ import { Props as LabelProps } from '../Label/Label';
3
+ import { Props as FormGroupWrapperProps } from '../../internal-components/FormGroupWrapper/FormGroupWrapper';
4
+ export type Props = {
5
+ /**
6
+ * The `RadioGroupItem`s to display in the group.
7
+ */
8
+ children: React.ReactNode;
9
+ /**
10
+ * The value of the selected radio (controlled). `null` means no radio is selected.
11
+ */
12
+ value?: string | null;
13
+ /**
14
+ * The value of the radio selected on first render (uncontrolled).
15
+ */
16
+ defaultValue?: string;
17
+ /**
18
+ * Handler that is called with the value of the newly selected radio.
19
+ */
20
+ onChange?: (value: string) => void;
21
+ /**
22
+ * The name of the radios, used when submitting an HTML form.
23
+ */
24
+ name?: string;
25
+ /**
26
+ * Whether all the radios of the group are disabled.
27
+ */
28
+ isDisabled?: boolean;
29
+ /**
30
+ * Whether the radios can be focused but not changed by the user.
31
+ */
32
+ isReadOnly?: boolean;
33
+ /**
34
+ * Layout of the radios inside the group.
35
+ * @default "vertical"
36
+ */
37
+ direction?: "vertical" | "horizontal";
38
+ /**
39
+ * Accessible name of the group, required when `label` is not a string.
40
+ */
41
+ "aria-label"?: string;
42
+ /**
43
+ * Props to pass to the wrapper div (for example, `style` or `className`).
44
+ */
45
+ wrapperProps?: React.HTMLProps<HTMLDivElement>;
46
+ } & Pick<LabelProps, "label" | "labelIconRight" | "labelIconRightTooltip" | "required"> & Pick<FormGroupWrapperProps, "helperText" | "helperTextIcon" | "errorHelperText" | "errorHelperTextIcon" | "successHelperText" | "successHelperTextIcon" | "warningHelperText" | "warningHelperTextIcon" | "orientation" | "className" | "style">;
47
+ declare const RadioGroup: React.ForwardRefExoticComponent<{
48
+ /**
49
+ * The `RadioGroupItem`s to display in the group.
50
+ */
51
+ children: React.ReactNode;
52
+ /**
53
+ * The value of the selected radio (controlled). `null` means no radio is selected.
54
+ */
55
+ value?: string | null;
56
+ /**
57
+ * The value of the radio selected on first render (uncontrolled).
58
+ */
59
+ defaultValue?: string;
60
+ /**
61
+ * Handler that is called with the value of the newly selected radio.
62
+ */
63
+ onChange?: (value: string) => void;
64
+ /**
65
+ * The name of the radios, used when submitting an HTML form.
66
+ */
67
+ name?: string;
68
+ /**
69
+ * Whether all the radios of the group are disabled.
70
+ */
71
+ isDisabled?: boolean;
72
+ /**
73
+ * Whether the radios can be focused but not changed by the user.
74
+ */
75
+ isReadOnly?: boolean;
76
+ /**
77
+ * Layout of the radios inside the group.
78
+ * @default "vertical"
79
+ */
80
+ direction?: "vertical" | "horizontal";
81
+ /**
82
+ * Accessible name of the group, required when `label` is not a string.
83
+ */
84
+ "aria-label"?: string;
85
+ /**
86
+ * Props to pass to the wrapper div (for example, `style` or `className`).
87
+ */
88
+ wrapperProps?: React.HTMLProps<HTMLDivElement>;
89
+ } & Pick<LabelProps, "label" | "required" | "labelIconRight" | "labelIconRightTooltip"> & Pick<FormGroupWrapperProps, "className" | "style" | "orientation" | "helperText" | "helperTextIcon" | "errorHelperText" | "errorHelperTextIcon" | "successHelperText" | "successHelperTextIcon" | "warningHelperText" | "warningHelperTextIcon"> & React.RefAttributes<{
90
+ focus: (options?: FocusOptions) => void;
91
+ }>>;
92
+ export default RadioGroup;