@codezee/sixtify-brahma 0.2.173 → 0.2.174
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/package.json +1 -1
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionButtonsWrapper.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionButtonsWrapper.js +14 -2
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionCell.js +3 -3
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridSelection.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridSelection.js +38 -7
- package/packages/shared-components/dist/AgGrid/hooks/useCellEnterClick.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/hooks/useCellEnterClick.js +30 -7
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButtonsWrapper.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/ActionCell/ActionButtonsWrapper.tsx"],"names":[],"mappings":"AAEA,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,QAAQ,CAAC,yBAAyB,CAAC,
|
|
1
|
+
{"version":3,"file":"ActionButtonsWrapper.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/ActionCell/ActionButtonsWrapper.tsx"],"names":[],"mappings":"AAEA,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,QAAQ,CAAC,yBAAyB,CAAC,2CAsNrC"}
|
|
@@ -22,6 +22,11 @@ function ActionButtonsWrapper({ children, disabled, }) {
|
|
|
22
22
|
disabled) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
+
if (document.querySelector(
|
|
26
|
+
// eslint-disable-next-line quotes
|
|
27
|
+
'.MuiDialog-root, [role="dialog"], .MuiPopover-root, .MuiModal-root')) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
25
30
|
const activeElement = document.activeElement;
|
|
26
31
|
const cell = activeElement?.closest(".ag-cell");
|
|
27
32
|
if (!cell || !container || !cell.contains(container)) {
|
|
@@ -31,11 +36,18 @@ function ActionButtonsWrapper({ children, disabled, }) {
|
|
|
31
36
|
if (isEditing) {
|
|
32
37
|
return;
|
|
33
38
|
}
|
|
39
|
+
if (!activeElement) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const isActiveElementInCell = activeElement === cell || cell.contains(activeElement);
|
|
43
|
+
if (!isActiveElementInCell) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
34
46
|
const focusedButton = container.querySelector("button:focus, [role='button']:focus, [tabindex='0']:focus");
|
|
35
47
|
if (focusedButton) {
|
|
36
|
-
focusedButton.click();
|
|
37
48
|
event.preventDefault();
|
|
38
49
|
event.stopPropagation();
|
|
50
|
+
focusedButton.click();
|
|
39
51
|
return;
|
|
40
52
|
}
|
|
41
53
|
const firstButton = container.querySelector("button, [role='button'], [tabindex='0']");
|
|
@@ -118,5 +130,5 @@ function ActionButtonsWrapper({ children, disabled, }) {
|
|
|
118
130
|
};
|
|
119
131
|
}
|
|
120
132
|
}, [disabled]);
|
|
121
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: containerRef, style: { display: "contents" }, children: children }));
|
|
133
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: containerRef, style: { display: "contents" }, "data-action-buttons-wrapper": "true", children: children }));
|
|
122
134
|
}
|
|
@@ -24,13 +24,13 @@ const ActionCell = ({ items, disabled }) => {
|
|
|
24
24
|
if (!items || items.length === 0) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: "100%" }, children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { ref: buttonRef, component: "div", sx: { width: "100%", cursor: "pointer", alignItems: "center" }, onClick: handleClick, disabled: disabled, "data-clickable": "true", children: (0, jsx_runtime_1.jsx)(MoreVert_1.default, {}) }), anchorEl && ((0, jsx_runtime_1.jsx)(Popover_1.Popover, { open: true, anchorEl: anchorEl, onClose: handleClose, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "2px" }, children: items.map((
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: "100%" }, children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { ref: buttonRef, component: "div", sx: { width: "100%", cursor: "pointer", alignItems: "center" }, onClick: handleClick, disabled: disabled, "data-clickable": "true", children: (0, jsx_runtime_1.jsx)(MoreVert_1.default, {}) }), anchorEl && ((0, jsx_runtime_1.jsx)(Popover_1.Popover, { open: true, anchorEl: anchorEl, onClose: handleClose, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "2px" }, children: items.map(({ title, onClick }) => ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.ListItemButton, { sx: {
|
|
28
28
|
width: "100%",
|
|
29
29
|
textAlign: "start",
|
|
30
30
|
padding: "5px 16px 5px 10px",
|
|
31
31
|
}, onClick: () => {
|
|
32
|
-
|
|
32
|
+
onClick();
|
|
33
33
|
handleClose();
|
|
34
|
-
}, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", children:
|
|
34
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", children: title }) }) }, title))) }) }))] }));
|
|
35
35
|
};
|
|
36
36
|
exports.ActionCell = ActionCell;
|
|
@@ -1 +1 @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eAAe,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,KAAK,OAAO,CAAC;CACpD,CAAC;AAEF,KAAK,wBAAwB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI;IACxD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IACzB,kBAAkB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,aAAa,EAAE;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;IACF,OAAO,EAAE;QACP,IAAI,EAAE,OAAO,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,IAAI,CAAC;KAC3B,GAAG,IAAI,CAAC;CACV,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,2GAQ1D,sBAAsB,CAAC,CAAC,CAAC,KAAG,wBAAwB,CAAC,CAAC,CA6RxD,CAAC"}
|
|
@@ -6,12 +6,17 @@ const useAgGridSelection = ({ gridRef, currentPageItems, totalRecords, selectedE
|
|
|
6
6
|
const [selectedIds, setSelectedIds] = (0, react_1.useState)([]);
|
|
7
7
|
const [allDataCache, setAllDataCache] = (0, react_1.useState)(null);
|
|
8
8
|
const [selectableCount, setSelectableCount] = (0, react_1.useState)(null);
|
|
9
|
+
const originalSelectableCountRef = (0, react_1.useRef)(null);
|
|
9
10
|
const lastQueryParamsRef = (0, react_1.useRef)(null);
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
if (originalSelectableCountRef.current === null && totalRecords > 0) {
|
|
13
|
+
originalSelectableCountRef.current = totalRecords;
|
|
14
|
+
}
|
|
15
|
+
}, [totalRecords]);
|
|
10
16
|
const currentPageState = (0, react_1.useMemo)(() => {
|
|
11
17
|
if (!currentPageItems.length) {
|
|
12
18
|
return { selected: 0, checked: false, indeterminate: false };
|
|
13
19
|
}
|
|
14
|
-
// Filter to only selectable items for checkbox state calculation
|
|
15
20
|
const selectableItems = isRowSelectable
|
|
16
21
|
? currentPageItems.filter((item) => isRowSelectable({ data: item }))
|
|
17
22
|
: currentPageItems;
|
|
@@ -45,7 +50,6 @@ const useAgGridSelection = ({ gridRef, currentPageItems, totalRecords, selectedE
|
|
|
45
50
|
syncGridSelection();
|
|
46
51
|
}, [syncGridSelection]);
|
|
47
52
|
const selectCurrentPage = (0, react_1.useCallback)(() => {
|
|
48
|
-
// Filter to only selectable rows if isRowSelectable is provided
|
|
49
53
|
const selectableItems = isRowSelectable
|
|
50
54
|
? currentPageItems.filter((item) => isRowSelectable({ data: item }))
|
|
51
55
|
: currentPageItems;
|
|
@@ -78,6 +82,17 @@ const useAgGridSelection = ({ gridRef, currentPageItems, totalRecords, selectedE
|
|
|
78
82
|
setAllDataCache(list);
|
|
79
83
|
if (apiSelectableCount !== undefined) {
|
|
80
84
|
setSelectableCount(apiSelectableCount);
|
|
85
|
+
if (originalSelectableCountRef.current === null) {
|
|
86
|
+
originalSelectableCountRef.current = apiSelectableCount;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const calculatedSelectableCount = isRowSelectable
|
|
91
|
+
? list.filter((item) => isRowSelectable({ data: item })).length
|
|
92
|
+
: list.length;
|
|
93
|
+
if (originalSelectableCountRef.current === null) {
|
|
94
|
+
originalSelectableCountRef.current = calculatedSelectableCount;
|
|
95
|
+
}
|
|
81
96
|
}
|
|
82
97
|
setSelectedIds(allIds);
|
|
83
98
|
if (totalRecords === 0 && totalCount) {
|
|
@@ -112,11 +127,27 @@ const useAgGridSelection = ({ gridRef, currentPageItems, totalRecords, selectedE
|
|
|
112
127
|
lastQueryParamsRef.current = params;
|
|
113
128
|
}, []);
|
|
114
129
|
const selectedRecords = selectedEmployee.length;
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
130
|
+
const getTotalRecordsCount = () => {
|
|
131
|
+
if (selectedRecords === 0) {
|
|
132
|
+
return totalRecords;
|
|
133
|
+
}
|
|
134
|
+
if (originalSelectableCountRef.current !== null) {
|
|
135
|
+
return originalSelectableCountRef.current;
|
|
136
|
+
}
|
|
137
|
+
if (selectableCount && selectableCount > totalRecords) {
|
|
138
|
+
return selectableCount;
|
|
139
|
+
}
|
|
140
|
+
if (allDataCache?.length) {
|
|
141
|
+
const calculatedSelectableCount = isRowSelectable
|
|
142
|
+
? allDataCache.filter((item) => isRowSelectable({ data: item })).length
|
|
143
|
+
: allDataCache.length;
|
|
144
|
+
if (calculatedSelectableCount > totalRecords) {
|
|
145
|
+
return calculatedSelectableCount;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return totalRecords;
|
|
149
|
+
};
|
|
150
|
+
const displayRecordsCount = getTotalRecordsCount();
|
|
120
151
|
const message = (0, react_1.useMemo)(() => {
|
|
121
152
|
if (!selectedRecords) {
|
|
122
153
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCellEnterClick.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/hooks/useCellEnterClick.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCellEnterClick.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/hooks/useCellEnterClick.ts"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,EAAE,qBAAqB,QA6GvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCellEnterClick = useCellEnterClick;
|
|
4
|
+
/* eslint-disable quotes */
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
function useCellEnterClick({ buttonRef, disabled, popoverOpen, onPressEnter, }) {
|
|
6
7
|
(0, react_1.useEffect)(() => {
|
|
@@ -8,10 +9,9 @@ function useCellEnterClick({ buttonRef, disabled, popoverOpen, onPressEnter, })
|
|
|
8
9
|
if (!button) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
12
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
11
13
|
const handleKeyDown = (event) => {
|
|
12
|
-
if (document.querySelector(
|
|
13
|
-
// eslint-disable-next-line quotes
|
|
14
|
-
'.MuiDialog-root, [role="dialog"], .MuiPopover-root, .MuiModal-root')) {
|
|
14
|
+
if (document.querySelector('.MuiDialog-root, [role="dialog"], .MuiPopover-root, .MuiModal-root')) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const keyIsClickTrigger = event.key === "Enter" || event.key === " ";
|
|
@@ -24,15 +24,38 @@ function useCellEnterClick({ buttonRef, disabled, popoverOpen, onPressEnter, })
|
|
|
24
24
|
popoverOpen) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (!focusedCell?.contains(button)) {
|
|
27
|
+
const actionButtonsWrapper = button.closest('[data-action-buttons-wrapper="true"]');
|
|
28
|
+
if (actionButtonsWrapper) {
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
|
-
const
|
|
31
|
+
const cellContainingButton = button.closest(".ag-cell");
|
|
32
|
+
if (!cellContainingButton) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const isEditing = cellContainingButton.classList.contains("ag-cell-inline-editing");
|
|
33
36
|
if (isEditing) {
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
39
|
+
const activeElement = document.activeElement;
|
|
40
|
+
if (!activeElement) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const isActiveElementInCell = activeElement === cellContainingButton ||
|
|
44
|
+
cellContainingButton.contains(activeElement);
|
|
45
|
+
if (!isActiveElementInCell) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const eventTarget = event.target;
|
|
49
|
+
const isEventTargetInGrid = eventTarget &&
|
|
50
|
+
(eventTarget === cellContainingButton ||
|
|
51
|
+
cellContainingButton.contains(eventTarget) ||
|
|
52
|
+
eventTarget.closest(".ag-cell") === cellContainingButton);
|
|
53
|
+
if (eventTarget && !isEventTargetInGrid) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!cellContainingButton.contains(button)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
36
59
|
event.preventDefault();
|
|
37
60
|
event.stopPropagation();
|
|
38
61
|
if (onPressEnter) {
|