@okta/odyssey-react-mui 1.14.3 → 1.14.5

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 (85) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/DataTable/DataTable.js +450 -0
  3. package/dist/DataTable/DataTable.js.map +1 -0
  4. package/dist/DataTable/DataTableEmptyState.js +55 -0
  5. package/dist/DataTable/DataTableEmptyState.js.map +1 -0
  6. package/dist/DataTable/DataTablePagination.js +221 -0
  7. package/dist/DataTable/DataTablePagination.js.map +1 -0
  8. package/dist/DataTable/DataTableRowActions.js +99 -0
  9. package/dist/DataTable/DataTableRowActions.js.map +1 -0
  10. package/dist/DataTable/DataTableSettings.js +84 -0
  11. package/dist/DataTable/DataTableSettings.js.map +1 -0
  12. package/dist/DataTable/constants.js +15 -0
  13. package/dist/DataTable/constants.js.map +1 -0
  14. package/dist/DataTable/index.js +15 -0
  15. package/dist/DataTable/index.js.map +1 -0
  16. package/dist/DataTable/reorderDataRowsLocally.js +26 -0
  17. package/dist/DataTable/reorderDataRowsLocally.js.map +1 -0
  18. package/dist/DataTable/useRowReordering.js +179 -0
  19. package/dist/DataTable/useRowReordering.js.map +1 -0
  20. package/dist/DataTable/useScrollIndication.js +70 -0
  21. package/dist/DataTable/useScrollIndication.js.map +1 -0
  22. package/dist/index.js +1 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/labs/DataFilters.js +47 -15
  25. package/dist/labs/DataFilters.js.map +1 -1
  26. package/dist/labs/DataTable.js +19 -14
  27. package/dist/labs/DataTable.js.map +1 -1
  28. package/dist/labs/index.js +0 -1
  29. package/dist/labs/index.js.map +1 -1
  30. package/dist/properties/ts/odyssey-react-mui.js +27 -1
  31. package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
  32. package/dist/src/DataTable/DataTable.d.ts +151 -0
  33. package/dist/src/DataTable/DataTable.d.ts.map +1 -0
  34. package/dist/src/DataTable/DataTableEmptyState.d.ts +21 -0
  35. package/dist/src/DataTable/DataTableEmptyState.d.ts.map +1 -0
  36. package/dist/src/DataTable/DataTablePagination.d.ts +33 -0
  37. package/dist/src/DataTable/DataTablePagination.d.ts.map +1 -0
  38. package/dist/src/DataTable/DataTableRowActions.d.ts +30 -0
  39. package/dist/src/DataTable/DataTableRowActions.d.ts.map +1 -0
  40. package/dist/src/DataTable/DataTableSettings.d.ts +27 -0
  41. package/dist/src/DataTable/DataTableSettings.d.ts.map +1 -0
  42. package/dist/src/DataTable/constants.d.ts +14 -0
  43. package/dist/src/DataTable/constants.d.ts.map +1 -0
  44. package/dist/src/DataTable/index.d.ts +16 -0
  45. package/dist/src/DataTable/index.d.ts.map +1 -0
  46. package/dist/src/DataTable/reorderDataRowsLocally.d.ts +26 -0
  47. package/dist/src/DataTable/reorderDataRowsLocally.d.ts.map +1 -0
  48. package/dist/src/DataTable/useRowReordering.d.ts +56 -0
  49. package/dist/src/DataTable/useRowReordering.d.ts.map +1 -0
  50. package/dist/src/DataTable/useScrollIndication.d.ts +22 -0
  51. package/dist/src/DataTable/useScrollIndication.d.ts.map +1 -0
  52. package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
  53. package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
  54. package/dist/src/index.d.ts +1 -0
  55. package/dist/src/index.d.ts.map +1 -1
  56. package/dist/src/labs/DataFilters.d.ts +5 -1
  57. package/dist/src/labs/DataFilters.d.ts.map +1 -1
  58. package/dist/src/labs/DataTable.d.ts +2 -2
  59. package/dist/src/labs/DataTable.d.ts.map +1 -1
  60. package/dist/src/labs/index.d.ts +3 -1
  61. package/dist/src/labs/index.d.ts.map +1 -1
  62. package/dist/src/properties/ts/odyssey-react-mui.d.ts +27 -1
  63. package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
  64. package/dist/src/theme/components.d.ts.map +1 -1
  65. package/dist/theme/components.js +37 -18
  66. package/dist/theme/components.js.map +1 -1
  67. package/dist/tsconfig.production.tsbuildinfo +1 -1
  68. package/package.json +3 -3
  69. package/src/DataTable/DataTable.tsx +746 -0
  70. package/src/DataTable/DataTableEmptyState.tsx +62 -0
  71. package/src/DataTable/DataTablePagination.tsx +289 -0
  72. package/src/DataTable/DataTableRowActions.tsx +122 -0
  73. package/src/DataTable/DataTableSettings.tsx +135 -0
  74. package/src/DataTable/constants.ts +14 -0
  75. package/src/DataTable/index.tsx +28 -0
  76. package/src/DataTable/reorderDataRowsLocally.tsx +48 -0
  77. package/src/DataTable/useRowReordering.tsx +235 -0
  78. package/src/DataTable/useScrollIndication.tsx +118 -0
  79. package/src/index.ts +1 -0
  80. package/src/labs/DataFilters.tsx +69 -17
  81. package/src/labs/DataTable.tsx +29 -20
  82. package/src/labs/index.ts +3 -1
  83. package/src/properties/odyssey-react-mui.properties +41 -2
  84. package/src/properties/ts/odyssey-react-mui.ts +1 -1
  85. package/src/theme/components.tsx +43 -16
@@ -0,0 +1,221 @@
1
+ import _InputBase from "@mui/material/InputBase";
2
+ /*!
3
+ * Copyright (c) 2023-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
+ import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
14
+ import { Paragraph } from "../Typography.js";
15
+ import { Button } from "../Button.js";
16
+ import { ArrowLeftIcon, ArrowRightIcon } from "../icons.generated/index.js";
17
+ import styled from "@emotion/styled";
18
+ import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext.js";
19
+ import { Box } from "../Box.js";
20
+ import { Trans, useTranslation } from "react-i18next";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
+ const PaginationContainer = styled("div")({
24
+ display: "flex",
25
+ alignItems: "center",
26
+ justifyContent: "space-between"
27
+ });
28
+ const PaginationSegment = styled("div", {
29
+ shouldForwardProp: prop => prop !== "odysseyDesignTokens"
30
+ })(({
31
+ odysseyDesignTokens
32
+ }) => ({
33
+ display: "flex",
34
+ alignItems: "center",
35
+ gap: odysseyDesignTokens.Spacing4,
36
+ "& > div": {
37
+ display: "flex",
38
+ alignItems: "center",
39
+ gap: odysseyDesignTokens.Spacing2
40
+ }
41
+ }));
42
+ const PaginationInput = styled(_InputBase, {
43
+ shouldForwardProp: prop => prop !== "odysseyDesignTokens"
44
+ })(({
45
+ odysseyDesignTokens
46
+ }) => ({
47
+ borderColor: odysseyDesignTokens.HueNeutral200,
48
+ borderRadius: odysseyDesignTokens.BorderRadiusTight,
49
+ height: odysseyDesignTokens.Spacing6,
50
+ width: "4.5714285714rem",
51
+ "&:hover": {
52
+ borderColor: odysseyDesignTokens.HueNeutral400
53
+ },
54
+ "&.Mui-focused:hover": {
55
+ borderColor: odysseyDesignTokens.PalettePrimaryMain
56
+ }
57
+ }));
58
+ const PaginationButtonContainer = styled("div")({
59
+ "& > *": {
60
+ marginInlineStart: `0 !important`
61
+ }
62
+ });
63
+ const DataTablePagination = ({
64
+ pagination,
65
+ setPagination,
66
+ totalRows,
67
+ isDisabled,
68
+ variant
69
+ }) => {
70
+ const odysseyDesignTokens = useOdysseyDesignTokens();
71
+ const {
72
+ t
73
+ } = useTranslation();
74
+ const [page, setPage] = useState(pagination.pageIndex);
75
+ const [rowsPerPage, setRowsPerPage] = useState(pagination.pageSize);
76
+ const initialRowsPerPage = useRef(pagination.pageSize);
77
+ const firstRow = pagination.pageSize * (pagination.pageIndex - 1) + 1;
78
+ let lastRow = firstRow + (pagination.pageSize - 1);
79
+ lastRow = totalRows && lastRow > totalRows ? totalRows : lastRow;
80
+ useEffect(() => {
81
+ setPage(pagination.pageIndex);
82
+ setRowsPerPage(pagination.pageSize);
83
+ }, [pagination]);
84
+ const handlePaginationChange = useCallback(() => {
85
+ const updatedPage = totalRows && page * totalRows > lastRow ? Math.ceil(totalRows / rowsPerPage) : page;
86
+ const updatedRowsPerPage = totalRows && rowsPerPage > totalRows ? totalRows : rowsPerPage;
87
+ setPagination({
88
+ pageIndex: updatedPage,
89
+ pageSize: updatedRowsPerPage
90
+ });
91
+ }, [page, rowsPerPage, lastRow, setPagination, totalRows]);
92
+ const handlePageSubmit = useCallback(event => {
93
+ if (event.key === "Enter") {
94
+ setPagination({
95
+ pageIndex: parseInt(event.currentTarget.value),
96
+ pageSize: rowsPerPage
97
+ });
98
+ }
99
+ }, [rowsPerPage, setPagination]);
100
+ const handleRowsPerPageSubmit = useCallback(event => {
101
+ if (event.key === "Enter") {
102
+ setPagination({
103
+ pageIndex: page,
104
+ pageSize: parseInt(event.currentTarget.value)
105
+ });
106
+ }
107
+ }, [page, setPagination]);
108
+ const setPageFromEvent = useCallback(event => {
109
+ setPage(parseInt(event.target.value));
110
+ }, [setPage]);
111
+ const setRowsPerPageFromEvent = useCallback(event => {
112
+ setRowsPerPage(parseInt(event.target.value));
113
+ }, [setRowsPerPage]);
114
+ const handleLoadMore = useCallback(() => {
115
+ setPagination({
116
+ pageIndex: 1,
117
+ pageSize: rowsPerPage + initialRowsPerPage.current
118
+ });
119
+ }, [rowsPerPage, setPagination]);
120
+ const handleNextButton = useCallback(() => {
121
+ setPagination({
122
+ pageIndex: page + 1,
123
+ pageSize: rowsPerPage
124
+ });
125
+ }, [setPagination, page, rowsPerPage]);
126
+ const handlePreviousButton = useCallback(() => {
127
+ setPagination({
128
+ pageIndex: page - 1,
129
+ pageSize: rowsPerPage
130
+ });
131
+ }, [setPagination, page, rowsPerPage]);
132
+ const loadMoreIsDisabled = useMemo(() => {
133
+ return totalRows ? rowsPerPage >= totalRows : false;
134
+ }, [rowsPerPage, totalRows]);
135
+ const nextButtonDisabled = useMemo(() => (totalRows ? lastRow >= totalRows : false) || isDisabled, [totalRows, lastRow, isDisabled]);
136
+ const previousButtonDisabled = useMemo(() => pagination.pageIndex <= 1 || isDisabled, [pagination, isDisabled]);
137
+ return variant === "paged" ? _jsxs(PaginationContainer, {
138
+ children: [_jsxs(PaginationSegment, {
139
+ odysseyDesignTokens: odysseyDesignTokens,
140
+ children: [_jsxs(Box, {
141
+ children: [_jsx(Paragraph, {
142
+ component: "span",
143
+ color: "textSecondary",
144
+ children: t("table.pagination.rowsperpage")
145
+ }), _jsx(PaginationInput, {
146
+ odysseyDesignTokens: odysseyDesignTokens,
147
+ type: "number",
148
+ value: rowsPerPage,
149
+ onChange: setRowsPerPageFromEvent,
150
+ onBlur: handlePaginationChange,
151
+ onKeyDown: handleRowsPerPageSubmit,
152
+ disabled: isDisabled,
153
+ inputProps: {
154
+ "aria-label": t("table.pagination.rowsperpage")
155
+ }
156
+ })]
157
+ }), _jsx(Paragraph, {
158
+ component: "span",
159
+ color: "textSecondary",
160
+ children: totalRows ? _jsx(Trans, {
161
+ i18nKey: "table.pagination.rowswithtotal",
162
+ values: {
163
+ firstRow,
164
+ lastRow,
165
+ totalRows
166
+ }
167
+ }) : _jsx(Trans, {
168
+ i18nKey: "table.pagination.rowswithouttotal",
169
+ values: {
170
+ firstRow,
171
+ lastRow
172
+ }
173
+ })
174
+ })]
175
+ }), _jsxs(PaginationSegment, {
176
+ odysseyDesignTokens: odysseyDesignTokens,
177
+ children: [totalRows && _jsxs(Box, {
178
+ children: [_jsx(Paragraph, {
179
+ component: "span",
180
+ color: "textSecondary",
181
+ children: t("table.pagination.page")
182
+ }), _jsx(PaginationInput, {
183
+ odysseyDesignTokens: odysseyDesignTokens,
184
+ type: "number",
185
+ value: page,
186
+ onChange: setPageFromEvent,
187
+ onBlur: handlePaginationChange,
188
+ onKeyDown: handlePageSubmit,
189
+ disabled: isDisabled,
190
+ inputProps: {
191
+ "aria-label": t("table.pagination.page")
192
+ }
193
+ })]
194
+ }), _jsxs(PaginationButtonContainer, {
195
+ children: [_jsx(Button, {
196
+ startIcon: _jsx(ArrowLeftIcon, {}),
197
+ variant: "floating",
198
+ size: "small",
199
+ ariaLabel: t("table.pagination.previous"),
200
+ onClick: handlePreviousButton,
201
+ isDisabled: previousButtonDisabled
202
+ }), _jsx(Button, {
203
+ endIcon: _jsx(ArrowRightIcon, {}),
204
+ variant: "floating",
205
+ size: "small",
206
+ ariaLabel: t("table.pagination.next"),
207
+ onClick: handleNextButton,
208
+ isDisabled: nextButtonDisabled
209
+ })]
210
+ })]
211
+ })]
212
+ }) : _jsx(Button, {
213
+ variant: "secondary",
214
+ label: t("table.pagination.loadmore"),
215
+ onClick: handleLoadMore,
216
+ isDisabled: loadMoreIsDisabled
217
+ });
218
+ };
219
+ const MemoizedDataTablePagination = memo(DataTablePagination);
220
+ export { MemoizedDataTablePagination as DataTablePagination };
221
+ //# sourceMappingURL=DataTablePagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTablePagination.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","Paragraph","Button","ArrowLeftIcon","ArrowRightIcon","styled","useOdysseyDesignTokens","Box","Trans","useTranslation","jsx","_jsx","jsxs","_jsxs","PaginationContainer","display","alignItems","justifyContent","PaginationSegment","shouldForwardProp","prop","odysseyDesignTokens","gap","Spacing4","Spacing2","PaginationInput","_InputBase","borderColor","HueNeutral200","borderRadius","BorderRadiusTight","height","Spacing6","width","HueNeutral400","PalettePrimaryMain","PaginationButtonContainer","marginInlineStart","DataTablePagination","pagination","setPagination","totalRows","isDisabled","variant","t","page","setPage","pageIndex","rowsPerPage","setRowsPerPage","pageSize","initialRowsPerPage","firstRow","lastRow","handlePaginationChange","updatedPage","Math","ceil","updatedRowsPerPage","handlePageSubmit","event","key","parseInt","currentTarget","value","handleRowsPerPageSubmit","setPageFromEvent","target","setRowsPerPageFromEvent","handleLoadMore","current","handleNextButton","handlePreviousButton","loadMoreIsDisabled","nextButtonDisabled","previousButtonDisabled","children","component","color","type","onChange","onBlur","onKeyDown","disabled","inputProps","i18nKey","values","startIcon","size","ariaLabel","onClick","endIcon","label","MemoizedDataTablePagination"],"sources":["../../src/DataTable/DataTablePagination.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 { InputBase } from \"@mui/material\";\nimport {\n Dispatch,\n SetStateAction,\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Paragraph } from \"../Typography\";\nimport { Button } from \"../Button\";\nimport { ArrowLeftIcon, ArrowRightIcon } from \"../icons.generated\";\nimport styled from \"@emotion/styled\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { Box } from \"../Box\";\nimport { Trans, useTranslation } from \"react-i18next\";\nimport { paginationTypeValues } from \"./constants\";\n\nconst PaginationContainer = styled(\"div\")({\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n});\n\nconst PaginationSegment = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing4,\n \"& > div\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing2,\n },\n}));\n\nconst PaginationInput = styled(InputBase, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n borderColor: odysseyDesignTokens.HueNeutral200,\n borderRadius: odysseyDesignTokens.BorderRadiusTight,\n height: odysseyDesignTokens.Spacing6,\n width: \"4.5714285714rem\", // This is a hardcoded value, keep as string\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral400,\n },\n \"&.Mui-focused:hover\": {\n borderColor: odysseyDesignTokens.PalettePrimaryMain,\n },\n}));\n\nconst PaginationButtonContainer = styled(\"div\")({\n \"& > *\": {\n marginInlineStart: `0 !important`,\n },\n});\n\nexport type DataTablePaginationProps = {\n pagination: {\n pageIndex: number;\n pageSize: number;\n };\n setPagination: Dispatch<\n SetStateAction<{ pageIndex: number; pageSize: number }>\n >;\n totalRows?: number;\n isDisabled?: boolean;\n /**\n * The type of pagination controls shown. Defaults to next/prev buttons, but can be\n * set to a simple \"Load more\" button by setting to \"loadMore\".\n */\n variant?: (typeof paginationTypeValues)[number];\n};\n\nconst DataTablePagination = ({\n pagination,\n setPagination,\n totalRows,\n isDisabled,\n variant,\n}: DataTablePaginationProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const [page, setPage] = useState<number>(pagination.pageIndex);\n const [rowsPerPage, setRowsPerPage] = useState<number>(pagination.pageSize);\n const initialRowsPerPage = useRef<number>(pagination.pageSize);\n\n const firstRow = pagination.pageSize * (pagination.pageIndex - 1) + 1;\n let lastRow = firstRow + (pagination.pageSize - 1);\n // If the last eligible row is greater than the number of total rows,\n // show the number of total rows instead (ie, if we're showing rows\n // 180-200 but there are only 190 rows, show 180-190 instead)\n lastRow = totalRows && lastRow > totalRows ? totalRows : lastRow;\n\n useEffect(() => {\n setPage(pagination.pageIndex);\n setRowsPerPage(pagination.pageSize);\n }, [pagination]);\n\n const handlePaginationChange = useCallback(() => {\n const updatedPage =\n totalRows && page * totalRows > lastRow\n ? Math.ceil(totalRows / rowsPerPage)\n : page;\n const updatedRowsPerPage =\n totalRows && rowsPerPage > totalRows ? totalRows : rowsPerPage;\n\n setPagination({\n pageIndex: updatedPage,\n pageSize: updatedRowsPerPage,\n });\n }, [page, rowsPerPage, lastRow, setPagination, totalRows]);\n\n // The following handlers use React.KeyboardEvent (rather than just KeyboardEvent) becuase React.KeyboardEvent\n // is generic, while plain KeyboardEvent is not. We need this generic so we can specify the HTMLInputElement,\n // which allows us to use currentTarget.value\n const handlePageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n setPagination({\n pageIndex: parseInt(event.currentTarget.value),\n pageSize: rowsPerPage,\n });\n }\n },\n [rowsPerPage, setPagination],\n );\n\n const handleRowsPerPageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n setPagination({\n pageIndex: page,\n pageSize: parseInt(event.currentTarget.value),\n });\n }\n },\n [page, setPagination],\n );\n\n const setPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setPage(parseInt(event.target.value));\n },\n [setPage],\n );\n\n const setRowsPerPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setRowsPerPage(parseInt(event.target.value));\n },\n [setRowsPerPage],\n );\n\n const handleLoadMore = useCallback(() => {\n setPagination({\n pageIndex: 1,\n pageSize: rowsPerPage + initialRowsPerPage.current,\n });\n }, [rowsPerPage, setPagination]);\n\n const handleNextButton = useCallback(() => {\n setPagination({ pageIndex: page + 1, pageSize: rowsPerPage });\n }, [setPagination, page, rowsPerPage]);\n\n const handlePreviousButton = useCallback(() => {\n setPagination({ pageIndex: page - 1, pageSize: rowsPerPage });\n }, [setPagination, page, rowsPerPage]);\n\n const loadMoreIsDisabled = useMemo(() => {\n return totalRows ? rowsPerPage >= totalRows : false;\n }, [rowsPerPage, totalRows]);\n\n const nextButtonDisabled = useMemo(\n () => (totalRows ? lastRow >= totalRows : false) || isDisabled,\n [totalRows, lastRow, isDisabled],\n );\n\n const previousButtonDisabled = useMemo(\n () => pagination.pageIndex <= 1 || isDisabled,\n [pagination, isDisabled],\n );\n\n return variant === \"paged\" ? (\n <PaginationContainer>\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {t(\"table.pagination.rowsperpage\")}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={rowsPerPage}\n onChange={setRowsPerPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handleRowsPerPageSubmit}\n disabled={isDisabled}\n inputProps={{\n \"aria-label\": t(\"table.pagination.rowsperpage\"),\n }}\n />\n </Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {totalRows ? (\n <Trans\n i18nKey=\"table.pagination.rowswithtotal\"\n values={{ firstRow, lastRow, totalRows }}\n />\n ) : (\n <Trans\n i18nKey=\"table.pagination.rowswithouttotal\"\n values={{ firstRow, lastRow }}\n />\n )}\n </Paragraph>\n </PaginationSegment>\n\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {totalRows && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {t(\"table.pagination.page\")}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={page}\n onChange={setPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handlePageSubmit}\n disabled={isDisabled}\n inputProps={{\n \"aria-label\": t(\"table.pagination.page\"),\n }}\n />\n </Box>\n )}\n <PaginationButtonContainer>\n <Button\n startIcon={<ArrowLeftIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={t(\"table.pagination.previous\")}\n onClick={handlePreviousButton}\n isDisabled={previousButtonDisabled}\n />\n <Button\n endIcon={<ArrowRightIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={t(\"table.pagination.next\")}\n onClick={handleNextButton}\n isDisabled={nextButtonDisabled}\n />\n </PaginationButtonContainer>\n </PaginationSegment>\n </PaginationContainer>\n ) : (\n <Button\n variant=\"secondary\"\n label={t(\"table.pagination.loadmore\")}\n onClick={handleLoadMore}\n isDisabled={loadMoreIsDisabled}\n />\n );\n};\n\nconst MemoizedDataTablePagination = memo(DataTablePagination);\nexport { MemoizedDataTablePagination as DataTablePagination };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAGEA,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAAC,SACNC,SAAS;AAAA,SACTC,MAAM;AAAA,SACNC,aAAa,EAAEC,cAAc;AACtC,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAGnCC,sBAAsB;AAAA,SAEfC,GAAG;AACZ,SAASC,KAAK,EAAEC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAGtD,MAAMC,mBAAmB,GAAGT,MAAM,CAAC,KAAK,CAAC,CAAC;EACxCU,OAAO,EAAE,MAAM;EACfC,UAAU,EAAE,QAAQ;EACpBC,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAGb,MAAM,CAAC,KAAK,EAAE;EACtCc,iBAAiB,EAAGC,IAAI,IAAKA,IAAI,KAAK;AACxC,CAAC,CAAC,CAAC,CAAC;EAAEC;AAA2D,CAAC,MAAM;EACtEN,OAAO,EAAE,MAAM;EACfC,UAAU,EAAE,QAAQ;EACpBM,GAAG,EAAED,mBAAmB,CAACE,QAAQ;EACjC,SAAS,EAAE;IACTR,OAAO,EAAE,MAAM;IACfC,UAAU,EAAE,QAAQ;IACpBM,GAAG,EAAED,mBAAmB,CAACG;EAC3B;AACF,CAAC,CAAC,CAAC;AAEH,MAAMC,eAAe,GAAGpB,MAAM,CAAAqB,UAAA,EAAY;EACxCP,iBAAiB,EAAGC,IAAI,IAAKA,IAAI,KAAK;AACxC,CAAC,CAAC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C,GAEtB/D,IAAA,CAACT,MAAM;IACLyC,OAAO,EAAC,WAAW;IACnBiD,KAAK,EAAEhD,CAAC,CAAC,2BAA2B,CAAE;IACtC8C,OAAO,EAAErB,cAAe;IACxB3B,UAAU,EAAE+B;EAAmB,CAChC,CACF;AACH,CAAC;AAED,MAAMoB,2BAA2B,GAAGlG,IAAI,CAAC2C,mBAAmB,CAAC;AAC7D,SAASuD,2BAA2B,IAAIvD,mBAAmB"}
@@ -0,0 +1,99 @@
1
+ import _Box from "@mui/material/Box";
2
+ /*!
3
+ * Copyright (c) 2023-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, useCallback } from "react";
15
+ import { MenuItem } from "../MenuItem.js";
16
+ import { MenuButton } from "../MenuButton.js";
17
+ import { ArrowBottomIcon, ArrowDownIcon, ArrowTopIcon, ArrowUpIcon, MoreIcon } from "../icons.generated/index.js";
18
+ import { Trans, useTranslation } from "react-i18next";
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { Fragment as _Fragment } from "react/jsx-runtime";
21
+ import { jsxs as _jsxs } from "react/jsx-runtime";
22
+ const DataTableRowActions = ({
23
+ row,
24
+ rowIndex,
25
+ rowActionButtons,
26
+ rowActionMenuItems,
27
+ totalRows,
28
+ updateRowOrder
29
+ }) => {
30
+ const {
31
+ t
32
+ } = useTranslation();
33
+ const handleToFrontClick = useCallback(() => {
34
+ updateRowOrder && updateRowOrder({
35
+ rowId: row.id,
36
+ newRowIndex: 0
37
+ });
38
+ }, [row.id, updateRowOrder]);
39
+ const handleForwardClick = useCallback(() => {
40
+ updateRowOrder && updateRowOrder({
41
+ rowId: row.id,
42
+ newRowIndex: Math.max(0, rowIndex - 1)
43
+ });
44
+ }, [row.id, rowIndex, updateRowOrder]);
45
+ const handleBackwardClick = useCallback(() => {
46
+ updateRowOrder && updateRowOrder({
47
+ rowId: row.id,
48
+ newRowIndex: rowIndex + 1
49
+ });
50
+ }, [row.id, rowIndex, updateRowOrder]);
51
+ const handleToBackClick = useCallback(() => {
52
+ updateRowOrder && updateRowOrder({
53
+ rowId: row.id,
54
+ newRowIndex: totalRows ? totalRows - 1 : rowIndex
55
+ });
56
+ }, [row.id, rowIndex, totalRows, updateRowOrder]);
57
+ return _jsxs(_Box, {
58
+ display: "flex",
59
+ children: [rowActionButtons?.(row), (rowActionMenuItems || updateRowOrder) && _jsxs(MenuButton, {
60
+ endIcon: _jsx(MoreIcon, {}),
61
+ size: "small",
62
+ buttonVariant: "floating",
63
+ ariaLabel: t("table.moreactions.arialabel"),
64
+ menuAlignment: "right",
65
+ children: [rowActionMenuItems && _jsx(_Fragment, {
66
+ children: rowActionMenuItems(row)
67
+ }), rowActionMenuItems && updateRowOrder && _jsx("hr", {}), updateRowOrder && _jsxs(_Fragment, {
68
+ children: [_jsxs(MenuItem, {
69
+ isDisabled: rowIndex <= 0,
70
+ onClick: handleToFrontClick,
71
+ children: [_jsx(ArrowTopIcon, {}), " ", _jsx(Trans, {
72
+ i18nKey: "table.reorder.tofront"
73
+ })]
74
+ }), _jsxs(MenuItem, {
75
+ isDisabled: rowIndex <= 0,
76
+ onClick: handleForwardClick,
77
+ children: [_jsx(ArrowUpIcon, {}), " ", _jsx(Trans, {
78
+ i18nKey: "table.reorder.forward"
79
+ })]
80
+ }), _jsxs(MenuItem, {
81
+ isDisabled: totalRows ? rowIndex >= totalRows - 1 : false,
82
+ onClick: handleBackwardClick,
83
+ children: [_jsx(ArrowDownIcon, {}), " ", _jsx(Trans, {
84
+ i18nKey: "table.reorder.backward"
85
+ })]
86
+ }), totalRows && _jsxs(MenuItem, {
87
+ isDisabled: rowIndex >= totalRows - 1,
88
+ onClick: handleToBackClick,
89
+ children: [_jsx(ArrowBottomIcon, {}), " ", _jsx(Trans, {
90
+ i18nKey: "table.reorder.toback"
91
+ })]
92
+ })]
93
+ })]
94
+ })]
95
+ });
96
+ };
97
+ const MemoizedDataTableRowActions = memo(DataTableRowActions);
98
+ export { MemoizedDataTableRowActions as DataTableRowActions };
99
+ //# sourceMappingURL=DataTableRowActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableRowActions.js","names":["memo","useCallback","MenuItem","MenuButton","ArrowBottomIcon","ArrowDownIcon","ArrowTopIcon","ArrowUpIcon","MoreIcon","Trans","useTranslation","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DataTableRowActions","row","rowIndex","rowActionButtons","rowActionMenuItems","totalRows","updateRowOrder","t","handleToFrontClick","rowId","id","newRowIndex","handleForwardClick","Math","max","handleBackwardClick","handleToBackClick","_Box","display","children","endIcon","size","buttonVariant","ariaLabel","menuAlignment","isDisabled","onClick","i18nKey","MemoizedDataTableRowActions"],"sources":["../../src/DataTable/DataTableRowActions.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_Row, MRT_RowData } from \"material-react-table\";\nimport { Fragment, ReactElement, memo, useCallback } from \"react\";\nimport { Button } from \"../Button\";\nimport { MenuItem } from \"../MenuItem\";\nimport { Box as MuiBox } from \"@mui/material\";\nimport { MenuButton, MenuButtonProps } from \"../MenuButton\";\nimport {\n ArrowBottomIcon,\n ArrowDownIcon,\n ArrowTopIcon,\n ArrowUpIcon,\n MoreIcon,\n} from \"../icons.generated\";\nimport { DataTableProps } from \"./DataTable\";\nimport { Trans, useTranslation } from \"react-i18next\";\n\nexport type DataTableRowActionsProps = {\n row: MRT_Row<MRT_RowData>;\n rowIndex: number;\n rowActionButtons?: (\n row: MRT_RowData,\n ) => ReactElement<typeof Button | typeof Fragment>;\n rowActionMenuItems?: (row: MRT_RowData) => MenuButtonProps[\"children\"];\n totalRows?: DataTableProps[\"totalRows\"];\n updateRowOrder?: ({\n rowId,\n newRowIndex,\n }: {\n rowId: string;\n newRowIndex: number;\n }) => void;\n};\n\nconst DataTableRowActions = ({\n row,\n rowIndex,\n rowActionButtons,\n rowActionMenuItems,\n totalRows,\n updateRowOrder,\n}: DataTableRowActionsProps) => {\n const { t } = useTranslation();\n\n const handleToFrontClick = useCallback(() => {\n updateRowOrder && updateRowOrder({ rowId: row.id, newRowIndex: 0 });\n }, [row.id, updateRowOrder]);\n\n const handleForwardClick = useCallback(() => {\n updateRowOrder &&\n updateRowOrder({ rowId: row.id, newRowIndex: Math.max(0, rowIndex - 1) });\n }, [row.id, rowIndex, updateRowOrder]);\n\n const handleBackwardClick = useCallback(() => {\n updateRowOrder &&\n updateRowOrder({ rowId: row.id, newRowIndex: rowIndex + 1 });\n }, [row.id, rowIndex, updateRowOrder]);\n\n const handleToBackClick = useCallback(() => {\n updateRowOrder &&\n updateRowOrder({\n rowId: row.id,\n newRowIndex: totalRows ? totalRows - 1 : rowIndex,\n });\n }, [row.id, rowIndex, totalRows, updateRowOrder]);\n\n return (\n <MuiBox display=\"flex\">\n {rowActionButtons?.(row)}\n {(rowActionMenuItems || updateRowOrder) && (\n <MenuButton\n endIcon={<MoreIcon />}\n size=\"small\"\n buttonVariant=\"floating\"\n ariaLabel={t(\"table.moreactions.arialabel\")}\n menuAlignment=\"right\"\n >\n {rowActionMenuItems && <>{rowActionMenuItems(row)}</>}\n {rowActionMenuItems && updateRowOrder && <hr />}\n {updateRowOrder && (\n <>\n <MenuItem isDisabled={rowIndex <= 0} onClick={handleToFrontClick}>\n <ArrowTopIcon /> <Trans i18nKey=\"table.reorder.tofront\" />\n </MenuItem>\n <MenuItem isDisabled={rowIndex <= 0} onClick={handleForwardClick}>\n <ArrowUpIcon /> <Trans i18nKey=\"table.reorder.forward\" />\n </MenuItem>\n <MenuItem\n isDisabled={totalRows ? rowIndex >= totalRows - 1 : false}\n onClick={handleBackwardClick}\n >\n <ArrowDownIcon /> <Trans i18nKey=\"table.reorder.backward\" />\n </MenuItem>\n {totalRows && (\n <MenuItem\n isDisabled={rowIndex >= totalRows - 1}\n onClick={handleToBackClick}\n >\n <ArrowBottomIcon /> <Trans i18nKey=\"table.reorder.toback\" />\n </MenuItem>\n )}\n </>\n )}\n </MenuButton>\n )}\n </MuiBox>\n );\n};\n\nconst MemoizedDataTableRowActions = memo(DataTableRowActions);\nexport { MemoizedDataTableRowActions as DataTableRowActions };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAAiCA,IAAI,EAAEC,WAAW,QAAQ,OAAO;AAAC,SAEzDC,QAAQ;AAAA,SAERC,UAAU;AAAA,SAEjBC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,QAAQ;AAGV,SAASC,KAAK,EAAEC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAmBtD,MAAMC,mBAAmB,GAAGA,CAAC;EAC3BC,GAAG;EACHC,QAAQ;EACRC,gBAAgB;EAChBC,kBAAkB;EAClBC,SAAS;EACTC;AACwB,CAAC,KAAK;EAC9B,MAAM;IAAEC;EAAE,CAAC,GAAGd,cAAc,CAAC,CAAC;EAE9B,MAAMe,kBAAkB,GAAGxB,WAAW,CAAC,MAAM;IAC3CsB,cAA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GAE3BxB,IAAA,CAACR,eAAe,IAAE,CAAC,KAAC,EAAAQ,IAAA,CAACH,KAAK;YAACmC,OAAO,EAAC;UAAsB,CAAE,CAAC;QAAA,CACpD,CACX;MAAA,CACD,CACH;IAAA,CACS,CACb;EAAA,CACK,CAAC;AAEb,CAAC;AAED,MAAMC,2BAA2B,GAAG7C,IAAI,CAACiB,mBAAmB,CAAC;AAC7D,SAAS4B,2BAA2B,IAAI5B,mBAAmB"}
@@ -0,0 +1,84 @@
1
+ import _Checkbox from "@mui/material/Checkbox";
2
+ /*!
3
+ * Copyright (c) 2023-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, useCallback, useMemo } from "react";
15
+ import { MenuButton } from "../MenuButton.js";
16
+ import { MenuItem } from "../MenuItem.js";
17
+ import { ListIcon, ShowIcon } from "../icons.generated/index.js";
18
+ import { densityValues } from "./constants.js";
19
+ import { useTranslation } from "react-i18next";
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ import { Fragment as _Fragment } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
+ const DataTableSettings = ({
24
+ hasChangeableDensity,
25
+ rowDensity,
26
+ setRowDensity,
27
+ hasColumnVisibility,
28
+ columns,
29
+ columnVisibility,
30
+ setColumnVisibility
31
+ }) => {
32
+ const {
33
+ t
34
+ } = useTranslation();
35
+ const changeRowDensity = useCallback(value => _event => {
36
+ if (process.env.NODE_ENV === "development") console.debug(_event);
37
+ setRowDensity(value);
38
+ }, [setRowDensity]);
39
+ const changeColumnVisibility = useCallback(columnId => _event => {
40
+ if (process.env.NODE_ENV === "development") console.debug(_event);
41
+ setColumnVisibility(prevVisibility => ({
42
+ ...prevVisibility,
43
+ [columnId]: prevVisibility ? prevVisibility[columnId] === false : false
44
+ }));
45
+ }, [setColumnVisibility]);
46
+ const isColumnVisibilityChecked = useMemo(() => {
47
+ return columns.reduce((acc, column) => {
48
+ const isChecked = columnVisibility ? columnVisibility[column.accessorKey] !== false : true;
49
+ acc[column.accessorKey] = isChecked;
50
+ return acc;
51
+ }, {});
52
+ }, [columns, columnVisibility]);
53
+ return _jsxs(_Fragment, {
54
+ children: [hasChangeableDensity && _jsx(MenuButton, {
55
+ endIcon: _jsx(ListIcon, {}),
56
+ ariaLabel: t("table.density.arialabel"),
57
+ menuAlignment: "right",
58
+ shouldCloseOnSelect: false,
59
+ children: _jsx(_Fragment, {
60
+ children: densityValues.map(value => _jsx(MenuItem, {
61
+ isSelected: rowDensity === value,
62
+ onClick: changeRowDensity(value),
63
+ children: `${value.charAt(0).toUpperCase()}${value.slice(1)}`
64
+ }, value))
65
+ })
66
+ }), hasColumnVisibility && _jsx(MenuButton, {
67
+ endIcon: _jsx(ShowIcon, {}),
68
+ ariaLabel: t("table.columnvisibility.arialabel"),
69
+ menuAlignment: "right",
70
+ shouldCloseOnSelect: false,
71
+ children: _jsx(_Fragment, {
72
+ children: columns.filter(column => column.enableHiding !== false).map(column => _jsxs(MenuItem, {
73
+ onClick: changeColumnVisibility(column.id),
74
+ children: [_jsx(_Checkbox, {
75
+ checked: isColumnVisibilityChecked[column.accessorKey]
76
+ }), column.header]
77
+ }, column.accessorKey))
78
+ })
79
+ })]
80
+ });
81
+ };
82
+ const MemoizedDataTableSettings = memo(DataTableSettings);
83
+ export { MemoizedDataTableSettings as DataTableSettings };
84
+ //# sourceMappingURL=DataTableSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableSettings.js","names":["memo","useCallback","useMemo","MenuButton","MenuItem","ListIcon","ShowIcon","densityValues","useTranslation","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DataTableSettings","hasChangeableDensity","rowDensity","setRowDensity","hasColumnVisibility","columns","columnVisibility","setColumnVisibility","t","changeRowDensity","value","_event","process","env","NODE_ENV","console","debug","changeColumnVisibility","columnId","prevVisibility","isColumnVisibilityChecked","reduce","acc","column","isChecked","accessorKey","children","endIcon","ariaLabel","menuAlignment","shouldCloseOnSelect","map","isSelected","onClick","charAt","toUpperCase","slice","filter","enableHiding","id","_Checkbox","checked","header","MemoizedDataTableSettings"],"sources":["../../src/DataTable/DataTableSettings.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, memo, useCallback, useMemo } from \"react\";\nimport { Checkbox as MuiCheckbox } from \"@mui/material\";\nimport { MenuButton } from \"../MenuButton\";\nimport { MenuItem } from \"../MenuItem\";\nimport { ListIcon, ShowIcon } from \"../icons.generated\";\nimport { densityValues } from \"./constants\";\nimport { DataTableProps } from \"./DataTable\";\nimport { MRT_VisibilityState } from \"material-react-table\";\nimport { useTranslation } from \"react-i18next\";\n\nexport type DataTableSettingsProps = {\n hasChangeableDensity: DataTableProps[\"hasChangeableDensity\"];\n rowDensity: (typeof densityValues)[number];\n setRowDensity: Dispatch<SetStateAction<(typeof densityValues)[number]>>;\n hasColumnVisibility: DataTableProps[\"hasColumnVisibility\"];\n columns: DataTableProps[\"columns\"];\n columnVisibility?: MRT_VisibilityState;\n setColumnVisibility: Dispatch<\n SetStateAction<MRT_VisibilityState | undefined>\n >;\n};\n\nconst DataTableSettings = ({\n hasChangeableDensity,\n rowDensity,\n setRowDensity,\n hasColumnVisibility,\n columns,\n columnVisibility,\n setColumnVisibility,\n}: DataTableSettingsProps) => {\n const { t } = useTranslation();\n\n const changeRowDensity = useCallback(\n (value: (typeof densityValues)[number]) =>\n (_event: React.MouseEvent<HTMLLIElement>) => {\n // This is necessary to avoid linter errors, while the _event is necessary to satisfy the onClick type\n if (process.env.NODE_ENV === \"development\") console.debug(_event);\n\n setRowDensity(value);\n },\n [setRowDensity],\n );\n\n const changeColumnVisibility = useCallback(\n (columnId: string) => (_event: React.MouseEvent<HTMLLIElement>) => {\n // This is necessary to avoid linter errors, while the _event is necessary to satisfy the onClick type\n if (process.env.NODE_ENV === \"development\") console.debug(_event);\n\n setColumnVisibility((prevVisibility) => ({\n ...prevVisibility,\n [columnId]: prevVisibility ? prevVisibility[columnId] === false : false,\n }));\n },\n [setColumnVisibility],\n );\n\n const isColumnVisibilityChecked = useMemo(() => {\n return columns.reduce(\n (acc, column) => {\n const isChecked = columnVisibility\n ? columnVisibility[column.accessorKey!] !== false\n : true;\n acc[column.accessorKey!] = isChecked;\n return acc;\n },\n {} as Record<string, boolean>,\n );\n }, [columns, columnVisibility]);\n\n return (\n <>\n {hasChangeableDensity && (\n <MenuButton\n endIcon={<ListIcon />}\n ariaLabel={t(\"table.density.arialabel\")}\n menuAlignment=\"right\"\n shouldCloseOnSelect={false}\n >\n <>\n {densityValues.map((value: (typeof densityValues)[number]) => (\n <MenuItem\n key={value}\n isSelected={rowDensity === value}\n onClick={changeRowDensity(value)}\n >\n {`${value.charAt(0).toUpperCase()}${value.slice(1)}`}\n </MenuItem>\n ))}\n </>\n </MenuButton>\n )}\n\n {hasColumnVisibility && (\n <MenuButton\n endIcon={<ShowIcon />}\n ariaLabel={t(\"table.columnvisibility.arialabel\")}\n menuAlignment=\"right\"\n shouldCloseOnSelect={false}\n >\n <>\n {columns\n .filter((column) => column.enableHiding !== false)\n .map((column) => (\n <MenuItem\n key={column.accessorKey}\n onClick={changeColumnVisibility(column.id as string)}\n >\n <MuiCheckbox\n checked={isColumnVisibilityChecked[column.accessorKey!]}\n />\n {column.header}\n </MenuItem>\n ))}\n </>\n </MenuButton>\n )}\n </>\n );\n};\n\nconst MemoizedDataTableSettings = memo(DataTableSettings);\nexport { MemoizedDataTableSettings as DataTableSettings };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAmCA,IAAI,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEpEC,UAAU;AAAA,SACVC,QAAQ;AAAA,SACRC,QAAQ,EAAEC,QAAQ;AAAA,SAClBC,aAAa;AAGtB,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAc/C,MAAMC,iBAAiB,GAAGA,CAAC;EACzBC,oBAAoB;EACpBC,UAAU;EACVC,aAAa;EACbC,mBAAmB;EACnBC,OAAO;EACPC,gBAAgB;EAChBC;AACsB,CAAC,KAAK;EAC5B,MAAM;IAAEC;EAAE,CAAC,GAAGf,cAAc,CAAC,CAAC;EAE9B,MAAMgB,gBAAgB,GAAGvB,WAAW,CACjCwB,KAAqC,IACnCC,MAAuC,IAAK;IAE3C,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAEC,OAAO,CAACC,KAAK,CAACL,MAAM,CAAC;IAEjER,aAAa,CAACO,KAAK,CAAC;EACtB,CAAC,EACH,CAACP,aAAa,CAChB,CAAC;EAED,MAAMc,sBAAsB,GAAG/B,WAAW,CACvCgC,QAAgB,IAAMP,MAAuC,IAAK;IAEjE,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAEC,OAAO,CAACC,KAAK,CAACL,MAAM,CAAC;IAEjEJ,mBAAmB,CAAEY,cAA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BAAmB,IAClBT,IAAA,CAACP,UAAU;MACTuC,OAAO,EAAEhC,IAAA,CAACJ,QAAQ,IAAE,CAAE;MACtBqC,SAAS,EAAEpB,CAAC,CAAC,kCAAkC,CAAE;MACjDqB,aAAa,EAAC,OAAO;MACrBC,mBAAmB,EAAE,KAAM;MAAAJ,QAAA,EAE3B/B,IAAA,CAAAE,SAAA;QAAA6B,QAAA,EACGrB,OAAO,CACLgC,MAAM,CAAEd,MAAM,IAAKA,MAAM,CAACe,YAAY,KAAK,KAAK,CAAC,CACjDP,GAAG,CAAER,MAAM,IACVxB,KAAA,CAACV,QAAQ;UAEP4C,OAAO,EAAEhB,sBAAsB,CAACM,MAAM,CAACgB,EAAY,CAAE;UAAAb,QAAA,GAErD/B,IAAA,CAAA6C,SAAA;YACEC,OAAO,EAAErB,yBAAyB,CAACG,MAAM,CAACE,WAAW;UAAG,CACzD,CAAC,EACDF,MAAM,CAACmB,MAAM;QAAA,GANTnB,MAAM,CAACE,WAOJ,CACX;MAAC,CACJ;IAAC,CACO,CACb;EAAA,CACD,CAAC;AAEP,CAAC;AAED,MAAMkB,yBAAyB,GAAG1D,IAAI,CAACe,iBAAiB,CAAC;AACzD,SAAS2C,yBAAyB,IAAI3C,iBAAiB"}
@@ -0,0 +1,15 @@
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"];
14
+ export const paginationTypeValues = ["paged", "loadMore"];
15
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["densityValues","paginationTypeValues"],"sources":["../../src/DataTable/constants.ts"],"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\nexport const densityValues = [\"comfortable\", \"spacious\", \"compact\"] as const;\nexport const paginationTypeValues = [\"paged\", \"loadMore\"] as const;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,aAAa,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,SAAS,CAAU;AAC5E,OAAO,MAAMC,oBAAoB,GAAG,CAAC,OAAO,EAAE,UAAU,CAAU"}
@@ -0,0 +1,15 @@
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
+ export { DataTable } from "./DataTable.js";
13
+ export { DataTableEmptyState } from "./DataTableEmptyState.js";
14
+ export { densityValues } from "./constants.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["DataTable","DataTableEmptyState","densityValues"],"sources":["../../src/DataTable/index.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\nexport {\n DataTable,\n type DataTableProps,\n type DataTableGetDataType,\n type DataTableOnReorderRowsType,\n} from \"./DataTable\";\nexport { DataTableEmptyState } from \"./DataTableEmptyState\";\nexport { densityValues } from \"./constants\";\nexport type {\n MRT_ColumnFiltersState as DataTableFiltersState,\n MRT_SortingState as DataTableSortingState,\n MRT_RowSelectionState as DataTableRowSelectionState,\n MRT_ColumnDef as DataTableColumn,\n MRT_RowData as DataTableRowData,\n MRT_Row as DataTableRow,\n} from \"material-react-table\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,SAaEA,SAAS;AAAA,SAKFC,mBAAmB;AAAA,SACnBC,aAAa"}
@@ -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"}