slick-table 1.1.15 → 1.1.17
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 +102 -99
- package/dist/index.es.js +10532 -9578
- package/dist/types/entities/popup-summary/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/lib/getTotals.d.ts +4 -0
- package/dist/types/entities/popup-summary/lib/getTotals.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/lib/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/lib/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/model/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/model/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/model/types/ITotal.d.ts +10 -0
- package/dist/types/entities/popup-summary/model/types/ITotal.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/model/types/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/model/types/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/PopupSummary.d.ts +3 -0
- package/dist/types/entities/popup-summary/ui/PopupSummary.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/PopupSummary.style.d.ts +13 -0
- package/dist/types/entities/popup-summary/ui/PopupSummary.style.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.d.ts +10 -0
- package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.style.d.ts +9 -0
- package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.style.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/TotalByColumn/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/ui/TotalByColumn/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/ui/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/styles/StyledDialogContentText.d.ts +4 -0
- package/dist/types/entities/popup-summary/ui/styles/StyledDialogContentText.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/styles/index.d.ts +2 -0
- package/dist/types/entities/popup-summary/ui/styles/index.d.ts.map +1 -0
- package/dist/types/features/context-menu/ui/ButtonSummary/ButtonSummary.d.ts +7 -0
- package/dist/types/features/context-menu/ui/ButtonSummary/ButtonSummary.d.ts.map +1 -0
- package/dist/types/features/context-menu/ui/ButtonSummary/index.d.ts +2 -0
- package/dist/types/features/context-menu/ui/ButtonSummary/index.d.ts.map +1 -0
- package/dist/types/features/context-menu/ui/ContextMenu.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- 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/hotKeys/hotKeysOpenSummary.d.ts +3 -0
- package/dist/types/shared/lib/slickgrid/lib/hotKeys/hotKeysOpenSummary.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/lib/hotKeys/index.d.ts +1 -0
- package/dist/types/shared/lib/slickgrid/lib/hotKeys/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/lib/index.d.ts +1 -1
- package/dist/types/shared/lib/slickgrid/lib/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/SlickTable/hotKeys/DefaultHotKeys.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/SlickTable/table/SlickTable.d.ts +2 -0
- package/dist/types/shared/lib/slickgrid/model/SlickTable/table/SlickTable.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/events/eventSummary.d.ts +13 -0
- package/dist/types/shared/lib/slickgrid/model/events/eventSummary.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 +1 -1
- package/dist/types/shared/lib/slickgrid/model/index.d.ts.map +1 -1
- package/dist/types/shared/model/enums/EKeyCode.d.ts +1 -0
- package/dist/types/shared/model/enums/EKeyCode.d.ts.map +1 -1
- package/dist/types/shared/model/types/ISlickTable.d.ts +1 -0
- package/dist/types/shared/model/types/ISlickTable.d.ts.map +1 -1
- package/dist/types/shared/model/types/index.d.ts +1 -1
- package/dist/types/shared/model/types/index.d.ts.map +1 -1
- package/dist/types/shared/ui/ContextSelect/ContextSelect.style.d.ts +1 -1
- package/package.json +1 -1
- package/src/app/styles/icons.scss +16 -0
- package/src/app/styles/mixins.scss +12 -0
- package/src/entities/popup-summary/index.ts +1 -0
- package/src/entities/popup-summary/lib/getTotals.ts +46 -0
- package/src/entities/popup-summary/lib/index.ts +1 -0
- package/src/entities/popup-summary/model/index.ts +1 -0
- package/src/entities/popup-summary/model/types/ITotal.ts +23 -0
- package/src/entities/popup-summary/model/types/index.ts +1 -0
- package/src/entities/popup-summary/ui/PopupSummary.style.ts +21 -0
- package/src/entities/popup-summary/ui/PopupSummary.tsx +67 -0
- package/src/entities/popup-summary/ui/TotalByColumn/TotalByColumn.style.ts +19 -0
- package/src/entities/popup-summary/ui/TotalByColumn/TotalByColumn.tsx +46 -0
- package/src/entities/popup-summary/ui/TotalByColumn/index.ts +1 -0
- package/src/entities/popup-summary/ui/index.ts +1 -0
- package/src/entities/popup-summary/ui/styles/StyledDialogContentText.ts +7 -0
- package/src/entities/popup-summary/ui/styles/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonSummary/ButtonSummary.tsx +34 -0
- package/src/features/context-menu/ui/ButtonSummary/index.ts +1 -0
- package/src/features/context-menu/ui/ContextMenu.tsx +2 -0
- package/src/index.scss +2 -1
- package/src/index.ts +1 -0
- package/src/shared/lib/slickgrid/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysOpenSummary.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/DefaultHotKeys.ts +9 -0
- package/src/shared/lib/slickgrid/model/SlickTable/table/SlickTable.ts +4 -0
- package/src/shared/lib/slickgrid/model/events/eventSummary.ts +24 -0
- package/src/shared/lib/slickgrid/model/events/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/index.ts +5 -1
- package/src/shared/model/enums/EKeyCode.ts +1 -0
- package/src/shared/model/types/ISlickTable.ts +1 -0
- package/src/shared/model/types/index.ts +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Box, Dialog, DialogActions, DialogContent } from "@mui/material";
|
|
2
|
+
import { FC, useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { eventSummary } from "shared/lib/slickgrid";
|
|
5
|
+
|
|
6
|
+
import { getTotals } from "../lib";
|
|
7
|
+
import { ITotal } from "../model";
|
|
8
|
+
import { TotalByColumn } from "./TotalByColumn";
|
|
9
|
+
import { StyledDialogContentText } from "./styles";
|
|
10
|
+
|
|
11
|
+
import Styled from "./PopupSummary.style";
|
|
12
|
+
|
|
13
|
+
export const PopupSummary: FC = () => {
|
|
14
|
+
const [rowsNumber, setRowsNumber] = useState(0);
|
|
15
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
16
|
+
const [totals, setTotals] = useState<ITotal>({});
|
|
17
|
+
|
|
18
|
+
function onClose() {
|
|
19
|
+
eventSummary.open = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
function callback() {
|
|
24
|
+
const open = eventSummary.open;
|
|
25
|
+
if (open) {
|
|
26
|
+
const table = eventSummary.table;
|
|
27
|
+
const grid = table?.grid;
|
|
28
|
+
setRowsNumber(grid?.getSelectedRows().length || 0);
|
|
29
|
+
setTotals(getTotals(table));
|
|
30
|
+
}
|
|
31
|
+
setIsOpened(open);
|
|
32
|
+
}
|
|
33
|
+
eventSummary.subscribe(callback);
|
|
34
|
+
return () => {
|
|
35
|
+
eventSummary.unsubscribe(callback);
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
if (!isOpened) return null;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Dialog open={isOpened} onClose={onClose}>
|
|
43
|
+
<Styled.DialogTitle>Selected rows summary</Styled.DialogTitle>
|
|
44
|
+
<DialogContent>
|
|
45
|
+
<Styled.List>
|
|
46
|
+
<StyledDialogContentText>{`number of selected rows: ${rowsNumber}`}</StyledDialogContentText>
|
|
47
|
+
{Object.entries(totals).map(
|
|
48
|
+
([id, { label, total, totalFormatted }]) => (
|
|
49
|
+
<Box key={id}>
|
|
50
|
+
<TotalByColumn
|
|
51
|
+
label={label}
|
|
52
|
+
total={total}
|
|
53
|
+
totalFormatted={totalFormatted}
|
|
54
|
+
/>
|
|
55
|
+
</Box>
|
|
56
|
+
),
|
|
57
|
+
)}
|
|
58
|
+
</Styled.List>
|
|
59
|
+
</DialogContent>
|
|
60
|
+
<DialogActions>
|
|
61
|
+
<Styled.Button variant={"outlined"} onClick={onClose}>
|
|
62
|
+
Close
|
|
63
|
+
</Styled.Button>
|
|
64
|
+
</DialogActions>
|
|
65
|
+
</Dialog>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DialogContentText, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
const Text = styled("span")({
|
|
4
|
+
marginRight: "0.5em",
|
|
5
|
+
});
|
|
6
|
+
const StyledDialogContentText = styled(DialogContentText)({
|
|
7
|
+
display: "flex",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const Icon = styled("span")({
|
|
12
|
+
cursor: "pointer",
|
|
13
|
+
backgroundColor: "#1E456F",
|
|
14
|
+
"&:hover": {
|
|
15
|
+
scale: "1.3",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default { DialogContentText: StyledDialogContentText, Icon, Text };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Tooltip } from "@mui/material";
|
|
2
|
+
import { FC, useState } from "react";
|
|
3
|
+
import { FormatterResultWithHtml, FormatterResultWithText } from "slickgrid";
|
|
4
|
+
|
|
5
|
+
import { StyledDialogContentText } from "../styles";
|
|
6
|
+
|
|
7
|
+
import Styled from "./TotalByColumn.style";
|
|
8
|
+
|
|
9
|
+
export const TotalByColumn: FC<IProps> = ({ label, total, totalFormatted }) => {
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
|
|
12
|
+
function copyToClipboard() {
|
|
13
|
+
navigator.clipboard.writeText(`${total}`);
|
|
14
|
+
setOpen(true);
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
setOpen(false);
|
|
17
|
+
}, 1000);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<StyledDialogContentText>
|
|
22
|
+
<Styled.Text>{`total ${label}: ${totalFormatted}`}</Styled.Text>
|
|
23
|
+
{open ? (
|
|
24
|
+
<Styled.Icon className={"sgi sgi-check"}></Styled.Icon>
|
|
25
|
+
) : (
|
|
26
|
+
<Tooltip title={"Copy to clipboard"}>
|
|
27
|
+
<Styled.Icon
|
|
28
|
+
className={"sgi sgi-content-copy"}
|
|
29
|
+
onClick={copyToClipboard}
|
|
30
|
+
/>
|
|
31
|
+
</Tooltip>
|
|
32
|
+
)}
|
|
33
|
+
</StyledDialogContentText>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
interface IProps {
|
|
38
|
+
label: string;
|
|
39
|
+
total: number;
|
|
40
|
+
totalFormatted:
|
|
41
|
+
| string
|
|
42
|
+
| HTMLElement
|
|
43
|
+
| DocumentFragment
|
|
44
|
+
| FormatterResultWithHtml
|
|
45
|
+
| FormatterResultWithText;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TotalByColumn } from "./TotalByColumn";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopupSummary } from "./PopupSummary";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StyledDialogContentText } from "./StyledDialogContentText";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Dispatch, FC, SetStateAction } from "react";
|
|
2
|
+
|
|
3
|
+
import { eventContextMenu, eventSummary } from "shared/lib/slickgrid";
|
|
4
|
+
|
|
5
|
+
import Styled from "../ContextMenu.style";
|
|
6
|
+
|
|
7
|
+
export const ButtonSummary: FC<IProps> = ({ setIsOpened }) => {
|
|
8
|
+
const table = eventContextMenu.table;
|
|
9
|
+
const grid = table?.grid;
|
|
10
|
+
const selectedRows = grid?.getSelectedRows();
|
|
11
|
+
|
|
12
|
+
function openSummary() {
|
|
13
|
+
if (!table) return;
|
|
14
|
+
setIsOpened(false);
|
|
15
|
+
eventSummary.table = table;
|
|
16
|
+
eventSummary.open = true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!table?.summaryColumnIds.length || Number(selectedRows?.length) < 2)
|
|
20
|
+
return null;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Styled.Li onClick={openSummary}>
|
|
24
|
+
<Styled.Icon
|
|
25
|
+
className={"sgi sgi-checkbox-multiple-outline"}
|
|
26
|
+
></Styled.Icon>
|
|
27
|
+
Summary
|
|
28
|
+
</Styled.Li>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
interface IProps {
|
|
33
|
+
setIsOpened: Dispatch<SetStateAction<boolean>>;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ButtonSummary } from "./ButtonSummary";
|
|
@@ -7,6 +7,7 @@ import { CONTEXT_MENU } from "../model";
|
|
|
7
7
|
import { ButtonDownloadCSV } from "./ButtonDownloadCSV";
|
|
8
8
|
import { ButtonGroup } from "./ButtonGroup";
|
|
9
9
|
import { ButtonResetFilters } from "./ButtonResetFilters";
|
|
10
|
+
import { ButtonSummary } from "./ButtonSummary";
|
|
10
11
|
import { ButtonUngroup } from "./ButtonUngroup";
|
|
11
12
|
import { CollapseAll } from "./CollapseAll";
|
|
12
13
|
import { CopyToClipboard } from "./CopyToClipboard";
|
|
@@ -43,6 +44,7 @@ export const ContextMenu: FC<Props> = ({ clientId, clientName }) => {
|
|
|
43
44
|
<ButtonGroup setIsOpened={setIsOpened} />
|
|
44
45
|
<ExpandAll setIsOpened={setIsOpened} />
|
|
45
46
|
<CollapseAll setIsOpened={setIsOpened} />
|
|
47
|
+
<ButtonSummary setIsOpened={setIsOpened} />
|
|
46
48
|
</Styled.Ul>
|
|
47
49
|
</Popup>
|
|
48
50
|
</Fragment>
|
package/src/index.scss
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Skeleton } from "entities/skeleton";
|
|
2
|
+
export { PopupSummary } from "entities/popup-summary";
|
|
2
3
|
export { ColumnFilters } from "features/column-filters";
|
|
3
4
|
export { ContextMenu } from "features/context-menu";
|
|
4
5
|
export { HeaderContextMenu } from "features/header-context-menu";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { hotKeysCopy } from "./hotKeysCopy";
|
|
2
2
|
export { hotKeysDelete } from "./hotKeysDelete";
|
|
3
|
+
export { hotKeysOpenSummary } from "./hotKeysOpenSummary";
|
|
3
4
|
export { hotKeysRedo } from "./hotKeysRedo";
|
|
4
5
|
export { hotKeysReverse } from "./hotKeysReverse";
|
|
5
6
|
export { hotKeysUndo } from "./hotKeysUndo";
|
|
@@ -17,10 +17,12 @@ import {
|
|
|
17
17
|
copySelectedRows,
|
|
18
18
|
hotKeysCopy,
|
|
19
19
|
hotKeysDelete,
|
|
20
|
+
hotKeysOpenSummary,
|
|
20
21
|
hotKeysRedo,
|
|
21
22
|
hotKeysUndo,
|
|
22
23
|
nothingToCopy,
|
|
23
24
|
} from "../../../lib";
|
|
25
|
+
import { eventSummary } from "../../../model";
|
|
24
26
|
|
|
25
27
|
export class DefaultHotKeys implements IHotKeysBehavior {
|
|
26
28
|
private externalVariables: IExternalVariables = {};
|
|
@@ -87,6 +89,13 @@ export class DefaultHotKeys implements IHotKeysBehavior {
|
|
|
87
89
|
dataView.setItems(copy(this.commandQueue[newQueueIndex]));
|
|
88
90
|
grid.invalidate();
|
|
89
91
|
table.isEdited = true;
|
|
92
|
+
} else if (hotKeysOpenSummary(event)) {
|
|
93
|
+
if (!table.summaryColumnIds.length) return;
|
|
94
|
+
if (grid.getSelectedRows().length < 2) return;
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
event.stopImmediatePropagation();
|
|
97
|
+
eventSummary.table = table;
|
|
98
|
+
eventSummary.open = true;
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
public pushToCommandQueue(grid: SlickGrid | null): void {
|
|
@@ -34,6 +34,7 @@ export class SlickTable implements ISlickTable {
|
|
|
34
34
|
public readonly id: string;
|
|
35
35
|
public readonly name: string;
|
|
36
36
|
public totalCalculator?: ITotalCalculator;
|
|
37
|
+
public readonly summaryColumnIds: string[] = [];
|
|
37
38
|
|
|
38
39
|
private _grid: SlickGrid | null = null;
|
|
39
40
|
private _grouping: IGrouping = {};
|
|
@@ -51,6 +52,7 @@ export class SlickTable implements ISlickTable {
|
|
|
51
52
|
id: string;
|
|
52
53
|
name?: string;
|
|
53
54
|
printer?: IPrinter;
|
|
55
|
+
summaryColumnIds?: string[];
|
|
54
56
|
totalCalculator?: ITotalCalculator;
|
|
55
57
|
}) {
|
|
56
58
|
const {
|
|
@@ -61,6 +63,7 @@ export class SlickTable implements ISlickTable {
|
|
|
61
63
|
id,
|
|
62
64
|
name,
|
|
63
65
|
printer,
|
|
66
|
+
summaryColumnIds,
|
|
64
67
|
totalCalculator,
|
|
65
68
|
} = args;
|
|
66
69
|
this.id = id;
|
|
@@ -70,6 +73,7 @@ export class SlickTable implements ISlickTable {
|
|
|
70
73
|
if (filter) this.filter = filter;
|
|
71
74
|
if (hotKeys) this.hotKeysBehavior = hotKeys;
|
|
72
75
|
if (printer) this.printer = printer;
|
|
76
|
+
if (summaryColumnIds) this.summaryColumnIds = summaryColumnIds;
|
|
73
77
|
if (totalCalculator) this.totalCalculator = totalCalculator;
|
|
74
78
|
}
|
|
75
79
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnEvent } from "shared/lib/an-event";
|
|
2
|
+
import { ISlickTable } from "shared/model/types";
|
|
3
|
+
|
|
4
|
+
class EventSummary extends AnEvent {
|
|
5
|
+
private _open = false;
|
|
6
|
+
private _table: ISlickTable | undefined;
|
|
7
|
+
|
|
8
|
+
get open() {
|
|
9
|
+
return this._open;
|
|
10
|
+
}
|
|
11
|
+
set open(open) {
|
|
12
|
+
this._open = open;
|
|
13
|
+
this.notify();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get table() {
|
|
17
|
+
return this._table;
|
|
18
|
+
}
|
|
19
|
+
set table(table) {
|
|
20
|
+
this._table = table;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const eventSummary = new EventSummary();
|
|
@@ -11,6 +11,6 @@ export type { IHotKeysBehavior } from "./IHotKeysBehavior";
|
|
|
11
11
|
export type { IObserver } from "./IObserver";
|
|
12
12
|
export type { IPrinter } from "./IPrinter";
|
|
13
13
|
export type { ISlickTable } from "./ISlickTable";
|
|
14
|
-
export type { TGridRow } from "./TGridRow";
|
|
15
14
|
export type { ISlickRow } from "./ISlickRow";
|
|
16
15
|
export type { ITotalCalculator } from "./ITotalCalculator";
|
|
16
|
+
export type { TGridRow } from "./TGridRow";
|