slick-table 1.1.3 → 1.1.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.
- package/dist/index.cjs.js +87 -87
- package/dist/index.es.js +5884 -5717
- package/dist/types/features/header-context-menu/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/lib/hooks/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/lib/hooks/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/lib/hooks/useSubscribeToEvent.d.ts +3 -0
- package/dist/types/features/header-context-menu/lib/hooks/useSubscribeToEvent.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/lib/index.d.ts +3 -0
- package/dist/types/features/header-context-menu/lib/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/lib/visibility/hideColumns.d.ts +2 -0
- package/dist/types/features/header-context-menu/lib/visibility/hideColumns.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/lib/visibility/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/lib/visibility/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/model/consts/id.d.ts +2 -0
- package/dist/types/features/header-context-menu/model/consts/id.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/model/consts/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/model/consts/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/model/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/model/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/ButtonCheckAll/ButtonCheckAll.d.ts +7 -0
- package/dist/types/features/header-context-menu/ui/ButtonCheckAll/ButtonCheckAll.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/ButtonCheckAll/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/ui/ButtonCheckAll/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/ButtonUncheckAll/ButtonUncheckAll.d.ts +8 -0
- package/dist/types/features/header-context-menu/ui/ButtonUncheckAll/ButtonUncheckAll.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/ButtonUncheckAll/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/ui/ButtonUncheckAll/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/HeaderContextMenu.d.ts +3 -0
- package/dist/types/features/header-context-menu/ui/HeaderContextMenu.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/HeaderContextMenu.style.d.ts +10 -0
- package/dist/types/features/header-context-menu/ui/HeaderContextMenu.style.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/Item/Item.d.ts +10 -0
- package/dist/types/features/header-context-menu/ui/Item/Item.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/Item/Item.style.d.ts +9 -0
- package/dist/types/features/header-context-menu/ui/Item/Item.style.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/Item/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/ui/Item/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/Title/Title.d.ts +3 -0
- package/dist/types/features/header-context-menu/ui/Title/Title.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/Title/Title.style.d.ts +7 -0
- package/dist/types/features/header-context-menu/ui/Title/Title.style.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/Title/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/ui/Title/index.d.ts.map +1 -0
- package/dist/types/features/header-context-menu/ui/index.d.ts +2 -0
- package/dist/types/features/header-context-menu/ui/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/index.d.ts +1 -1
- package/dist/types/shared/lib/slickgrid/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/lib/header-context-menu/index.d.ts +2 -0
- package/dist/types/shared/lib/slickgrid/lib/header-context-menu/index.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/lib/header-context-menu/openHeaderContextMenu.d.ts +4 -0
- package/dist/types/shared/lib/slickgrid/lib/header-context-menu/openHeaderContextMenu.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/lib/index.d.ts +2 -1
- package/dist/types/shared/lib/slickgrid/lib/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/SlickTable/column-picker/ColumnPicker.d.ts +10 -0
- package/dist/types/shared/lib/slickgrid/model/SlickTable/column-picker/ColumnPicker.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/model/SlickTable/column-picker/index.d.ts +2 -0
- package/dist/types/shared/lib/slickgrid/model/SlickTable/column-picker/index.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/DecoratorColumnFilter.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/SlickTable/index.d.ts +1 -0
- package/dist/types/shared/lib/slickgrid/model/SlickTable/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/SlickTable/table/SlickTable.d.ts +3 -1
- package/dist/types/shared/lib/slickgrid/model/SlickTable/table/SlickTable.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/events/eventHeaderContextMenu.d.ts +10 -0
- package/dist/types/shared/lib/slickgrid/model/events/eventHeaderContextMenu.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/model/events/index.d.ts +1 -0
- package/dist/types/shared/lib/slickgrid/model/events/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/index.d.ts +2 -2
- package/dist/types/shared/lib/slickgrid/model/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.d.ts.map +1 -1
- package/dist/types/shared/model/types/IColumnPicker.d.ts +6 -0
- package/dist/types/shared/model/types/IColumnPicker.d.ts.map +1 -0
- package/dist/types/shared/model/types/ISlickTable.d.ts +2 -0
- package/dist/types/shared/model/types/ISlickTable.d.ts.map +1 -1
- package/dist/types/shared/model/types/index.d.ts +1 -0
- package/dist/types/shared/model/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/header-context-menu/index.ts +1 -0
- package/src/features/header-context-menu/lib/hooks/index.ts +1 -0
- package/src/features/header-context-menu/lib/hooks/useSubscribeToEvent.ts +27 -0
- package/src/features/header-context-menu/lib/index.ts +2 -0
- package/src/features/header-context-menu/lib/visibility/hideColumns.ts +18 -0
- package/src/features/header-context-menu/lib/visibility/index.ts +1 -0
- package/src/features/header-context-menu/model/consts/id.ts +1 -0
- package/src/features/header-context-menu/model/consts/index.ts +1 -0
- package/src/features/header-context-menu/model/index.ts +1 -0
- package/src/features/header-context-menu/ui/ButtonCheckAll/ButtonCheckAll.tsx +33 -0
- package/src/features/header-context-menu/ui/ButtonCheckAll/index.ts +1 -0
- package/src/features/header-context-menu/ui/ButtonUncheckAll/ButtonUncheckAll.tsx +30 -0
- package/src/features/header-context-menu/ui/ButtonUncheckAll/index.ts +1 -0
- package/src/features/header-context-menu/ui/HeaderContextMenu.style.ts +15 -0
- package/src/features/header-context-menu/ui/HeaderContextMenu.tsx +61 -0
- package/src/features/header-context-menu/ui/Item/Item.style.ts +18 -0
- package/src/features/header-context-menu/ui/Item/Item.tsx +39 -0
- package/src/features/header-context-menu/ui/Item/index.ts +1 -0
- package/src/features/header-context-menu/ui/Title/Title.style.ts +8 -0
- package/src/features/header-context-menu/ui/Title/Title.tsx +7 -0
- package/src/features/header-context-menu/ui/Title/index.ts +1 -0
- package/src/features/header-context-menu/ui/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/shared/lib/slickgrid/index.ts +2 -0
- package/src/shared/lib/slickgrid/lib/header-context-menu/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/header-context-menu/openHeaderContextMenu.ts +17 -0
- package/src/shared/lib/slickgrid/lib/index.ts +7 -6
- package/src/shared/lib/slickgrid/model/SlickTable/column-picker/ColumnPicker.ts +23 -0
- package/src/shared/lib/slickgrid/model/SlickTable/column-picker/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/DecoratorColumnFilter.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/table/SlickTable.ts +5 -0
- package/src/shared/lib/slickgrid/model/events/eventHeaderContextMenu.ts +10 -0
- package/src/shared/lib/slickgrid/model/events/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/index.ts +2 -1
- package/src/shared/lib/slickgrid/ui/HeaderButtons/lib/highlighting/headerButtons.ts +1 -1
- package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.ts +13 -0
- package/src/shared/model/types/IColumnPicker.ts +6 -0
- package/src/shared/model/types/ISlickTable.ts +2 -0
- package/src/shared/model/types/index.ts +1 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Button } from "@mui/material";
|
|
2
|
+
import { Dispatch, FC, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
import { eventHeaderContextMenu } from "shared/lib/slickgrid";
|
|
5
|
+
|
|
6
|
+
import { hideColumns } from "../../lib";
|
|
7
|
+
|
|
8
|
+
export const ButtonCheckAll: FC<IProps> = ({ setChecked }) => {
|
|
9
|
+
function onClick() {
|
|
10
|
+
const table = eventHeaderContextMenu.table;
|
|
11
|
+
if (!table?.columnPicker) return;
|
|
12
|
+
const newChecked = table.columnPicker.initialColumns.map(
|
|
13
|
+
({ id }) => id,
|
|
14
|
+
) as string[];
|
|
15
|
+
setChecked(newChecked);
|
|
16
|
+
hideColumns(newChecked);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Button
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
size={"small"}
|
|
23
|
+
sx={{ textTransform: "none" }}
|
|
24
|
+
variant={"contained"}
|
|
25
|
+
>
|
|
26
|
+
Check all
|
|
27
|
+
</Button>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
interface IProps {
|
|
32
|
+
setChecked: Dispatch<SetStateAction<string[]>>;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ButtonCheckAll } from "./ButtonCheckAll";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Button } from "@mui/material";
|
|
2
|
+
import { Dispatch, FC, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
import { hideColumns } from "../../lib";
|
|
5
|
+
|
|
6
|
+
export const ButtonUncheckAll: FC<IProps> = ({ checked, setChecked }) => {
|
|
7
|
+
function onClick() {
|
|
8
|
+
const newChecked = checked.filter(
|
|
9
|
+
(id) => id === "_checkbox_selector" || id === "isEdited",
|
|
10
|
+
);
|
|
11
|
+
setChecked(newChecked);
|
|
12
|
+
hideColumns(newChecked);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
onClick={onClick}
|
|
18
|
+
size={"small"}
|
|
19
|
+
sx={{ textTransform: "none" }}
|
|
20
|
+
variant={"contained"}
|
|
21
|
+
>
|
|
22
|
+
Uncheck all
|
|
23
|
+
</Button>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface IProps {
|
|
28
|
+
checked: string[];
|
|
29
|
+
setChecked: Dispatch<SetStateAction<string[]>>;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ButtonUncheckAll } from "./ButtonUncheckAll";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Box, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
const ButtonsGroup = styled(Box)({
|
|
4
|
+
columnGap: "0.5em",
|
|
5
|
+
display: "flex",
|
|
6
|
+
justifyContent: "flex-end",
|
|
7
|
+
marginTop: "0.5em",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const ItemsGroup = styled(Box)({
|
|
11
|
+
maxHeight: "20em",
|
|
12
|
+
overflowY: "auto",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default { ButtonsGroup, ItemsGroup };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FC, Fragment, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { eventHeaderContextMenu } from "shared/lib/slickgrid";
|
|
4
|
+
|
|
5
|
+
import { Overlay, Popup } from "entities/popup";
|
|
6
|
+
|
|
7
|
+
import { useSubscribeToEvent } from "../lib";
|
|
8
|
+
import { HEADER_CONTEXT_MENU } from "../model";
|
|
9
|
+
import { ButtonCheckAll } from "./ButtonCheckAll";
|
|
10
|
+
import { ButtonUncheckAll } from "./ButtonUncheckAll";
|
|
11
|
+
import { Item } from "./Item";
|
|
12
|
+
import { Title } from "./Title";
|
|
13
|
+
|
|
14
|
+
import Styled from "./HeaderContextMenu.style";
|
|
15
|
+
|
|
16
|
+
export const HeaderContextMenu: FC = () => {
|
|
17
|
+
const [checked, setChecked] = useState<string[]>([]);
|
|
18
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
19
|
+
|
|
20
|
+
useSubscribeToEvent(setIsOpened);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!isOpened) return;
|
|
24
|
+
const table = eventHeaderContextMenu.table;
|
|
25
|
+
if (!table?.columnPicker) return;
|
|
26
|
+
setChecked([...table.columnPicker.visibleColumnIds]);
|
|
27
|
+
}, [isOpened]);
|
|
28
|
+
|
|
29
|
+
if (!isOpened) return null;
|
|
30
|
+
const table = eventHeaderContextMenu.table;
|
|
31
|
+
if (!table?.columnPicker) return null;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Fragment>
|
|
35
|
+
<Overlay setIsOpened={setIsOpened} />
|
|
36
|
+
<Popup id={HEADER_CONTEXT_MENU}>
|
|
37
|
+
<Title />
|
|
38
|
+
<Styled.ItemsGroup>
|
|
39
|
+
{table.columnPicker.initialColumns
|
|
40
|
+
.filter(
|
|
41
|
+
({ id }) => id !== "_checkbox_selector" && id !== "isEdited",
|
|
42
|
+
)
|
|
43
|
+
.map(({ id, name }) => (
|
|
44
|
+
<Fragment key={id}>
|
|
45
|
+
<Item
|
|
46
|
+
checked={checked}
|
|
47
|
+
columnId={id as string}
|
|
48
|
+
columnName={name as string}
|
|
49
|
+
setChecked={setChecked}
|
|
50
|
+
/>
|
|
51
|
+
</Fragment>
|
|
52
|
+
))}
|
|
53
|
+
</Styled.ItemsGroup>
|
|
54
|
+
<Styled.ButtonsGroup>
|
|
55
|
+
<ButtonCheckAll setChecked={setChecked} />
|
|
56
|
+
<ButtonUncheckAll checked={checked} setChecked={setChecked} />
|
|
57
|
+
</Styled.ButtonsGroup>
|
|
58
|
+
</Popup>
|
|
59
|
+
</Fragment>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Button, Checkbox, styled } from "@mui/material";
|
|
2
|
+
import { CheckboxProps } from "@mui/material/Checkbox/Checkbox";
|
|
3
|
+
|
|
4
|
+
const StyledButton = styled(Button)({
|
|
5
|
+
display: "flex",
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
justifyContent: "flex-start",
|
|
8
|
+
columnGap: "0.5em",
|
|
9
|
+
textTransform: "none",
|
|
10
|
+
color: "#1E456F",
|
|
11
|
+
padding: "0",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const StyledCheckbox = styled(Checkbox)<CheckboxProps>({
|
|
15
|
+
padding: 0,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default { Checkbox: StyledCheckbox, Button: StyledButton };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import { Dispatch, FC, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
import { hideColumns } from "../../lib";
|
|
5
|
+
|
|
6
|
+
import Styled from "./Item.style";
|
|
7
|
+
|
|
8
|
+
export const Item: FC<IProps> = ({
|
|
9
|
+
checked,
|
|
10
|
+
columnId,
|
|
11
|
+
columnName,
|
|
12
|
+
setChecked,
|
|
13
|
+
}) => {
|
|
14
|
+
function onClick() {
|
|
15
|
+
const index = checked.indexOf(columnId);
|
|
16
|
+
const newChecked = [...checked];
|
|
17
|
+
if (~index) {
|
|
18
|
+
newChecked.splice(index, 1);
|
|
19
|
+
} else {
|
|
20
|
+
newChecked.push(columnId);
|
|
21
|
+
}
|
|
22
|
+
setChecked(newChecked);
|
|
23
|
+
hideColumns(newChecked);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Styled.Button onClick={onClick}>
|
|
28
|
+
<Styled.Checkbox checked={checked.includes(columnId)} size={"small"} />
|
|
29
|
+
<Box>{columnName}</Box>
|
|
30
|
+
</Styled.Button>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
interface IProps {
|
|
35
|
+
checked: string[];
|
|
36
|
+
columnId: string;
|
|
37
|
+
columnName: string;
|
|
38
|
+
setChecked: Dispatch<SetStateAction<string[]>>;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Item } from "./Item";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Title } from "./Title";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HeaderContextMenu } from "./HeaderContextMenu";
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { Skeleton } from "entities/skeleton";
|
|
2
2
|
export { ColumnFilters } from "features/column-filters";
|
|
3
3
|
export { ContextMenu } from "features/context-menu";
|
|
4
|
+
export { HeaderContextMenu } from "features/header-context-menu";
|
|
4
5
|
export {
|
|
5
6
|
Autocomplete,
|
|
7
|
+
ColumnPicker,
|
|
6
8
|
ColumnSorter,
|
|
7
9
|
DecoratorColumnFilter,
|
|
8
10
|
DecoratorFilter,
|
|
@@ -41,6 +41,7 @@ export {
|
|
|
41
41
|
wereEdited,
|
|
42
42
|
} from "./lib";
|
|
43
43
|
export {
|
|
44
|
+
ColumnPicker,
|
|
44
45
|
DownloadManager,
|
|
45
46
|
DecoratorEndingDate,
|
|
46
47
|
DecoratorFilter,
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
WithConfirmationOfDeletion,
|
|
58
59
|
WithoutHotKeys,
|
|
59
60
|
eventContextMenu,
|
|
61
|
+
eventHeaderContextMenu,
|
|
60
62
|
} from "./model";
|
|
61
63
|
export {
|
|
62
64
|
SlickgridTable,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { openHeaderContextMenu } from "./openHeaderContextMenu";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OnHeaderContextMenuEventArgs, SlickEventData } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
import { eventHeaderContextMenu } from "../../model";
|
|
6
|
+
import { commitCurrentEdit } from "../functions";
|
|
7
|
+
|
|
8
|
+
export function openHeaderContextMenu(table: ISlickTable) {
|
|
9
|
+
return function (e: SlickEventData<OnHeaderContextMenuEventArgs>): void {
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
commitCurrentEdit();
|
|
12
|
+
eventHeaderContextMenu.table = table;
|
|
13
|
+
eventHeaderContextMenu.x = e.pageX || 0;
|
|
14
|
+
eventHeaderContextMenu.y = e.pageY || 0;
|
|
15
|
+
eventHeaderContextMenu.notify();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
getOnKeyDownCallback,
|
|
3
|
+
onCellChange,
|
|
4
|
+
onRowCountChanged,
|
|
5
|
+
onRowsChanged,
|
|
6
|
+
} from "./callbacks";
|
|
1
7
|
export { openContextMenu } from "./contextMenu";
|
|
8
|
+
export { openHeaderContextMenu } from "./header-context-menu";
|
|
2
9
|
export {
|
|
3
10
|
useHotKeys,
|
|
4
11
|
useListenIfTablesWereEdited,
|
|
@@ -14,12 +21,6 @@ export {
|
|
|
14
21
|
nothingToCopy,
|
|
15
22
|
positionToPaste,
|
|
16
23
|
} from "./hotKeys";
|
|
17
|
-
export {
|
|
18
|
-
getOnKeyDownCallback,
|
|
19
|
-
onCellChange,
|
|
20
|
-
onRowCountChanged,
|
|
21
|
-
onRowsChanged,
|
|
22
|
-
} from "./callbacks";
|
|
23
24
|
export {
|
|
24
25
|
Autocomplete,
|
|
25
26
|
EditorAmount,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IColumn, IColumnPicker } from "shared/model/types";
|
|
2
|
+
|
|
3
|
+
export class ColumnPicker implements IColumnPicker {
|
|
4
|
+
private _initialColumns: IColumn[] = [];
|
|
5
|
+
private _visibleColumnIds: string[] = [];
|
|
6
|
+
|
|
7
|
+
get visibleColumnIds() {
|
|
8
|
+
return this._visibleColumnIds;
|
|
9
|
+
}
|
|
10
|
+
set visibleColumnIds(ids) {
|
|
11
|
+
this._visibleColumnIds = ids;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get initialColumns() {
|
|
15
|
+
return this._initialColumns;
|
|
16
|
+
}
|
|
17
|
+
set initialColumns(columns) {
|
|
18
|
+
if (!this.visibleColumnIds.length) {
|
|
19
|
+
this.visibleColumnIds = columns.map(({ id }) => id as string);
|
|
20
|
+
}
|
|
21
|
+
this._initialColumns = columns;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColumnPicker } from "./ColumnPicker";
|
|
@@ -21,6 +21,7 @@ export class DecoratorColumnFilter extends DecoratorFilter {
|
|
|
21
21
|
for (let i = 0; i < columnIds.length; i++) {
|
|
22
22
|
const columnId = columnIds[i];
|
|
23
23
|
const column = columns[grid.getColumnIndex(columnId)];
|
|
24
|
+
if (!column) continue;
|
|
24
25
|
const { filterId, group, value } = args.columnFilters[columnId];
|
|
25
26
|
let cellValue = item[column?.field];
|
|
26
27
|
if (!formatterNotNeeded.includes(group)) {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import { elementNotVisible } from "shared/lib/dom";
|
|
11
11
|
import {
|
|
12
|
+
IColumnPicker,
|
|
12
13
|
IDownloadManager,
|
|
13
14
|
IFilter,
|
|
14
15
|
IGrouping,
|
|
@@ -26,6 +27,7 @@ import { WithoutHotKeys } from "../hotKeys";
|
|
|
26
27
|
import { DefaultPrinter } from "../printer";
|
|
27
28
|
|
|
28
29
|
export class SlickTable implements ISlickTable {
|
|
30
|
+
public columnPicker: IColumnPicker | null = null;
|
|
29
31
|
public downloadManager: IDownloadManager = new DownloadManager();
|
|
30
32
|
public filter: IFilter = new WithoutFilter();
|
|
31
33
|
public readonly hotKeysBehavior: IHotKeysBehavior = new WithoutHotKeys();
|
|
@@ -42,6 +44,7 @@ export class SlickTable implements ISlickTable {
|
|
|
42
44
|
private _printer: IPrinter = new DefaultPrinter();
|
|
43
45
|
|
|
44
46
|
constructor(args: {
|
|
47
|
+
columnPicker?: IColumnPicker;
|
|
45
48
|
downloadManager?: IDownloadManager;
|
|
46
49
|
filter?: IFilter;
|
|
47
50
|
hotKeys?: IHotKeysBehavior;
|
|
@@ -51,6 +54,7 @@ export class SlickTable implements ISlickTable {
|
|
|
51
54
|
totalCalculator?: ITotalCalculator;
|
|
52
55
|
}) {
|
|
53
56
|
const {
|
|
57
|
+
columnPicker,
|
|
54
58
|
downloadManager,
|
|
55
59
|
filter,
|
|
56
60
|
hotKeys,
|
|
@@ -61,6 +65,7 @@ export class SlickTable implements ISlickTable {
|
|
|
61
65
|
} = args;
|
|
62
66
|
this.id = id;
|
|
63
67
|
this.name = name || "";
|
|
68
|
+
if (columnPicker) this.columnPicker = columnPicker;
|
|
64
69
|
if (downloadManager) this.downloadManager = downloadManager;
|
|
65
70
|
if (filter) this.filter = filter;
|
|
66
71
|
if (hotKeys) this.hotKeysBehavior = hotKeys;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnEvent } from "shared/lib/an-event";
|
|
2
|
+
import { ISlickTable } from "shared/model/types";
|
|
3
|
+
|
|
4
|
+
class EventHeaderContextMenu extends AnEvent {
|
|
5
|
+
table?: ISlickTable | undefined;
|
|
6
|
+
x = 0;
|
|
7
|
+
y = 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const eventHeaderContextMenu = new EventHeaderContextMenu();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {
|
|
2
|
+
ColumnPicker,
|
|
2
3
|
DownloadManager,
|
|
3
4
|
DecoratorEndingDate,
|
|
4
5
|
DecoratorFilter,
|
|
@@ -15,4 +16,4 @@ export {
|
|
|
15
16
|
WithConfirmationOfDeletion,
|
|
16
17
|
WithoutHotKeys,
|
|
17
18
|
} from "./SlickTable";
|
|
18
|
-
export { eventContextMenu } from "./events";
|
|
19
|
+
export { eventContextMenu, eventHeaderContextMenu } from "./events";
|
|
@@ -13,7 +13,7 @@ class HeaderButtons {
|
|
|
13
13
|
} else {
|
|
14
14
|
for (const columnId of columnIds) {
|
|
15
15
|
const column = slickTable.querySelector(`[data-id="${columnId}"]`);
|
|
16
|
-
if (!column)
|
|
16
|
+
if (!column) continue;
|
|
17
17
|
if (
|
|
18
18
|
args.columnFilters[columnId].value[1] ||
|
|
19
19
|
args.columnFilters[columnId].value[2]
|
|
@@ -16,6 +16,7 @@ import { CHECKBOX_SELECTOR } from "shared/model/consts";
|
|
|
16
16
|
import {
|
|
17
17
|
onRowsChanged,
|
|
18
18
|
openContextMenu,
|
|
19
|
+
openHeaderContextMenu,
|
|
19
20
|
columnSorter as sorter,
|
|
20
21
|
onRowCountChanged as updateRowCount,
|
|
21
22
|
} from "../../../../lib";
|
|
@@ -81,6 +82,8 @@ export function useGrid({
|
|
|
81
82
|
onDblClick && grid.onDblClick.subscribe(onDblClick);
|
|
82
83
|
grid.onSort.subscribe(columnSorter.getSortFunction(table.id));
|
|
83
84
|
grid.onContextMenu.subscribe(openContextMenu(table));
|
|
85
|
+
table.columnPicker &&
|
|
86
|
+
grid.onHeaderContextMenu.subscribe(openHeaderContextMenu(table));
|
|
84
87
|
const onHeaderButtonCommand = handleHeaderButtons(table);
|
|
85
88
|
headerButtonsPlugin.onCommand.subscribe(onHeaderButtonCommand);
|
|
86
89
|
|
|
@@ -144,4 +147,14 @@ export function useGrid({
|
|
|
144
147
|
table.notifyObservers();
|
|
145
148
|
columnSorter.restoreSorting(table);
|
|
146
149
|
}, [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]);
|
|
147
160
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SlickGrid,
|
|
8
8
|
} from "slickgrid";
|
|
9
9
|
|
|
10
|
+
import { IColumnPicker } from "./IColumnPicker";
|
|
10
11
|
import { IDownloadManager } from "./IDownloadManager";
|
|
11
12
|
import { IFilter } from "./IFilter";
|
|
12
13
|
import { IGrouping } from "./IGrouping";
|
|
@@ -16,6 +17,7 @@ import { IPrinter } from "./IPrinter";
|
|
|
16
17
|
import { ITotalCalculator } from "./ITotalCalculator";
|
|
17
18
|
|
|
18
19
|
export interface ISlickTable {
|
|
20
|
+
columnPicker: IColumnPicker | null;
|
|
19
21
|
createGrid(
|
|
20
22
|
dataView: SlickDataView,
|
|
21
23
|
columns: Column[],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { IFilterArguments } from "./IFilterArguments";
|
|
2
2
|
export type { IColumn } from "./IColumn";
|
|
3
3
|
export type { IColumnFilterValue } from "./IColumnFilterValue";
|
|
4
|
+
export type { IColumnPicker } from "./IColumnPicker";
|
|
4
5
|
export type { IDownloadManager } from "./IDownloadManager";
|
|
5
6
|
export type { IEditedRow } from "./IEditedRow";
|
|
6
7
|
export type { IExternalVariables } from "./IExternalVariables";
|