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