@codezee/sixtify-brahma 0.2.70 → 0.2.72
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/CellSelectionTable/CellSelectionTable.d.ts +2 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.js +120 -48
- package/packages/shared-components/dist/CellSelectionTable/SubComponents/EmployeeCell.d.ts +1 -1
- package/packages/shared-components/dist/CellSelectionTable/SubComponents/EmployeeCell.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/hook/useStickyColumns.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/hook/useStickyColumns.js +10 -18
- package/packages/shared-components/dist/CellSelectionTable/utils/helper.d.ts +5 -5
- package/packages/shared-components/dist/CellSelectionTable/utils/helper.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/helper.js +125 -61
- package/packages/shared-components/dist/CellSelectionTable/utils/index.d.ts +0 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/index.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/index.js +0 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/types.d.ts +38 -6
- package/packages/shared-components/dist/CellSelectionTable/utils/types.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/index.d.ts +1 -0
- package/packages/shared-components/dist/FilterList/index.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/index.js +1 -0
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts +3 -2
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.js +15 -20
- package/packages/shared-components/dist/FormFields/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DateRangePicker/DateRangePicker.js +2 -2
package/package.json
CHANGED
|
@@ -3,9 +3,10 @@ import { type MouseEvent, type ReactNode } from "react";
|
|
|
3
3
|
import type { CellCoord, Column } from "./utils/types";
|
|
4
4
|
export type Cell = {
|
|
5
5
|
cellLabel: string;
|
|
6
|
+
} & {
|
|
6
7
|
[key: string]: ReactNode;
|
|
7
8
|
};
|
|
8
|
-
export type TableDataRow = Record<string, string | Cell>;
|
|
9
|
+
export type TableDataRow = Record<string, string | Cell | boolean>;
|
|
9
10
|
export type CellSelectionTableProps = {
|
|
10
11
|
columns: Column[];
|
|
11
12
|
data: TableDataRow[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellSelectionTable.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/CellSelectionTable.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"CellSelectionTable.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/CellSelectionTable.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EACV,SAAS,EACT,MAAM,EAGP,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,IAAI,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,eAAe,EAAE,CACf,aAAa,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC,EACtC,CAAC,EAAE,UAAU,KACV,IAAI,CAAC;IACV,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,oFAQhC,QAAQ,CAAC,uBAAuB,CAAC,4CA+WnC,CAAC"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
4
|
exports.CellSelectionTable = void 0;
|
|
8
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
6
|
const material_1 = require("@mui/material");
|
|
10
|
-
const useStickyColumns_1 = require("./hook/useStickyColumns");
|
|
11
|
-
const groupBy_1 = __importDefault(require("lodash/groupBy"));
|
|
12
|
-
const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
|
|
13
7
|
const react_1 = require("react");
|
|
14
|
-
const
|
|
8
|
+
const useStickyColumns_1 = require("./hook/useStickyColumns");
|
|
15
9
|
const EmployeeCell_1 = require("./SubComponents/EmployeeCell");
|
|
16
10
|
const TableBodyLoader_1 = require("./SubComponents/TableBodyLoader");
|
|
17
11
|
const helper_1 = require("./utils/helper");
|
|
@@ -19,19 +13,41 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
19
13
|
const theme = (0, material_1.useTheme)();
|
|
20
14
|
const { slate, iron, butterflyBlue } = theme.palette.app.color;
|
|
21
15
|
const selectingRef = (0, react_1.useRef)(false);
|
|
16
|
+
const selectionModeRef = (0, react_1.useRef)("add");
|
|
22
17
|
const anchorRef = (0, react_1.useRef)(null);
|
|
23
18
|
const hoveringRef = (0, react_1.useRef)(null);
|
|
24
19
|
const [selectedRanges, setSelectedRanges] = (0, react_1.useState)([]);
|
|
20
|
+
const [currentSelectedRanges, setCurrentSelectedRanges] = (0, react_1.useState)([]);
|
|
25
21
|
const { stickyMap } = (0, useStickyColumns_1.useStickyColumns)(columns);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const isSelectedCell = (rowIndex, colIndex) => {
|
|
23
|
+
if (selectedRanges.length === 0 && currentSelectedRanges.length === 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return [...selectedRanges, ...currentSelectedRanges].some((range) => range.some((cell) => cell.row === rowIndex && cell.col === colIndex));
|
|
27
|
+
};
|
|
28
|
+
const memoizedData = (0, react_1.useMemo)(() => {
|
|
29
|
+
return data.map((row) => {
|
|
30
|
+
const normalizedRow = {};
|
|
31
|
+
for (const key in row) {
|
|
32
|
+
const value = row[key];
|
|
33
|
+
if (typeof value === "string") {
|
|
34
|
+
if (value.toLowerCase() === "true") {
|
|
35
|
+
normalizedRow[key] = true;
|
|
36
|
+
}
|
|
37
|
+
else if (value.toLowerCase() === "false") {
|
|
38
|
+
normalizedRow[key] = false;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
normalizedRow[key] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (typeof value === "boolean" || typeof value === "object") {
|
|
45
|
+
normalizedRow[key] = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return normalizedRow;
|
|
30
49
|
});
|
|
31
|
-
|
|
32
|
-
}, [selectedRanges]);
|
|
33
|
-
const isSelectedCell = (0, react_1.useCallback)((rowIndex, colIndex) => selectedSet.has(`${rowIndex}-${colIndex}`), [selectedSet]);
|
|
34
|
-
const memoizedData = (0, react_1.useMemo)(() => data, [data]);
|
|
50
|
+
}, [data]);
|
|
35
51
|
function getCellColor({ cellKey, isSelected = false, }) {
|
|
36
52
|
if (isSelected) {
|
|
37
53
|
return butterflyBlue[800];
|
|
@@ -41,44 +57,92 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
41
57
|
}
|
|
42
58
|
return iron[600];
|
|
43
59
|
}
|
|
44
|
-
const groupedRanges = (0, react_1.useMemo)(() => {
|
|
45
|
-
const unique = (0, uniqBy_1.default)(selectedRanges, (cell) => `${cell.row}-${cell.col}`);
|
|
46
|
-
return (0, groupBy_1.default)(unique, "row");
|
|
47
|
-
}, [selectedRanges]);
|
|
48
60
|
const handleCellMouseDown = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
61
|
+
if (columns[ci]?.disableSelection) {
|
|
62
|
+
const nextSelectableIndex = columns.findIndex((col, index) => !col.disableSelection && index > ci);
|
|
63
|
+
if (nextSelectableIndex !== -1) {
|
|
64
|
+
return (0, helper_1.handleMouseDown)({
|
|
65
|
+
e,
|
|
66
|
+
ri,
|
|
67
|
+
ci: nextSelectableIndex,
|
|
68
|
+
selectingRef,
|
|
69
|
+
anchorRef,
|
|
70
|
+
selectedRanges,
|
|
71
|
+
setSelectedRanges,
|
|
72
|
+
selectionModeRef,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const fallbackIndex = [...columns]
|
|
76
|
+
.reverse()
|
|
77
|
+
.findIndex((col, index) => !col.disableSelection && columns.length - 1 - index < ci);
|
|
78
|
+
if (fallbackIndex !== -1) {
|
|
79
|
+
const adjustedIndex = columns.length - 1 - fallbackIndex;
|
|
80
|
+
return (0, helper_1.handleMouseDown)({
|
|
81
|
+
e,
|
|
82
|
+
ri,
|
|
83
|
+
ci: adjustedIndex,
|
|
84
|
+
selectingRef,
|
|
85
|
+
anchorRef,
|
|
86
|
+
selectedRanges,
|
|
87
|
+
setSelectedRanges,
|
|
88
|
+
selectionModeRef,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
49
93
|
(0, helper_1.handleMouseDown)({
|
|
50
94
|
e,
|
|
51
95
|
ri,
|
|
52
96
|
ci,
|
|
53
97
|
selectingRef,
|
|
54
98
|
anchorRef,
|
|
99
|
+
selectedRanges,
|
|
55
100
|
setSelectedRanges,
|
|
101
|
+
selectionModeRef,
|
|
56
102
|
});
|
|
57
|
-
}, []);
|
|
58
|
-
const handleCellMouseEnter = (0, react_1.useCallback)((ri, ci) => () => {
|
|
103
|
+
}, [selectedRanges]);
|
|
104
|
+
const handleCellMouseEnter = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
59
105
|
(0, helper_1.handleMouseEnter)({
|
|
106
|
+
e,
|
|
60
107
|
selectingRef,
|
|
61
108
|
anchorRef,
|
|
62
109
|
hoveringRef,
|
|
63
110
|
ri,
|
|
64
111
|
ci,
|
|
112
|
+
selectedRanges,
|
|
65
113
|
setSelectedRanges,
|
|
114
|
+
selectionModeRef,
|
|
115
|
+
currentSelectedRanges,
|
|
116
|
+
setCurrentSelectedRanges,
|
|
117
|
+
columns,
|
|
118
|
+
data: memoizedData,
|
|
66
119
|
});
|
|
67
|
-
}, [
|
|
68
|
-
|
|
120
|
+
}, [
|
|
121
|
+
helper_1.handleMouseEnter,
|
|
122
|
+
selectingRef,
|
|
123
|
+
anchorRef,
|
|
124
|
+
hoveringRef,
|
|
125
|
+
setSelectedRanges,
|
|
126
|
+
selectionModeRef,
|
|
127
|
+
memoizedData,
|
|
128
|
+
columns,
|
|
129
|
+
]);
|
|
130
|
+
const handleCellMouseUp = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
69
131
|
(0, helper_1.handleMouseUp)({
|
|
70
132
|
e,
|
|
71
133
|
selectingRef,
|
|
72
134
|
anchorRef,
|
|
73
135
|
hoveringRef,
|
|
136
|
+
ri,
|
|
137
|
+
ci,
|
|
74
138
|
setSelectedRanges,
|
|
139
|
+
selectionModeRef,
|
|
140
|
+
setCurrentSelectedRanges,
|
|
141
|
+
data: memoizedData,
|
|
142
|
+
columns,
|
|
75
143
|
});
|
|
76
|
-
}, []);
|
|
144
|
+
}, [memoizedData, columns]);
|
|
77
145
|
const handleContextMenuCallback = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
78
|
-
if (Object.keys(groupedRanges).length && !e) {
|
|
79
|
-
setSelectedRanges([]);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
146
|
(0, helper_1.handleContextMenu)({
|
|
83
147
|
e,
|
|
84
148
|
ri,
|
|
@@ -87,7 +151,7 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
87
151
|
setSelectedRanges,
|
|
88
152
|
onCellSelection,
|
|
89
153
|
});
|
|
90
|
-
}, [
|
|
154
|
+
}, [onCellSelection, selectedRanges]);
|
|
91
155
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { position: "relative", overflow: "auto", height: height, bgcolor: iron[600], children: (0, jsx_runtime_1.jsxs)(material_1.Table, { stickyHeader: true, sx: {
|
|
92
156
|
borderCollapse: "separate",
|
|
93
157
|
borderSpacing: 0,
|
|
@@ -97,20 +161,25 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
97
161
|
padding: "5px",
|
|
98
162
|
height: "50px",
|
|
99
163
|
},
|
|
100
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.TableHead, { children: (0, jsx_runtime_1.jsx)(material_1.TableRow, { children: columns.map(({ key, label, minWidth = "auto", lockPinned = false, align = "left", }, ci) =>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
164
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.TableHead, { children: (0, jsx_runtime_1.jsx)(material_1.TableRow, { children: columns.map(({ key, label, minWidth = "auto", lockPinned = false, align = "left", }, ci) => {
|
|
165
|
+
const isSticky = stickyMap.has(ci);
|
|
166
|
+
const left = isSticky ? stickyMap.get(ci) : 0;
|
|
167
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TableCell, { align: align, sx: {
|
|
168
|
+
...(lockPinned && {
|
|
169
|
+
top: 0,
|
|
170
|
+
left,
|
|
171
|
+
zIndex: 10,
|
|
172
|
+
position: "sticky",
|
|
173
|
+
}),
|
|
174
|
+
backgroundColor: slate[700],
|
|
175
|
+
minWidth,
|
|
176
|
+
padding: "5px 10px",
|
|
177
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", children: label }) }, key));
|
|
178
|
+
}) }) }), loading ? ((0, jsx_runtime_1.jsx)(TableBodyLoader_1.TableBodyLoader, { columns: columns, rowCount: 25 })) : ((0, jsx_runtime_1.jsx)(material_1.TableBody, { children: memoizedData.map((row, ri) => ((0, jsx_runtime_1.jsx)(material_1.TableRow, { sx: { backgroundColor: iron[600] }, children: columns.map(({ key, maxWidth = "auto", minWidth = "auto", isEmployee, align = "center", lockPinned = false, }, ci) => {
|
|
111
179
|
const cell = row[key];
|
|
112
180
|
const getRowTitle = (0, helper_1.getCellValue)(cell, "cellLabel");
|
|
113
|
-
const tooltip = typeof cell
|
|
181
|
+
const tooltip = typeof cell === "object" &&
|
|
182
|
+
cell != null &&
|
|
114
183
|
typeof cell?.["cellTooltip"] === "object"
|
|
115
184
|
? cell["cellTooltip"]
|
|
116
185
|
: (0, helper_1.getCellValue)(cell, "cellTooltip");
|
|
@@ -118,6 +187,8 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
118
187
|
const cellActive = (0, helper_1.getCellValue)(cell, "cellActive");
|
|
119
188
|
const isSticky = stickyMap.has(ci);
|
|
120
189
|
const left = isSticky ? stickyMap.get(ci) : 0;
|
|
190
|
+
const content = isEmployee ? ((0, jsx_runtime_1.jsx)(EmployeeCell_1.EmployeeCell, { row: row })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: getRowTitle }));
|
|
191
|
+
const isNotDisabled = !(columns[ci]?.disableSelection || row?.rowDisabled);
|
|
121
192
|
return ((0, jsx_runtime_1.jsx)(material_1.TableCell, { align: align, sx: {
|
|
122
193
|
...(lockPinned && {
|
|
123
194
|
top: 0,
|
|
@@ -125,6 +196,11 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
125
196
|
zIndex: 5,
|
|
126
197
|
position: "sticky",
|
|
127
198
|
}),
|
|
199
|
+
...(isNotDisabled
|
|
200
|
+
? {}
|
|
201
|
+
: {
|
|
202
|
+
cursor: "not-allowed",
|
|
203
|
+
}),
|
|
128
204
|
userSelect: "none",
|
|
129
205
|
overflow: "hidden",
|
|
130
206
|
bgcolor: (0, material_1.lighten)(getCellColor({
|
|
@@ -137,15 +213,11 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
137
213
|
cursor: "pointer",
|
|
138
214
|
maxWidth,
|
|
139
215
|
minWidth,
|
|
140
|
-
}, onMouseDown:
|
|
141
|
-
? handleCellMouseDown(ri, ci)
|
|
142
|
-
: undefined, onMouseEnter: !columns[ci]?.disableSelection
|
|
216
|
+
}, onMouseDown: (e) => handleCellMouseDown(ri, ci)(e), onMouseEnter: isNotDisabled
|
|
143
217
|
? handleCellMouseEnter(ri, ci)
|
|
144
|
-
: undefined, onMouseUp:
|
|
145
|
-
? handleCellMouseUp
|
|
146
|
-
: undefined, onContextMenu: !columns[ci]?.disableSelection
|
|
218
|
+
: undefined, onMouseUp: (e) => handleCellMouseUp(ri, ci)(e), onContextMenu: isNotDisabled
|
|
147
219
|
? handleContextMenuCallback(ri, ci)
|
|
148
|
-
: undefined, children:
|
|
220
|
+
: undefined, children: tooltip ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: tooltip, children: content })) : (content) }, key));
|
|
149
221
|
}) }, typeof row.id === "string" ? row.id : ""))) }))] }) }));
|
|
150
222
|
};
|
|
151
223
|
exports.CellSelectionTable = CellSelectionTable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ModifyCellObj } from "../utils";
|
|
2
2
|
type EmployeeCellProps = {
|
|
3
|
-
row: Record<string, string | ModifyCellObj | undefined>;
|
|
3
|
+
row: Record<string, string | ModifyCellObj | boolean | undefined>;
|
|
4
4
|
};
|
|
5
5
|
export declare const EmployeeCell: ({ row }: EmployeeCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
package/packages/shared-components/dist/CellSelectionTable/SubComponents/EmployeeCell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmployeeCell.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/SubComponents/EmployeeCell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"EmployeeCell.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/SubComponents/EmployeeCell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CACnE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,iBAAiB,4CAiBtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStickyColumns.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/hook/useStickyColumns.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStickyColumns.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/hook/useStickyColumns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,KAAK,YAAY,GAAG,MAAM,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAYF,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,KAAG,sBAuBpD,CAAC"}
|
|
@@ -1,35 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useStickyColumns = void 0;
|
|
7
|
-
const isNaN_1 = __importDefault(require("lodash/isNaN"));
|
|
8
|
-
const isNumber_1 = __importDefault(require("lodash/isNumber"));
|
|
9
|
-
const parseInt_1 = __importDefault(require("lodash/parseInt"));
|
|
10
4
|
const react_1 = require("react");
|
|
11
5
|
const parseMinWidth = (minWidth) => {
|
|
12
|
-
if (
|
|
6
|
+
if (typeof minWidth === "number") {
|
|
13
7
|
return minWidth;
|
|
14
8
|
}
|
|
15
|
-
const
|
|
16
|
-
return (
|
|
9
|
+
const cleaned = parseInt((minWidth ?? "36").replace("px", ""), 10);
|
|
10
|
+
return isNaN(cleaned) ? 36 : cleaned;
|
|
17
11
|
};
|
|
18
12
|
const useStickyColumns = (columns) => {
|
|
19
13
|
return (0, react_1.useMemo)(() => {
|
|
20
|
-
const
|
|
14
|
+
const stickyMap = new Map();
|
|
15
|
+
const parsedColumns = [];
|
|
16
|
+
let runningOffset = 0;
|
|
17
|
+
columns.forEach((col, idx) => {
|
|
21
18
|
const parsedMinWidth = parseMinWidth(col.minWidth);
|
|
22
19
|
const parsedCol = { ...col, idx, parsedMinWidth };
|
|
23
|
-
|
|
20
|
+
parsedColumns.push(parsedCol);
|
|
24
21
|
if (col.lockPinned) {
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
stickyMap.set(idx, runningOffset);
|
|
23
|
+
runningOffset += parsedMinWidth;
|
|
27
24
|
}
|
|
28
|
-
return acc;
|
|
29
|
-
}, {
|
|
30
|
-
parsedColumns: [],
|
|
31
|
-
stickyMap: new Map(),
|
|
32
|
-
offset: 0,
|
|
33
25
|
});
|
|
34
26
|
return { parsedColumns, stickyMap };
|
|
35
27
|
}, [columns]);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { HandleContextMenuArgs, HandleMouseDownArgs, HandleMouseEnterArgs, HandleMunseUpArgs } from "./types";
|
|
2
1
|
import type { Cell } from "../CellSelectionTable";
|
|
3
|
-
|
|
4
|
-
export declare function handleMouseDown({ e, ri, ci, selectingRef, anchorRef,
|
|
5
|
-
export declare function
|
|
2
|
+
import type { HandleContextMenuArgs, HandleMouseDownArgs, HandleMouseEnterArgs, HandleMouseUpArgs } from "./types";
|
|
3
|
+
export declare function handleMouseDown({ e, ri, ci, selectingRef, anchorRef, selectedRanges, selectionModeRef, }: HandleMouseDownArgs): void;
|
|
4
|
+
export declare function handleMouseEnter({ anchorRef, hoveringRef, ri, ci, setSelectedRanges, selectionModeRef, setCurrentSelectedRanges, columns, data, }: HandleMouseEnterArgs): void;
|
|
5
|
+
export declare function handleMouseUp({ e, ri, ci, selectingRef, anchorRef, hoveringRef, setSelectedRanges, selectionModeRef, setCurrentSelectedRanges, columns, data, }: HandleMouseUpArgs): void;
|
|
6
6
|
export declare function handleContextMenu({ e, ri, ci, setSelectedRanges, onCellSelection, selectedRanges, }: HandleContextMenuArgs): void;
|
|
7
|
-
export declare const getCellValue: (cell: string | Cell | undefined, key: string) => string;
|
|
7
|
+
export declare const getCellValue: (cell: string | Cell | boolean | undefined, key: string) => string;
|
|
8
8
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/helper.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAEV,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAwBjB,wBAAgB,eAAe,CAAC,EAC9B,CAAC,EACD,EAAE,EACF,EAAE,EACF,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gBAAgB,GACjB,EAAE,mBAAmB,QAwBrB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,WAAW,EACX,EAAE,EACF,EAAE,EACF,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,OAAO,EACP,IAAI,GACL,EAAE,oBAAoB,QAiDtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,CAAC,EACD,EAAE,EACF,EAAE,EACF,YAAY,EACZ,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,OAAO,EACP,IAAI,GACL,EAAE,iBAAiB,QA+CnB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,CAAC,EACD,EAAE,EACF,EAAE,EACF,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,EAAE,qBAAqB,QA6CvB;AAED,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,EACzC,KAAK,MAAM,KACV,MAsBF,CAAC"}
|
|
@@ -4,91 +4,155 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCellValue = void 0;
|
|
7
|
-
exports.handleMouseEnter = handleMouseEnter;
|
|
8
7
|
exports.handleMouseDown = handleMouseDown;
|
|
8
|
+
exports.handleMouseEnter = handleMouseEnter;
|
|
9
9
|
exports.handleMouseUp = handleMouseUp;
|
|
10
10
|
exports.handleContextMenu = handleContextMenu;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (let c = left; c <= right; c++) {
|
|
21
|
-
range.push({ row: r, col: c });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
setSelectedRanges((prev) => {
|
|
25
|
-
const out = [...prev];
|
|
26
|
-
out.splice(out.length - 1, 1, ...range);
|
|
27
|
-
return out;
|
|
28
|
-
});
|
|
11
|
+
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
12
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
13
|
+
const range_1 = __importDefault(require("lodash/range"));
|
|
14
|
+
const some_1 = __importDefault(require("lodash/some"));
|
|
15
|
+
const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
|
|
16
|
+
const values_1 = __importDefault(require("lodash/values"));
|
|
17
|
+
const cellKey = ({ row, col }) => `${row}:${col}`;
|
|
18
|
+
function rangeCoords(a, b) {
|
|
19
|
+
return (0, range_1.default)(Math.min(a, b), Math.max(a, b) + 1);
|
|
29
20
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
function getRangeCells(a, b) {
|
|
22
|
+
const rows = rangeCoords(a.row, b.row);
|
|
23
|
+
const cols = rangeCoords(a.col, b.col);
|
|
24
|
+
return rows.flatMap((row) => cols.map((col) => ({ row, col })));
|
|
25
|
+
}
|
|
26
|
+
function arrayToRecord(cells) {
|
|
27
|
+
return (0, keyBy_1.default)(cells, cellKey);
|
|
36
28
|
}
|
|
37
|
-
function
|
|
29
|
+
function recordToArray(rec) {
|
|
30
|
+
return (0, values_1.default)(rec);
|
|
31
|
+
}
|
|
32
|
+
function handleMouseDown({ e, ri, ci, selectingRef, anchorRef, selectedRanges, selectionModeRef, }) {
|
|
38
33
|
if (e.button === 2) {
|
|
39
34
|
return;
|
|
40
35
|
}
|
|
41
|
-
const
|
|
36
|
+
const start = { row: ri, col: ci };
|
|
37
|
+
const additive = e.ctrlKey || e.metaKey;
|
|
42
38
|
selectingRef.current = true;
|
|
43
|
-
anchorRef.current =
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
anchorRef.current = start;
|
|
40
|
+
const key = cellKey(start);
|
|
41
|
+
const isAlreadySelected = (0, some_1.default)(selectedRanges.flat(), (c) => cellKey(c) === key);
|
|
42
|
+
if (additive) {
|
|
43
|
+
selectionModeRef.current = isAlreadySelected ? "remove" : "add";
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
selectionModeRef.current = "replace";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function handleMouseEnter({ anchorRef, hoveringRef, ri, ci, setSelectedRanges, selectionModeRef, setCurrentSelectedRanges, columns, data, }) {
|
|
50
|
+
if (anchorRef.current === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const end = { row: ri, col: ci };
|
|
54
|
+
hoveringRef.current = end;
|
|
55
|
+
const rawDraggedCells = getRangeCells(anchorRef.current, end);
|
|
56
|
+
const draggedCells = data.some((row) => row?.rowDisabled) ||
|
|
57
|
+
columns.some((col) => col?.disableSelection)
|
|
58
|
+
? rawDraggedCells.filter((cell) => !data[cell.row]?.rowDisabled && !columns[cell.col]?.disableSelection)
|
|
59
|
+
: rawDraggedCells;
|
|
60
|
+
if (!draggedCells.length) {
|
|
61
|
+
setCurrentSelectedRanges([]);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const mode = selectionModeRef.current;
|
|
65
|
+
if (mode === "replace") {
|
|
66
|
+
setSelectedRanges([draggedCells]);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (mode === "remove") {
|
|
70
|
+
const toRemove = new Set(draggedCells.map(cellKey));
|
|
71
|
+
setSelectedRanges((prev) => prev
|
|
72
|
+
.map((group) => group.filter((cell) => !toRemove.has(cellKey(cell))))
|
|
73
|
+
.filter((group) => group.length));
|
|
46
74
|
return;
|
|
47
75
|
}
|
|
48
|
-
|
|
76
|
+
if (mode === "add") {
|
|
77
|
+
setCurrentSelectedRanges([draggedCells]);
|
|
78
|
+
}
|
|
49
79
|
}
|
|
50
|
-
function handleMouseUp({ e, selectingRef, anchorRef, hoveringRef, setSelectedRanges, }) {
|
|
80
|
+
function handleMouseUp({ e, ri, ci, selectingRef, anchorRef, hoveringRef, setSelectedRanges, selectionModeRef, setCurrentSelectedRanges, columns, data, }) {
|
|
81
|
+
if (!selectionModeRef.current || !anchorRef.current) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const end = { row: ri, col: ci };
|
|
85
|
+
const additive = e.ctrlKey || e.metaKey;
|
|
86
|
+
const mode = selectionModeRef.current;
|
|
87
|
+
const rawDraggedCells = getRangeCells(anchorRef.current, end);
|
|
88
|
+
const draggedCells = data.some((row) => row?.rowDisabled) ||
|
|
89
|
+
columns.some((col) => col?.disableSelection)
|
|
90
|
+
? rawDraggedCells.filter((cell) => !data[cell.row]?.rowDisabled && !columns[cell.col]?.disableSelection)
|
|
91
|
+
: rawDraggedCells;
|
|
51
92
|
selectingRef.current = false;
|
|
52
93
|
anchorRef.current = null;
|
|
53
94
|
hoveringRef.current = null;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
95
|
+
setSelectedRanges((prev) => {
|
|
96
|
+
if (mode === "replace") {
|
|
97
|
+
return [draggedCells];
|
|
98
|
+
}
|
|
99
|
+
if (mode === "remove") {
|
|
100
|
+
const toRemove = new Set(draggedCells.map(cellKey));
|
|
101
|
+
return prev
|
|
102
|
+
.map((group) => group.filter((cell) => !toRemove.has(cellKey(cell))))
|
|
103
|
+
.filter((group) => group.length);
|
|
104
|
+
}
|
|
105
|
+
if (mode === "add") {
|
|
106
|
+
return additive ? [...prev, draggedCells] : [draggedCells];
|
|
107
|
+
}
|
|
108
|
+
return prev;
|
|
109
|
+
});
|
|
110
|
+
setCurrentSelectedRanges([]);
|
|
57
111
|
}
|
|
58
112
|
function handleContextMenu({ e, ri, ci, setSelectedRanges, onCellSelection, selectedRanges, }) {
|
|
59
113
|
e.preventDefault();
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
114
|
+
const clicked = { row: ri, col: ci };
|
|
115
|
+
const keyClicked = cellKey(clicked);
|
|
116
|
+
const additive = e.button === 2;
|
|
117
|
+
const additiveCtrl = e.ctrlKey || e.metaKey;
|
|
118
|
+
const allSelectedCells = selectedRanges.flat();
|
|
119
|
+
const alreadySelected = (0, some_1.default)(allSelectedCells, (c) => cellKey(c) === keyClicked);
|
|
120
|
+
const baseRec = arrayToRecord(allSelectedCells);
|
|
121
|
+
const newRec = (() => {
|
|
122
|
+
if (additiveCtrl || additive) {
|
|
123
|
+
if (!additive && alreadySelected) {
|
|
124
|
+
return (0, omit_1.default)(baseRec, keyClicked);
|
|
125
|
+
}
|
|
126
|
+
if (clicked && alreadySelected) {
|
|
127
|
+
return { ...baseRec, [keyClicked]: clicked };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { [keyClicked]: clicked };
|
|
131
|
+
})();
|
|
132
|
+
const newSelection = recordToArray(newRec);
|
|
133
|
+
if (newSelection.length > 0) {
|
|
134
|
+
setSelectedRanges([newSelection]);
|
|
135
|
+
const newSelectedData = (0, uniqBy_1.default)(newSelection, cellKey);
|
|
136
|
+
if (onCellSelection) {
|
|
137
|
+
onCellSelection({ selectedCells: newSelectedData }, e);
|
|
138
|
+
}
|
|
75
139
|
}
|
|
76
|
-
setSelectedRanges(singleCell);
|
|
77
|
-
onCellSelection?.({ selectedCells: singleCell }, e);
|
|
78
140
|
}
|
|
79
141
|
const getCellValue = (cell, key) => {
|
|
80
142
|
if (typeof cell === "string") {
|
|
81
143
|
return cell;
|
|
82
144
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
145
|
+
if (cell && typeof cell === "object") {
|
|
146
|
+
const value = cell[key];
|
|
147
|
+
if (typeof value === "string") {
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
if (typeof value === "number") {
|
|
151
|
+
return value.toString();
|
|
152
|
+
}
|
|
153
|
+
if (value === true) {
|
|
154
|
+
return "active";
|
|
155
|
+
}
|
|
92
156
|
}
|
|
93
157
|
return "";
|
|
94
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./helper"), exports);
|
|
18
17
|
__exportStar(require("./types"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TableCellProps } from "@mui/material";
|
|
2
2
|
import type { Dictionary } from "lodash";
|
|
3
3
|
import type { Dispatch, MouseEvent, MutableRefObject, SetStateAction } from "react";
|
|
4
|
+
import type { TableDataRow } from "../CellSelectionTable";
|
|
4
5
|
export type Column = {
|
|
5
6
|
key: string;
|
|
6
7
|
label: string;
|
|
@@ -21,13 +22,26 @@ export type CellCoord = {
|
|
|
21
22
|
row: number;
|
|
22
23
|
col: number;
|
|
23
24
|
};
|
|
25
|
+
export type SelectionRange = {
|
|
26
|
+
start: CellCoord;
|
|
27
|
+
end: CellCoord;
|
|
28
|
+
};
|
|
29
|
+
export type SelectionMode = "add" | "remove" | "replace" | "move";
|
|
30
|
+
export type SelectionRecord = Record<string, CellCoord>;
|
|
24
31
|
export type HandleMouseEnterArgs = {
|
|
32
|
+
e: MouseEvent<HTMLTableCellElement>;
|
|
25
33
|
selectingRef: MutableRefObject<boolean>;
|
|
26
34
|
anchorRef: MutableRefObject<CellCoord | null>;
|
|
27
35
|
hoveringRef: MutableRefObject<CellCoord | null>;
|
|
28
36
|
ri: number;
|
|
29
37
|
ci: number;
|
|
30
|
-
|
|
38
|
+
selectedRanges: CellCoord[][];
|
|
39
|
+
setSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
40
|
+
selectionModeRef: MutableRefObject<SelectionMode>;
|
|
41
|
+
currentSelectedRanges: CellCoord[][];
|
|
42
|
+
setCurrentSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
43
|
+
columns: Column[];
|
|
44
|
+
data: TableDataRow[];
|
|
31
45
|
};
|
|
32
46
|
export type HandleMouseDownArgs = {
|
|
33
47
|
e: MouseEvent<HTMLTableCellElement>;
|
|
@@ -35,21 +49,39 @@ export type HandleMouseDownArgs = {
|
|
|
35
49
|
ci: number;
|
|
36
50
|
selectingRef: MutableRefObject<boolean>;
|
|
37
51
|
anchorRef: MutableRefObject<CellCoord | null>;
|
|
38
|
-
|
|
52
|
+
selectedRanges: CellCoord[][];
|
|
53
|
+
setSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
54
|
+
selectionModeRef: MutableRefObject<SelectionMode>;
|
|
39
55
|
};
|
|
40
|
-
export type
|
|
56
|
+
export type HandleMouseUpArgs = {
|
|
41
57
|
e: MouseEvent<HTMLTableCellElement>;
|
|
58
|
+
ri: number;
|
|
59
|
+
ci: number;
|
|
60
|
+
selectingRef: MutableRefObject<boolean>;
|
|
61
|
+
anchorRef: MutableRefObject<CellCoord | null>;
|
|
62
|
+
hoveringRef: MutableRefObject<CellCoord | null>;
|
|
63
|
+
setSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
64
|
+
selectionModeRef: MutableRefObject<SelectionMode>;
|
|
65
|
+
setCurrentSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
66
|
+
columns: Column[];
|
|
67
|
+
data: TableDataRow[];
|
|
68
|
+
};
|
|
69
|
+
export type HandleMouseMoveArgs = {
|
|
70
|
+
e: MouseEvent<HTMLTableCellElement>;
|
|
71
|
+
ri: number;
|
|
72
|
+
ci: number;
|
|
42
73
|
selectingRef: MutableRefObject<boolean>;
|
|
43
74
|
anchorRef: MutableRefObject<CellCoord | null>;
|
|
44
75
|
hoveringRef: MutableRefObject<CellCoord | null>;
|
|
45
|
-
setSelectedRanges: Dispatch<SetStateAction<CellCoord[]>>;
|
|
76
|
+
setSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
77
|
+
selectionModeRef: MutableRefObject<SelectionMode>;
|
|
46
78
|
};
|
|
47
79
|
export type HandleContextMenuArgs = {
|
|
48
80
|
e: MouseEvent<HTMLTableCellElement>;
|
|
49
81
|
ri: number;
|
|
50
82
|
ci: number;
|
|
51
|
-
selectedRanges: CellCoord[];
|
|
52
|
-
setSelectedRanges: Dispatch<SetStateAction<CellCoord[]>>;
|
|
83
|
+
selectedRanges: CellCoord[][];
|
|
84
|
+
setSelectedRanges: Dispatch<SetStateAction<CellCoord[][]>>;
|
|
53
85
|
onCellSelection: (ranges: Dictionary<CellCoord[]>, e: MouseEvent<HTMLTableCellElement>) => void;
|
|
54
86
|
};
|
|
55
87
|
export type GetCellColorArgs = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,cAAc,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FilterList/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FilterList/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DateRangePickerPopUp"), exports);
|
|
17
18
|
__exportStar(require("./FilterList"), exports);
|
|
18
19
|
__exportStar(require("./FilterListV2"), exports);
|
|
19
20
|
__exportStar(require("./FilterPopup"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatePickerProps as MuiDatePickerProps } from "@mui/x-date-pickers/DatePicker";
|
|
2
|
-
import type { PickerValidDate } from "@mui/x-date-pickers/models";
|
|
2
|
+
import type { DateView, PickerValidDate } from "@mui/x-date-pickers/models";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { FieldError, FieldValues, UseControllerProps } from "react-hook-form";
|
|
5
5
|
export type DatePickerProps<P extends FieldValues> = UseControllerProps<P> & MuiDatePickerProps<PickerValidDate> & Partial<{
|
|
@@ -11,6 +11,7 @@ export type DatePickerProps<P extends FieldValues> = UseControllerProps<P> & Mui
|
|
|
11
11
|
helperText: string;
|
|
12
12
|
loading: boolean;
|
|
13
13
|
clearable?: boolean;
|
|
14
|
+
view?: DateView[];
|
|
14
15
|
disableKeyboardInput?: boolean;
|
|
15
16
|
setError: (name: keyof P, error: FieldError | {
|
|
16
17
|
type: string;
|
|
@@ -23,5 +24,5 @@ export declare const dateFormats: {
|
|
|
23
24
|
};
|
|
24
25
|
export declare const LeftArrowIcon: React.FC;
|
|
25
26
|
export declare const RightArrowIcon: React.FC;
|
|
26
|
-
export declare function DatePicker<P extends FieldValues>({ setError, control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, disableKeyboardInput, format, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function DatePicker<P extends FieldValues>({ setError, control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, disableKeyboardInput, views, format, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
//# sourceMappingURL=DatePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG5E,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACxE,kBAAkB,CAAC,eAAe,CAAC,GACnC,OAAO,CAAC;IACN,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;CACX,CAAC,CAAC;AAEL,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAcjC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAclC,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,SAAgB,EAChB,KAAK,EACL,oBAA4B,EAC5B,KAAgC,EAChC,MAAqC,EACrC,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CAyIpB"}
|
|
@@ -40,7 +40,8 @@ const RightArrowIcon = () => {
|
|
|
40
40
|
} }));
|
|
41
41
|
};
|
|
42
42
|
exports.RightArrowIcon = RightArrowIcon;
|
|
43
|
-
function DatePicker({ setError, control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = true, rules, disableKeyboardInput = false, format = exports.dateFormats.dateWithEuropean, ...restProps }) {
|
|
43
|
+
function DatePicker({ setError, control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = true, rules, disableKeyboardInput = false, views = ["year", "month", "day"], format = exports.dateFormats.dateWithEuropean, ...restProps }) {
|
|
44
|
+
const [localError, setLocalError] = (0, react_1.useState)();
|
|
44
45
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
45
46
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
46
47
|
const theme = (0, material_1.useTheme)();
|
|
@@ -49,8 +50,7 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
49
50
|
if (loading) {
|
|
50
51
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && (0, jsx_runtime_1.jsx)(material_1.InputLabel, { required: required, children: label }), (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, { ...restField, ...restProps, disabled: disabled, format: format, value: finalValue, readOnly: readOnly, open: open && !readOnly, onOpen: () => setOpen(true), onClose: () => setOpen(false), slotProps: {
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && (0, jsx_runtime_1.jsx)(material_1.InputLabel, { required: required, children: label }), (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, { ...restField, ...restProps, disabled: disabled, views: views, format: format, value: finalValue, readOnly: readOnly, open: open && !readOnly, onOpen: () => setOpen(true), onClose: () => setOpen(false), slotProps: {
|
|
54
54
|
field: {
|
|
55
55
|
clearable,
|
|
56
56
|
onClear: () => onChange(null),
|
|
@@ -61,8 +61,8 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
61
61
|
},
|
|
62
62
|
textField: {
|
|
63
63
|
disabled,
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
error: !!localError || error,
|
|
65
|
+
helperText: localError ?? helperText,
|
|
66
66
|
InputProps: {
|
|
67
67
|
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { disabled: disabled, onClick: () => setOpen(true) })),
|
|
68
68
|
sx: {
|
|
@@ -119,26 +119,21 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
119
119
|
}, slots: {
|
|
120
120
|
leftArrowIcon: exports.LeftArrowIcon,
|
|
121
121
|
rightArrowIcon: exports.RightArrowIcon,
|
|
122
|
-
switchViewIcon: EmptyIcon,
|
|
123
122
|
}, dayOfWeekFormatter: (weekday) => `${weekday.toFormat("ccc")}`, onAccept: (value, details) => {
|
|
124
123
|
if (restProps?.onAccept) {
|
|
125
124
|
restProps.onAccept(value, details);
|
|
126
125
|
}
|
|
127
126
|
}, onChange: (value, details) => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else if (value?.isValid) {
|
|
141
|
-
onChange(value.toISODate());
|
|
127
|
+
const isValid = value?.isValid === true;
|
|
128
|
+
const hasError = Boolean(details.validationError ?? !isValid);
|
|
129
|
+
onChange(isValid ? value.toISODate() : null);
|
|
130
|
+
setLocalError(hasError ? "Please enter a valid date" : "");
|
|
131
|
+
if ((0, isFunction_1.default)(setError) && hasError) {
|
|
132
|
+
setError(name, {
|
|
133
|
+
type: "manual",
|
|
134
|
+
message: "common.date.invalid",
|
|
135
|
+
});
|
|
142
136
|
}
|
|
137
|
+
restProps?.onChange?.(value, details);
|
|
143
138
|
} })] }));
|
|
144
139
|
}
|
|
@@ -8,6 +8,7 @@ export type DateRangePickerProps<P extends FieldValues> = UseControllerProps<P>
|
|
|
8
8
|
loading?: boolean;
|
|
9
9
|
minDate?: Date;
|
|
10
10
|
maxDate?: Date;
|
|
11
|
+
months?: number;
|
|
11
12
|
};
|
|
12
|
-
export declare function DateRangePicker<P extends FieldValues>({ control, defaultValue, disabled, label, name, error, helperText, loading, required, rules, }: DateRangePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function DateRangePicker<P extends FieldValues>({ control, defaultValue, disabled, label, name, error, helperText, loading, required, months, rules, }: DateRangePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
//# sourceMappingURL=DateRangePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DateRangePicker/DateRangePicker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIvE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,IACpD,kBAAkB,CAAC,CAAC,CAAC,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DateRangePicker/DateRangePicker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIvE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,IACpD,kBAAkB,CAAC,CAAC,CAAC,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEJ,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EACrD,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,MAAU,EACV,KAAK,GACN,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAkEzB"}
|
|
@@ -8,7 +8,7 @@ const react_1 = require("react");
|
|
|
8
8
|
const react_date_range_1 = require("react-date-range");
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
10
|
const Skeleton_1 = require("./Skeleton");
|
|
11
|
-
function DateRangePicker({ control, defaultValue, disabled = false, label, name, error = false, helperText, loading = false, required = false, rules, }) {
|
|
11
|
+
function DateRangePicker({ control, defaultValue, disabled = false, label, name, error = false, helperText, loading = false, required = false, months = 1, rules, }) {
|
|
12
12
|
const { field: { onChange }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
13
13
|
const [range, setRange] = (0, react_1.useState)([
|
|
14
14
|
{
|
|
@@ -36,5 +36,5 @@ function DateRangePicker({ control, defaultValue, disabled = false, label, name,
|
|
|
36
36
|
const endDate = luxon_1.DateTime.fromJSDate(selectedRange.endDate).toISODate();
|
|
37
37
|
onChange([startDate, endDate]);
|
|
38
38
|
}
|
|
39
|
-
}, months:
|
|
39
|
+
}, months: months, direction: "horizontal", calendarFocus: "backwards", staticRanges: [], inputRanges: [], moveRangeOnFirstSelection: false, preventSnapRefocus: true }), error && (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "red", children: helperText })] }));
|
|
40
40
|
}
|