@onewelcome/react-lib-components 1.2.0 → 1.4.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.
Files changed (97) hide show
  1. package/dist/Button/IconButton.d.ts +2 -1
  2. package/dist/DataGrid/DataGrid.d.ts +1 -0
  3. package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +2 -1
  4. package/dist/Form/Form.d.ts +3 -3
  5. package/dist/Notifications/SlideInModal/SlideInModal.d.ts +1 -1
  6. package/dist/Tabs/Tab.d.ts +5 -9
  7. package/dist/Tabs/TabButton.d.ts +3 -6
  8. package/dist/Tabs/Tabs.d.ts +1 -2
  9. package/dist/hooks/useDebouncedCallback.d.ts +1 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/react-lib-components.cjs.development.js +472 -395
  12. package/dist/react-lib-components.cjs.development.js.map +1 -1
  13. package/dist/react-lib-components.cjs.production.min.js +1 -1
  14. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  15. package/dist/react-lib-components.esm.js +473 -397
  16. package/dist/react-lib-components.esm.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/Breadcrumbs/Breadcrumbs.tsx +46 -38
  19. package/src/Button/BaseButton.tsx +23 -20
  20. package/src/Button/Button.module.scss +9 -0
  21. package/src/Button/Button.tsx +40 -40
  22. package/src/Button/IconButton.tsx +28 -28
  23. package/src/ContextMenu/ContextMenu.tsx +161 -160
  24. package/src/ContextMenu/ContextMenuItem.tsx +55 -49
  25. package/src/DataGrid/DataGrid.tsx +1 -0
  26. package/src/DataGrid/DataGridActions/DataGridActions.module.scss +1 -1
  27. package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +4 -2
  28. package/src/DataGrid/DataGridActions/DataGridActions.tsx +95 -87
  29. package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +64 -64
  30. package/src/DataGrid/DataGridBody/DataGridCell.tsx +42 -44
  31. package/src/DataGrid/DataGridBody/DataGridRow.tsx +29 -29
  32. package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +78 -78
  33. package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +48 -48
  34. package/src/Form/Checkbox/Checkbox.tsx +134 -130
  35. package/src/Form/Fieldset/Fieldset.tsx +81 -78
  36. package/src/Form/Form.tsx +9 -4
  37. package/src/Form/FormControl/FormControl.module.scss +1 -20
  38. package/src/Form/FormControl/FormControl.tsx +36 -35
  39. package/src/Form/FormGroup/FormGroup.tsx +62 -62
  40. package/src/Form/FormHelperText/FormHelperText.tsx +19 -18
  41. package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +58 -53
  42. package/src/Form/Input/Input.tsx +90 -87
  43. package/src/Form/Label/Label.tsx +17 -16
  44. package/src/Form/Radio/Radio.tsx +91 -91
  45. package/src/Form/Select/Option.tsx +66 -60
  46. package/src/Form/Select/Select.tsx +207 -209
  47. package/src/Form/Textarea/Textarea.tsx +51 -53
  48. package/src/Form/Toggle/Toggle.tsx +26 -23
  49. package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +51 -43
  50. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +112 -106
  51. package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +67 -62
  52. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +42 -37
  53. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +94 -94
  54. package/src/Form/Wrapper/Wrapper/Wrapper.tsx +73 -73
  55. package/src/Icon/Icon.module.scss +1 -0
  56. package/src/Icon/Icon.tsx +19 -16
  57. package/src/Link/Link.tsx +68 -63
  58. package/src/Notifications/BaseModal/BaseModal.tsx +68 -68
  59. package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +13 -10
  60. package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +33 -25
  61. package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +20 -17
  62. package/src/Notifications/Dialog/Dialog.tsx +83 -83
  63. package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +17 -14
  64. package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +15 -12
  65. package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +40 -40
  66. package/src/Notifications/SlideInModal/SlideInModal.module.scss +5 -5
  67. package/src/Notifications/SlideInModal/SlideInModal.test.tsx +7 -2
  68. package/src/Notifications/SlideInModal/SlideInModal.tsx +47 -27
  69. package/src/Pagination/Pagination.tsx +169 -169
  70. package/src/Popover/Popover.module.scss +1 -0
  71. package/src/Popover/Popover.tsx +43 -33
  72. package/src/ProgressBar/ProgressBar.tsx +17 -14
  73. package/src/Skeleton/Skeleton.tsx +23 -20
  74. package/src/StatusIndicator/StatusIndicator.tsx +18 -15
  75. package/src/Tabs/{TabPanel.module.scss → Tab.module.scss} +1 -1
  76. package/src/Tabs/Tab.test.tsx +1 -39
  77. package/src/Tabs/Tab.tsx +16 -10
  78. package/src/Tabs/TabButton.module.scss +0 -4
  79. package/src/Tabs/TabButton.test.tsx +3 -31
  80. package/src/Tabs/TabButton.tsx +35 -49
  81. package/src/Tabs/Tabs.test.tsx +40 -33
  82. package/src/Tabs/Tabs.tsx +107 -101
  83. package/src/TextEllipsis/TextEllipsis.tsx +50 -41
  84. package/src/Tiles/Tile.tsx +58 -56
  85. package/src/Tiles/Tiles.tsx +44 -41
  86. package/src/Tooltip/Tooltip.tsx +101 -100
  87. package/src/Typography/Typography.tsx +47 -44
  88. package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +55 -52
  89. package/src/Wizard/WizardSteps/WizardSteps.tsx +25 -22
  90. package/src/hooks/useDebouncedCallback.test.ts +140 -0
  91. package/src/hooks/useDebouncedCallback.tsx +32 -0
  92. package/src/index.ts +1 -0
  93. package/src/mixins.module.scss +2 -2
  94. package/src/util/helper.test.tsx +0 -28
  95. package/dist/Tabs/TabPanel.d.ts +0 -8
  96. package/src/Tabs/TabPanel.test.tsx +0 -92
  97. package/src/Tabs/TabPanel.tsx +0 -43
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, useEffect, useState } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef, useEffect, useState } from "react";
18
18
  import { ColumnName, Direction, HeaderCell, OnSortFunction, Sort } from "../datagrid.interfaces";
19
19
  import { DataGridHeaderCell } from "./DataGridHeaderCell";
20
20
  import classes from "./DataGridHeader.module.scss";
@@ -30,90 +30,90 @@ export interface Props extends ComponentPropsWithRef<"thead"> {
30
30
 
31
31
  const sortingStates = [undefined, "ASC", "DESC"] as (Direction | undefined)[];
32
32
 
33
- export const DataGridHeader = React.forwardRef<HTMLTableSectionElement, Props>(
34
- (
35
- {
36
- initialSort,
37
- onSort,
38
- headers,
39
- disableContextMenuColumn,
40
- enableMultiSorting,
41
- spacing,
42
- ...rest
43
- }: Props,
44
- ref
45
- ) => {
46
- const [sortList, setSortList] = useState(initialSort || []);
33
+ const DataGridHeaderComponent: ForwardRefRenderFunction<HTMLTableSectionElement, Props> = (
34
+ {
35
+ initialSort,
36
+ onSort,
37
+ headers,
38
+ disableContextMenuColumn,
39
+ enableMultiSorting,
40
+ spacing,
41
+ ...rest
42
+ }: Props,
43
+ ref
44
+ ) => {
45
+ const [sortList, setSortList] = useState(initialSort || []);
47
46
 
48
- useEffect(() => {
49
- setSortList(initialSort || []);
50
- }, [initialSort]);
47
+ useEffect(() => {
48
+ setSortList(initialSort || []);
49
+ }, [initialSort]);
51
50
 
52
- const calculateNextSortState = (direction?: Direction) => {
53
- const currentDirectionIdx = sortingStates.findIndex(item => item === direction);
54
- return sortingStates[currentDirectionIdx + (1 % sortingStates.length)];
55
- };
51
+ const calculateNextSortState = (direction?: Direction) => {
52
+ const currentDirectionIdx = sortingStates.findIndex(item => item === direction);
53
+ return sortingStates[currentDirectionIdx + (1 % sortingStates.length)];
54
+ };
56
55
 
57
- /**
58
- * The sortList contains sorting columns objects. The order of those objects determinates priorities of sorting.
59
- * Last modified sorting column has the highest priority.
60
- */
61
- const updateSortList = (name: ColumnName): Sort => {
62
- const current = sortList.find(item => item.name === name);
63
- const restSortList = enableMultiSorting ? sortList.filter(item => item.name !== name) : [];
64
- const newSortDirection = calculateNextSortState(current?.direction);
65
- return newSortDirection
66
- ? [{ name, direction: newSortDirection }, ...restSortList]
67
- : restSortList;
68
- };
56
+ /**
57
+ * The sortList contains sorting columns objects. The order of those objects determinates priorities of sorting.
58
+ * Last modified sorting column has the highest priority.
59
+ */
60
+ const updateSortList = (name: ColumnName): Sort => {
61
+ const current = sortList.find(item => item.name === name);
62
+ const restSortList = enableMultiSorting ? sortList.filter(item => item.name !== name) : [];
63
+ const newSortDirection = calculateNextSortState(current?.direction);
64
+ return newSortDirection
65
+ ? [{ name, direction: newSortDirection }, ...restSortList]
66
+ : restSortList;
67
+ };
69
68
 
70
- const wrapOnSort = (name: ColumnName) => {
71
- const newSort = updateSortList(name);
72
- onSort && onSort(newSort);
73
- setSortList(newSort);
74
- };
69
+ const wrapOnSort = (name: ColumnName) => {
70
+ const newSort = updateSortList(name);
71
+ onSort && onSort(newSort);
72
+ setSortList(newSort);
73
+ };
75
74
 
76
- const headerCells = headers.map((header, index) => {
77
- if (header.hidden) {
78
- return null;
79
- }
75
+ const headerCells = headers.map((header, index) => {
76
+ if (header.hidden) {
77
+ return null;
78
+ }
80
79
 
81
- let headerStyle: React.CSSProperties = {};
80
+ let headerStyle: React.CSSProperties = {};
82
81
 
83
- if (index === 0) {
84
- headerStyle.paddingLeft = spacing?.paddingLeft;
85
- }
86
- if (index === headers.length - 1 && disableContextMenuColumn) {
87
- headerStyle.paddingRight = spacing?.paddingRight;
88
- }
89
-
90
- const sort = sortList.find(item => item.name === header.name);
91
- return (
92
- <DataGridHeaderCell
93
- key={header.name}
94
- name={header.name}
95
- headline={header.headline}
96
- disableSorting={header.disableSorting || !onSort}
97
- onSort={wrapOnSort}
98
- activeSortDirection={sort?.direction}
99
- style={headerStyle}
100
- />
101
- );
102
- });
82
+ if (index === 0) {
83
+ headerStyle.paddingLeft = spacing?.paddingLeft;
84
+ }
85
+ if (index === headers.length - 1 && disableContextMenuColumn) {
86
+ headerStyle.paddingRight = spacing?.paddingRight;
87
+ }
103
88
 
89
+ const sort = sortList.find(item => item.name === header.name);
104
90
  return (
105
- <thead {...rest} ref={ref} className={classes["thead"]}>
106
- <tr className={classes["row"]}>
107
- {headerCells}
108
- {!disableContextMenuColumn && (
109
- <td
110
- style={{ paddingRight: spacing?.paddingRight }}
111
- aria-label="context menu"
112
- className={classes["context-menu"]}
113
- ></td>
114
- )}
115
- </tr>
116
- </thead>
91
+ <DataGridHeaderCell
92
+ key={header.name}
93
+ name={header.name}
94
+ headline={header.headline}
95
+ disableSorting={header.disableSorting || !onSort}
96
+ onSort={wrapOnSort}
97
+ activeSortDirection={sort?.direction}
98
+ style={headerStyle}
99
+ />
117
100
  );
118
- }
119
- );
101
+ });
102
+
103
+ return (
104
+ <thead {...rest} ref={ref} className={classes["thead"]}>
105
+ <tr className={classes["row"]}>
106
+ {headerCells}
107
+ {!disableContextMenuColumn && (
108
+ <td
109
+ style={{ paddingRight: spacing?.paddingRight }}
110
+ aria-label="context menu"
111
+ className={classes["context-menu"]}
112
+ ></td>
113
+ )}
114
+ </tr>
115
+ </thead>
116
+ );
117
+ };
118
+
119
+ export const DataGridHeader = React.forwardRef(DataGridHeaderComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, Fragment } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef, Fragment } from "react";
18
18
  import { Icon, Icons } from "../../Icon/Icon";
19
19
  import { ColumnName, Direction } from "../datagrid.interfaces";
20
20
  import classes from "./DataGridHeaderCell.module.scss";
@@ -32,57 +32,57 @@ const ariaSortMapping = {
32
32
  DESC: "descending"
33
33
  } as const;
34
34
 
35
- export const DataGridHeaderCell = React.forwardRef<HTMLTableCellElement, Props>(
36
- ({ headline, name, disableSorting, activeSortDirection, onSort, ...rest }: Props, ref) => {
37
- const onCellClick = () => {
38
- onSort && onSort(name);
39
- };
40
-
41
- const sortingIndicator = () => {
42
- const getSortingIndicatorClasses = (direction: Direction) => {
43
- const sortingIndicatorClasses = [classes["indicator"]];
44
- activeSortDirection &&
45
- sortingIndicatorClasses.push(
46
- activeSortDirection === direction ? classes["active"] : classes["hidden"]
47
- );
48
- return sortingIndicatorClasses;
49
- };
35
+ const DataGridHeaderCellComponent: ForwardRefRenderFunction<HTMLTableCellElement, Props> = (
36
+ { headline, name, disableSorting, activeSortDirection, onSort, ...rest }: Props,
37
+ ref
38
+ ) => {
39
+ const onCellClick = () => {
40
+ onSort && onSort(name);
41
+ };
50
42
 
51
- return (
52
- <Fragment>
53
- <Icon className={getSortingIndicatorClasses("ASC").join(" ")} icon={Icons.TriangleUp} />
54
- <Icon
55
- className={getSortingIndicatorClasses("DESC").join(" ")}
56
- icon={Icons.TriangleDown}
57
- />
58
- </Fragment>
59
- );
43
+ const sortingIndicator = () => {
44
+ const getSortingIndicatorClasses = (direction: Direction) => {
45
+ const sortingIndicatorClasses = [classes["indicator"]];
46
+ activeSortDirection &&
47
+ sortingIndicatorClasses.push(
48
+ activeSortDirection === direction ? classes["active"] : classes["hidden"]
49
+ );
50
+ return sortingIndicatorClasses;
60
51
  };
61
52
 
62
- const innerContent = (
53
+ return (
63
54
  <Fragment>
64
- <span className={classes["headline"]}>{headline}</span>
65
- {!disableSorting && (
66
- <div className={classes["sorting-indicator-container"]}>{sortingIndicator()}</div>
67
- )}
55
+ <Icon className={getSortingIndicatorClasses("ASC").join(" ")} icon={Icons.TriangleUp} />
56
+ <Icon className={getSortingIndicatorClasses("DESC").join(" ")} icon={Icons.TriangleDown} />
68
57
  </Fragment>
69
58
  );
59
+ };
70
60
 
71
- return (
72
- <th
73
- {...rest}
74
- ref={ref}
75
- className={classes["header-cell"]}
76
- aria-sort={activeSortDirection && ariaSortMapping[activeSortDirection]}
77
- >
78
- {disableSorting ? (
79
- <div key={name}>{innerContent}</div>
80
- ) : (
81
- <button key={name} onClick={onCellClick}>
82
- {innerContent}
83
- </button>
84
- )}
85
- </th>
86
- );
87
- }
88
- );
61
+ const innerContent = (
62
+ <Fragment>
63
+ <span className={classes["headline"]}>{headline}</span>
64
+ {!disableSorting && (
65
+ <div className={classes["sorting-indicator-container"]}>{sortingIndicator()}</div>
66
+ )}
67
+ </Fragment>
68
+ );
69
+
70
+ return (
71
+ <th
72
+ {...rest}
73
+ ref={ref}
74
+ className={classes["header-cell"]}
75
+ aria-sort={activeSortDirection && ariaSortMapping[activeSortDirection]}
76
+ >
77
+ {disableSorting ? (
78
+ <div key={name}>{innerContent}</div>
79
+ ) : (
80
+ <button key={name} onClick={onCellClick}>
81
+ {innerContent}
82
+ </button>
83
+ )}
84
+ </th>
85
+ );
86
+ };
87
+
88
+ export const DataGridHeaderCell = React.forwardRef(DataGridHeaderCellComponent);
@@ -14,7 +14,13 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, ReactElement, ReactNode, useEffect } from "react";
17
+ import React, {
18
+ ForwardRefRenderFunction,
19
+ ComponentPropsWithRef,
20
+ ReactElement,
21
+ ReactNode,
22
+ useEffect
23
+ } from "react";
18
24
  import { Icon, Icons } from "../../Icon/Icon";
19
25
  import { Props as FormHelperTextProps } from "../FormHelperText/FormHelperText";
20
26
  import classes from "./Checkbox.module.scss";
@@ -36,141 +42,139 @@ export interface Props extends ComponentPropsWithRef<"input">, FormSelector {
36
42
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
37
43
  }
38
44
 
39
- export const Checkbox = React.forwardRef<HTMLInputElement, Props>(
40
- (
41
- {
42
- children,
43
- name,
44
- helperText,
45
- helperProps,
46
- indeterminate,
47
- parentErrorId,
48
- errorMessage,
49
- disabled,
50
- label,
51
- parentHelperId,
52
- className,
53
- error,
54
- checked = false,
55
- formSelectorWrapperProps,
56
- onChange,
57
- ...rest
58
- }: Props,
59
- ref
60
- ) => {
61
- const { errorId, identifier, describedBy } = useFormSelector({
62
- name,
63
- helperText,
64
- parentErrorId,
65
- errorMessage,
66
- error,
67
- parentHelperId
68
- });
69
-
70
- useEffect(() => {
71
- if (!name) {
72
- throw new Error("Please pass a 'name' prop to your <Checkbox> component.");
73
- }
45
+ const CheckboxComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
46
+ {
47
+ children,
48
+ name,
49
+ helperText,
50
+ helperProps,
51
+ indeterminate,
52
+ parentErrorId,
53
+ errorMessage,
54
+ disabled,
55
+ label,
56
+ parentHelperId,
57
+ className,
58
+ error,
59
+ checked = false,
60
+ formSelectorWrapperProps,
61
+ onChange,
62
+ ...rest
63
+ }: Props,
64
+ ref
65
+ ) => {
66
+ const { errorId, identifier, describedBy } = useFormSelector({
67
+ name,
68
+ helperText,
69
+ parentErrorId,
70
+ errorMessage,
71
+ error,
72
+ parentHelperId
73
+ });
74
74
 
75
- if (typeof children === "object" && !isToggle(children) && indeterminate === undefined) {
76
- throw new Error(
77
- "If you have nested checkboxes you have to manage the indeterminate state by passing a boolean to the `indeterminate` prop."
78
- );
79
- }
80
- }, []);
81
-
82
- const determineLabel = () => {
83
- if (label) {
84
- return label;
85
- } else if (children === undefined) {
86
- throw new Error(
87
- "Please make sure to pass either a string or more Checkbox components as a child of your Checkbox component."
88
- );
89
- }
75
+ useEffect(() => {
76
+ if (!name) {
77
+ throw new Error("Please pass a 'name' prop to your <Checkbox> component.");
78
+ }
90
79
 
91
- if (typeof children === "string") {
92
- return children;
93
- }
80
+ if (typeof children === "object" && !isToggle(children) && indeterminate === undefined) {
81
+ throw new Error(
82
+ "If you have nested checkboxes you have to manage the indeterminate state by passing a boolean to the `indeterminate` prop."
83
+ );
84
+ }
85
+ }, []);
94
86
 
87
+ const determineLabel = () => {
88
+ if (label) {
89
+ return label;
90
+ } else if (children === undefined) {
95
91
  throw new Error(
96
- "If you pass Checkboxes as a child component (to create nested checkbox tree) you need to pass a label to the parent checkbox."
92
+ "Please make sure to pass either a string or more Checkbox components as a child of your Checkbox component."
97
93
  );
98
- };
99
-
100
- const renderNestedCheckboxes = () => (
101
- <ul className={classes["checkbox-list"]}>
102
- {React.Children.map(children as ReactElement[], child => {
103
- return (
104
- <li>
105
- <Checkbox
106
- {...child.props}
107
- parentHelperId={parentHelperId}
108
- parentErrorId={parentErrorId}
109
- error={error}
110
- disabled={child.props.disabled ? child.props.disabled : disabled}
111
- >
112
- {child.props.children}
113
- </Checkbox>
114
- </li>
115
- );
116
- })}
117
- </ul>
94
+ }
95
+
96
+ if (typeof children === "string") {
97
+ return children;
98
+ }
99
+
100
+ throw new Error(
101
+ "If you pass Checkboxes as a child component (to create nested checkbox tree) you need to pass a label to the parent checkbox."
118
102
  );
103
+ };
104
+
105
+ const renderNestedCheckboxes = () => (
106
+ <ul className={classes["checkbox-list"]}>
107
+ {React.Children.map(children as ReactElement[], child => {
108
+ return (
109
+ <li>
110
+ <Checkbox
111
+ {...child.props}
112
+ parentHelperId={parentHelperId}
113
+ parentErrorId={parentErrorId}
114
+ error={error}
115
+ disabled={child.props.disabled ? child.props.disabled : disabled}
116
+ >
117
+ {child.props.children}
118
+ </Checkbox>
119
+ </li>
120
+ );
121
+ })}
122
+ </ul>
123
+ );
124
+
125
+ const onChangeHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
126
+ if (disabled) {
127
+ return;
128
+ }
129
+ onChange && onChange(event);
130
+ };
131
+
132
+ const renderToggle = () => React.Children.toArray(children).filter(isToggle);
119
133
 
120
- const onChangeHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
121
- if (disabled) {
122
- return;
134
+ const iconClasses = [classes["input"], disabled ? classes["disabled"] : ""];
135
+
136
+ /** Default return value is the default checkbox */
137
+ return (
138
+ <FormSelectorWrapper
139
+ {...formSelectorWrapperProps}
140
+ className={`${classes["checkbox-wrapper"]} ${className ? className : ""}`}
141
+ containerProps={{ className: classes["checkbox-container"] }}
142
+ helperText={helperText}
143
+ helperProps={helperProps}
144
+ parentErrorId={parentErrorId}
145
+ errorId={errorId}
146
+ errorMessage={errorMessage}
147
+ error={error}
148
+ disabled={disabled}
149
+ identifier={identifier}
150
+ nestedChildren={
151
+ typeof children === "object" && !isToggle(children) && renderNestedCheckboxes()
123
152
  }
124
- onChange && onChange(event);
125
- };
126
-
127
- const renderToggle = () => React.Children.toArray(children).filter(isToggle);
128
-
129
- const iconClasses = [classes["input"], disabled ? classes["disabled"] : ""];
130
-
131
- /** Default return value is the default checkbox */
132
- return (
133
- <FormSelectorWrapper
134
- {...formSelectorWrapperProps}
135
- className={`${classes["checkbox-wrapper"]} ${className ? className : ""}`}
136
- containerProps={{ className: classes["checkbox-container"] }}
137
- helperText={helperText}
138
- helperProps={helperProps}
139
- parentErrorId={parentErrorId}
140
- errorId={errorId}
141
- errorMessage={errorMessage}
142
- error={error}
153
+ >
154
+ <input
155
+ {...rest}
156
+ ref={ref}
143
157
  disabled={disabled}
144
- identifier={identifier}
145
- nestedChildren={
146
- typeof children === "object" && !isToggle(children) && renderNestedCheckboxes()
147
- }
148
- >
149
- <input
150
- {...rest}
151
- ref={ref}
152
- disabled={disabled}
153
- className={`${classes["native-input"]} ${error ? classes["error"] : ""}`}
154
- checked={checked}
155
- onChange={onChangeHandler}
156
- aria-invalid={error as boolean}
157
- aria-checked={indeterminate ? "mixed" : checked}
158
- aria-describedby={describedBy}
159
- id={`${identifier}-checkbox`}
160
- name={name}
161
- type="checkbox"
162
- />
163
- {renderToggle()}
164
-
165
- {indeterminate && <Icon className={iconClasses.join(" ")} icon={Icons.MinusSquare} />}
166
- {checked && !indeterminate && (
167
- <Icon className={iconClasses.join(" ")} icon={Icons.CheckmarkSquare} />
168
- )}
169
- {!checked && !indeterminate && (
170
- <Icon className={iconClasses.join(" ")} icon={Icons.Square} />
171
- )}
172
- <label htmlFor={`${identifier}-checkbox`}>{determineLabel()}</label>
173
- </FormSelectorWrapper>
174
- );
175
- }
176
- );
158
+ className={`${classes["native-input"]} ${error ? classes["error"] : ""}`}
159
+ checked={checked}
160
+ onChange={onChangeHandler}
161
+ aria-invalid={error as boolean}
162
+ aria-checked={indeterminate ? "mixed" : checked}
163
+ aria-describedby={describedBy}
164
+ id={`${identifier}-checkbox`}
165
+ name={name}
166
+ type="checkbox"
167
+ />
168
+ {renderToggle()}
169
+
170
+ {indeterminate && <Icon className={iconClasses.join(" ")} icon={Icons.MinusSquare} />}
171
+ {checked && !indeterminate && (
172
+ <Icon className={iconClasses.join(" ")} icon={Icons.CheckmarkSquare} />
173
+ )}
174
+ {!checked && !indeterminate && <Icon className={iconClasses.join(" ")} icon={Icons.Square} />}
175
+ <label htmlFor={`${identifier}-checkbox`}>{determineLabel()}</label>
176
+ </FormSelectorWrapper>
177
+ );
178
+ };
179
+
180
+ export const Checkbox = React.forwardRef(CheckboxComponent);