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.
Files changed (95) hide show
  1. package/dist/index.cjs.js +102 -99
  2. package/dist/index.es.js +10532 -9578
  3. package/dist/types/entities/popup-summary/index.d.ts +2 -0
  4. package/dist/types/entities/popup-summary/index.d.ts.map +1 -0
  5. package/dist/types/entities/popup-summary/lib/getTotals.d.ts +4 -0
  6. package/dist/types/entities/popup-summary/lib/getTotals.d.ts.map +1 -0
  7. package/dist/types/entities/popup-summary/lib/index.d.ts +2 -0
  8. package/dist/types/entities/popup-summary/lib/index.d.ts.map +1 -0
  9. package/dist/types/entities/popup-summary/model/index.d.ts +2 -0
  10. package/dist/types/entities/popup-summary/model/index.d.ts.map +1 -0
  11. package/dist/types/entities/popup-summary/model/types/ITotal.d.ts +10 -0
  12. package/dist/types/entities/popup-summary/model/types/ITotal.d.ts.map +1 -0
  13. package/dist/types/entities/popup-summary/model/types/index.d.ts +2 -0
  14. package/dist/types/entities/popup-summary/model/types/index.d.ts.map +1 -0
  15. package/dist/types/entities/popup-summary/ui/PopupSummary.d.ts +3 -0
  16. package/dist/types/entities/popup-summary/ui/PopupSummary.d.ts.map +1 -0
  17. package/dist/types/entities/popup-summary/ui/PopupSummary.style.d.ts +13 -0
  18. package/dist/types/entities/popup-summary/ui/PopupSummary.style.d.ts.map +1 -0
  19. package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.d.ts +10 -0
  20. package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.d.ts.map +1 -0
  21. package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.style.d.ts +9 -0
  22. package/dist/types/entities/popup-summary/ui/TotalByColumn/TotalByColumn.style.d.ts.map +1 -0
  23. package/dist/types/entities/popup-summary/ui/TotalByColumn/index.d.ts +2 -0
  24. package/dist/types/entities/popup-summary/ui/TotalByColumn/index.d.ts.map +1 -0
  25. package/dist/types/entities/popup-summary/ui/index.d.ts +2 -0
  26. package/dist/types/entities/popup-summary/ui/index.d.ts.map +1 -0
  27. package/dist/types/entities/popup-summary/ui/styles/StyledDialogContentText.d.ts +4 -0
  28. package/dist/types/entities/popup-summary/ui/styles/StyledDialogContentText.d.ts.map +1 -0
  29. package/dist/types/entities/popup-summary/ui/styles/index.d.ts +2 -0
  30. package/dist/types/entities/popup-summary/ui/styles/index.d.ts.map +1 -0
  31. package/dist/types/features/context-menu/ui/ButtonSummary/ButtonSummary.d.ts +7 -0
  32. package/dist/types/features/context-menu/ui/ButtonSummary/ButtonSummary.d.ts.map +1 -0
  33. package/dist/types/features/context-menu/ui/ButtonSummary/index.d.ts +2 -0
  34. package/dist/types/features/context-menu/ui/ButtonSummary/index.d.ts.map +1 -0
  35. package/dist/types/features/context-menu/ui/ContextMenu.d.ts.map +1 -1
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/dist/types/shared/lib/slickgrid/index.d.ts +1 -1
  39. package/dist/types/shared/lib/slickgrid/index.d.ts.map +1 -1
  40. package/dist/types/shared/lib/slickgrid/lib/hotKeys/hotKeysOpenSummary.d.ts +3 -0
  41. package/dist/types/shared/lib/slickgrid/lib/hotKeys/hotKeysOpenSummary.d.ts.map +1 -0
  42. package/dist/types/shared/lib/slickgrid/lib/hotKeys/index.d.ts +1 -0
  43. package/dist/types/shared/lib/slickgrid/lib/hotKeys/index.d.ts.map +1 -1
  44. package/dist/types/shared/lib/slickgrid/lib/index.d.ts +1 -1
  45. package/dist/types/shared/lib/slickgrid/lib/index.d.ts.map +1 -1
  46. package/dist/types/shared/lib/slickgrid/model/SlickTable/hotKeys/DefaultHotKeys.d.ts.map +1 -1
  47. package/dist/types/shared/lib/slickgrid/model/SlickTable/table/SlickTable.d.ts +2 -0
  48. package/dist/types/shared/lib/slickgrid/model/SlickTable/table/SlickTable.d.ts.map +1 -1
  49. package/dist/types/shared/lib/slickgrid/model/events/eventSummary.d.ts +13 -0
  50. package/dist/types/shared/lib/slickgrid/model/events/eventSummary.d.ts.map +1 -0
  51. package/dist/types/shared/lib/slickgrid/model/events/index.d.ts +1 -0
  52. package/dist/types/shared/lib/slickgrid/model/events/index.d.ts.map +1 -1
  53. package/dist/types/shared/lib/slickgrid/model/index.d.ts +1 -1
  54. package/dist/types/shared/lib/slickgrid/model/index.d.ts.map +1 -1
  55. package/dist/types/shared/model/enums/EKeyCode.d.ts +1 -0
  56. package/dist/types/shared/model/enums/EKeyCode.d.ts.map +1 -1
  57. package/dist/types/shared/model/types/ISlickTable.d.ts +1 -0
  58. package/dist/types/shared/model/types/ISlickTable.d.ts.map +1 -1
  59. package/dist/types/shared/model/types/index.d.ts +1 -1
  60. package/dist/types/shared/model/types/index.d.ts.map +1 -1
  61. package/dist/types/shared/ui/ContextSelect/ContextSelect.style.d.ts +1 -1
  62. package/package.json +1 -1
  63. package/src/app/styles/icons.scss +16 -0
  64. package/src/app/styles/mixins.scss +12 -0
  65. package/src/entities/popup-summary/index.ts +1 -0
  66. package/src/entities/popup-summary/lib/getTotals.ts +46 -0
  67. package/src/entities/popup-summary/lib/index.ts +1 -0
  68. package/src/entities/popup-summary/model/index.ts +1 -0
  69. package/src/entities/popup-summary/model/types/ITotal.ts +23 -0
  70. package/src/entities/popup-summary/model/types/index.ts +1 -0
  71. package/src/entities/popup-summary/ui/PopupSummary.style.ts +21 -0
  72. package/src/entities/popup-summary/ui/PopupSummary.tsx +67 -0
  73. package/src/entities/popup-summary/ui/TotalByColumn/TotalByColumn.style.ts +19 -0
  74. package/src/entities/popup-summary/ui/TotalByColumn/TotalByColumn.tsx +46 -0
  75. package/src/entities/popup-summary/ui/TotalByColumn/index.ts +1 -0
  76. package/src/entities/popup-summary/ui/index.ts +1 -0
  77. package/src/entities/popup-summary/ui/styles/StyledDialogContentText.ts +7 -0
  78. package/src/entities/popup-summary/ui/styles/index.ts +1 -0
  79. package/src/features/context-menu/ui/ButtonSummary/ButtonSummary.tsx +34 -0
  80. package/src/features/context-menu/ui/ButtonSummary/index.ts +1 -0
  81. package/src/features/context-menu/ui/ContextMenu.tsx +2 -0
  82. package/src/index.scss +2 -1
  83. package/src/index.ts +1 -0
  84. package/src/shared/lib/slickgrid/index.ts +1 -0
  85. package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysOpenSummary.ts +7 -0
  86. package/src/shared/lib/slickgrid/lib/hotKeys/index.ts +1 -0
  87. package/src/shared/lib/slickgrid/lib/index.ts +1 -0
  88. package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/DefaultHotKeys.ts +9 -0
  89. package/src/shared/lib/slickgrid/model/SlickTable/table/SlickTable.ts +4 -0
  90. package/src/shared/lib/slickgrid/model/events/eventSummary.ts +24 -0
  91. package/src/shared/lib/slickgrid/model/events/index.ts +1 -0
  92. package/src/shared/lib/slickgrid/model/index.ts +5 -1
  93. package/src/shared/model/enums/EKeyCode.ts +1 -0
  94. package/src/shared/model/types/ISlickTable.ts +1 -0
  95. 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,7 @@
1
+ import { DialogContentText, styled } from "@mui/material";
2
+
3
+ export const StyledDialogContentText = styled(DialogContentText)({
4
+ alignItems: "center",
5
+ color: "#1E456F",
6
+ display: "flex",
7
+ });
@@ -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
@@ -1,2 +1,3 @@
1
1
  @use './app/styles/slickgrid' as *;
2
- @use './app/styles/global' as *;
2
+ @use './app/styles/global' as *;
3
+ @use './app/styles/icons' as *;
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";
@@ -63,6 +63,7 @@ export {
63
63
  WithoutHotKeys,
64
64
  eventContextMenu,
65
65
  eventHeaderContextMenu,
66
+ eventSummary,
66
67
  } from "./model";
67
68
  export {
68
69
  SlickgridTable,
@@ -0,0 +1,7 @@
1
+ import { OnKeyDownEventArgs, SlickEventData } from "slickgrid";
2
+
3
+ import { EKeyCode } from "shared/model/enums";
4
+
5
+ export function hotKeysOpenSummary(event: SlickEventData<OnKeyDownEventArgs>) {
6
+ return event.altKey && event.keyCode === EKeyCode.KeyS;
7
+ }
@@ -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";
@@ -15,6 +15,7 @@ export {
15
15
  export {
16
16
  hotKeysCopy,
17
17
  hotKeysDelete,
18
+ hotKeysOpenSummary,
18
19
  hotKeysRedo,
19
20
  hotKeysReverse,
20
21
  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();
@@ -1,2 +1,3 @@
1
1
  export { eventContextMenu } from "./eventContextMenu";
2
2
  export { eventHeaderContextMenu } from "./eventHeaderContextMenu";
3
+ export { eventSummary } from "./eventSummary";
@@ -16,4 +16,8 @@ export {
16
16
  WithConfirmationOfDeletion,
17
17
  WithoutHotKeys,
18
18
  } from "./SlickTable";
19
- export { eventContextMenu, eventHeaderContextMenu } from "./events";
19
+ export {
20
+ eventContextMenu,
21
+ eventHeaderContextMenu,
22
+ eventSummary,
23
+ } from "./events";
@@ -3,6 +3,7 @@ export enum EKeyCode {
3
3
  "KeyDel" = 46,
4
4
  "KeyEnter" = 13,
5
5
  "KeyR" = 82,
6
+ "KeyS" = 83,
6
7
  "KeyY" = 89,
7
8
  "KeyZ" = 90,
8
9
  }
@@ -39,5 +39,6 @@ export interface ISlickTable {
39
39
  notifyObservers(): void;
40
40
  registerObservers(observer: IObserver): void;
41
41
  reset(): void;
42
+ summaryColumnIds: string[];
42
43
  totalCalculator?: ITotalCalculator;
43
44
  }
@@ -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";