@codezee/sixtify-brahma 0.2.59 → 0.2.60
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/ActionCell.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionCell.js +4 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.d.ts +3 -2
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.js +16 -7
- package/packages/shared-components/dist/CellSelectionTable/SubComponents/TableBodyLoader.d.ts +8 -0
- package/packages/shared-components/dist/CellSelectionTable/SubComponents/TableBodyLoader.d.ts.map +1 -0
- package/packages/shared-components/dist/CellSelectionTable/SubComponents/TableBodyLoader.js +10 -0
- package/packages/shared-components/dist/CellSelectionTable/index.d.ts +1 -0
- package/packages/shared-components/dist/CellSelectionTable/index.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/index.js +1 -0
- package/packages/shared-components/dist/CellSelectionTable/utils/helper.d.ts +1 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/helper.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/helper.js +26 -3
- package/packages/shared-components/dist/CellSelectionTable/utils/index.d.ts +2 -0
- package/packages/shared-components/dist/CellSelectionTable/utils/index.d.ts.map +1 -0
- package/packages/shared-components/dist/CellSelectionTable/utils/index.js +17 -0
- package/packages/shared-components/dist/CellSelectionTable/utils/types.d.ts +3 -1
- package/packages/shared-components/dist/CellSelectionTable/utils/types.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/FileUpload/Dialogs/FilePreview.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/FileUpload/Dialogs/FilePreview.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/FileUpload/Dialogs/FilePreview.js +121 -7
- package/packages/shared-components/dist/FormFields/FileUpload/Dialogs/ViewFilePreviewDialog.js +2 -2
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionCell.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/ActionCell/ActionCell.tsx"],"names":[],"mappings":"AAMA,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,UAAU,GAAI,qBAAqB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ActionCell.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/ActionCell/ActionCell.tsx"],"names":[],"mappings":"AAMA,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,UAAU,GAAI,qBAAqB,iBAAiB,4CA6ChE,CAAC"}
|
|
@@ -19,7 +19,10 @@ const ActionCell = ({ items, disabled }) => {
|
|
|
19
19
|
setAnchorEl(event.currentTarget);
|
|
20
20
|
};
|
|
21
21
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: "100%" }, children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { component: "div", sx: { cursor: "pointer", alignItems: "center", width: "100%" }, onClick: HandleClick, disabled: disabled, 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((item) => {
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(material_1.
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.ListItemButton, { sx: { width: "100%", textAlign: "center" }, onClick: () => {
|
|
23
|
+
item?.onClick();
|
|
24
|
+
setAnchorEl(null);
|
|
25
|
+
}, children: item.title }) }, item.title));
|
|
23
26
|
}) }) }))] }));
|
|
24
27
|
};
|
|
25
28
|
exports.ActionCell = ActionCell;
|
|
@@ -4,9 +4,10 @@ import type { CellCoord, Column } from "./utils/types";
|
|
|
4
4
|
export type CellSelectionTableProps = {
|
|
5
5
|
columns: Column[];
|
|
6
6
|
data: Record<string, string>[];
|
|
7
|
-
onCellSelection: (selectedCells: Dictionary<CellCoord[]>, e
|
|
7
|
+
onCellSelection: (selectedCells: Dictionary<CellCoord[]>, e: MouseEvent) => void;
|
|
8
8
|
cellColors?: (status: string) => string;
|
|
9
9
|
height?: string | number;
|
|
10
|
+
loading?: boolean;
|
|
10
11
|
};
|
|
11
|
-
export declare const CellSelectionTable: ({ columns, data, onCellSelection, cellColors, height, }: Readonly<CellSelectionTableProps>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const CellSelectionTable: ({ columns, data, onCellSelection, cellColors, height, loading, }: Readonly<CellSelectionTableProps>) => import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
//# sourceMappingURL=CellSelectionTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellSelectionTable.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/CellSelectionTable.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAE,KAAK,UAAU,EAA0C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CellSelectionTable.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/CellSelectionTable.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAE,KAAK,UAAU,EAA0C,MAAM,OAAO,CAAC;AAUhF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAoB,MAAM,eAAe,CAAC;AAEzE,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/B,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;CACnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,kEAOhC,QAAQ,CAAC,uBAAuB,CAAC,4CAoOnC,CAAC"}
|
|
@@ -12,8 +12,9 @@ const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
|
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const Tooltip_1 = require("../Tooltip");
|
|
14
14
|
const EmployeeCell_1 = require("./SubComponents/EmployeeCell");
|
|
15
|
+
const TableBodyLoader_1 = require("./SubComponents/TableBodyLoader");
|
|
15
16
|
const helper_1 = require("./utils/helper");
|
|
16
|
-
const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height, }) => {
|
|
17
|
+
const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height, loading = false, }) => {
|
|
17
18
|
const theme = (0, material_1.useTheme)();
|
|
18
19
|
const { slate, iron, butterflyBlue } = theme.palette.app.color;
|
|
19
20
|
const selectingRef = (0, react_1.useRef)(false);
|
|
@@ -42,9 +43,6 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
42
43
|
const unique = (0, uniqBy_1.default)(selectedRanges, (cell) => `${cell.row}-${cell.col}`);
|
|
43
44
|
return (0, groupBy_1.default)(unique, "row");
|
|
44
45
|
}, [selectedRanges]);
|
|
45
|
-
(0, react_1.useMemo)(() => {
|
|
46
|
-
onCellSelection(groupedRanges);
|
|
47
|
-
}, [groupedRanges, onCellSelection]);
|
|
48
46
|
const handleCellMouseDown = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
49
47
|
(0, helper_1.handleMouseDown)({
|
|
50
48
|
e,
|
|
@@ -83,6 +81,7 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
83
81
|
e,
|
|
84
82
|
ri,
|
|
85
83
|
ci,
|
|
84
|
+
selectedRanges,
|
|
86
85
|
setSelectedRanges,
|
|
87
86
|
onCellSelection,
|
|
88
87
|
});
|
|
@@ -99,7 +98,8 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
99
98
|
}, 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", align = "left" }) => ((0, jsx_runtime_1.jsx)(material_1.TableCell, { align: align, sx: {
|
|
100
99
|
backgroundColor: slate[700],
|
|
101
100
|
minWidth,
|
|
102
|
-
|
|
101
|
+
padding: "5px 10px",
|
|
102
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", children: label }) }, key))) }) }), 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", }, ci) => {
|
|
103
103
|
return ((0, jsx_runtime_1.jsx)(material_1.TableCell, { align: align, sx: {
|
|
104
104
|
userSelect: "none",
|
|
105
105
|
overflow: "hidden",
|
|
@@ -107,10 +107,19 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
107
107
|
cellKey: row[key],
|
|
108
108
|
isSelected: isSelectedCell(ri, ci),
|
|
109
109
|
}), 0.8),
|
|
110
|
+
padding: "5px 10px",
|
|
110
111
|
cursor: "pointer",
|
|
111
112
|
maxWidth,
|
|
112
113
|
minWidth,
|
|
113
|
-
}, onMouseDown:
|
|
114
|
-
|
|
114
|
+
}, onMouseDown: !columns[ci]?.disableSelection
|
|
115
|
+
? handleCellMouseDown(ri, ci)
|
|
116
|
+
: undefined, onMouseEnter: !columns[ci]?.disableSelection
|
|
117
|
+
? handleCellMouseEnter(ri, ci)
|
|
118
|
+
: undefined, onMouseUp: !columns[ci]?.disableSelection
|
|
119
|
+
? handleCellMouseUp
|
|
120
|
+
: undefined, onContextMenu: !columns[ci]?.disableSelection
|
|
121
|
+
? handleContextMenuCallback(ri, ci)
|
|
122
|
+
: undefined, children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { toolTipLabel: row[key], children: isEmployee ? ((0, jsx_runtime_1.jsx)(EmployeeCell_1.EmployeeCell, { row: row })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { title: row[key], children: row[key] })) }) }, key));
|
|
123
|
+
}) }, row.id))) }))] }) }));
|
|
115
124
|
};
|
|
116
125
|
exports.CellSelectionTable = CellSelectionTable;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Column } from "../utils";
|
|
2
|
+
type TableBodyLoaderProps = {
|
|
3
|
+
columns: Column[];
|
|
4
|
+
rowCount?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const TableBodyLoader: ({ columns, rowCount, }: TableBodyLoaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=TableBodyLoader.d.ts.map
|
package/packages/shared-components/dist/CellSelectionTable/SubComponents/TableBodyLoader.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBodyLoader.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/SubComponents/TableBodyLoader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,wBAG7B,oBAAoB,4CActB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableBodyLoader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
const TableBodyLoader = ({ columns, rowCount = 25, }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TableBody, { children: Array.from({ length: rowCount }).map(() => ((0, jsx_runtime_1.jsx)(material_1.TableRow, { children: columns.map(() => ((0, jsx_runtime_1.jsx)(material_1.TableCell, { sx: { padding: "5px 10px" }, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: "100%", height: "100%" }) }, (0, uuid_1.v4)()))) }, (0, uuid_1.v4)()))) }));
|
|
9
|
+
};
|
|
10
|
+
exports.TableBodyLoader = TableBodyLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC"}
|
|
@@ -2,5 +2,5 @@ import type { HandleContextMenuArgs, HandleMouseDownArgs, HandleMouseEnterArgs,
|
|
|
2
2
|
export declare function handleMouseEnter({ selectingRef, anchorRef, hoveringRef, ri, ci, setSelectedRanges, }: HandleMouseEnterArgs): void;
|
|
3
3
|
export declare function handleMouseDown({ e, ri, ci, selectingRef, anchorRef, setSelectedRanges, }: HandleMouseDownArgs): void;
|
|
4
4
|
export declare function handleMouseUp({ e, selectingRef, anchorRef, hoveringRef, setSelectedRanges, }: HandleMunseUpArgs): void;
|
|
5
|
-
export declare function handleContextMenu({ e, ri, ci, setSelectedRanges, onCellSelection, }: HandleContextMenuArgs): void;
|
|
5
|
+
export declare function handleContextMenu({ e, ri, ci, setSelectedRanges, onCellSelection, selectedRanges, }: HandleContextMenuArgs): void;
|
|
6
6
|
//# 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":"AAGA,OAAO,KAAK,EAEV,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAgCjB,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,EACZ,SAAS,EACT,WAAW,EACX,EAAE,EACF,EAAE,EACF,iBAAiB,GAClB,EAAE,oBAAoB,QAOtB;AAED,wBAAgB,eAAe,CAAC,EAC9B,CAAC,EACD,EAAE,EACF,EAAE,EACF,YAAY,EACZ,SAAS,EACT,iBAAiB,GAClB,EAAE,mBAAmB,QAkBrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,CAAC,EACD,YAAY,EACZ,SAAS,EACT,WAAW,EACX,iBAAiB,GAClB,EAAE,iBAAiB,QAQnB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,CAAC,EACD,EAAE,EACF,EAAE,EACF,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,EAAE,qBAAqB,QAkCvB"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.handleMouseEnter = handleMouseEnter;
|
|
4
7
|
exports.handleMouseDown = handleMouseDown;
|
|
5
8
|
exports.handleMouseUp = handleMouseUp;
|
|
6
9
|
exports.handleContextMenu = handleContextMenu;
|
|
10
|
+
const compact_1 = __importDefault(require("lodash/compact"));
|
|
11
|
+
const map_1 = __importDefault(require("lodash/map"));
|
|
7
12
|
function updateRange(start, end, setSelectedRanges) {
|
|
8
13
|
const top = Math.min(start.row, end.row);
|
|
9
14
|
const bottom = Math.max(start.row, end.row);
|
|
@@ -29,6 +34,9 @@ function handleMouseEnter({ selectingRef, anchorRef, hoveringRef, ri, ci, setSel
|
|
|
29
34
|
updateRange(anchorRef.current, hoveringRef.current, setSelectedRanges);
|
|
30
35
|
}
|
|
31
36
|
function handleMouseDown({ e, ri, ci, selectingRef, anchorRef, setSelectedRanges, }) {
|
|
37
|
+
if (e.button === 2) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
32
40
|
const anchor = { row: ri, col: ci };
|
|
33
41
|
selectingRef.current = true;
|
|
34
42
|
anchorRef.current = anchor;
|
|
@@ -42,13 +50,28 @@ function handleMouseUp({ e, selectingRef, anchorRef, hoveringRef, setSelectedRan
|
|
|
42
50
|
selectingRef.current = false;
|
|
43
51
|
anchorRef.current = null;
|
|
44
52
|
hoveringRef.current = null;
|
|
45
|
-
if (!e
|
|
53
|
+
if (!(e?.ctrlKey || e?.metaKey)) {
|
|
46
54
|
setSelectedRanges([]);
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
|
-
function handleContextMenu({ e, ri, ci, setSelectedRanges, onCellSelection, }) {
|
|
57
|
+
function handleContextMenu({ e, ri, ci, setSelectedRanges, onCellSelection, selectedRanges, }) {
|
|
50
58
|
e.preventDefault();
|
|
51
59
|
const singleCell = [{ row: ri, col: ci }];
|
|
52
|
-
|
|
60
|
+
const keySet = new Set((0, map_1.default)(selectedRanges, (cell) => `${cell.row}:${cell.col}`));
|
|
61
|
+
if (e.ctrlKey || e.metaKey) {
|
|
62
|
+
singleCell.forEach((cell) => keySet.add(`${cell.row}:${cell.col}`));
|
|
63
|
+
const merged = (0, compact_1.default)((0, map_1.default)(Array.from(keySet), (key) => {
|
|
64
|
+
const [rowStr, colStr] = key.split(":");
|
|
65
|
+
const row = Number(rowStr);
|
|
66
|
+
const col = Number(colStr);
|
|
67
|
+
return Number.isNaN(row) || Number.isNaN(col)
|
|
68
|
+
? null
|
|
69
|
+
: { row, col };
|
|
70
|
+
}));
|
|
71
|
+
setSelectedRanges(merged);
|
|
72
|
+
onCellSelection?.({ selectedCells: merged }, e);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setSelectedRanges(singleCell);
|
|
53
76
|
onCellSelection?.({ selectedCells: singleCell }, e);
|
|
54
77
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
@@ -8,6 +8,7 @@ export type Column = {
|
|
|
8
8
|
minWidth?: string | number;
|
|
9
9
|
maxWidth?: string | number;
|
|
10
10
|
align?: TableCellProps["align"];
|
|
11
|
+
disableSelection?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type OptionsType = {
|
|
13
14
|
value: string;
|
|
@@ -45,8 +46,9 @@ export type HandleContextMenuArgs = {
|
|
|
45
46
|
e: MouseEvent<HTMLTableCellElement>;
|
|
46
47
|
ri: number;
|
|
47
48
|
ci: number;
|
|
49
|
+
selectedRanges: CellCoord[];
|
|
48
50
|
setSelectedRanges: Dispatch<SetStateAction<CellCoord[]>>;
|
|
49
|
-
onCellSelection: (ranges: Dictionary<CellCoord[]>, e
|
|
51
|
+
onCellSelection: (ranges: Dictionary<CellCoord[]>, e: MouseEvent<HTMLTableCellElement>) => void;
|
|
50
52
|
};
|
|
51
53
|
export type GetCellColorArgs = {
|
|
52
54
|
cellKey?: string;
|
|
@@ -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,U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AC,SAAS,EAAE,CAAC,CAAC,CAAC;IACzD,eAAe,EAAE,CACf,MAAM,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC,EAC/B,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,KAChC,IAAI,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
type FilePreviewProps = {
|
|
2
2
|
fileName: string;
|
|
3
|
+
resetTrigger?: number;
|
|
3
4
|
};
|
|
4
5
|
export declare const SUPPORTED_IMAGE_FORMATS: readonly [".png", ".jpg", ".jpeg"];
|
|
5
6
|
export declare const SUPPORTED_PDF_FORMATS: readonly [".pdf"];
|
|
6
7
|
export declare const SUPPORTED_DOC_FORMATS: readonly [".doc", ".docx"];
|
|
7
8
|
export declare const SUPPORTED_EXCEL_FORMATS: readonly [".xls", ".xlsx"];
|
|
8
9
|
export declare function isFileType(url: string, extensions: readonly string[]): boolean;
|
|
9
|
-
export declare const FilePreview: ({ fileName }: FilePreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const FilePreview: ({ fileName, resetTrigger }: FilePreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=FilePreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/FormFields/FileUpload/Dialogs/FilePreview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/FormFields/FileUpload/Dialogs/FilePreview.tsx"],"names":[],"mappings":"AA0BA,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,uBAAuB,oCAAqC,CAAC;AAE1E,eAAO,MAAM,qBAAqB,mBAAoB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,4BAA6B,CAAC;AAEhE,eAAO,MAAM,uBAAuB,4BAA6B,CAAC;AASlE,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,OAAO,CAET;AAED,eAAO,MAAM,WAAW,GAAI,4BAA4B,gBAAgB,4CAkQvE,CAAC"}
|
|
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FilePreview = exports.SUPPORTED_EXCEL_FORMATS = exports.SUPPORTED_DOC_FORMATS = exports.SUPPORTED_PDF_FORMATS = exports.SUPPORTED_IMAGE_FORMATS = void 0;
|
|
7
7
|
exports.isFileType = isFileType;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const ZoomInOutlined_1 = __importDefault(require("@mui/icons-material/ZoomInOutlined"));
|
|
10
|
+
const ZoomOutOutlined_1 = __importDefault(require("@mui/icons-material/ZoomOutOutlined"));
|
|
9
11
|
const material_1 = require("@mui/material");
|
|
10
12
|
const image_1 = __importDefault(require("next/image"));
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const Button_1 = require("../../../Button");
|
|
11
15
|
const Layouts_1 = require("../../../Layouts");
|
|
12
16
|
const PadBox_1 = require("../../../PadBox");
|
|
13
17
|
const utils_1 = require("../../../utils");
|
|
@@ -15,21 +19,131 @@ exports.SUPPORTED_IMAGE_FORMATS = [".png", ".jpg", ".jpeg"];
|
|
|
15
19
|
exports.SUPPORTED_PDF_FORMATS = [".pdf"];
|
|
16
20
|
exports.SUPPORTED_DOC_FORMATS = [".doc", ".docx"];
|
|
17
21
|
exports.SUPPORTED_EXCEL_FORMATS = [".xls", ".xlsx"];
|
|
22
|
+
const DEFAULT_ZOOM_CONFIG = {
|
|
23
|
+
min: 0.5,
|
|
24
|
+
max: 2,
|
|
25
|
+
step: 0.5,
|
|
26
|
+
sensitivity: 0.1,
|
|
27
|
+
};
|
|
18
28
|
function isFileType(url, extensions) {
|
|
19
29
|
return extensions.some((ext) => url.toLowerCase().endsWith(ext));
|
|
20
30
|
}
|
|
21
|
-
const FilePreview = ({ fileName }) => {
|
|
31
|
+
const FilePreview = ({ fileName, resetTrigger }) => {
|
|
22
32
|
const isValidUrl = (0, utils_1.isImageDomainValid)(fileName);
|
|
33
|
+
const [isDragging, setIsDragging] = (0, react_1.useState)(false);
|
|
34
|
+
const [position, setPosition] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
35
|
+
const [startPos, setStartPos] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
36
|
+
const [zoomLevel, setZoomLevel] = (0, react_1.useState)(1);
|
|
37
|
+
const imageContainerRef = (0, react_1.useRef)(null);
|
|
38
|
+
const theme = (0, material_1.useTheme)();
|
|
39
|
+
const { slate } = theme.palette.app.color;
|
|
40
|
+
const { sensitivity, min, max, step } = DEFAULT_ZOOM_CONFIG;
|
|
41
|
+
const { x: positionX, y: positionY } = position;
|
|
42
|
+
const handleMouseDown = ({ clientX, clientY, }) => {
|
|
43
|
+
setIsDragging(true);
|
|
44
|
+
setStartPos({ x: clientX - positionX, y: clientY - positionY });
|
|
45
|
+
};
|
|
46
|
+
const handleMouseMove = ({ clientX, clientY, }) => {
|
|
47
|
+
if (isDragging) {
|
|
48
|
+
const x = clientX - startPos.x;
|
|
49
|
+
const y = clientY - startPos.y;
|
|
50
|
+
setPosition({ x, y });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const calculateOffset = ({ clientX, clientY, }, container) => {
|
|
54
|
+
const { left, top, height, width } = container.getBoundingClientRect();
|
|
55
|
+
const mouseX = clientX - left;
|
|
56
|
+
const mouseY = clientY - top;
|
|
57
|
+
return {
|
|
58
|
+
offsetX: mouseX - width / 2,
|
|
59
|
+
offsetY: mouseY - height / 2,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const handleWheel = (e) => {
|
|
63
|
+
const container = imageContainerRef.current;
|
|
64
|
+
if (!container) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const { offsetX, offsetY } = calculateOffset(e, container);
|
|
68
|
+
const delta = e.deltaY > 0 ? -sensitivity : sensitivity;
|
|
69
|
+
const newZoom = Math.min(Math.max(zoomLevel + delta, min), max);
|
|
70
|
+
if (newZoom !== zoomLevel) {
|
|
71
|
+
const zoomFactor = newZoom / zoomLevel;
|
|
72
|
+
const newX = positionX - offsetX * (zoomFactor - 1);
|
|
73
|
+
const newY = positionY - offsetY * (zoomFactor - 1);
|
|
74
|
+
setPosition({ x: newX, y: newY });
|
|
75
|
+
setZoomLevel(newZoom);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const resetZoomLevel = () => {
|
|
79
|
+
setZoomLevel(1);
|
|
80
|
+
setPosition({ x: 0, y: 0 });
|
|
81
|
+
};
|
|
82
|
+
(0, react_1.useMemo)(() => {
|
|
83
|
+
resetZoomLevel();
|
|
84
|
+
}, [resetTrigger]);
|
|
85
|
+
const updateZoomLevel = (delta) => {
|
|
86
|
+
setZoomLevel((prev) => {
|
|
87
|
+
const updatedZoom = Math.min(2, Math.max(0.5, prev + delta));
|
|
88
|
+
return updatedZoom;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const handleDoubleClick = (e) => {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
const container = imageContainerRef.current;
|
|
94
|
+
if (!container) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const { offsetX, offsetY } = calculateOffset(e, container);
|
|
98
|
+
const newZoom = zoomLevel > 1 ? 1 : Math.min(zoomLevel + step, max);
|
|
99
|
+
if (zoomLevel > 1) {
|
|
100
|
+
resetZoomLevel();
|
|
101
|
+
setZoomLevel(newZoom);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const zoomFactor = newZoom / zoomLevel;
|
|
105
|
+
const newX = positionX - offsetX * (zoomFactor - 1);
|
|
106
|
+
const newY = positionY - offsetY * (zoomFactor - 1);
|
|
107
|
+
setPosition({ x: newX, y: newY });
|
|
108
|
+
setZoomLevel(newZoom);
|
|
109
|
+
};
|
|
110
|
+
const endDrag = () => {
|
|
111
|
+
setIsDragging(false);
|
|
112
|
+
};
|
|
23
113
|
if (isFileType(fileName, exports.SUPPORTED_PDF_FORMATS)) {
|
|
24
114
|
return ((0, jsx_runtime_1.jsx)(Layouts_1.FilePreviewContainer, { children: (0, jsx_runtime_1.jsx)("iframe", { src: `${fileName}#toolbar=0`, style: { width: "100%", height: "100%" } }) }));
|
|
25
115
|
}
|
|
26
116
|
if (isFileType(fileName, exports.SUPPORTED_IMAGE_FORMATS) && isValidUrl) {
|
|
27
|
-
return ((0, jsx_runtime_1.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
117
|
+
return ((0, jsx_runtime_1.jsxs)(Layouts_1.FilePreviewContainer, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: "10px", sx: {
|
|
118
|
+
position: "absolute",
|
|
119
|
+
top: 10,
|
|
120
|
+
right: 66,
|
|
121
|
+
zIndex: 10,
|
|
122
|
+
}, children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { sx: {
|
|
123
|
+
backgroundColor: slate[900],
|
|
124
|
+
minWidth: "42px",
|
|
125
|
+
height: "42px",
|
|
126
|
+
}, onClick: () => updateZoomLevel(-0.3), children: (0, jsx_runtime_1.jsx)(ZoomOutOutlined_1.default, {}) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { sx: {
|
|
127
|
+
backgroundColor: slate[900],
|
|
128
|
+
minWidth: "42px",
|
|
129
|
+
height: "42px",
|
|
130
|
+
}, onClick: () => updateZoomLevel(0.3), children: (0, jsx_runtime_1.jsx)(ZoomInOutlined_1.default, {}) }), zoomLevel !== 1 && ((0, jsx_runtime_1.jsx)(Button_1.Button, { sx: {
|
|
131
|
+
backgroundColor: slate[900],
|
|
132
|
+
minWidth: "42px",
|
|
133
|
+
height: "42px",
|
|
134
|
+
}, onClick: () => resetZoomLevel(), children: "Reset" }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { ref: imageContainerRef, style: {
|
|
135
|
+
position: "relative",
|
|
136
|
+
width: "100%",
|
|
137
|
+
height: "100%",
|
|
138
|
+
cursor: isDragging ? "grabbing" : "grab",
|
|
139
|
+
transform: `scale(${zoomLevel}) translate(${positionX / zoomLevel}px, ${positionY / zoomLevel}px)`,
|
|
140
|
+
transformOrigin: "center center",
|
|
141
|
+
transition: isDragging ? "none" : "transform 0.2s ease-in-out",
|
|
142
|
+
}, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: endDrag, onMouseLeave: endDrag, onWheel: handleWheel, onDoubleClick: handleDoubleClick, children: (0, jsx_runtime_1.jsx)(image_1.default, { src: fileName, alt: "Attachment", fill: true, style: {
|
|
143
|
+
objectFit: "contain",
|
|
144
|
+
userSelect: "none",
|
|
145
|
+
pointerEvents: "none",
|
|
146
|
+
} }) })] }));
|
|
33
147
|
}
|
|
34
148
|
if (isFileType(fileName, exports.SUPPORTED_DOC_FORMATS) ||
|
|
35
149
|
isFileType(fileName, exports.SUPPORTED_EXCEL_FORMATS)) {
|
package/packages/shared-components/dist/FormFields/FileUpload/Dialogs/ViewFilePreviewDialog.js
CHANGED
|
@@ -17,7 +17,7 @@ const ViewFilePreviewDialog = ({ open, onClose, fileName, }) => {
|
|
|
17
17
|
}, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "20px" }, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
18
18
|
position: "relative",
|
|
19
19
|
backgroundColor: iron[600],
|
|
20
|
-
overflow: "
|
|
20
|
+
overflow: "hidden",
|
|
21
21
|
maxHeight: "650px",
|
|
22
22
|
boxShadow: "none",
|
|
23
23
|
}, children: [(0, jsx_runtime_1.jsx)(Actions_1.DownloadIconAction
|
|
@@ -26,7 +26,7 @@ const ViewFilePreviewDialog = ({ open, onClose, fileName, }) => {
|
|
|
26
26
|
// eslint-disable-next-line sonarjs/no-misused-promises
|
|
27
27
|
onClick: () => (0, download_1.downloadFile)(fileName, fileName), sx: {
|
|
28
28
|
position: "absolute",
|
|
29
|
-
top:
|
|
29
|
+
top: 5,
|
|
30
30
|
right: 10,
|
|
31
31
|
zIndex: 10,
|
|
32
32
|
} }), (0, jsx_runtime_1.jsx)(FilePreview_1.FilePreview, { fileName: fileName })] }) }) }) }));
|