@bluemarble/bm-components 0.0.36 → 0.0.38
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/dist/esm/index.js
CHANGED
|
@@ -15041,14 +15041,14 @@ function Grid({ columns: columnsData, children, fixedColumns, paperProps, tableB
|
|
|
15041
15041
|
defaultColumn.current = newColumns;
|
|
15042
15042
|
setColumns(newColumns);
|
|
15043
15043
|
}, [columnsData]);
|
|
15044
|
-
return (React__default.createElement(Paper, Object.assign({}, paperProps, { sx: Object.assign(
|
|
15044
|
+
return (React__default.createElement(Paper, Object.assign({}, paperProps, { sx: Object.assign({ "tr td": {
|
|
15045
15045
|
py: dense ? 0.23 : 0.7,
|
|
15046
15046
|
border: bordered ? "1px solid" : "",
|
|
15047
15047
|
borderColor: "divider",
|
|
15048
15048
|
}, "tr:nth-of-type(even)": {
|
|
15049
15049
|
transition: "background-color ease 200ms",
|
|
15050
15050
|
bgcolor: striped ? "divider" : "initial",
|
|
15051
|
-
} },
|
|
15051
|
+
} }, paperProps === null || paperProps === void 0 ? void 0 : paperProps.sx) }),
|
|
15052
15052
|
React__default.createElement(Table, Object.assign({ size: "small", stickyHeader: true }, tableProps, { sx: Object.assign(Object.assign({}, getTableWidth()), tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) }),
|
|
15053
15053
|
React__default.createElement(TableHead, Object.assign({}, tableHeadProps),
|
|
15054
15054
|
React__default.createElement(TableRow, { ref: columnsRef }, columns.map((column, index) => (React__default.createElement(TableCell, { key: column.name, padding: dense ? "none" : "normal", sx: Object.assign({ border: "1px solid", borderColor: "divider", width: column.width || 100, pl: 2, zIndex: columns.length - index }, column === null || column === void 0 ? void 0 : column.sx) },
|
|
@@ -15146,12 +15146,11 @@ function createFilter(filters) {
|
|
|
15146
15146
|
}
|
|
15147
15147
|
|
|
15148
15148
|
function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], }) {
|
|
15149
|
-
const [
|
|
15149
|
+
const [defaultData, setDefaultData] = useState([]);
|
|
15150
15150
|
const [sortedBy, setSortedBy] = useState("");
|
|
15151
15151
|
const [sortedDirection, setSortedDirection] = useState("desc");
|
|
15152
15152
|
const [currentPage, setCurrentPage] = useState(0);
|
|
15153
15153
|
const [rowsPerPage, setRowsPerPage] = useState(rowsPerPageOptions[0]);
|
|
15154
|
-
const defaultData = useRef([]);
|
|
15155
15154
|
const toggleSortedDirection = () => {
|
|
15156
15155
|
if (sortedDirection === "desc")
|
|
15157
15156
|
setSortedDirection("asc");
|
|
@@ -15175,8 +15174,7 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
|
|
|
15175
15174
|
}
|
|
15176
15175
|
};
|
|
15177
15176
|
const set = (data) => {
|
|
15178
|
-
|
|
15179
|
-
defaultData.current = data;
|
|
15177
|
+
setDefaultData(data);
|
|
15180
15178
|
};
|
|
15181
15179
|
const sortData = (data) => {
|
|
15182
15180
|
if (sortedBy) {
|
|
@@ -15204,10 +15202,10 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
|
|
|
15204
15202
|
setRowsPerPage(rows);
|
|
15205
15203
|
};
|
|
15206
15204
|
const filteredData = useMemo(() => {
|
|
15207
|
-
const newData = defaultData.
|
|
15205
|
+
const newData = defaultData.slice(0);
|
|
15208
15206
|
const newFilter = createFilter(filters);
|
|
15209
15207
|
return newData.filter(newFilter.apply);
|
|
15210
|
-
}, [
|
|
15208
|
+
}, [defaultData, filters]);
|
|
15211
15209
|
const displayData = useMemo(() => {
|
|
15212
15210
|
const sortedData = sortData(filteredData);
|
|
15213
15211
|
const startPage = currentPage * rowsPerPage;
|
|
@@ -15217,10 +15215,10 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
|
|
|
15217
15215
|
const totalNumberOfPages = Math.round(filteredData.length / rowsPerPage) - 1;
|
|
15218
15216
|
return {
|
|
15219
15217
|
data: displayData,
|
|
15220
|
-
defaultData: defaultData.current,
|
|
15221
15218
|
set,
|
|
15222
15219
|
onSortBy,
|
|
15223
15220
|
sortedBy,
|
|
15221
|
+
defaultData,
|
|
15224
15222
|
sortedDirection,
|
|
15225
15223
|
columns,
|
|
15226
15224
|
currentPage,
|