@okta/odyssey-react-mui 1.14.2 → 1.14.4

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 (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/DataTable/DataTable.js +330 -0
  3. package/dist/DataTable/DataTable.js.map +1 -0
  4. package/dist/DataTable/DataTableRowActions.js +89 -0
  5. package/dist/DataTable/DataTableRowActions.js.map +1 -0
  6. package/dist/DataTable/DataTableSettings.js +72 -0
  7. package/dist/DataTable/DataTableSettings.js.map +1 -0
  8. package/dist/DataTable/constants.js +14 -0
  9. package/dist/DataTable/constants.js.map +1 -0
  10. package/dist/DataTable/index.js +14 -0
  11. package/dist/DataTable/index.js.map +1 -0
  12. package/dist/DataTable/reorderDataRowsLocally.js +26 -0
  13. package/dist/DataTable/reorderDataRowsLocally.js.map +1 -0
  14. package/dist/DataTable/useRowReordering.js +179 -0
  15. package/dist/DataTable/useRowReordering.js.map +1 -0
  16. package/dist/IconWithTooltip.js +63 -0
  17. package/dist/IconWithTooltip.js.map +1 -0
  18. package/dist/index.js +2 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/labs/DataFilters.js +42 -14
  21. package/dist/labs/DataFilters.js.map +1 -1
  22. package/dist/labs/DataTable.js +16 -11
  23. package/dist/labs/DataTable.js.map +1 -1
  24. package/dist/labs/index.js +0 -1
  25. package/dist/labs/index.js.map +1 -1
  26. package/dist/properties/ts/odyssey-react-mui.js +18 -1
  27. package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
  28. package/dist/src/DataTable/DataTable.d.ts +133 -0
  29. package/dist/src/DataTable/DataTable.d.ts.map +1 -0
  30. package/dist/src/DataTable/DataTableRowActions.d.ts +30 -0
  31. package/dist/src/DataTable/DataTableRowActions.d.ts.map +1 -0
  32. package/dist/src/DataTable/DataTableSettings.d.ts +27 -0
  33. package/dist/src/DataTable/DataTableSettings.d.ts.map +1 -0
  34. package/dist/src/DataTable/constants.d.ts +13 -0
  35. package/dist/src/DataTable/constants.d.ts.map +1 -0
  36. package/dist/src/DataTable/index.d.ts +15 -0
  37. package/dist/src/DataTable/index.d.ts.map +1 -0
  38. package/dist/src/DataTable/reorderDataRowsLocally.d.ts +26 -0
  39. package/dist/src/DataTable/reorderDataRowsLocally.d.ts.map +1 -0
  40. package/dist/src/DataTable/useRowReordering.d.ts +56 -0
  41. package/dist/src/DataTable/useRowReordering.d.ts.map +1 -0
  42. package/dist/src/IconWithTooltip.d.ts +31 -0
  43. package/dist/src/IconWithTooltip.d.ts.map +1 -0
  44. package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
  45. package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
  46. package/dist/src/index.d.ts +2 -0
  47. package/dist/src/index.d.ts.map +1 -1
  48. package/dist/src/labs/DataFilters.d.ts.map +1 -1
  49. package/dist/src/labs/DataTable.d.ts +2 -2
  50. package/dist/src/labs/DataTable.d.ts.map +1 -1
  51. package/dist/src/labs/index.d.ts +0 -1
  52. package/dist/src/labs/index.d.ts.map +1 -1
  53. package/dist/src/properties/ts/odyssey-react-mui.d.ts +18 -1
  54. package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
  55. package/dist/src/theme/components.d.ts.map +1 -1
  56. package/dist/theme/components.js +37 -18
  57. package/dist/theme/components.js.map +1 -1
  58. package/dist/tsconfig.production.tsbuildinfo +1 -1
  59. package/package.json +3 -3
  60. package/src/DataTable/DataTable.tsx +538 -0
  61. package/src/DataTable/DataTableRowActions.tsx +124 -0
  62. package/src/DataTable/DataTableSettings.tsx +109 -0
  63. package/src/DataTable/constants.ts +13 -0
  64. package/src/DataTable/index.tsx +22 -0
  65. package/src/DataTable/reorderDataRowsLocally.tsx +48 -0
  66. package/src/DataTable/useRowReordering.tsx +233 -0
  67. package/src/IconWithTooltip.tsx +90 -0
  68. package/src/index.ts +2 -0
  69. package/src/labs/DataFilters.tsx +60 -17
  70. package/src/labs/DataTable.tsx +24 -11
  71. package/src/labs/index.ts +0 -1
  72. package/src/properties/odyssey-react-mui.properties +19 -2
  73. package/src/properties/ts/odyssey-react-mui.ts +1 -1
  74. package/src/theme/components.tsx +43 -16
@@ -0,0 +1,109 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { Dispatch, SetStateAction, memo } from "react";
14
+ import { Checkbox as MuiCheckbox } from "@mui/material";
15
+ import { MenuButton } from "../MenuButton";
16
+ import { MenuItem } from "../MenuItem";
17
+ import { ListIcon, ShowIcon } from "../icons.generated";
18
+ import { densityValues } from "./constants";
19
+ import { DataTableProps } from "./DataTable";
20
+ import { MRT_VisibilityState } from "material-react-table";
21
+ import { useTranslation } from "react-i18next";
22
+
23
+ export type DataTableSettingsProps = {
24
+ hasChangeableDensity: DataTableProps["hasChangeableDensity"];
25
+ rowDensity: (typeof densityValues)[number];
26
+ setRowDensity: Dispatch<SetStateAction<(typeof densityValues)[number]>>;
27
+ hasColumnVisibility: DataTableProps["hasColumnVisibility"];
28
+ columns: DataTableProps["columns"];
29
+ columnVisibility?: MRT_VisibilityState;
30
+ setColumnVisibility: Dispatch<
31
+ SetStateAction<MRT_VisibilityState | undefined>
32
+ >;
33
+ };
34
+
35
+ const DataTableSettings = ({
36
+ hasChangeableDensity,
37
+ rowDensity,
38
+ setRowDensity,
39
+ hasColumnVisibility,
40
+ columns,
41
+ columnVisibility,
42
+ setColumnVisibility,
43
+ }: DataTableSettingsProps) => {
44
+ const { t } = useTranslation();
45
+ return (
46
+ <>
47
+ {hasChangeableDensity && (
48
+ <MenuButton
49
+ endIcon={<ListIcon />}
50
+ ariaLabel={t("table.density.arialabel")}
51
+ menuAlignment="right"
52
+ shouldCloseOnSelect={false}
53
+ >
54
+ <>
55
+ {densityValues.map((value: (typeof densityValues)[number]) => (
56
+ <MenuItem
57
+ key={value}
58
+ isSelected={rowDensity === value}
59
+ onClick={() => setRowDensity(value)}
60
+ >
61
+ {`${value.charAt(0).toUpperCase()}${value.slice(1)}`}
62
+ </MenuItem>
63
+ ))}
64
+ </>
65
+ </MenuButton>
66
+ )}
67
+
68
+ {hasColumnVisibility && (
69
+ <MenuButton
70
+ endIcon={<ShowIcon />}
71
+ ariaLabel={t("table.columnvisibility.arialabel")}
72
+ menuAlignment="right"
73
+ shouldCloseOnSelect={false}
74
+ >
75
+ <>
76
+ {columns
77
+ .filter((column) => column.enableHiding !== false)
78
+ .map((column) => (
79
+ <MenuItem
80
+ key={column.accessorKey}
81
+ onClick={() => {
82
+ const columnId = column.id as string;
83
+ setColumnVisibility((prevVisibility) => ({
84
+ ...prevVisibility,
85
+ [columnId]: prevVisibility
86
+ ? prevVisibility[columnId] === false
87
+ : false,
88
+ }));
89
+ }}
90
+ >
91
+ <MuiCheckbox
92
+ checked={
93
+ columnVisibility
94
+ ? columnVisibility[column.accessorKey as string] !==
95
+ false
96
+ : true
97
+ }
98
+ />
99
+ {column.header}
100
+ </MenuItem>
101
+ ))}
102
+ </>
103
+ </MenuButton>
104
+ )}
105
+ </>
106
+ );
107
+ };
108
+ const MemoizedDataTableSettings = memo(DataTableSettings);
109
+ export { MemoizedDataTableSettings as DataTableSettings };
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ export const densityValues = ["comfortable", "spacious", "compact"] as const;
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ export { DataTable, type DataTableProps } from "./DataTable";
14
+ export { densityValues } from "./constants";
15
+ export type {
16
+ MRT_ColumnFiltersState as DataTableFiltersState,
17
+ MRT_SortingState as DataTableSortingState,
18
+ MRT_RowSelectionState as DataTableRowSelectionState,
19
+ MRT_ColumnDef as DataTableColumn,
20
+ MRT_RowData as DataTableRowData,
21
+ MRT_Row as DataTableRow,
22
+ } from "material-react-table";
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { MRT_RowData } from "material-react-table";
14
+
15
+ /**
16
+ * Reorders data rows locally.
17
+ *
18
+ * @param currentData - The current array of data rows.
19
+ * @param rowId - The ID of the row to move.
20
+ * @param newIndex - The new index to move the row to.
21
+ * @returns A new array of data with the row moved to the specified index.
22
+ */
23
+ export const reorderDataRowsLocally = ({
24
+ currentData,
25
+ rowId,
26
+ newRowIndex,
27
+ }: {
28
+ currentData: MRT_RowData[];
29
+ rowId: string;
30
+ newRowIndex: number;
31
+ }): MRT_RowData[] => {
32
+ const updatedData = [...currentData];
33
+ const rowIndex = updatedData.findIndex((row) => row.id === rowId);
34
+
35
+ // Ensure the row exists and the new index is within bounds
36
+ if (rowIndex === -1 || newRowIndex < 0 || newRowIndex >= updatedData.length) {
37
+ console.warn("Invalid row ID or newIndex; cannot reorder rows.");
38
+ return updatedData; // Return the original data if conditions aren't met
39
+ }
40
+
41
+ // Remove the row from its current position
42
+ const [removedRow] = updatedData.splice(rowIndex, 1);
43
+
44
+ // Insert the row at the new index
45
+ updatedData.splice(newRowIndex, 0, removedRow);
46
+
47
+ return updatedData;
48
+ };
@@ -0,0 +1,233 @@
1
+ /*!
2
+ * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { Dispatch, SetStateAction, KeyboardEvent } from "react";
14
+ import { DataTableProps } from "./DataTable";
15
+ import { reorderDataRowsLocally } from "./reorderDataRowsLocally";
16
+ import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext";
17
+ import { MRT_Row, MRT_RowData, MRT_TableInstance } from "material-react-table";
18
+
19
+ export const useRowReordering = ({
20
+ totalRows,
21
+ onReorderRows,
22
+ data,
23
+ setData,
24
+ draggingRow,
25
+ setDraggingRow,
26
+ resultsPerPage,
27
+ page,
28
+ }: {
29
+ totalRows: DataTableProps["totalRows"];
30
+ onReorderRows: DataTableProps["onReorderRows"];
31
+ data: MRT_RowData[];
32
+ setData: Dispatch<SetStateAction<MRT_RowData[]>>;
33
+ draggingRow?: MRT_Row<MRT_RowData> | null;
34
+ setDraggingRow: Dispatch<
35
+ SetStateAction<MRT_Row<MRT_RowData> | null | undefined>
36
+ >;
37
+ resultsPerPage: number;
38
+ page: number;
39
+ }) => {
40
+ const updateRowOrder = ({
41
+ rowId,
42
+ newRowIndex,
43
+ }: {
44
+ rowId: string;
45
+ newRowIndex: number;
46
+ }) => {
47
+ if (newRowIndex < 0) {
48
+ return;
49
+ }
50
+
51
+ if (totalRows && newRowIndex > totalRows) {
52
+ return;
53
+ }
54
+
55
+ const newData = reorderDataRowsLocally({
56
+ currentData: data,
57
+ rowId,
58
+ newRowIndex,
59
+ });
60
+
61
+ setData(newData);
62
+ onReorderRows?.({ rowId, newRowIndex });
63
+ };
64
+
65
+ const odysseyDesignTokens = useOdysseyDesignTokens();
66
+ const dragHandleStyles = {
67
+ padding: odysseyDesignTokens.Spacing1,
68
+ borderRadius: odysseyDesignTokens.BorderRadiusMain,
69
+
70
+ "&:focus-visible": {
71
+ boxShadow: `0 0 0 2px ${odysseyDesignTokens.HueNeutralWhite}, 0 0 0 4px ${odysseyDesignTokens.PalettePrimaryMain}`,
72
+ outline: "2px solid transparent",
73
+ outlineOffset: "1px",
74
+ },
75
+ };
76
+
77
+ const dragHandleText = {
78
+ title: "Drag row or press space/enter key to start and stop reordering",
79
+ "aria-label":
80
+ "Drag row to reorder. Or, press space or enter to start and stop reordering and esc to cancel.",
81
+ };
82
+
83
+ const draggableTableBodyRowClassName = ({
84
+ currentRowId,
85
+ draggingRowId,
86
+ hoveredRowId,
87
+ }: {
88
+ currentRowId: string;
89
+ draggingRowId?: string;
90
+ hoveredRowId?: string;
91
+ }) => {
92
+ if (draggingRowId === currentRowId && hoveredRowId !== currentRowId) {
93
+ return "isDragging";
94
+ }
95
+
96
+ if (hoveredRowId === currentRowId && draggingRowId !== currentRowId) {
97
+ return "isDragTarget";
98
+ }
99
+
100
+ if (draggingRowId === currentRowId && hoveredRowId === currentRowId) {
101
+ return "isDragging isDragTarget";
102
+ }
103
+
104
+ return undefined;
105
+ };
106
+
107
+ const getRowFromTableAndSetHovered = (
108
+ table: MRT_TableInstance<MRT_RowData>,
109
+ id: MRT_RowData["id"],
110
+ ) => {
111
+ if (id) {
112
+ const nextRow: MRT_RowData = table.getRow(id);
113
+
114
+ if (nextRow) {
115
+ table.setHoveredRow(nextRow);
116
+ }
117
+ }
118
+ };
119
+
120
+ type HandleDragHandleKeyDownArgs = {
121
+ table: MRT_TableInstance<MRT_RowData>;
122
+ row: MRT_Row<MRT_RowData>;
123
+ event: KeyboardEvent<HTMLButtonElement>;
124
+ };
125
+
126
+ const handleDragHandleKeyDown = ({
127
+ table,
128
+ row,
129
+ event,
130
+ }: HandleDragHandleKeyDownArgs) => {
131
+ const { hoveredRow } = table.getState();
132
+
133
+ const { key } = event;
134
+
135
+ const isSpaceKey = key === " ";
136
+ const isEnterKey = key === "Enter";
137
+ const isEscapeKey = key === "Escape";
138
+ const isArrowDown = key === "ArrowDown";
139
+ const isArrowUp = key === "ArrowUp";
140
+ const isSpaceOrEnter = isSpaceKey || isEnterKey;
141
+ const zeroIndexedPageNumber = page - 1;
142
+ const currentIndex = row.index + zeroIndexedPageNumber * resultsPerPage;
143
+
144
+ if (isEscapeKey) {
145
+ resetDraggingAndHoveredRow(table);
146
+ return;
147
+ }
148
+
149
+ if (isSpaceOrEnter) {
150
+ event.preventDefault();
151
+ event.stopPropagation();
152
+ }
153
+
154
+ if (draggingRow) {
155
+ if (typeof hoveredRow?.index === "number") {
156
+ const { index } = hoveredRow;
157
+
158
+ if (isSpaceOrEnter) {
159
+ const pageRelativeIndex =
160
+ index + zeroIndexedPageNumber * resultsPerPage;
161
+
162
+ if (pageRelativeIndex !== currentIndex) {
163
+ updateRowOrder({
164
+ rowId: row.id,
165
+ newRowIndex: pageRelativeIndex,
166
+ });
167
+
168
+ // Can't transition CSS hover effect. Use timeout to delay hovered row effect removal
169
+ setTimeout(() => {
170
+ resetDraggingAndHoveredRow(table);
171
+ }, odysseyDesignTokens.TransitionDurationMainAsNumber);
172
+ return;
173
+ }
174
+ }
175
+
176
+ if (isArrowDown || isArrowUp) {
177
+ const nextIndex = isArrowDown ? index + 1 : index - 1;
178
+ getRowFromTableAndSetHovered(table, data[nextIndex]?.id);
179
+ }
180
+ } else {
181
+ if (isArrowDown || isArrowUp) {
182
+ const nextIndex = isArrowDown ? row.index + 1 : row.index - 1;
183
+ getRowFromTableAndSetHovered(table, data[nextIndex]?.id);
184
+ }
185
+ }
186
+ } else {
187
+ if (isSpaceOrEnter) {
188
+ setDraggingRow(row);
189
+ }
190
+ }
191
+ };
192
+
193
+ const handleDragHandleOnDragEnd = (table: MRT_TableInstance<MRT_RowData>) => {
194
+ const cols = table.getAllColumns();
195
+ cols[0].toggleVisibility();
196
+
197
+ const { draggingRow, hoveredRow } = table.getState();
198
+ if (draggingRow) {
199
+ updateRowOrder({
200
+ rowId: draggingRow.id,
201
+ newRowIndex: (hoveredRow as MRT_RowData).index,
202
+ });
203
+ }
204
+
205
+ setDraggingRow(null);
206
+ };
207
+
208
+ const handleDragHandleOnDragCapture = (
209
+ table: MRT_TableInstance<MRT_RowData>,
210
+ ) => {
211
+ if (!draggingRow && table.getState().draggingRow?.id) {
212
+ setDraggingRow(table.getState().draggingRow);
213
+ }
214
+ };
215
+
216
+ const resetDraggingAndHoveredRow = (
217
+ table: MRT_TableInstance<MRT_RowData>,
218
+ ) => {
219
+ setDraggingRow(null);
220
+ table.setHoveredRow(null);
221
+ };
222
+
223
+ return {
224
+ dragHandleStyles,
225
+ dragHandleText,
226
+ draggableTableBodyRowClassName,
227
+ handleDragHandleKeyDown,
228
+ handleDragHandleOnDragCapture,
229
+ handleDragHandleOnDragEnd,
230
+ resetDraggingAndHoveredRow,
231
+ updateRowOrder,
232
+ };
233
+ };
@@ -0,0 +1,90 @@
1
+ /*!
2
+ * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { memo, ReactNode } from "react";
14
+ import styled from "@emotion/styled";
15
+ import { Tooltip as MuiTooltip } from "@mui/material";
16
+ import type { TooltipProps as MuiTooltipProps } from "@mui/material";
17
+
18
+ import { HtmlProps } from "./HtmlProps";
19
+ import { InformationCircleIcon } from "./icons.generated";
20
+ import { useMuiProps } from "./MuiPropsContext";
21
+ import {
22
+ useOdysseyDesignTokens,
23
+ DesignTokens,
24
+ } from "./OdysseyDesignTokensContext";
25
+
26
+ const IconContainer = styled.span<{
27
+ odysseyDesignTokens: DesignTokens;
28
+ }>(({ odysseyDesignTokens }) => ({
29
+ display: "inline-flex",
30
+ transitionProperty: "border-color, box-shadow, outline",
31
+ transitionDuration: odysseyDesignTokens.TransitionDurationMain,
32
+ border: "1px solid transparent",
33
+
34
+ "&:focus, &:focus-visible": {
35
+ borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,
36
+ boxShadow: `0 0 0 1px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,
37
+ outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,
38
+ outlineOffset: odysseyDesignTokens.FocusOutlineOffsetTight,
39
+ },
40
+
41
+ svg: {
42
+ display: "flex",
43
+ },
44
+ }));
45
+
46
+ export type IconWithTooltipProps = {
47
+ /**
48
+ * The icon to render. Defaults to `InformationCircleIcon`
49
+ */
50
+ IconComponent?: ReactNode;
51
+ /**
52
+ * The placement of the Tooltip
53
+ */
54
+ placement?: MuiTooltipProps["placement"];
55
+ /**
56
+ * The text to display in the Tooltip
57
+ */
58
+ tooltipText: string;
59
+ } & Pick<HtmlProps, "testId" | "translate">;
60
+
61
+ const IconWithTooltip = ({
62
+ IconComponent = <InformationCircleIcon />,
63
+ placement = "right",
64
+ testId,
65
+ tooltipText,
66
+ translate,
67
+ }: IconWithTooltipProps) => {
68
+ const muiProps = useMuiProps();
69
+ const odysseyDesignTokens = useOdysseyDesignTokens();
70
+
71
+ return (
72
+ <MuiTooltip
73
+ data-se={testId}
74
+ describeChild
75
+ placement={placement}
76
+ tabIndex={0}
77
+ title={tooltipText}
78
+ translate={translate}
79
+ >
80
+ <IconContainer odysseyDesignTokens={odysseyDesignTokens} {...muiProps}>
81
+ {IconComponent}
82
+ </IconContainer>
83
+ </MuiTooltip>
84
+ );
85
+ };
86
+
87
+ const MemoizedIconWithTooltip = memo(IconWithTooltip);
88
+ MemoizedIconWithTooltip.displayName = "IconWithTooltip";
89
+
90
+ export { MemoizedIconWithTooltip as IconWithTooltip };
package/src/index.ts CHANGED
@@ -69,11 +69,13 @@ export * from "./CircularProgress";
69
69
  export * from "./CssBaseline";
70
70
  export * from "./createShadowRootElement";
71
71
  export * from "./createUniqueId";
72
+ export * from "./DataTable";
72
73
  export * from "./Dialog";
73
74
  export * from "./Fieldset";
74
75
  export * from "./FieldComponentProps";
75
76
  export * from "./Form";
76
77
  export * from "./HintLink";
78
+ export * from "./IconWithTooltip";
77
79
  export * from "./Link";
78
80
  export * from "./MenuButton";
79
81
  export * from "./MenuItem";