@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.
- package/CHANGELOG.md +8 -0
- package/dist/DataTable/DataTable.js +330 -0
- package/dist/DataTable/DataTable.js.map +1 -0
- package/dist/DataTable/DataTableRowActions.js +89 -0
- package/dist/DataTable/DataTableRowActions.js.map +1 -0
- package/dist/DataTable/DataTableSettings.js +72 -0
- package/dist/DataTable/DataTableSettings.js.map +1 -0
- package/dist/DataTable/constants.js +14 -0
- package/dist/DataTable/constants.js.map +1 -0
- package/dist/DataTable/index.js +14 -0
- package/dist/DataTable/index.js.map +1 -0
- package/dist/DataTable/reorderDataRowsLocally.js +26 -0
- package/dist/DataTable/reorderDataRowsLocally.js.map +1 -0
- package/dist/DataTable/useRowReordering.js +179 -0
- package/dist/DataTable/useRowReordering.js.map +1 -0
- package/dist/IconWithTooltip.js +63 -0
- package/dist/IconWithTooltip.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/labs/DataFilters.js +42 -14
- package/dist/labs/DataFilters.js.map +1 -1
- package/dist/labs/DataTable.js +16 -11
- package/dist/labs/DataTable.js.map +1 -1
- package/dist/labs/index.js +0 -1
- package/dist/labs/index.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui.js +18 -1
- package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/src/DataTable/DataTable.d.ts +133 -0
- package/dist/src/DataTable/DataTable.d.ts.map +1 -0
- package/dist/src/DataTable/DataTableRowActions.d.ts +30 -0
- package/dist/src/DataTable/DataTableRowActions.d.ts.map +1 -0
- package/dist/src/DataTable/DataTableSettings.d.ts +27 -0
- package/dist/src/DataTable/DataTableSettings.d.ts.map +1 -0
- package/dist/src/DataTable/constants.d.ts +13 -0
- package/dist/src/DataTable/constants.d.ts.map +1 -0
- package/dist/src/DataTable/index.d.ts +15 -0
- package/dist/src/DataTable/index.d.ts.map +1 -0
- package/dist/src/DataTable/reorderDataRowsLocally.d.ts +26 -0
- package/dist/src/DataTable/reorderDataRowsLocally.d.ts.map +1 -0
- package/dist/src/DataTable/useRowReordering.d.ts +56 -0
- package/dist/src/DataTable/useRowReordering.d.ts.map +1 -0
- package/dist/src/IconWithTooltip.d.ts +31 -0
- package/dist/src/IconWithTooltip.d.ts.map +1 -0
- package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/labs/DataFilters.d.ts.map +1 -1
- package/dist/src/labs/DataTable.d.ts +2 -2
- package/dist/src/labs/DataTable.d.ts.map +1 -1
- package/dist/src/labs/index.d.ts +0 -1
- package/dist/src/labs/index.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui.d.ts +18 -1
- package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/theme/components.js +37 -18
- package/dist/theme/components.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/DataTable/DataTable.tsx +538 -0
- package/src/DataTable/DataTableRowActions.tsx +124 -0
- package/src/DataTable/DataTableSettings.tsx +109 -0
- package/src/DataTable/constants.ts +13 -0
- package/src/DataTable/index.tsx +22 -0
- package/src/DataTable/reorderDataRowsLocally.tsx +48 -0
- package/src/DataTable/useRowReordering.tsx +233 -0
- package/src/IconWithTooltip.tsx +90 -0
- package/src/index.ts +2 -0
- package/src/labs/DataFilters.tsx +60 -17
- package/src/labs/DataTable.tsx +24 -11
- package/src/labs/index.ts +0 -1
- package/src/properties/odyssey-react-mui.properties +19 -2
- package/src/properties/ts/odyssey-react-mui.ts +1 -1
- package/src/theme/components.tsx +43 -16
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
*/export const reorderDataRowsLocally = ({
|
|
12
|
+
currentData,
|
|
13
|
+
rowId,
|
|
14
|
+
newRowIndex
|
|
15
|
+
}) => {
|
|
16
|
+
const updatedData = [...currentData];
|
|
17
|
+
const rowIndex = updatedData.findIndex(row => row.id === rowId);
|
|
18
|
+
if (rowIndex === -1 || newRowIndex < 0 || newRowIndex >= updatedData.length) {
|
|
19
|
+
console.warn("Invalid row ID or newIndex; cannot reorder rows.");
|
|
20
|
+
return updatedData;
|
|
21
|
+
}
|
|
22
|
+
const [removedRow] = updatedData.splice(rowIndex, 1);
|
|
23
|
+
updatedData.splice(newRowIndex, 0, removedRow);
|
|
24
|
+
return updatedData;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=reorderDataRowsLocally.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reorderDataRowsLocally.js","names":["reorderDataRowsLocally","currentData","rowId","newRowIndex","updatedData","rowIndex","findIndex","row","id","length","console","warn","removedRow","splice"],"sources":["../../src/DataTable/reorderDataRowsLocally.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { MRT_RowData } from \"material-react-table\";\n\n/**\n * Reorders data rows locally.\n *\n * @param currentData - The current array of data rows.\n * @param rowId - The ID of the row to move.\n * @param newIndex - The new index to move the row to.\n * @returns A new array of data with the row moved to the specified index.\n */\nexport const reorderDataRowsLocally = ({\n currentData,\n rowId,\n newRowIndex,\n}: {\n currentData: MRT_RowData[];\n rowId: string;\n newRowIndex: number;\n}): MRT_RowData[] => {\n const updatedData = [...currentData];\n const rowIndex = updatedData.findIndex((row) => row.id === rowId);\n\n // Ensure the row exists and the new index is within bounds\n if (rowIndex === -1 || newRowIndex < 0 || newRowIndex >= updatedData.length) {\n console.warn(\"Invalid row ID or newIndex; cannot reorder rows.\");\n return updatedData; // Return the original data if conditions aren't met\n }\n\n // Remove the row from its current position\n const [removedRow] = updatedData.splice(rowIndex, 1);\n\n // Insert the row at the new index\n updatedData.splice(newRowIndex, 0, removedRow);\n\n return updatedData;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAYA,OAAO,MAAMA,sBAAsB,GAAGA,CAAC;EACrCC,WAAW;EACXC,KAAK;EACLC;AAKF,CAAC,KAAoB;EACnB,MAAMC,WAAW,GAAG,CAAC,GAAGH,WAAW,CAAC;EACpC,MAAMI,QAAQ,GAAGD,WAAW,CAACE,SAAS,CAAEC,GAAG,IAAKA,GAAG,CAACC,EAAE,KAAKN,KAAK,CAAC;EAGjE,IAAIG,QAAQ,KAAK,CAAC,CAAC,IAAIF,WAAW,GAAG,CAAC,IAAIA,WAAW,IAAIC,WAAW,CAACK,MAAM,EAAE;IAC3EC,OAAO,CAACC,IAAI,CAAC,kDAAkD,CAAC;IAChE,OAAOP,WAAW;EACpB;EAGA,MAAM,CAACQ,UAAU,CAAC,GAAGR,WAAW,CAACS,MAAM,CAACR,QAAQ,EAAE,CAAC,CAAC;EAGpDD,WAAW,CAACS,MAAM,CAACV,WAAW,EAAE,CAAC,EAAES,UAAU,CAAC;EAE9C,OAAOR,WAAW;AACpB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
import { reorderDataRowsLocally } from "./reorderDataRowsLocally.js";
|
|
13
|
+
import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext.js";
|
|
14
|
+
export const useRowReordering = ({
|
|
15
|
+
totalRows,
|
|
16
|
+
onReorderRows,
|
|
17
|
+
data,
|
|
18
|
+
setData,
|
|
19
|
+
draggingRow,
|
|
20
|
+
setDraggingRow,
|
|
21
|
+
resultsPerPage,
|
|
22
|
+
page
|
|
23
|
+
}) => {
|
|
24
|
+
const updateRowOrder = ({
|
|
25
|
+
rowId,
|
|
26
|
+
newRowIndex
|
|
27
|
+
}) => {
|
|
28
|
+
if (newRowIndex < 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (totalRows && newRowIndex > totalRows) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const newData = reorderDataRowsLocally({
|
|
35
|
+
currentData: data,
|
|
36
|
+
rowId,
|
|
37
|
+
newRowIndex
|
|
38
|
+
});
|
|
39
|
+
setData(newData);
|
|
40
|
+
onReorderRows?.({
|
|
41
|
+
rowId,
|
|
42
|
+
newRowIndex
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
46
|
+
const dragHandleStyles = {
|
|
47
|
+
padding: odysseyDesignTokens.Spacing1,
|
|
48
|
+
borderRadius: odysseyDesignTokens.BorderRadiusMain,
|
|
49
|
+
"&:focus-visible": {
|
|
50
|
+
boxShadow: `0 0 0 2px ${odysseyDesignTokens.HueNeutralWhite}, 0 0 0 4px ${odysseyDesignTokens.PalettePrimaryMain}`,
|
|
51
|
+
outline: "2px solid transparent",
|
|
52
|
+
outlineOffset: "1px"
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const dragHandleText = {
|
|
56
|
+
title: "Drag row or press space/enter key to start and stop reordering",
|
|
57
|
+
"aria-label": "Drag row to reorder. Or, press space or enter to start and stop reordering and esc to cancel."
|
|
58
|
+
};
|
|
59
|
+
const draggableTableBodyRowClassName = ({
|
|
60
|
+
currentRowId,
|
|
61
|
+
draggingRowId,
|
|
62
|
+
hoveredRowId
|
|
63
|
+
}) => {
|
|
64
|
+
if (draggingRowId === currentRowId && hoveredRowId !== currentRowId) {
|
|
65
|
+
return "isDragging";
|
|
66
|
+
}
|
|
67
|
+
if (hoveredRowId === currentRowId && draggingRowId !== currentRowId) {
|
|
68
|
+
return "isDragTarget";
|
|
69
|
+
}
|
|
70
|
+
if (draggingRowId === currentRowId && hoveredRowId === currentRowId) {
|
|
71
|
+
return "isDragging isDragTarget";
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
};
|
|
75
|
+
const getRowFromTableAndSetHovered = (table, id) => {
|
|
76
|
+
if (id) {
|
|
77
|
+
const nextRow = table.getRow(id);
|
|
78
|
+
if (nextRow) {
|
|
79
|
+
table.setHoveredRow(nextRow);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const handleDragHandleKeyDown = ({
|
|
84
|
+
table,
|
|
85
|
+
row,
|
|
86
|
+
event
|
|
87
|
+
}) => {
|
|
88
|
+
const {
|
|
89
|
+
hoveredRow
|
|
90
|
+
} = table.getState();
|
|
91
|
+
const {
|
|
92
|
+
key
|
|
93
|
+
} = event;
|
|
94
|
+
const isSpaceKey = key === " ";
|
|
95
|
+
const isEnterKey = key === "Enter";
|
|
96
|
+
const isEscapeKey = key === "Escape";
|
|
97
|
+
const isArrowDown = key === "ArrowDown";
|
|
98
|
+
const isArrowUp = key === "ArrowUp";
|
|
99
|
+
const isSpaceOrEnter = isSpaceKey || isEnterKey;
|
|
100
|
+
const zeroIndexedPageNumber = page - 1;
|
|
101
|
+
const currentIndex = row.index + zeroIndexedPageNumber * resultsPerPage;
|
|
102
|
+
if (isEscapeKey) {
|
|
103
|
+
resetDraggingAndHoveredRow(table);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (isSpaceOrEnter) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
}
|
|
110
|
+
if (draggingRow) {
|
|
111
|
+
if (typeof hoveredRow?.index === "number") {
|
|
112
|
+
const {
|
|
113
|
+
index
|
|
114
|
+
} = hoveredRow;
|
|
115
|
+
if (isSpaceOrEnter) {
|
|
116
|
+
const pageRelativeIndex = index + zeroIndexedPageNumber * resultsPerPage;
|
|
117
|
+
if (pageRelativeIndex !== currentIndex) {
|
|
118
|
+
updateRowOrder({
|
|
119
|
+
rowId: row.id,
|
|
120
|
+
newRowIndex: pageRelativeIndex
|
|
121
|
+
});
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
resetDraggingAndHoveredRow(table);
|
|
124
|
+
}, odysseyDesignTokens.TransitionDurationMainAsNumber);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (isArrowDown || isArrowUp) {
|
|
129
|
+
const nextIndex = isArrowDown ? index + 1 : index - 1;
|
|
130
|
+
getRowFromTableAndSetHovered(table, data[nextIndex]?.id);
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
if (isArrowDown || isArrowUp) {
|
|
134
|
+
const nextIndex = isArrowDown ? row.index + 1 : row.index - 1;
|
|
135
|
+
getRowFromTableAndSetHovered(table, data[nextIndex]?.id);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
if (isSpaceOrEnter) {
|
|
140
|
+
setDraggingRow(row);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const handleDragHandleOnDragEnd = table => {
|
|
145
|
+
const cols = table.getAllColumns();
|
|
146
|
+
cols[0].toggleVisibility();
|
|
147
|
+
const {
|
|
148
|
+
draggingRow,
|
|
149
|
+
hoveredRow
|
|
150
|
+
} = table.getState();
|
|
151
|
+
if (draggingRow) {
|
|
152
|
+
updateRowOrder({
|
|
153
|
+
rowId: draggingRow.id,
|
|
154
|
+
newRowIndex: hoveredRow.index
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
setDraggingRow(null);
|
|
158
|
+
};
|
|
159
|
+
const handleDragHandleOnDragCapture = table => {
|
|
160
|
+
if (!draggingRow && table.getState().draggingRow?.id) {
|
|
161
|
+
setDraggingRow(table.getState().draggingRow);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const resetDraggingAndHoveredRow = table => {
|
|
165
|
+
setDraggingRow(null);
|
|
166
|
+
table.setHoveredRow(null);
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
dragHandleStyles,
|
|
170
|
+
dragHandleText,
|
|
171
|
+
draggableTableBodyRowClassName,
|
|
172
|
+
handleDragHandleKeyDown,
|
|
173
|
+
handleDragHandleOnDragCapture,
|
|
174
|
+
handleDragHandleOnDragEnd,
|
|
175
|
+
resetDraggingAndHoveredRow,
|
|
176
|
+
updateRowOrder
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=useRowReordering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRowReordering.js","names":["reorderDataRowsLocally","useOdysseyDesignTokens","useRowReordering","totalRows","onReorderRows","data","setData","draggingRow","setDraggingRow","resultsPerPage","page","updateRowOrder","rowId","newRowIndex","newData","currentData","odysseyDesignTokens","dragHandleStyles","padding","Spacing1","borderRadius","BorderRadiusMain","boxShadow","HueNeutralWhite","PalettePrimaryMain","outline","outlineOffset","dragHandleText","title","draggableTableBodyRowClassName","currentRowId","draggingRowId","hoveredRowId","undefined","getRowFromTableAndSetHovered","table","id","nextRow","getRow","setHoveredRow","handleDragHandleKeyDown","row","event","hoveredRow","getState","key","isSpaceKey","isEnterKey","isEscapeKey","isArrowDown","isArrowUp","isSpaceOrEnter","zeroIndexedPageNumber","currentIndex","index","resetDraggingAndHoveredRow","preventDefault","stopPropagation","pageRelativeIndex","setTimeout","TransitionDurationMainAsNumber","nextIndex","handleDragHandleOnDragEnd","cols","getAllColumns","toggleVisibility","handleDragHandleOnDragCapture"],"sources":["../../src/DataTable/useRowReordering.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { Dispatch, SetStateAction, KeyboardEvent } from \"react\";\nimport { DataTableProps } from \"./DataTable\";\nimport { reorderDataRowsLocally } from \"./reorderDataRowsLocally\";\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext\";\nimport { MRT_Row, MRT_RowData, MRT_TableInstance } from \"material-react-table\";\n\nexport const useRowReordering = ({\n totalRows,\n onReorderRows,\n data,\n setData,\n draggingRow,\n setDraggingRow,\n resultsPerPage,\n page,\n}: {\n totalRows: DataTableProps[\"totalRows\"];\n onReorderRows: DataTableProps[\"onReorderRows\"];\n data: MRT_RowData[];\n setData: Dispatch<SetStateAction<MRT_RowData[]>>;\n draggingRow?: MRT_Row<MRT_RowData> | null;\n setDraggingRow: Dispatch<\n SetStateAction<MRT_Row<MRT_RowData> | null | undefined>\n >;\n resultsPerPage: number;\n page: number;\n}) => {\n const updateRowOrder = ({\n rowId,\n newRowIndex,\n }: {\n rowId: string;\n newRowIndex: number;\n }) => {\n if (newRowIndex < 0) {\n return;\n }\n\n if (totalRows && newRowIndex > totalRows) {\n return;\n }\n\n const newData = reorderDataRowsLocally({\n currentData: data,\n rowId,\n newRowIndex,\n });\n\n setData(newData);\n onReorderRows?.({ rowId, newRowIndex });\n };\n\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const dragHandleStyles = {\n padding: odysseyDesignTokens.Spacing1,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n\n \"&:focus-visible\": {\n boxShadow: `0 0 0 2px ${odysseyDesignTokens.HueNeutralWhite}, 0 0 0 4px ${odysseyDesignTokens.PalettePrimaryMain}`,\n outline: \"2px solid transparent\",\n outlineOffset: \"1px\",\n },\n };\n\n const dragHandleText = {\n title: \"Drag row or press space/enter key to start and stop reordering\",\n \"aria-label\":\n \"Drag row to reorder. Or, press space or enter to start and stop reordering and esc to cancel.\",\n };\n\n const draggableTableBodyRowClassName = ({\n currentRowId,\n draggingRowId,\n hoveredRowId,\n }: {\n currentRowId: string;\n draggingRowId?: string;\n hoveredRowId?: string;\n }) => {\n if (draggingRowId === currentRowId && hoveredRowId !== currentRowId) {\n return \"isDragging\";\n }\n\n if (hoveredRowId === currentRowId && draggingRowId !== currentRowId) {\n return \"isDragTarget\";\n }\n\n if (draggingRowId === currentRowId && hoveredRowId === currentRowId) {\n return \"isDragging isDragTarget\";\n }\n\n return undefined;\n };\n\n const getRowFromTableAndSetHovered = (\n table: MRT_TableInstance<MRT_RowData>,\n id: MRT_RowData[\"id\"],\n ) => {\n if (id) {\n const nextRow: MRT_RowData = table.getRow(id);\n\n if (nextRow) {\n table.setHoveredRow(nextRow);\n }\n }\n };\n\n type HandleDragHandleKeyDownArgs = {\n table: MRT_TableInstance<MRT_RowData>;\n row: MRT_Row<MRT_RowData>;\n event: KeyboardEvent<HTMLButtonElement>;\n };\n\n const handleDragHandleKeyDown = ({\n table,\n row,\n event,\n }: HandleDragHandleKeyDownArgs) => {\n const { hoveredRow } = table.getState();\n\n const { key } = event;\n\n const isSpaceKey = key === \" \";\n const isEnterKey = key === \"Enter\";\n const isEscapeKey = key === \"Escape\";\n const isArrowDown = key === \"ArrowDown\";\n const isArrowUp = key === \"ArrowUp\";\n const isSpaceOrEnter = isSpaceKey || isEnterKey;\n const zeroIndexedPageNumber = page - 1;\n const currentIndex = row.index + zeroIndexedPageNumber * resultsPerPage;\n\n if (isEscapeKey) {\n resetDraggingAndHoveredRow(table);\n return;\n }\n\n if (isSpaceOrEnter) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n if (draggingRow) {\n if (typeof hoveredRow?.index === \"number\") {\n const { index } = hoveredRow;\n\n if (isSpaceOrEnter) {\n const pageRelativeIndex =\n index + zeroIndexedPageNumber * resultsPerPage;\n\n if (pageRelativeIndex !== currentIndex) {\n updateRowOrder({\n rowId: row.id,\n newRowIndex: pageRelativeIndex,\n });\n\n // Can't transition CSS hover effect. Use timeout to delay hovered row effect removal\n setTimeout(() => {\n resetDraggingAndHoveredRow(table);\n }, odysseyDesignTokens.TransitionDurationMainAsNumber);\n return;\n }\n }\n\n if (isArrowDown || isArrowUp) {\n const nextIndex = isArrowDown ? index + 1 : index - 1;\n getRowFromTableAndSetHovered(table, data[nextIndex]?.id);\n }\n } else {\n if (isArrowDown || isArrowUp) {\n const nextIndex = isArrowDown ? row.index + 1 : row.index - 1;\n getRowFromTableAndSetHovered(table, data[nextIndex]?.id);\n }\n }\n } else {\n if (isSpaceOrEnter) {\n setDraggingRow(row);\n }\n }\n };\n\n const handleDragHandleOnDragEnd = (table: MRT_TableInstance<MRT_RowData>) => {\n const cols = table.getAllColumns();\n cols[0].toggleVisibility();\n\n const { draggingRow, hoveredRow } = table.getState();\n if (draggingRow) {\n updateRowOrder({\n rowId: draggingRow.id,\n newRowIndex: (hoveredRow as MRT_RowData).index,\n });\n }\n\n setDraggingRow(null);\n };\n\n const handleDragHandleOnDragCapture = (\n table: MRT_TableInstance<MRT_RowData>,\n ) => {\n if (!draggingRow && table.getState().draggingRow?.id) {\n setDraggingRow(table.getState().draggingRow);\n }\n };\n\n const resetDraggingAndHoveredRow = (\n table: MRT_TableInstance<MRT_RowData>,\n ) => {\n setDraggingRow(null);\n table.setHoveredRow(null);\n };\n\n return {\n dragHandleStyles,\n dragHandleText,\n draggableTableBodyRowClassName,\n handleDragHandleKeyDown,\n handleDragHandleOnDragCapture,\n handleDragHandleOnDragEnd,\n resetDraggingAndHoveredRow,\n updateRowOrder,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,SAcSA,sBAAsB;AAAA,SACtBC,sBAAsB;AAG/B,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,SAAS;EACTC,aAAa;EACbC,IAAI;EACJC,OAAO;EACPC,WAAW;EACXC,cAAc;EACdC,cAAc;EACdC;AAYF,CAAC,KAAK;EACJ,MAAMC,cAAc,GAAGA,CAAC;IACtBC,KAAK;IACLC;EAIF,CAAC,KAAK;IACJ,IAAIA,WAAW,GAAG,CAAC,EAAE;MACnB;IACF;IAEA,IAAIV,SAAS,IAAIU,WAAW,GAAGV,SAAS,EAAE;MACxC;IACF;IAEA,MAAMW,OAAO,GAAGd,sBAAsB,CAAC;MACrCe,WAAW,EAAEV,IAAI;MACjBO,KAAK;MACLC;IACF,CAAC,CAAC;IAEFP,OAAO,CAACQ,OAAO,CAAC;IAChBV,aAAa,GAAG;MAAEQ,KAAK;MAAEC;IAAY,CAAC,CAAC;EACzC,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OAAO;IACLtB,gBAAgB;IAChBU,cAAc;IACdE,8BAA8B;IAC9BW,uBAAuB;IACvB0B,6BAA6B;IAC7BJ,yBAAyB;IACzBP,0BAA0B;IAC1B5C;EACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _Tooltip from "@mui/material/Tooltip";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
4
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
5
|
+
*
|
|
6
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
9
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
*
|
|
11
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { memo } from "react";
|
|
15
|
+
import styled from "@emotion/styled";
|
|
16
|
+
import { InformationCircleIcon } from "./icons.generated/index.js";
|
|
17
|
+
import { useMuiProps } from "./MuiPropsContext.js";
|
|
18
|
+
import { useOdysseyDesignTokens } from "./OdysseyDesignTokensContext.js";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
const IconContainer = styled.span(({
|
|
21
|
+
odysseyDesignTokens
|
|
22
|
+
}) => ({
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
transitionProperty: "border-color, box-shadow, outline",
|
|
25
|
+
transitionDuration: odysseyDesignTokens.TransitionDurationMain,
|
|
26
|
+
border: "1px solid transparent",
|
|
27
|
+
"&:focus, &:focus-visible": {
|
|
28
|
+
borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,
|
|
29
|
+
boxShadow: `0 0 0 1px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,
|
|
30
|
+
outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,
|
|
31
|
+
outlineOffset: odysseyDesignTokens.FocusOutlineOffsetTight
|
|
32
|
+
},
|
|
33
|
+
svg: {
|
|
34
|
+
display: "flex"
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
const IconWithTooltip = ({
|
|
38
|
+
IconComponent = _jsx(InformationCircleIcon, {}),
|
|
39
|
+
placement = "right",
|
|
40
|
+
testId,
|
|
41
|
+
tooltipText,
|
|
42
|
+
translate
|
|
43
|
+
}) => {
|
|
44
|
+
const muiProps = useMuiProps();
|
|
45
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
46
|
+
return _jsx(_Tooltip, {
|
|
47
|
+
"data-se": testId,
|
|
48
|
+
describeChild: true,
|
|
49
|
+
placement: placement,
|
|
50
|
+
tabIndex: 0,
|
|
51
|
+
title: tooltipText,
|
|
52
|
+
translate: translate,
|
|
53
|
+
children: _jsx(IconContainer, {
|
|
54
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
55
|
+
...muiProps,
|
|
56
|
+
children: IconComponent
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const MemoizedIconWithTooltip = memo(IconWithTooltip);
|
|
61
|
+
MemoizedIconWithTooltip.displayName = "IconWithTooltip";
|
|
62
|
+
export { MemoizedIconWithTooltip as IconWithTooltip };
|
|
63
|
+
//# sourceMappingURL=IconWithTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconWithTooltip.js","names":["memo","styled","InformationCircleIcon","useMuiProps","useOdysseyDesignTokens","jsx","_jsx","IconContainer","span","odysseyDesignTokens","display","transitionProperty","transitionDuration","TransitionDurationMain","border","borderColor","FocusOutlineColorPrimary","boxShadow","outline","FocusOutlineWidthMain","FocusOutlineStyle","outlineOffset","FocusOutlineOffsetTight","svg","IconWithTooltip","IconComponent","placement","testId","tooltipText","translate","muiProps","_Tooltip","describeChild","tabIndex","title","children","MemoizedIconWithTooltip","displayName"],"sources":["../src/IconWithTooltip.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, ReactNode } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { Tooltip as MuiTooltip } from \"@mui/material\";\nimport type { TooltipProps as MuiTooltipProps } from \"@mui/material\";\n\nimport { HtmlProps } from \"./HtmlProps\";\nimport { InformationCircleIcon } from \"./icons.generated\";\nimport { useMuiProps } from \"./MuiPropsContext\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext\";\n\nconst IconContainer = styled.span<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n display: \"inline-flex\",\n transitionProperty: \"border-color, box-shadow, outline\",\n transitionDuration: odysseyDesignTokens.TransitionDurationMain,\n border: \"1px solid transparent\",\n\n \"&:focus, &:focus-visible\": {\n borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,\n boxShadow: `0 0 0 1px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,\n outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,\n outlineOffset: odysseyDesignTokens.FocusOutlineOffsetTight,\n },\n\n svg: {\n display: \"flex\",\n },\n}));\n\nexport type IconWithTooltipProps = {\n /**\n * The icon to render. Defaults to `InformationCircleIcon`\n */\n IconComponent?: ReactNode;\n /**\n * The placement of the Tooltip\n */\n placement?: MuiTooltipProps[\"placement\"];\n /**\n * The text to display in the Tooltip\n */\n tooltipText: string;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst IconWithTooltip = ({\n IconComponent = <InformationCircleIcon />,\n placement = \"right\",\n testId,\n tooltipText,\n translate,\n}: IconWithTooltipProps) => {\n const muiProps = useMuiProps();\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n return (\n <MuiTooltip\n data-se={testId}\n describeChild\n placement={placement}\n tabIndex={0}\n title={tooltipText}\n translate={translate}\n >\n <IconContainer odysseyDesignTokens={odysseyDesignTokens} {...muiProps}>\n {IconComponent}\n </IconContainer>\n </MuiTooltip>\n );\n};\n\nconst MemoizedIconWithTooltip = memo(IconWithTooltip);\nMemoizedIconWithTooltip.displayName = \"IconWithTooltip\";\n\nexport { MemoizedIconWithTooltip as IconWithTooltip };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAmB,OAAO;AACvC,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAK5BC,qBAAqB;AAAA,SACrBC,WAAW;AAAA,SAElBC,sBAAsB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAIxB,MAAMC,aAAa,GAAGN,MAAM,CAACO,IAAI,CAE9B,CAAC;EAAEC;AAAoB,CAAC,MAAM;EAC/BC,OAAO,EAAE,aAAa;EACtBC,kBAAkB,EAAE,mCAAmC;EACvDC,kBAAkB,EAAEH,mBAAmB,CAACI,sBAAsB;EAC9DC,MAAM,EAAE,uBAAuB;EAE/B,0BAA0B,EAAE;IAC1BC,WAAW,EAAEN,mBAAmB,CAACO,wBAAwB;IACzDC,SAAS,EAAG,aAAYR,mBAAmB,CAACO,wBAAyB,EAAC;IACtEE,OAAO,EAAG,GAAET,mBAAmB,CAACU,qBAAsB,IAAGV,mBAAmB,CAACW,iBAAkB,cAAa;IAC5GC,aAAa,EAAEZ,mBAAmB,CAACa;EACrC,CAAC;EAEDC,GAAG,EAAE;IACHb,OAAO,EAAE;EACX;AACF,CAAC,CAAC,CAAC;AAiBH,MAAMc,eAAe,GAAGA,CAAC;EACvBC,aAAa,GAAGnB,IAAA,CAACJ,qBAAqB,IAAE,CAAC;EACzCwB,SAAS,GAAG,OAAO;EACnBC,MAAM;EACNC,WAAW;EACXC;AACoB,CAAC,KAAK;EAC1B,MAAMC,QAAQ,GAAG3B,WAAW,CAAC,CAAC;EAC9B,MAAMM,mBAAmB,GAAGL,sBAAsB,CAAC,CAAC;EAEpD,OACEE,IAAA,CAAAyB,QAAA;IACE,WAASJ,MAAO;IAChBK,aAAa;IACbN,SAAS,EAAEA,SAAU;IACrBO,QAAQ,EAAE,CAAE;IACZC,KAAK,EAAEN,WAAY;IACnBC,SAAS,EAAEA,SAAU;IAAAM,QAAA,EAErB7B,IAAA,CAACC,aAAa;MAACE,mBAAmB,EAAEA,mBAAoB;MAAA,GAAKqB,QAAQ;MAAAK,QAAA,EAClEV;IAAa,CACD;EAAC,CACN,CAAC;AAEjB,CAAC;AAED,MAAMW,uBAAuB,GAAGpC,IAAI,CAACwB,eAAe,CAAC;AACrDY,uBAAuB,CAACC,WAAW,GAAG,iBAAiB;AAEvD,SAASD,uBAAuB,IAAIZ,eAAe"}
|
package/dist/index.js
CHANGED
|
@@ -27,11 +27,13 @@ export * from "./CircularProgress.js";
|
|
|
27
27
|
export * from "./CssBaseline.js";
|
|
28
28
|
export * from "./createShadowRootElement.js";
|
|
29
29
|
export * from "./createUniqueId.js";
|
|
30
|
+
export * from "./DataTable/index.js";
|
|
30
31
|
export * from "./Dialog.js";
|
|
31
32
|
export * from "./Fieldset.js";
|
|
32
33
|
export * from "./FieldComponentProps.js";
|
|
33
34
|
export * from "./Form.js";
|
|
34
35
|
export * from "./HintLink.js";
|
|
36
|
+
export * from "./IconWithTooltip.js";
|
|
35
37
|
export * from "./Link.js";
|
|
36
38
|
export * from "./MenuButton.js";
|
|
37
39
|
export * from "./MenuItem.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["deepmerge","visuallyHidden","createTheme","DialogContentText","Divider","InputAdornment","InputBase","ListItemIcon","ListItemText","ListSubheader","MenuList","Paper","ScopedCssBaseline","ThemeProvider","useOdysseyDesignTokens","odysseyTranslate"],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport { deepmerge, visuallyHidden } from \"@mui/utils\";\n\nexport {\n createTheme,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n DialogContentText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Divider,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputAdornment,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputBase,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemIcon,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListSubheader,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n MenuList,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Paper,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ScopedCssBaseline,\n ThemeProvider,\n} from \"@mui/material\";\n\nexport type {\n CssBaselineProps,\n DialogContentTextProps,\n DividerProps,\n InputAdornmentProps,\n InputBaseProps,\n ListItemIconProps,\n ListItemTextProps,\n ListSubheaderProps,\n MenuListProps,\n PaperProps,\n ScopedCssBaselineProps,\n ThemeOptions,\n} from \"@mui/material\";\n\nexport type { FocusHandle } from \"./inputUtils\";\nexport { useOdysseyDesignTokens } from \"./OdysseyDesignTokensContext\";\n\nexport * from \"./Accordion\";\nexport * from \"./Autocomplete\";\nexport * from \"./Banner\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Tile\";\nexport * from \"./Callout\";\nexport * from \"./Checkbox\";\nexport * from \"./CheckboxGroup\";\nexport * from \"./CircularProgress\";\nexport * from \"./CssBaseline\";\nexport * from \"./createShadowRootElement\";\nexport * from \"./createUniqueId\";\nexport * from \"./Dialog\";\nexport * from \"./Fieldset\";\nexport * from \"./FieldComponentProps\";\nexport * from \"./Form\";\nexport * from \"./HintLink\";\nexport * from \"./Link\";\nexport * from \"./MenuButton\";\nexport * from \"./MenuItem\";\nexport * from \"./NativeSelect\";\nexport * from \"./NullElement\";\nexport * from \"./OdysseyCacheProvider\";\nexport { odysseyTranslate } from \"./i18n\";\nexport * from \"./OdysseyProvider\";\nexport * from \"./OdysseyThemeProvider\";\nexport * from \"./OdysseyTranslationProvider\";\nexport * from \"./PasswordField\";\nexport * from \"./Radio\";\nexport * from \"./RadioGroup\";\nexport * from \"./ScreenReaderText\";\nexport * from \"./SearchField\";\nexport * from \"./Select\";\nexport * from \"./Status\";\nexport * from \"./Tabs\";\nexport * from \"./Tag\";\nexport * from \"./TagList\";\nexport * from \"./TextField\";\nexport * from \"./theme\";\nexport * from \"./Toast\";\nexport * from \"./ToastStack\";\nexport * from \"./labs/Switch\";\nexport * from \"./Tooltip\";\nexport * from \"./Typography\";\nexport * from \"./useUniqueId\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,cAAc,QAAQ,YAAY;AAEtD,SACEC,WAAW,EAEXC,iBAAiB,EAEjBC,OAAO,EAEPC,cAAc,EAEdC,SAAS,EAETC,YAAY,EAEZC,YAAY,EAEZC,aAAa,EAEbC,QAAQ,EAERC,KAAK,EAELC,iBAAiB,EACjBC,aAAa,QACR,eAAe;AAAC,SAkBdC,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["deepmerge","visuallyHidden","createTheme","DialogContentText","Divider","InputAdornment","InputBase","ListItemIcon","ListItemText","ListSubheader","MenuList","Paper","ScopedCssBaseline","ThemeProvider","useOdysseyDesignTokens","odysseyTranslate"],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport { deepmerge, visuallyHidden } from \"@mui/utils\";\n\nexport {\n createTheme,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n DialogContentText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Divider,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputAdornment,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n InputBase,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemIcon,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListItemText,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ListSubheader,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n MenuList,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n Paper,\n /** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */\n ScopedCssBaseline,\n ThemeProvider,\n} from \"@mui/material\";\n\nexport type {\n CssBaselineProps,\n DialogContentTextProps,\n DividerProps,\n InputAdornmentProps,\n InputBaseProps,\n ListItemIconProps,\n ListItemTextProps,\n ListSubheaderProps,\n MenuListProps,\n PaperProps,\n ScopedCssBaselineProps,\n ThemeOptions,\n} from \"@mui/material\";\n\nexport type { FocusHandle } from \"./inputUtils\";\nexport { useOdysseyDesignTokens } from \"./OdysseyDesignTokensContext\";\n\nexport * from \"./Accordion\";\nexport * from \"./Autocomplete\";\nexport * from \"./Banner\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Tile\";\nexport * from \"./Callout\";\nexport * from \"./Checkbox\";\nexport * from \"./CheckboxGroup\";\nexport * from \"./CircularProgress\";\nexport * from \"./CssBaseline\";\nexport * from \"./createShadowRootElement\";\nexport * from \"./createUniqueId\";\nexport * from \"./DataTable\";\nexport * from \"./Dialog\";\nexport * from \"./Fieldset\";\nexport * from \"./FieldComponentProps\";\nexport * from \"./Form\";\nexport * from \"./HintLink\";\nexport * from \"./IconWithTooltip\";\nexport * from \"./Link\";\nexport * from \"./MenuButton\";\nexport * from \"./MenuItem\";\nexport * from \"./NativeSelect\";\nexport * from \"./NullElement\";\nexport * from \"./OdysseyCacheProvider\";\nexport { odysseyTranslate } from \"./i18n\";\nexport * from \"./OdysseyProvider\";\nexport * from \"./OdysseyThemeProvider\";\nexport * from \"./OdysseyTranslationProvider\";\nexport * from \"./PasswordField\";\nexport * from \"./Radio\";\nexport * from \"./RadioGroup\";\nexport * from \"./ScreenReaderText\";\nexport * from \"./SearchField\";\nexport * from \"./Select\";\nexport * from \"./Status\";\nexport * from \"./Tabs\";\nexport * from \"./Tag\";\nexport * from \"./TagList\";\nexport * from \"./TextField\";\nexport * from \"./theme\";\nexport * from \"./Toast\";\nexport * from \"./ToastStack\";\nexport * from \"./labs/Switch\";\nexport * from \"./Tooltip\";\nexport * from \"./Typography\";\nexport * from \"./useUniqueId\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,cAAc,QAAQ,YAAY;AAEtD,SACEC,WAAW,EAEXC,iBAAiB,EAEjBC,OAAO,EAEPC,cAAc,EAEdC,SAAS,EAETC,YAAY,EAEZC,YAAY,EAEZC,aAAa,EAEbC,QAAQ,EAERC,KAAK,EAELC,iBAAiB,EACjBC,aAAa,QACR,eAAe;AAAC,SAkBdC,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SA6BtBC,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
|
package/dist/labs/DataFilters.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _Popover from "@mui/material/Popover";
|
|
2
2
|
import _IconButton from "@mui/material/IconButton";
|
|
3
3
|
import _Menu from "@mui/material/Menu";
|
|
4
|
+
import _MenuItem from "@mui/material/MenuItem";
|
|
5
|
+
import _Typography from "@mui/material/Typography";
|
|
4
6
|
/*!
|
|
5
7
|
* Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
6
8
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -22,13 +24,13 @@ import { Tag } from "../Tag.js";
|
|
|
22
24
|
import { SearchField } from "../SearchField.js";
|
|
23
25
|
import { Button } from "../Button.js";
|
|
24
26
|
import { CheckIcon, ChevronRightIcon, CloseCircleFilledIcon, FilterIcon } from "../icons.generated/index.js";
|
|
25
|
-
import {
|
|
26
|
-
import { Paragraph, Subordinate } from "../Typography.js";
|
|
27
|
+
import { Subordinate } from "../Typography.js";
|
|
27
28
|
import { TextField } from "../TextField.js";
|
|
28
29
|
import { CheckboxGroup } from "../CheckboxGroup.js";
|
|
29
30
|
import { Checkbox } from "../Checkbox.js";
|
|
30
31
|
import { RadioGroup } from "../RadioGroup.js";
|
|
31
32
|
import { Radio } from "../Radio.js";
|
|
33
|
+
import { Trans, useTranslation } from "react-i18next";
|
|
32
34
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
35
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
34
36
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -42,6 +44,9 @@ const DataFilters = ({
|
|
|
42
44
|
filters: filtersProp = []
|
|
43
45
|
}) => {
|
|
44
46
|
const [filters, setFilters] = useState(filtersProp);
|
|
47
|
+
const {
|
|
48
|
+
t
|
|
49
|
+
} = useTranslation();
|
|
45
50
|
const initialInputValues = useMemo(() => {
|
|
46
51
|
return filtersProp.reduce((accumulator, filter) => {
|
|
47
52
|
accumulator[filter.id] = filter.value;
|
|
@@ -162,7 +167,7 @@ const DataFilters = ({
|
|
|
162
167
|
"aria-controls": isFiltersMenuOpen ? "filters-menu" : undefined,
|
|
163
168
|
"aria-expanded": isFiltersMenuOpen ? "true" : undefined,
|
|
164
169
|
"aria-haspopup": "true",
|
|
165
|
-
ariaLabel: "
|
|
170
|
+
ariaLabel: t("filters.filters.arialabel"),
|
|
166
171
|
endIcon: _jsx(FilterIcon, {}),
|
|
167
172
|
onClick: event => {
|
|
168
173
|
setFiltersMenuAnchorElement(event.currentTarget);
|
|
@@ -188,37 +193,55 @@ const DataFilters = ({
|
|
|
188
193
|
},
|
|
189
194
|
children: filtersProp.map(filter => {
|
|
190
195
|
const latestFilterValue = filters.find(f => f.id === filter.id)?.value;
|
|
191
|
-
return _jsx(
|
|
196
|
+
return _jsx(_MenuItem, {
|
|
192
197
|
onClick: event => {
|
|
193
198
|
setIsFilterPopoverOpen(true);
|
|
194
199
|
setFilterPopoverAnchorElement(event.currentTarget);
|
|
195
200
|
setFilterPopoverCurrentFilter(filter);
|
|
196
201
|
},
|
|
202
|
+
selected: filterPopoverCurrentFilter === filter && isFilterPopoverOpen === true,
|
|
203
|
+
className: filterPopoverCurrentFilter === filter && isFilterPopoverOpen === true ? "isVisiblySelected" : undefined,
|
|
197
204
|
children: _jsxs(Box, {
|
|
198
205
|
sx: {
|
|
199
206
|
display: "flex",
|
|
200
207
|
alignItems: "center",
|
|
201
208
|
justifyContent: "space-between",
|
|
202
209
|
width: "100%",
|
|
203
|
-
minWidth: 180
|
|
210
|
+
minWidth: 180,
|
|
211
|
+
paddingBlock: 1,
|
|
212
|
+
paddingInlineStart: 2
|
|
204
213
|
},
|
|
205
214
|
children: [_jsxs(Box, {
|
|
206
215
|
sx: {
|
|
207
216
|
marginRight: 2
|
|
208
217
|
},
|
|
209
|
-
children: [_jsx(
|
|
210
|
-
|
|
218
|
+
children: [_jsx(_Typography, {
|
|
219
|
+
fontWeight: "500",
|
|
220
|
+
sx: {
|
|
221
|
+
marginBlockEnd: 2
|
|
222
|
+
},
|
|
211
223
|
children: filter.label
|
|
212
224
|
}), _jsx(Subordinate, {
|
|
213
225
|
component: "div",
|
|
214
|
-
children: !latestFilterValue || Array.isArray(latestFilterValue) && latestFilterValue.length === 0 ?
|
|
226
|
+
children: !latestFilterValue || Array.isArray(latestFilterValue) && latestFilterValue.length === 0 ? _jsx(Trans, {
|
|
227
|
+
i18nKey: "filters.menuitem.any",
|
|
228
|
+
values: {
|
|
229
|
+
label: filter.label.toLowerCase()
|
|
230
|
+
}
|
|
231
|
+
}) : Array.isArray(latestFilterValue) ? _jsx(Trans, {
|
|
232
|
+
count: latestFilterValue.length,
|
|
233
|
+
i18nKey: "filters.menuitem.selected",
|
|
234
|
+
values: {
|
|
235
|
+
selected: latestFilterValue.length
|
|
236
|
+
}
|
|
237
|
+
}) : latestFilterValue
|
|
215
238
|
})]
|
|
216
239
|
}), _jsx(ChevronRightIcon, {})]
|
|
217
240
|
})
|
|
218
241
|
}, filter.id);
|
|
219
242
|
})
|
|
220
243
|
})]
|
|
221
|
-
}), [isFiltersMenuOpen, filtersMenuAnchorElement, filtersProp, filters]);
|
|
244
|
+
}), [isFiltersMenuOpen, filterPopoverCurrentFilter, isFilterPopoverOpen, filtersMenuAnchorElement, filtersProp, filters, t]);
|
|
222
245
|
return _jsxs(Box, {
|
|
223
246
|
children: [_jsxs(Box, {
|
|
224
247
|
sx: {
|
|
@@ -235,6 +258,11 @@ const DataFilters = ({
|
|
|
235
258
|
children: [filters.length > 0 && _jsxs(_Fragment, {
|
|
236
259
|
children: [filterMenu, _jsx(_Popover, {
|
|
237
260
|
anchorEl: filterPopoverAnchorElement,
|
|
261
|
+
elevation: 2,
|
|
262
|
+
sx: {
|
|
263
|
+
marginLeft: 2,
|
|
264
|
+
marginTop: -1
|
|
265
|
+
},
|
|
238
266
|
open: isFilterPopoverOpen,
|
|
239
267
|
anchorOrigin: {
|
|
240
268
|
vertical: "top",
|
|
@@ -306,7 +334,7 @@ const DataFilters = ({
|
|
|
306
334
|
}),
|
|
307
335
|
endAdornment: inputValues[filterPopoverCurrentFilter.id] && _jsx(_IconButton, {
|
|
308
336
|
size: "small",
|
|
309
|
-
"aria-label": "
|
|
337
|
+
"aria-label": t("filters.filter.clear"),
|
|
310
338
|
onClick: () => {
|
|
311
339
|
updateInputValue({
|
|
312
340
|
filterId: filterPopoverCurrentFilter.id,
|
|
@@ -347,7 +375,7 @@ const DataFilters = ({
|
|
|
347
375
|
});
|
|
348
376
|
},
|
|
349
377
|
children: [_jsx(Radio, {
|
|
350
|
-
label: "
|
|
378
|
+
label: t("filters.filter.any"),
|
|
351
379
|
value: "",
|
|
352
380
|
isChecked: !inputValues[filterPopoverCurrentFilter.id]
|
|
353
381
|
}), _jsx(_Fragment, {
|
|
@@ -379,7 +407,7 @@ const DataFilters = ({
|
|
|
379
407
|
},
|
|
380
408
|
children: [_jsx(SearchField, {
|
|
381
409
|
value: searchValue,
|
|
382
|
-
label: "
|
|
410
|
+
label: t("filters.search.label"),
|
|
383
411
|
onClear: () => {
|
|
384
412
|
setSearchValue("");
|
|
385
413
|
onChangeSearch("");
|
|
@@ -388,7 +416,7 @@ const DataFilters = ({
|
|
|
388
416
|
}), hasSearchSubmitButton && _jsx(Box, {
|
|
389
417
|
children: _jsx(Button, {
|
|
390
418
|
variant: "primary",
|
|
391
|
-
label: "
|
|
419
|
+
label: t("filters.search.label"),
|
|
392
420
|
onClick: () => onChangeSearch(searchValue)
|
|
393
421
|
})
|
|
394
422
|
})]
|
|
@@ -402,7 +430,7 @@ const DataFilters = ({
|
|
|
402
430
|
children: [activeFilters.length > 0 && _jsx(Box, {
|
|
403
431
|
children: _jsx(Button, {
|
|
404
432
|
variant: "secondary",
|
|
405
|
-
label: "
|
|
433
|
+
label: t("filters.clear.label"),
|
|
406
434
|
onClick: clearAllFilters
|
|
407
435
|
})
|
|
408
436
|
}), additionalActions]
|