@odoo/o-spreadsheet 18.0.1 → 18.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 18.0.1
6
- * @date 2024-10-14T07:54:24.768Z
7
- * @hash 1771f68
5
+ * @version 18.1.0-alpha.1
6
+ * @date 2024-10-14T07:53:17.717Z
7
+ * @hash e9ce3aa
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -6075,18 +6075,9 @@
6075
6075
  * https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
6076
6076
  * */
6077
6077
  class UuidGenerator {
6078
- isFastIdStrategy = false;
6079
- fastIdStart = 0;
6080
- setIsFastStrategy(isFast) {
6081
- this.isFastIdStrategy = isFast;
6082
- }
6083
6078
  uuidv4() {
6084
- if (this.isFastIdStrategy) {
6085
- this.fastIdStart++;
6086
- return String(this.fastIdStart);
6087
- //@ts-ignore
6088
- }
6089
- else if (window.crypto && window.crypto.getRandomValues) {
6079
+ //@ts-ignore
6080
+ if (window.crypto && window.crypto.getRandomValues) {
6090
6081
  //@ts-ignore
6091
6082
  return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16));
6092
6083
  }
@@ -9289,6 +9280,49 @@ stores.inject(MyMetaStore, storeInstance);
9289
9280
  useLeftAxis ||= !useRightAxis;
9290
9281
  return { useLeftAxis, useRightAxis };
9291
9282
  }
9283
+ function getChartAxis(definition, position, type, options) {
9284
+ const { useLeftAxis, useRightAxis } = getDefinedAxis(definition);
9285
+ if ((position === "left" && !useLeftAxis) || (position === "right" && !useRightAxis)) {
9286
+ return undefined;
9287
+ }
9288
+ const fontColor = chartFontColor(definition.background);
9289
+ let design;
9290
+ if (position === "bottom") {
9291
+ design = definition.axesDesign?.x;
9292
+ }
9293
+ else if (position === "left") {
9294
+ design = definition.axesDesign?.y;
9295
+ }
9296
+ else {
9297
+ design = definition.axesDesign?.y1;
9298
+ }
9299
+ if (type === "values") {
9300
+ const displayGridLines = position === "left" || (position === "right" && !useLeftAxis);
9301
+ return {
9302
+ position: position,
9303
+ title: getChartAxisTitleRuntime(design),
9304
+ grid: {
9305
+ display: displayGridLines,
9306
+ },
9307
+ beginAtZero: true,
9308
+ stacked: options?.stacked,
9309
+ ticks: {
9310
+ color: fontColor,
9311
+ callback: formatTickValue(options),
9312
+ },
9313
+ };
9314
+ }
9315
+ else {
9316
+ return {
9317
+ ticks: {
9318
+ padding: 5,
9319
+ color: fontColor,
9320
+ },
9321
+ stacked: options?.stacked,
9322
+ title: getChartAxisTitleRuntime(design),
9323
+ };
9324
+ }
9325
+ }
9292
9326
  function computeChartPadding({ displayTitle, displayLegend, }) {
9293
9327
  let top = 25;
9294
9328
  if (displayTitle) {
@@ -9375,6 +9409,12 @@ stores.inject(MyMetaStore, storeInstance);
9375
9409
  return [];
9376
9410
  }
9377
9411
  }
9412
+ function formatChartDatasetValue(axisFormats, locale) {
9413
+ return (value, axisId) => {
9414
+ const format = axisId ? axisFormats?.[axisId] : undefined;
9415
+ return formatTickValue({ format, locale })(value);
9416
+ };
9417
+ }
9378
9418
  function formatTickValue(localeFormat) {
9379
9419
  return (value) => {
9380
9420
  value = Number(value);
@@ -9437,10 +9477,12 @@ stores.inject(MyMetaStore, storeInstance);
9437
9477
  case "bar":
9438
9478
  case "line": {
9439
9479
  const yOffset = dataset.type === "bar" && !options.horizontal ? 0 : 3;
9480
+ const horizontalChart = dataset.type === "bar" && options.horizontal;
9481
+ const axisId = horizontalChart ? dataset.xAxisID : dataset.yAxisID;
9440
9482
  for (let i = 0; i < dataset._parsed.length; i++) {
9441
9483
  const point = dataset.data[i];
9442
9484
  const value = options.horizontal ? dataset._parsed[i].x : dataset._parsed[i].y;
9443
- const displayedValue = options.callback(value - 0);
9485
+ const displayedValue = options.callback(value - 0, axisId);
9444
9486
  let xPosition = 0, yPosition = 0;
9445
9487
  if (options.horizontal) {
9446
9488
  yPosition = point.y;
@@ -20171,7 +20213,7 @@ stores.inject(MyMetaStore, storeInstance);
20171
20213
  let startNode = this.findChildAtCharacterIndex(start);
20172
20214
  let endNode = this.findChildAtCharacterIndex(end);
20173
20215
  range.setStart(startNode.node, startNode.offset);
20174
- selection.extend(endNode.node, endNode.offset);
20216
+ range.setEnd(endNode.node, endNode.offset);
20175
20217
  }
20176
20218
  }
20177
20219
  /**
@@ -20669,7 +20711,7 @@ stores.inject(MyMetaStore, storeInstance);
20669
20711
  "Alt+Enter": this.processNewLineEvent,
20670
20712
  "Ctrl+Enter": this.processNewLineEvent,
20671
20713
  Escape: this.processEscapeKey,
20672
- F2: () => console.warn("Not implemented"),
20714
+ F2: (ev) => this.toggleEditionMode(ev),
20673
20715
  F4: (ev) => this.processF4Key(ev),
20674
20716
  Tab: (ev) => this.processTabKey(ev, "right"),
20675
20717
  "Shift+Tab": (ev) => this.processTabKey(ev, "left"),
@@ -20788,6 +20830,11 @@ stores.inject(MyMetaStore, storeInstance);
20788
20830
  this.props.composerStore.cycleReferences();
20789
20831
  this.processContent();
20790
20832
  }
20833
+ toggleEditionMode(ev) {
20834
+ ev.stopPropagation();
20835
+ this.props.composerStore.toggleEditionMode();
20836
+ this.processContent();
20837
+ }
20791
20838
  processNumpadDecimal(ev) {
20792
20839
  ev.stopPropagation();
20793
20840
  ev.preventDefault();
@@ -21013,7 +21060,13 @@ stores.inject(MyMetaStore, storeInstance);
21013
21060
  break;
21014
21061
  case "REFERENCE":
21015
21062
  const { xc, sheetName } = splitReference(token.value);
21016
- result.push({ value: token.value, color: this.rangeColor(xc, sheetName) || "#000" });
21063
+ result.push({
21064
+ value: token.value,
21065
+ color: this.rangeColor(xc, sheetName) || "#000",
21066
+ class: tokenAtCursor === token && this.props.composerStore.editionMode === "selecting"
21067
+ ? "text-decoration-underline"
21068
+ : undefined,
21069
+ });
21017
21070
  break;
21018
21071
  case "SYMBOL":
21019
21072
  const value = token.value;
@@ -28039,9 +28092,9 @@ stores.inject(MyMetaStore, storeInstance);
28039
28092
  /**
28040
28093
  * Get a default chart js configuration
28041
28094
  */
28042
- function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true, horizontalChart, }) {
28095
+ function getDefaultChartJsRuntime(chart, labels, fontColor, { axisFormats, locale, truncateLabels = true, horizontalChart }) {
28043
28096
  const chartTitle = chart.title.text ? chart.title : { ...chart.title, content: "" };
28044
- const options = {
28097
+ const chartOptions = {
28045
28098
  // https://www.chartjs.org/docs/latest/general/responsive.html
28046
28099
  responsive: true, // will resize when its container is resized
28047
28100
  maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
@@ -28088,8 +28141,10 @@ stores.inject(MyMetaStore, storeInstance);
28088
28141
  if (!yLabel) {
28089
28142
  yLabel = tooltipItem.parsed;
28090
28143
  }
28091
- const toolTipFormat = !format && Math.abs(yLabel) >= 1000 ? "#,##" : format;
28092
- const yLabelStr = formatValue(yLabel, { format: toolTipFormat, locale });
28144
+ const axisId = horizontalChart
28145
+ ? tooltipItem.dataset.xAxisID
28146
+ : tooltipItem.dataset.yAxisID;
28147
+ const yLabelStr = formatChartDatasetValue(axisFormats, locale)(yLabel, axisId);
28093
28148
  return xLabel ? `${xLabel}: ${yLabelStr}` : yLabelStr;
28094
28149
  },
28095
28150
  },
@@ -28098,7 +28153,7 @@ stores.inject(MyMetaStore, storeInstance);
28098
28153
  };
28099
28154
  return {
28100
28155
  type: chart.type,
28101
- options,
28156
+ options: chartOptions,
28102
28157
  data: {
28103
28158
  labels: truncateLabels ? labels.map(truncateLabel) : labels,
28104
28159
  datasets: [],
@@ -28157,7 +28212,8 @@ stores.inject(MyMetaStore, storeInstance);
28157
28212
  * Get the format to apply to the the dataset values. This format is defined as the first format
28158
28213
  * found in the dataset ranges that isn't a date format.
28159
28214
  */
28160
- function getChartDatasetFormat(getters, dataSets) {
28215
+ function getChartDatasetFormat(getters, allDataSets, axis) {
28216
+ const dataSets = allDataSets.filter((ds) => (axis === "right") === !!ds.rightYAxis);
28161
28217
  for (const ds of dataSets) {
28162
28218
  const formatsInDataset = getters.getRangeFormats(ds.dataRange);
28163
28219
  const format = formatsInDataset.find((f) => f !== undefined && !isDateTimeFormat(f));
@@ -28411,12 +28467,16 @@ stores.inject(MyMetaStore, storeInstance);
28411
28467
  if (chart.aggregated) {
28412
28468
  ({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
28413
28469
  }
28414
- const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
28470
+ const leftAxisFormat = getChartDatasetFormat(getters, chart.dataSets, "left");
28471
+ const rightAxisFormat = getChartDatasetFormat(getters, chart.dataSets, "right");
28415
28472
  const locale = getters.getLocale();
28416
- const localeFormat = { format: dataSetFormat, locale };
28417
28473
  const fontColor = chartFontColor(chart.background);
28474
+ const axisFormats = chart.horizontal
28475
+ ? { x: leftAxisFormat || rightAxisFormat }
28476
+ : { y: leftAxisFormat, y1: rightAxisFormat };
28418
28477
  const config = getDefaultChartJsRuntime(chart, labels, fontColor, {
28419
- ...localeFormat,
28478
+ locale,
28479
+ axisFormats,
28420
28480
  horizontalChart: chart.horizontal,
28421
28481
  });
28422
28482
  const legend = {
@@ -28437,51 +28497,27 @@ stores.inject(MyMetaStore, storeInstance);
28437
28497
  };
28438
28498
  config.options.indexAxis = chart.horizontal ? "y" : "x";
28439
28499
  config.options.scales = {};
28440
- const labelsAxis = { ticks: { padding: 5, color: fontColor } };
28441
- const valuesAxis = {
28442
- beginAtZero: true, // the origin of the y axis is always zero
28443
- ticks: {
28444
- color: fontColor,
28445
- callback: formatTickValue(localeFormat),
28446
- },
28447
- };
28448
- const xAxis = chart.horizontal ? valuesAxis : labelsAxis;
28449
- const yAxis = chart.horizontal ? labelsAxis : valuesAxis;
28450
- const { useLeftAxis, useRightAxis } = getDefinedAxis(chart.getDefinition());
28451
- config.options.scales.x = { ...xAxis, title: getChartAxisTitleRuntime(chart.axesDesign?.x) };
28452
- if (useLeftAxis) {
28453
- config.options.scales.y = {
28454
- ...yAxis,
28455
- position: "left",
28456
- title: getChartAxisTitleRuntime(chart.axesDesign?.y),
28457
- };
28458
- }
28459
- if (useRightAxis) {
28460
- config.options.scales.y1 = {
28461
- ...yAxis,
28462
- position: "right",
28463
- title: getChartAxisTitleRuntime(chart.axesDesign?.y1),
28464
- };
28500
+ const definition = chart.getDefinition();
28501
+ const options = { stacked: chart.stacked, locale };
28502
+ if (chart.horizontal) {
28503
+ const format = leftAxisFormat || rightAxisFormat;
28504
+ config.options.scales.x = getChartAxis(definition, "bottom", "values", { ...options, format });
28505
+ config.options.scales.y = getChartAxis(definition, "left", "labels", options);
28465
28506
  }
28466
- if (chart.stacked) {
28467
- // @ts-ignore chart.js type is broken
28468
- config.options.scales.x.stacked = true;
28469
- if (useLeftAxis) {
28470
- // @ts-ignore chart.js type is broken
28471
- config.options.scales.y.stacked = true;
28472
- }
28473
- if (useRightAxis) {
28474
- // @ts-ignore chart.js type is broken
28475
- config.options.scales.y1.stacked = true;
28476
- }
28507
+ else {
28508
+ config.options.scales.x = getChartAxis(definition, "bottom", "labels", options);
28509
+ const leftAxisOptions = { ...options, format: leftAxisFormat };
28510
+ config.options.scales.y = getChartAxis(definition, "left", "values", leftAxisOptions);
28511
+ const rightAxisOptions = { ...options, format: rightAxisFormat };
28512
+ config.options.scales.y1 = getChartAxis(definition, "right", "values", rightAxisOptions);
28477
28513
  }
28514
+ config.options.scales = removeFalsyAttributes(config.options.scales);
28478
28515
  config.options.plugins.chartShowValuesPlugin = {
28479
28516
  showValues: chart.showValues,
28480
28517
  background: chart.background,
28481
28518
  horizontal: chart.horizontal,
28482
- callback: formatTickValue(localeFormat),
28519
+ callback: formatChartDatasetValue(axisFormats, locale),
28483
28520
  };
28484
- const definition = chart.getDefinition();
28485
28521
  const colors = getChartColorsGenerator(definition, dataSetsValues.length);
28486
28522
  const trendDatasets = [];
28487
28523
  for (const index in dataSetsValues) {
@@ -28499,9 +28535,8 @@ stores.inject(MyMetaStore, storeInstance);
28499
28535
  const label = definition.dataSets[index].label;
28500
28536
  dataset.label = label;
28501
28537
  }
28502
- if (definition.dataSets?.[index]?.yAxisId && !chart.horizontal) {
28503
- dataset["yAxisID"] = definition.dataSets[index].yAxisId;
28504
- }
28538
+ dataset.yAxisID = chart.horizontal ? "y" : definition.dataSets[index].yAxisId || "y";
28539
+ dataset.xAxisID = "x";
28505
28540
  const trend = definition.dataSets?.[index].trend;
28506
28541
  if (!trend?.display || chart.horizontal) {
28507
28542
  continue;
@@ -28517,7 +28552,7 @@ stores.inject(MyMetaStore, storeInstance);
28517
28552
  */
28518
28553
  const maxLength = Math.max(...trendDatasets.map((trendDataset) => trendDataset.data.length));
28519
28554
  config.options.scales[TREND_LINE_XAXIS_ID] = {
28520
- ...xAxis,
28555
+ ...config.options.scales.x,
28521
28556
  labels: Array(maxLength).fill(""),
28522
28557
  offset: false,
28523
28558
  display: false,
@@ -28807,8 +28842,10 @@ stores.inject(MyMetaStore, storeInstance);
28807
28842
  }
28808
28843
  const locale = getters.getLocale();
28809
28844
  const truncateLabels = axisType === "category";
28810
- const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
28811
- const options = { format: dataSetFormat, locale, truncateLabels };
28845
+ const leftAxisFormat = getChartDatasetFormat(getters, chart.dataSets, "left");
28846
+ const rightAxisFormat = getChartDatasetFormat(getters, chart.dataSets, "right");
28847
+ const axisFormats = { y: leftAxisFormat, y1: rightAxisFormat };
28848
+ const options = { locale, truncateLabels, axisFormats };
28812
28849
  const fontColor = chartFontColor(chart.background);
28813
28850
  const config = getDefaultChartJsRuntime(chart, labels, fontColor, options);
28814
28851
  const legend = {
@@ -28838,52 +28875,18 @@ stores.inject(MyMetaStore, storeInstance);
28838
28875
  displayLegend: chart.legendPosition === "top",
28839
28876
  }),
28840
28877
  };
28841
- const xAxis = {
28842
- ticks: {
28843
- padding: 5,
28844
- color: fontColor,
28845
- },
28846
- title: getChartAxisTitleRuntime(chart.axesDesign?.x),
28847
- };
28878
+ const definition = chart.getDefinition();
28879
+ const stacked = "stacked" in chart && chart.stacked;
28848
28880
  config.options.scales = {
28849
- x: xAxis,
28881
+ x: getChartAxis(definition, "bottom", "labels", { locale }),
28882
+ y: getChartAxis(definition, "left", "values", { locale, stacked, format: leftAxisFormat }),
28883
+ y1: getChartAxis(definition, "right", "values", { locale, stacked, format: rightAxisFormat }),
28850
28884
  };
28851
- const yAxis = {
28852
- beginAtZero: true, // the origin of the y axis is always zero
28853
- ticks: {
28854
- color: fontColor,
28855
- callback: formatTickValue(options),
28856
- },
28857
- };
28858
- const { useLeftAxis, useRightAxis } = getDefinedAxis(chart.getDefinition());
28859
- if (useLeftAxis) {
28860
- config.options.scales.y = {
28861
- ...yAxis,
28862
- position: "left",
28863
- title: getChartAxisTitleRuntime(chart.axesDesign?.y),
28864
- };
28865
- }
28866
- if (useRightAxis) {
28867
- config.options.scales.y1 = {
28868
- ...yAxis,
28869
- position: "right",
28870
- title: getChartAxisTitleRuntime(chart.axesDesign?.y1),
28871
- };
28872
- }
28873
- if ("stacked" in chart && chart.stacked) {
28874
- if (useLeftAxis) {
28875
- // @ts-ignore chart.js type is broken
28876
- config.options.scales.y.stacked = true;
28877
- }
28878
- if (useRightAxis) {
28879
- // @ts-ignore chart.js type is broken
28880
- config.options.scales.y1.stacked = true;
28881
- }
28882
- }
28885
+ config.options.scales = removeFalsyAttributes(config.options.scales);
28883
28886
  config.options.plugins.chartShowValuesPlugin = {
28884
28887
  showValues: chart.showValues,
28885
28888
  background: chart.background,
28886
- callback: formatTickValue(options),
28889
+ callback: formatChartDatasetValue(axisFormats, locale),
28887
28890
  };
28888
28891
  if (chart.dataSetsHaveTitle &&
28889
28892
  dataSetsValues[0] &&
@@ -28910,7 +28913,7 @@ stores.inject(MyMetaStore, storeInstance);
28910
28913
  label = toNumber(label, locale);
28911
28914
  }
28912
28915
  const formattedX = formatValue(label, { locale, format: labelFormat });
28913
- const formattedY = formatValue(dataSetPoint, { locale, format: dataSetFormat });
28916
+ const formattedY = formatValue(dataSetPoint, { locale, format: leftAxisFormat });
28914
28917
  const dataSetTitle = tooltipItem.dataset.label;
28915
28918
  return formattedX
28916
28919
  ? `${dataSetTitle}: (${formattedX}, ${formattedY})`
@@ -28920,7 +28923,6 @@ stores.inject(MyMetaStore, storeInstance);
28920
28923
  const areaChart = "fillArea" in chart ? chart.fillArea : false;
28921
28924
  const stackedChart = "stacked" in chart ? chart.stacked : false;
28922
28925
  const cumulative = "cumulative" in chart ? chart.cumulative : false;
28923
- const definition = chart.getDefinition();
28924
28926
  const colors = getChartColorsGenerator(definition, dataSetsValues.length);
28925
28927
  for (let [index, { label, data }] of dataSetsValues.entries()) {
28926
28928
  const color = colors.next();
@@ -28961,9 +28963,7 @@ stores.inject(MyMetaStore, storeInstance);
28961
28963
  const label = definition.dataSets[index].label;
28962
28964
  dataset.label = label;
28963
28965
  }
28964
- if (definition.dataSets?.[index]?.yAxisId) {
28965
- dataset["yAxisID"] = definition.dataSets[index].yAxisId;
28966
- }
28966
+ dataset["yAxisID"] = definition.dataSets[index].yAxisId || "y";
28967
28967
  const trend = definition.dataSets?.[index].trend;
28968
28968
  if (!trend?.display) {
28969
28969
  continue;
@@ -28980,7 +28980,7 @@ stores.inject(MyMetaStore, storeInstance);
28980
28980
  * set so that the second axis points match the classical x axis
28981
28981
  */
28982
28982
  config.options.scales[TREND_LINE_XAXIS_ID] = {
28983
- ...xAxis,
28983
+ ...config.options.scales.x,
28984
28984
  type: "category",
28985
28985
  labels: range(0, maxLength).map((x) => x.toString()),
28986
28986
  offset: false,
@@ -29002,10 +29002,6 @@ stores.inject(MyMetaStore, storeInstance);
29002
29002
  return {
29003
29003
  chartJsConfig: config,
29004
29004
  background: chart.background || BACKGROUND_CHART_COLOR,
29005
- dataSetsValues,
29006
- labelValues,
29007
- dataSetFormat,
29008
- labelFormat,
29009
29005
  };
29010
29006
  }
29011
29007
 
@@ -29138,10 +29134,8 @@ stores.inject(MyMetaStore, storeInstance);
29138
29134
  }
29139
29135
  }
29140
29136
  function createComboChartRuntime(chart, getters) {
29141
- const mainDataSetFormat = chart.dataSets.length
29142
- ? getChartDatasetFormat(getters, [chart.dataSets[0]])
29143
- : undefined;
29144
- const lineDataSetsFormat = getChartDatasetFormat(getters, chart.dataSets.slice(1));
29137
+ const mainDataSetFormat = getChartDatasetFormat(getters, chart.dataSets, "left");
29138
+ const lineDataSetsFormat = getChartDatasetFormat(getters, chart.dataSets, "right");
29145
29139
  const locale = getters.getLocale();
29146
29140
  const labelValues = getChartLabelValues(getters, chart.dataSets, chart.labelRange);
29147
29141
  let labels = labelValues.formattedValues;
@@ -29155,9 +29149,9 @@ stores.inject(MyMetaStore, storeInstance);
29155
29149
  if (chart.aggregated) {
29156
29150
  ({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
29157
29151
  }
29158
- const localeFormat = { format: mainDataSetFormat, locale };
29159
29152
  const fontColor = chartFontColor(chart.background);
29160
- const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat);
29153
+ const axisFormats = { y: mainDataSetFormat, y1: lineDataSetsFormat };
29154
+ const config = getDefaultChartJsRuntime(chart, labels, fontColor, { locale, axisFormats });
29161
29155
  const legend = {
29162
29156
  labels: { color: fontColor },
29163
29157
  };
@@ -29174,52 +29168,17 @@ stores.inject(MyMetaStore, storeInstance);
29174
29168
  displayLegend: chart.legendPosition === "top",
29175
29169
  }),
29176
29170
  };
29171
+ const definition = chart.getDefinition();
29177
29172
  config.options.scales = {
29178
- x: {
29179
- ticks: {
29180
- padding: 5,
29181
- color: fontColor,
29182
- },
29183
- title: getChartAxisTitleRuntime(chart.axesDesign?.x),
29184
- },
29185
- };
29186
- const leftVerticalAxis = {
29187
- beginAtZero: true, // the origin of the y axis is always zero
29188
- ticks: {
29189
- color: fontColor,
29190
- callback: formatTickValue({ format: mainDataSetFormat, locale }),
29191
- },
29173
+ x: getChartAxis(definition, "bottom", "labels", { locale }),
29174
+ y: getChartAxis(definition, "left", "values", { locale, format: mainDataSetFormat }),
29175
+ y1: getChartAxis(definition, "right", "values", { locale, format: lineDataSetsFormat }),
29192
29176
  };
29193
- const rightVerticalAxis = {
29194
- beginAtZero: true, // the origin of the y axis is always zero
29195
- ticks: {
29196
- color: fontColor,
29197
- callback: formatTickValue({ format: lineDataSetsFormat, locale }),
29198
- },
29199
- };
29200
- const definition = chart.getDefinition();
29201
- const { useLeftAxis, useRightAxis } = getDefinedAxis(definition);
29202
- if (useLeftAxis) {
29203
- config.options.scales.y = {
29204
- ...leftVerticalAxis,
29205
- position: "left",
29206
- title: getChartAxisTitleRuntime(chart.axesDesign?.y),
29207
- };
29208
- }
29209
- if (useRightAxis) {
29210
- config.options.scales.y1 = {
29211
- ...rightVerticalAxis,
29212
- position: "right",
29213
- grid: {
29214
- display: false,
29215
- },
29216
- title: getChartAxisTitleRuntime(chart.axesDesign?.y1),
29217
- };
29218
- }
29177
+ config.options.scales = removeFalsyAttributes(config.options.scales);
29219
29178
  config.options.plugins.chartShowValuesPlugin = {
29220
29179
  showValues: chart.showValues,
29221
29180
  background: chart.background,
29222
- callback: formatTickValue({ format: mainDataSetFormat, locale }),
29181
+ callback: formatChartDatasetValue(axisFormats, locale),
29223
29182
  };
29224
29183
  const colors = getChartColorsGenerator(definition, dataSetsValues.length);
29225
29184
  let maxLength = 0;
@@ -29848,7 +29807,7 @@ stores.inject(MyMetaStore, storeInstance);
29848
29807
  ({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
29849
29808
  }
29850
29809
  ({ dataSetsValues, labels } = filterNegativeValues(labels, dataSetsValues));
29851
- const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
29810
+ const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets, "left");
29852
29811
  const locale = getters.getLocale();
29853
29812
  const config = getPieConfiguration(chart, labels, { format: dataSetFormat, locale });
29854
29813
  const dataSetsLength = Math.max(0, ...dataSetsValues.map((ds) => ds?.data?.length ?? 0));
@@ -30003,7 +29962,7 @@ stores.inject(MyMetaStore, storeInstance);
30003
29962
  return tooltipLabelCallback(tooltipItem);
30004
29963
  };
30005
29964
  const callback = config.options.plugins.chartShowValuesPlugin.callback;
30006
- config.options.plugins.chartShowValuesPlugin.callback = (x) => callback(Math.abs(x));
29965
+ config.options.plugins.chartShowValuesPlugin.callback = (x, axisId) => callback(Math.abs(x), axisId);
30007
29966
  return { chartJsConfig: config, background: chart.background || BACKGROUND_CHART_COLOR };
30008
29967
  }
30009
29968
 
@@ -30394,7 +30353,8 @@ stores.inject(MyMetaStore, storeInstance);
30394
30353
  if (chart.showSubTotals) {
30395
30354
  labels.push(_t("Subtotal"));
30396
30355
  }
30397
- const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
30356
+ const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets, "left") ||
30357
+ getChartDatasetFormat(getters, chart.dataSets, "right");
30398
30358
  const locale = getters.getLocale();
30399
30359
  const dataSeriesLabels = dataSetsValues.map((dataSet) => dataSet.label);
30400
30360
  const config = getWaterfallConfiguration(chart, labels, dataSeriesLabels, {
@@ -38121,6 +38081,7 @@ stores.inject(MyMetaStore, storeInstance);
38121
38081
  "stopComposerRangeSelection",
38122
38082
  "cancelEdition",
38123
38083
  "cycleReferences",
38084
+ "toggleEditionMode",
38124
38085
  "changeComposerCursorSelection",
38125
38086
  "replaceComposerCursorSelection",
38126
38087
  ];
@@ -38276,6 +38237,42 @@ stores.inject(MyMetaStore, storeInstance);
38276
38237
  }
38277
38238
  this.setCurrentContent(updated.content, updated.selection);
38278
38239
  }
38240
+ toggleEditionMode() {
38241
+ if (this.editionMode === "inactive")
38242
+ return;
38243
+ const start = Math.min(this.selectionStart, this.selectionEnd);
38244
+ const end = Math.max(this.selectionStart, this.selectionEnd);
38245
+ const refToken = [...this.currentTokens]
38246
+ .reverse()
38247
+ .find((tk) => tk.end >= start && end >= tk.start && tk.type === "REFERENCE");
38248
+ if (this.editionMode === "editing" && refToken) {
38249
+ const currentSheetId = this.getters.getActiveSheetId();
38250
+ const { sheetName, xc } = splitReference(refToken.value);
38251
+ const sheetId = this.getters.getSheetIdByName(sheetName);
38252
+ if (sheetId && sheetId !== currentSheetId) {
38253
+ this.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom: currentSheetId, sheetIdTo: sheetId });
38254
+ }
38255
+ // move cursor to the right part of the token
38256
+ this.selectionStart = this.selectionEnd = refToken.end;
38257
+ const zone = this.getters.getRangeFromSheetXC(this.sheetId, xc).zone;
38258
+ this.captureSelection(zone);
38259
+ this.editionMode = "selecting";
38260
+ }
38261
+ else {
38262
+ this.editionMode = "editing";
38263
+ }
38264
+ }
38265
+ captureSelection(zone, col, row) {
38266
+ this.model.selection.capture(this, {
38267
+ cell: { col: col || zone.left, row: row || zone.right },
38268
+ zone,
38269
+ }, {
38270
+ handleEvent: this.handleEvent.bind(this),
38271
+ release: () => {
38272
+ this._stopEdition();
38273
+ },
38274
+ });
38275
+ }
38279
38276
  isSelectionValid(length, start, end) {
38280
38277
  return start >= 0 && start <= length && end >= 0 && end <= length;
38281
38278
  }
@@ -38314,12 +38311,7 @@ stores.inject(MyMetaStore, storeInstance);
38314
38311
  this.setContent(str || this.initialContent, selection);
38315
38312
  this.colorIndexByRange = {};
38316
38313
  const zone = positionToZone({ col: this.col, row: this.row });
38317
- this.model.selection.capture(this, { cell: { col: this.col, row: this.row }, zone }, {
38318
- handleEvent: this.handleEvent.bind(this),
38319
- release: () => {
38320
- this._stopEdition();
38321
- },
38322
- });
38314
+ this.captureSelection(zone, col, row);
38323
38315
  }
38324
38316
  _stopEdition() {
38325
38317
  if (this.editionMode !== "inactive") {
@@ -50002,12 +49994,10 @@ stores.inject(MyMetaStore, storeInstance);
50002
49994
  */
50003
49995
  class CorePlugin extends BasePlugin {
50004
49996
  getters;
50005
- uuidGenerator;
50006
- constructor({ getters, stateObserver, range, dispatch, canDispatch, uuidGenerator, }) {
49997
+ constructor({ getters, stateObserver, range, dispatch, canDispatch }) {
50007
49998
  super(stateObserver, dispatch, canDispatch);
50008
49999
  range.addRangeProvider(this.adaptRanges.bind(this));
50009
50000
  this.getters = getters;
50010
- this.uuidGenerator = uuidGenerator;
50011
50001
  }
50012
50002
  // ---------------------------------------------------------------------------
50013
50003
  // Import/Export
@@ -54505,6 +54495,7 @@ stores.inject(MyMetaStore, storeInstance);
54505
54495
  }
54506
54496
  }
54507
54497
 
54498
+ let nextTableId = 1;
54508
54499
  class TablePlugin extends CorePlugin {
54509
54500
  static getters = ["getCoreTable", "getCoreTables", "getCoreTableMatchingTopLeft"];
54510
54501
  tables = {};
@@ -54572,7 +54563,7 @@ stores.inject(MyMetaStore, storeInstance);
54572
54563
  const union = this.getters.getRangesUnion(ranges);
54573
54564
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, union.zone);
54574
54565
  this.dispatch("REMOVE_MERGE", { sheetId: cmd.sheetId, target: mergesInTarget });
54575
- const id = this.uuidGenerator.uuidv4();
54566
+ const id = `${nextTableId++}`;
54576
54567
  const config = cmd.config || DEFAULT_TABLE_CONFIG;
54577
54568
  const newTable = cmd.tableType === "dynamic"
54578
54569
  ? this.createDynamicTable(id, union, config)
@@ -54725,7 +54716,7 @@ stores.inject(MyMetaStore, storeInstance);
54725
54716
  filters = [];
54726
54717
  for (const i of range(zone.left, zone.right + 1)) {
54727
54718
  const filterZone = { ...zone, left: i, right: i };
54728
- const uid = this.uuidGenerator.uuidv4();
54719
+ const uid = `${nextTableId++}`;
54729
54720
  filters.push(this.createFilterFromZone(uid, tableRange.sheetId, filterZone, config));
54730
54721
  }
54731
54722
  }
@@ -54790,7 +54781,7 @@ stores.inject(MyMetaStore, storeInstance);
54790
54781
  ? table.filters.find((f) => f.col === i)
54791
54782
  : undefined;
54792
54783
  const filterZone = { ...tableZone, left: i, right: i };
54793
- const filterId = oldFilter?.id || this.uuidGenerator.uuidv4();
54784
+ const filterId = oldFilter?.id || `${nextTableId++}`;
54794
54785
  filters.push(this.createFilterFromZone(filterId, tableRange.sheetId, filterZone, config));
54795
54786
  }
54796
54787
  }
@@ -54891,7 +54882,7 @@ stores.inject(MyMetaStore, storeInstance);
54891
54882
  if (filters.length < zoneToDimension(tableZone).numberOfCols) {
54892
54883
  for (let col = tableZone.left; col <= tableZone.right; col++) {
54893
54884
  if (!filters.find((filter) => filter.col === col)) {
54894
- const uid = this.uuidGenerator.uuidv4();
54885
+ const uid = `${nextTableId++}`;
54895
54886
  const filterZone = { ...tableZone, left: col, right: col };
54896
54887
  filters.push(this.createFilterFromZone(uid, sheetId, filterZone, table.config));
54897
54888
  }
@@ -54907,7 +54898,7 @@ stores.inject(MyMetaStore, storeInstance);
54907
54898
  import(data) {
54908
54899
  for (const sheet of data.sheets) {
54909
54900
  for (const tableData of sheet.tables || []) {
54910
- const uuid = this.uuidGenerator.uuidv4();
54901
+ const uuid = `${nextTableId++}`;
54911
54902
  const tableConfig = tableData.config || DEFAULT_TABLE_CONFIG;
54912
54903
  const range = this.getters.getRangeFromSheetXC(sheet.id, tableData.range);
54913
54904
  const tableType = tableData.type || "static";
@@ -71756,7 +71747,6 @@ stores.inject(MyMetaStore, storeInstance);
71756
71747
  this.handlers.push(plugin);
71757
71748
  this.uiHandlers.push(plugin);
71758
71749
  }
71759
- this.uuidGenerator.setIsFastStrategy(false);
71760
71750
  // starting plugins
71761
71751
  this.dispatch("START");
71762
71752
  // Model should be the last permanent subscriber in the list since he should render
@@ -71904,7 +71894,6 @@ stores.inject(MyMetaStore, storeInstance);
71904
71894
  range: this.range,
71905
71895
  dispatch: this.dispatchFromCorePlugin,
71906
71896
  canDispatch: this.canDispatch,
71907
- uuidGenerator: this.uuidGenerator,
71908
71897
  custom: this.config.custom,
71909
71898
  external: this.config.external,
71910
71899
  };
@@ -72398,9 +72387,9 @@ stores.inject(MyMetaStore, storeInstance);
72398
72387
  exports.tokenize = tokenize;
72399
72388
 
72400
72389
 
72401
- __info__.version = "18.0.1";
72402
- __info__.date = "2024-10-14T07:54:24.768Z";
72403
- __info__.hash = "1771f68";
72390
+ __info__.version = "18.1.0-alpha.1";
72391
+ __info__.date = "2024-10-14T07:53:17.717Z";
72392
+ __info__.hash = "e9ce3aa";
72404
72393
 
72405
72394
 
72406
72395
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);