abdul-react 0.0.33 → 0.0.36
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/ComponentProps/TreeNodeProps.d.ts +1 -0
- package/lib/_virtual/index10.js +2 -2
- package/lib/_virtual/index11.js +2 -2
- package/lib/_virtual/index9.js +2 -2
- package/lib/assets/icons/fia_ai_icon.svg.js +846 -0
- package/lib/assets/icons/fia_ai_icon.svg.js.map +1 -0
- package/lib/assets/icons/mac_white_icon.svg.js +6 -0
- package/lib/assets/icons/mac_white_icon.svg.js.map +1 -0
- package/lib/assets/icons/maximize_livetesting.svg.js +6 -0
- package/lib/assets/icons/maximize_livetesting.svg.js.map +1 -0
- package/lib/assets/icons/minimize_tree.svg.js +6 -0
- package/lib/assets/icons/minimize_tree.svg.js.map +1 -0
- package/lib/assets/icons/timer_icon.svg.js +6 -0
- package/lib/assets/icons/timer_icon.svg.js.map +1 -0
- package/lib/assets/icons/view_access_icon.svg.js +1 -1
- package/lib/assets/icons/view_access_icon.svg.js.map +1 -1
- package/lib/assets/icons/windows_blue_icon.svg.js +6 -0
- package/lib/assets/icons/windows_blue_icon.svg.js.map +1 -0
- package/lib/components/AllProjectsDropdown/AllProjectsDropdown.js +53 -13
- package/lib/components/AllProjectsDropdown/AllProjectsDropdown.js.map +1 -1
- package/lib/components/AppHeader/AppHeader.js +37 -4
- package/lib/components/AppHeader/AppHeader.js.map +1 -1
- package/lib/components/AppHeader/types.d.ts +11 -0
- package/lib/components/Comments/childComment/ChildComment.js +6 -6
- package/lib/components/Comments/childComment/ChildComment.js.map +1 -1
- package/lib/components/ConditionalDropdown/ConditionalDropdown.js +17 -5
- package/lib/components/ConditionalDropdown/ConditionalDropdown.js.map +1 -1
- package/lib/components/ConditionalDropdown/OptionsDropdown.js +16 -6
- package/lib/components/ConditionalDropdown/OptionsDropdown.js.map +1 -1
- package/lib/components/ConditionalDropdown/types.d.ts +12 -0
- package/lib/components/CreateVariable/CreateVariableSlider.js +3 -2
- package/lib/components/CreateVariable/CreateVariableSlider.js.map +1 -1
- package/lib/components/CreateVariable/types.d.ts +3 -2
- package/lib/components/DragAndDrop/DragAndDrop.d.ts +2 -0
- package/lib/components/DragAndDrop/DragAndDrop.js +3 -1
- package/lib/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib/components/Drawer/Drawer.js +7 -4
- package/lib/components/Drawer/Drawer.js.map +1 -1
- package/lib/components/EditLabel/EditLabel.js +2 -2
- package/lib/components/EditLabel/EditLabel.js.map +1 -1
- package/lib/components/Editor/Editor.js +12 -5
- package/lib/components/Editor/Editor.js.map +1 -1
- package/lib/components/Editor/VariableDropdown.js +7 -7
- package/lib/components/Editor/VariableDropdown.js.map +1 -1
- package/lib/components/Editor/types.d.ts +12 -0
- package/lib/components/Excel/Data.d.ts +8 -0
- package/lib/components/Excel/Data.js +48 -6
- package/lib/components/Excel/Data.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.js +28 -14
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Cell.js +8 -2
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Cell.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.js +44 -20
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Copied.d.ts +0 -3
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Copied.js +4 -8
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Copied.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataEditor.js +45 -2
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataEditor.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.js +5 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.js +11 -10
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Selected.d.ts +0 -3
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Selected.js +5 -9
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Selected.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.js +160 -189
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Table.js +9 -13
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Table.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.d.ts +17 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.js +21 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/index.js +1 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/index.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js +400 -54
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.js +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +3 -5
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.d.ts +10 -18
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.js +157 -64
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.js.map +1 -1
- package/lib/components/Excel/ExcelToolBar/ExcelToolBar.js +26 -25
- package/lib/components/Excel/ExcelToolBar/ExcelToolBar.js.map +1 -1
- package/lib/components/Excel/Types.d.ts +2 -0
- package/lib/components/Excel/dataConversion.js +17 -4
- package/lib/components/Excel/dataConversion.js.map +1 -1
- package/lib/components/Icon/Icon.js +14 -1
- package/lib/components/Icon/Icon.js.map +1 -1
- package/lib/components/Icon/iconList.js +18 -6
- package/lib/components/Icon/iconList.js.map +1 -1
- package/lib/components/Input/Input.js +3 -2
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/Input/types.d.ts +1 -0
- package/lib/components/MachineInputField/MachineInputField.js +2 -2
- package/lib/components/MachineInputField/MachineInputField.js.map +1 -1
- package/lib/components/NLPInput/NlpInput.js +1 -1
- package/lib/components/NLPInput/components/NlpDropDown/NlpDropdown.js +1 -1
- package/lib/components/NLPInput/components/NlpDropDown/NlpDropdown.js.map +1 -1
- package/lib/components/PrePostTable/PrePostTable.js +2 -0
- package/lib/components/PrePostTable/PrePostTable.js.map +1 -1
- package/lib/components/Prompt/Prompt.js +17 -2
- package/lib/components/Prompt/Prompt.js.map +1 -1
- package/lib/components/Prompt/types.d.ts +4 -0
- package/lib/components/Select/Select.js +3 -1
- package/lib/components/Select/Select.js.map +1 -1
- package/lib/components/Select/components/Dropdown.js +2 -1
- package/lib/components/Select/components/Dropdown.js.map +1 -1
- package/lib/components/Select/types.d.ts +3 -2
- package/lib/components/SequentialConnectingBranch/SequentialConnectingBranch.js +14 -9
- package/lib/components/SequentialConnectingBranch/SequentialConnectingBranch.js.map +1 -1
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.js +4 -4
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.js.map +1 -1
- package/lib/components/StepsLandingTable/Components/StepGroupAccordions.js +92 -69
- package/lib/components/StepsLandingTable/Components/StepGroupAccordions.js.map +1 -1
- package/lib/components/StepsLandingTable/Components/StepInnerTable.d.ts +1 -1
- package/lib/components/StepsLandingTable/Components/StepInnerTable.js +189 -15
- package/lib/components/StepsLandingTable/Components/StepInnerTable.js.map +1 -1
- package/lib/components/StepsLandingTable/Components/StepTableMainRow.js +20 -4
- package/lib/components/StepsLandingTable/Components/StepTableMainRow.js.map +1 -1
- package/lib/components/StepsLandingTable/Components/Types.d.ts +6 -0
- package/lib/components/StepsLandingTable/StepLandingTable.js +12 -5
- package/lib/components/StepsLandingTable/StepLandingTable.js.map +1 -1
- package/lib/components/StepsLandingTable/types.d.ts +3 -0
- package/lib/components/Table/Table.js +184 -42
- package/lib/components/Table/Table.js.map +1 -1
- package/lib/components/TableTreeFn/TableTreeFn.js +30 -0
- package/lib/components/TableTreeFn/TableTreeFn.js.map +1 -1
- package/lib/components/TableWithAccordion/TableWithAccordion.js +4 -3
- package/lib/components/TableWithAccordion/TableWithAccordion.js.map +1 -1
- package/lib/components/Toggle/Toggle.js +6 -2
- package/lib/components/Toggle/Toggle.js.map +1 -1
- package/lib/components/variableSuggestionInputDropDown/OptionsDropdown.js +7 -5
- package/lib/components/variableSuggestionInputDropDown/OptionsDropdown.js.map +1 -1
- package/lib/components/variableSuggestionInputDropDown/VariableSuggestionInputDropDown.js +1 -1
- package/lib/hooks/useFileDropzone.js +45 -17
- package/lib/hooks/useFileDropzone.js.map +1 -1
- package/lib/index.cjs +2737 -651
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +52 -4
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.js +106 -0
- package/lib/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.js.map +1 -0
- package/lib/node_modules/js-beautify/js/src/css/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/beautifier.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/options.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/beautifier.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/lib/styles.css +1 -1
- package/lib/styles.css.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/useDeviceType/useDeviceType.d.ts +6 -0
- package/lib/utils/useDeviceType/useDeviceType.js +27 -0
- package/lib/utils/useDeviceType/useDeviceType.js.map +1 -0
- package/package.json +2 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PointRange } from './point-range.js';
|
|
2
|
-
import {
|
|
2
|
+
import { get, set, split, getSize, unset, pad, entries, has } from './matrix.js';
|
|
3
3
|
import { ORIGIN } from './point.js';
|
|
4
4
|
import { EmptySelection, RangeSelection, EntireWorksheetSelection, EntireColumnsSelection, EntireRowsSelection } from './selection.js';
|
|
5
|
-
import { EmptyCell, isPasteAllowed, isActive, deleteColumnDimension, deleteRowDimension, insertColumnDimension, insertRowDimension } from './util.js';
|
|
6
|
-
import { COMMIT, DRAG_END, ON_MOUSE_UP, DRAG_START, SET_COLUMN_POSITION,
|
|
5
|
+
import { getFontString, measureText, EmptyCell, isPasteAllowed, debouncedResize, isActive, deleteColumnDimension, deleteRowDimension, insertColumnDimension, insertRowDimension } from './util.js';
|
|
6
|
+
import { BATCH_RESIZE, COMMIT, DRAG_END, ON_MOUSE_UP, DRAG_START, SET_COLUMN_POSITION, SET_COLUMN_WIDTH, KEY_DOWN, KEY_PRESS, BLUR, CLEAR, batchResize, VIEW, EDIT, PASTE, CUT, COPY, SET_CELL_DIMENSIONS, SET_CELL_DATA, ACTIVATE, SELECT, SET_SELECTION, SELECT_ENTIRE_WORKSHEET, SELECT_ENTIRE_COLUMN, SELECT_ENTIRE_ROW, SET_CREATE_FORMULA_PARSER, SET_DATA, FORMATE_PAINTER, BACKGROUND_COLOR, COLOR, TEXT_ALIGN, FONT_FAMILY, FONT_SIZE, UNDERLINE_TYPE, BORDER_TYPE, ITALIC, BOLD, DELETE_COLUMN, DELETE_ROW, ADD_COLUMN_RIGHT, ADD_COLUMN_LEFT, ADD_ROW_BOTTOM, ADD_ROW_TOP, SET_AUTO_FILL, SET_EDITABLE } from './actions.js';
|
|
7
7
|
import { Model, updateCellValue } from './engine/engine.js';
|
|
8
8
|
import { createFormulaParser } from './engine/formula.js';
|
|
9
9
|
import { commit, dragEndFormatePainter, dragEndAutoFill, cellFormatePainter, isActiveReadOnly, getKeyDownHandler, edit, clear, blur, view, applyFormatePainter, applyBackgroundColorToCells, applyColorToCells, applyTextAlign, applyFontFamily, applyFontSize, applyUnderlineToCells, applyBorderToCells, applyItalicToCells, applyBoldToCells } from './reducerFunctions.js';
|
|
@@ -112,17 +112,26 @@ function reducer(state, action) {
|
|
|
112
112
|
if (checkEmpty(selectedRow)) {
|
|
113
113
|
return state;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
const insertIndex = (row ?? selectedRow) + 1;
|
|
116
116
|
let updatedData = [...model.data];
|
|
117
117
|
const newRow = Array(updatedData[0]?.length || 0).fill(EmptyCell);
|
|
118
|
-
updatedData.splice(
|
|
118
|
+
updatedData.splice(insertIndex, 0, newRow);
|
|
119
119
|
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
|
120
|
+
const newSelectedRow = insertIndex;
|
|
121
|
+
const newSelectedColumn = selectedColumn ?? 0;
|
|
122
|
+
const newActive = updatedData.length > 0 ? {
|
|
123
|
+
row: newSelectedRow,
|
|
124
|
+
column: newSelectedColumn
|
|
125
|
+
} : null;
|
|
126
|
+
const newSelected = updatedData.length > 0 ? new EntireRowsSelection(newSelectedRow, newSelectedRow) : new EmptySelection();
|
|
120
127
|
return {
|
|
121
128
|
...state,
|
|
122
129
|
model: updatedModel,
|
|
123
|
-
selectedRow:
|
|
124
|
-
selectedColumn:
|
|
125
|
-
|
|
130
|
+
selectedRow: newSelectedRow,
|
|
131
|
+
selectedColumn: newSelectedColumn,
|
|
132
|
+
selected: newSelected,
|
|
133
|
+
active: newActive,
|
|
134
|
+
rowDimensions: insertRowDimension(rowDimensions, insertIndex, 32)
|
|
126
135
|
};
|
|
127
136
|
}
|
|
128
137
|
case ADD_COLUMN_LEFT:
|
|
@@ -169,18 +178,27 @@ function reducer(state, action) {
|
|
|
169
178
|
if (checkEmpty(column ?? selectedColumn)) {
|
|
170
179
|
return state;
|
|
171
180
|
}
|
|
172
|
-
|
|
181
|
+
const insertIndex = (column ?? selectedColumn) + 1;
|
|
173
182
|
let updatedData = [...model.data];
|
|
174
183
|
updatedData = updatedData.map(row => {
|
|
175
|
-
return [...row.slice(0,
|
|
184
|
+
return [...row.slice(0, insertIndex), EmptyCell, ...row.slice(insertIndex)];
|
|
176
185
|
});
|
|
177
186
|
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
|
187
|
+
const newSelectedRow = selectedRow ?? 0;
|
|
188
|
+
const newSelectedColumn = insertIndex;
|
|
189
|
+
const newActive = updatedData.length > 0 ? {
|
|
190
|
+
row: newSelectedRow,
|
|
191
|
+
column: newSelectedColumn
|
|
192
|
+
} : null;
|
|
193
|
+
const newSelected = updatedData.length > 0 ? new EntireColumnsSelection(newSelectedColumn, newSelectedColumn) : new EmptySelection();
|
|
178
194
|
return {
|
|
179
195
|
...state,
|
|
180
196
|
model: updatedModel,
|
|
181
|
-
selectedRow:
|
|
182
|
-
selectedColumn:
|
|
183
|
-
|
|
197
|
+
selectedRow: newSelectedRow,
|
|
198
|
+
selectedColumn: newSelectedColumn,
|
|
199
|
+
selected: newSelected,
|
|
200
|
+
active: newActive,
|
|
201
|
+
columnDimensions: insertColumnDimension(columnDimensions, insertIndex, columnWidth)
|
|
184
202
|
};
|
|
185
203
|
}
|
|
186
204
|
case DELETE_ROW:
|
|
@@ -189,14 +207,13 @@ function reducer(state, action) {
|
|
|
189
207
|
selectedRow,
|
|
190
208
|
selectedColumn,
|
|
191
209
|
model,
|
|
192
|
-
rowDimensions
|
|
210
|
+
rowDimensions,
|
|
211
|
+
copied
|
|
193
212
|
} = state;
|
|
194
213
|
const {
|
|
195
214
|
row
|
|
196
215
|
} = action;
|
|
197
|
-
if (checkEmpty(selectedRow))
|
|
198
|
-
return state;
|
|
199
|
-
}
|
|
216
|
+
if (checkEmpty(selectedRow)) return state;
|
|
200
217
|
const deleteIndex = row ?? selectedRow;
|
|
201
218
|
let updatedData = [...model.data];
|
|
202
219
|
updatedData.splice(deleteIndex, 1);
|
|
@@ -208,6 +225,10 @@ function reducer(state, action) {
|
|
|
208
225
|
column: newSelectedColumn
|
|
209
226
|
} : null;
|
|
210
227
|
const newSelected = updatedData.length > 0 ? new EntireRowsSelection(newSelectedRow, newSelectedRow) : new EmptySelection();
|
|
228
|
+
let newCopied = copied;
|
|
229
|
+
if (copied && copied.start.row <= deleteIndex && copied.end.row >= deleteIndex) {
|
|
230
|
+
newCopied = null;
|
|
231
|
+
}
|
|
211
232
|
return {
|
|
212
233
|
...state,
|
|
213
234
|
model: updatedModel,
|
|
@@ -215,6 +236,7 @@ function reducer(state, action) {
|
|
|
215
236
|
selectedColumn: newSelectedColumn,
|
|
216
237
|
selected: newSelected,
|
|
217
238
|
active: newActive,
|
|
239
|
+
copied: newCopied,
|
|
218
240
|
rowDimensions: deleteRowDimension(rowDimensions, deleteIndex)
|
|
219
241
|
};
|
|
220
242
|
}
|
|
@@ -224,7 +246,8 @@ function reducer(state, action) {
|
|
|
224
246
|
selectedRow,
|
|
225
247
|
selectedColumn,
|
|
226
248
|
model,
|
|
227
|
-
columnDimensions
|
|
249
|
+
columnDimensions,
|
|
250
|
+
copied
|
|
228
251
|
} = state;
|
|
229
252
|
const {
|
|
230
253
|
column
|
|
@@ -233,13 +256,25 @@ function reducer(state, action) {
|
|
|
233
256
|
const deleteIndex = column ?? selectedColumn;
|
|
234
257
|
const updatedData = model.data.map(row => row.filter((_, cellIndex) => cellIndex !== deleteIndex));
|
|
235
258
|
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
|
236
|
-
const newSelectedRow = selectedRow
|
|
259
|
+
const newSelectedRow = selectedRow !== null ? selectedRow : 0;
|
|
237
260
|
const newSelectedColumn = deleteIndex > 0 ? deleteIndex - 1 : 0;
|
|
261
|
+
const newActive = updatedData.length > 0 ? {
|
|
262
|
+
row: newSelectedRow,
|
|
263
|
+
column: newSelectedColumn
|
|
264
|
+
} : null;
|
|
265
|
+
const newSelected = updatedData.length > 0 ? new EntireColumnsSelection(newSelectedColumn, newSelectedColumn) : new EmptySelection();
|
|
266
|
+
let newCopied = copied;
|
|
267
|
+
if (copied && copied.start.column <= deleteIndex && copied.end.column >= deleteIndex) {
|
|
268
|
+
newCopied = null;
|
|
269
|
+
}
|
|
238
270
|
return {
|
|
239
271
|
...state,
|
|
240
272
|
model: updatedModel,
|
|
241
273
|
selectedRow: newSelectedRow,
|
|
242
274
|
selectedColumn: newSelectedColumn,
|
|
275
|
+
selected: newSelected,
|
|
276
|
+
active: newActive,
|
|
277
|
+
copied: newCopied,
|
|
243
278
|
columnDimensions: deleteColumnDimension(columnDimensions, deleteIndex)
|
|
244
279
|
};
|
|
245
280
|
}
|
|
@@ -290,9 +325,59 @@ function reducer(state, action) {
|
|
|
290
325
|
} = action.payload;
|
|
291
326
|
const selectedRange = state.selected.toRange(state.model.data);
|
|
292
327
|
const updatedData = applyFontSize(state.model.data, selectedRange, value, state.editable);
|
|
328
|
+
const updatedModel = new Model(state.model.createFormulaParser, updatedData);
|
|
329
|
+
// Auto-resize all rows and columns on initial load
|
|
330
|
+
let newRowDimensions = {
|
|
331
|
+
...state.rowDimensions
|
|
332
|
+
};
|
|
333
|
+
let newColumnDimensions = {
|
|
334
|
+
...state.columnDimensions
|
|
335
|
+
};
|
|
336
|
+
// Auto-resize all rows
|
|
337
|
+
updatedData.forEach((rowData, rowIndex) => {
|
|
338
|
+
let maxHeight = 32; // Default row height
|
|
339
|
+
rowData.forEach((cell, _colIndex) => {
|
|
340
|
+
if (cell && cell.value) {
|
|
341
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
342
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
343
|
+
const lines = String(cell.value).split('\n').length;
|
|
344
|
+
const cellHeight = lineHeight * lines + 10;
|
|
345
|
+
maxHeight = Math.max(Number(cell?.style?.height) ?? maxHeight, cellHeight);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
newRowDimensions[rowIndex] = {
|
|
349
|
+
...(newRowDimensions[rowIndex] || {
|
|
350
|
+
top: 0,
|
|
351
|
+
height: 32
|
|
352
|
+
}),
|
|
353
|
+
height: maxHeight
|
|
354
|
+
};
|
|
355
|
+
});
|
|
356
|
+
// Auto-resize all columns
|
|
357
|
+
const columnCount = updatedData[0] ? updatedData[0].length : 0;
|
|
358
|
+
for (let col = 0; col < columnCount; col++) {
|
|
359
|
+
let maxWidth = 100; // Default column width
|
|
360
|
+
updatedData.forEach((rowData, _rowIndex) => {
|
|
361
|
+
const cell = rowData[col];
|
|
362
|
+
if (cell && cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
363
|
+
const font = getFontString(cell);
|
|
364
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
365
|
+
maxWidth = Math.max(Number(cell?.style?.width) ?? maxWidth, textWidth);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
newColumnDimensions[col] = {
|
|
369
|
+
...(newColumnDimensions[col] || {
|
|
370
|
+
left: 0,
|
|
371
|
+
width: 100
|
|
372
|
+
}),
|
|
373
|
+
width: maxWidth
|
|
374
|
+
};
|
|
375
|
+
}
|
|
293
376
|
return {
|
|
294
377
|
...state,
|
|
295
|
-
model:
|
|
378
|
+
model: updatedModel,
|
|
379
|
+
rowDimensions: newRowDimensions,
|
|
380
|
+
columnDimensions: newColumnDimensions
|
|
296
381
|
};
|
|
297
382
|
}
|
|
298
383
|
case FONT_FAMILY:
|
|
@@ -381,11 +466,61 @@ function reducer(state, action) {
|
|
|
381
466
|
} = action.payload;
|
|
382
467
|
const nextActive = state.active && has(state.active, data) ? state.active : null;
|
|
383
468
|
const nextSelected = state.selected.normalizeTo(data);
|
|
469
|
+
const updatedModel = new Model(state.model.createFormulaParser, data);
|
|
470
|
+
// Auto-resize all rows and columns on initial load
|
|
471
|
+
let newRowDimensions = {
|
|
472
|
+
...state.rowDimensions
|
|
473
|
+
};
|
|
474
|
+
let newColumnDimensions = {
|
|
475
|
+
...state.columnDimensions
|
|
476
|
+
};
|
|
477
|
+
// Auto-resize all rows
|
|
478
|
+
data.forEach((rowData, rowIndex) => {
|
|
479
|
+
let maxHeight = 32; // Default row height
|
|
480
|
+
rowData.forEach((cell, _colIndex) => {
|
|
481
|
+
if (cell && cell.value) {
|
|
482
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
483
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
484
|
+
const lines = String(cell.value).split('\n').length;
|
|
485
|
+
const cellHeight = lineHeight * lines + 10;
|
|
486
|
+
maxHeight = Math.max(Number(cell?.style?.height) ?? maxHeight, cellHeight);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
newRowDimensions[rowIndex] = {
|
|
490
|
+
...(newRowDimensions[rowIndex] || {
|
|
491
|
+
top: 0,
|
|
492
|
+
height: 32
|
|
493
|
+
}),
|
|
494
|
+
height: maxHeight
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
// Auto-resize all columns
|
|
498
|
+
const columnCount = data[0] ? data[0].length : 0;
|
|
499
|
+
for (let col = 0; col < columnCount; col++) {
|
|
500
|
+
let maxWidth = 100; // Default column width
|
|
501
|
+
data.forEach((rowData, _rowIndex) => {
|
|
502
|
+
const cell = rowData[col];
|
|
503
|
+
if (cell && cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
504
|
+
const font = getFontString(cell);
|
|
505
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
506
|
+
maxWidth = Math.max(Number(cell?.style?.width) ?? maxWidth, textWidth);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
newColumnDimensions[col] = {
|
|
510
|
+
...(newColumnDimensions[col] || {
|
|
511
|
+
left: 0,
|
|
512
|
+
width: 100
|
|
513
|
+
}),
|
|
514
|
+
width: maxWidth
|
|
515
|
+
};
|
|
516
|
+
}
|
|
384
517
|
return {
|
|
385
518
|
...state,
|
|
386
|
-
model:
|
|
519
|
+
model: updatedModel,
|
|
387
520
|
active: nextActive,
|
|
388
|
-
selected: nextSelected
|
|
521
|
+
selected: nextSelected,
|
|
522
|
+
rowDimensions: newRowDimensions,
|
|
523
|
+
columnDimensions: newColumnDimensions
|
|
389
524
|
};
|
|
390
525
|
}
|
|
391
526
|
case SET_CREATE_FORMULA_PARSER:
|
|
@@ -502,9 +637,64 @@ function reducer(state, action) {
|
|
|
502
637
|
if (isActiveReadOnly(state) || !state.editable) {
|
|
503
638
|
return state;
|
|
504
639
|
}
|
|
640
|
+
const updatedModel = updateCellValue(state.model, active, cellData);
|
|
641
|
+
// Only auto-resize if the cell value actually changed
|
|
642
|
+
const previousCell = get(active, state.model.data);
|
|
643
|
+
const valueChanged = previousCell?.value !== cellData.value;
|
|
644
|
+
let newRowDimensions = {
|
|
645
|
+
...state.rowDimensions
|
|
646
|
+
};
|
|
647
|
+
let newColumnDimensions = {
|
|
648
|
+
...state.columnDimensions
|
|
649
|
+
};
|
|
650
|
+
if (valueChanged) {
|
|
651
|
+
debouncedResize(`resize-${active.row}-${active.column}`, () => {
|
|
652
|
+
// Auto-resize row
|
|
653
|
+
const rowData = updatedModel.data[active.row] || [];
|
|
654
|
+
let maxRowHeight = 32; // Default row height
|
|
655
|
+
// Only check this row's cells for height calculation
|
|
656
|
+
rowData.forEach((cell, _colIndex) => {
|
|
657
|
+
if (cell && cell.value) {
|
|
658
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
659
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
660
|
+
const lines = String(cell.value).split('\n').length;
|
|
661
|
+
const cellHeight = lineHeight * lines + 10;
|
|
662
|
+
maxRowHeight = Math.max(Number(cell?.style?.height) ?? maxRowHeight, cellHeight);
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
newRowDimensions[active.row] = {
|
|
666
|
+
...(newRowDimensions[active.row] || {
|
|
667
|
+
top: 0,
|
|
668
|
+
height: 32
|
|
669
|
+
}),
|
|
670
|
+
height: maxRowHeight
|
|
671
|
+
};
|
|
672
|
+
// Auto-resize column
|
|
673
|
+
let maxColWidth = 100; // Default column width
|
|
674
|
+
// Only check this column's cells for width calculation
|
|
675
|
+
updatedModel.data.forEach((rowData, _rowIndex) => {
|
|
676
|
+
const cell = rowData[active.column];
|
|
677
|
+
if (cell && cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
678
|
+
const font = getFontString(cell);
|
|
679
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
680
|
+
maxColWidth = Math.max(Number(cell?.style?.width) ?? maxColWidth, textWidth);
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
newColumnDimensions[active.column] = {
|
|
684
|
+
...(newColumnDimensions[active.column] || {
|
|
685
|
+
left: 0,
|
|
686
|
+
width: 100
|
|
687
|
+
}),
|
|
688
|
+
width: maxColWidth
|
|
689
|
+
};
|
|
690
|
+
}, 300 // 300ms delay
|
|
691
|
+
);
|
|
692
|
+
}
|
|
505
693
|
return {
|
|
506
694
|
...state,
|
|
507
|
-
model:
|
|
695
|
+
model: updatedModel,
|
|
696
|
+
rowDimensions: newRowDimensions,
|
|
697
|
+
columnDimensions: newColumnDimensions,
|
|
508
698
|
lastChanged: active
|
|
509
699
|
};
|
|
510
700
|
}
|
|
@@ -514,28 +704,61 @@ function reducer(state, action) {
|
|
|
514
704
|
point,
|
|
515
705
|
dimensions
|
|
516
706
|
} = action.payload;
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
707
|
+
let newState = {
|
|
708
|
+
...state
|
|
709
|
+
};
|
|
710
|
+
let updatedData = state.model.data;
|
|
711
|
+
const cell = get(point, updatedData) || EmptyCell;
|
|
712
|
+
const newStyle = {
|
|
713
|
+
...cell.style
|
|
714
|
+
};
|
|
715
|
+
let styleChanged = false;
|
|
716
|
+
if (dimensions.width !== undefined) {
|
|
717
|
+
newStyle.width = dimensions.width;
|
|
718
|
+
styleChanged = true;
|
|
521
719
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
720
|
+
if (dimensions.height !== undefined) {
|
|
721
|
+
newStyle.height = dimensions.height;
|
|
722
|
+
styleChanged = true;
|
|
723
|
+
}
|
|
724
|
+
if (styleChanged) {
|
|
725
|
+
const newCell = {
|
|
726
|
+
...cell,
|
|
727
|
+
style: newStyle
|
|
728
|
+
};
|
|
729
|
+
updatedData = set(point, newCell, updatedData);
|
|
730
|
+
}
|
|
731
|
+
const updatedModel = new Model(state.model.createFormulaParser, updatedData);
|
|
732
|
+
// Update column dimensions if width/left provided
|
|
733
|
+
if (dimensions.width !== undefined && dimensions.left !== undefined) {
|
|
734
|
+
newState = {
|
|
735
|
+
...newState,
|
|
736
|
+
columnDimensions: {
|
|
737
|
+
...state.columnDimensions,
|
|
738
|
+
[point.column]: {
|
|
739
|
+
left: dimensions.left,
|
|
740
|
+
width: dimensions.width
|
|
741
|
+
}
|
|
529
742
|
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
// Update row dimensions if height/top provided
|
|
746
|
+
if (dimensions.top !== undefined && dimensions.height !== undefined) {
|
|
747
|
+
newState = {
|
|
748
|
+
...newState,
|
|
749
|
+
rowDimensions: {
|
|
750
|
+
...state.rowDimensions,
|
|
751
|
+
[point.row]: {
|
|
752
|
+
top: dimensions.top,
|
|
753
|
+
height: dimensions.height
|
|
754
|
+
}
|
|
536
755
|
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
return {
|
|
759
|
+
...newState,
|
|
760
|
+
model: updatedModel
|
|
761
|
+
}; // Include updated model
|
|
539
762
|
}
|
|
540
763
|
case COPY:
|
|
541
764
|
case CUT:
|
|
@@ -665,9 +888,36 @@ function reducer(state, action) {
|
|
|
665
888
|
{
|
|
666
889
|
return view(state);
|
|
667
890
|
}
|
|
891
|
+
// In reducer.ts, update the CLEAR action for better performance
|
|
668
892
|
case CLEAR:
|
|
669
893
|
{
|
|
670
|
-
|
|
894
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
|
895
|
+
if (!selectedRange || !state.editable) {
|
|
896
|
+
return state;
|
|
897
|
+
}
|
|
898
|
+
let updatedData = state.model.data;
|
|
899
|
+
const commit = [];
|
|
900
|
+
// Track which rows and columns were cleared
|
|
901
|
+
const clearedRows = new Set();
|
|
902
|
+
const clearedColumns = new Set();
|
|
903
|
+
for (const point of selectedRange) {
|
|
904
|
+
const cell = get(point, updatedData) || null;
|
|
905
|
+
commit.push({
|
|
906
|
+
prevCell: cell,
|
|
907
|
+
nextCell: null
|
|
908
|
+
});
|
|
909
|
+
updatedData = set(point, EmptyCell, updatedData);
|
|
910
|
+
// Track cleared rows and columns
|
|
911
|
+
clearedRows.add(point.row);
|
|
912
|
+
clearedColumns.add(point.column);
|
|
913
|
+
}
|
|
914
|
+
const updatedModel = new Model(state.model.createFormulaParser, updatedData);
|
|
915
|
+
// Use batch resize for better performance
|
|
916
|
+
return reducer({
|
|
917
|
+
...state,
|
|
918
|
+
model: updatedModel,
|
|
919
|
+
lastCommit: commit
|
|
920
|
+
}, batchResize(Array.from(clearedRows), Array.from(clearedColumns)));
|
|
671
921
|
}
|
|
672
922
|
case BLUR:
|
|
673
923
|
{
|
|
@@ -713,23 +963,56 @@ function reducer(state, action) {
|
|
|
713
963
|
}
|
|
714
964
|
return state;
|
|
715
965
|
}
|
|
716
|
-
case
|
|
966
|
+
case SET_COLUMN_WIDTH:
|
|
717
967
|
{
|
|
718
968
|
const {
|
|
719
|
-
|
|
720
|
-
|
|
969
|
+
column,
|
|
970
|
+
width
|
|
721
971
|
} = action.payload;
|
|
722
|
-
const prevDimensions = state.
|
|
723
|
-
|
|
972
|
+
const prevDimensions = state.columnDimensions[column] || {
|
|
973
|
+
left: 0};
|
|
974
|
+
// Narrow first
|
|
975
|
+
if (!state.model.data) {
|
|
976
|
+
return {
|
|
977
|
+
...state,
|
|
978
|
+
columnDimensions: {
|
|
979
|
+
...state.columnDimensions,
|
|
980
|
+
[column]: {
|
|
981
|
+
left: prevDimensions.left,
|
|
982
|
+
width
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
let updatedData = state.model.data ?? [];
|
|
988
|
+
for (let r = 0; r < updatedData.length; r++) {
|
|
989
|
+
if (updatedData[r] && updatedData?.[r]?.length > column) {
|
|
990
|
+
const point = {
|
|
991
|
+
row: r,
|
|
992
|
+
column
|
|
993
|
+
};
|
|
994
|
+
const cell = get(point, updatedData) ?? EmptyCell;
|
|
995
|
+
const newCell = {
|
|
996
|
+
...cell,
|
|
997
|
+
style: {
|
|
998
|
+
...(cell.style ?? {}),
|
|
999
|
+
width
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
updatedData = set(point, newCell, updatedData);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
const updatedModel = new Model(state.model.createFormulaParser, updatedData);
|
|
724
1006
|
return {
|
|
725
1007
|
...state,
|
|
726
|
-
|
|
727
|
-
...state.
|
|
728
|
-
[
|
|
729
|
-
|
|
730
|
-
|
|
1008
|
+
columnDimensions: {
|
|
1009
|
+
...state.columnDimensions,
|
|
1010
|
+
[column]: {
|
|
1011
|
+
left: prevDimensions.left,
|
|
1012
|
+
width
|
|
731
1013
|
}
|
|
732
|
-
}
|
|
1014
|
+
},
|
|
1015
|
+
model: updatedModel
|
|
733
1016
|
};
|
|
734
1017
|
}
|
|
735
1018
|
case SET_COLUMN_POSITION:
|
|
@@ -867,6 +1150,69 @@ function reducer(state, action) {
|
|
|
867
1150
|
...commit(changes)
|
|
868
1151
|
};
|
|
869
1152
|
}
|
|
1153
|
+
case BATCH_RESIZE:
|
|
1154
|
+
{
|
|
1155
|
+
const {
|
|
1156
|
+
rows,
|
|
1157
|
+
columns
|
|
1158
|
+
} = action.payload;
|
|
1159
|
+
const {
|
|
1160
|
+
model,
|
|
1161
|
+
rowDimensions,
|
|
1162
|
+
columnDimensions
|
|
1163
|
+
} = state;
|
|
1164
|
+
let newRowDimensions = {
|
|
1165
|
+
...rowDimensions
|
|
1166
|
+
};
|
|
1167
|
+
let newColumnDimensions = {
|
|
1168
|
+
...columnDimensions
|
|
1169
|
+
};
|
|
1170
|
+
// Resize specified rows
|
|
1171
|
+
rows.forEach(row => {
|
|
1172
|
+
const rowData = model.data[row] || [];
|
|
1173
|
+
let maxHeight = 32;
|
|
1174
|
+
rowData.forEach((cell, _colIndex) => {
|
|
1175
|
+
if (cell && cell.value) {
|
|
1176
|
+
const fontSize = cell.style?.fontSize ? parseInt(cell.style.fontSize.toString().replace('px', '')) : 11;
|
|
1177
|
+
const lineHeight = Math.max(fontSize * 1.2, 18);
|
|
1178
|
+
const lines = String(cell.value).split('\n').length;
|
|
1179
|
+
const cellHeight = lineHeight * lines + 10;
|
|
1180
|
+
maxHeight = Math.max(Number(cell?.style?.height) ?? maxHeight, cellHeight);
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
newRowDimensions[row] = {
|
|
1184
|
+
...(newRowDimensions[row] || {
|
|
1185
|
+
top: 0,
|
|
1186
|
+
height: 32
|
|
1187
|
+
}),
|
|
1188
|
+
height: maxHeight
|
|
1189
|
+
};
|
|
1190
|
+
});
|
|
1191
|
+
// Resize specified columns
|
|
1192
|
+
columns.forEach(col => {
|
|
1193
|
+
let maxWidth = 100;
|
|
1194
|
+
model.data.forEach((rowData, _rowIndex) => {
|
|
1195
|
+
const cell = rowData[col];
|
|
1196
|
+
if (cell && cell.value && !['file'].includes(cell?.inputType?.type ?? 'text')) {
|
|
1197
|
+
const font = getFontString(cell);
|
|
1198
|
+
const textWidth = measureText(String(cell.value), font) + 20;
|
|
1199
|
+
maxWidth = Math.max(Number(cell?.style?.width) ?? maxWidth, textWidth);
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
newColumnDimensions[col] = {
|
|
1203
|
+
...(newColumnDimensions[col] || {
|
|
1204
|
+
left: 0,
|
|
1205
|
+
width: 100
|
|
1206
|
+
}),
|
|
1207
|
+
width: maxWidth
|
|
1208
|
+
};
|
|
1209
|
+
});
|
|
1210
|
+
return {
|
|
1211
|
+
...state,
|
|
1212
|
+
rowDimensions: newRowDimensions,
|
|
1213
|
+
columnDimensions: newColumnDimensions
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
870
1216
|
default:
|
|
871
1217
|
throw new Error('Unknown action');
|
|
872
1218
|
}
|