From 09847abea0eadbda022f55a82516b66db7f473b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Wed, 16 Nov 2022 08:25:03 +0000 Subject: [PATCH] [IMP] spreadsheet: update o_spreadsheet to latest version ### Contains the following commits: https://github.com/odoo/o-spreadsheet/commit/1b4fac5a [FIX] edition: Handle too long formulas https://github.com/odoo/o-spreadsheet/commit/544cfe68 [FIX] composer: Allow to paste text in the composer https://github.com/odoo/o-spreadsheet/commit/f04c7589 [FIX] functions: dichotomicSearch handle 2d array https://github.com/odoo/o-spreadsheet/commit/3660bf27 [REF] components: enforce component autonomy during keyboard event handling https://github.com/odoo/o-spreadsheet/commit/39bb9d88 [IMP] keyboard shortcuts: Insert link https://github.com/odoo/o-spreadsheet/commit/a40186aa [FIX] grid: capture IME altered inputs https://github.com/odoo/o-spreadsheet/commit/a884c78a [FIX] sheet: prevent creation of sheet with the same id https://github.com/odoo/o-spreadsheet/commit/aff05bdd [FIX] figure: prevent duplication of figure id https://github.com/odoo/o-spreadsheet/commit/5c18b6e1 [REF] ranges: make Range immutable object https://github.com/odoo/o-spreadsheet/commit/de5612e3 [FIX] config: Allow to build outside of git repository https://github.com/odoo/o-spreadsheet/commit/b100135c [FIX] grid: remove old component https://github.com/odoo/o-spreadsheet/commit/45f7f714 [FIX] selection: update default selection anchor on dispatched commands https://github.com/odoo/o-spreadsheet/commit/b41a1610 [FIX] selection: don't reset selection on Autofill https://github.com/odoo/o-spreadsheet/commit/16a98748 [FIX] selection: Properly add merge when adding them to the selection https://github.com/odoo/o-spreadsheet/commit/231bbbca [FIX] model: do not replay core commands in ui plugins closes odoo/odoo#105837 Related: odoo/enterprise#34029 Signed-off-by: Pierre Rousseau (pro) --- .../static/src/o_spreadsheet/o_spreadsheet.js | 868 +++++++++--------- .../src/o_spreadsheet/o_spreadsheet.xml | 39 +- addons/spreadsheet/static/src/pivot/index.js | 1 + 3 files changed, 468 insertions(+), 440 deletions(-) diff --git a/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js b/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js index 63b418a1203..f9366006f21 100644 --- a/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js +++ b/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js @@ -2110,25 +2110,42 @@ * Check that a zone is valid regarding the order of top-bottom and left-right. * Left should be smaller than right, top should be smaller than bottom. * If it's not the case, simply invert them, and invert the linked parts - * (in place!) */ orderZone() { - if (this._zone.right !== undefined && this._zone.right < this._zone.left) { - let right = this._zone.right; - this._zone.right = this._zone.left; - this._zone.left = right; - let rightFixed = this.parts[1].colFixed; - this.parts[1].colFixed = this.parts[0].colFixed; - this.parts[0].colFixed = rightFixed; + var _a, _b, _c, _d, _e, _f, _g, _h; + const zone = { ...this._zone }; + let parts = this.parts; + if (zone.right !== undefined && zone.right < zone.left) { + let right = zone.right; + zone.right = zone.left; + zone.left = right; + parts = [ + { + colFixed: ((_a = parts[1]) === null || _a === void 0 ? void 0 : _a.colFixed) || false, + rowFixed: ((_b = parts[0]) === null || _b === void 0 ? void 0 : _b.rowFixed) || false, + }, + { + colFixed: ((_c = parts[0]) === null || _c === void 0 ? void 0 : _c.colFixed) || false, + rowFixed: ((_d = parts[1]) === null || _d === void 0 ? void 0 : _d.rowFixed) || false, + }, + ]; } - if (this._zone.bottom !== undefined && this._zone.bottom < this._zone.top) { - let bottom = this._zone.bottom; - this._zone.bottom = this._zone.top; - this._zone.top = bottom; - let bottomFixed = this.parts[1].rowFixed; - this.parts[1].rowFixed = this.parts[0].rowFixed; - this.parts[0].rowFixed = bottomFixed; + if (zone.bottom !== undefined && zone.bottom < zone.top) { + let bottom = zone.bottom; + zone.bottom = zone.top; + zone.top = bottom; + parts = [ + { + colFixed: ((_e = parts[0]) === null || _e === void 0 ? void 0 : _e.colFixed) || false, + rowFixed: ((_f = parts[1]) === null || _f === void 0 ? void 0 : _f.rowFixed) || false, + }, + { + colFixed: ((_g = parts[1]) === null || _g === void 0 ? void 0 : _g.colFixed) || false, + rowFixed: ((_h = parts[0]) === null || _h === void 0 ? void 0 : _h.rowFixed) || false, + }, + ]; } + return this.clone({ zone, parts }); } /** * @@ -2770,7 +2787,7 @@ * This function will compare the modifications of selection to determine * a cell that is part of the new zone and not the previous one. */ - function findCellInNewZone(oldZone, currentZone) { + function findCellInNewZone(oldZone, currentZone, viewport) { let col, row; const { left: oldLeft, right: oldRight, top: oldTop, bottom: oldBottom } = oldZone; const { left, right, top, bottom } = currentZone; @@ -2781,7 +2798,8 @@ col = right; } else { - col = left; + // left and right don't change + col = viewport.left > left || left > viewport.right ? viewport.left : left; } if (top != oldTop) { row = top; @@ -2790,7 +2808,8 @@ row = bottom; } else { - row = top; + // top and bottom don't change + row = viewport.top > top || top > viewport.bottom ? viewport.top : top; } return { col, row }; } @@ -3087,74 +3106,76 @@ CommandResult[CommandResult["NotEnoughSheets"] = 8] = "NotEnoughSheets"; CommandResult[CommandResult["MissingSheetName"] = 9] = "MissingSheetName"; CommandResult[CommandResult["DuplicatedSheetName"] = 10] = "DuplicatedSheetName"; - CommandResult[CommandResult["ForbiddenCharactersInSheetName"] = 11] = "ForbiddenCharactersInSheetName"; - CommandResult[CommandResult["WrongSheetMove"] = 12] = "WrongSheetMove"; - CommandResult[CommandResult["WrongSheetPosition"] = 13] = "WrongSheetPosition"; - CommandResult[CommandResult["InvalidAnchorZone"] = 14] = "InvalidAnchorZone"; - CommandResult[CommandResult["SelectionOutOfBound"] = 15] = "SelectionOutOfBound"; - CommandResult[CommandResult["TargetOutOfSheet"] = 16] = "TargetOutOfSheet"; - CommandResult[CommandResult["WrongCutSelection"] = 17] = "WrongCutSelection"; - CommandResult[CommandResult["WrongPasteSelection"] = 18] = "WrongPasteSelection"; - CommandResult[CommandResult["WrongPasteOption"] = 19] = "WrongPasteOption"; - CommandResult[CommandResult["WrongFigurePasteOption"] = 20] = "WrongFigurePasteOption"; - CommandResult[CommandResult["EmptyClipboard"] = 21] = "EmptyClipboard"; - CommandResult[CommandResult["EmptyRange"] = 22] = "EmptyRange"; - CommandResult[CommandResult["InvalidRange"] = 23] = "InvalidRange"; - CommandResult[CommandResult["InvalidZones"] = 24] = "InvalidZones"; - CommandResult[CommandResult["InvalidSheetId"] = 25] = "InvalidSheetId"; - CommandResult[CommandResult["InputAlreadyFocused"] = 26] = "InputAlreadyFocused"; - CommandResult[CommandResult["MaximumRangesReached"] = 27] = "MaximumRangesReached"; - CommandResult[CommandResult["InvalidChartDefinition"] = 28] = "InvalidChartDefinition"; - CommandResult[CommandResult["InvalidDataSet"] = 29] = "InvalidDataSet"; - CommandResult[CommandResult["InvalidLabelRange"] = 30] = "InvalidLabelRange"; - CommandResult[CommandResult["InvalidScorecardKeyValue"] = 31] = "InvalidScorecardKeyValue"; - CommandResult[CommandResult["InvalidScorecardBaseline"] = 32] = "InvalidScorecardBaseline"; - CommandResult[CommandResult["InvalidGaugeDataRange"] = 33] = "InvalidGaugeDataRange"; - CommandResult[CommandResult["EmptyGaugeRangeMin"] = 34] = "EmptyGaugeRangeMin"; - CommandResult[CommandResult["GaugeRangeMinNaN"] = 35] = "GaugeRangeMinNaN"; - CommandResult[CommandResult["EmptyGaugeRangeMax"] = 36] = "EmptyGaugeRangeMax"; - CommandResult[CommandResult["GaugeRangeMaxNaN"] = 37] = "GaugeRangeMaxNaN"; - CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 38] = "GaugeRangeMinBiggerThanRangeMax"; - CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 39] = "GaugeLowerInflectionPointNaN"; - CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 40] = "GaugeUpperInflectionPointNaN"; - CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 41] = "GaugeLowerBiggerThanUpper"; - CommandResult[CommandResult["InvalidAutofillSelection"] = 42] = "InvalidAutofillSelection"; - CommandResult[CommandResult["WrongComposerSelection"] = 43] = "WrongComposerSelection"; - CommandResult[CommandResult["MinBiggerThanMax"] = 44] = "MinBiggerThanMax"; - CommandResult[CommandResult["LowerBiggerThanUpper"] = 45] = "LowerBiggerThanUpper"; - CommandResult[CommandResult["MidBiggerThanMax"] = 46] = "MidBiggerThanMax"; - CommandResult[CommandResult["MinBiggerThanMid"] = 47] = "MinBiggerThanMid"; - CommandResult[CommandResult["FirstArgMissing"] = 48] = "FirstArgMissing"; - CommandResult[CommandResult["SecondArgMissing"] = 49] = "SecondArgMissing"; - CommandResult[CommandResult["MinNaN"] = 50] = "MinNaN"; - CommandResult[CommandResult["MidNaN"] = 51] = "MidNaN"; - CommandResult[CommandResult["MaxNaN"] = 52] = "MaxNaN"; - CommandResult[CommandResult["ValueUpperInflectionNaN"] = 53] = "ValueUpperInflectionNaN"; - CommandResult[CommandResult["ValueLowerInflectionNaN"] = 54] = "ValueLowerInflectionNaN"; - CommandResult[CommandResult["MinInvalidFormula"] = 55] = "MinInvalidFormula"; - CommandResult[CommandResult["MidInvalidFormula"] = 56] = "MidInvalidFormula"; - CommandResult[CommandResult["MaxInvalidFormula"] = 57] = "MaxInvalidFormula"; - CommandResult[CommandResult["ValueUpperInvalidFormula"] = 58] = "ValueUpperInvalidFormula"; - CommandResult[CommandResult["ValueLowerInvalidFormula"] = 59] = "ValueLowerInvalidFormula"; - CommandResult[CommandResult["InvalidSortZone"] = 60] = "InvalidSortZone"; - CommandResult[CommandResult["WaitingSessionConfirmation"] = 61] = "WaitingSessionConfirmation"; - CommandResult[CommandResult["MergeOverlap"] = 62] = "MergeOverlap"; - CommandResult[CommandResult["TooManyHiddenElements"] = 63] = "TooManyHiddenElements"; - CommandResult[CommandResult["Readonly"] = 64] = "Readonly"; - CommandResult[CommandResult["InvalidViewportSize"] = 65] = "InvalidViewportSize"; - CommandResult[CommandResult["InvalidScrollingDirection"] = 66] = "InvalidScrollingDirection"; - CommandResult[CommandResult["FigureDoesNotExist"] = 67] = "FigureDoesNotExist"; - CommandResult[CommandResult["InvalidConditionalFormatId"] = 68] = "InvalidConditionalFormatId"; - CommandResult[CommandResult["InvalidCellPopover"] = 69] = "InvalidCellPopover"; - CommandResult[CommandResult["EmptyTarget"] = 70] = "EmptyTarget"; - CommandResult[CommandResult["InvalidFreezeQuantity"] = 71] = "InvalidFreezeQuantity"; - CommandResult[CommandResult["FrozenPaneOverlap"] = 72] = "FrozenPaneOverlap"; - CommandResult[CommandResult["ValuesNotChanged"] = 73] = "ValuesNotChanged"; - CommandResult[CommandResult["InvalidFilterZone"] = 74] = "InvalidFilterZone"; - CommandResult[CommandResult["FilterOverlap"] = 75] = "FilterOverlap"; - CommandResult[CommandResult["FilterNotFound"] = 76] = "FilterNotFound"; - CommandResult[CommandResult["MergeInFilter"] = 77] = "MergeInFilter"; - CommandResult[CommandResult["NonContinuousTargets"] = 78] = "NonContinuousTargets"; + CommandResult[CommandResult["DuplicatedSheetId"] = 11] = "DuplicatedSheetId"; + CommandResult[CommandResult["ForbiddenCharactersInSheetName"] = 12] = "ForbiddenCharactersInSheetName"; + CommandResult[CommandResult["WrongSheetMove"] = 13] = "WrongSheetMove"; + CommandResult[CommandResult["WrongSheetPosition"] = 14] = "WrongSheetPosition"; + CommandResult[CommandResult["InvalidAnchorZone"] = 15] = "InvalidAnchorZone"; + CommandResult[CommandResult["SelectionOutOfBound"] = 16] = "SelectionOutOfBound"; + CommandResult[CommandResult["TargetOutOfSheet"] = 17] = "TargetOutOfSheet"; + CommandResult[CommandResult["WrongCutSelection"] = 18] = "WrongCutSelection"; + CommandResult[CommandResult["WrongPasteSelection"] = 19] = "WrongPasteSelection"; + CommandResult[CommandResult["WrongPasteOption"] = 20] = "WrongPasteOption"; + CommandResult[CommandResult["WrongFigurePasteOption"] = 21] = "WrongFigurePasteOption"; + CommandResult[CommandResult["EmptyClipboard"] = 22] = "EmptyClipboard"; + CommandResult[CommandResult["EmptyRange"] = 23] = "EmptyRange"; + CommandResult[CommandResult["InvalidRange"] = 24] = "InvalidRange"; + CommandResult[CommandResult["InvalidZones"] = 25] = "InvalidZones"; + CommandResult[CommandResult["InvalidSheetId"] = 26] = "InvalidSheetId"; + CommandResult[CommandResult["InputAlreadyFocused"] = 27] = "InputAlreadyFocused"; + CommandResult[CommandResult["MaximumRangesReached"] = 28] = "MaximumRangesReached"; + CommandResult[CommandResult["InvalidChartDefinition"] = 29] = "InvalidChartDefinition"; + CommandResult[CommandResult["InvalidDataSet"] = 30] = "InvalidDataSet"; + CommandResult[CommandResult["InvalidLabelRange"] = 31] = "InvalidLabelRange"; + CommandResult[CommandResult["InvalidScorecardKeyValue"] = 32] = "InvalidScorecardKeyValue"; + CommandResult[CommandResult["InvalidScorecardBaseline"] = 33] = "InvalidScorecardBaseline"; + CommandResult[CommandResult["InvalidGaugeDataRange"] = 34] = "InvalidGaugeDataRange"; + CommandResult[CommandResult["EmptyGaugeRangeMin"] = 35] = "EmptyGaugeRangeMin"; + CommandResult[CommandResult["GaugeRangeMinNaN"] = 36] = "GaugeRangeMinNaN"; + CommandResult[CommandResult["EmptyGaugeRangeMax"] = 37] = "EmptyGaugeRangeMax"; + CommandResult[CommandResult["GaugeRangeMaxNaN"] = 38] = "GaugeRangeMaxNaN"; + CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 39] = "GaugeRangeMinBiggerThanRangeMax"; + CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 40] = "GaugeLowerInflectionPointNaN"; + CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 41] = "GaugeUpperInflectionPointNaN"; + CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 42] = "GaugeLowerBiggerThanUpper"; + CommandResult[CommandResult["InvalidAutofillSelection"] = 43] = "InvalidAutofillSelection"; + CommandResult[CommandResult["WrongComposerSelection"] = 44] = "WrongComposerSelection"; + CommandResult[CommandResult["MinBiggerThanMax"] = 45] = "MinBiggerThanMax"; + CommandResult[CommandResult["LowerBiggerThanUpper"] = 46] = "LowerBiggerThanUpper"; + CommandResult[CommandResult["MidBiggerThanMax"] = 47] = "MidBiggerThanMax"; + CommandResult[CommandResult["MinBiggerThanMid"] = 48] = "MinBiggerThanMid"; + CommandResult[CommandResult["FirstArgMissing"] = 49] = "FirstArgMissing"; + CommandResult[CommandResult["SecondArgMissing"] = 50] = "SecondArgMissing"; + CommandResult[CommandResult["MinNaN"] = 51] = "MinNaN"; + CommandResult[CommandResult["MidNaN"] = 52] = "MidNaN"; + CommandResult[CommandResult["MaxNaN"] = 53] = "MaxNaN"; + CommandResult[CommandResult["ValueUpperInflectionNaN"] = 54] = "ValueUpperInflectionNaN"; + CommandResult[CommandResult["ValueLowerInflectionNaN"] = 55] = "ValueLowerInflectionNaN"; + CommandResult[CommandResult["MinInvalidFormula"] = 56] = "MinInvalidFormula"; + CommandResult[CommandResult["MidInvalidFormula"] = 57] = "MidInvalidFormula"; + CommandResult[CommandResult["MaxInvalidFormula"] = 58] = "MaxInvalidFormula"; + CommandResult[CommandResult["ValueUpperInvalidFormula"] = 59] = "ValueUpperInvalidFormula"; + CommandResult[CommandResult["ValueLowerInvalidFormula"] = 60] = "ValueLowerInvalidFormula"; + CommandResult[CommandResult["InvalidSortZone"] = 61] = "InvalidSortZone"; + CommandResult[CommandResult["WaitingSessionConfirmation"] = 62] = "WaitingSessionConfirmation"; + CommandResult[CommandResult["MergeOverlap"] = 63] = "MergeOverlap"; + CommandResult[CommandResult["TooManyHiddenElements"] = 64] = "TooManyHiddenElements"; + CommandResult[CommandResult["Readonly"] = 65] = "Readonly"; + CommandResult[CommandResult["InvalidViewportSize"] = 66] = "InvalidViewportSize"; + CommandResult[CommandResult["InvalidScrollingDirection"] = 67] = "InvalidScrollingDirection"; + CommandResult[CommandResult["FigureDoesNotExist"] = 68] = "FigureDoesNotExist"; + CommandResult[CommandResult["InvalidConditionalFormatId"] = 69] = "InvalidConditionalFormatId"; + CommandResult[CommandResult["InvalidCellPopover"] = 70] = "InvalidCellPopover"; + CommandResult[CommandResult["EmptyTarget"] = 71] = "EmptyTarget"; + CommandResult[CommandResult["InvalidFreezeQuantity"] = 72] = "InvalidFreezeQuantity"; + CommandResult[CommandResult["FrozenPaneOverlap"] = 73] = "FrozenPaneOverlap"; + CommandResult[CommandResult["ValuesNotChanged"] = 74] = "ValuesNotChanged"; + CommandResult[CommandResult["InvalidFilterZone"] = 75] = "InvalidFilterZone"; + CommandResult[CommandResult["FilterOverlap"] = 76] = "FilterOverlap"; + CommandResult[CommandResult["FilterNotFound"] = 77] = "FilterNotFound"; + CommandResult[CommandResult["MergeInFilter"] = 78] = "MergeInFilter"; + CommandResult[CommandResult["NonContinuousTargets"] = 79] = "NonContinuousTargets"; + CommandResult[CommandResult["DuplicatedFigureId"] = 80] = "DuplicatedFigureId"; })(exports.CommandResult || (exports.CommandResult = {})); var DIRECTION; @@ -3646,6 +3667,7 @@ selectedIndex = Math.min(selectedIndex + 1, displayedValues.length - 1); } ev.preventDefault(); + ev.stopPropagation(); break; case "ArrowUp": if (selectedIndex === undefined) { @@ -3655,11 +3677,13 @@ selectedIndex = Math.max(selectedIndex - 1, 0); } ev.preventDefault(); + ev.stopPropagation(); break; case "Enter": if (selectedIndex !== undefined) { this.checkValue(displayedValues[selectedIndex]); } + ev.stopPropagation(); ev.preventDefault(); break; } @@ -4435,9 +4459,11 @@ if (this.state.link.url) { this.save(); } + ev.stopPropagation(); break; case "Escape": this.cancel(); + ev.stopPropagation(); break; } } @@ -4676,7 +4702,7 @@ }); } } - if (result.isCancelledBecause(60 /* CommandResult.InvalidSortZone */)) { + if (result.isCancelledBecause(61 /* CommandResult.InvalidSortZone */)) { const { col, row } = anchor; env.model.selection.selectZone({ cell: { col, row }, zone }); env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size.")); @@ -4686,7 +4712,7 @@ function interactiveCut(env) { const result = env.model.dispatch("CUT"); if (!result.isSuccessful) { - if (result.isCancelledBecause(17 /* CommandResult.WrongCutSelection */)) { + if (result.isCancelledBecause(18 /* CommandResult.WrongCutSelection */)) { env.raiseError(_lt("This operation is not allowed with multiple selections.")); } } @@ -4699,13 +4725,13 @@ }; function interactiveAddFilter(env, sheetId, target) { const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId }); - if (result.isCancelledBecause(75 /* CommandResult.FilterOverlap */)) { + if (result.isCancelledBecause(76 /* CommandResult.FilterOverlap */)) { env.raiseError(AddFilterInteractiveContent.filterOverlap); } - else if (result.isCancelledBecause(77 /* CommandResult.MergeInFilter */)) { + else if (result.isCancelledBecause(78 /* CommandResult.MergeInFilter */)) { env.raiseError(AddFilterInteractiveContent.mergeInFilter); } - else if (result.isCancelledBecause(78 /* CommandResult.NonContinuousTargets */)) { + else if (result.isCancelledBecause(79 /* CommandResult.NonContinuousTargets */)) { env.raiseError(AddFilterInteractiveContent.nonContinuousTargets); } } @@ -4718,16 +4744,16 @@ }; function handlePasteResult(env, result) { if (!result.isSuccessful) { - if (result.reasons.includes(18 /* CommandResult.WrongPasteSelection */)) { + if (result.reasons.includes(19 /* CommandResult.WrongPasteSelection */)) { env.raiseError(PasteInteractiveContent.wrongPasteSelection); } else if (result.reasons.includes(2 /* CommandResult.WillRemoveExistingMerge */)) { env.raiseError(PasteInteractiveContent.willRemoveExistingMerge); } - else if (result.reasons.includes(20 /* CommandResult.WrongFigurePasteOption */)) { + else if (result.reasons.includes(21 /* CommandResult.WrongFigurePasteOption */)) { env.raiseError(PasteInteractiveContent.wrongFigurePasteOption); } - else if (result.reasons.includes(72 /* CommandResult.FrozenPaneOverlap */)) { + else if (result.reasons.includes(73 /* CommandResult.FrozenPaneOverlap */)) { env.raiseError(PasteInteractiveContent.frozenPaneOverlap); } } @@ -5694,7 +5720,7 @@ if (result.reasons.includes(10 /* CommandResult.DuplicatedSheetName */)) { interactiveRenameSheet(env, sheetId, _lt("A sheet with the name %s already exists. Please select another name.", name)); } - if (result.reasons.includes(11 /* CommandResult.ForbiddenCharactersInSheetName */)) { + if (result.reasons.includes(12 /* CommandResult.ForbiddenCharactersInSheetName */)) { interactiveRenameSheet(env, sheetId, _lt("Some used characters are not allowed in a sheet name (Forbidden characters are %s).", FORBIDDEN_SHEET_CHARS.join(" "))); } } @@ -5769,24 +5795,24 @@ const CfTerms = { Errors: { - [23 /* CommandResult.InvalidRange */]: _lt("The range is invalid"), - [48 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"), - [49 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"), - [50 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"), - [51 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"), - [52 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"), - [53 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"), - [54 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"), - [44 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"), - [47 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"), - [46 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"), - [45 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"), - [55 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"), - [57 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"), - [56 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"), - [58 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"), - [59 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"), - [22 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"), + [24 /* CommandResult.InvalidRange */]: _lt("The range is invalid"), + [49 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"), + [50 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"), + [51 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"), + [52 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"), + [53 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"), + [54 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"), + [55 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"), + [45 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"), + [48 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"), + [47 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"), + [46 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"), + [56 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"), + [58 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"), + [57 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"), + [59 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"), + [60 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"), + [23 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"), Unexpected: _lt("The rule is invalid for an unknown reason"), }, ColorScale: _lt("Color scale"), @@ -5813,20 +5839,20 @@ Errors: { Unexpected: _lt("The chart definition is invalid for an unknown reason"), // BASIC CHART ERRORS (LINE | BAR | PIE) - [29 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"), - [30 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"), + [30 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"), + [31 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"), // SCORECARD CHART ERRORS - [31 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"), - [32 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"), + [32 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"), + [33 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"), // GAUGE CHART ERRORS - [33 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"), - [34 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"), - [35 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"), - [36 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"), - [37 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"), - [38 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"), - [39 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"), - [40 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"), + [34 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"), + [35 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"), + [36 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"), + [37 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"), + [38 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"), + [39 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"), + [40 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"), + [41 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"), }, }; const NumberFormatTerms = { @@ -5850,7 +5876,7 @@ const sheetId = env.model.getters.getActiveSheetId(); const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS"; const result = env.model.dispatch(cmd, { sheetId, quantity: base }); - if (result.isCancelledBecause(62 /* CommandResult.MergeOverlap */)) { + if (result.isCancelledBecause(63 /* CommandResult.MergeOverlap */)) { env.raiseError(MergeErrorMessage); } } @@ -6296,7 +6322,23 @@ } const otRegistry = new OTRegistry(); - const uuidGenerator$1 = new UuidGenerator(); + const arrowMap = { + ArrowDown: "down", + ArrowLeft: "left", + ArrowRight: "right", + ArrowUp: "up", + }; + function updateSelectionWithArrowKeys(ev, selection) { + const direction = arrowMap[ev.key]; + if (ev.shiftKey) { + selection.resizeAnchorZone(direction, ev.ctrlKey ? "end" : "one"); + } + else { + selection.moveAnchorCell(direction, ev.ctrlKey ? "end" : "one"); + } + } + + const uuidGenerator = new UuidGenerator(); css /* scss */ ` .o-selection { .o-selection-input { @@ -6353,11 +6395,12 @@ class SelectionInput extends owl.Component { constructor() { super(...arguments); - this.id = uuidGenerator$1.uuidv4(); + this.id = uuidGenerator.uuidv4(); this.previousRanges = this.props.ranges || []; this.originSheet = this.env.model.getters.getActiveSheetId(); this.state = owl.useState({ isMissing: false, + mode: "select-range", }); } get ranges() { @@ -6416,8 +6459,23 @@ (_b = (_a = this.props).onSelectionChanged) === null || _b === void 0 ? void 0 : _b.call(_a, ranges); this.previousRanges = ranges; } + onKeydown(ev) { + if (ev.key === "F2") { + ev.preventDefault(); + ev.stopPropagation(); + this.state.mode = this.state.mode === "select-range" ? "text-edit" : "select-range"; + } + else if (ev.key.startsWith("Arrow")) { + ev.stopPropagation(); + if (this.state.mode === "select-range") { + ev.preventDefault(); + updateSelectionWithArrowKeys(ev, this.env.model.selection); + } + } + } focus(rangeId) { this.state.isMissing = false; + this.state.mode = "select-range"; this.env.model.dispatch("FOCUS_RANGE", { id: this.id, rangeId, @@ -6493,11 +6551,11 @@ } get isDatasetInvalid() { var _a; - return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(29 /* CommandResult.InvalidDataSet */)); + return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(30 /* CommandResult.InvalidDataSet */)); } get isLabelInvalid() { var _a; - return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(30 /* CommandResult.InvalidLabelRange */)); + return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(31 /* CommandResult.InvalidLabelRange */)); } onUpdateDataSetsHaveTitle(ev) { this.props.updateChart({ @@ -6850,11 +6908,11 @@ if (definition.dataSets) { const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined; if (invalidRanges) { - return 29 /* CommandResult.InvalidDataSet */; + return 30 /* CommandResult.InvalidDataSet */; } const zones = definition.dataSets.map(toUnboundedZone); if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) { - return 29 /* CommandResult.InvalidDataSet */; + return 30 /* CommandResult.InvalidDataSet */; } } return 0 /* CommandResult.Success */; @@ -6863,7 +6921,7 @@ if (definition.labelRange) { const invalidLabels = !rangeReference.test(definition.labelRange || ""); if (invalidLabels) { - return 30 /* CommandResult.InvalidLabelRange */; + return 31 /* CommandResult.InvalidLabelRange */; } } return 0 /* CommandResult.Success */; @@ -7321,7 +7379,7 @@ }); function isDataRangeValid(definition) { return definition.dataRange && !rangeReference.test(definition.dataRange) - ? 33 /* CommandResult.InvalidGaugeDataRange */ + ? 34 /* CommandResult.InvalidGaugeDataRange */ : 0 /* CommandResult.Success */; } function checkRangeLimits(check, batchValidations) { @@ -7353,7 +7411,7 @@ function checkRangeMinBiggerThanRangeMax(definition) { if (definition.sectionRule) { if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) { - return 38 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */; + return 39 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */; } } return 0 /* CommandResult.Success */; @@ -7362,9 +7420,9 @@ if (value === "") { switch (valueName) { case "rangeMin": - return 34 /* CommandResult.EmptyGaugeRangeMin */; + return 35 /* CommandResult.EmptyGaugeRangeMin */; case "rangeMax": - return 36 /* CommandResult.EmptyGaugeRangeMax */; + return 37 /* CommandResult.EmptyGaugeRangeMax */; } } return 0 /* CommandResult.Success */; @@ -7373,13 +7431,13 @@ if (isNaN(value)) { switch (valueName) { case "rangeMin": - return 35 /* CommandResult.GaugeRangeMinNaN */; + return 36 /* CommandResult.GaugeRangeMinNaN */; case "rangeMax": - return 37 /* CommandResult.GaugeRangeMaxNaN */; + return 38 /* CommandResult.GaugeRangeMaxNaN */; case "lowerInflectionPointValue": - return 39 /* CommandResult.GaugeLowerInflectionPointNaN */; + return 40 /* CommandResult.GaugeLowerInflectionPointNaN */; case "upperInflectionPointValue": - return 40 /* CommandResult.GaugeUpperInflectionPointNaN */; + return 41 /* CommandResult.GaugeUpperInflectionPointNaN */; } } return 0 /* CommandResult.Success */; @@ -8119,12 +8177,12 @@ }); function checkKeyValue(definition) { return definition.keyValue && !rangeReference.test(definition.keyValue) - ? 31 /* CommandResult.InvalidScorecardKeyValue */ + ? 32 /* CommandResult.InvalidScorecardKeyValue */ : 0 /* CommandResult.Success */; } function checkBaseline(definition) { return definition.baseline && !rangeReference.test(definition.baseline) - ? 32 /* CommandResult.InvalidScorecardBaseline */ + ? 33 /* CommandResult.InvalidScorecardBaseline */ : 0 /* CommandResult.Success */; } class ScorecardChart$1 extends AbstractChart { @@ -8536,7 +8594,7 @@ } get isDataRangeInvalid() { var _a; - return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidGaugeDataRange */)); + return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidGaugeDataRange */)); } onDataRangeChanged(ranges) { this.dataRange = ranges[0]; @@ -8622,28 +8680,28 @@ } isRangeMinInvalid() { var _a, _b, _c; - return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.EmptyGaugeRangeMin */)) || - ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(35 /* CommandResult.GaugeRangeMinNaN */)) || - ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(38 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */))); + return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.EmptyGaugeRangeMin */)) || + ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(36 /* CommandResult.GaugeRangeMinNaN */)) || + ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(39 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */))); } isRangeMaxInvalid() { var _a, _b, _c; - return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.EmptyGaugeRangeMax */)) || - ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(37 /* CommandResult.GaugeRangeMaxNaN */)) || - ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(38 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */))); + return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMax */)) || + ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(38 /* CommandResult.GaugeRangeMaxNaN */)) || + ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(39 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */))); } // --------------------------------------------------------------------------- // COLOR_SECTION_TEMPLATE // --------------------------------------------------------------------------- get isLowerInflectionPointInvalid() { var _a, _b; - return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(39 /* CommandResult.GaugeLowerInflectionPointNaN */)) || - ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(41 /* CommandResult.GaugeLowerBiggerThanUpper */))); + return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(40 /* CommandResult.GaugeLowerInflectionPointNaN */)) || + ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(42 /* CommandResult.GaugeLowerBiggerThanUpper */))); } get isUpperInflectionPointInvalid() { var _a, _b; - return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(40 /* CommandResult.GaugeUpperInflectionPointNaN */)) || - ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(41 /* CommandResult.GaugeLowerBiggerThanUpper */))); + return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(41 /* CommandResult.GaugeUpperInflectionPointNaN */)) || + ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(42 /* CommandResult.GaugeLowerBiggerThanUpper */))); } updateInflectionPointValue(attr, ev) { const sectionRule = deepCopy(this.props.definition.sectionRule); @@ -8746,11 +8804,11 @@ } get isKeyValueInvalid() { var _a; - return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(31 /* CommandResult.InvalidScorecardKeyValue */)); + return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(32 /* CommandResult.InvalidScorecardKeyValue */)); } get isBaselineInvalid() { var _a; - return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(32 /* CommandResult.InvalidScorecardBaseline */)); + return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidScorecardBaseline */)); } onKeyValueRangeChanged(ranges) { this.keyValue = ranges[0]; @@ -9390,7 +9448,7 @@ return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId()); } get isRangeValid() { - return this.state.errors.includes(22 /* CommandResult.EmptyRange */); + return this.state.errors.includes(23 /* CommandResult.EmptyRange */); } errorMessage(error) { return CfTerms.Errors[error] || CfTerms.Errors.Unexpected; @@ -9452,7 +9510,7 @@ if (this.state.currentCF) { const invalidRanges = this.state.currentCF.ranges.some((xc) => !xc.match(rangeReference)); if (invalidRanges) { - this.state.errors = [23 /* CommandResult.InvalidRange */]; + this.state.errors = [24 /* CommandResult.InvalidRange */]; return; } const sheetId = this.env.model.getters.getActiveSheetId(); @@ -9608,11 +9666,11 @@ ****************************************************************************/ get isValue1Invalid() { var _a; - return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(48 /* CommandResult.FirstArgMissing */)); + return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(49 /* CommandResult.FirstArgMissing */)); } get isValue2Invalid() { var _a; - return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(49 /* CommandResult.SecondArgMissing */)); + return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(50 /* CommandResult.SecondArgMissing */)); } toggleStyle(tool) { const style = this.state.rules.cellIs.style; @@ -9629,17 +9687,17 @@ isValueInvalid(threshold) { switch (threshold) { case "minimum": - return (this.state.errors.includes(55 /* CommandResult.MinInvalidFormula */) || - this.state.errors.includes(47 /* CommandResult.MinBiggerThanMid */) || - this.state.errors.includes(44 /* CommandResult.MinBiggerThanMax */) || - this.state.errors.includes(50 /* CommandResult.MinNaN */)); + return (this.state.errors.includes(56 /* CommandResult.MinInvalidFormula */) || + this.state.errors.includes(48 /* CommandResult.MinBiggerThanMid */) || + this.state.errors.includes(45 /* CommandResult.MinBiggerThanMax */) || + this.state.errors.includes(51 /* CommandResult.MinNaN */)); case "midpoint": - return (this.state.errors.includes(56 /* CommandResult.MidInvalidFormula */) || - this.state.errors.includes(51 /* CommandResult.MidNaN */) || - this.state.errors.includes(46 /* CommandResult.MidBiggerThanMax */)); + return (this.state.errors.includes(57 /* CommandResult.MidInvalidFormula */) || + this.state.errors.includes(52 /* CommandResult.MidNaN */) || + this.state.errors.includes(47 /* CommandResult.MidBiggerThanMax */)); case "maximum": - return (this.state.errors.includes(57 /* CommandResult.MaxInvalidFormula */) || - this.state.errors.includes(52 /* CommandResult.MaxNaN */)); + return (this.state.errors.includes(58 /* CommandResult.MaxInvalidFormula */) || + this.state.errors.includes(53 /* CommandResult.MaxNaN */)); default: return false; } @@ -9688,13 +9746,13 @@ isInflectionPointInvalid(inflectionPoint) { switch (inflectionPoint) { case "lowerInflectionPoint": - return (this.state.errors.includes(54 /* CommandResult.ValueLowerInflectionNaN */) || - this.state.errors.includes(59 /* CommandResult.ValueLowerInvalidFormula */) || - this.state.errors.includes(45 /* CommandResult.LowerBiggerThanUpper */)); + return (this.state.errors.includes(55 /* CommandResult.ValueLowerInflectionNaN */) || + this.state.errors.includes(60 /* CommandResult.ValueLowerInvalidFormula */) || + this.state.errors.includes(46 /* CommandResult.LowerBiggerThanUpper */)); case "upperInflectionPoint": - return (this.state.errors.includes(53 /* CommandResult.ValueUpperInflectionNaN */) || - this.state.errors.includes(58 /* CommandResult.ValueUpperInvalidFormula */) || - this.state.errors.includes(45 /* CommandResult.LowerBiggerThanUpper */)); + return (this.state.errors.includes(54 /* CommandResult.ValueUpperInflectionNaN */) || + this.state.errors.includes(59 /* CommandResult.ValueUpperInvalidFormula */) || + this.state.errors.includes(46 /* CommandResult.LowerBiggerThanUpper */)); default: return true; } @@ -9923,12 +9981,14 @@ onKeydownSearch(ev) { if (ev.key === "Enter") { ev.preventDefault(); + ev.stopPropagation(); this.onSelectNextCell(); } } onKeydownReplace(ev) { if (ev.key === "Enter") { ev.preventDefault(); + ev.stopPropagation(); this.replace(); } } @@ -11248,7 +11308,7 @@ currentVal = getValueInData(data, currentIndex); currentType = typeof currentVal; // 1 - linear search to find value with the same type - while (indexLeft <= currentIndex && targetType !== currentType) { + while (indexLeft < currentIndex && targetType !== currentType) { currentIndex--; currentVal = getValueInData(data, currentIndex); currentType = typeof currentVal; @@ -17820,7 +17880,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A TEXT: TEXT }); - const functions$4 = { + const functions$3 = { database, date, financial, @@ -17881,8 +17941,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A return arg === null || arg === void 0 ? void 0 : arg.value; } const functionRegistry = new FunctionRegistry(); - for (let category in functions$4) { - const fns = functions$4[category]; + for (let category in functions$3) { + const fns = functions$3[category]; for (let name in fns) { const addDescr = fns[name]; addDescr.category = category; @@ -17907,18 +17967,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A * is useful for the composer, which needs to be able to work with incomplete * formulas. */ - const functions$3 = functionRegistry.content; + const functions$2 = functionRegistry.content; const POSTFIX_UNARY_OPERATORS = ["%"]; const OPERATORS = "+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(POSTFIX_UNARY_OPERATORS); function tokenize(str) { const chars = str.split(""); const result = []; - let tokenCount = 0; while (chars.length) { - tokenCount++; - if (tokenCount > 100) { - throw new Error(_lt("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")); - } let token = tokenizeSpace(chars) || tokenizeMisc(chars) || tokenizeOperator(chars) || @@ -18041,7 +18096,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } if (result.length) { const value = result; - const isFunction = value.toUpperCase() in functions$3; + const isFunction = value.toUpperCase() in functions$2; if (isFunction) { return { type: "FUNCTION", value }; } @@ -18493,7 +18548,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A return result; } - const functions$2 = functionRegistry.content; + const functions$1 = functionRegistry.content; const OPERATOR_MAP = { "=": "EQ", "+": "ADD", @@ -18567,7 +18622,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A * between a cell value and a non cell value. */ function compileFunctionArgs(ast) { - const functionDefinition = functions$2[ast.value.toUpperCase()]; + const functionDefinition = functions$1[ast.value.toUpperCase()]; const currentFunctionArguments = ast.args; // check if arguments are supplied in the correct quantities const nbrArg = currentFunctionArguments.length; @@ -19171,7 +19226,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A this.colorIndexByRange = {}; break; case "SET_CURRENT_CONTENT": - this.setContent(cmd.content, cmd.selection); + this.setContent(cmd.content, cmd.selection, true); this.updateRangeColor(); break; case "REPLACE_COMPOSER_CURSOR_SELECTION": @@ -19327,7 +19382,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A validateSelection(length, start, end) { return start >= 0 && start <= length && end >= 0 && end <= length ? 0 /* CommandResult.Success */ - : 43 /* CommandResult.WrongComposerSelection */; + : 44 /* CommandResult.WrongComposerSelection */; } onColumnsRemoved(cmd) { if (cmd.elements.includes(this.col) && this.mode !== "inactive") { @@ -19459,7 +19514,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A resetContent() { this.setContent(this.initialContent || ""); } - setContent(text, selection) { + setContent(text, selection, raise) { const isNewCurrentContent = this.currentContent !== text; this.currentContent = text; if (selection) { @@ -19471,6 +19526,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } if (isNewCurrentContent || this.mode !== "inactive") { this.currentTokens = text.startsWith("=") ? composerTokenize(text) : []; + if (this.currentTokens.length > 100) { + if (raise) { + this.ui.notifyUI({ + type: "ERROR", + text: _lt("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"), + }); + } + } } if (this.canStartComposerRangeSelection()) { this.startComposerRangeSelection(); @@ -19506,13 +19569,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A return selectedXc; } getRangeReference(range, fixedParts = [{ colFixed: false, rowFixed: false }]) { + let _fixedParts = [...fixedParts]; if (fixedParts.length === 1 && getZoneArea(range.zone) > 1) { - fixedParts.push({ ...fixedParts[0] }); + _fixedParts.push({ ...fixedParts[0] }); } else if (fixedParts.length === 2 && getZoneArea(range.zone) === 1) { - fixedParts.pop(); + _fixedParts.pop(); } - const newRange = range.clone({ parts: this.previousRange.parts }); + const newRange = range.clone({ parts: _fixedParts }); return this.getters.getSelectionRangeString(newRange, this.getters.getEditionSheet()); } /** @@ -19659,19 +19723,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A "getComposerHighlights", ]; - const functions$1 = functionRegistry.content; - const providerRegistry = new Registry(); - providerRegistry.add("functions", () => { - return Object.keys(functions$1).map((key) => { - return { - text: key, - description: functions$1[key].description, - }; - }); - }); - // ----------------------------------------------------------------------------- - // Autocomplete DropDown component - // ----------------------------------------------------------------------------- css /* scss */ ` .o-autocomplete-dropdown { pointer-events: auto; @@ -19698,69 +19749,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } `; class TextValueProvider extends owl.Component { - constructor() { - super(...arguments); - this.state = owl.useState({ - values: [], - selectedIndex: 0, - }); - } - setup() { - owl.onMounted(() => this.filter(this.props.search)); - owl.onWillUpdateProps((nextProps) => this.checkUpdateProps(nextProps)); - this.props.exposeAPI({ - getValueToFill: () => this.getValueToFill(), - moveDown: () => this.moveDown(), - moveUp: () => this.moveUp(), - }); - } - checkUpdateProps(nextProps) { - if (nextProps.search !== this.props.search) { - this.filter(nextProps.search); - } - } - async filter(searchTerm) { - const provider = providerRegistry.get(this.props.provider); - let values = provider(); - if (this.props.filter) { - values = this.props.filter(searchTerm, values); - } - else { - values = values - .filter((t) => t.text.toUpperCase().startsWith(searchTerm.toUpperCase())) - .sort((l, r) => (l.text < r.text ? -1 : l.text > r.text ? 1 : 0)); - } - this.state.values = values.slice(0, 10); - this.state.selectedIndex = 0; - } - fillValue(index) { - this.state.selectedIndex = index; - this.props.onCompleted(this.getValueToFill()); - } - moveDown() { - this.state.selectedIndex = (this.state.selectedIndex + 1) % this.state.values.length; - } - moveUp() { - this.state.selectedIndex--; - if (this.state.selectedIndex < 0) { - this.state.selectedIndex = this.state.values.length - 1; - } - } - getValueToFill() { - if (this.state.values.length) { - return this.state.values[this.state.selectedIndex].text; - } - return undefined; - } } TextValueProvider.template = "o-spreadsheet-TextValueProvider"; TextValueProvider.props = { - provider: String, - filter: { type: Function, optional: true }, - search: String, - borderStyle: String, - exposeAPI: Function, - onCompleted: Function, + values: Array, + selectedIndex: Number, + onValueSelected: Function, }; class ContentEditableHelper { @@ -19989,7 +19983,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A functionName: String, functionDescription: Object, argToFocus: Number, - borderStyle: String, }; const functions = functionRegistry.content; @@ -20043,6 +20036,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A margin: 4px; pointer-events: none; } + + .o-autocomplete-dropdown, + .o-formula-assistant-container { + box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15); + } } /* Custom css to highlight topbar composer on focus */ @@ -20061,8 +20059,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A }); this.autoCompleteState = owl.useState({ showProvider: false, - provider: "functions", - search: "", + values: [], + selectedIndex: 0, }); this.functionDescriptionState = owl.useState({ showDescription: false, @@ -20071,7 +20069,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A argToFocus: 0, }); this.isKeyStillDown = false; - this.borderStyle = `box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);`; // we can't allow input events to be triggered while we remove and add back the content of the composer in processContent this.shouldProcessInputEvents = false; this.tokens = []; @@ -20130,9 +20127,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A if (this.env.model.getters.isSelectingForComposer()) { this.functionDescriptionState.showDescription = false; // Prevent the default content editable behavior which moves the cursor - // but don't stop the event and let it bubble to the grid which will - // update the selection accordingly ev.preventDefault(); + ev.stopPropagation(); + updateSelectionWithArrowKeys(ev, this.env.model.selection); return; } const content = this.env.model.getters.getCurrentContent(); @@ -20142,25 +20139,33 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A this.env.model.dispatch("STOP_EDITION"); return; } + // All arrow keys are processed: up and down should move autocomplete, left + // and right should move the cursor. ev.stopPropagation(); + this.handleArrowKeysForAutocomplete(ev); + } + handleArrowKeysForAutocomplete(ev) { // only for arrow up and down - if (["ArrowUp", "ArrowDown"].includes(ev.key) && - this.autoCompleteState.showProvider && - this.autocompleteAPI) { + if (["ArrowUp", "ArrowDown"].includes(ev.key) && this.autoCompleteState.showProvider) { ev.preventDefault(); if (ev.key === "ArrowUp") { - this.autocompleteAPI.moveUp(); + this.autoCompleteState.selectedIndex--; + if (this.autoCompleteState.selectedIndex < 0) { + this.autoCompleteState.selectedIndex = this.autoCompleteState.values.length - 1; + } } else { - this.autocompleteAPI.moveDown(); + this.autoCompleteState.selectedIndex = + (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length; } } } processTabKey(ev) { + var _a; ev.preventDefault(); ev.stopPropagation(); - if (this.autoCompleteState.showProvider && this.autocompleteAPI) { - const autoCompleteValue = this.autocompleteAPI.getValueToFill(); + if (this.autoCompleteState.showProvider) { + const autoCompleteValue = (_a = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]) === null || _a === void 0 ? void 0 : _a.text; if (autoCompleteValue) { this.autoComplete(autoCompleteValue); return; @@ -20177,11 +20182,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A this.env.model.selection.moveAnchorCell(direction, "one"); } processEnterKey(ev) { + var _a; ev.preventDefault(); ev.stopPropagation(); this.isKeyStillDown = false; - if (this.autoCompleteState.showProvider && this.autocompleteAPI) { - const autoCompleteValue = this.autocompleteAPI.getValueToFill(); + if (this.autoCompleteState.showProvider) { + const autoCompleteValue = (_a = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]) === null || _a === void 0 ? void 0 : _a.text; if (autoCompleteValue) { this.autoComplete(autoCompleteValue); return; @@ -20243,8 +20249,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A ev.stopPropagation(); this.autoCompleteState.showProvider = false; if (ev.ctrlKey && ev.key === " ") { - this.autoCompleteState.search = ""; - this.autoCompleteState.showProvider = true; + this.showAutocomplete(""); this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"); return; } @@ -20256,6 +20261,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A this.processTokenAtCursor(); this.processContent(); } + showAutocomplete(searchTerm) { + this.autoCompleteState.showProvider = true; + let values = Object.entries(functionRegistry.content).map(([text, { description }]) => { + return { + text, + description, + }; + }); + values = values + .filter((t) => t.text.toUpperCase().startsWith(searchTerm.toUpperCase())) + .sort((l, r) => (l.text < r.text ? -1 : l.text > r.text ? 1 : 0)); + this.autoCompleteState.values = values.slice(0, 10); + this.autoCompleteState.selectedIndex = 0; + } onMousedown(ev) { if (ev.button > 0) { // not main button, probably a context menu @@ -20278,9 +20297,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A onBlur() { this.isKeyStillDown = false; } - onCompleted(text) { - text && this.autoComplete(text); - } // --------------------------------------------------------------------------- // Private // --------------------------------------------------------------------------- @@ -20303,11 +20319,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } getContent() { let content; - let value = this.env.model.getters.getCurrentContent(); + const value = this.env.model.getters.getCurrentContent(); + const isValidFormula = value.startsWith("=") && this.env.model.getters.getCurrentTokens().length > 0; if (value === "") { content = []; } - else if (value.startsWith("=") && this.props.focus !== "inactive") { + else if (isValidFormula && this.props.focus !== "inactive") { content = this.getColoredTokens(); } else { @@ -20319,8 +20336,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const tokens = this.env.model.getters.getCurrentTokens(); const tokenAtCursor = this.env.model.getters.getTokenAtCursor(); const result = []; - const { end, start } = this.env.model.getters.getComposerSelection(); - for (let token of tokens) { + const { start, end } = this.env.model.getters.getComposerSelection(); + for (const token of tokens) { switch (token.type) { case "OPERATOR": case "NUMBER": @@ -20400,8 +20417,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A if (tokenAtCursor.type === "FUNCTION" || (tokenAtCursor.type === "SYMBOL" && !rangeReference.test(xc))) { // initialize Autocomplete Dropdown - this.autoCompleteState.search = tokenAtCursor.value; - this.autoCompleteState.showProvider = true; + this.showAutocomplete(tokenAtCursor.value); } else if (tokenAtCursor.functionContext && tokenAtCursor.type !== "UNKNOWN") { // initialize Formula Assistant @@ -20428,7 +20444,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A start = tokenAtCursor.start; } const tokens = this.env.model.getters.getCurrentTokens(); - if (this.autoCompleteState.provider && tokens.length) { + if (tokens.length) { value += "("; const currentTokenIndex = tokens.map((token) => token.start).indexOf(tokenAtCursor.start); if (currentTokenIndex + 1 < tokens.length) { @@ -20981,6 +20997,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A id: figure.id, }); this.props.onFigureDeleted(); + ev.stopPropagation(); ev.preventDefault(); break; case "ArrowDown": @@ -21000,6 +21017,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A x: figure.x + delta[0], y: figure.y + delta[1], }); + ev.stopPropagation(); ev.preventDefault(); break; } @@ -22262,10 +22280,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A COL: colMenuRegistry, CELL: cellMenuRegistry, }; - // copy and paste are specific events that should not be managed by the keydown event, - // but they shouldn't be preventDefault and stopped (else copy and paste events will not trigger) - // and also should not result in typing the character C or V in the composer - const keyDownMappingIgnore = ["CTRL+C", "CTRL+V"]; // ----------------------------------------------------------------------------- // JS // ----------------------------------------------------------------------------- @@ -22380,6 +22394,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A }, PAGEDOWN: () => this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"), PAGEUP: () => this.env.model.dispatch("SHIFT_VIEWPORT_UP"), + "CTRL+K": () => INSERT_LINK(this.env), }; } setup() { @@ -22389,6 +22404,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A menuItems: [], }); this.gridRef = owl.useRef("grid"); + this.hiddenInput = owl.useRef("hiddenInput"); this.canvasPosition = useAbsolutePosition(this.gridRef); this.hoveredCell = owl.useState({ col: undefined, row: undefined }); owl.useExternalListener(document.body, "cut", this.copy.bind(this, true)); @@ -22422,7 +22438,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } focus() { if (!this.env.model.getters.getSelectedFigureId()) { - this.gridRef.el.focus(); + this.hiddenInput.el.focus(); } } get gridEl() { @@ -22530,19 +22546,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A ev.preventDefault(); ev.stopPropagation(); this.closeOpenedPopover(); - const arrowMap = { - ArrowDown: { direction: "down", delta: [0, 1] }, - ArrowLeft: { direction: "left", delta: [-1, 0] }, - ArrowRight: { direction: "right", delta: [1, 0] }, - ArrowUp: { direction: "up", delta: [0, -1] }, - }; - const { direction } = arrowMap[ev.key]; - if (ev.shiftKey) { - this.env.model.selection.resizeAnchorZone(direction, ev.ctrlKey ? "end" : "one"); - } - else { - this.env.model.selection.moveAnchorCell(direction, ev.ctrlKey ? "end" : "one"); - } + updateSelectionWithArrowKeys(ev, this.env.model.selection); if (this.env.model.getters.isPaintingFormat()) { this.env.model.dispatch("PASTE", { target: this.env.model.getters.getSelectedZones(), @@ -22571,14 +22575,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A handler(); return; } - if (!keyDownMappingIgnore.includes(keyDownString)) { - if (ev.key.length === 1 && !ev.ctrlKey && !ev.metaKey && !ev.altKey) { - // if the user types a character on the grid, it means he wants to start composing the selected cell with that - // character - ev.preventDefault(); - ev.stopPropagation(); - this.props.onGridComposerCellFocused(ev.key); - } + } + onInput(ev) { + if (ev.data) { + // if the user types a character on the grid, it means he wants to start composing the selected cell with that + // character + ev.preventDefault(); + ev.stopPropagation(); + this.props.onGridComposerCellFocused(ev.data); } } // --------------------------------------------------------------------------- @@ -27565,9 +27569,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A checkCellOutOfSheet(sheetId, col, row) { const sheet = this.getters.tryGetSheet(sheetId); if (!sheet) - return 25 /* CommandResult.InvalidSheetId */; + return 26 /* CommandResult.InvalidSheetId */; const sheetZone = this.getters.getSheetZone(sheetId); - return isInside(col, row, sheetZone) ? 0 /* CommandResult.Success */ : 16 /* CommandResult.TargetOutOfSheet */; + return isInside(col, row, sheetZone) ? 0 /* CommandResult.Success */ : 17 /* CommandResult.TargetOutOfSheet */; } } CellPlugin.getters = [ @@ -27690,6 +27694,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A // figure data should be external IMO => chart should be in sheet.chart // instead of in figure.data if (figure.tag === "chart") { + this.history.update("nextId", this.nextId + 1); this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id); } } @@ -27957,18 +27962,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } checkValidReordering(cfId, direction, sheetId) { if (!this.cfRules[sheetId]) - return 25 /* CommandResult.InvalidSheetId */; + return 26 /* CommandResult.InvalidSheetId */; const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId); if (ruleIndex === -1) - return 68 /* CommandResult.InvalidConditionalFormatId */; + return 69 /* CommandResult.InvalidConditionalFormatId */; const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1; if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) { - return 68 /* CommandResult.InvalidConditionalFormatId */; + return 69 /* CommandResult.InvalidConditionalFormatId */; } return 0 /* CommandResult.Success */; } checkEmptyRange(cmd) { - return cmd.ranges.length ? 0 /* CommandResult.Success */ : 22 /* CommandResult.EmptyRange */; + return cmd.ranges.length ? 0 /* CommandResult.Success */ : 23 /* CommandResult.EmptyRange */; } checkCFRule(cmd) { const rule = cmd.cf.rule; @@ -28004,10 +28009,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const errors = []; const isEmpty = (value) => value === undefined || value === ""; if (expectedNumber >= 1 && isEmpty(rule.values[0])) { - errors.push(48 /* CommandResult.FirstArgMissing */); + errors.push(49 /* CommandResult.FirstArgMissing */); } if (expectedNumber >= 2 && isEmpty(rule.values[1])) { - errors.push(49 /* CommandResult.SecondArgMissing */); + errors.push(50 /* CommandResult.SecondArgMissing */); } return errors.length ? errors : 0 /* CommandResult.Success */; } @@ -28019,15 +28024,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A (threshold.value === "" || isNaN(threshold.value))) { switch (thresholdName) { case "min": - return 50 /* CommandResult.MinNaN */; + return 51 /* CommandResult.MinNaN */; case "max": - return 52 /* CommandResult.MaxNaN */; + return 53 /* CommandResult.MaxNaN */; case "mid": - return 51 /* CommandResult.MidNaN */; + return 52 /* CommandResult.MidNaN */; case "upperInflectionPoint": - return 53 /* CommandResult.ValueUpperInflectionNaN */; + return 54 /* CommandResult.ValueUpperInflectionNaN */; case "lowerInflectionPoint": - return 54 /* CommandResult.ValueLowerInflectionNaN */; + return 55 /* CommandResult.ValueLowerInflectionNaN */; } } return 0 /* CommandResult.Success */; @@ -28041,15 +28046,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A catch (error) { switch (thresholdName) { case "min": - return 55 /* CommandResult.MinInvalidFormula */; + return 56 /* CommandResult.MinInvalidFormula */; case "max": - return 57 /* CommandResult.MaxInvalidFormula */; + return 58 /* CommandResult.MaxInvalidFormula */; case "mid": - return 56 /* CommandResult.MidInvalidFormula */; + return 57 /* CommandResult.MidInvalidFormula */; case "upperInflectionPoint": - return 58 /* CommandResult.ValueUpperInvalidFormula */; + return 59 /* CommandResult.ValueUpperInvalidFormula */; case "lowerInflectionPoint": - return 59 /* CommandResult.ValueLowerInvalidFormula */; + return 60 /* CommandResult.ValueLowerInvalidFormula */; } } return 0 /* CommandResult.Success */; @@ -28066,7 +28071,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) && rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type && Number(minValue) > Number(maxValue)) { - return 45 /* CommandResult.LowerBiggerThanUpper */; + return 46 /* CommandResult.LowerBiggerThanUpper */; } return 0 /* CommandResult.Success */; } @@ -28076,7 +28081,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A if (["number", "percentage", "percentile"].includes(rule.minimum.type) && rule.minimum.type === rule.maximum.type && stringToNumber(minValue) >= stringToNumber(maxValue)) { - return 44 /* CommandResult.MinBiggerThanMax */; + return 45 /* CommandResult.MinBiggerThanMax */; } return 0 /* CommandResult.Success */; } @@ -28088,7 +28093,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A ["number", "percentage", "percentile"].includes(rule.midpoint.type) && rule.midpoint.type === rule.maximum.type && stringToNumber(midValue) >= stringToNumber(maxValue)) { - return 46 /* CommandResult.MidBiggerThanMax */; + return 47 /* CommandResult.MidBiggerThanMax */; } return 0 /* CommandResult.Success */; } @@ -28100,7 +28105,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A ["number", "percentage", "percentile"].includes(rule.midpoint.type) && rule.minimum.type === rule.midpoint.type && stringToNumber(minValue) >= stringToNumber(midValue)) { - return 47 /* CommandResult.MinBiggerThanMid */; + return 48 /* CommandResult.MinBiggerThanMid */; } return 0 /* CommandResult.Success */; } @@ -28138,6 +28143,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A // --------------------------------------------------------------------------- allowDispatch(cmd) { switch (cmd.type) { + case "CREATE_FIGURE": + return this.checkFigureDuplicate(cmd.figure.id); case "UPDATE_FIGURE": case "DELETE_FIGURE": return this.checkFigureExists(cmd.sheetId, cmd.id); @@ -28199,7 +28206,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A checkFigureExists(sheetId, figureId) { var _a; if (((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === undefined) { - return 67 /* CommandResult.FigureDoesNotExist */; + return 68 /* CommandResult.FigureDoesNotExist */; + } + return 0 /* CommandResult.Success */; + } + checkFigureDuplicate(figureId) { + if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) { + return 80 /* CommandResult.DuplicatedFigureId */; } return 0 /* CommandResult.Success */; } @@ -28298,12 +28311,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A switch (cmd.type) { case "CREATE_FILTER_TABLE": if (!areZonesContinuous(...cmd.target)) { - return 78 /* CommandResult.NonContinuousTargets */; + return 79 /* CommandResult.NonContinuousTargets */; } const zone = union(...cmd.target); const checkFilterOverlap = () => { if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) { - return 75 /* CommandResult.FilterOverlap */; + return 76 /* CommandResult.FilterOverlap */; } return 0 /* CommandResult.Success */; }; @@ -28311,7 +28324,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone); for (let merge of mergesInTarget) { if (overlap(zone, merge)) { - return 77 /* CommandResult.MergeInFilter */; + return 78 /* CommandResult.MergeInFilter */; } } return 0 /* CommandResult.Success */; @@ -28321,7 +28334,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A for (let merge of cmd.target) { for (let filterTable of this.getFilterTables(cmd.sheetId)) { if (overlap(filterTable.zone, merge)) { - return 77 /* CommandResult.MergeInFilter */; + return 78 /* CommandResult.MergeInFilter */; } } } @@ -28785,7 +28798,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A switch (cmd.type) { case "HIDE_COLUMNS_ROWS": { if (!this.hiddenHeaders[cmd.sheetId]) { - return 25 /* CommandResult.InvalidSheetId */; + return 26 /* CommandResult.InvalidSheetId */; } const hiddenGroup = cmd.dimension === "COL" ? this.getHiddenColsGroups(cmd.sheetId) @@ -28795,7 +28808,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A : this.getters.getNumberRows(cmd.sheetId); return (hiddenGroup || []).flat().concat(cmd.elements).length < elements ? 0 /* CommandResult.Success */ - : 63 /* CommandResult.TooManyHiddenElements */; + : 64 /* CommandResult.TooManyHiddenElements */; } } return 0 /* CommandResult.Success */; @@ -29176,7 +29189,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A for (const zone of target) { for (const zone2 of target) { if (zone !== zone2 && overlap(zone, zone2)) { - return 62 /* CommandResult.MergeOverlap */; + return 63 /* CommandResult.MergeOverlap */; } } } @@ -29190,7 +29203,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A for (const zone of target) { if ((zone.left < xSplit && zone.right >= xSplit) || (zone.top < ySplit && zone.bottom >= ySplit)) { - return 72 /* CommandResult.FrozenPaneOverlap */; + return 73 /* CommandResult.FrozenPaneOverlap */; } } return 0 /* CommandResult.Success */; @@ -29404,7 +29417,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A .slice(0, currentIndex) .map((id) => !this.isSheetVisible(id)); return leftSheets.every((isHidden) => isHidden) - ? 12 /* CommandResult.WrongSheetMove */ + ? 13 /* CommandResult.WrongSheetMove */ : 0 /* CommandResult.Success */; } else { @@ -29412,7 +29425,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A .slice(currentIndex + 1) .map((id) => !this.isSheetVisible(id)); return rightSheets.every((isHidden) => isHidden) - ? 12 /* CommandResult.WrongSheetMove */ + ? 13 /* CommandResult.WrongSheetMove */ : 0 /* CommandResult.Success */; } case "RENAME_SHEET": @@ -29432,12 +29445,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A case "FREEZE_ROWS": { return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId) ? 0 /* CommandResult.Success */ - : 71 /* CommandResult.InvalidFreezeQuantity */; + : 72 /* CommandResult.InvalidFreezeQuantity */; } case "FREEZE_COLUMNS": { return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId) ? 0 /* CommandResult.Success */ - : 71 /* CommandResult.InvalidFreezeQuantity */; + : 72 /* CommandResult.InvalidFreezeQuantity */; } default: return 0 /* CommandResult.Success */; @@ -29853,14 +29866,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A return 10 /* CommandResult.DuplicatedSheetName */; } if (FORBIDDEN_IN_EXCEL_REGEX.test(name)) { - return 11 /* CommandResult.ForbiddenCharactersInSheetName */; + return 12 /* CommandResult.ForbiddenCharactersInSheetName */; } return 0 /* CommandResult.Success */; } checkSheetPosition(cmd) { const { orderedSheetIds } = this; if (cmd.position > orderedSheetIds.length || cmd.position < 0) { - return 13 /* CommandResult.WrongSheetPosition */; + return 14 /* CommandResult.WrongSheetPosition */; } return 0 /* CommandResult.Success */; } @@ -30173,7 +30186,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A */ checkSheetExists(cmd) { if (cmd.type !== "CREATE_SHEET" && "sheetId" in cmd && this.sheets[cmd.sheetId] === undefined) { - return 25 /* CommandResult.InvalidSheetId */; + return 26 /* CommandResult.InvalidSheetId */; + } + else if (cmd.type === "CREATE_SHEET" && this.sheets[cmd.sheetId] !== undefined) { + return 11 /* CommandResult.DuplicatedSheetId */; } return 0 /* CommandResult.Success */; } @@ -30193,13 +30209,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone)); } if (!zones.every(isZoneValid)) { - return 23 /* CommandResult.InvalidRange */; + return 24 /* CommandResult.InvalidRange */; } else if (zones.length && "sheetId" in cmd) { const sheetZone = this.getSheetZone(cmd.sheetId); return zones.every((zone) => isZoneInside(zone, sheetZone)) ? 0 /* CommandResult.Success */ - : 16 /* CommandResult.TargetOutOfSheet */; + : 17 /* CommandResult.TargetOutOfSheet */; } return 0 /* CommandResult.Success */; } @@ -30310,7 +30326,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) { return 0 /* CommandResult.Success */; } - return 42 /* CommandResult.InvalidAutofillSelection */; + return 43 /* CommandResult.InvalidAutofillSelection */; case "AUTOFILL_AUTO": const zone = this.getters.getSelectedZone(); return zone.top === zone.bottom @@ -30906,7 +30922,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A cellPopoverRegistry.get(cmd.popoverType); } catch (error) { - return 69 /* CommandResult.InvalidCellPopover */; + return 70 /* CommandResult.InvalidCellPopover */; } return 0 /* CommandResult.Success */; default: @@ -31098,7 +31114,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } isCutAllowed(target) { if (target.length !== 1) { - return 17 /* CommandResult.WrongCutSelection */; + return 18 /* CommandResult.WrongCutSelection */; } return 0 /* CommandResult.Success */; } @@ -31106,13 +31122,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const sheetId = this.getters.getActiveSheetId(); if (this.operation === "CUT" && (clipboardOption === null || clipboardOption === void 0 ? void 0 : clipboardOption.pasteOption) !== undefined) { // cannot paste only format or only value if the previous operation is a CUT - return 19 /* CommandResult.WrongPasteOption */; + return 20 /* CommandResult.WrongPasteOption */; } if (target.length > 1) { // cannot paste if we have a clipped zone larger than a cell and multiple // zones selected if (this.cells.length > 1 || this.cells[0].length > 1) { - return 18 /* CommandResult.WrongPasteSelection */; + return 19 /* CommandResult.WrongPasteSelection */; } } const clipboardHeight = this.cells.length; @@ -31130,7 +31146,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A for (const zone of this.getPasteZones(target)) { if ((zone.left < xSplit && zone.right >= xSplit) || (zone.top < ySplit && zone.bottom >= ySplit)) { - return 72 /* CommandResult.FrozenPaneOverlap */; + return 73 /* CommandResult.FrozenPaneOverlap */; } } return 0 /* CommandResult.Success */; @@ -31490,10 +31506,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } isPasteAllowed(target, option) { if (target.length === 0) { - return 70 /* CommandResult.EmptyTarget */; + return 71 /* CommandResult.EmptyTarget */; } if ((option === null || option === void 0 ? void 0 : option.pasteOption) !== undefined) { - return 20 /* CommandResult.WrongFigurePasteOption */; + return 21 /* CommandResult.WrongFigurePasteOption */; } return 0 /* CommandResult.Success */; } @@ -31613,7 +31629,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A return state.isCutAllowed(zones); case "PASTE": if (!this.state) { - return 21 /* CommandResult.EmptyClipboard */; + return 22 /* CommandResult.EmptyClipboard */; } const pasteOption = cmd.pasteOption || (this._isPaintingFormat ? "onlyFormat" : undefined); return this.state.isPasteAllowed(cmd.target, { pasteOption }); @@ -32628,7 +32644,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A switch (cmd.type) { case "UPDATE_FILTER": if (!this.getters.getFilterId(cmd.sheetId, cmd.col, cmd.row)) { - return 76 /* CommandResult.FilterNotFound */; + return 77 /* CommandResult.FilterNotFound */; } break; } @@ -33924,7 +33940,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A break; } catch (error) { - return 25 /* CommandResult.InvalidSheetId */; + return 26 /* CommandResult.InvalidSheetId */; } case "MOVE_COLUMNS_ROWS": return this.isMoveElementAllowed(cmd); @@ -33950,6 +33966,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A break; } this.setSelectionMixin(event.anchor, zones); + /** Any change to the selection has to be reflected in the selection processor. */ + this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor)); const { col, row } = this.gridSelection.anchor.cell; this.moveClient({ sheetId: this.getters.getActiveSheetId(), @@ -33982,11 +34000,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A sheetIdTo: firstSheetId, sheetIdFrom: firstSheetId, }); + const { col, row } = this.getters.getNextVisibleCellPosition(firstSheetId, 0, 0); + this.selectCell(col, row); this.selection.registerAsDefault(this, this.gridSelection.anchor, { handleEvent: this.handleEvent.bind(this), }); - const { col, row } = this.getters.getNextVisibleCellPosition(firstSheetId, 0, 0); - this.selectCell(col, row); this.moveClient({ sheetId: firstSheetId, col: 0, row: 0 }); break; case "ACTIVATE_SHEET": { @@ -33999,7 +34017,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A }; if (cmd.sheetIdTo in this.sheetsData) { Object.assign(this, this.sheetsData[cmd.sheetIdTo]); - this.selection.resetDefaultAnchor(this, this.gridSelection.anchor); + this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor)); } else { const { col, row } = this.getters.getNextVisibleCellPosition(cmd.sheetIdTo, 0, 0); @@ -34085,8 +34103,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const sheetId = this.getters.getActiveSheetId(); this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z)); this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone); - this.ensureSelectionValidity(); + this.setSelectionMixin(this.gridSelection.anchor, this.gridSelection.zones); + break; } + /** Any change to the selection has to be reflected in the selection processor. */ + this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor)); } // --------------------------------------------------------------------------- // Getters @@ -34234,11 +34255,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A // --------------------------------------------------------------------------- // Other // --------------------------------------------------------------------------- + /** + * Ensure selections are not outside sheet boundaries. + * They are clipped to fit inside the sheet if needed. + */ setSelectionMixin(anchor, zones) { const { anchor: clippedAnchor, zones: clippedZones } = this.clipSelection(this.getters.getActiveSheetId(), { anchor, zones }); - this.gridSelection.anchor.cell.col = clippedAnchor.cell.col; - this.gridSelection.anchor.cell.row = clippedAnchor.cell.row; - this.gridSelection.anchor.zone = clippedAnchor.zone; + this.gridSelection.anchor = clippedAnchor; this.gridSelection.zones = uniqueZones(clippedZones); } /** @@ -34280,7 +34303,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A zone: selectedZone, }; this.setSelectionMixin(anchor, [selectedZone]); - this.ensureSelectionValidity(); } onRowsRemoved(cmd) { const { cell, zone } = this.gridSelection.anchor; @@ -34295,7 +34317,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A zone: selectedZone, }; this.setSelectionMixin(anchor, [selectedZone]); - this.ensureSelectionValidity(); } onAddElements(cmd) { const selection = this.gridSelection.anchor.zone; @@ -34376,17 +34397,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A //------------------------------------------- // Helpers for extensions // ------------------------------------------ - /** - * Ensure selections are not outside sheet boundaries. - * They are clipped to fit inside the sheet if needed. - */ - ensureSelectionValidity() { - let { anchor, zones } = this.clipSelection(this.getters.getActiveSheetId(), this.gridSelection); - this.gridSelection.zones = uniqueZones(zones); - this.gridSelection.anchor.cell.col = anchor.cell.col; - this.gridSelection.anchor.cell.row = anchor.cell.row; - this.gridSelection.anchor.zone = anchor.zone; - } /** * Clip the selection if it spans outside the sheet */ @@ -34483,7 +34493,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A "getElementsFromSelection", ]; - const uuidGenerator = new UuidGenerator(); /** * Selection input Plugin * @@ -34512,7 +34521,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A switch (cmd.type) { case "ADD_EMPTY_RANGE": if (this.inputHasSingleRange && this.ranges.length === 1) { - return 27 /* CommandResult.MaximumRangesReached */; + return 28 /* CommandResult.MaximumRangesReached */; } break; } @@ -34618,7 +34627,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A setContent(index, xc) { this.ranges[index] = { ...this.ranges[index], - id: uuidGenerator.uuidv4(), xc, }; } @@ -34731,7 +34739,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A case "FOCUS_RANGE": const index = (_a = this.currentInput) === null || _a === void 0 ? void 0 : _a.getIndex(cmd.rangeId); if (this.focusedInputId === cmd.id && ((_b = this.currentInput) === null || _b === void 0 ? void 0 : _b.focusedRangeIndex) === index) { - return 26 /* CommandResult.InputAlreadyFocused */; + return 27 /* CommandResult.InputAlreadyFocused */; } break; } @@ -34757,11 +34765,19 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A break; case "ADD_EMPTY_RANGE": case "REMOVE_RANGE": + if (cmd.id !== this.focusedInputId) { + const input = this.inputs[cmd.id]; + this.selection.capture(input, { cell: { col: 0, row: 0 }, zone: positionToZone({ col: 0, row: 0 }) }, { handleEvent: input.handleEvent.bind(input) }); + this.focusedInputId = cmd.id; + } + break; case "FOCUS_RANGE": case "CHANGE_RANGE": if (cmd.id !== this.focusedInputId) { const input = this.inputs[cmd.id]; - this.selection.capture(input, { cell: { col: 0, row: 0 }, zone: positionToZone({ col: 0, row: 0 }) }, { handleEvent: input.handleEvent.bind(input) }); + const range = input.ranges.find((range) => range.id === cmd.rangeId); + const zone = toZone((range === null || range === void 0 ? void 0 : range.xc) || "A1"); + this.selection.capture(input, { cell: { col: zone.left, row: zone.top }, zone }, { handleEvent: input.handleEvent.bind(input) }); this.focusedInputId = cmd.id; } break; @@ -35674,7 +35690,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const merges = this.getters.getMerges(sheetId); for (let merge of merges) { if (merge.left < cmd.quantity && cmd.quantity <= merge.right) { - return 62 /* CommandResult.MergeOverlap */; + return 63 /* CommandResult.MergeOverlap */; } } return 0 /* CommandResult.Success */; @@ -35684,7 +35700,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const merges = this.getters.getMerges(sheetId); for (let merge of merges) { if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) { - return 62 /* CommandResult.MergeOverlap */; + return 63 /* CommandResult.MergeOverlap */; } } return 0 /* CommandResult.Success */; @@ -35701,7 +35717,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A case "ZonesSelected": // altering a zone should not move the viewport const sheetId = this.getters.getActiveSheetId(); - let { col, row } = findCellInNewZone(event.previousAnchor.zone, event.anchor.zone); + let { col, row } = findCellInNewZone(event.previousAnchor.zone, event.anchor.zone, this.getters.getActiveMainViewport()); col = Math.min(col, this.getters.getNumberCols(sheetId) - 1); row = Math.min(row, this.getters.getNumberRows(sheetId) - 1); this.refreshViewport(this.getters.getActiveSheetId(), { col, row }); @@ -36003,7 +36019,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } checkPositiveDimension(cmd) { if (cmd.width < 0 || cmd.height < 0) { - return 65 /* CommandResult.InvalidViewportSize */; + return 66 /* CommandResult.InvalidViewportSize */; } return 0 /* CommandResult.Success */; } @@ -36013,7 +36029,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A cmd.gridOffsetY === this.gridOffsetY && cmd.width === width && cmd.height === height) { - return 73 /* CommandResult.ValuesNotChanged */; + return 74 /* CommandResult.ValuesNotChanged */; } return 0 /* CommandResult.Success */; } @@ -36021,7 +36037,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const pane = this.getMainInternalViewport(this.getters.getActiveSheetId()); if ((!pane.canScrollHorizontally && offsetX > 0) || (!pane.canScrollVertically && offsetY > 0)) { - return 66 /* CommandResult.InvalidScrollingDirection */; + return 67 /* CommandResult.InvalidScrollingDirection */; } return 0 /* CommandResult.Success */; } @@ -36231,7 +36247,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A for (let row = zone.top; row <= zone.bottom; row++) { for (let col = zone.left; col <= zone.right; col++) { if (!this.getters.isInMerge(sheetId, col, row)) { - return 60 /* CommandResult.InvalidSortZone */; + return 61 /* CommandResult.InvalidSortZone */; } } } @@ -36252,7 +36268,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A ]; return widthCurrent === widthFirst && heightCurrent === heightFirst; })) { - return 60 /* CommandResult.InvalidSortZone */; + return 61 /* CommandResult.InvalidSortZone */; } return 0 /* CommandResult.Success */; } @@ -36537,7 +36553,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A break; } catch (error) { - return 25 /* CommandResult.InvalidSheetId */; + return 26 /* CommandResult.InvalidSheetId */; } } return 0 /* CommandResult.Success */; @@ -37408,7 +37424,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A env.model.dispatch("ADD_MERGE", { sheetId, target, force: true }); }); } - else if (result.isCancelledBecause(77 /* CommandResult.MergeInFilter */)) { + else if (result.isCancelledBecause(78 /* CommandResult.MergeInFilter */)) { env.raiseError(AddMergeInteractiveContent.MergeInFilter); } } @@ -39285,7 +39301,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A } allowDispatch(cmd) { if (this.isWaitingForUndoRedo) { - return 61 /* CommandResult.WaitingSessionConfirmation */; + return 62 /* CommandResult.WaitingSessionConfirmation */; } switch (cmd.type) { case "REQUEST_UNDO": @@ -39366,7 +39382,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A // --------------------------------------------------------------------------- allowDispatch(cmd) { if (cmd.type === "MOVE_RANGES") { - return cmd.target.length === 1 ? 0 /* CommandResult.Success */ : 24 /* CommandResult.InvalidZones */; + return cmd.target.length === 1 ? 0 /* CommandResult.Success */ : 25 /* CommandResult.InvalidZones */; } return 0 /* CommandResult.Success */; } @@ -39571,9 +39587,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A : range.unboundedZone.bottom + ((range.parts[1] || range.parts[0]).rowFixed ? 0 : offsetY), }; - range = range.clone({ sheetId: copySheetId, zone: unboundZone }); - range.orderZone(); - return range; + return range.clone({ sheetId: copySheetId, zone: unboundZone }).orderZone(); }); } /** @@ -39604,9 +39618,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const invalidSheetName = sheetName && !this.getters.getSheetIdByName(sheetName) ? sheetName : undefined; const sheetId = this.getters.getSheetIdByName(sheetName) || defaultSheetId; const rangeInterface = { prefixSheet, zone, sheetId, invalidSheetName, parts }; - const range = new RangeImpl(rangeInterface, this.getters.getSheetSize); - range.orderZone(); - return range; + return new RangeImpl(rangeInterface, this.getters.getSheetSize).orderZone(); } /** * Same as `getRangeString` but add all necessary merge to the range to make it a valid selection @@ -39919,7 +39931,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A addCellToSelection(col, row) { const sheetId = this.getters.getActiveSheetId(); ({ col, row } = this.getters.getMainCellPosition(sheetId, col, row)); - const zone = positionToZone({ col, row }); + const zone = this.getters.expandZone(sheetId, positionToZone({ col, row })); return this.processEvent({ type: "ZonesSelected", anchor: { zone, cell: { col, row } }, @@ -40131,20 +40143,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A checkAnchorZone(anchor) { const { cell, zone } = anchor; if (!isInside(cell.col, cell.row, zone)) { - return 14 /* CommandResult.InvalidAnchorZone */; + return 15 /* CommandResult.InvalidAnchorZone */; } const { left, right, top, bottom } = zone; const sheetId = this.getters.getActiveSheetId(); const refCol = this.getters.findVisibleHeader(sheetId, "COL", range(left, right + 1)); const refRow = this.getters.findVisibleHeader(sheetId, "ROW", range(top, bottom + 1)); if (refRow === undefined || refCol === undefined) { - return 15 /* CommandResult.SelectionOutOfBound */; + return 16 /* CommandResult.SelectionOutOfBound */; } return 0 /* CommandResult.Success */; } checkAnchorZoneOrThrow(anchor) { const result = this.checkAnchorZone(anchor); - if (result === 14 /* CommandResult.InvalidAnchorZone */) { + if (result === 15 /* CommandResult.InvalidAnchorZone */) { throw new Error(_t("The provided anchor is invalid. The cell must be part of the zone.")); } } @@ -41837,6 +41849,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A super(); this.corePlugins = []; this.uiPlugins = []; + /** + * In a collaborative context, some commands can be replayed, we have to ensure + * that these commands are not replayed on the UI plugins. + */ + this.isReplayingCommand = false; /** * A plugin can draw some contents on the canvas. But even better: it can do * so multiple times. The order of the render calls will determine a list of @@ -41867,7 +41884,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const command = { type, ...payload }; let status = this.status; if (this.getters.isReadonly() && !canExecuteInReadonly(command)) { - return new DispatchResult(64 /* CommandResult.Readonly */); + return new DispatchResult(65 /* CommandResult.Readonly */); } switch (status) { case 0 /* Status.Ready */: @@ -41912,7 +41929,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A const command = { type, ...payload }; const previousStatus = this.status; this.status = 2 /* Status.RunningCore */; - this.dispatchToHandlers(this.handlers, command); + const handlers = this.isReplayingCommand ? [this.range, ...this.corePlugins] : this.handlers; + this.dispatchToHandlers(handlers, command); this.status = previousStatus; return DispatchResult.Success; }; @@ -42026,7 +42044,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A this.finalize(); } setupSession(revisionId) { - const session = new Session(buildRevisionLog(revisionId, this.state.recordChanges.bind(this.state), (command) => this.dispatchToHandlers([this.range, ...this.corePlugins], command)), this.config.transportService, revisionId); + const session = new Session(buildRevisionLog(revisionId, this.state.recordChanges.bind(this.state), (command) => { + this.isReplayingCommand = true; + this.dispatchToHandlers([this.range, ...this.corePlugins], command); + this.isReplayingCommand = false; + }), this.config.transportService, revisionId); return session; } setupSessionEvents() { @@ -42283,8 +42305,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A Object.defineProperty(exports, '__esModule', { value: true }); exports.__info__.version = '2.0.0'; - exports.__info__.date = '2022-11-03T06:57:12.461Z'; - exports.__info__.hash = '7112f4d'; + exports.__info__.date = '2022-11-16T08:24:59.755Z'; + exports.__info__.hash = '1b4fac5'; })(this.o_spreadsheet = this.o_spreadsheet || {}, owl); //# sourceMappingURL=o_spreadsheet.js.map diff --git a/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.xml b/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.xml index f30d47de0e0..d0a61442495 100644 --- a/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.xml +++ b/addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.xml @@ -150,18 +150,16 @@ -
- +
+
+ t-att-class="{'o-autocomplete-value-focus': props.selectedIndex === v_index}" + t-on-click.stop.prevent="() => this.props.onValueSelected(v.text)">
@@ -183,6 +181,7 @@ t-on-keyup="onKeyup" t-on-click.stop="onClick" t-on-blur="onBlur" + t-on-paste.stop="" />
@@ -211,7 +207,6 @@
@@ -592,6 +587,14 @@ focus="props.focusComposer" /> + + +
Text
@@ -1517,6 +1520,7 @@ spellcheck="false" t-on-change="(ev) => this.onInputChanged(range.id, ev)" t-on-focus="() => this.focus(range.id)" + t-on-keydown="onKeydown" t-att-value="range.xc" t-att-style="getColor(range)" t-att-class="{ @@ -1524,6 +1528,7 @@ 'o-required': props.required, 'o-optional': !props.required, 'o-invalid': isInvalid || !range.isValidRange, + 'text-decoration-underline': range.isFocused and state.mode === 'select-range' }" />