slick-table 1.1.5 → 1.1.7

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 (21) hide show
  1. package/dist/index.cjs.js +51 -51
  2. package/dist/index.es.js +736 -737
  3. package/dist/types/features/header-context-menu/model/consts/id.d.ts +1 -1
  4. package/dist/types/features/header-context-menu/ui/Title/Title.d.ts.map +1 -1
  5. package/dist/types/features/header-context-menu/ui/Title/Title.style.d.ts.map +1 -1
  6. package/dist/types/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.d.ts.map +1 -1
  7. package/package.json +1 -1
  8. package/src/features/header-context-menu/model/consts/id.ts +1 -1
  9. package/src/features/header-context-menu/ui/HeaderContextMenu.style.ts +1 -1
  10. package/src/features/header-context-menu/ui/HeaderContextMenu.tsx +1 -1
  11. package/src/features/header-context-menu/ui/Title/Title.style.ts +2 -1
  12. package/src/features/header-context-menu/ui/Title/Title.tsx +5 -1
  13. package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.ts +15 -10
  14. package/src/entities/popup/ui/Overlay/Overlay.test.tsx +0 -19
  15. package/src/shared/lib/slickgrid/lib/grouping/formatterGroupTotals.test.ts +0 -59
  16. package/src/shared/lib/slickgrid/model/SlickTable/filters/Filter.test.ts +0 -80
  17. package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/DecoratorColumnFilter.test.ts +0 -216
  18. package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/Filter.test.ts +0 -264
  19. package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/DecoratorFilter.test.ts +0 -139
  20. package/src/shared/lib/slickgrid/model/SlickTable/printer/DefaultPrinter.test.ts +0 -226
  21. package/src/shared/lib/slickgrid/model/SlickTable/table/SlickTable.test.ts +0 -72
@@ -1,2 +1,2 @@
1
- export declare const HEADER_CONTEXT_MENU = "header_context_menu";
1
+ export declare const HEADER_CONTEXT_MENU = "header-context-menu";
2
2
  //# sourceMappingURL=id.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Title.d.ts","sourceRoot":"","sources":["../../../../../../src/features/header-context-menu/ui/Title/Title.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,KAAK,EAAE,EAEnB,CAAC"}
1
+ {"version":3,"file":"Title.d.ts","sourceRoot":"","sources":["../../../../../../src/features/header-context-menu/ui/Title/Title.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,KAAK,EAAE,EAMnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Title.style.d.ts","sourceRoot":"","sources":["../../../../../../src/features/header-context-menu/ui/Title/Title.style.ts"],"names":[],"mappings":";;;;;AAOA,wBAA2B"}
1
+ {"version":3,"file":"Title.style.d.ts","sourceRoot":"","sources":["../../../../../../src/features/header-context-menu/ui/Title/Title.style.ts"],"names":[],"mappings":";;;;;AAQA,wBAA2B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGrid.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.ts"],"names":[],"mappings":"AACA,OAAO,EACN,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EAOrB,MAAM,WAAW,CAAC;AAYnB,OAAO,EAAE,KAAK,EAAkB,MAAM,aAAa,CAAC;AAEpD,wBAAgB,OAAO,CAAC,EACvB,aAAiC,EACjC,kBAAkB,EAClB,SAAiB,EACjB,YAAqB,EACrB,OAAO,EACP,eAAe,EACf,MAAM,EACN,cAAqB,EACrB,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,iBAAkC,EAClC,qBAAqB,EACrB,OAAY,EACZ,KAAK,GACL,EAAE,KAAK,GAAG;IACV,WAAW,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3C,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC7C,QA+GA"}
1
+ {"version":3,"file":"useGrid.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.ts"],"names":[],"mappings":"AACA,OAAO,EACN,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EAOrB,MAAM,WAAW,CAAC;AAYnB,OAAO,EAAE,KAAK,EAAkB,MAAM,aAAa,CAAC;AAEpD,wBAAgB,OAAO,CAAC,EACvB,aAAiC,EACjC,kBAAkB,EAClB,SAAiB,EACjB,YAAqB,EACrB,OAAO,EACP,eAAe,EACf,MAAM,EACN,cAAqB,EACrB,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,iBAAkC,EAClC,qBAAqB,EACrB,OAAY,EACZ,KAAK,GACL,EAAE,KAAK,GAAG;IACV,WAAW,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3C,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC7C,QAoHA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slick-table",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Enhanced version of SlickGrid library",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1 +1 @@
1
- export const HEADER_CONTEXT_MENU = "header_context_menu";
1
+ export const HEADER_CONTEXT_MENU = "header-context-menu";
@@ -8,7 +8,7 @@ const ButtonsGroup = styled(Box)({
8
8
  });
9
9
 
10
10
  const ItemsGroup = styled(Box)({
11
- maxHeight: "20em",
11
+ maxHeight: "35em",
12
12
  overflowY: "auto",
13
13
  });
14
14
 
@@ -51,7 +51,7 @@ export const HeaderContextMenu: FC = () => {
51
51
  </Fragment>
52
52
  ))}
53
53
  </Styled.ItemsGroup>
54
- <Styled.ButtonsGroup>
54
+ <Styled.ButtonsGroup className={"header-context-menu-footer"}>
55
55
  <ButtonCheckAll setChecked={setChecked} />
56
56
  <ButtonUncheckAll checked={checked} setChecked={setChecked} />
57
57
  </Styled.ButtonsGroup>
@@ -2,7 +2,8 @@ import { Box, styled } from "@mui/material";
2
2
 
3
3
  const Wrapper = styled(Box)({
4
4
  color: "#1e456f",
5
- marginBottom: "0.5em",
5
+ marginBottom: "0.6em",
6
+ fontSize: "1rem",
6
7
  });
7
8
 
8
9
  export default { Wrapper };
@@ -3,5 +3,9 @@ import { FC } from "react";
3
3
  import Styled from "./Title.style";
4
4
 
5
5
  export const Title: FC = () => {
6
- return <Styled.Wrapper>Columns</Styled.Wrapper>;
6
+ return (
7
+ <Styled.Wrapper className={"header-context-menu-header"}>
8
+ Columns
9
+ </Styled.Wrapper>
10
+ );
7
11
  };
@@ -140,6 +140,21 @@ export function useGrid({
140
140
  } else {
141
141
  grid.setColumns(columns);
142
142
  }
143
+ if (table.columnPicker) {
144
+ if (!table.columnPicker.initialColumns.length) {
145
+ table.columnPicker.initialColumns = grid.getColumns();
146
+ table.columnPicker.visibleColumnIds = grid
147
+ .getColumns()
148
+ .map(({ id }) => id as string);
149
+ }
150
+ grid.setColumns(
151
+ grid.getColumns().filter(({ id }) => {
152
+ if (!table.columnPicker) return true;
153
+ if (!table.columnPicker.visibleColumnIds.length) return true;
154
+ return table.columnPicker.visibleColumnIds.includes(id as string);
155
+ }),
156
+ );
157
+ }
143
158
  headerButtons.highlightAllColumns(table.filter.args, table.id);
144
159
  table.filter.register(grid, table.id);
145
160
  grid.invalidate();
@@ -147,14 +162,4 @@ export function useGrid({
147
162
  table.notifyObservers();
148
163
  columnSorter.restoreSorting(table);
149
164
  }, [columns, items]);
150
-
151
- useEffect(() => {
152
- if (!table.columnPicker) return;
153
- const grid = table.grid;
154
- if (!grid) return;
155
- table.columnPicker.initialColumns = grid.getColumns();
156
- table.columnPicker.visibleColumnIds = grid
157
- .getColumns()
158
- .map(({ id }) => id as string);
159
- }, [columns]);
160
165
  }
@@ -1,19 +0,0 @@
1
- import { fireEvent, render } from "@testing-library/react";
2
- import userEvent from "@testing-library/user-event";
3
-
4
- import { Overlay } from "./Overlay";
5
-
6
- describe("Overlay", () => {
7
- it("should call setIsOpened with false on click or right-click", async () => {
8
- const user = userEvent.setup();
9
- const setIsOpened = jest.fn();
10
- const { getByTestId } = render(<Overlay setIsOpened={setIsOpened} />);
11
- const div = getByTestId("overlay");
12
- expect(div).toBeInTheDocument();
13
- await user.click(div);
14
- expect(setIsOpened).toHaveBeenCalledWith(false);
15
- fireEvent.contextMenu(div);
16
- expect(setIsOpened).toHaveBeenCalledWith(false);
17
- expect(setIsOpened).toHaveBeenCalledTimes(2);
18
- });
19
- });
@@ -1,59 +0,0 @@
1
- import { SlickGroup } from "slickgrid";
2
-
3
- import { IColumn } from "shared/model/types";
4
-
5
- import { formatterGroupTotals } from "./formatterGroupTotals";
6
-
7
- describe("sumTotalsFormatter", () => {
8
- it("should return an empty string when totals.sum is undefined", () => {
9
- const totals = {
10
- group: { level: 0 } as SlickGroup,
11
- initialized: true,
12
- sum: undefined,
13
- };
14
- const columnDef: IColumn = { field: "someField" };
15
-
16
- const result = formatterGroupTotals(totals as any, columnDef);
17
-
18
- expect(result).toBe("TOTAL: ");
19
- });
20
-
21
- it("should return 'TOTAL: 1,000.00' for group level 0", () => {
22
- const totals = {
23
- group: { level: 0 } as SlickGroup,
24
- initialized: true,
25
- sum: { someField: 1000 },
26
- };
27
- const columnDef: IColumn = { field: "someField" };
28
-
29
- const result = formatterGroupTotals(totals as any, columnDef);
30
-
31
- expect(result).toBe("TOTAL: 1,000.00");
32
- });
33
-
34
- it("should return 'total: 1,000.00' for group levels greater than 0", () => {
35
- const totals = {
36
- group: { level: 1 } as SlickGroup,
37
- initialized: true,
38
- sum: { someField: 1000 },
39
- };
40
- const columnDef: IColumn = { field: "someField" };
41
-
42
- const result = formatterGroupTotals(totals as any, columnDef);
43
-
44
- expect(result).toBe("total: 1,000.00");
45
- });
46
-
47
- it("should return an empty string when totals.sum[columnDef.field] is null", () => {
48
- const totals = {
49
- group: { level: 0 } as SlickGroup,
50
- initialized: true,
51
- sum: { someField: null },
52
- };
53
- const columnDef: IColumn = { field: "someField" };
54
-
55
- const result = formatterGroupTotals(totals as any, columnDef);
56
-
57
- expect(result).toBe("");
58
- });
59
- });
@@ -1,80 +0,0 @@
1
- import { SlickGrid } from "slickgrid";
2
-
3
- import { Filter } from "./Filter";
4
-
5
- describe("shared | lib | slickgrid | Filter", () => {
6
- it("should initialize with empty arguments and null grid", () => {
7
- const filter = new Filter();
8
- expect(filter.args).toEqual({});
9
- expect(filter.grid).toBeNull();
10
- });
11
-
12
- it("should register the filter with the provided grid and table ID", () => {
13
- const filter = new Filter();
14
- const mockGrid = {
15
- getData: jest.fn().mockReturnValue({
16
- setFilter: jest.fn(),
17
- setFilterArgs: jest.fn(),
18
- refresh: jest.fn(),
19
- }),
20
- } as unknown as SlickGrid;
21
- const tableId = "testTable";
22
-
23
- filter.register(mockGrid, tableId);
24
-
25
- expect(filter.grid).toBe(mockGrid);
26
- expect(filter.tableId).toBe(tableId);
27
- expect(mockGrid.getData().setFilter).toHaveBeenCalledWith(
28
- expect.any(Function),
29
- );
30
- expect(mockGrid.getData().setFilterArgs).toHaveBeenCalledWith(filter.args);
31
- expect(mockGrid.getData().refresh).toHaveBeenCalled();
32
- });
33
-
34
- it("should reset arguments to an empty object when reset is called", () => {
35
- const filter = new Filter();
36
- const mockGrid = {
37
- getData: jest.fn().mockReturnValue({
38
- setFilterArgs: jest.fn(),
39
- refresh: jest.fn(),
40
- }),
41
- } as unknown as SlickGrid;
42
- const initialArgs = { key: "value" };
43
-
44
- filter.grid = mockGrid;
45
- filter.args = initialArgs;
46
-
47
- filter.reset();
48
-
49
- expect(filter.args).toEqual({});
50
- expect(mockGrid.getData().setFilterArgs).toHaveBeenCalledWith({});
51
- expect(mockGrid.getData().refresh).toHaveBeenCalled();
52
- });
53
-
54
- it("should return an empty array from the print method", () => {
55
- const filter = new Filter();
56
- const result = filter.print();
57
- expect(Array.isArray(result)).toBe(true);
58
- expect(result).toEqual([]);
59
- expect(result.length).toBe(0);
60
- });
61
-
62
- it("should not attempt to reset if grid is null", () => {
63
- const filter = new Filter();
64
- filter.grid = null;
65
-
66
- filter.reset();
67
-
68
- expect(filter.args).toEqual({});
69
- });
70
-
71
- it("should not attempt to update data view if grid is null when setting args", () => {
72
- const filter = new Filter();
73
- const newArgs = { key: "value" };
74
-
75
- filter.grid = null;
76
- filter.args = newArgs;
77
-
78
- expect(filter.args).toEqual(newArgs);
79
- });
80
- });
@@ -1,216 +0,0 @@
1
- import { SlickGrid } from "slickgrid";
2
-
3
- import { headerButtons } from "shared/lib/slickgrid";
4
- import { EColumnFilter, EColumnFiltersGroup } from "shared/model/enums";
5
- import { IFilter } from "shared/model/types";
6
-
7
- import { DecoratorColumnFilter } from "./DecoratorColumnFilter";
8
- import { filter } from "./Filter";
9
-
10
- jest.mock("app/store/store");
11
-
12
- describe("DecoratorColumnFilter", () => {
13
- let decoratorColumnFilter: DecoratorColumnFilter;
14
- let mockFilter: IFilter;
15
-
16
- beforeEach(() => {
17
- mockFilter = {
18
- getFilterFn: jest.fn(),
19
- reset: jest.fn(),
20
- print: jest.fn(),
21
- args: {},
22
- grid: {} as SlickGrid,
23
- tableId: "test-table",
24
- } as unknown as IFilter;
25
- decoratorColumnFilter = new DecoratorColumnFilter(mockFilter);
26
- });
27
-
28
- it("should return true when args.columnFilters is undefined", () => {
29
- const item = { id: 1, name: "Test" };
30
- const args: any = {};
31
-
32
- const result = decoratorColumnFilter.filterFn(item, args);
33
-
34
- expect(result).toBe(true);
35
- });
36
-
37
- it("should return true when the grid is not available", () => {
38
- const item = { id: 1, name: "Test" };
39
- const args = {
40
- columnFilters: {
41
- name: {
42
- filterId: EColumnFilter.TextContain,
43
- group: EColumnFiltersGroup.Text,
44
- value: { 1: "Test", 2: "" },
45
- },
46
- },
47
- };
48
- decoratorColumnFilter.grid = null;
49
-
50
- const result = decoratorColumnFilter.filterFn(item, args);
51
-
52
- expect(result).toBe(true);
53
- });
54
-
55
- it("should correctly apply filters for boolean column types", () => {
56
- const mockGrid = {
57
- getColumns: jest.fn(() => [{ id: "isActive", field: "isActive" }]),
58
- getColumnIndex: jest.fn(() => 0),
59
- } as unknown as SlickGrid;
60
- decoratorColumnFilter.grid = mockGrid;
61
-
62
- const item = { isActive: true };
63
- const args = {
64
- columnFilters: {
65
- isActive: {
66
- filterId: EColumnFilter.Boolean,
67
- group: EColumnFiltersGroup.Boolean,
68
- value: { 1: "true", 2: "" },
69
- },
70
- },
71
- };
72
-
73
- const result = decoratorColumnFilter.filterFn(item, args);
74
-
75
- expect(result).toBe(true);
76
- expect(mockGrid.getColumns).toHaveBeenCalled();
77
- expect(mockGrid.getColumnIndex).toHaveBeenCalledWith("isActive");
78
- });
79
-
80
- it("should return false if any column filter fails", () => {
81
- const mockGrid = {
82
- getColumns: jest.fn(() => [
83
- { id: "name", field: "name" },
84
- { id: "age", field: "age" },
85
- ]),
86
- getColumnIndex: jest.fn((id) => (id === "name" ? 0 : 1)),
87
- } as unknown as SlickGrid;
88
- decoratorColumnFilter.grid = mockGrid;
89
-
90
- const item = { name: "John", age: 30 };
91
- const args = {
92
- columnFilters: {
93
- name: {
94
- filterId: EColumnFilter.TextContain,
95
- group: EColumnFiltersGroup.Text,
96
- value: { 1: "John", 2: "" },
97
- },
98
- age: {
99
- filterId: EColumnFilter.NumberFrom,
100
- group: EColumnFiltersGroup.Number,
101
- value: { 1: "40", 2: "" },
102
- },
103
- },
104
- };
105
-
106
- jest
107
- .spyOn(filter, "passed")
108
- .mockReturnValueOnce(true) // For name filter
109
- .mockReturnValueOnce(false); // For age filter
110
-
111
- const result = decoratorColumnFilter.filterFn(item, args);
112
-
113
- expect(result).toBe(false);
114
- expect(mockGrid.getColumns).toHaveBeenCalled();
115
- expect(mockGrid.getColumnIndex).toHaveBeenCalledWith("name");
116
- expect(mockGrid.getColumnIndex).toHaveBeenCalledWith("age");
117
- expect(filter.passed).toHaveBeenCalledTimes(2);
118
- });
119
-
120
- it("should use the formatter function for non-boolean and non-number column types", () => {
121
- const mockGrid = {
122
- getColumns: jest.fn(() => [
123
- {
124
- id: "name",
125
- field: "name",
126
- formatter: (_row: number, _cell: number, value: string) =>
127
- `Formatted: ${value}`,
128
- },
129
- { id: "age", field: "age" },
130
- ]),
131
- getColumnIndex: jest.fn((id) => (id === "name" ? 0 : 1)),
132
- } as unknown as SlickGrid;
133
- decoratorColumnFilter.grid = mockGrid;
134
-
135
- const item = { name: "John", age: 30 };
136
- const args = {
137
- columnFilters: {
138
- name: {
139
- filterId: EColumnFilter.TextContain,
140
- group: EColumnFiltersGroup.Text,
141
- value: { 1: "Formatted: John", 2: "" },
142
- },
143
- age: {
144
- filterId: EColumnFilter.NumberFrom,
145
- group: EColumnFiltersGroup.Number,
146
- value: { 1: "30", 2: "" },
147
- },
148
- },
149
- };
150
-
151
- jest.spyOn(filter, "passed").mockReturnValue(true);
152
-
153
- decoratorColumnFilter.filterFn(item, args);
154
-
155
- expect(filter.passed).toHaveBeenCalledWith(
156
- "Formatted: John",
157
- { 1: "Formatted: John", 2: "" },
158
- EColumnFilter.TextContain,
159
- );
160
- expect(filter.passed).toHaveBeenCalledWith(
161
- 30,
162
- { 1: "30", 2: "" },
163
- EColumnFilter.NumberFrom,
164
- );
165
- });
166
-
167
- it("should correctly reset filters and highlight all columns", () => {
168
- const mockFilter = {
169
- reset: jest.fn(),
170
- };
171
- const mockHeaderButtons = {
172
- highlightAllColumns: jest.fn(),
173
- };
174
- const mockArgs = { someArg: "value" };
175
- const mockTableId = "test-table";
176
-
177
- jest
178
- .spyOn(headerButtons, "highlightAllColumns")
179
- .mockImplementation(mockHeaderButtons.highlightAllColumns);
180
-
181
- const decoratorColumnFilter = new DecoratorColumnFilter(mockFilter as any);
182
- decoratorColumnFilter.args = mockArgs;
183
- decoratorColumnFilter.tableId = mockTableId;
184
-
185
- decoratorColumnFilter.reset();
186
-
187
- expect(mockFilter.reset).toHaveBeenCalled();
188
- expect(mockHeaderButtons.highlightAllColumns).toHaveBeenCalledWith(
189
- mockArgs,
190
- mockTableId,
191
- );
192
- });
193
- it("should correctly reset filters and highlight all columns", () => {
194
- const mockFilter = {
195
- reset: jest.fn(),
196
- };
197
- const mockHeaderButtons = {
198
- highlightAllColumns: jest.fn(),
199
- };
200
- const mockArgs = { someArg: "value" };
201
- const mockTableId = "";
202
-
203
- jest
204
- .spyOn(headerButtons, "highlightAllColumns")
205
- .mockImplementation(mockHeaderButtons.highlightAllColumns);
206
-
207
- const decoratorColumnFilter = new DecoratorColumnFilter(mockFilter as any);
208
- decoratorColumnFilter.args = mockArgs;
209
- decoratorColumnFilter.tableId = mockTableId;
210
-
211
- decoratorColumnFilter.reset();
212
-
213
- expect(mockFilter.reset).toHaveBeenCalled();
214
- expect(mockHeaderButtons.highlightAllColumns).not.toHaveBeenCalled();
215
- });
216
- });