abdul-react 0.0.36 → 0.0.38
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/lib/_virtual/index10.js +2 -2
- package/lib/_virtual/index11.js +2 -2
- package/lib/_virtual/index9.js +2 -2
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.js +11 -9
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.js +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.js +51 -7
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js +118 -58
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js.map +1 -1
- package/lib/index.cjs +179 -73
- package/lib/index.cjs.map +1 -1
- package/lib/node_modules/js-beautify/js/src/css/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/css/options.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/options.js +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -40214,12 +40214,15 @@ function reducer(state, action) {
|
|
|
40214
40214
|
updatedData.forEach((rowData, rowIndex) => {
|
|
40215
40215
|
let maxHeight = 32; // Default row height
|
|
40216
40216
|
rowData.forEach((cell, _colIndex) => {
|
|
40217
|
-
if (cell
|
|
40218
|
-
|
|
40219
|
-
|
|
40220
|
-
|
|
40221
|
-
|
|
40222
|
-
|
|
40217
|
+
if (cell) {
|
|
40218
|
+
maxHeight = Math.max(maxHeight, Number(cell.style?.height ?? 32));
|
|
40219
|
+
if (cell.value) {
|
|
40220
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
40221
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
40222
|
+
const lines = String(cell.value).split('\n').length;
|
|
40223
|
+
const cellHeight = lineHeight * lines + 10;
|
|
40224
|
+
maxHeight = Math.max(maxHeight, cellHeight);
|
|
40225
|
+
}
|
|
40223
40226
|
}
|
|
40224
40227
|
});
|
|
40225
40228
|
newRowDimensions[rowIndex] = {
|
|
@@ -40236,10 +40239,13 @@ function reducer(state, action) {
|
|
|
40236
40239
|
let maxWidth = 100; // Default column width
|
|
40237
40240
|
updatedData.forEach((rowData, _rowIndex) => {
|
|
40238
40241
|
const cell = rowData[col];
|
|
40239
|
-
if (cell
|
|
40240
|
-
|
|
40241
|
-
|
|
40242
|
-
|
|
40242
|
+
if (cell) {
|
|
40243
|
+
maxWidth = Math.max(maxWidth, Number(cell.style?.width ?? 100));
|
|
40244
|
+
if (cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
40245
|
+
const font = getFontString(cell);
|
|
40246
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
40247
|
+
maxWidth = Math.max(maxWidth, textWidth);
|
|
40248
|
+
}
|
|
40243
40249
|
}
|
|
40244
40250
|
});
|
|
40245
40251
|
newColumnDimensions[col] = {
|
|
@@ -40343,7 +40349,9 @@ function reducer(state, action) {
|
|
|
40343
40349
|
} = action.payload;
|
|
40344
40350
|
const nextActive = state.active && has$1(state.active, data) ? state.active : null;
|
|
40345
40351
|
const nextSelected = state.selected.normalizeTo(data);
|
|
40346
|
-
|
|
40352
|
+
// Ensure data is a valid array; fallback to empty matrix if invalid
|
|
40353
|
+
const updatedData = Array.isArray(data) && data.every(row => Array.isArray(row)) ? data : [[EmptyCell]];
|
|
40354
|
+
const updatedModel = new Model(state.model.createFormulaParser, updatedData);
|
|
40347
40355
|
// Auto-resize all rows and columns on initial load
|
|
40348
40356
|
let newRowDimensions = {
|
|
40349
40357
|
...state.rowDimensions
|
|
@@ -40352,15 +40360,18 @@ function reducer(state, action) {
|
|
|
40352
40360
|
...state.columnDimensions
|
|
40353
40361
|
};
|
|
40354
40362
|
// Auto-resize all rows
|
|
40355
|
-
|
|
40363
|
+
updatedData.forEach((rowData, rowIndex) => {
|
|
40356
40364
|
let maxHeight = 32; // Default row height
|
|
40357
40365
|
rowData.forEach((cell, _colIndex) => {
|
|
40358
|
-
if (cell
|
|
40359
|
-
|
|
40360
|
-
|
|
40361
|
-
|
|
40362
|
-
|
|
40363
|
-
|
|
40366
|
+
if (cell) {
|
|
40367
|
+
maxHeight = Math.max(maxHeight, Number(cell.style?.height ?? 32));
|
|
40368
|
+
if (cell.value) {
|
|
40369
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
40370
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
40371
|
+
const lines = String(cell.value).split('\n').length;
|
|
40372
|
+
const cellHeight = lineHeight * lines + 10;
|
|
40373
|
+
maxHeight = Math.max(maxHeight, cellHeight);
|
|
40374
|
+
}
|
|
40364
40375
|
}
|
|
40365
40376
|
});
|
|
40366
40377
|
newRowDimensions[rowIndex] = {
|
|
@@ -40372,15 +40383,18 @@ function reducer(state, action) {
|
|
|
40372
40383
|
};
|
|
40373
40384
|
});
|
|
40374
40385
|
// Auto-resize all columns
|
|
40375
|
-
const columnCount =
|
|
40386
|
+
const columnCount = updatedData[0] ? updatedData[0].length : 0;
|
|
40376
40387
|
for (let col = 0; col < columnCount; col++) {
|
|
40377
40388
|
let maxWidth = 100; // Default column width
|
|
40378
|
-
|
|
40389
|
+
updatedData.forEach((rowData, _rowIndex) => {
|
|
40379
40390
|
const cell = rowData[col];
|
|
40380
|
-
if (cell
|
|
40381
|
-
|
|
40382
|
-
|
|
40383
|
-
|
|
40391
|
+
if (cell) {
|
|
40392
|
+
maxWidth = Math.max(maxWidth, Number(cell.style?.width ?? 100));
|
|
40393
|
+
if (cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
40394
|
+
const font = getFontString(cell);
|
|
40395
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
40396
|
+
maxWidth = Math.max(maxWidth, textWidth);
|
|
40397
|
+
}
|
|
40384
40398
|
}
|
|
40385
40399
|
});
|
|
40386
40400
|
newColumnDimensions[col] = {
|
|
@@ -40528,15 +40542,18 @@ function reducer(state, action) {
|
|
|
40528
40542
|
debouncedResize(`resize-${active.row}-${active.column}`, () => {
|
|
40529
40543
|
// Auto-resize row
|
|
40530
40544
|
const rowData = updatedModel.data[active.row] || [];
|
|
40531
|
-
let
|
|
40545
|
+
let maxHeight = 32; // Default row height
|
|
40532
40546
|
// Only check this row's cells for height calculation
|
|
40533
40547
|
rowData.forEach((cell, _colIndex) => {
|
|
40534
|
-
if (cell
|
|
40535
|
-
|
|
40536
|
-
|
|
40537
|
-
|
|
40538
|
-
|
|
40539
|
-
|
|
40548
|
+
if (cell) {
|
|
40549
|
+
maxHeight = Math.max(maxHeight, Number(cell.style?.height ?? 32));
|
|
40550
|
+
if (cell.value) {
|
|
40551
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
40552
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
40553
|
+
const lines = String(cell.value).split('\n').length;
|
|
40554
|
+
const cellHeight = lineHeight * lines + 10;
|
|
40555
|
+
maxHeight = Math.max(maxHeight, cellHeight);
|
|
40556
|
+
}
|
|
40540
40557
|
}
|
|
40541
40558
|
});
|
|
40542
40559
|
newRowDimensions[active.row] = {
|
|
@@ -40544,17 +40561,20 @@ function reducer(state, action) {
|
|
|
40544
40561
|
top: 0,
|
|
40545
40562
|
height: 32
|
|
40546
40563
|
}),
|
|
40547
|
-
height:
|
|
40564
|
+
height: maxHeight
|
|
40548
40565
|
};
|
|
40549
40566
|
// Auto-resize column
|
|
40550
|
-
let
|
|
40567
|
+
let maxWidth = 100; // Default column width
|
|
40551
40568
|
// Only check this column's cells for width calculation
|
|
40552
40569
|
updatedModel.data.forEach((rowData, _rowIndex) => {
|
|
40553
40570
|
const cell = rowData[active.column];
|
|
40554
|
-
if (cell
|
|
40555
|
-
|
|
40556
|
-
|
|
40557
|
-
|
|
40571
|
+
if (cell) {
|
|
40572
|
+
maxWidth = Math.max(maxWidth, Number(cell.style?.width ?? 100));
|
|
40573
|
+
if (cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
40574
|
+
const font = getFontString(cell);
|
|
40575
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
40576
|
+
maxWidth = Math.max(maxWidth, textWidth);
|
|
40577
|
+
}
|
|
40558
40578
|
}
|
|
40559
40579
|
});
|
|
40560
40580
|
newColumnDimensions[active.column] = {
|
|
@@ -40562,7 +40582,7 @@ function reducer(state, action) {
|
|
|
40562
40582
|
left: 0,
|
|
40563
40583
|
width: 100
|
|
40564
40584
|
}),
|
|
40565
|
-
width:
|
|
40585
|
+
width: maxWidth
|
|
40566
40586
|
};
|
|
40567
40587
|
}, 300 // 300ms delay
|
|
40568
40588
|
);
|
|
@@ -40840,6 +40860,48 @@ function reducer(state, action) {
|
|
|
40840
40860
|
}
|
|
40841
40861
|
return state;
|
|
40842
40862
|
}
|
|
40863
|
+
case SET_ROW_HEIGHT:
|
|
40864
|
+
{
|
|
40865
|
+
const {
|
|
40866
|
+
row,
|
|
40867
|
+
height
|
|
40868
|
+
} = action.payload;
|
|
40869
|
+
const prevDimensions = state.rowDimensions[row] || {
|
|
40870
|
+
top: 0};
|
|
40871
|
+
let updatedData = state.model.data; // Start with original data
|
|
40872
|
+
// Update all cells in the row with style.height
|
|
40873
|
+
if (updatedData[row]) {
|
|
40874
|
+
// Check if row exists
|
|
40875
|
+
const len = updatedData?.[row]?.length;
|
|
40876
|
+
for (let col = 0; col < len; col++) {
|
|
40877
|
+
const point = {
|
|
40878
|
+
row,
|
|
40879
|
+
column: col
|
|
40880
|
+
};
|
|
40881
|
+
const cell = get$1(point, updatedData) || EmptyCell;
|
|
40882
|
+
const newCell = {
|
|
40883
|
+
...cell,
|
|
40884
|
+
style: {
|
|
40885
|
+
...cell.style,
|
|
40886
|
+
height // Set the new height in cell style
|
|
40887
|
+
}
|
|
40888
|
+
};
|
|
40889
|
+
updatedData = set$1(point, newCell, updatedData); // Immutable set
|
|
40890
|
+
}
|
|
40891
|
+
}
|
|
40892
|
+
const updatedModel = new Model(state.model.createFormulaParser, updatedData);
|
|
40893
|
+
return {
|
|
40894
|
+
...state,
|
|
40895
|
+
rowDimensions: {
|
|
40896
|
+
...state.rowDimensions,
|
|
40897
|
+
[row]: {
|
|
40898
|
+
top: prevDimensions.top,
|
|
40899
|
+
height
|
|
40900
|
+
}
|
|
40901
|
+
},
|
|
40902
|
+
model: updatedModel
|
|
40903
|
+
};
|
|
40904
|
+
}
|
|
40843
40905
|
case SET_COLUMN_WIDTH:
|
|
40844
40906
|
{
|
|
40845
40907
|
const {
|
|
@@ -41049,12 +41111,15 @@ function reducer(state, action) {
|
|
|
41049
41111
|
const rowData = model.data[row] || [];
|
|
41050
41112
|
let maxHeight = 32;
|
|
41051
41113
|
rowData.forEach((cell, _colIndex) => {
|
|
41052
|
-
if (cell
|
|
41053
|
-
|
|
41054
|
-
|
|
41055
|
-
|
|
41056
|
-
|
|
41057
|
-
|
|
41114
|
+
if (cell) {
|
|
41115
|
+
maxHeight = Math.max(maxHeight, Number(cell.style?.height ?? 32));
|
|
41116
|
+
if (cell.value) {
|
|
41117
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
41118
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
41119
|
+
const lines = String(cell.value).split('\n').length;
|
|
41120
|
+
const cellHeight = lineHeight * lines + 10;
|
|
41121
|
+
maxHeight = Math.max(maxHeight, cellHeight);
|
|
41122
|
+
}
|
|
41058
41123
|
}
|
|
41059
41124
|
});
|
|
41060
41125
|
newRowDimensions[row] = {
|
|
@@ -41070,10 +41135,13 @@ function reducer(state, action) {
|
|
|
41070
41135
|
let maxWidth = 100;
|
|
41071
41136
|
model.data.forEach((rowData, _rowIndex) => {
|
|
41072
41137
|
const cell = rowData[col];
|
|
41073
|
-
if (cell
|
|
41074
|
-
|
|
41075
|
-
|
|
41076
|
-
|
|
41138
|
+
if (cell) {
|
|
41139
|
+
maxWidth = Math.max(maxWidth, Number(cell.style?.width ?? 100));
|
|
41140
|
+
if (cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
41141
|
+
const font = getFontString(cell);
|
|
41142
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
41143
|
+
maxWidth = Math.max(maxWidth, textWidth);
|
|
41144
|
+
}
|
|
41077
41145
|
}
|
|
41078
41146
|
});
|
|
41079
41147
|
newColumnDimensions[col] = {
|
|
@@ -41094,15 +41162,7 @@ function reducer(state, action) {
|
|
|
41094
41162
|
throw new Error('Unknown action');
|
|
41095
41163
|
}
|
|
41096
41164
|
}
|
|
41097
|
-
//
|
|
41098
|
-
// builder.addMatcher(
|
|
41099
|
-
// (action) =>
|
|
41100
|
-
// action.type === Actions.copy.type || action.type === Actions.cut.type,
|
|
41101
|
-
// (state, action) => {
|
|
41102
|
-
// }
|
|
41103
|
-
// );
|
|
41104
|
-
// });
|
|
41105
|
-
// // Shared reducers
|
|
41165
|
+
// Shared reducers
|
|
41106
41166
|
|
|
41107
41167
|
var scheduler = {exports: {}};
|
|
41108
41168
|
|
|
@@ -42442,7 +42502,7 @@ const ColumnIndicator = ({
|
|
|
42442
42502
|
const dispatch = useDispatch();
|
|
42443
42503
|
const excelData = useSelector(state => state.model.data);
|
|
42444
42504
|
const activeCell = useSelector(state => state.active);
|
|
42445
|
-
const
|
|
42505
|
+
const columnWidth = useSelector(state => state.columnDimensions[column]?.width ?? 100);
|
|
42446
42506
|
const matrixData = useSelector(state => state.model.data);
|
|
42447
42507
|
const {
|
|
42448
42508
|
columnCount
|
|
@@ -42471,7 +42531,6 @@ const ColumnIndicator = ({
|
|
|
42471
42531
|
return value;
|
|
42472
42532
|
});
|
|
42473
42533
|
};
|
|
42474
|
-
const columnWidth = useSelector(state => state.columnDimensions[column]?.width ?? minColumnWidth);
|
|
42475
42534
|
const options = React.useMemo(() => {
|
|
42476
42535
|
const checkVisible = cell?.contextDisable?.['Delete Column'] && isCellDataChanged();
|
|
42477
42536
|
return [{
|
|
@@ -42480,7 +42539,7 @@ const ColumnIndicator = ({
|
|
|
42480
42539
|
iconName: 'plus_icon',
|
|
42481
42540
|
action: () => {
|
|
42482
42541
|
updateVisibleRangeEnd('increment');
|
|
42483
|
-
addColumnLeft(
|
|
42542
|
+
addColumnLeft(minimumColumnWidth);
|
|
42484
42543
|
onAddColumn?.(selectedColumn ?? column, true);
|
|
42485
42544
|
},
|
|
42486
42545
|
disableTooltip: 'Column limit reached',
|
|
@@ -42492,7 +42551,7 @@ const ColumnIndicator = ({
|
|
|
42492
42551
|
iconName: 'plus_icon',
|
|
42493
42552
|
action: () => {
|
|
42494
42553
|
updateVisibleRangeEnd('increment');
|
|
42495
|
-
addColumnRight(
|
|
42554
|
+
addColumnRight(minimumColumnWidth);
|
|
42496
42555
|
onAddColumn?.(selectedColumn ?? column, false);
|
|
42497
42556
|
},
|
|
42498
42557
|
disableTooltip: 'Column limit reached',
|
|
@@ -42511,8 +42570,7 @@ const ColumnIndicator = ({
|
|
|
42511
42570
|
visible: checkVisible ? true : false,
|
|
42512
42571
|
disable: false
|
|
42513
42572
|
}] : [])];
|
|
42514
|
-
}, [selectedColumn, cell, addColumnLeft, addColumnRight, deleteColumn,
|
|
42515
|
-
const MIN_COLUMN_WIDTH = minimumColumnWidth || 100;
|
|
42573
|
+
}, [selectedColumn, cell, addColumnLeft, addColumnRight, deleteColumn, minimumColumnWidth, columnCount, maxColLimit, disableDeleteOption, onAddColumn, onDeleteColumn, column, isCellDataChanged]);
|
|
42516
42574
|
const onMouseDrag = React__namespace.useCallback((event, isRight) => {
|
|
42517
42575
|
const getTargetColumn = isRight ? column - 1 : column;
|
|
42518
42576
|
const targetColumn = Math.max(getTargetColumn, 0);
|
|
@@ -42521,7 +42579,7 @@ const ColumnIndicator = ({
|
|
|
42521
42579
|
const initialWidth = Number(columnWidth);
|
|
42522
42580
|
const onMouseMove = moveEvent => {
|
|
42523
42581
|
const delta = moveEvent.clientX - startX;
|
|
42524
|
-
const newWidth = Math.max(
|
|
42582
|
+
const newWidth = Math.max(minimumColumnWidth, initialWidth + delta);
|
|
42525
42583
|
dispatch(setColumnWidth(targetColumn, newWidth));
|
|
42526
42584
|
};
|
|
42527
42585
|
const onMouseUp = () => {
|
|
@@ -42559,6 +42617,10 @@ const ColumnIndicator = ({
|
|
|
42559
42617
|
className: classNames('ff-spreadsheet-header', {
|
|
42560
42618
|
'ff-spreadsheet-header--selected': selected
|
|
42561
42619
|
}),
|
|
42620
|
+
style: {
|
|
42621
|
+
width: `${columnWidth}px`,
|
|
42622
|
+
minWidth: '100px'
|
|
42623
|
+
},
|
|
42562
42624
|
onClick: handleClick,
|
|
42563
42625
|
onContextMenu: contextClick,
|
|
42564
42626
|
tabIndex: 0,
|
|
@@ -42568,7 +42630,7 @@ const ColumnIndicator = ({
|
|
|
42568
42630
|
}), jsxRuntime.jsx("div", {
|
|
42569
42631
|
className: "drag-column-selector drag-column-left",
|
|
42570
42632
|
onMouseDown: e => onMouseDrag(e, false),
|
|
42571
|
-
onDoubleClick: () => dispatch(setColumnPosition(column,
|
|
42633
|
+
onDoubleClick: () => dispatch(setColumnPosition(column, columnWidth)),
|
|
42572
42634
|
onClick: () => activate$1({
|
|
42573
42635
|
row: -1,
|
|
42574
42636
|
column
|
|
@@ -42576,7 +42638,7 @@ const ColumnIndicator = ({
|
|
|
42576
42638
|
}), jsxRuntime.jsx("div", {
|
|
42577
42639
|
className: "drag-column-selector drag-column-right",
|
|
42578
42640
|
onMouseDown: e => onMouseDrag(e, true),
|
|
42579
|
-
onDoubleClick: () => dispatch(setColumnPosition(column,
|
|
42641
|
+
onDoubleClick: () => dispatch(setColumnPosition(column, columnWidth)),
|
|
42580
42642
|
onClick: () => activate$1({
|
|
42581
42643
|
row: -1,
|
|
42582
42644
|
column
|
|
@@ -42732,7 +42794,7 @@ const RowIndicator = ({
|
|
|
42732
42794
|
}),
|
|
42733
42795
|
style: {
|
|
42734
42796
|
height: `${rowHeight}px`,
|
|
42735
|
-
|
|
42797
|
+
minHeight: '32px'
|
|
42736
42798
|
},
|
|
42737
42799
|
onClick: handleClick,
|
|
42738
42800
|
onContextMenu: contextClick,
|
|
@@ -44194,13 +44256,57 @@ const Spreadsheet = /*#__PURE__*/React__namespace.forwardRef(function Spreadshee
|
|
|
44194
44256
|
const initialState = React__namespace.useMemo(() => {
|
|
44195
44257
|
const createParser = props.createFormulaParser || createFormulaParser;
|
|
44196
44258
|
const model = new Model(createParser, props.data);
|
|
44259
|
+
let newRowDimensions = {};
|
|
44260
|
+
let newColumnDimensions = {};
|
|
44261
|
+
props.data.forEach((rowData, rowIndex) => {
|
|
44262
|
+
let maxHeight = DEFAULT_ROW_HEIGHT;
|
|
44263
|
+
rowData.forEach(cell => {
|
|
44264
|
+
if (cell) {
|
|
44265
|
+
const cellHeight = parseFloat(String(cell.style?.height).replace('px', '')) || DEFAULT_ROW_HEIGHT;
|
|
44266
|
+
maxHeight = Math.max(maxHeight, cellHeight);
|
|
44267
|
+
if (cell.value) {
|
|
44268
|
+
const fontSize = parseFloat(String(cell.style?.fontSize).replace('px', '')) || 11;
|
|
44269
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
44270
|
+
const lines = String(cell.value).split('\n').length;
|
|
44271
|
+
const contentHeight = lineHeight * lines + 10;
|
|
44272
|
+
maxHeight = Math.max(maxHeight, contentHeight);
|
|
44273
|
+
}
|
|
44274
|
+
}
|
|
44275
|
+
});
|
|
44276
|
+
newRowDimensions[rowIndex] = {
|
|
44277
|
+
top: 0,
|
|
44278
|
+
height: maxHeight
|
|
44279
|
+
};
|
|
44280
|
+
});
|
|
44281
|
+
const columnCount = props.data[0] ? props.data[0].length : 0;
|
|
44282
|
+
for (let col = 0; col < columnCount; col++) {
|
|
44283
|
+
let maxWidth = DEFAULT_COLUMN_WIDTH;
|
|
44284
|
+
props.data.forEach(rowData => {
|
|
44285
|
+
const cell = rowData[col];
|
|
44286
|
+
if (cell) {
|
|
44287
|
+
const cellWidth = parseFloat(String(cell.style?.width).replace('px', '')) || DEFAULT_COLUMN_WIDTH;
|
|
44288
|
+
maxWidth = Math.max(maxWidth, cellWidth);
|
|
44289
|
+
if (cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
44290
|
+
const font = getFontString(cell);
|
|
44291
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
44292
|
+
maxWidth = Math.max(maxWidth, textWidth);
|
|
44293
|
+
}
|
|
44294
|
+
}
|
|
44295
|
+
});
|
|
44296
|
+
newColumnDimensions[col] = {
|
|
44297
|
+
left: 0,
|
|
44298
|
+
width: maxWidth
|
|
44299
|
+
};
|
|
44300
|
+
}
|
|
44197
44301
|
setSheetChange(prev => !prev);
|
|
44198
44302
|
return {
|
|
44199
44303
|
...INITIAL_STATE,
|
|
44200
44304
|
model,
|
|
44201
|
-
selected: props.selected || INITIAL_STATE.selected
|
|
44305
|
+
selected: props.selected || INITIAL_STATE.selected,
|
|
44306
|
+
rowDimensions: newRowDimensions,
|
|
44307
|
+
columnDimensions: newColumnDimensions
|
|
44202
44308
|
};
|
|
44203
|
-
}, [props.createFormulaParser, props.data, props.selected]);
|
|
44309
|
+
}, [props.createFormulaParser, props.data, props.selected, props.minimumColumnWidth]);
|
|
44204
44310
|
const reducerElements = React__namespace.useReducer(reducer, initialState);
|
|
44205
44311
|
const [state, dispatch] = reducerElements;
|
|
44206
44312
|
const size = React__namespace.useMemo(() => {
|
|
@@ -44313,10 +44419,10 @@ const Spreadsheet = /*#__PURE__*/React__namespace.forwardRef(function Spreadshee
|
|
|
44313
44419
|
prevSelectedPropRef.current = props.selected;
|
|
44314
44420
|
}, [props.selected, setSelection$1]);
|
|
44315
44421
|
// Update data when props.data changes
|
|
44316
|
-
let prevDataPropRef = React__namespace.useRef(
|
|
44422
|
+
let prevDataPropRef = React__namespace.useRef();
|
|
44317
44423
|
React__namespace.useEffect(() => {
|
|
44318
44424
|
setEditable(editable$1);
|
|
44319
|
-
if (props.data !== prevDataPropRef.current) {
|
|
44425
|
+
if (prevDataPropRef.current !== undefined && props.data !== prevDataPropRef.current) {
|
|
44320
44426
|
setData$1(props.data);
|
|
44321
44427
|
}
|
|
44322
44428
|
prevDataPropRef.current = props.data;
|
|
@@ -44481,7 +44587,7 @@ const Spreadsheet = /*#__PURE__*/React__namespace.forwardRef(function Spreadshee
|
|
|
44481
44587
|
requestAnimationFrame(() => {
|
|
44482
44588
|
let scrollTop = 0;
|
|
44483
44589
|
for (let r = 0; r <= row; r++) {
|
|
44484
|
-
scrollTop += state.rowDimensions
|
|
44590
|
+
scrollTop += state.rowDimensions[r]?.height || DEFAULT_ROW_HEIGHT;
|
|
44485
44591
|
}
|
|
44486
44592
|
requestAnimationFrame(() => {
|
|
44487
44593
|
if (!rootRef.current) return;
|
|
@@ -44500,7 +44606,7 @@ const Spreadsheet = /*#__PURE__*/React__namespace.forwardRef(function Spreadshee
|
|
|
44500
44606
|
requestAnimationFrame(() => {
|
|
44501
44607
|
let scrollLeft = 0;
|
|
44502
44608
|
for (let c = 0; c <= column; c++) {
|
|
44503
|
-
scrollLeft += state.columnDimensions
|
|
44609
|
+
scrollLeft += state.columnDimensions[c]?.width || DEFAULT_COLUMN_WIDTH;
|
|
44504
44610
|
}
|
|
44505
44611
|
requestAnimationFrame(() => {
|
|
44506
44612
|
if (!rootRef.current) return;
|