opus-toolkit-components 1.9.6 → 1.9.8

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,19 +1,19 @@
1
- // Accordion Typescript Definitions - update when new props added
2
- export interface AccordionProps {
3
- title: string | React.ReactNode;
4
- handleToggle?: (index: number) => void;
5
- activeIndex?: number;
6
- index: number;
7
- isPreview?: boolean;
8
- isLocked?: boolean;
9
- onExitPreview?: () => void;
10
- content: React.ReactNode;
11
- preview?: React.ReactNode;
12
- isPill?: boolean;
13
- pillText?: string;
14
- pillStatus?: "success" | "warning" | "error" | "info" | string;
15
- pillIcon?: React.ReactNode;
16
- disabled?: boolean;
17
- }
18
-
19
- export const Accordion: React.ComponentType<AccordionProps>;
1
+ // Accordion Typescript Definitions - update when new props added
2
+ export interface AccordionProps {
3
+ title?: string | React.ReactNode;
4
+ handleToggle?: (index: number) => void;
5
+ activeIndex?: number;
6
+ index: number;
7
+ isPreview?: boolean;
8
+ isLocked?: boolean;
9
+ onExitPreview?: () => void;
10
+ content: React.ReactNode;
11
+ preview?: React.ReactNode;
12
+ isPill?: boolean;
13
+ pillText?: string;
14
+ pillStatus?: "success" | "warning" | "error" | "info" | string;
15
+ pillIcon?: React.ReactNode;
16
+ disabled?: boolean;
17
+ }
18
+
19
+ export const Accordion: React.ComponentType<AccordionProps>;
@@ -1,20 +1,21 @@
1
- export interface CheckboxChangeEvent {
2
- target: {
3
- name: string;
4
- value: boolean;
5
- };
6
- }
7
-
8
- export interface CheckboxProps extends React.HTMLAttributes<HTMLDivElement> {
9
- label: string;
10
- name: string;
11
- onChange?: (event: CheckboxChangeEvent) => void;
12
- value?: boolean;
13
- isValid?: boolean;
14
- errorMessage?: string;
15
- disabled?: boolean;
16
- title?: string;
17
- dataCy?: string;
18
- }
19
-
20
- export const Checkbox: React.ComponentType<CheckboxProps>;
1
+ export interface CheckboxChangeEvent {
2
+ target: {
3
+ name: string;
4
+ value: boolean;
5
+ };
6
+ }
7
+
8
+ export interface CheckboxProps extends React.HTMLAttributes<HTMLDivElement> {
9
+ label?: string;
10
+ hideLabel?: boolean;
11
+ name: string;
12
+ onChange?: (event: CheckboxChangeEvent) => void;
13
+ value?: boolean;
14
+ isValid?: boolean;
15
+ errorMessage?: string;
16
+ disabled?: boolean;
17
+ title?: string;
18
+ dataCy?: string;
19
+ }
20
+
21
+ export const Checkbox: React.ComponentType<CheckboxProps>;
@@ -16,6 +16,7 @@ export interface DatePickerProps extends React.HTMLAttributes<HTMLDivElement> {
16
16
  className?: string;
17
17
  title?: string;
18
18
  required?: boolean;
19
+ hideLabel?: boolean;
19
20
  dataCy?: string;
20
21
  disabled?: boolean;
21
22
  minDate?: string;
@@ -19,6 +19,7 @@ export interface DropdownProps extends React.HTMLAttributes<HTMLDivElement> {
19
19
  label?: string;
20
20
  isValid?: boolean;
21
21
  required?: boolean;
22
+ hideLabel?: boolean;
22
23
  placeholder?: string;
23
24
  name?: string;
24
25
  className?: string;
@@ -39,6 +40,7 @@ export interface SearchDropdownProps extends React.HTMLAttributes<HTMLDivElement
39
40
  label?: string;
40
41
  isValid?: boolean;
41
42
  required?: boolean;
43
+ hideLabel?: boolean;
42
44
  placeholder?: string;
43
45
  searchPlaceholder?: string;
44
46
  name?: string;
@@ -68,6 +70,7 @@ export interface SearchMultiSelectDropdownProps extends React.HTMLAttributes<HTM
68
70
  label?: string;
69
71
  isValid?: boolean;
70
72
  required?: boolean;
73
+ hideLabel?: boolean;
71
74
  placeholder?: string;
72
75
  searchPlaceholder?: string;
73
76
  name?: string;
@@ -11,7 +11,7 @@ export interface RadioChangeEvent {
11
11
  }
12
12
 
13
13
  export interface RadioButtonProps extends React.HTMLAttributes<HTMLDivElement> {
14
- label: string;
14
+ label?: string;
15
15
  options?: RadioOption[];
16
16
  name: string;
17
17
  value?: string | number;
package/lib/main.js CHANGED
@@ -21,54 +21,54 @@ __webpack_require__.r(__webpack_exports__);
21
21
 
22
22
 
23
23
 
24
- /**
25
- * @typedef {Object} AccordionProps
26
- *
27
- * @property {string | React.ReactNode} title
28
- * Title rendered inside the header.
29
- *
30
- * @property {Function} [handleToggle]
31
- * Optional external toggle handler called with (index).
32
- *
33
- * @property {number} [activeIndex]
34
- * Controlled active index. If provided, the accordion becomes controlled.
35
- *
36
- * @property {number} index
37
- * This accordion's position in a list.
38
- *
39
- * @property {boolean} [isPreview]
40
- * If true, accordion goes into preview mode.
41
- *
42
- * @property {boolean} [isLocked]
43
- * If true, accordion cannot toggle.
44
- *
45
- * @property {Function} [onExitPreview]
46
- * Callback fired when exiting preview mode.
47
- *
48
- * @property {React.ReactNode} content
49
- * Accordion expanded content.
50
- *
51
- * @property {React.ReactNode} [preview]
52
- * Rendered when in preview mode and not active.
53
- *
54
- * @property {boolean} [isPill]
55
- * Whether to show a status pill.
56
- *
57
- * @property {string} [pillText]
58
- * Label inside the pill.
59
- *
60
- * @property {'success'|'warning'|'error'|'info'|string} [pillStatus]
61
- * Visual status for the pill.
62
- *
63
- * @property {React.ReactNode} [pillIcon]
64
- * Optional icon inside the pill.
65
- *
66
- * @property {boolean} [disabled]
67
- * Disables interaction with the accordion.
24
+ /**
25
+ * @typedef {Object} AccordionProps
26
+ *
27
+ * @property {string | React.ReactNode} [title]
28
+ * Title rendered inside the header.
29
+ *
30
+ * @property {Function} [handleToggle]
31
+ * Optional external toggle handler called with (index).
32
+ *
33
+ * @property {number} [activeIndex]
34
+ * Controlled active index. If provided, the accordion becomes controlled.
35
+ *
36
+ * @property {number} index
37
+ * This accordion's position in a list.
38
+ *
39
+ * @property {boolean} [isPreview]
40
+ * If true, accordion goes into preview mode.
41
+ *
42
+ * @property {boolean} [isLocked]
43
+ * If true, accordion cannot toggle.
44
+ *
45
+ * @property {Function} [onExitPreview]
46
+ * Callback fired when exiting preview mode.
47
+ *
48
+ * @property {React.ReactNode} content
49
+ * Accordion expanded content.
50
+ *
51
+ * @property {React.ReactNode} [preview]
52
+ * Rendered when in preview mode and not active.
53
+ *
54
+ * @property {boolean} [isPill]
55
+ * Whether to show a status pill.
56
+ *
57
+ * @property {string} [pillText]
58
+ * Label inside the pill.
59
+ *
60
+ * @property {'success'|'warning'|'error'|'info'|string} [pillStatus]
61
+ * Visual status for the pill.
62
+ *
63
+ * @property {React.ReactNode} [pillIcon]
64
+ * Optional icon inside the pill.
65
+ *
66
+ * @property {boolean} [disabled]
67
+ * Disables interaction with the accordion.
68
68
  */
69
69
 
70
- /**
71
- * @param {AccordionProps} props
70
+ /**
71
+ * @param {AccordionProps} props
72
72
  */
73
73
 
74
74
  const Accordion = _ref => {
@@ -89,6 +89,7 @@ const Accordion = _ref => {
89
89
  disabled = false
90
90
  } = _ref;
91
91
  const [internalActiveIndex, setInternalActiveIndex] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
92
+ const hasTitle = title !== undefined && title !== null && title !== "";
92
93
 
93
94
  // Determine which activeIndex to use: internal or external
94
95
  const isActive = activeIndex !== undefined ? activeIndex === index : internalActiveIndex === index;
@@ -116,7 +117,7 @@ const Accordion = _ref => {
116
117
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)("div", {
117
118
  onClick: !isPreview && !isLocked ? toggle : null,
118
119
  className: `accordion-header flex items-center justify-between rounded-t-lg bg-[--color-accordion-header] ${isActive || isPreview ? "" : "rounded-b-lg"} hover: ${!isLocked ? "cursor-pointer" : null} `,
119
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", {
120
+ children: [hasTitle && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", {
120
121
  className: "flex items-center justify-between gap-2",
121
122
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_3__["default"], {
122
123
  as: "h2",
@@ -1141,9 +1142,12 @@ __webpack_require__.r(__webpack_exports__);
1141
1142
  *
1142
1143
  * @typedef {Object} CheckboxProps
1143
1144
  *
1144
- * @property {string} label
1145
+ * @property {string} [label]
1145
1146
  * Label displayed next to the checkbox.
1146
1147
  *
1148
+ * @property {boolean} [hideLabel]
1149
+ * Hides the visible label while keeping it available to assistive technology.
1150
+ *
1147
1151
  * @property {string} name
1148
1152
  * Name used in the emitted onChange event.
1149
1153
  *
@@ -1175,6 +1179,7 @@ __webpack_require__.r(__webpack_exports__);
1175
1179
  function Checkbox(_ref) {
1176
1180
  let {
1177
1181
  label,
1182
+ hideLabel = false,
1178
1183
  name,
1179
1184
  onChange,
1180
1185
  value = false,
@@ -1189,6 +1194,7 @@ function Checkbox(_ref) {
1189
1194
  const id = `checkbox-${name}`;
1190
1195
  const errorId = `${id}-error`;
1191
1196
  const showError = !isValid && errorMessage;
1197
+ const hasLabel = Boolean(label);
1192
1198
  const handleChange = event => {
1193
1199
  onChange?.({
1194
1200
  target: {
@@ -1221,10 +1227,11 @@ function Checkbox(_ref) {
1221
1227
  accentColor: "var(--color-primary-btn)"
1222
1228
  },
1223
1229
  className: `mr-2 rounded-sm ${disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"}`
1224
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1230
+ }), hasLabel && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1225
1231
  variant: "label",
1226
1232
  as: "label",
1227
1233
  htmlFor: id,
1234
+ className: hideLabel ? "sr-only" : undefined,
1228
1235
  children: label
1229
1236
  })]
1230
1237
  }), !isValid && errorMessage && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
@@ -1297,6 +1304,9 @@ __webpack_require__.r(__webpack_exports__);
1297
1304
  *
1298
1305
  * @property {boolean} [required]
1299
1306
  *
1307
+ * @property {boolean} [hideLabel]
1308
+ * Hides the visible label while keeping it available to assistive technology.
1309
+ *
1300
1310
  * @property {string} [dataCy]
1301
1311
  *
1302
1312
  * @property {boolean} [disabled]
@@ -1315,15 +1325,16 @@ __webpack_require__.r(__webpack_exports__);
1315
1325
  function DatePicker(_ref) {
1316
1326
  let {
1317
1327
  initialDate = "",
1318
- label = "Select a Date:",
1328
+ label,
1319
1329
  isValid = true,
1320
- errorMessage = "Error message",
1330
+ errorMessage,
1321
1331
  name = "date",
1322
1332
  onChange,
1323
1333
  value,
1324
1334
  className = "",
1325
1335
  title = "",
1326
1336
  required = false,
1337
+ hideLabel = false,
1327
1338
  dataCy,
1328
1339
  disabled = false,
1329
1340
  minDate,
@@ -1332,6 +1343,8 @@ function DatePicker(_ref) {
1332
1343
  } = _ref;
1333
1344
  const [selectedDate, setSelectedDate] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
1334
1345
  const inputRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1346
+ const hasLabel = Boolean(label);
1347
+ const resolvedErrorMessage = errorMessage || (hasLabel ? `${label} is required` : "This field is required");
1335
1348
  const normalizeToInputFormat = dateString => {
1336
1349
  if (!dateString) return "";
1337
1350
  const [datePart] = dateString.split(" "); // Remove time if present
@@ -1380,11 +1393,11 @@ function DatePicker(_ref) {
1380
1393
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
1381
1394
  className: "relative mb-4 flex flex-col",
1382
1395
  ...rest,
1383
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1396
+ children: [hasLabel && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1384
1397
  as: "label",
1385
1398
  variant: "label",
1386
1399
  htmlFor: name,
1387
- className: "mb-1",
1400
+ className: hideLabel ? "sr-only" : "mb-1",
1388
1401
  children: [label, required && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", {
1389
1402
  className: "ml-1 text-[--color-util-red]",
1390
1403
  children: "*"
@@ -1422,7 +1435,7 @@ function DatePicker(_ref) {
1422
1435
  id: `${name}-error`,
1423
1436
  variant: "small",
1424
1437
  className: "text-[--color-util-red]",
1425
- children: errorMessage
1438
+ children: resolvedErrorMessage
1426
1439
  })]
1427
1440
  });
1428
1441
  }
@@ -1481,6 +1494,9 @@ __webpack_require__.r(__webpack_exports__);
1481
1494
  * @property {boolean} [required]
1482
1495
  * Whether a * is appended.
1483
1496
  *
1497
+ * @property {boolean} [hideLabel]
1498
+ * Hides the visible label while keeping it available to assistive technology.
1499
+ *
1484
1500
  * @property {string} [placeholder]
1485
1501
  *
1486
1502
  * @property {string} [name]
@@ -1515,9 +1531,10 @@ __webpack_require__.r(__webpack_exports__);
1515
1531
  function Dropdown(_ref) {
1516
1532
  let {
1517
1533
  items = [],
1518
- label = "Test Label",
1534
+ label,
1519
1535
  isValid = true,
1520
1536
  required = false,
1537
+ hideLabel = false,
1521
1538
  placeholder = "Example Placeholder",
1522
1539
  name,
1523
1540
  className = "",
@@ -1532,6 +1549,7 @@ function Dropdown(_ref) {
1532
1549
  ...rest
1533
1550
  } = _ref;
1534
1551
  const [selectedItem, setSelectedItem] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
1552
+ const hasLabel = Boolean(label);
1535
1553
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1536
1554
  const newSelectedItem = items.find(item => item.value === value) || null;
1537
1555
  setSelectedItem(newSelectedItem);
@@ -1551,10 +1569,10 @@ function Dropdown(_ref) {
1551
1569
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
1552
1570
  className: `mb-4 flex flex-col ${className}`,
1553
1571
  ...rest,
1554
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1572
+ children: [hasLabel && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1555
1573
  as: "label",
1556
1574
  variant: "label",
1557
- className: "mb-1",
1575
+ className: hideLabel ? "sr-only" : "mb-1",
1558
1576
  htmlFor: name,
1559
1577
  children: [label, required && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", {
1560
1578
  className: "ml-1 text-[--color-util-red]",
@@ -1665,6 +1683,7 @@ __webpack_require__.r(__webpack_exports__);
1665
1683
  * @property {string} [label]
1666
1684
  * @property {boolean} [isValid]
1667
1685
  * @property {boolean} [required]
1686
+ * @property {boolean} [hideLabel]
1668
1687
  * @property {string} [placeholder]
1669
1688
  * @property {string} [searchPlaceholder]
1670
1689
  * @property {string} [name]
@@ -1687,9 +1706,10 @@ __webpack_require__.r(__webpack_exports__);
1687
1706
  function SearchDropdown(_ref) {
1688
1707
  let {
1689
1708
  items = [],
1690
- label = "Test Label",
1709
+ label,
1691
1710
  isValid = true,
1692
1711
  required = false,
1712
+ hideLabel = false,
1693
1713
  placeholder = "Example Placeholder",
1694
1714
  searchPlaceholder = "Search",
1695
1715
  name,
@@ -1707,6 +1727,7 @@ function SearchDropdown(_ref) {
1707
1727
  } = _ref;
1708
1728
  const [selectedItem, setSelectedItem] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
1709
1729
  const [searchTerm, setSearchTerm] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
1730
+ const hasLabel = Boolean(label);
1710
1731
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1711
1732
  const newSelectedItem = items.find(item => item.value === value) || null;
1712
1733
  setSelectedItem(newSelectedItem);
@@ -1734,10 +1755,10 @@ function SearchDropdown(_ref) {
1734
1755
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
1735
1756
  className: `mb-4 flex flex-col ${className}`,
1736
1757
  ...rest,
1737
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1758
+ children: [hasLabel && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1738
1759
  as: "label",
1739
1760
  variant: "label",
1740
- className: "mb-1",
1761
+ className: hideLabel ? "sr-only" : "mb-1",
1741
1762
  htmlFor: name,
1742
1763
  children: [label, required && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", {
1743
1764
  className: "ml-1 text-[--color-util-red]",
@@ -1864,6 +1885,7 @@ __webpack_require__.r(__webpack_exports__);
1864
1885
  * @property {string} [label]
1865
1886
  * @property {boolean} [isValid]
1866
1887
  * @property {boolean} [required]
1888
+ * @property {boolean} [hideLabel]
1867
1889
  * @property {string} [placeholder]
1868
1890
  * @property {string} [searchPlaceholder]
1869
1891
  * @property {string} [name]
@@ -1896,9 +1918,10 @@ __webpack_require__.r(__webpack_exports__);
1896
1918
  function SearchMultiSelectDropdown(_ref) {
1897
1919
  let {
1898
1920
  items = [],
1899
- label = "Test Label",
1921
+ label,
1900
1922
  isValid = true,
1901
1923
  required = false,
1924
+ hideLabel = false,
1902
1925
  placeholder = "Select options",
1903
1926
  searchPlaceholder = "Search",
1904
1927
  name,
@@ -1919,6 +1942,7 @@ function SearchMultiSelectDropdown(_ref) {
1919
1942
  } = _ref;
1920
1943
  const [searchTerm, setSearchTerm] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
1921
1944
  const [localSelectedValues, setLocalSelectedValues] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(value);
1945
+ const hasLabel = Boolean(label);
1922
1946
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1923
1947
  setLocalSelectedValues(value);
1924
1948
  }, [value]);
@@ -1963,10 +1987,10 @@ function SearchMultiSelectDropdown(_ref) {
1963
1987
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", {
1964
1988
  className: `mb-4 flex flex-col ${className}`,
1965
1989
  ...rest,
1966
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1990
+ children: [hasLabel && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1967
1991
  as: "label",
1968
1992
  variant: "label",
1969
- className: "mb-1",
1993
+ className: hideLabel ? "sr-only" : "mb-1",
1970
1994
  htmlFor: name,
1971
1995
  children: [label, required && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("span", {
1972
1996
  className: "ml-1 text-[--color-util-red]",
@@ -2478,7 +2502,7 @@ __webpack_require__.r(__webpack_exports__);
2478
2502
  *
2479
2503
  * @typedef {Object} RadioButtonProps
2480
2504
  *
2481
- * @property {string} label
2505
+ * @property {string} [label]
2482
2506
  * Form label above the radio group.
2483
2507
  *
2484
2508
  * @property {RadioOption[]} [options]
@@ -2541,7 +2565,7 @@ const RadioButton = _ref => {
2541
2565
  tabIndex = "",
2542
2566
  title = "",
2543
2567
  isValid = true,
2544
- errorMessage = `${label} is required`,
2568
+ errorMessage,
2545
2569
  required = false,
2546
2570
  hideLabel = false,
2547
2571
  dataCy,
@@ -2549,6 +2573,10 @@ const RadioButton = _ref => {
2549
2573
  ...rest
2550
2574
  } = _ref;
2551
2575
  const selectedValue = value;
2576
+ const hasLabel = Boolean(label);
2577
+ const labelId = `${name}-label`;
2578
+ const errorId = `${name}-error`;
2579
+ const resolvedErrorMessage = errorMessage || (hasLabel ? `${label} is required` : "This field is required");
2552
2580
  const handleChange = item => {
2553
2581
  if (disabled) return;
2554
2582
  const event = {
@@ -2562,7 +2590,8 @@ const RadioButton = _ref => {
2562
2590
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("div", {
2563
2591
  className: `mb-4 flex flex-col ${className}`,
2564
2592
  ...rest,
2565
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
2593
+ children: [hasLabel && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
2594
+ id: labelId,
2566
2595
  as: "label",
2567
2596
  variant: "label",
2568
2597
  className: hideLabel ? "sr-only" : "mb-2 flex items-center text-[--color-text-strong]",
@@ -2573,6 +2602,9 @@ const RadioButton = _ref => {
2573
2602
  children: "*"
2574
2603
  })]
2575
2604
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", {
2605
+ role: "radiogroup",
2606
+ "aria-labelledby": hasLabel ? labelId : undefined,
2607
+ "aria-describedby": !isValid ? errorId : undefined,
2576
2608
  className: "flex flex-wrap gap-4 md:flex-nowrap md:gap-0 md:space-x-4",
2577
2609
  children: options.map(option => {
2578
2610
  const id = `${name}-${option.value}`;
@@ -2595,16 +2627,16 @@ const RadioButton = _ref => {
2595
2627
  value: option.value,
2596
2628
  dataCy
2597
2629
  }),
2598
- "aria-describedby": !isValid ? `${name}-error` : undefined
2630
+ "aria-describedby": !isValid ? errorId : undefined
2599
2631
  }), option.label]
2600
2632
  }, option.value);
2601
2633
  })
2602
2634
  }), !isValid && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
2603
2635
  as: "span",
2604
2636
  variant: "small",
2605
- id: `${name}-error`,
2637
+ id: errorId,
2606
2638
  className: "text-[--color-util-red]",
2607
- children: errorMessage
2639
+ children: resolvedErrorMessage
2608
2640
  })]
2609
2641
  });
2610
2642
  };