rez-table-listing-mui 0.0.24 → 0.0.25

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.
@@ -64,7 +64,7 @@ function TableBody<T>({
64
64
  style: {
65
65
  ...getColumnPinningStylesBody(cell.column),
66
66
  width: cell.column.getSize(),
67
- ...(wrapColumns[cell.column.id] && {
67
+ ...((wrapColumns.all_wrap || wrapColumns[cell.column.id]) && {
68
68
  wordBreak: "break-all",
69
69
  // whiteSpace: "normal",
70
70
  }),
@@ -98,9 +98,10 @@ function TableBody<T>({
98
98
  <React.Fragment key={row.id}>
99
99
  {renderedRow}
100
100
  <tr>
101
- <td colSpan={table.getAllLeafColumns().length}>
101
+ {/* <td colSpan={table.getAllLeafColumns().length}>//commented out to remove extra line on opening of nested row
102
102
  {NestedComponent && <NestedComponent {...{ row }} />}
103
- </td>
103
+ </td> */}
104
+ {NestedComponent && <NestedComponent {...{ row }} />}
104
105
  </tr>
105
106
  </React.Fragment>
106
107
  );
@@ -39,6 +39,7 @@ function TableHeadPopover<T>({
39
39
  setWrapColumns((prev: Record<string, boolean>) => ({
40
40
  ...prev,
41
41
  [columnId]: !prev[columnId],
42
+ all_wrap: false,
42
43
  }));
43
44
  };
44
45
 
@@ -84,7 +85,7 @@ function TableHeadPopover<T>({
84
85
  <ListItemButton>
85
86
  <ListItemText primary="Wrap Cell" />
86
87
  <Switch
87
- checked={wrapColumns[column.id]}
88
+ checked={wrapColumns.all_wrap || wrapColumns[column.id]}
88
89
  onChange={() => toggleWrapForColumn(column.id)}
89
90
  />
90
91
  </ListItemButton>
@@ -62,7 +62,7 @@
62
62
  }
63
63
 
64
64
  .change-layout {
65
- margin-top: 1rem;
65
+ margin-top: 0.99rem;
66
66
  cursor: pointer;
67
67
  }
68
68
 
@@ -1,7 +1,6 @@
1
1
  import React, { useState, useRef, useEffect } from "react";
2
2
  import {
3
3
  ChangeLayoutIcon,
4
- SearchIcon,
5
4
  SortingIcon,
6
5
  CustomizationIcon,
7
6
  HideColumnIcon,
@@ -28,7 +27,7 @@ interface TopbarProps<T> {
28
27
  topbarOptions?: TopbarOptionsProps;
29
28
  columnOrder?: string[];
30
29
  setColumnOrder?: React.Dispatch<React.SetStateAction<string[]>>;
31
- tableStates?: CraftTableOptionsProps;
30
+ tableStates: CraftTableOptionsProps;
32
31
  searchValue?: string;
33
32
  onSearchChange?: (val: string) => void;
34
33
  }
@@ -40,10 +39,8 @@ function Topbar<T>({
40
39
  setIsCompactTable,
41
40
  paginationComponent,
42
41
  topbarOptions,
43
- searchValue,
44
- onSearchChange,
42
+ tableStates,
45
43
  }: TopbarProps<T>) {
46
- const [wrapCell, setWrapCell] = useState(false);
47
44
  const [isFullscreen, setIsFullscreen] = useState(false);
48
45
  const [sortAnchorEl, setSortAnchorEl] = useState<HTMLElement | null>(null);
49
46
  const [groupBy, setGroupBy] = useState<string>("None");
@@ -76,6 +73,8 @@ function Topbar<T>({
76
73
  showSearch,
77
74
  showFilter,
78
75
  showCustomizationToggle,
76
+ searchValue,
77
+ onSearchChange,
79
78
  } = topbarOptions ?? {};
80
79
 
81
80
  const { container: fullscreenContainer } = useFullscreenPopoverContainer();
@@ -112,13 +111,6 @@ function Topbar<T>({
112
111
  {rightSideComponent}
113
112
  {paginationComponent}
114
113
 
115
- {/* {showSearch && (
116
- <div className="search ts--button" title="Search">
117
- <SearchIcon />
118
-
119
- </div>
120
- )} */}
121
-
122
114
  {showSearch && (
123
115
  <TableSearch
124
116
  value={searchValue ?? ""}
@@ -206,8 +198,6 @@ function Topbar<T>({
206
198
  {viewMoreToggle && (
207
199
  <div className="view-more ts--button" title="View More">
208
200
  <ViewMore
209
- wrapCell={wrapCell}
210
- onWrapCellToggle={() => setWrapCell((prev) => !prev)}
211
201
  compactMode={isCompactTable}
212
202
  onCompactToggle={(value: string) =>
213
203
  setIsCompactTable(value === "Compact")
@@ -219,6 +209,7 @@ function Topbar<T>({
219
209
  }}
220
210
  groupBy={groupBy}
221
211
  onGroupByChange={(value: string) => setGroupBy(value)}
212
+ tableStates={tableStates}
222
213
  />
223
214
  </div>
224
215
  )}
@@ -10,28 +10,26 @@ import {
10
10
  } from "@mui/material";
11
11
  import { CloseIcon, ViewMoreIcon } from "../../assets/svg";
12
12
  import { useFullscreenPopoverContainer } from "../../libs/hooks/useFullScreen";
13
+ import { CraftTableOptionsProps } from "../../types/table-options";
13
14
 
14
15
  interface ViewMorePopoverProps {
15
- wrapCell: boolean;
16
- onWrapCellToggle: () => void;
17
16
  compactMode: boolean;
18
17
  onCompactToggle: (value: string) => void;
19
18
  isFullscreen: boolean;
20
19
  onFullscreenToggle: () => void;
21
20
  groupBy: string;
22
21
  onGroupByChange: (value: string) => void;
23
- // tableStates: CraftTableOptionsProps;
22
+ tableStates: CraftTableOptionsProps;
24
23
  }
25
24
 
26
25
  const ViewMore = ({
27
- wrapCell,
28
- onWrapCellToggle,
29
26
  compactMode,
30
27
  onCompactToggle,
31
28
  isFullscreen,
32
29
  onFullscreenToggle,
33
30
  groupBy,
34
31
  onGroupByChange,
32
+ tableStates,
35
33
  }: ViewMorePopoverProps) => {
36
34
  const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
37
35
 
@@ -46,16 +44,13 @@ const ViewMore = ({
46
44
  setAnchorEl(null);
47
45
  };
48
46
 
49
- // const { wrapColumns, globalWrapColumns, setGlobalWrapColumns } = tableStates;
47
+ const { wrapColumns, setWrapColumns } = tableStates;
50
48
 
51
- // const toggleGlobalWrap = (value: boolean | null) => {
52
- // setGlobalWrapColumns(value); // true = wrap all, false = un-wrap all, null = use wrapState
53
- // };
54
-
55
- // const isWrapped =
56
- // globalWrapColumns !== null
57
- // ? globalWrapColumns
58
- // : !!wrapColumns[cell.column.id];
49
+ const onWrapCellToggle = () => {
50
+ setWrapColumns((prev: Record<string, boolean>) => ({
51
+ all_wrap: !prev["all_wrap"],
52
+ }));
53
+ };
59
54
 
60
55
  return (
61
56
  <>
@@ -112,7 +107,10 @@ const ViewMore = ({
112
107
  <Typography fontSize="14px" fontWeight={400} color="#000000DE">
113
108
  Wrap Cell
114
109
  </Typography>
115
- <MUISwitch checked={wrapCell} onChange={onWrapCellToggle} />
110
+ <MUISwitch
111
+ checked={wrapColumns?.all_wrap || false}
112
+ onChange={onWrapCellToggle}
113
+ />
116
114
  </Box>
117
115
 
118
116
  {/* List View */}
@@ -135,6 +133,15 @@ const ViewMore = ({
135
133
  color: "#000",
136
134
  fontSize: "13px",
137
135
  }}
136
+ MenuProps={{
137
+ container: fullscreenContainer,
138
+ disablePortal: false,
139
+ PaperProps: {
140
+ style: {
141
+ zIndex: 1500,
142
+ },
143
+ },
144
+ }}
138
145
  >
139
146
  <MenuItem value="Comfy">Comfy</MenuItem>
140
147
  <MenuItem value="Compact">Compact</MenuItem>
@@ -161,6 +168,15 @@ const ViewMore = ({
161
168
  color: "#000",
162
169
  fontSize: "13px",
163
170
  }}
171
+ MenuProps={{
172
+ container: fullscreenContainer,
173
+ disablePortal: false,
174
+ PaperProps: {
175
+ style: {
176
+ zIndex: 1500,
177
+ },
178
+ },
179
+ }}
164
180
  >
165
181
  <MenuItem value="None">None</MenuItem>
166
182
  <MenuItem value="Status">Status</MenuItem>
@@ -15,7 +15,9 @@ export function useCraftTable(paginationPageSize: number = 25) {
15
15
  const [sorting, setSorting] = useState<SortingState>([]);
16
16
  const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
17
17
  const [expanded, setExpanded] = useState<ExpandedState>({});
18
- const [wrapColumns, setWrapColumns] = useState<Record<string, boolean>>({});
18
+ const [wrapColumns, setWrapColumns] = useState<Record<string, boolean>>({
19
+ all_wrap: true,
20
+ });
19
21
  const [globalWrapColumns, setGlobalWrapColumns] = useState<boolean | null>(
20
22
  null
21
23
  );
@@ -26,11 +26,12 @@ export const useDefaultColumns = () => {
26
26
  // ),
27
27
  cell: ({ row, getValue }) => {
28
28
  return (
29
- <div style={{ paddingLeft: `${row.depth * 2}rem` }}>
29
+ <div
30
+ style={{ paddingLeft: `${row.depth * 2}rem`, display: "flex" }}
31
+ >
30
32
  {row.getCanExpand() ? (
31
33
  <button
32
34
  style={{
33
- // marginRight: "0.8rem",
34
35
  cursor: "pointer",
35
36
  background: "none",
36
37
  border: "none",
@@ -48,7 +49,7 @@ export const useDefaultColumns = () => {
48
49
  ) : (
49
50
  <span style={{ marginRight: "0.8rem" }}></span>
50
51
  )}
51
- {getValue<boolean>()}
52
+ <span style={{ marginTop: "0.2rem" }}>{getValue<boolean>()}</span>
52
53
  </div>
53
54
  );
54
55
  },
@@ -37,6 +37,9 @@ export interface TopbarOptionsProps {
37
37
  showSearch?: boolean;
38
38
  showFilter?: boolean;
39
39
  showCustomizationToggle?: boolean;
40
+ tableStates: CraftTableOptionsProps;
41
+ searchValue?: string;
42
+ onSearchChange?: (val: string) => void;
40
43
  }
41
44
 
42
45
  export interface CustomRenderContext<T> {
@@ -75,8 +78,6 @@ export interface CraftTableProps<T> {
75
78
  customRenderFn?: CustomRenderFnMap<T>;
76
79
  shouldHideColumn?: (accessorKey?: string) => boolean;
77
80
  styleOptions?: CraftTableStyleProps;
78
- searchValue?: string;
79
- onSearchChange?: (val: string) => void;
80
81
  }
81
82
  export interface CraftTableComponentProps<T> {
82
83
  table: Table<T>;