@codezee/sixtify-brahma 0.2.156 → 0.2.158
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 +7 -0
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionButtonsWrapper.d.ts.map +1 -0
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionButtonsWrapper.js +122 -0
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionCell.d.ts +1 -1
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionCell.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/ActionCell/ActionCell.js +15 -11
- package/packages/shared-components/dist/AgGrid/ActionCell/index.d.ts +3 -0
- package/packages/shared-components/dist/AgGrid/ActionCell/index.d.ts.map +1 -0
- package/packages/shared-components/dist/AgGrid/ActionCell/index.js +18 -0
- package/packages/shared-components/dist/AgGrid/AgGrid.d.ts +1 -1
- package/packages/shared-components/dist/AgGrid/AgGrid.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/AgGrid.js +2 -5
- package/packages/shared-components/dist/AgGrid/RedirectionCell/ClickableCell.d.ts +12 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/ClickableCell.d.ts.map +1 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/ClickableCell.js +28 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/RedirectionCell.d.ts +13 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/RedirectionCell.d.ts.map +1 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/RedirectionCell.js +31 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/index.d.ts +3 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/index.d.ts.map +1 -0
- package/packages/shared-components/dist/AgGrid/RedirectionCell/index.js +18 -0
- package/packages/shared-components/dist/AgGrid/hooks/index.d.ts +3 -3
- package/packages/shared-components/dist/AgGrid/hooks/index.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/hooks/index.js +3 -3
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridRowSelectionConfig.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridRowSelectionConfig.js +2 -0
- package/packages/shared-components/dist/AgGrid/hooks/useCellEnterClick.d.ts +8 -0
- package/packages/shared-components/dist/AgGrid/hooks/useCellEnterClick.d.ts.map +1 -0
- package/packages/shared-components/dist/AgGrid/hooks/useCellEnterClick.js +39 -0
- package/packages/shared-components/dist/AgGrid/index.d.ts +4 -3
- package/packages/shared-components/dist/AgGrid/index.d.ts.map +1 -1
- package/packages/shared-components/dist/AgGrid/index.js +4 -3
- package/packages/shared-components/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/packages/shared-components/dist/Breadcrumbs/Breadcrumbs.js +8 -4
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.js +145 -54
- package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.js +14 -9
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.js +19 -6
- package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.js +26 -11
- package/packages/shared-components/dist/UserProfileMenu/UserProfileMenu.d.ts.map +1 -1
- package/packages/shared-components/dist/UserProfileMenu/UserProfileMenu.js +13 -16
- package/packages/shared-components/dist/utils/hooks/useFormFieldFocus.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/hooks/useFormFieldFocus.js +71 -3
- package/packages/shared-components/dist/utils/hooks/useGlobalKeyboardShortcut.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/hooks/useGlobalKeyboardShortcut.js +27 -0
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridFocusManagement.d.ts +0 -2
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridFocusManagement.d.ts.map +0 -1
- package/packages/shared-components/dist/AgGrid/hooks/useAgGridFocusManagement.js +0 -105
|
@@ -5,7 +5,9 @@ exports.CellSelectionTable = void 0;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const icons_material_1 = require("@mui/icons-material");
|
|
7
7
|
const material_1 = require("@mui/material");
|
|
8
|
+
const react_virtual_1 = require("@tanstack/react-virtual");
|
|
8
9
|
const react_1 = require("react");
|
|
10
|
+
const Tooltip_1 = require("../Tooltip");
|
|
9
11
|
const useOutsideClick_1 = require("./hook/useOutsideClick");
|
|
10
12
|
const useSorting_1 = require("./hook/useSorting");
|
|
11
13
|
const useStickyColumns_1 = require("./hook/useStickyColumns");
|
|
@@ -13,12 +15,14 @@ const EmployeeCell_1 = require("./SubComponents/EmployeeCell");
|
|
|
13
15
|
const TableBodyLoader_1 = require("./SubComponents/TableBodyLoader");
|
|
14
16
|
const helper_1 = require("./utils/helper");
|
|
15
17
|
const sortUtils_1 = require("./utils/sortUtils");
|
|
16
|
-
const Tooltip_1 = require("../Tooltip");
|
|
17
18
|
exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSelection, cellColors, height, loading = false, getCellTextColor = () => "", onDataUpdate, }, ref) => {
|
|
18
19
|
const theme = (0, material_1.useTheme)();
|
|
19
20
|
const { slate, iron, butterflyBlue } = theme.palette.app.color;
|
|
20
21
|
const selectingRef = (0, react_1.useRef)(false);
|
|
21
22
|
const tableRef = (0, react_1.useRef)(null);
|
|
23
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
24
|
+
const headerRef = (0, react_1.useRef)(null);
|
|
25
|
+
const [columnWidths, setColumnWidths] = (0, react_1.useState)([]);
|
|
22
26
|
const selectionModeRef = (0, react_1.useRef)("add");
|
|
23
27
|
const anchorRef = (0, react_1.useRef)(null);
|
|
24
28
|
const hoveringRef = (0, react_1.useRef)(null);
|
|
@@ -34,12 +38,21 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
34
38
|
setCurrentSelectedRanges([]);
|
|
35
39
|
}
|
|
36
40
|
}, [loading]);
|
|
37
|
-
const
|
|
41
|
+
const selectedCellsSet = (0, react_1.useMemo)(() => {
|
|
42
|
+
const set = new Set();
|
|
38
43
|
if (selectedRanges.length === 0 && currentSelectedRanges.length === 0) {
|
|
39
|
-
return
|
|
44
|
+
return set;
|
|
40
45
|
}
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
[...selectedRanges, ...currentSelectedRanges].forEach((range) => {
|
|
47
|
+
range.forEach((cell) => {
|
|
48
|
+
set.add(`${cell.row}-${cell.col}`);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return set;
|
|
52
|
+
}, [selectedRanges, currentSelectedRanges]);
|
|
53
|
+
const isSelectedCell = (0, react_1.useCallback)((rowIndex, colIndex) => {
|
|
54
|
+
return selectedCellsSet.has(`${rowIndex}-${colIndex}`);
|
|
55
|
+
}, [selectedCellsSet]);
|
|
43
56
|
const { stickyMap } = (0, useStickyColumns_1.useStickyColumns)(columns);
|
|
44
57
|
(0, useOutsideClick_1.useOutsideClick)(tableRef, () => {
|
|
45
58
|
setSelectedRanges([]);
|
|
@@ -78,6 +91,18 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
78
91
|
data: memoizedData,
|
|
79
92
|
columns,
|
|
80
93
|
});
|
|
94
|
+
const ROW_HEIGHT = 40;
|
|
95
|
+
const estimateSize = (0, react_1.useCallback)(() => ROW_HEIGHT, []);
|
|
96
|
+
const getScrollElement = (0, react_1.useCallback)(() => containerRef.current, []);
|
|
97
|
+
const rowVirtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
98
|
+
count: sortedData.length,
|
|
99
|
+
estimateSize,
|
|
100
|
+
getScrollElement,
|
|
101
|
+
overscan: 5,
|
|
102
|
+
scrollPaddingStart: 0,
|
|
103
|
+
scrollPaddingEnd: 0,
|
|
104
|
+
});
|
|
105
|
+
const virtualItems = rowVirtualizer.getVirtualItems();
|
|
81
106
|
const prevSortedDataRef = (0, react_1.useRef)([]);
|
|
82
107
|
const selectedRangesRef = (0, react_1.useRef)([]);
|
|
83
108
|
// Keep track of the latest data for the ref methods
|
|
@@ -168,7 +193,31 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
168
193
|
(0, react_1.useEffect)(() => {
|
|
169
194
|
selectedRangesRef.current = selectedRanges;
|
|
170
195
|
}, [selectedRanges]);
|
|
171
|
-
|
|
196
|
+
// Measure header column widths to ensure body cells match
|
|
197
|
+
(0, react_1.useEffect)(() => {
|
|
198
|
+
if (headerRef.current && !loading) {
|
|
199
|
+
const measureWidths = () => {
|
|
200
|
+
const headerRow = headerRef.current?.querySelector("tr");
|
|
201
|
+
if (headerRow) {
|
|
202
|
+
const headerCells = headerRow.querySelectorAll("th");
|
|
203
|
+
const widths = Array.from(headerCells).map((cell) => {
|
|
204
|
+
return cell.getBoundingClientRect().width;
|
|
205
|
+
});
|
|
206
|
+
if (widths.length > 0) {
|
|
207
|
+
setColumnWidths(widths);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
// Use requestAnimationFrame to avoid blocking the main thread
|
|
212
|
+
const rafId = requestAnimationFrame(() => {
|
|
213
|
+
measureWidths();
|
|
214
|
+
});
|
|
215
|
+
return () => {
|
|
216
|
+
cancelAnimationFrame(rafId);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}, [columns, loading]);
|
|
220
|
+
const getCellColor = (0, react_1.useCallback)(({ cellKey, isSelected = false }) => {
|
|
172
221
|
if (isSelected) {
|
|
173
222
|
return butterflyBlue[800];
|
|
174
223
|
}
|
|
@@ -176,7 +225,7 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
176
225
|
return cellColors(cellKey);
|
|
177
226
|
}
|
|
178
227
|
return iron[600];
|
|
179
|
-
}
|
|
228
|
+
}, [butterflyBlue, cellColors, iron]);
|
|
180
229
|
const handleCellMouseDown = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
181
230
|
e.preventDefault();
|
|
182
231
|
if ((0, sortUtils_1.isSelectionDisabled)(columns[ci]?.disableSelection, columns[ci]?.sorting) &&
|
|
@@ -276,10 +325,15 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
276
325
|
onCellSelection,
|
|
277
326
|
});
|
|
278
327
|
}, [onCellSelection, selectedRanges]);
|
|
279
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { position: "relative", overflow: "auto", height: height, bgcolor: iron[600],
|
|
328
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, position: "relative", overflow: "auto", height: height, bgcolor: iron[600], sx: {
|
|
329
|
+
WebkitOverflowScrolling: "touch",
|
|
330
|
+
scrollBehavior: "auto",
|
|
331
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Table, { ref: tableRef, stickyHeader: true, sx: {
|
|
280
332
|
userSelect: "none",
|
|
281
333
|
borderCollapse: "separate",
|
|
282
334
|
borderSpacing: 0,
|
|
335
|
+
tableLayout: "fixed",
|
|
336
|
+
width: "100%",
|
|
283
337
|
"& th, & td": {
|
|
284
338
|
borderRight: `1px solid ${slate[700]}`,
|
|
285
339
|
borderBottom: `1px solid ${slate[700]}`,
|
|
@@ -291,7 +345,7 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
291
345
|
"& td": {
|
|
292
346
|
padding: "0px 5px",
|
|
293
347
|
},
|
|
294
|
-
}, 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", disableSelection, sorting, }, ci) => {
|
|
348
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.TableHead, { ref: headerRef, children: (0, jsx_runtime_1.jsx)(material_1.TableRow, { children: columns.map(({ key, label, minWidth = "auto", lockPinned = false, align = "left", disableSelection, sorting, }, ci) => {
|
|
295
349
|
const isSticky = stickyMap.has(ci);
|
|
296
350
|
const left = isSticky ? stickyMap.get(ci) : 0;
|
|
297
351
|
const sortDirection = getSortDirection(key);
|
|
@@ -321,54 +375,91 @@ exports.CellSelectionTable = (0, react_1.forwardRef)(({ columns, data, onCellSel
|
|
|
321
375
|
}),
|
|
322
376
|
backgroundColor: slate[700],
|
|
323
377
|
minWidth,
|
|
378
|
+
maxWidth: columns[ci]?.maxWidth ?? "auto",
|
|
379
|
+
width: minWidth !== "auto" ? minWidth : undefined,
|
|
324
380
|
padding: "5px 10px",
|
|
325
381
|
cursor: canSort ? "pointer" : "default",
|
|
382
|
+
boxSizing: "border-box",
|
|
326
383
|
}, onClick: canSort ? () => handleSort(key) : undefined, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", justifyContent: justifyContent, gap: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", lineHeight: "18px", children: label }), canSort && ((0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", flexDirection: "column", alignItems: "center", children: renderSortIcon() }))] }) }, key));
|
|
327
|
-
}) }) }), loading ? ((0, jsx_runtime_1.jsx)(TableBodyLoader_1.TableBodyLoader, { columns: columns, rowCount: 25 })) : ((0, jsx_runtime_1.jsx)(material_1.TableBody, {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
384
|
+
}) }) }), loading ? ((0, jsx_runtime_1.jsx)(TableBodyLoader_1.TableBodyLoader, { columns: columns, rowCount: 25 })) : ((0, jsx_runtime_1.jsx)(material_1.TableBody, { style: {
|
|
385
|
+
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
386
|
+
position: "relative",
|
|
387
|
+
}, children: virtualItems.map((virtualRow) => {
|
|
388
|
+
const row = sortedData[virtualRow.index];
|
|
389
|
+
if (!row) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
const ri = virtualRow.index;
|
|
393
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TableRow, { sx: {
|
|
394
|
+
backgroundColor: iron[600],
|
|
395
|
+
position: "absolute",
|
|
396
|
+
top: 0,
|
|
397
|
+
left: 0,
|
|
398
|
+
width: "100%",
|
|
399
|
+
height: `${virtualRow.size}px`,
|
|
400
|
+
transform: `translateY(${virtualRow.start}px) translateZ(0)`,
|
|
401
|
+
display: "table-row",
|
|
402
|
+
willChange: "transform",
|
|
403
|
+
backfaceVisibility: "hidden",
|
|
404
|
+
WebkitBackfaceVisibility: "hidden",
|
|
405
|
+
}, children: columns.map(({ key, maxWidth = "auto", minWidth = "auto", isEmployee, align = "center", lockPinned = false, }, ci) => {
|
|
406
|
+
const cell = row[key];
|
|
407
|
+
const getRowTitle = (0, helper_1.getCellValue)(cell, "cellLabel");
|
|
408
|
+
const tooltip = typeof cell === "object" &&
|
|
409
|
+
cell != null &&
|
|
410
|
+
typeof cell?.["cellTooltip"] === "object"
|
|
411
|
+
? cell["cellTooltip"]
|
|
412
|
+
: (0, helper_1.getCellValue)(cell, "cellTooltip");
|
|
413
|
+
const getColor = (0, helper_1.getCellValue)(cell, "cellBackgroundConditionKey");
|
|
414
|
+
const cellActive = (0, helper_1.getCellValue)(cell, "cellActive");
|
|
415
|
+
const isSticky = stickyMap.has(ci);
|
|
416
|
+
const left = isSticky ? stickyMap.get(ci) : 0;
|
|
417
|
+
const content = isEmployee ? ((0, jsx_runtime_1.jsx)(EmployeeCell_1.EmployeeCell, { row: row, maxWidth: maxWidth, minWidth: minWidth })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: getRowTitle }));
|
|
418
|
+
const isNotDisabled = !((0, sortUtils_1.isSelectionDisabled)(columns[ci]?.disableSelection, columns[ci]?.sorting) || row?.rowDisabled);
|
|
419
|
+
let cellWidth;
|
|
420
|
+
if (columnWidths[ci] !== undefined) {
|
|
421
|
+
cellWidth = `${columnWidths[ci]}px`;
|
|
422
|
+
}
|
|
423
|
+
else if (minWidth !== "auto") {
|
|
424
|
+
cellWidth = minWidth;
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
cellWidth = undefined;
|
|
428
|
+
}
|
|
429
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TableCell, { align: align, sx: {
|
|
430
|
+
...(lockPinned && {
|
|
431
|
+
top: 0,
|
|
432
|
+
left,
|
|
433
|
+
zIndex: 5,
|
|
434
|
+
position: "sticky",
|
|
352
435
|
}),
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
436
|
+
...(isNotDisabled
|
|
437
|
+
? {}
|
|
438
|
+
: {
|
|
439
|
+
cursor: "not-allowed",
|
|
440
|
+
}),
|
|
441
|
+
userSelect: "none",
|
|
442
|
+
overflow: "hidden",
|
|
443
|
+
bgcolor: (0, material_1.lighten)(getCellColor({
|
|
444
|
+
cellKey: getColor,
|
|
445
|
+
isSelected: isSelectedCell(ri, ci),
|
|
446
|
+
}), 0.8),
|
|
447
|
+
...(cellActive &&
|
|
448
|
+
ci > 0 && {
|
|
449
|
+
color: getCellTextColor(cellActive),
|
|
450
|
+
}),
|
|
451
|
+
padding: "5px 10px",
|
|
452
|
+
cursor: "pointer",
|
|
453
|
+
maxWidth,
|
|
454
|
+
minWidth,
|
|
455
|
+
width: cellWidth,
|
|
456
|
+
boxSizing: "border-box",
|
|
457
|
+
}, onMouseDown: (e) => handleCellMouseDown(ri, ci)(e), onMouseEnter: isNotDisabled
|
|
458
|
+
? handleCellMouseEnter(ri, ci)
|
|
459
|
+
: undefined, onMouseUp: (e) => handleCellMouseUp(ri, ci)(e), onContextMenu: isNotDisabled
|
|
460
|
+
? handleContextMenuCallback(ri, ci)
|
|
461
|
+
: undefined, children: tooltip ? ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { toolTipLabel: tooltip, children: content })) : (content) }, key));
|
|
462
|
+
}) }, typeof row.id === "string" ? row.id : `row-${ri}`));
|
|
463
|
+
}) }))] }) }));
|
|
373
464
|
});
|
|
374
465
|
exports.CellSelectionTable.displayName = "CellSelectionTable";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/FileUpload/FileUpload.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/FileUpload/FileUpload.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAKrB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,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;AAEF,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,OAAe,EACf,QAAQ,EACR,UAAU,EACV,QAAgB,EAChB,QAAgB,EAChB,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,IAAS,EACT,IAAI,EACJ,QAAQ,EACR,MAA6B,EAC7B,WAAsD,EACtD,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CAoSpB"}
|
|
@@ -14,14 +14,15 @@ const react_i18next_1 = require("react-i18next");
|
|
|
14
14
|
const PadBox_1 = require("../../PadBox");
|
|
15
15
|
const Svgs_1 = require("../../Svgs");
|
|
16
16
|
const utils_1 = require("../../utils");
|
|
17
|
+
const useFormFieldFocus_1 = require("../../utils/hooks/useFormFieldFocus");
|
|
17
18
|
const FileUpload_styled_1 = require("./FileUpload.styled");
|
|
18
19
|
const Skeleton_1 = require("./Skeleton");
|
|
19
20
|
exports.error_with_transaltion = "error_with_transaltion";
|
|
20
21
|
function FileUpload({ loading = false, onChange, isDisabled, multiple = false, required = false, error, helperText, label, fileNames, size = 10, name, setError, accept = utils_1.SUPPORTED_FILE_TYPES, acceptTitle = "Only JPG, PNG, PDF files are accepted.", ...restProps }) {
|
|
21
22
|
const theme = (0, material_1.useTheme)();
|
|
22
|
-
const { red, iron, black } = theme.palette.app.color;
|
|
23
|
+
const { red, iron, black, butterflyBlue } = theme.palette.app.color;
|
|
23
24
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
24
|
-
const inputRef = (0,
|
|
25
|
+
const { inputRef, setInputRef } = (0, useFormFieldFocus_1.useFormFieldFocus)();
|
|
25
26
|
const dragCounter = (0, react_1.useRef)(0);
|
|
26
27
|
const rafRef = (0, react_1.useRef)(null);
|
|
27
28
|
const animStartRef = (0, react_1.useRef)(null);
|
|
@@ -60,9 +61,6 @@ function FileUpload({ loading = false, onChange, isDisabled, multiple = false, r
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
onChange(validFiles);
|
|
63
|
-
if (inputRef.current) {
|
|
64
|
-
inputRef.current.value = "";
|
|
65
|
-
}
|
|
66
64
|
};
|
|
67
65
|
const handleFileChange = (event) => {
|
|
68
66
|
const files = event.target.files;
|
|
@@ -160,8 +158,11 @@ function FileUpload({ loading = false, onChange, isDisabled, multiple = false, r
|
|
|
160
158
|
}
|
|
161
159
|
const fileArray = Array.from(files);
|
|
162
160
|
processFiles(fileArray);
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
};
|
|
162
|
+
const handleContainerKeyDown = (event) => {
|
|
163
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
inputRef.current?.click();
|
|
165
166
|
}
|
|
166
167
|
};
|
|
167
168
|
if (loading) {
|
|
@@ -169,12 +170,16 @@ function FileUpload({ loading = false, onChange, isDisabled, multiple = false, r
|
|
|
169
170
|
}
|
|
170
171
|
const boxShadowIntensity = 0.08 + 0.12 * dragProgress;
|
|
171
172
|
const scale = 1 + 0.02 * dragProgress;
|
|
172
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { disabled: isDisabled, required: required, children: label }), (0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileUploadContainer, { onClick: () => inputRef.current?.click(), onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, error: error, disabled: isDisabled, sx: {
|
|
173
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { disabled: isDisabled, required: required, children: label }), (0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileUploadContainer, { onClick: () => inputRef.current?.click(), onKeyDown: handleContainerKeyDown, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, error: error, disabled: isDisabled, tabIndex: isDisabled ? -1 : 0, role: "button", "aria-label": label ?? "Upload files", sx: {
|
|
173
174
|
transform: `scale(${scale})`,
|
|
174
175
|
transition: "transform 30ms linear",
|
|
175
176
|
boxShadow: `0 0px ${12 * dragProgress}px ${(0, material_1.alpha)(black[900], boxShadowIntensity)}`,
|
|
176
177
|
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
177
|
-
|
|
178
|
+
"&:focus-visible": {
|
|
179
|
+
outline: `2px solid ${butterflyBlue[900]}`,
|
|
180
|
+
outlineOffset: "2px",
|
|
181
|
+
},
|
|
182
|
+
}, ...restProps, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "20px" }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "4px", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileInput, { disabled: isDisabled, type: "file", accept: accept.toString(), ref: setInputRef, onChange: handleFileChange, multiple: multiple }), (0, jsx_runtime_1.jsx)(Svgs_1.SvgDrop, { disabled: isDisabled }), (0, jsx_runtime_1.jsx)(material_1.Typography, { color: isDisabled ? iron[800] : "revert-layer", children: "Drag & drop files or Browse" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: isDisabled ? iron[800] : "revert-layer", children: acceptTitle })] }) }) }), error && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: {
|
|
178
183
|
color: `${red[900]}`,
|
|
179
184
|
whiteSpace: "pre",
|
|
180
185
|
textWrap: "wrap",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/ImageUpload/ImageUpload.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/ImageUpload/ImageUpload.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAKlD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AASH,wBAAgB,WAAW,CAAC,EAC1B,OAAkB,EAClB,WAAmB,EACnB,YAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,SAAiB,EACjB,OAAe,EACf,IAAQ,EACR,QAAiC,GAClC,EAAE,gBAAgB,2CAuMlB"}
|
|
@@ -15,15 +15,16 @@ const Button_1 = require("../../Button");
|
|
|
15
15
|
const PadBox_1 = require("../../PadBox");
|
|
16
16
|
const Toast_1 = require("../../Toast");
|
|
17
17
|
const utils_1 = require("../../utils");
|
|
18
|
+
const useFormFieldFocus_1 = require("../../utils/hooks/useFormFieldFocus");
|
|
18
19
|
const ImageUpload_styled_1 = require("./ImageUpload.styled");
|
|
19
20
|
const PhotoCaptureDialog_1 = require("./PhotoCaptureDialog");
|
|
20
21
|
const Skeleton_1 = require("./Skeleton");
|
|
21
22
|
const imageFileType = ["image/png", "image/jpeg", "image/jpg"];
|
|
22
23
|
function ImageUpload({ variant = "square", isUploading = false, defaultValue = "", onDelete, onChange, label, isCapture = false, loading = false, size = 5, subTitle = "PNG, JPEG under 5 MB", }) {
|
|
23
24
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
24
|
-
const inputRef = (0, react_1.useRef)(null);
|
|
25
25
|
const [hover, setHover] = (0, react_1.useState)(false);
|
|
26
26
|
const [isOpenCaptureModal, setIsOpenCaptureModal] = (0, react_1.useState)(false);
|
|
27
|
+
const { inputRef, setInputRef, maintainFocusAfterClose } = (0, useFormFieldFocus_1.useFormFieldFocus)(isOpenCaptureModal);
|
|
27
28
|
const theme = (0, material_1.useTheme)();
|
|
28
29
|
const { butterflyBlue, iron } = theme.palette.app.color;
|
|
29
30
|
const handleFileChange = (event) => {
|
|
@@ -53,15 +54,20 @@ function ImageUpload({ variant = "square", isUploading = false, defaultValue = "
|
|
|
53
54
|
const handleFileRemove = (event) => {
|
|
54
55
|
event.stopPropagation();
|
|
55
56
|
onDelete();
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
};
|
|
58
|
+
const handleContainerKeyDown = (event) => {
|
|
59
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
if (!defaultValue) {
|
|
62
|
+
inputRef.current?.click();
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
const { layout } = (0, utils_1.useGetDeviceType)();
|
|
61
67
|
if (loading) {
|
|
62
68
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {});
|
|
63
69
|
}
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { flexWrap: isCapture ? "wrap" : "nowrap", gap: "20px", direction: "row", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => !defaultValue && inputRef.current?.click(), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), sx: {
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { flexWrap: isCapture ? "wrap" : "nowrap", gap: "20px", direction: "row", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => !defaultValue && inputRef.current?.click(), onKeyDown: handleContainerKeyDown, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), tabIndex: 0, role: "button", "aria-label": label ?? "Upload image", sx: {
|
|
65
71
|
height: "120px",
|
|
66
72
|
width: "120px",
|
|
67
73
|
position: "relative",
|
|
@@ -77,6 +83,10 @@ function ImageUpload({ variant = "square", isUploading = false, defaultValue = "
|
|
|
77
83
|
":hover": {
|
|
78
84
|
border: `2px dashed ${butterflyBlue[900]}`,
|
|
79
85
|
},
|
|
86
|
+
":focus-visible": {
|
|
87
|
+
outline: `2px solid ${butterflyBlue[900]}`,
|
|
88
|
+
outlineOffset: "2px",
|
|
89
|
+
},
|
|
80
90
|
...(variant === "circle"
|
|
81
91
|
? {
|
|
82
92
|
borderRadius: "50%",
|
|
@@ -85,9 +95,12 @@ function ImageUpload({ variant = "square", isUploading = false, defaultValue = "
|
|
|
85
95
|
},
|
|
86
96
|
}
|
|
87
97
|
: {}),
|
|
88
|
-
}, children: [(0, jsx_runtime_1.jsx)("input", { type: "file", ref:
|
|
98
|
+
}, children: [(0, jsx_runtime_1.jsx)("input", { type: "file", ref: setInputRef, accept: imageFileType.join(","), onChange: handleFileChange, style: { display: "none" } }), hover && !!defaultValue && ((0, jsx_runtime_1.jsxs)(ImageUpload_styled_1.DarkBackgroundContainer, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => inputRef.current?.click(), children: (0, jsx_runtime_1.jsx)(icons_material_1.Edit, { sx: { color: "white" } }) }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: handleFileRemove, children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, { sx: { color: "white" } }) })] })), isUploading && ((0, jsx_runtime_1.jsx)(ImageUpload_styled_1.DarkBackgroundContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { color: iron[600], children: "Processing..." }) })), defaultValue ? ((0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "2px" }, children: (0, jsx_runtime_1.jsx)("img", { alt: "", src: defaultValue, style: {
|
|
89
99
|
width: "100%",
|
|
90
100
|
height: "100%",
|
|
91
101
|
objectFit: "cover",
|
|
92
|
-
} }) })) : ((0, jsx_runtime_1.jsx)(material_1.Stack, { justifyContent: "center", alignItems: "center", sx: { height: "100%" }, children: (0, jsx_runtime_1.jsx)(PersonAddAlt_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, variant: "subtitle1", fontWeight: 500, children: label }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: iron[800], children: subTitle })] }), isCapture && ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => setIsOpenCaptureModal(true), variant: "outlined", fullWidth: layout === "mobile", children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", direction: "row", children: [(0, jsx_runtime_1.jsx)(CameraAltOutlined_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", children: "Capture photo" })] }) }))] }), isOpenCaptureModal && ((0, jsx_runtime_1.jsx)(PhotoCaptureDialog_1.PhotoCaptureDialog, { onChange: onChange, isUploading: isUploading, open: isOpenCaptureModal, onClose: () =>
|
|
102
|
+
} }) })) : ((0, jsx_runtime_1.jsx)(material_1.Stack, { justifyContent: "center", alignItems: "center", sx: { height: "100%" }, children: (0, jsx_runtime_1.jsx)(PersonAddAlt_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, variant: "subtitle1", fontWeight: 500, children: label }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: iron[800], children: subTitle })] }), isCapture && ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => setIsOpenCaptureModal(true), variant: "outlined", fullWidth: layout === "mobile", children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", direction: "row", children: [(0, jsx_runtime_1.jsx)(CameraAltOutlined_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", children: "Capture photo" })] }) }))] }), isOpenCaptureModal && ((0, jsx_runtime_1.jsx)(PhotoCaptureDialog_1.PhotoCaptureDialog, { onChange: onChange, isUploading: isUploading, open: isOpenCaptureModal, onClose: () => {
|
|
103
|
+
setIsOpenCaptureModal(false);
|
|
104
|
+
maintainFocusAfterClose();
|
|
105
|
+
} }))] }));
|
|
93
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInputField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/PhoneInputField/PhoneInputField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,IACpD,kBAAkB,CAAC,CAAC,CAAC,GACnB,IAAI,CAAC,eAAe,EAAE,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EACrD,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,QAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,OAAe,EACf,WAAgB,EAChB,KAAK,EACL,UAAU,EACV,GAAG,eAAe,EACnB,EAAE,oBAAoB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"PhoneInputField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/PhoneInputField/PhoneInputField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,IACpD,kBAAkB,CAAC,CAAC,CAAC,GACnB,IAAI,CAAC,eAAe,EAAE,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EACrD,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,QAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,OAAe,EACf,WAAgB,EAChB,KAAK,EACL,UAAU,EACV,GAAG,eAAe,EACnB,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAsNzB"}
|
|
@@ -26,7 +26,7 @@ function PhoneInputField({ control, name, defaultValue, rules, label, disabled =
|
|
|
26
26
|
const containerRef = (0, react_1.useRef)(null);
|
|
27
27
|
(0, react_1.useEffect)(() => {
|
|
28
28
|
const container = containerRef.current;
|
|
29
|
-
if (!container) {
|
|
29
|
+
if (!container || disabled) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const mainInput = container.querySelector("input[type='tel']");
|
|
@@ -35,6 +35,13 @@ function PhoneInputField({ control, name, defaultValue, rules, label, disabled =
|
|
|
35
35
|
restField.ref(mainInput);
|
|
36
36
|
}
|
|
37
37
|
const checkDropdownState = () => {
|
|
38
|
+
const selectedFlag = container.querySelector(".selected-flag");
|
|
39
|
+
if (selectedFlag) {
|
|
40
|
+
selectedFlag.setAttribute("tabindex", "-1");
|
|
41
|
+
selectedFlag.addEventListener("focus", () => {
|
|
42
|
+
selectedFlag.blur();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
38
45
|
const dropdown = container.querySelector(".flag-dropdown.open");
|
|
39
46
|
const isOpen = !!dropdown;
|
|
40
47
|
setDropdownOpen(isOpen);
|
|
@@ -75,22 +82,30 @@ function PhoneInputField({ control, name, defaultValue, rules, label, disabled =
|
|
|
75
82
|
container.removeEventListener("click", handleClick);
|
|
76
83
|
document.removeEventListener("click", handleClickOutside);
|
|
77
84
|
};
|
|
78
|
-
}, [setInputRef, restField]);
|
|
85
|
+
}, [setInputRef, restField, disabled]);
|
|
79
86
|
if (loading) {
|
|
80
87
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label, rows: rows });
|
|
81
88
|
}
|
|
82
89
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "4px", children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, sx: {
|
|
83
90
|
"& .phone-input-container": {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
:
|
|
88
|
-
|
|
91
|
+
...(disabled
|
|
92
|
+
? {}
|
|
93
|
+
: {
|
|
94
|
+
"&:focus-within": {
|
|
95
|
+
border: `2px solid ${butterflyBlue[900]} !important`,
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
89
98
|
},
|
|
90
|
-
"& .phone-input-field
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
"& .phone-input-field": {
|
|
100
|
+
...(disabled
|
|
101
|
+
? {}
|
|
102
|
+
: {
|
|
103
|
+
"&:focus": {
|
|
104
|
+
"& ~ .flag-dropdown": {
|
|
105
|
+
borderColor: error ? red[900] : butterflyBlue[900],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
94
109
|
},
|
|
95
110
|
"& .flag-dropdown": {
|
|
96
111
|
"&.open": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfileMenu.d.ts","sourceRoot":"","sources":["../../src/UserProfileMenu/UserProfileMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAa/C,OAAO,
|
|
1
|
+
{"version":3,"file":"UserProfileMenu.d.ts","sourceRoot":"","sources":["../../src/UserProfileMenu/UserProfileMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAa/C,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG;IACzE,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,EAAE,CAAC,EAAE,aAAa,CAAC;QACnB,OAAO,CAAC,EAAE,QAAQ,CAAC;KACpB,EAAE,CAAC;CACL,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,SAAS,GACV,EAAE,oBAAoB,2CA0ItB"}
|
|
@@ -13,6 +13,7 @@ const utils_1 = require("../utils");
|
|
|
13
13
|
const UserProfileMenu_styled_1 = require("./UserProfileMenu.styled");
|
|
14
14
|
function UserProfileMenu({ userDetails, menuItems, }) {
|
|
15
15
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
16
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
16
17
|
const { layout } = (0, utils_1.useGetDeviceType)();
|
|
17
18
|
const isDesktop = layout === "desktop";
|
|
18
19
|
const theme = (0, material_1.useTheme)();
|
|
@@ -21,29 +22,27 @@ function UserProfileMenu({ userDetails, menuItems, }) {
|
|
|
21
22
|
const handleClick = (event) => {
|
|
22
23
|
setAnchorEl(event.currentTarget);
|
|
23
24
|
};
|
|
24
|
-
const handleClose = () =>
|
|
25
|
-
setAnchorEl(null);
|
|
26
|
-
};
|
|
25
|
+
const handleClose = () => setAnchorEl(null);
|
|
27
26
|
const { name } = userDetails;
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { position: "relative", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: "flex", alignItems: "center"
|
|
29
|
-
"& .MuiPaper-root": {
|
|
30
|
-
width: "220px",
|
|
31
|
-
},
|
|
32
|
-
}, slotProps: {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { position: "relative", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: "flex", alignItems: "center" }, children: (0, jsx_runtime_1.jsx)(UserProfileMenu_styled_1.IconButtonStyled, { ref: buttonRef, onClick: handleClick, size: "small", "aria-haspopup": "true", children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: 1, color: "black", children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { src: userDetails.avatar, sx: { border: `1px solid ${iron[700]}` } }), isDesktop && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { maxWidth: 150, noWrap: true, children: name }), open ? (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowUp, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowDown, {})] }))] }) }) }), open && ((0, jsx_runtime_1.jsx)(material_1.Popover, { open: true, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "right" }, transformOrigin: { vertical: "top", horizontal: "right" }, slotProps: {
|
|
33
28
|
paper: {
|
|
34
29
|
elevation: 0,
|
|
35
30
|
sx: {
|
|
31
|
+
width: 220,
|
|
36
32
|
overflow: "visible",
|
|
37
|
-
filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
|
|
38
33
|
mt: 1.5,
|
|
34
|
+
px: 0,
|
|
35
|
+
py: 0,
|
|
36
|
+
filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
|
|
39
37
|
"& .MuiAvatar-root": {
|
|
40
38
|
width: 32,
|
|
41
39
|
height: 32,
|
|
42
40
|
ml: -0.5,
|
|
43
41
|
mr: 1,
|
|
44
42
|
},
|
|
45
|
-
"
|
|
46
|
-
|
|
43
|
+
"&:before": {
|
|
44
|
+
// eslint-disable-next-line quotes
|
|
45
|
+
content: '""',
|
|
47
46
|
display: "block",
|
|
48
47
|
position: "absolute",
|
|
49
48
|
top: 0,
|
|
@@ -56,15 +55,13 @@ function UserProfileMenu({ userDetails, menuItems, }) {
|
|
|
56
55
|
},
|
|
57
56
|
},
|
|
58
57
|
},
|
|
59
|
-
},
|
|
60
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [divider && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { onClick: () => {
|
|
58
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { padding: "4px 0" }, children: menuItems.map(({ key, divider, label, icon, sx, onClick }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [divider && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.ListItemButton, { onClick: () => {
|
|
61
59
|
if ((0, isFunction_1.default)(onClick)) {
|
|
62
60
|
onClick();
|
|
63
61
|
}
|
|
64
|
-
}, children: (icon || label) && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "
|
|
62
|
+
}, children: (icon || label) && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "16px", alignItems: "center", width: "100%", flexDirection: "row", sx: { ...sx }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { sx: {
|
|
65
63
|
minWidth: "20px",
|
|
66
64
|
alignItems: "center",
|
|
67
65
|
...sx,
|
|
68
|
-
}, children: icon }), label && ((0, jsx_runtime_1.jsx)(material_1.Typography, { sx: { fontSize: "15px" }, children: label }))] })) })] }, `${key}_container`));
|
|
69
|
-
}) })] }));
|
|
66
|
+
}, children: icon }), label && ((0, jsx_runtime_1.jsx)(material_1.Typography, { sx: { fontSize: "15px" }, children: label }))] })) })] }, `${key}_container`))) }) }))] }));
|
|
70
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormFieldFocus.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/useFormFieldFocus.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS;;
|
|
1
|
+
{"version":3,"file":"useFormFieldFocus.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/useFormFieldFocus.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS;;uBA8GtB,gBAAgB,GAAG,IAAI;;;oBAf1D,CAAC,SAAS,WAAW,uBACb,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,YACnB,MAAM,IAAI,gBACN,OAAO;EA8C1B"}
|