@yudaocode/univer-sheets-ui 1.6.217 → 1.6.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var __decorateClass = (decorators, target, key, kind) => {
20
30
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
@@ -302,6 +312,10 @@ var OpenSheetIoModalOperation = {
302
312
  function mergeImportedTemplateMetadata(prevMeta, importedMeta) {
303
313
  const next = { ...prevMeta, ...importedMeta };
304
314
  if (!importedMeta.charts) delete next.charts;
315
+ if (!importedMeta.shapes) delete next.shapes;
316
+ if (!importedMeta.outlines) delete next.outlines;
317
+ if (!importedMeta.pivots) delete next.pivots;
318
+ if (!importedMeta.sparklines) delete next.sparklines;
305
319
  return next;
306
320
  }
307
321
  var ImportSheetFileOperation = {
@@ -640,9 +654,24 @@ var SheetInspectorPanel = () => {
640
654
  const templateService = (0, import_ui3.useDependency)(import_univer_sheets2.ISheetTemplateService);
641
655
  const ioService = (0, import_ui3.useDependency)(import_univer_sheets2.ISheetIoService);
642
656
  const featureService = (0, import_ui3.useDependency)(ISheetsUIFeatureService);
657
+ const injector = (0, import_ui3.useInjector)();
658
+ const macroService = (() => {
659
+ try {
660
+ return injector.get(import_univer_sheets2.ISheetMacroService);
661
+ } catch {
662
+ return void 0;
663
+ }
664
+ })();
643
665
  const features = (0, import_ui3.useObservable)(featureService.features$, featureService.getFeatures());
644
666
  const metaVersion = (0, import_ui3.useObservable)(templateService.metadataChange$, "");
645
667
  const protWarn = (0, import_ui3.useObservable)(templateService.protectionWarning$, null);
668
+ const defaultMacroRecState = {
669
+ recording: false,
670
+ stepCount: 0,
671
+ steps: []
672
+ };
673
+ const macroRecState = (0, import_ui3.useObservable)(macroService?.recordingState$, defaultMacroRecState);
674
+ const macroListVer = (0, import_ui3.useObservable)(macroService?.macrosChange$, "");
646
675
  const workbook = (0, import_ui3.useObservable)(
647
676
  () => instanceService.getCurrentTypeOfUnit$(import_core4.UniverInstanceType.UNIVER_SHEET),
648
677
  instanceService.getCurrentUnitOfType(import_core4.UniverInstanceType.UNIVER_SHEET),
@@ -694,6 +723,38 @@ var SheetInspectorPanel = () => {
694
723
  const [qpDatasetCode, setQpDatasetCode] = (0, import_react2.useState)("");
695
724
  const [qpTargetField, setQpTargetField] = (0, import_react2.useState)("");
696
725
  const [qpDefaultVal, setQpDefaultVal] = (0, import_react2.useState)("");
726
+ const [selectedChartId, setSelectedChartId] = (0, import_react2.useState)("");
727
+ const [selectedPivotId, setSelectedPivotId] = (0, import_react2.useState)("__new__");
728
+ const [pivotSourceRange, setPivotSourceRange] = (0, import_react2.useState)("");
729
+ const [pivotChipTarget, setPivotChipTarget] = (0, import_react2.useState)("rows");
730
+ const [pivotRowFields, setPivotRowFields] = (0, import_react2.useState)([1]);
731
+ const [pivotColFields, setPivotColFields] = (0, import_react2.useState)([]);
732
+ const [pivotValueFields, setPivotValueFields] = (0, import_react2.useState)([
733
+ { colIndex: 5, aggFunc: "sum" }
734
+ ]);
735
+ const [pivotFilterFields, setPivotFilterFields] = (0, import_react2.useState)([]);
736
+ const [pivotCalcFields, setPivotCalcFields] = (0, import_react2.useState)([]);
737
+ const [calcFieldName, setCalcFieldName] = (0, import_react2.useState)("");
738
+ const [calcFieldFormula, setCalcFieldFormula] = (0, import_react2.useState)("");
739
+ const [watchInputRef, setWatchInputRef] = (0, import_react2.useState)("");
740
+ const [evalSteps, setEvalSteps] = (0, import_react2.useState)([]);
741
+ const [evalStepIdx, setEvalStepIdx] = (0, import_react2.useState)(0);
742
+ const [evalCellKey, setEvalCellKey] = (0, import_react2.useState)("");
743
+ const [scenarioNameInput, setScenarioNameInput] = (0, import_react2.useState)("\u4E50\u89C2\u589E\u957F\u65B9\u6848");
744
+ const [scenarioCellsInput, setScenarioCellsInput] = (0, import_react2.useState)("B2=120, B3=0.18");
745
+ const [scenarioResultsInput, setScenarioResultsInput] = (0, import_react2.useState)("F10");
746
+ const [scenarioCommentInput, setScenarioCommentInput] = (0, import_react2.useState)("");
747
+ const [whatIfMode, setWhatIfMode] = (0, import_react2.useState)("1var");
748
+ const [dtInputCell, setDtInputCell] = (0, import_react2.useState)("B2");
749
+ const [dtInputValues, setDtInputValues] = (0, import_react2.useState)("80, 100, 120");
750
+ const [dtFormulaCells, setDtFormulaCells] = (0, import_react2.useState)("F10");
751
+ const [dtColInputCell, setDtColInputCell] = (0, import_react2.useState)("B3");
752
+ const [dtColValues, setDtColValues] = (0, import_react2.useState)("10, 20, 30");
753
+ const [dtOutputTopLeft, setDtOutputTopLeft] = (0, import_react2.useState)("H2");
754
+ const [whatIfStatusMsg, setWhatIfStatusMsg] = (0, import_react2.useState)("");
755
+ const [macroNameInput, setMacroNameInput] = (0, import_react2.useState)("");
756
+ const [macroStatusMsg, setMacroStatusMsg] = (0, import_react2.useState)("");
757
+ const [previewMacro, setPreviewMacro] = (0, import_react2.useState)(null);
697
758
  (0, import_react2.useEffect)(() => {
698
759
  const sub = selectionService.selectionChanged$.subscribe(() => setSelTick((v) => v + 1));
699
760
  const disp = commandService.onCommandExecuted((info) => {
@@ -709,6 +770,7 @@ var SheetInspectorPanel = () => {
709
770
  if (!workbook) return null;
710
771
  void selTick;
711
772
  void metaVersion;
773
+ void macroListVer;
712
774
  const unitId = workbook.getUnitId();
713
775
  const sheet = workbook.getActiveSheet();
714
776
  if (!sheet) return null;
@@ -751,6 +813,63 @@ var SheetInspectorPanel = () => {
751
813
  const printCfg = metadata.printConfig ?? {};
752
814
  const protectionCfg = metadata.protection;
753
815
  const charts = metadata.charts ?? [];
816
+ const pivots = metadata.pivots ?? [];
817
+ const editingChart = charts.find((c) => c.id === selectedChartId) ?? charts[0];
818
+ const activePivot = selectedPivotId !== "__new__" ? pivots.find((p) => p.id === selectedPivotId) : void 0;
819
+ const pivotSrcSheet = (activePivot?.sourceSheetId ? workbook.getSheetBySheetId(activePivot.sourceSheetId) : null) ?? sheet;
820
+ const rawPivotRangePart = (pivotSourceRange || activePivot?.sourceRange || "").trim().replace(/^.*!/, "");
821
+ const parsedPivotRange = rawPivotRangePart ? (0, import_univer_sheets2.parseA1Range)(rawPivotRangePart) : null;
822
+ const pivotHeaderRow = parsedPivotRange ? parsedPivotRange.startRow : 0;
823
+ const pivotStartCol = parsedPivotRange ? parsedPivotRange.startColumn : 0;
824
+ const pivotEndCol = (() => {
825
+ if (parsedPivotRange) {
826
+ return Math.max(parsedPivotRange.startColumn, parsedPivotRange.endColumn);
827
+ }
828
+ let maxCol = 6;
829
+ for (let c = 0; c < 20; c++) {
830
+ const v = pivotSrcSheet.getCellRaw(0, c)?.v;
831
+ if (v !== void 0 && v !== null && String(v).trim() !== "") {
832
+ maxCol = Math.max(maxCol, c);
833
+ }
834
+ }
835
+ return maxCol;
836
+ })();
837
+ const pivotSourceColumns = [];
838
+ for (let c = pivotStartCol; c <= pivotEndCol; c++) {
839
+ const hdrVal = pivotSrcSheet.getCellRaw(pivotHeaderRow, c)?.v;
840
+ const hdrStr = hdrVal !== void 0 && hdrVal !== null ? String(hdrVal).trim() : "";
841
+ pivotSourceColumns.push({
842
+ colIndex: c,
843
+ rawHeader: hdrStr || `${(0, import_univer_sheets2.colIndexToLetter)(c)}\u5217`,
844
+ label: hdrStr ? `${hdrStr} (${(0, import_univer_sheets2.colIndexToLetter)(c)})` : `${(0, import_univer_sheets2.colIndexToLetter)(c)} \u5217`
845
+ });
846
+ }
847
+ const resolvePivotFieldCol = (fieldOrIdx, fallback = 0) => {
848
+ if (typeof fieldOrIdx === "number" && Number.isFinite(fieldOrIdx)) return fieldOrIdx;
849
+ if (typeof fieldOrIdx === "string") {
850
+ const tStr = fieldOrIdx.trim();
851
+ if (/^\d+$/.test(tStr)) return Number(tStr);
852
+ const hit = pivotSourceColumns.find(
853
+ (col) => col.rawHeader.toLowerCase() === tStr.toLowerCase()
854
+ );
855
+ if (hit) return hit.colIndex;
856
+ }
857
+ return fallback;
858
+ };
859
+ const getPivotColumnLabel = (colIdx) => pivotSourceColumns.find((col) => col.colIndex === colIdx)?.rawHeader ?? `${(0, import_univer_sheets2.colIndexToLetter)(Math.max(0, colIdx))}\u5217`;
860
+ const getPivotFilterChoices = (colIdx) => {
861
+ const startR = pivotHeaderRow + 1;
862
+ const endR = parsedPivotRange ? Math.min(parsedPivotRange.endRow, startR + 200) : Math.min(pivotSrcSheet.getRowCount() - 1, startR + 150);
863
+ const seen = /* @__PURE__ */ new Set();
864
+ for (let r = startR; r <= endR; r++) {
865
+ const val = pivotSrcSheet.getCellRaw(r, colIdx)?.v;
866
+ if (val !== void 0 && val !== null && String(val).trim() !== "") {
867
+ seen.add(String(val).trim());
868
+ if (seen.size >= 24) break;
869
+ }
870
+ }
871
+ return Array.from(seen);
872
+ };
754
873
  const activeAlertRule = cellMeta.alertRules?.[0];
755
874
  const singleExprRe = features.contextualCellBinding && effectiveSyntax === "hash" ? /^#\{([#$]?\s*[\p{L}\p{N}_][\p{L}\p{N}_.\[\]-]*)\}$/u : features.contextualCellBinding && effectiveSyntax === "dollar" ? /^\$\{([#$]?\s*[\p{L}\p{N}_][\p{L}\p{N}_.\[\]-]*)\}$/u : /^(?:\$|#)\{([#$]?\s*[\p{L}\p{N}_][\p{L}\p{N}_.\[\]-]*)\}$/u;
756
875
  const currentExprMatch = typeof activeCell?.v === "string" ? activeCell.v.trim().match(singleExprRe) : null;
@@ -2160,7 +2279,9 @@ var SheetInspectorPanel = () => {
2160
2279
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "ellipse", children: "\u692D\u5706 (Ellipse)" }),
2161
2280
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "diamond", children: "\u83F1\u5F62 (Diamond)" }),
2162
2281
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "arrow", children: "\u53F3\u5411\u7BAD\u5934 (Arrow)" }),
2163
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "callout", children: "\u6807\u6CE8\u6C14\u6CE1 (Callout)" })
2282
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "callout", children: "\u6807\u6CE8\u6C14\u6CE1 (Callout)" }),
2283
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "line", children: "\u8FDE\u63A5\u76F4\u7EBF (Line)" }),
2284
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "connector", children: "\u7BAD\u5934\u8FDE\u63A5\u7EBF (Connector)" })
2164
2285
  ]
2165
2286
  }
2166
2287
  )
@@ -2211,7 +2332,8 @@ var SheetInspectorPanel = () => {
2211
2332
  left: 360,
2212
2333
  top: 56,
2213
2334
  width: 148,
2214
- height: 60
2335
+ height: shapeType === "line" || shapeType === "connector" ? 36 : 60,
2336
+ ...shapeType === "connector" ? { arrowEnd: true } : {}
2215
2337
  }
2216
2338
  });
2217
2339
  },
@@ -2493,24 +2615,30 @@ var SheetInspectorPanel = () => {
2493
2615
  className: "yudao-sheet-btn is-soft-primary",
2494
2616
  onClick: () => {
2495
2617
  const isSmoothEnabled = chartType.startsWith("line") && (chartSmooth || chartType.endsWith("Smooth"));
2496
- templateService.addOrUpdateChart(unitId, {
2497
- id: `chart-${(0, import_core4.generateRandomId)(5)}`,
2498
- sheetId: sheet.getSheetId(),
2499
- title: chartTitle || "\u4E1A\u52A1\u7EDF\u8BA1\u56FE",
2500
- chartType,
2501
- categoryRange: chartCatRange || "B6:B9",
2502
- valueRange: chartValRange || "F6:F9",
2503
- smooth: isSmoothEnabled ? true : void 0,
2504
- showLegend: chartShowLegend,
2505
- legendPosition: chartShowLegend ? chartLegendPos : void 0,
2506
- trendline: chartTrendline !== "none" ? chartTrendline : void 0,
2507
- yAxisScale: chartLogScale ? "log" : "linear",
2508
- threeD: chartThreeD ? { rotX: 15, rotY: 20 } : void 0,
2509
- left: 520,
2510
- top: 48 + charts.length * 24,
2511
- width: 280,
2512
- height: 175
2618
+ const newId = `chart-${(0, import_core4.generateRandomId)(5)}`;
2619
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2620
+ unitId,
2621
+ chart: {
2622
+ id: newId,
2623
+ sheetId: sheet.getSheetId(),
2624
+ title: chartTitle || "\u4E1A\u52A1\u7EDF\u8BA1\u56FE",
2625
+ chartType,
2626
+ categoryRange: chartCatRange || "B6:B9",
2627
+ valueRange: chartValRange || "F6:F9",
2628
+ smooth: isSmoothEnabled ? true : void 0,
2629
+ showLegend: chartShowLegend,
2630
+ legendPosition: chartShowLegend ? chartLegendPos : "none",
2631
+ trendline: chartTrendline !== "none" ? chartTrendline : void 0,
2632
+ ...chartType === "combo" ? { comboLineSeriesIndices: [1], secondarySeriesIndices: [1] } : {},
2633
+ yAxisScale: chartLogScale ? "log" : "linear",
2634
+ threeD: chartThreeD ? { rotX: 15, rotY: 20 } : void 0,
2635
+ left: 520,
2636
+ top: 48 + charts.length * 24,
2637
+ width: 280,
2638
+ height: 175
2639
+ }
2513
2640
  });
2641
+ setSelectedChartId(newId);
2514
2642
  },
2515
2643
  children: "+ \u63D2\u5165\u6D6E\u52A8\u56FE\u8868"
2516
2644
  }
@@ -2549,141 +2677,1209 @@ var SheetInspectorPanel = () => {
2549
2677
  }
2550
2678
  )
2551
2679
  ] }),
2552
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2553
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u4E00\u952E\u751F\u6210 2D \u6570\u636E\u900F\u89C6\u8868\uFF0811 \u79CD\u7EDF\u8BA1\u805A\u5408 + \u503C\u663E\u793A\u65B9\u5F0F\uFF09" }),
2554
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2555
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2556
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u884C\u7EF4\u5EA6\u5217" }),
2557
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { value: pivotRowCol, onChange: (e) => setPivotRowCol(Number(e.target.value)), children: [0, 1, 2, 3, 4, 5].map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: c, children: [
2558
- (0, import_univer_sheets2.colIndexToLetter)(c),
2559
- " \u5217"
2560
- ] }, c)) })
2561
- ] }),
2562
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2563
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5217\u7EF4\u5EA6\uFF08\u53EF\u9009\u4EA4\u53C9\uFF09" }),
2564
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { value: pivotColCol, onChange: (e) => setPivotColCol(Number(e.target.value)), children: [
2565
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: -1, children: "\u65E0\uFF08\u4E00\u7EF4\u6C47\u603B\uFF09" }),
2566
- [0, 1, 2, 3, 4, 5].map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: c, children: [
2567
- (0, import_univer_sheets2.colIndexToLetter)(c),
2568
- " \u5217"
2569
- ] }, c))
2570
- ] })
2571
- ] }),
2572
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2573
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u7EDF\u8BA1\u6570\u503C\u5217" }),
2574
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { value: pivotValCol, onChange: (e) => setPivotValCol(Number(e.target.value)), children: [0, 1, 2, 3, 4, 5, 6].map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: c, children: [
2575
- (0, import_univer_sheets2.colIndexToLetter)(c),
2576
- " \u5217"
2577
- ] }, c)) })
2578
- ] }),
2579
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2580
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u805A\u5408\u51FD\u6570 (11 \u79CD)" }),
2581
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2582
- "select",
2583
- {
2584
- value: pivotAgg,
2585
- onChange: (e) => setPivotAgg(e.target.value),
2586
- children: [
2587
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "SUM", children: "\u6C42\u548C (SUM)" }),
2588
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "COUNT", children: "\u6570\u503C\u8BA1\u6570 (COUNT)" }),
2589
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "COUNTA", children: "\u975E\u7A7A\u8BA1\u6570 (COUNTA)" }),
2590
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "AVG", children: "\u5747\u503C (AVG)" }),
2591
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "MAX", children: "\u6700\u5927\u503C (MAX)" }),
2592
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "MIN", children: "\u6700\u5C0F\u503C (MIN)" }),
2593
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "PRODUCT", children: "\u4E58\u79EF (PRODUCT)" }),
2594
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "STDEV", children: "\u6837\u672C\u6807\u51C6\u5DEE (STDEV)" }),
2595
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "STDEVP", children: "\u603B\u4F53\u6807\u51C6\u5DEE (STDEVP)" }),
2596
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "VAR", children: "\u6837\u672C\u65B9\u5DEE (VAR)" }),
2597
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "VARP", children: "\u603B\u4F53\u65B9\u5DEE (VARP)" })
2598
- ]
2599
- }
2600
- )
2601
- ] }),
2602
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2603
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u503C\u663E\u793A\u65B9\u5F0F" }),
2604
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2605
- "select",
2606
- {
2607
- value: pivotShowAs,
2608
- onChange: (e) => setPivotShowAs(e.target.value),
2609
- children: [
2610
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "normal", children: "\u5E38\u89C4\u6C47\u603B\u503C" }),
2611
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentOfGrandTotal", children: "\u5360\u603B\u8BA1\u767E\u5206\u6BD4" }),
2612
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentOfRow", children: "\u5360\u884C\u6C47\u603B\u767E\u5206\u6BD4" }),
2613
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentOfColumn", children: "\u5360\u5217\u6C47\u603B\u767E\u5206\u6BD4" }),
2614
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "runningTotal", children: "\u6309\u5217\u7D2F\u8BA1\u503C" }),
2615
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "rankDesc", children: "\u964D\u5E8F\u6392\u540D" })
2616
- ]
2617
- }
2618
- )
2619
- ] }),
2620
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2621
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u884C\u7EF4\u5EA6\u65E5\u671F\u5206\u7EC4" }),
2622
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2623
- "select",
2624
- {
2625
- value: pivotDateGroup,
2626
- onChange: (e) => setPivotDateGroup(e.target.value),
2627
- children: [
2628
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\u4E0D\u6309\u65E5\u671F\u5206\u7EC4" }),
2629
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "year", children: "\u6309\u5E74\u4EFD (YYYY\u5E74)" }),
2630
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "quarter", children: "\u6309\u5B63\u5EA6 (YYYY-QN)" }),
2631
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "month", children: "\u6309\u6708\u4EFD (YYYY-MM)" })
2632
- ]
2633
- }
2634
- )
2635
- ] })
2636
- ] }),
2637
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer", fontSize: 11.5 }, children: [
2638
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2639
- "input",
2640
- {
2641
- type: "checkbox",
2642
- checked: withPivotChart,
2643
- onChange: (e) => setWithPivotChart(e.target.checked)
2644
- }
2645
- ),
2646
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u540C\u6B65\u751F\u6210\u900F\u89C6\u8054\u52A8\u56FE\u8868 (Pivot Chart)" })
2647
- ] }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2649
- "button",
2680
+ editingChart && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2681
+ "div",
2650
2682
  {
2651
- type: "button",
2652
- className: "yudao-sheet-btn",
2653
- onClick: () => commandService.syncExecuteCommand(import_univer_sheets2.GenerateSheetPivotCommand.id, {
2654
- unitId,
2655
- sourceSubUnitId: sheet.getSheetId(),
2656
- pivotConfig: {
2657
- rowDimCols: [pivotRowCol],
2658
- colDimCols: pivotColCol >= 0 ? [pivotColCol] : [],
2659
- valueCol: pivotValCol,
2660
- aggFunc: pivotAgg,
2661
- valueShowAs: pivotShowAs,
2662
- ...pivotDateGroup ? { dateGroupBy: pivotDateGroup } : {},
2663
- showSubtotals: true,
2664
- withPivotChart,
2665
- pivotChartType: chartType
2666
- }
2667
- }),
2683
+ "data-testid": "yudao-chart-inspector",
2684
+ style: {
2685
+ display: "flex",
2686
+ flexDirection: "column",
2687
+ gap: 6,
2688
+ padding: "7px 8px",
2689
+ borderRadius: 6,
2690
+ background: "#F9FAFB",
2691
+ border: "1px solid #E3E5EA"
2692
+ },
2668
2693
  children: [
2669
- "\u751F\u6210\u4EA4\u53C9\u900F\u89C6\u8868 Sheet",
2670
- withPivotChart ? " + \u8054\u52A8\u900F\u89C6\u56FE" : ""
2694
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2695
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u56FE\u8868\u914D\u7F6E\u5668 (Chart Inspector)" }),
2696
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2697
+ "button",
2698
+ {
2699
+ type: "button",
2700
+ className: "yudao-sheet-btn",
2701
+ style: { padding: "1px 6px", fontSize: 10.5, color: "#DC2626" },
2702
+ onClick: () => {
2703
+ commandService.syncExecuteCommand(import_univer_sheets2.RemoveSheetChartCommand.id, {
2704
+ unitId,
2705
+ chartId: editingChart.id
2706
+ });
2707
+ },
2708
+ children: "\u5220\u9664\u56FE\u8868"
2709
+ }
2710
+ )
2711
+ ] }),
2712
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2713
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u9009\u62E9\u5DF2\u6709\u56FE\u8868" }),
2714
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2715
+ "select",
2716
+ {
2717
+ "data-testid": "yudao-chart-inspector-select",
2718
+ value: editingChart.id,
2719
+ onChange: (e) => setSelectedChartId(e.target.value),
2720
+ children: charts.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: c.id, children: [
2721
+ c.title || c.id,
2722
+ " (",
2723
+ c.chartType,
2724
+ c.pivotId ? " \xB7 \u900F\u89C6\u56FE" : "",
2725
+ ")"
2726
+ ] }, c.id))
2727
+ }
2728
+ )
2729
+ ] }),
2730
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 4 }, children: [
2731
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2732
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u56FE\u8868\u7C7B\u578B" }),
2733
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2734
+ "select",
2735
+ {
2736
+ "data-testid": "yudao-chart-inspector-type",
2737
+ value: editingChart.chartType,
2738
+ onChange: (e) => {
2739
+ const nextType = e.target.value;
2740
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2741
+ unitId,
2742
+ chart: {
2743
+ ...editingChart,
2744
+ chartType: nextType,
2745
+ ...nextType === "combo" && !editingChart.comboLineSeriesIndices?.length ? {
2746
+ comboLineSeriesIndices: [1],
2747
+ secondarySeriesIndices: editingChart.secondarySeriesIndices?.length ? editingChart.secondarySeriesIndices : [1]
2748
+ } : {}
2749
+ }
2750
+ });
2751
+ },
2752
+ children: import_univer_sheets2.SHEET_CHART_TYPE_GROUPS.map((grp) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("optgroup", { label: grp.label, children: grp.options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: opt.value, children: opt.label }, opt.value)) }, grp.category))
2753
+ }
2754
+ )
2755
+ ] }),
2756
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2757
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6807\u9898" }),
2758
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2759
+ "input",
2760
+ {
2761
+ type: "text",
2762
+ value: editingChart.title,
2763
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2764
+ unitId,
2765
+ chart: { ...editingChart, title: e.target.value }
2766
+ })
2767
+ }
2768
+ )
2769
+ ] })
2770
+ ] }),
2771
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2772
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2773
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "X / \u5206\u7C7B\u533A\u95F4" }),
2774
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2775
+ "input",
2776
+ {
2777
+ "data-testid": "yudao-chart-inspector-cat-range",
2778
+ type: "text",
2779
+ value: editingChart.categoryRange,
2780
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2781
+ unitId,
2782
+ chart: { ...editingChart, categoryRange: e.target.value }
2783
+ })
2784
+ }
2785
+ )
2786
+ ] }),
2787
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2788
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Y / \u7CFB\u5217\u533A\u95F4" }),
2789
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2790
+ "input",
2791
+ {
2792
+ "data-testid": "yudao-chart-inspector-val-range",
2793
+ type: "text",
2794
+ value: editingChart.valueRange,
2795
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2796
+ unitId,
2797
+ chart: { ...editingChart, valueRange: e.target.value }
2798
+ })
2799
+ }
2800
+ )
2801
+ ] })
2802
+ ] }),
2803
+ (() => {
2804
+ const trObj = typeof editingChart.trendline === "object" && editingChart.trendline ? editingChart.trendline : typeof editingChart.trendline === "string" && editingChart.trendline !== "none" ? {
2805
+ type: editingChart.trendline === "movingAverage" ? "movingAvg" : editingChart.trendline
2806
+ } : void 0;
2807
+ const trType = trObj?.type ?? "none";
2808
+ const errObj = Array.isArray(editingChart.errorBars) ? editingChart.errorBars[0] ? {
2809
+ type: editingChart.errorBars[0].valueType === "fixed" ? "fixedVal" : editingChart.errorBars[0].valueType === "stdev" ? "stdDev" : "percentage",
2810
+ value: editingChart.errorBars[0].value
2811
+ } : void 0 : editingChart.errorBars;
2812
+ const errType = errObj?.type ?? "none";
2813
+ const legVal = editingChart.showLegend === false || editingChart.legendPosition === "none" ? "none" : editingChart.legendPosition === "bottom" || editingChart.legendPosition === "b" ? "b" : editingChart.legendPosition === "top" || editingChart.legendPosition === "t" ? "t" : editingChart.legendPosition === "left" || editingChart.legendPosition === "l" ? "l" : "r";
2814
+ const hasSecondary = (editingChart.secondarySeriesIndices?.length ?? 0) > 0;
2815
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2816
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2817
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2818
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8D8B\u52BF\u7EBF\u7C7B\u578B" }),
2819
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2820
+ "select",
2821
+ {
2822
+ "data-testid": "yudao-chart-inspector-trendline",
2823
+ value: trType,
2824
+ onChange: (e) => {
2825
+ const val = e.target.value;
2826
+ const nextTr = val === "none" ? void 0 : {
2827
+ type: val,
2828
+ ...val === "polynomial" ? { order: trObj?.order ?? 2 } : {},
2829
+ ...val === "movingAvg" ? { period: trObj?.period ?? 2 } : {},
2830
+ displayEquation: trObj?.displayEquation,
2831
+ displayRSqr: trObj?.displayRSqr
2832
+ };
2833
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2834
+ unitId,
2835
+ chart: { ...editingChart, trendline: nextTr }
2836
+ });
2837
+ },
2838
+ children: [
2839
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "none", children: "\u65E0\u8D8B\u52BF\u7EBF" }),
2840
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "linear", children: "\u7EBF\u6027 (Linear)" }),
2841
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "exponential", children: "\u6307\u6570 (Exponential)" }),
2842
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "polynomial", children: "\u591A\u9879\u5F0F (Polynomial)" }),
2843
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "movingAvg", children: "\u79FB\u52A8\u5E73\u5747 (MovingAvg)" })
2844
+ ]
2845
+ }
2846
+ )
2847
+ ] }),
2848
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2849
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8BEF\u5DEE\u7EBF (Error Bars)" }),
2850
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2851
+ "select",
2852
+ {
2853
+ "data-testid": "yudao-chart-inspector-errbars",
2854
+ value: errType,
2855
+ onChange: (e) => {
2856
+ const val = e.target.value;
2857
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2858
+ unitId,
2859
+ chart: {
2860
+ ...editingChart,
2861
+ errorBars: val === "none" ? void 0 : {
2862
+ type: val,
2863
+ value: errObj?.value ?? (val === "percentage" ? 10 : val === "fixedVal" ? 5 : 1)
2864
+ }
2865
+ }
2866
+ });
2867
+ },
2868
+ children: [
2869
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "none", children: "\u65E0\u8BEF\u5DEE\u7EBF" }),
2870
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentage", children: "\u767E\u5206\u6BD4 (%)" }),
2871
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "fixedVal", children: "\u56FA\u5B9A\u503C (Fixed)" }),
2872
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "stdDev", children: "\u6807\u51C6\u5DEE (StdDev)" })
2873
+ ]
2874
+ }
2875
+ )
2876
+ ] })
2877
+ ] }),
2878
+ (trType === "polynomial" || trType === "movingAvg" || errType !== "none") && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2879
+ trType === "polynomial" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2880
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u591A\u9879\u5F0F\u9636\u6570 (2-6)" }),
2881
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2882
+ "input",
2883
+ {
2884
+ type: "number",
2885
+ min: 2,
2886
+ max: 6,
2887
+ value: trObj?.order ?? 2,
2888
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2889
+ unitId,
2890
+ chart: {
2891
+ ...editingChart,
2892
+ trendline: {
2893
+ ...trObj,
2894
+ order: Math.max(2, Math.min(6, Number(e.target.value) || 2))
2895
+ }
2896
+ }
2897
+ })
2898
+ }
2899
+ )
2900
+ ] }),
2901
+ trType === "movingAvg" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2902
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u79FB\u52A8\u5E73\u5747\u5468\u671F" }),
2903
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2904
+ "input",
2905
+ {
2906
+ type: "number",
2907
+ min: 2,
2908
+ max: 12,
2909
+ value: trObj?.period ?? 2,
2910
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2911
+ unitId,
2912
+ chart: {
2913
+ ...editingChart,
2914
+ trendline: {
2915
+ ...trObj,
2916
+ period: Math.max(2, Math.min(12, Number(e.target.value) || 2))
2917
+ }
2918
+ }
2919
+ })
2920
+ }
2921
+ )
2922
+ ] }),
2923
+ errType !== "none" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2924
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8BEF\u5DEE\u6570\u503C" }),
2925
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2926
+ "input",
2927
+ {
2928
+ type: "number",
2929
+ min: 0,
2930
+ step: "0.5",
2931
+ value: errObj?.value ?? 10,
2932
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2933
+ unitId,
2934
+ chart: {
2935
+ ...editingChart,
2936
+ errorBars: {
2937
+ type: errType,
2938
+ value: Math.max(0, Number(e.target.value) || 0)
2939
+ }
2940
+ }
2941
+ })
2942
+ }
2943
+ )
2944
+ ] })
2945
+ ] }),
2946
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr auto", gap: 6, alignItems: "end" }, children: [
2947
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2948
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u56FE\u4F8B\u4F4D\u7F6E" }),
2949
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2950
+ "select",
2951
+ {
2952
+ "data-testid": "yudao-chart-inspector-legend",
2953
+ value: legVal,
2954
+ onChange: (e) => {
2955
+ const nextPos = e.target.value;
2956
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2957
+ unitId,
2958
+ chart: {
2959
+ ...editingChart,
2960
+ showLegend: nextPos !== "none",
2961
+ legendPosition: nextPos
2962
+ }
2963
+ });
2964
+ },
2965
+ children: [
2966
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "r", children: "\u53F3\u4FA7 (Right)" }),
2967
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "t", children: "\u9876\u90E8 (Top)" }),
2968
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "b", children: "\u5E95\u90E8 (Bottom)" }),
2969
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "l", children: "\u5DE6\u4FA7 (Left)" }),
2970
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "none", children: "\u9690\u85CF\u56FE\u4F8B (None)" })
2971
+ ]
2972
+ }
2973
+ )
2974
+ ] }),
2975
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2976
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u4E3B\u8272" }),
2977
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2978
+ "input",
2979
+ {
2980
+ type: "color",
2981
+ style: { width: 38, height: 25, padding: 1 },
2982
+ value: editingChart.palette?.[0] ?? "#2C53F1",
2983
+ onChange: (e) => {
2984
+ const rest = editingChart.palette?.slice(1) ?? [
2985
+ "#10B981",
2986
+ "#F59E0B",
2987
+ "#EF4444",
2988
+ "#8B5CF6"
2989
+ ];
2990
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
2991
+ unitId,
2992
+ chart: {
2993
+ ...editingChart,
2994
+ palette: [e.target.value, ...rest]
2995
+ }
2996
+ });
2997
+ }
2998
+ }
2999
+ )
3000
+ ] })
3001
+ ] }),
3002
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexWrap: "wrap", gap: 10, fontSize: 11, color: "#31363F" }, children: [
3003
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
3004
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3005
+ "input",
3006
+ {
3007
+ "data-testid": "yudao-chart-inspector-secondary-axis",
3008
+ type: "checkbox",
3009
+ checked: hasSecondary,
3010
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
3011
+ unitId,
3012
+ chart: {
3013
+ ...editingChart,
3014
+ secondarySeriesIndices: e.target.checked ? [1] : void 0,
3015
+ ...e.target.checked && editingChart.chartType === "combo" ? {
3016
+ comboLineSeriesIndices: editingChart.comboLineSeriesIndices?.length ? editingChart.comboLineSeriesIndices : [1]
3017
+ } : {}
3018
+ }
3019
+ })
3020
+ }
3021
+ ),
3022
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u53CC\u8F74\u6B21\u5750\u6807\u8F74 (\u53F3\u4FA7\u8F74)" })
3023
+ ] }),
3024
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
3025
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3026
+ "input",
3027
+ {
3028
+ type: "checkbox",
3029
+ checked: Boolean(editingChart.showDataLabels || editingChart.dataLabels?.showVal),
3030
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
3031
+ unitId,
3032
+ chart: {
3033
+ ...editingChart,
3034
+ showDataLabels: e.target.checked,
3035
+ dataLabels: {
3036
+ ...editingChart.dataLabels,
3037
+ showVal: e.target.checked
3038
+ }
3039
+ }
3040
+ })
3041
+ }
3042
+ ),
3043
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u663E\u793A\u6570\u636E\u6807\u7B7E" })
3044
+ ] }),
3045
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
3046
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3047
+ "input",
3048
+ {
3049
+ type: "checkbox",
3050
+ checked: Boolean(editingChart.smooth),
3051
+ onChange: (e) => commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
3052
+ unitId,
3053
+ chart: { ...editingChart, smooth: e.target.checked }
3054
+ })
3055
+ }
3056
+ ),
3057
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5E73\u6ED1\u66F2\u7EBF" })
3058
+ ] })
3059
+ ] })
3060
+ ] });
3061
+ })()
2671
3062
  ]
2672
3063
  }
2673
3064
  ),
2674
3065
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2675
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u4EA4\u4E92\u5F0F\u5207\u7247\u5668 & \u65E5\u671F\u65F6\u95F4\u8F74\u7B5B\u9009" }),
2676
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 0.8fr 1fr", gap: 4 }, children: [
2677
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2678
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6570\u636E\u533A\u95F4" }),
2679
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2680
- "input",
2681
- {
2682
- type: "text",
2683
- value: slicerRange,
2684
- onChange: (e) => setSlicerRange(e.target.value)
2685
- }
2686
- )
3066
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3067
+ "div",
3068
+ {
3069
+ "data-testid": "yudao-pivot-configurator",
3070
+ style: { display: "flex", flexDirection: "column", gap: 6 },
3071
+ children: [
3072
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
3073
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u56DB\u8C61\u9650\u6570\u636E\u900F\u89C6\u8868\u914D\u7F6E\u9762\u677F" }),
3074
+ pivots.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3075
+ "span",
3076
+ {
3077
+ style: {
3078
+ fontSize: 10,
3079
+ padding: "1px 6px",
3080
+ borderRadius: 999,
3081
+ background: "#EEF2FF",
3082
+ color: "#2C53F1"
3083
+ },
3084
+ children: [
3085
+ pivots.length,
3086
+ " \u4E2A\u900F\u89C6\u8868"
3087
+ ]
3088
+ }
3089
+ )
3090
+ ] }),
3091
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
3092
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
3093
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u900F\u89C6\u8868\u5B9E\u4F8B" }),
3094
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3095
+ "select",
3096
+ {
3097
+ "data-testid": "yudao-pivot-instance-select",
3098
+ value: activePivot ? activePivot.id : "__new__",
3099
+ onChange: (e) => {
3100
+ const nextId = e.target.value;
3101
+ setSelectedPivotId(nextId);
3102
+ const found = pivots.find((p) => p.id === nextId);
3103
+ if (found) {
3104
+ setPivotSourceRange(found.sourceRange ?? "");
3105
+ const rows = (found.rowFields ?? found.rowDimCols ?? []).map(
3106
+ (f) => resolvePivotFieldCol(f, 0)
3107
+ );
3108
+ const cols = (found.columnFields ?? found.colDimCols ?? []).map(
3109
+ (f) => resolvePivotFieldCol(f, 0)
3110
+ );
3111
+ const vals = found.valueFields && found.valueFields.length > 0 ? found.valueFields.map((vf) => ({
3112
+ ...vf,
3113
+ colIndex: resolvePivotFieldCol(vf.colIndex ?? vf.field, 0)
3114
+ })) : [{ colIndex: found.valueCol ?? 0, aggFunc: found.aggFunc ?? "SUM" }];
3115
+ setPivotRowFields(rows);
3116
+ setPivotColFields(cols);
3117
+ setPivotValueFields(vals);
3118
+ setPivotFilterFields(
3119
+ (found.filterFields ?? []).map((ff) => ({
3120
+ ...ff,
3121
+ colIndex: resolvePivotFieldCol(ff.colIndex ?? ff.field, 0)
3122
+ }))
3123
+ );
3124
+ setPivotCalcFields(found.calculatedFields ?? []);
3125
+ if (rows[0] !== void 0) setPivotRowCol(rows[0]);
3126
+ setPivotColCol(cols[0] ?? -1);
3127
+ if (vals[0]) {
3128
+ setPivotValCol(resolvePivotFieldCol(vals[0].colIndex ?? vals[0].field, 0));
3129
+ setPivotAgg(vals[0].aggFunc);
3130
+ }
3131
+ }
3132
+ },
3133
+ children: [
3134
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "__new__", children: "+ \u65B0\u5EFA\u6570\u636E\u900F\u89C6\u8868" }),
3135
+ pivots.map((p, idx) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: p.id ?? `__idx_${idx}`, children: p.name || p.targetSheetName || `PivotTable${idx + 1}` }, p.id ?? idx))
3136
+ ]
3137
+ }
3138
+ )
3139
+ ] }),
3140
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
3141
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6570\u636E\u6E90\u533A\u95F4 (\u53EF\u9009)" }),
3142
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3143
+ "input",
3144
+ {
3145
+ type: "text",
3146
+ placeholder: "\u9ED8\u8BA4\u6574\u8868\u5982 A1:F20",
3147
+ value: pivotSourceRange,
3148
+ onChange: (e) => setPivotSourceRange(e.target.value)
3149
+ }
3150
+ )
3151
+ ] })
3152
+ ] }),
3153
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3154
+ "div",
3155
+ {
3156
+ style: {
3157
+ padding: "5px 6px",
3158
+ borderRadius: 6,
3159
+ background: "#F8FAFC",
3160
+ border: "1px solid #E2E8F0",
3161
+ display: "flex",
3162
+ flexDirection: "column",
3163
+ gap: 4
3164
+ },
3165
+ children: [
3166
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
3167
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#475569" }, children: "\u6E90\u5B57\u6BB5\u5217\u8868\uFF08\u70B9\u51FB\u6DFB\u52A0\u81F3\uFF1A" }),
3168
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", gap: 2 }, children: [
3169
+ { key: "rows", label: "\u884C" },
3170
+ { key: "cols", label: "\u5217" },
3171
+ { key: "values", label: "\u503C" },
3172
+ { key: "filters", label: "\u7B5B\u9009" }
3173
+ ].map((q) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3174
+ "button",
3175
+ {
3176
+ type: "button",
3177
+ onClick: () => setPivotChipTarget(q.key),
3178
+ style: {
3179
+ fontSize: 10,
3180
+ padding: "1px 5px",
3181
+ borderRadius: 4,
3182
+ border: "1px solid",
3183
+ borderColor: pivotChipTarget === q.key ? "#2C53F1" : "#CBD5E1",
3184
+ background: pivotChipTarget === q.key ? "#EEF2FF" : "#FFFFFF",
3185
+ color: pivotChipTarget === q.key ? "#2C53F1" : "#475569",
3186
+ cursor: "pointer"
3187
+ },
3188
+ children: q.label
3189
+ },
3190
+ q.key
3191
+ )) })
3192
+ ] }),
3193
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: pivotSourceColumns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3194
+ "button",
3195
+ {
3196
+ type: "button",
3197
+ onClick: () => {
3198
+ if (pivotChipTarget === "rows") {
3199
+ if (!pivotRowFields.includes(col.colIndex)) {
3200
+ const next = [...pivotRowFields, col.colIndex];
3201
+ setPivotRowFields(next);
3202
+ setPivotRowCol(next[0]);
3203
+ }
3204
+ } else if (pivotChipTarget === "cols") {
3205
+ if (!pivotColFields.includes(col.colIndex)) {
3206
+ const next = [...pivotColFields, col.colIndex];
3207
+ setPivotColFields(next);
3208
+ setPivotColCol(next[0]);
3209
+ }
3210
+ } else if (pivotChipTarget === "values") {
3211
+ const next = [
3212
+ ...pivotValueFields,
3213
+ { colIndex: col.colIndex, aggFunc: "sum" }
3214
+ ];
3215
+ setPivotValueFields(next);
3216
+ setPivotValCol(col.colIndex);
3217
+ } else if (!pivotFilterFields.some((f) => f.colIndex === col.colIndex)) {
3218
+ setPivotFilterFields([...pivotFilterFields, { colIndex: col.colIndex }]);
3219
+ }
3220
+ },
3221
+ style: {
3222
+ fontSize: 10.5,
3223
+ padding: "2px 6px",
3224
+ borderRadius: 999,
3225
+ border: "1px solid #CBD5E1",
3226
+ background: "#FFFFFF",
3227
+ color: "#1E293B",
3228
+ cursor: "pointer"
3229
+ },
3230
+ children: [
3231
+ "+ ",
3232
+ col.label
3233
+ ]
3234
+ },
3235
+ col.colIndex
3236
+ )) })
3237
+ ]
3238
+ }
3239
+ ),
3240
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3241
+ "div",
3242
+ {
3243
+ "data-testid": "yudao-pivot-quadrants",
3244
+ style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 5 },
3245
+ children: [
3246
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3247
+ "div",
3248
+ {
3249
+ style: {
3250
+ padding: "5px 6px",
3251
+ borderRadius: 6,
3252
+ border: "1px solid #E2E8F0",
3253
+ background: "#FFFFFF",
3254
+ display: "flex",
3255
+ flexDirection: "column",
3256
+ gap: 4,
3257
+ minHeight: 74
3258
+ },
3259
+ children: [
3260
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3261
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u7B5B\u9009\u5668 (Filters)" }),
3262
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3263
+ "select",
3264
+ {
3265
+ value: "",
3266
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3267
+ onChange: (e) => {
3268
+ if (e.target.value === "") return;
3269
+ const c = Number(e.target.value);
3270
+ if (!pivotFilterFields.some((f) => f.colIndex === c)) {
3271
+ setPivotFilterFields([...pivotFilterFields, { colIndex: c }]);
3272
+ }
3273
+ },
3274
+ children: [
3275
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "+ \u5B57\u6BB5" }),
3276
+ pivotSourceColumns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: c.colIndex, children: c.label }, c.colIndex))
3277
+ ]
3278
+ }
3279
+ )
3280
+ ] }),
3281
+ pivotFilterFields.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10, color: "#94A3B8" }, children: "\u672A\u8BBE\u7F6E\u62A5\u8868\u7B5B\u9009" }),
3282
+ pivotFilterFields.map((ff, ffIdx) => {
3283
+ const ffCol = resolvePivotFieldCol(ff.colIndex ?? ff.field, 0);
3284
+ const choices = getPivotFilterChoices(ffCol);
3285
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3286
+ "div",
3287
+ {
3288
+ style: {
3289
+ display: "flex",
3290
+ flexDirection: "column",
3291
+ gap: 2,
3292
+ padding: "3px 4px",
3293
+ borderRadius: 4,
3294
+ background: "#F8FAFC",
3295
+ fontSize: 10
3296
+ },
3297
+ children: [
3298
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
3299
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontWeight: 500, color: "#1E293B" }, children: getPivotColumnLabel(ffCol) }),
3300
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3301
+ "button",
3302
+ {
3303
+ type: "button",
3304
+ onClick: () => setPivotFilterFields(
3305
+ pivotFilterFields.filter((_, idx) => idx !== ffIdx)
3306
+ ),
3307
+ style: {
3308
+ border: "none",
3309
+ background: "transparent",
3310
+ color: "#64748B",
3311
+ cursor: "pointer",
3312
+ fontSize: 11,
3313
+ padding: "0 2px"
3314
+ },
3315
+ children: "\xD7"
3316
+ }
3317
+ )
3318
+ ] }),
3319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3320
+ "select",
3321
+ {
3322
+ value: ff.selectedValues?.length === 1 ? ff.selectedValues[0] : "__all__",
3323
+ style: { fontSize: 10, padding: "1px 2px" },
3324
+ onChange: (e) => {
3325
+ const v = e.target.value;
3326
+ setPivotFilterFields(
3327
+ pivotFilterFields.map(
3328
+ (item, idx) => idx === ffIdx ? { ...item, selectedValues: v === "__all__" ? void 0 : [v] } : item
3329
+ )
3330
+ );
3331
+ },
3332
+ children: [
3333
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "__all__", children: "(\u5168\u90E8\u503C)" }),
3334
+ choices.map((val) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: val, children: val }, val))
3335
+ ]
3336
+ }
3337
+ )
3338
+ ]
3339
+ },
3340
+ `${ffCol}-${ffIdx}`
3341
+ );
3342
+ })
3343
+ ]
3344
+ }
3345
+ ),
3346
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3347
+ "div",
3348
+ {
3349
+ style: {
3350
+ padding: "5px 6px",
3351
+ borderRadius: 6,
3352
+ border: "1px solid #E2E8F0",
3353
+ background: "#FFFFFF",
3354
+ display: "flex",
3355
+ flexDirection: "column",
3356
+ gap: 4,
3357
+ minHeight: 74
3358
+ },
3359
+ children: [
3360
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u5217\u7EF4\u5EA6 (Columns)" }),
3362
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3363
+ "select",
3364
+ {
3365
+ value: "",
3366
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3367
+ onChange: (e) => {
3368
+ if (e.target.value === "") return;
3369
+ const c = Number(e.target.value);
3370
+ if (!pivotColFields.includes(c)) {
3371
+ const next = [...pivotColFields, c];
3372
+ setPivotColFields(next);
3373
+ setPivotColCol(next[0]);
3374
+ }
3375
+ },
3376
+ children: [
3377
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "+ \u5B57\u6BB5" }),
3378
+ pivotSourceColumns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: c.colIndex, children: c.label }, c.colIndex))
3379
+ ]
3380
+ }
3381
+ )
3382
+ ] }),
3383
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexWrap: "wrap", gap: 3 }, children: [
3384
+ pivotColFields.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10, color: "#94A3B8" }, children: "\u65E0\u4EA4\u53C9\u5217\uFF08\u4E00\u7EF4\u6C47\u603B\uFF09" }),
3385
+ pivotColFields.map((colIdx) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3386
+ "span",
3387
+ {
3388
+ style: {
3389
+ display: "inline-flex",
3390
+ alignItems: "center",
3391
+ gap: 3,
3392
+ fontSize: 10,
3393
+ padding: "2px 5px",
3394
+ borderRadius: 4,
3395
+ background: "#EEF2FF",
3396
+ color: "#2C53F1"
3397
+ },
3398
+ children: [
3399
+ getPivotColumnLabel(colIdx),
3400
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3401
+ "button",
3402
+ {
3403
+ type: "button",
3404
+ onClick: () => {
3405
+ const next = pivotColFields.filter((x) => x !== colIdx);
3406
+ setPivotColFields(next);
3407
+ setPivotColCol(next[0] ?? -1);
3408
+ },
3409
+ style: {
3410
+ border: "none",
3411
+ background: "transparent",
3412
+ color: "#2C53F1",
3413
+ cursor: "pointer",
3414
+ padding: 0,
3415
+ fontSize: 11
3416
+ },
3417
+ children: "\xD7"
3418
+ }
3419
+ )
3420
+ ]
3421
+ },
3422
+ colIdx
3423
+ ))
3424
+ ] })
3425
+ ]
3426
+ }
3427
+ ),
3428
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3429
+ "div",
3430
+ {
3431
+ style: {
3432
+ padding: "5px 6px",
3433
+ borderRadius: 6,
3434
+ border: "1px solid #E2E8F0",
3435
+ background: "#FFFFFF",
3436
+ display: "flex",
3437
+ flexDirection: "column",
3438
+ gap: 4,
3439
+ minHeight: 74
3440
+ },
3441
+ children: [
3442
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3443
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u884C\u7EF4\u5EA6 (Rows)" }),
3444
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3445
+ "select",
3446
+ {
3447
+ value: "",
3448
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3449
+ onChange: (e) => {
3450
+ if (e.target.value === "") return;
3451
+ const c = Number(e.target.value);
3452
+ if (!pivotRowFields.includes(c)) {
3453
+ const next = [...pivotRowFields, c];
3454
+ setPivotRowFields(next);
3455
+ setPivotRowCol(next[0]);
3456
+ }
3457
+ },
3458
+ children: [
3459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "+ \u5B57\u6BB5" }),
3460
+ pivotSourceColumns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: c.colIndex, children: c.label }, c.colIndex))
3461
+ ]
3462
+ }
3463
+ )
3464
+ ] }),
3465
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 3 }, children: pivotRowFields.map((colIdx) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3466
+ "span",
3467
+ {
3468
+ style: {
3469
+ display: "inline-flex",
3470
+ alignItems: "center",
3471
+ gap: 3,
3472
+ fontSize: 10,
3473
+ padding: "2px 5px",
3474
+ borderRadius: 4,
3475
+ background: "#ECFDF5",
3476
+ color: "#047857"
3477
+ },
3478
+ children: [
3479
+ getPivotColumnLabel(colIdx),
3480
+ pivotRowFields.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3481
+ "button",
3482
+ {
3483
+ type: "button",
3484
+ onClick: () => {
3485
+ const next = pivotRowFields.filter((x) => x !== colIdx);
3486
+ setPivotRowFields(next);
3487
+ if (next[0] !== void 0) setPivotRowCol(next[0]);
3488
+ },
3489
+ style: {
3490
+ border: "none",
3491
+ background: "transparent",
3492
+ color: "#047857",
3493
+ cursor: "pointer",
3494
+ padding: 0,
3495
+ fontSize: 11
3496
+ },
3497
+ children: "\xD7"
3498
+ }
3499
+ )
3500
+ ]
3501
+ },
3502
+ colIdx
3503
+ )) })
3504
+ ]
3505
+ }
3506
+ ),
3507
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3508
+ "div",
3509
+ {
3510
+ style: {
3511
+ padding: "5px 6px",
3512
+ borderRadius: 6,
3513
+ border: "1px solid #E2E8F0",
3514
+ background: "#FFFFFF",
3515
+ display: "flex",
3516
+ flexDirection: "column",
3517
+ gap: 4,
3518
+ minHeight: 74
3519
+ },
3520
+ children: [
3521
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3522
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u503C\u6307\u6807 (Values)" }),
3523
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3524
+ "select",
3525
+ {
3526
+ value: "",
3527
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3528
+ onChange: (e) => {
3529
+ if (e.target.value === "") return;
3530
+ const c = Number(e.target.value);
3531
+ const next = [
3532
+ ...pivotValueFields,
3533
+ { colIndex: c, aggFunc: "sum" }
3534
+ ];
3535
+ setPivotValueFields(next);
3536
+ setPivotValCol(c);
3537
+ },
3538
+ children: [
3539
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "+ \u5B57\u6BB5" }),
3540
+ pivotSourceColumns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: c.colIndex, children: c.label }, c.colIndex))
3541
+ ]
3542
+ }
3543
+ )
3544
+ ] }),
3545
+ pivotValueFields.map((vf, idx) => {
3546
+ const vfCol = resolvePivotFieldCol(vf.colIndex ?? vf.field, 0);
3547
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3548
+ "div",
3549
+ {
3550
+ style: {
3551
+ display: "flex",
3552
+ alignItems: "center",
3553
+ justifyContent: "space-between",
3554
+ gap: 2,
3555
+ padding: "2px 4px",
3556
+ borderRadius: 4,
3557
+ background: "#FFFBEB",
3558
+ fontSize: 10
3559
+ },
3560
+ children: [
3561
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3562
+ "span",
3563
+ {
3564
+ style: {
3565
+ color: "#92400E",
3566
+ fontWeight: 500,
3567
+ overflow: "hidden",
3568
+ textOverflow: "ellipsis",
3569
+ whiteSpace: "nowrap"
3570
+ },
3571
+ children: getPivotColumnLabel(vfCol)
3572
+ }
3573
+ ),
3574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 2 }, children: [
3575
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3576
+ "select",
3577
+ {
3578
+ value: vf.aggFunc.toLowerCase(),
3579
+ style: { fontSize: 10, padding: "0 2px" },
3580
+ onChange: (e) => {
3581
+ const nextAgg = e.target.value;
3582
+ const next = pivotValueFields.map(
3583
+ (item, i) => i === idx ? { ...item, aggFunc: nextAgg } : item
3584
+ );
3585
+ setPivotValueFields(next);
3586
+ if (idx === 0) setPivotAgg(nextAgg.toUpperCase());
3587
+ },
3588
+ children: [
3589
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "sum", children: "\u6C42\u548C" }),
3590
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "count", children: "\u8BA1\u6570" }),
3591
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "avg", children: "\u5E73\u5747" }),
3592
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "max", children: "\u6700\u5927" }),
3593
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "min", children: "\u6700\u5C0F" }),
3594
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "stdev", children: "\u6807\u51C6\u5DEE" }),
3595
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "var", children: "\u65B9\u5DEE" })
3596
+ ]
3597
+ }
3598
+ ),
3599
+ pivotValueFields.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3600
+ "button",
3601
+ {
3602
+ type: "button",
3603
+ onClick: () => setPivotValueFields(pivotValueFields.filter((_, i) => i !== idx)),
3604
+ style: {
3605
+ border: "none",
3606
+ background: "transparent",
3607
+ color: "#92400E",
3608
+ cursor: "pointer",
3609
+ padding: 0,
3610
+ fontSize: 11
3611
+ },
3612
+ children: "\xD7"
3613
+ }
3614
+ )
3615
+ ] })
3616
+ ]
3617
+ },
3618
+ `${vfCol}-${idx}`
3619
+ );
3620
+ })
3621
+ ]
3622
+ }
3623
+ )
3624
+ ]
3625
+ }
3626
+ ),
3627
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
3628
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
3629
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u503C\u663E\u793A\u65B9\u5F0F" }),
3630
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3631
+ "select",
3632
+ {
3633
+ value: pivotShowAs,
3634
+ onChange: (e) => setPivotShowAs(e.target.value),
3635
+ children: [
3636
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "normal", children: "\u5E38\u89C4\u6C47\u603B\u503C" }),
3637
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentOfGrandTotal", children: "\u5360\u603B\u8BA1\u767E\u5206\u6BD4" }),
3638
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentOfRow", children: "\u5360\u884C\u6C47\u603B\u767E\u5206\u6BD4" }),
3639
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "percentOfColumn", children: "\u5360\u5217\u6C47\u603B\u767E\u5206\u6BD4" }),
3640
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "runningTotal", children: "\u6309\u5217\u7D2F\u8BA1\u503C" }),
3641
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "rankDesc", children: "\u964D\u5E8F\u6392\u540D" })
3642
+ ]
3643
+ }
3644
+ )
3645
+ ] }),
3646
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
3647
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u884C\u65E5\u671F\u5206\u7EC4" }),
3648
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3649
+ "select",
3650
+ {
3651
+ value: pivotDateGroup,
3652
+ onChange: (e) => setPivotDateGroup(e.target.value),
3653
+ children: [
3654
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\u4E0D\u6309\u65E5\u671F\u5206\u7EC4" }),
3655
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "year", children: "\u6309\u5E74\u4EFD (YYYY\u5E74)" }),
3656
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "quarter", children: "\u6309\u5B63\u5EA6 (YYYY-QN)" }),
3657
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "month", children: "\u6309\u6708\u4EFD (YYYY-MM)" })
3658
+ ]
3659
+ }
3660
+ )
3661
+ ] })
3662
+ ] }),
3663
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3664
+ "div",
3665
+ {
3666
+ style: {
3667
+ display: "flex",
3668
+ flexDirection: "column",
3669
+ gap: 4,
3670
+ padding: "5px 6px",
3671
+ borderRadius: 6,
3672
+ background: "#F8FAFC",
3673
+ border: "1px solid #E2E8F0"
3674
+ },
3675
+ children: [
3676
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u8BA1\u7B97\u5B57\u6BB5 (Calculated Fields)" }),
3677
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "0.8fr 1.2fr auto", gap: 4 }, children: [
3678
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3679
+ "input",
3680
+ {
3681
+ type: "text",
3682
+ placeholder: "\u540D\u79F0\u5982 \u6BDB\u5229\u7387",
3683
+ style: { fontSize: 10.5, padding: "3px 5px" },
3684
+ value: calcFieldName,
3685
+ onChange: (e) => setCalcFieldName(e.target.value)
3686
+ }
3687
+ ),
3688
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3689
+ "input",
3690
+ {
3691
+ type: "text",
3692
+ placeholder: "\u516C\u5F0F\u5982 \u5229\u6DA6 / \u9500\u552E\u989D",
3693
+ style: { fontSize: 10.5, padding: "3px 5px" },
3694
+ value: calcFieldFormula,
3695
+ onChange: (e) => setCalcFieldFormula(e.target.value)
3696
+ }
3697
+ ),
3698
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3699
+ "button",
3700
+ {
3701
+ type: "button",
3702
+ className: "yudao-sheet-btn",
3703
+ style: { padding: "2px 6px", fontSize: 10.5 },
3704
+ onClick: () => {
3705
+ const n = calcFieldName.trim();
3706
+ const f = calcFieldFormula.trim();
3707
+ if (!n || !f) return;
3708
+ setPivotCalcFields([
3709
+ ...pivotCalcFields.filter((c) => c.name !== n),
3710
+ { name: n, formula: f }
3711
+ ]);
3712
+ setCalcFieldName("");
3713
+ setCalcFieldFormula("");
3714
+ },
3715
+ children: "+ \u6DFB\u52A0"
3716
+ }
3717
+ )
3718
+ ] }),
3719
+ pivotCalcFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: pivotCalcFields.map((cf) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3720
+ "span",
3721
+ {
3722
+ style: {
3723
+ display: "inline-flex",
3724
+ alignItems: "center",
3725
+ gap: 4,
3726
+ fontSize: 10,
3727
+ padding: "2px 6px",
3728
+ borderRadius: 4,
3729
+ background: "#F3E8FF",
3730
+ color: "#6B21A8"
3731
+ },
3732
+ children: [
3733
+ cf.name,
3734
+ " = ",
3735
+ cf.formula,
3736
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3737
+ "button",
3738
+ {
3739
+ type: "button",
3740
+ onClick: () => setPivotCalcFields(pivotCalcFields.filter((x) => x.name !== cf.name)),
3741
+ style: {
3742
+ border: "none",
3743
+ background: "transparent",
3744
+ color: "#6B21A8",
3745
+ cursor: "pointer",
3746
+ padding: 0,
3747
+ fontSize: 11
3748
+ },
3749
+ children: "\xD7"
3750
+ }
3751
+ )
3752
+ ]
3753
+ },
3754
+ cf.name
3755
+ )) })
3756
+ ]
3757
+ }
3758
+ ),
3759
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer", fontSize: 11 }, children: [
3760
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3761
+ "input",
3762
+ {
3763
+ type: "checkbox",
3764
+ checked: withPivotChart,
3765
+ onChange: (e) => setWithPivotChart(e.target.checked)
3766
+ }
3767
+ ),
3768
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u65B0\u5EFA\u65F6\u540C\u6B65\u751F\u6210\u8054\u52A8\u900F\u89C6\u56FE (PivotChart)" })
3769
+ ] }),
3770
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 4 }, children: [
3771
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3772
+ "button",
3773
+ {
3774
+ "data-testid": "yudao-pivot-apply-btn",
3775
+ type: "button",
3776
+ className: "yudao-sheet-btn is-soft-primary",
3777
+ onClick: () => {
3778
+ const effectiveRows = pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol];
3779
+ const effectiveVals = pivotValueFields.length > 0 ? pivotValueFields : [{ colIndex: pivotValCol, aggFunc: pivotAgg }];
3780
+ const firstVal = effectiveVals[0];
3781
+ const builtConfig = {
3782
+ ...activePivot ?? {},
3783
+ ...pivotSourceRange.trim() ? { sourceRange: pivotSourceRange.trim() } : {},
3784
+ rowDimCols: effectiveRows,
3785
+ rowFields: effectiveRows,
3786
+ colDimCols: pivotColFields,
3787
+ columnFields: pivotColFields,
3788
+ valueCol: firstVal.colIndex,
3789
+ aggFunc: firstVal.aggFunc.toUpperCase(),
3790
+ valueFields: effectiveVals,
3791
+ filterFields: pivotFilterFields.length > 0 ? pivotFilterFields : void 0,
3792
+ calculatedFields: pivotCalcFields.length > 0 ? pivotCalcFields : void 0,
3793
+ valueShowAs: pivotShowAs,
3794
+ ...pivotDateGroup ? { dateGroupBy: pivotDateGroup } : {},
3795
+ showSubtotals: true,
3796
+ withPivotChart,
3797
+ pivotChartType: chartType
3798
+ };
3799
+ if (activePivot?.id) {
3800
+ templateService.addOrUpdatePivot(unitId, builtConfig);
3801
+ commandService.syncExecuteCommand(import_univer_sheets2.RefreshSheetPivotCommand.id, {
3802
+ unitId,
3803
+ pivotId: activePivot.id
3804
+ });
3805
+ } else {
3806
+ commandService.syncExecuteCommand(import_univer_sheets2.GenerateSheetPivotCommand.id, {
3807
+ unitId,
3808
+ sourceSubUnitId: sheet.getSheetId(),
3809
+ pivotConfig: builtConfig
3810
+ });
3811
+ }
3812
+ },
3813
+ children: activePivot ? "\u5E94\u7528\u5E76\u5237\u65B0\u900F\u89C6\u8868" : `\u751F\u6210\u900F\u89C6\u8868${withPivotChart ? " + \u900F\u89C6\u56FE" : ""}`
3814
+ }
3815
+ ),
3816
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3817
+ "button",
3818
+ {
3819
+ "data-testid": "yudao-pivot-create-chart-btn",
3820
+ type: "button",
3821
+ className: "yudao-sheet-btn",
3822
+ onClick: () => {
3823
+ const targetPivot = activePivot ?? pivots[pivots.length - 1];
3824
+ if (targetPivot?.targetSheetId) {
3825
+ const pivotSheet = workbook.getSheetBySheetId(targetPivot.targetSheetId);
3826
+ if (pivotSheet) {
3827
+ const pSnap = pivotSheet.getConfig();
3828
+ const linked = (0, import_univer_sheets2.buildPivotLinkedChart)(
3829
+ pSnap,
3830
+ { ...targetPivot, pivotChartType: chartType },
3831
+ targetPivot.targetSheetId
3832
+ );
3833
+ if (linked) {
3834
+ commandService.syncExecuteCommand(import_univer_sheets2.UpdateSheetChartCommand.id, {
3835
+ unitId,
3836
+ chart: linked
3837
+ });
3838
+ setSelectedChartId(linked.id);
3839
+ return;
3840
+ }
3841
+ }
3842
+ }
3843
+ commandService.syncExecuteCommand(import_univer_sheets2.GenerateSheetPivotCommand.id, {
3844
+ unitId,
3845
+ sourceSubUnitId: sheet.getSheetId(),
3846
+ pivotConfig: {
3847
+ ...pivotSourceRange.trim() ? { sourceRange: pivotSourceRange.trim() } : {},
3848
+ rowDimCols: pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol],
3849
+ rowFields: pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol],
3850
+ colDimCols: pivotColFields,
3851
+ columnFields: pivotColFields,
3852
+ valueCol: pivotValueFields[0]?.colIndex ?? pivotValCol,
3853
+ aggFunc: (pivotValueFields[0]?.aggFunc ?? pivotAgg).toUpperCase(),
3854
+ valueFields: pivotValueFields,
3855
+ filterFields: pivotFilterFields.length > 0 ? pivotFilterFields : void 0,
3856
+ calculatedFields: pivotCalcFields.length > 0 ? pivotCalcFields : void 0,
3857
+ showSubtotals: true,
3858
+ withPivotChart: true,
3859
+ pivotChartType: chartType
3860
+ }
3861
+ });
3862
+ },
3863
+ children: "+ \u521B\u5EFA\u900F\u89C6\u56FE"
3864
+ }
3865
+ )
3866
+ ] })
3867
+ ]
3868
+ }
3869
+ ),
3870
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
3871
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u4EA4\u4E92\u5F0F\u5207\u7247\u5668 & \u65E5\u671F\u65F6\u95F4\u8F74\u7B5B\u9009" }),
3872
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 0.8fr 1fr", gap: 4 }, children: [
3873
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
3874
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6570\u636E\u533A\u95F4" }),
3875
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3876
+ "input",
3877
+ {
3878
+ type: "text",
3879
+ value: slicerRange,
3880
+ onChange: (e) => setSlicerRange(e.target.value)
3881
+ }
3882
+ )
2687
3883
  ] }),
2688
3884
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
2689
3885
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u7B5B\u9009\u5217" }),
@@ -2793,11 +3989,11 @@ var SheetInspectorPanel = () => {
2793
3989
  ),
2794
3990
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2795
3991
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: [
2796
- "\u516C\u5F0F\u5BA1\u6838 \xB7 \u76D1\u89C6\u7A97\u53E3 \xB7 \u5355\u53D8\u91CF\u6C42\u89E3 (",
3992
+ "\u516C\u5F0F\u6C42\u503C\u4E0E\u76D1\u89C6\u7A97\u53E3 (",
2797
3993
  activeRef,
2798
3994
  ")"
2799
3995
  ] }),
2800
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 4 }, children: [
3996
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2801
3997
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2802
3998
  "button",
2803
3999
  {
@@ -2811,29 +4007,10 @@ var SheetInspectorPanel = () => {
2811
4007
  activeCol
2812
4008
  );
2813
4009
  setAuditOutput(
2814
- nodes.length > 0 ? `\u5F15\u7528\u6E90: ${nodes.map((n) => `${n.sheetName}!${n.cellRef}`).join(" -> ")}` : `${activeRef} \u65E0\u524D\u7F6E\u516C\u5F0F\u5F15\u7528\u5355\u5143\u683C`
2815
- );
2816
- },
2817
- children: "\u8FFD\u8E2A\u5F15\u7528\u5355\u5143\u683C"
2818
- }
2819
- ),
2820
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2821
- "button",
2822
- {
2823
- type: "button",
2824
- className: "yudao-sheet-btn",
2825
- onClick: () => {
2826
- const nodes = (0, import_univer_sheets2.traceFormulaDependents)(
2827
- workbook.save(),
2828
- sheet.getSheetId(),
2829
- activeRow,
2830
- activeCol
2831
- );
2832
- setAuditOutput(
2833
- nodes.length > 0 ? `\u4ECE\u5C5E\u9879: ${nodes.map((n) => `${n.sheetName}!${n.cellRef}`).join(", ")}` : `${activeRef} \u65E0\u4ECE\u5C5E\u4F9D\u8D56\u516C\u5F0F`
4010
+ nodes.length > 0 ? `\u5F15\u7528\u6E90: ${nodes.map((n) => `${n.sheetName}!${n.cellRef}`).join(" -> ")}` : `${activeRef} \u65E0\u524D\u7F6E\u516C\u5F0F\u5F15\u7528\u5355\u5143\u683C`
2834
4011
  );
2835
4012
  },
2836
- children: "\u8FFD\u8E2A\u4ECE\u5C5E\u5355\u5143\u683C"
4013
+ children: "\u8FFD\u8E2A\u5F15\u7528\u5355\u5143\u683C"
2837
4014
  }
2838
4015
  ),
2839
4016
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -2842,57 +4019,243 @@ var SheetInspectorPanel = () => {
2842
4019
  type: "button",
2843
4020
  className: "yudao-sheet-btn",
2844
4021
  onClick: () => {
2845
- const steps = (0, import_univer_sheets2.evaluateFormulaSteps)(
4022
+ const nodes = (0, import_univer_sheets2.traceFormulaDependents)(
2846
4023
  workbook.save(),
2847
4024
  sheet.getSheetId(),
2848
4025
  activeRow,
2849
4026
  activeCol
2850
4027
  );
2851
- setAuditOutput(steps.join(" => "));
2852
- },
2853
- children: "\u516C\u5F0F\u5206\u6B65\u6C42\u503C"
2854
- }
2855
- )
2856
- ] }),
2857
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2858
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontSize: 11, color: "#4E5565" }, children: [
2859
- "\u76D1\u89C6\u7A97\u53E3 (",
2860
- (metadata.watchCells ?? []).length,
2861
- " \u9879)"
2862
- ] }),
2863
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2864
- "button",
2865
- {
2866
- type: "button",
2867
- className: "yudao-sheet-btn",
2868
- style: { padding: "2px 8px", fontSize: 10.5 },
2869
- onClick: () => {
2870
- const curList = metadata.watchCells ?? [];
2871
- const sid = sheet.getSheetId();
2872
- if (curList.some((w) => w.sheetId === sid && w.row === activeRow && w.col === activeCol)) {
2873
- return;
2874
- }
2875
- templateService.setTemplateMetadata(unitId, {
2876
- ...metadata,
2877
- watchCells: [
2878
- ...curList,
2879
- {
2880
- id: `watch-${(0, import_core4.generateRandomId)(5)}`,
2881
- sheetId: sid,
2882
- row: activeRow,
2883
- col: activeCol,
2884
- cellRef: activeRef
2885
- }
2886
- ]
2887
- });
4028
+ setAuditOutput(
4029
+ nodes.length > 0 ? `\u4ECE\u5C5E\u9879: ${nodes.map((n) => `${n.sheetName}!${n.cellRef}`).join(", ")}` : `${activeRef} \u65E0\u4ECE\u5C5E\u4F9D\u8D56\u516C\u5F0F`
4030
+ );
2888
4031
  },
2889
- children: [
2890
- "+ \u76D1\u89C6\u5F53\u524D\u5355\u5143\u683C ",
2891
- activeRef
2892
- ]
4032
+ children: "\u8FFD\u8E2A\u4ECE\u5C5E\u5355\u5143\u683C"
2893
4033
  }
2894
4034
  )
2895
4035
  ] }),
4036
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4037
+ "div",
4038
+ {
4039
+ "data-testid": "yudao-formula-step-evaluator",
4040
+ style: {
4041
+ display: "flex",
4042
+ flexDirection: "column",
4043
+ gap: 5,
4044
+ padding: "6px 7px",
4045
+ borderRadius: 6,
4046
+ background: "#F8FAFC",
4047
+ border: "1px solid #E2E8F0"
4048
+ },
4049
+ children: [
4050
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr auto", gap: 4 }, children: [
4051
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4052
+ "button",
4053
+ {
4054
+ "data-testid": "yudao-formula-step-into",
4055
+ type: "button",
4056
+ className: "yudao-sheet-btn is-soft-primary",
4057
+ onClick: () => {
4058
+ const key = `${sheet.getSheetId()}:${activeRef}`;
4059
+ const steps = (0, import_univer_sheets2.evaluateFormulaSteps)(
4060
+ workbook.save(),
4061
+ sheet.getSheetId(),
4062
+ activeRow,
4063
+ activeCol
4064
+ );
4065
+ setEvalCellKey(key);
4066
+ setEvalSteps(steps);
4067
+ const nextIdx = evalCellKey === key && evalSteps.length === steps.length ? Math.min(steps.length - 1, evalStepIdx + 1) : 0;
4068
+ setEvalStepIdx(nextIdx);
4069
+ setAuditOutput(steps.join(" => "));
4070
+ },
4071
+ children: "\u6B65\u5165\u6C42\u503C (Step Into)"
4072
+ }
4073
+ ),
4074
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4075
+ "button",
4076
+ {
4077
+ "data-testid": "yudao-formula-eval-next",
4078
+ type: "button",
4079
+ className: "yudao-sheet-btn",
4080
+ onClick: () => {
4081
+ const key = `${sheet.getSheetId()}:${activeRef}`;
4082
+ const steps = evalCellKey === key && evalSteps.length > 0 ? evalSteps : (0, import_univer_sheets2.evaluateFormulaSteps)(
4083
+ workbook.save(),
4084
+ sheet.getSheetId(),
4085
+ activeRow,
4086
+ activeCol
4087
+ );
4088
+ const nextIdx = evalCellKey === key ? Math.min(steps.length - 1, evalStepIdx + 1) : 0;
4089
+ setEvalCellKey(key);
4090
+ setEvalSteps(steps);
4091
+ setEvalStepIdx(nextIdx);
4092
+ setAuditOutput(steps[nextIdx] ?? "");
4093
+ },
4094
+ children: "\u4E0B\u4E00\u6B65\u6C42\u503C (Next)"
4095
+ }
4096
+ ),
4097
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4098
+ "button",
4099
+ {
4100
+ type: "button",
4101
+ className: "yudao-sheet-btn",
4102
+ style: { padding: "2px 7px", fontSize: 10.5 },
4103
+ onClick: () => {
4104
+ setEvalStepIdx(0);
4105
+ },
4106
+ children: "\u91CD\u7F6E"
4107
+ }
4108
+ )
4109
+ ] }),
4110
+ evalSteps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 3, fontSize: 10.5 }, children: [
4111
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", color: "#475569" }, children: [
4112
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
4113
+ "\u5F53\u524D\u6C42\u503C\u5B50\u8868\u8FBE\u5F0F (",
4114
+ evalCellKey.split(":")[1] ?? activeRef,
4115
+ ")"
4116
+ ] }),
4117
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontWeight: 600, color: "#2C53F1" }, children: [
4118
+ "\u6B65\u9AA4 ",
4119
+ Math.min(evalStepIdx + 1, evalSteps.length),
4120
+ " / ",
4121
+ evalSteps.length
4122
+ ] })
4123
+ ] }),
4124
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4125
+ "div",
4126
+ {
4127
+ "data-testid": "yudao-formula-current-step",
4128
+ style: {
4129
+ padding: "4px 6px",
4130
+ borderRadius: 4,
4131
+ background: "#EEF2FF",
4132
+ border: "1px solid #C7D2FE",
4133
+ color: "#1E1B4B",
4134
+ fontFamily: "monospace",
4135
+ wordBreak: "break-all"
4136
+ },
4137
+ children: evalSteps[Math.min(evalStepIdx, evalSteps.length - 1)]
4138
+ }
4139
+ )
4140
+ ] })
4141
+ ]
4142
+ }
4143
+ ),
4144
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4145
+ "div",
4146
+ {
4147
+ "data-testid": "yudao-formula-watch-window",
4148
+ style: { display: "flex", flexDirection: "column", gap: 4 },
4149
+ children: [
4150
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
4151
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontSize: 11, fontWeight: 600, color: "#4E5565" }, children: [
4152
+ "\u76D1\u89C6\u7A97\u53E3 (",
4153
+ (metadata.watchCells ?? []).length,
4154
+ " \u9879)"
4155
+ ] }),
4156
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4157
+ "button",
4158
+ {
4159
+ type: "button",
4160
+ className: "yudao-sheet-btn",
4161
+ style: { padding: "2px 8px", fontSize: 10.5 },
4162
+ onClick: () => {
4163
+ const curList = metadata.watchCells ?? [];
4164
+ const sid = sheet.getSheetId();
4165
+ if (curList.some((w) => w.sheetId === sid && w.row === activeRow && w.col === activeCol)) {
4166
+ return;
4167
+ }
4168
+ templateService.setTemplateMetadata(unitId, {
4169
+ ...metadata,
4170
+ watchCells: [
4171
+ ...curList,
4172
+ {
4173
+ id: `watch-${(0, import_core4.generateRandomId)(5)}`,
4174
+ sheetId: sid,
4175
+ row: activeRow,
4176
+ col: activeCol,
4177
+ cellRef: activeRef
4178
+ }
4179
+ ]
4180
+ });
4181
+ },
4182
+ children: [
4183
+ "+ \u76D1\u89C6\u5F53\u524D\u683C ",
4184
+ activeRef
4185
+ ]
4186
+ }
4187
+ )
4188
+ ] }),
4189
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr auto", gap: 4 }, children: [
4190
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4191
+ "input",
4192
+ {
4193
+ "data-testid": "yudao-watch-ref-input",
4194
+ type: "text",
4195
+ placeholder: "\u8F93\u5165\u5F15\u7528\u5982 Sheet1!D10 \u6216 F10",
4196
+ style: { fontSize: 11, padding: "3px 6px" },
4197
+ value: watchInputRef,
4198
+ onChange: (e) => setWatchInputRef(e.target.value)
4199
+ }
4200
+ ),
4201
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4202
+ "button",
4203
+ {
4204
+ "data-testid": "yudao-watch-add-input-btn",
4205
+ type: "button",
4206
+ className: "yudao-sheet-btn is-soft-primary",
4207
+ style: { padding: "2px 8px", fontSize: 10.5 },
4208
+ onClick: () => {
4209
+ const raw = watchInputRef.trim();
4210
+ if (!raw) return;
4211
+ let targetSheet = sheet;
4212
+ let cellPart = raw;
4213
+ const bangIdx = raw.lastIndexOf("!");
4214
+ if (bangIdx > 0) {
4215
+ const sheetToken = raw.slice(0, bangIdx).trim().replace(/^'+|'+$/g, "");
4216
+ cellPart = raw.slice(bangIdx + 1).trim();
4217
+ const snap = workbook.save();
4218
+ for (const sid2 of snap.sheetOrder ?? Object.keys(snap.sheets ?? {})) {
4219
+ const ws = workbook.getSheetBySheetId(sid2);
4220
+ if (ws && (ws.getName() === sheetToken || ws.getSheetId() === sheetToken)) {
4221
+ targetSheet = ws;
4222
+ break;
4223
+ }
4224
+ }
4225
+ }
4226
+ const cleanCell = cellPart.replace(/\$/g, "").toUpperCase();
4227
+ const coords = (0, import_univer_sheets2.a1ToCellCoords)(cleanCell);
4228
+ if (!coords) return;
4229
+ const sid = targetSheet.getSheetId();
4230
+ const curList = metadata.watchCells ?? [];
4231
+ if (curList.some(
4232
+ (w) => w.sheetId === sid && w.row === coords.row && w.col === coords.col
4233
+ )) {
4234
+ setWatchInputRef("");
4235
+ return;
4236
+ }
4237
+ templateService.setTemplateMetadata(unitId, {
4238
+ ...metadata,
4239
+ watchCells: [
4240
+ ...curList,
4241
+ {
4242
+ id: `watch-${(0, import_core4.generateRandomId)(5)}`,
4243
+ sheetId: sid,
4244
+ row: coords.row,
4245
+ col: coords.col,
4246
+ cellRef: (0, import_univer_sheets2.cellCoordsToA1)(coords.row, coords.col)
4247
+ }
4248
+ ]
4249
+ });
4250
+ setWatchInputRef("");
4251
+ },
4252
+ children: "+ \u6DFB\u52A0\u76D1\u89C6"
4253
+ }
4254
+ )
4255
+ ] })
4256
+ ]
4257
+ }
4258
+ ),
2896
4259
  (metadata.watchCells ?? []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2897
4260
  "div",
2898
4261
  {
@@ -3017,6 +4380,527 @@ var SheetInspectorPanel = () => {
3017
4380
  },
3018
4381
  children: auditOutput
3019
4382
  }
4383
+ ),
4384
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
4385
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4386
+ "div",
4387
+ {
4388
+ "data-testid": "yudao-whatif-scenarios-card",
4389
+ style: {
4390
+ display: "flex",
4391
+ flexDirection: "column",
4392
+ gap: 6,
4393
+ padding: "7px 8px",
4394
+ borderRadius: 6,
4395
+ background: "#F8FAFC",
4396
+ border: "1px solid #E2E8F0"
4397
+ },
4398
+ children: [
4399
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4400
+ "div",
4401
+ {
4402
+ style: {
4403
+ display: "flex",
4404
+ alignItems: "center",
4405
+ justifyContent: "space-between",
4406
+ gap: 6
4407
+ },
4408
+ children: [
4409
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4410
+ "span",
4411
+ {
4412
+ style: {
4413
+ display: "inline-flex",
4414
+ alignItems: "center",
4415
+ gap: 5,
4416
+ fontSize: 11.5,
4417
+ fontWeight: 600,
4418
+ color: "#1B1C1F"
4419
+ },
4420
+ children: [
4421
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4422
+ "svg",
4423
+ {
4424
+ width: "13",
4425
+ height: "13",
4426
+ viewBox: "0 0 16 16",
4427
+ fill: "none",
4428
+ "aria-hidden": "true",
4429
+ children: [
4430
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4431
+ "rect",
4432
+ {
4433
+ x: "1.5",
4434
+ y: "2.5",
4435
+ width: "13",
4436
+ height: "11",
4437
+ rx: "2",
4438
+ stroke: "#2C53F1",
4439
+ strokeWidth: "1.3"
4440
+ }
4441
+ ),
4442
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M1.5 6H14.5M6 6V13.5", stroke: "#2C53F1", strokeWidth: "1.2" })
4443
+ ]
4444
+ }
4445
+ ),
4446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6A21\u62DF\u5206\u6790\u4E0E\u65B9\u6848\u7BA1\u7406\u5668" })
4447
+ ]
4448
+ }
4449
+ ),
4450
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontSize: 10, color: "#64748B" }, children: [
4451
+ (0, import_univer_sheets2.getWorkbookScenarios)(workbook).length,
4452
+ " \u4E2A\u65B9\u6848"
4453
+ ] })
4454
+ ]
4455
+ }
4456
+ ),
4457
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
4458
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u65B9\u6848\u540D\u79F0" }),
4460
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4461
+ "input",
4462
+ {
4463
+ "data-testid": "yudao-scenario-name-input",
4464
+ type: "text",
4465
+ placeholder: "\u5982\uFF1A\u4E50\u89C2\u589E\u957F\u65B9\u6848",
4466
+ value: scenarioNameInput,
4467
+ onChange: (e) => setScenarioNameInput(e.target.value)
4468
+ }
4469
+ )
4470
+ ] }),
4471
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4472
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u7ED3\u679C\u76EE\u6807\u683C (\u9017\u53F7\u5206\u9694)" }),
4473
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4474
+ "input",
4475
+ {
4476
+ "data-testid": "yudao-scenario-results-input",
4477
+ type: "text",
4478
+ placeholder: "\u5982 F10, G10",
4479
+ value: scenarioResultsInput,
4480
+ onChange: (e) => setScenarioResultsInput(e.target.value)
4481
+ }
4482
+ )
4483
+ ] })
4484
+ ] }),
4485
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4486
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u53EF\u53D8\u5355\u5143\u683C\u8D4B\u503C (\u683C\u5F0F: B2=120, B3=0.18)" }),
4487
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4488
+ "input",
4489
+ {
4490
+ "data-testid": "yudao-scenario-cells-input",
4491
+ type: "text",
4492
+ placeholder: "\u5982 B2=120, B3=0.18",
4493
+ value: scenarioCellsInput,
4494
+ onChange: (e) => setScenarioCellsInput(e.target.value)
4495
+ }
4496
+ )
4497
+ ] }),
4498
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4499
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u65B9\u6848\u5907\u6CE8 (\u53EF\u9009)" }),
4500
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4501
+ "input",
4502
+ {
4503
+ "data-testid": "yudao-scenario-comment-input",
4504
+ type: "text",
4505
+ placeholder: "\u8BB0\u5F55\u5047\u8BBE\u524D\u63D0\u6761\u4EF6",
4506
+ value: scenarioCommentInput,
4507
+ onChange: (e) => setScenarioCommentInput(e.target.value)
4508
+ }
4509
+ )
4510
+ ] }),
4511
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1.2fr", gap: 4 }, children: [
4512
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4513
+ "button",
4514
+ {
4515
+ "data-testid": "yudao-scenario-save-btn",
4516
+ type: "button",
4517
+ className: "yudao-sheet-btn is-soft-primary",
4518
+ onClick: () => {
4519
+ const changingCells = scenarioCellsInput.split(/[,;\n]+/).map((seg) => seg.trim()).filter(Boolean).map((pair) => {
4520
+ const eqIdx = pair.indexOf("=");
4521
+ if (eqIdx <= 0) return null;
4522
+ const cellA1 = pair.slice(0, eqIdx).trim();
4523
+ const rawVal = pair.slice(eqIdx + 1).trim();
4524
+ if (!cellA1) return null;
4525
+ if (/^true$/i.test(rawVal)) return { cellA1, value: true };
4526
+ if (/^false$/i.test(rawVal)) return { cellA1, value: false };
4527
+ const asNum = Number(rawVal);
4528
+ return {
4529
+ cellA1,
4530
+ value: rawVal !== "" && Number.isFinite(asNum) ? asNum : rawVal
4531
+ };
4532
+ }).filter((item) => item !== null);
4533
+ if (changingCells.length === 0) {
4534
+ setWhatIfStatusMsg("\u8BF7\u586B\u5199\u81F3\u5C11\u4E00\u9879\u53EF\u53D8\u5355\u5143\u683C\uFF08\u4F8B\u5982 B2=120\uFF09");
4535
+ return;
4536
+ }
4537
+ const resultCells = scenarioResultsInput.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
4538
+ const ok = commandService.syncExecuteCommand(import_univer_sheets2.SaveSheetScenarioCommand.id, {
4539
+ unitId,
4540
+ scenario: {
4541
+ name: scenarioNameInput.trim() || "\u672A\u547D\u540D\u65B9\u6848",
4542
+ comment: scenarioCommentInput.trim() || void 0,
4543
+ sheetId: sheet.getSheetId(),
4544
+ changingCells,
4545
+ resultCells: resultCells.length > 0 ? resultCells : void 0
4546
+ }
4547
+ });
4548
+ if (ok) {
4549
+ setWhatIfStatusMsg(
4550
+ `\u5DF2\u4FDD\u5B58\u65B9\u6848\u300C${scenarioNameInput.trim() || "\u672A\u547D\u540D\u65B9\u6848"}\u300D\uFF08${changingCells.length} \u9879\u53EF\u53D8\u683C\uFF09`
4551
+ );
4552
+ }
4553
+ },
4554
+ children: "\u4FDD\u5B58\u65B9\u6848"
4555
+ }
4556
+ ),
4557
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4558
+ "button",
4559
+ {
4560
+ "data-testid": "yudao-scenario-summary-btn",
4561
+ type: "button",
4562
+ className: "yudao-sheet-btn",
4563
+ onClick: () => {
4564
+ const resultCellsA1 = scenarioResultsInput.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
4565
+ const ok = commandService.syncExecuteCommand(
4566
+ import_univer_sheets2.GenerateScenarioSummaryCommand.id,
4567
+ {
4568
+ unitId,
4569
+ sheetId: sheet.getSheetId(),
4570
+ resultCellsA1: resultCellsA1.length > 0 ? resultCellsA1 : void 0
4571
+ }
4572
+ );
4573
+ setWhatIfStatusMsg(
4574
+ ok ? "\u5DF2\u751F\u6210/\u66F4\u65B0\u300C\u65B9\u6848\u6458\u8981\u300D\u5BF9\u6BD4\u5DE5\u4F5C\u8868" : "\u751F\u6210\u65B9\u6848\u6458\u8981\u5931\u8D25"
4575
+ );
4576
+ },
4577
+ children: "\u4E00\u952E\u751F\u6210\u65B9\u6848\u6458\u8981\u8868"
4578
+ }
4579
+ )
4580
+ ] }),
4581
+ (0, import_univer_sheets2.getWorkbookScenarios)(workbook).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4582
+ "div",
4583
+ {
4584
+ "data-testid": "yudao-scenario-list",
4585
+ style: { display: "flex", flexDirection: "column", gap: 3 },
4586
+ children: (0, import_univer_sheets2.getWorkbookScenarios)(workbook).map((sc) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4587
+ "div",
4588
+ {
4589
+ style: {
4590
+ display: "flex",
4591
+ alignItems: "center",
4592
+ justifyContent: "space-between",
4593
+ gap: 4,
4594
+ padding: "4px 6px",
4595
+ borderRadius: 5,
4596
+ background: "#FFFFFF",
4597
+ border: "1px solid #E2E8F0",
4598
+ fontSize: 10.5
4599
+ },
4600
+ children: [
4601
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { minWidth: 0, flex: 1 }, children: [
4602
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontWeight: 600, color: "#1E293B" }, children: sc.name }),
4603
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { color: "#64748B", fontSize: 10 }, children: sc.changingCells.map((c) => `${c.cellA1}=${String(c.value)}`).join(", ") })
4604
+ ] }),
4605
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 3 }, children: [
4606
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4607
+ "button",
4608
+ {
4609
+ "data-testid": `yudao-scenario-apply-${sc.id}`,
4610
+ type: "button",
4611
+ className: "yudao-sheet-btn is-soft-primary",
4612
+ style: { padding: "1px 6px", fontSize: 10 },
4613
+ onClick: () => {
4614
+ const ok = commandService.syncExecuteCommand(
4615
+ import_univer_sheets2.ApplySheetScenarioCommand.id,
4616
+ {
4617
+ unitId,
4618
+ scenarioId: sc.id
4619
+ }
4620
+ );
4621
+ if (ok) {
4622
+ setWhatIfStatusMsg(`\u5DF2\u5207\u6362\u5E94\u7528\u65B9\u6848\u300C${sc.name}\u300D`);
4623
+ }
4624
+ },
4625
+ children: "\u5207\u6362"
4626
+ }
4627
+ ),
4628
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4629
+ "button",
4630
+ {
4631
+ "data-testid": `yudao-scenario-delete-${sc.id}`,
4632
+ type: "button",
4633
+ className: "yudao-sheet-btn",
4634
+ style: { padding: "1px 5px", fontSize: 10 },
4635
+ onClick: () => {
4636
+ commandService.syncExecuteCommand(import_univer_sheets2.DeleteSheetScenarioCommand.id, {
4637
+ unitId,
4638
+ scenarioId: sc.id
4639
+ });
4640
+ setWhatIfStatusMsg(`\u5DF2\u5220\u9664\u65B9\u6848\u300C${sc.name}\u300D`);
4641
+ },
4642
+ children: "\u5220\u9664"
4643
+ }
4644
+ )
4645
+ ] })
4646
+ ]
4647
+ },
4648
+ sc.id
4649
+ ))
4650
+ }
4651
+ ),
4652
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4653
+ "div",
4654
+ {
4655
+ style: {
4656
+ borderTop: "1px dashed #CBD5E1",
4657
+ paddingTop: 5,
4658
+ display: "flex",
4659
+ flexDirection: "column",
4660
+ gap: 5
4661
+ },
4662
+ children: [
4663
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4664
+ "div",
4665
+ {
4666
+ className: "yudao-sheet-segmented",
4667
+ style: { gridTemplateColumns: "1fr 1fr" },
4668
+ children: [
4669
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4670
+ "button",
4671
+ {
4672
+ "data-testid": "yudao-datatable-mode-1var",
4673
+ type: "button",
4674
+ className: `yudao-sheet-segmented-item ${whatIfMode === "1var" ? "is-active" : ""}`,
4675
+ style: { padding: "3px 4px", fontSize: 10.5 },
4676
+ onClick: () => setWhatIfMode("1var"),
4677
+ children: "\u5355\u53D8\u91CF\u6A21\u62DF\u8FD0\u7B97\u8868"
4678
+ }
4679
+ ),
4680
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4681
+ "button",
4682
+ {
4683
+ "data-testid": "yudao-datatable-mode-2var",
4684
+ type: "button",
4685
+ className: `yudao-sheet-segmented-item ${whatIfMode === "2var" ? "is-active" : ""}`,
4686
+ style: { padding: "3px 4px", fontSize: 10.5 },
4687
+ onClick: () => setWhatIfMode("2var"),
4688
+ children: "\u53CC\u53D8\u91CF\u4EA4\u53C9\u6A21\u62DF\u8868"
4689
+ }
4690
+ )
4691
+ ]
4692
+ }
4693
+ ),
4694
+ whatIfMode === "1var" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
4695
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
4696
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4697
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8F93\u5165\u53D8\u91CF\u683C" }),
4698
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4699
+ "input",
4700
+ {
4701
+ "data-testid": "yudao-dt-input-cell",
4702
+ type: "text",
4703
+ value: dtInputCell,
4704
+ onChange: (e) => setDtInputCell(e.target.value)
4705
+ }
4706
+ )
4707
+ ] }),
4708
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4709
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5019\u9009\u8F93\u5165\u5E8F\u5217 (\u9017\u53F7\u5206\u9694)" }),
4710
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4711
+ "input",
4712
+ {
4713
+ "data-testid": "yudao-dt-input-values",
4714
+ type: "text",
4715
+ value: dtInputValues,
4716
+ onChange: (e) => setDtInputValues(e.target.value)
4717
+ }
4718
+ )
4719
+ ] })
4720
+ ] }),
4721
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
4722
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4723
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u76EE\u6807\u516C\u5F0F\u683C (\u53EF\u591A\u4E2A)" }),
4724
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4725
+ "input",
4726
+ {
4727
+ "data-testid": "yudao-dt-formula-cells",
4728
+ type: "text",
4729
+ value: dtFormulaCells,
4730
+ onChange: (e) => setDtFormulaCells(e.target.value)
4731
+ }
4732
+ )
4733
+ ] }),
4734
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4735
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8F93\u51FA\u5DE6\u4E0A\u89D2 (\u53EF\u9009)" }),
4736
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4737
+ "input",
4738
+ {
4739
+ "data-testid": "yudao-dt-output-cell",
4740
+ type: "text",
4741
+ placeholder: "\u5982 H2",
4742
+ value: dtOutputTopLeft,
4743
+ onChange: (e) => setDtOutputTopLeft(e.target.value)
4744
+ }
4745
+ )
4746
+ ] })
4747
+ ] })
4748
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
4749
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
4750
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4751
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u884C\u53D8\u91CF\u683C" }),
4752
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4753
+ "input",
4754
+ {
4755
+ "data-testid": "yudao-dt-row-input-cell",
4756
+ type: "text",
4757
+ value: dtInputCell,
4758
+ onChange: (e) => setDtInputCell(e.target.value)
4759
+ }
4760
+ )
4761
+ ] }),
4762
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4763
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u884C\u5019\u9009\u503C (\u9017\u53F7\u5206\u9694)" }),
4764
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4765
+ "input",
4766
+ {
4767
+ "data-testid": "yudao-dt-row-values",
4768
+ type: "text",
4769
+ value: dtInputValues,
4770
+ onChange: (e) => setDtInputValues(e.target.value)
4771
+ }
4772
+ )
4773
+ ] })
4774
+ ] }),
4775
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
4776
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4777
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5217\u53D8\u91CF\u683C" }),
4778
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4779
+ "input",
4780
+ {
4781
+ "data-testid": "yudao-dt-col-input-cell",
4782
+ type: "text",
4783
+ value: dtColInputCell,
4784
+ onChange: (e) => setDtColInputCell(e.target.value)
4785
+ }
4786
+ )
4787
+ ] }),
4788
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4789
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5217\u5019\u9009\u503C (\u9017\u53F7\u5206\u9694)" }),
4790
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4791
+ "input",
4792
+ {
4793
+ "data-testid": "yudao-dt-col-values",
4794
+ type: "text",
4795
+ value: dtColValues,
4796
+ onChange: (e) => setDtColValues(e.target.value)
4797
+ }
4798
+ )
4799
+ ] })
4800
+ ] }),
4801
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
4802
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4803
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u76EE\u6807\u516C\u5F0F\u683C" }),
4804
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4805
+ "input",
4806
+ {
4807
+ "data-testid": "yudao-dt-target-formula",
4808
+ type: "text",
4809
+ value: dtFormulaCells,
4810
+ onChange: (e) => setDtFormulaCells(e.target.value)
4811
+ }
4812
+ )
4813
+ ] }),
4814
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
4815
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8F93\u51FA\u5DE6\u4E0A\u89D2 (\u53EF\u9009)" }),
4816
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4817
+ "input",
4818
+ {
4819
+ "data-testid": "yudao-dt-output-cell",
4820
+ type: "text",
4821
+ placeholder: "\u5982 H2",
4822
+ value: dtOutputTopLeft,
4823
+ onChange: (e) => setDtOutputTopLeft(e.target.value)
4824
+ }
4825
+ )
4826
+ ] })
4827
+ ] })
4828
+ ] }),
4829
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4830
+ "button",
4831
+ {
4832
+ "data-testid": "yudao-datatable-run-btn",
4833
+ type: "button",
4834
+ className: "yudao-sheet-btn is-soft-primary",
4835
+ onClick: () => {
4836
+ const parseCandidateValues = (raw) => raw.split(/[,;]+/).map((s) => s.trim()).filter(Boolean).map((tok) => {
4837
+ const n = Number(tok);
4838
+ return Number.isFinite(n) ? n : tok;
4839
+ });
4840
+ if (whatIfMode === "1var") {
4841
+ const inputVals = parseCandidateValues(dtInputValues);
4842
+ const fCells = dtFormulaCells.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
4843
+ commandService.syncExecuteCommand(import_univer_sheets2.RunSheetDataTableCommand.id, {
4844
+ unitId,
4845
+ mode: "1var",
4846
+ sheetId: sheet.getSheetId(),
4847
+ inputCellA1: dtInputCell.trim(),
4848
+ inputValues: inputVals,
4849
+ formulaCellsA1: fCells,
4850
+ outputTopLeftA1: dtOutputTopLeft.trim() || void 0,
4851
+ onResult: (res) => {
4852
+ setWhatIfStatusMsg(
4853
+ `\u5355\u53D8\u91CF\u6A21\u62DF\u5B8C\u6210 (${res.matrix.length}\xD7${res.formulaCellsA1.length})${res.outputRangeA1 ? ` -> \u5DF2\u5199\u5165 ${res.outputRangeA1}` : ""}: ${res.matrix.map((r) => `[${r.join(", ")}]`).join(" ")}`
4854
+ );
4855
+ }
4856
+ });
4857
+ } else {
4858
+ const rVals = parseCandidateValues(dtInputValues);
4859
+ const cVals = parseCandidateValues(dtColValues);
4860
+ const targetF = dtFormulaCells.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean)[0] ?? "F10";
4861
+ commandService.syncExecuteCommand(import_univer_sheets2.RunSheetDataTableCommand.id, {
4862
+ unitId,
4863
+ mode: "2var",
4864
+ sheetId: sheet.getSheetId(),
4865
+ rowInputCellA1: dtInputCell.trim(),
4866
+ colInputCellA1: dtColInputCell.trim(),
4867
+ rowValues: rVals,
4868
+ colValues: cVals,
4869
+ targetFormulaA1: targetF,
4870
+ outputTopLeftA1: dtOutputTopLeft.trim() || void 0,
4871
+ onResult: (res) => {
4872
+ setWhatIfStatusMsg(
4873
+ `\u53CC\u53D8\u91CF\u6A21\u62DF\u5B8C\u6210 (${res.colValues.length}\xD7${res.rowValues.length})${res.outputRangeA1 ? ` -> \u5DF2\u5199\u5165 ${res.outputRangeA1}` : ""}: ${res.matrix.map((r) => `[${r.join(", ")}]`).join(" ")}`
4874
+ );
4875
+ }
4876
+ });
4877
+ }
4878
+ },
4879
+ children: "\u8BA1\u7B97\u5E76\u8F93\u51FA\u6A21\u62DF\u8FD0\u7B97\u8868"
4880
+ }
4881
+ )
4882
+ ]
4883
+ }
4884
+ ),
4885
+ whatIfStatusMsg && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4886
+ "div",
4887
+ {
4888
+ "data-testid": "yudao-whatif-status",
4889
+ style: {
4890
+ fontSize: 10.5,
4891
+ padding: "4px 6px",
4892
+ borderRadius: 5,
4893
+ background: "#EEF2FF",
4894
+ border: "1px solid #C7D2FE",
4895
+ color: "#1E1B4B",
4896
+ lineHeight: 1.35,
4897
+ wordBreak: "break-all"
4898
+ },
4899
+ children: whatIfStatusMsg
4900
+ }
4901
+ )
4902
+ ]
4903
+ }
3020
4904
  )
3021
4905
  ] }),
3022
4906
  features.datasetBinding && activeSubTab === "fill" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "yudao-sheet-section", children: [
@@ -3675,10 +5559,274 @@ var SheetInspectorPanel = () => {
3675
5559
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3676
5560
  "button",
3677
5561
  {
3678
- type: "button",
3679
- className: "yudao-sheet-btn is-soft-primary",
3680
- onClick: () => commandService.syncExecuteCommand(OpenSheetModalOperation.id, { tab: "print" }),
3681
- children: "\u6253\u5F00\u5957\u6253\u4E0E\u5206\u9875\u6253\u5370\u9884\u89C8"
5562
+ type: "button",
5563
+ className: "yudao-sheet-btn is-soft-primary",
5564
+ onClick: () => commandService.syncExecuteCommand(OpenSheetModalOperation.id, { tab: "print" }),
5565
+ children: "\u6253\u5F00\u5957\u6253\u4E0E\u5206\u9875\u6253\u5370\u9884\u89C8"
5566
+ }
5567
+ )
5568
+ ] }),
5569
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "yudao-sheet-section", "data-testid": "yudao-macro-recorder-card", children: [
5570
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "yudao-sheet-section-title", children: [
5571
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { display: "inline-flex", alignItems: "center", gap: 5 }, children: [
5572
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "13", height: "13", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
5573
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5574
+ "circle",
5575
+ {
5576
+ cx: "8",
5577
+ cy: "8",
5578
+ r: "6",
5579
+ stroke: macroRecState.recording ? "#DC2626" : "#2C53F1",
5580
+ strokeWidth: "1.4"
5581
+ }
5582
+ ),
5583
+ macroRecState.recording ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "5.5", y: "5.5", width: "5", height: "5", rx: "1", fill: "#DC2626" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polygon", { points: "6.5,5 11.5,8 6.5,11", fill: "#2C53F1" })
5584
+ ] }),
5585
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u64CD\u4F5C\u5B8F\u5F55\u5236\u4E0E\u56DE\u653E" })
5586
+ ] }),
5587
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5588
+ "span",
5589
+ {
5590
+ "data-testid": "yudao-macro-badge",
5591
+ style: {
5592
+ fontSize: 10,
5593
+ fontWeight: 500,
5594
+ padding: "1px 6px",
5595
+ borderRadius: 999,
5596
+ background: macroRecState.recording ? "#FEF2F2" : "#F3F5FF",
5597
+ color: macroRecState.recording ? "#DC2626" : "#2C53F1"
5598
+ },
5599
+ children: macroRecState.recording ? `\u5F55\u5236\u4E2D (${macroRecState.stepCount} \u6B65)` : `${(macroService ? macroService.getMacros(unitId) : (0, import_univer_sheets2.getWorkbookMacros)(workbook)).length} \u4E2A\u5B8F`
5600
+ }
5601
+ )
5602
+ ] }),
5603
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 4 }, children: [
5604
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5605
+ "input",
5606
+ {
5607
+ "data-testid": "yudao-macro-name-input",
5608
+ type: "text",
5609
+ style: {
5610
+ flex: 1,
5611
+ minWidth: 0,
5612
+ fontSize: 11.5,
5613
+ padding: "4px 6px",
5614
+ borderRadius: 6,
5615
+ border: "1px solid #E3E5EA",
5616
+ background: "#FFFFFF",
5617
+ color: "#1B1C1F",
5618
+ outline: "none"
5619
+ },
5620
+ placeholder: "\u5B8F\u540D\u79F0\uFF08\u5982\uFF1A\u6708\u5EA6\u62A5\u8868\u6E05\u6D17\uFF09",
5621
+ value: macroNameInput,
5622
+ onChange: (e) => setMacroNameInput(e.target.value)
5623
+ }
5624
+ ),
5625
+ !macroRecState.recording ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5626
+ "button",
5627
+ {
5628
+ "data-testid": "yudao-macro-start-btn",
5629
+ type: "button",
5630
+ className: "yudao-sheet-btn is-soft-primary",
5631
+ onClick: () => {
5632
+ commandService.syncExecuteCommand(import_univer_sheets2.StartSheetMacroRecordCommand.id, {
5633
+ unitId,
5634
+ name: macroNameInput.trim() || void 0
5635
+ });
5636
+ setMacroStatusMsg("\u5DF2\u5F00\u59CB\u5F55\u5236\u5DE5\u4F5C\u8868\u64CD\u4F5C\uFF08\u4EC5\u8BB0\u5F55\u6570\u636E/\u6837\u5F0F/\u5206\u6790\u53D8\u66F4\uFF0C\u5FFD\u7565\u9009\u533A\u6EDA\u52A8\uFF09");
5637
+ },
5638
+ children: "\u5F00\u59CB\u5F55\u5236"
5639
+ }
5640
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5641
+ "button",
5642
+ {
5643
+ "data-testid": "yudao-macro-stop-btn",
5644
+ type: "button",
5645
+ className: "yudao-sheet-btn",
5646
+ style: { borderColor: "#FCA5A5", color: "#B91C1C", background: "#FEF2F2" },
5647
+ onClick: () => {
5648
+ commandService.syncExecuteCommand(import_univer_sheets2.StopSheetMacroRecordCommand.id, {
5649
+ unitId,
5650
+ name: macroNameInput.trim() || void 0,
5651
+ onSaved: (saved) => {
5652
+ setMacroStatusMsg(`\u5DF2\u4FDD\u5B58\u64CD\u4F5C\u5B8F\u300C${saved.name}\u300D\uFF08\u5171 ${saved.steps.length} \u6B65\uFF09`);
5653
+ setMacroNameInput("");
5654
+ }
5655
+ });
5656
+ },
5657
+ children: "\u505C\u6B62\u4FDD\u5B58"
5658
+ }
5659
+ )
5660
+ ] }),
5661
+ (macroService ? macroService.getMacros(unitId) : (0, import_univer_sheets2.getWorkbookMacros)(workbook)).map((m) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
5662
+ "div",
5663
+ {
5664
+ "data-testid": `yudao-macro-item-${m.id}`,
5665
+ style: {
5666
+ display: "flex",
5667
+ alignItems: "center",
5668
+ justifyContent: "space-between",
5669
+ gap: 6,
5670
+ padding: "4px 6px",
5671
+ background: "#FFFFFF",
5672
+ border: "1px solid #E3E5EA",
5673
+ borderRadius: 6,
5674
+ fontSize: 11
5675
+ },
5676
+ children: [
5677
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { minWidth: 0, flex: 1 }, children: [
5678
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontWeight: 600, color: "#1B1C1F" }, children: m.name }),
5679
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { color: "#7D8698", fontSize: 10 }, children: [
5680
+ m.steps.length,
5681
+ " \u6B65\u81EA\u52A8\u5316\u6307\u4EE4"
5682
+ ] })
5683
+ ] }),
5684
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 3 }, children: [
5685
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5686
+ "button",
5687
+ {
5688
+ "data-testid": `yudao-macro-replay-${m.id}`,
5689
+ type: "button",
5690
+ className: "yudao-sheet-btn is-soft-primary",
5691
+ style: { padding: "2px 6px", fontSize: 10.5 },
5692
+ onClick: () => {
5693
+ const ok = commandService.syncExecuteCommand(import_univer_sheets2.ReplaySheetMacroCommand.id, {
5694
+ unitId,
5695
+ macroId: m.id,
5696
+ sheetId: sheet.getSheetId()
5697
+ });
5698
+ setMacroStatusMsg(
5699
+ ok ? `\u5DF2\u5728\u5DE5\u4F5C\u8868\u300C${sheet.getName()}\u300D\u4E00\u952E\u56DE\u653E\u5B8F\u300C${m.name}\u300D` : `\u56DE\u653E\u5B8F\u300C${m.name}\u300D\u5931\u8D25`
5700
+ );
5701
+ },
5702
+ children: "\u4E00\u952E\u56DE\u653E"
5703
+ }
5704
+ ),
5705
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5706
+ "button",
5707
+ {
5708
+ "data-testid": `yudao-macro-view-script-${m.id}`,
5709
+ type: "button",
5710
+ className: "yudao-sheet-btn",
5711
+ style: { padding: "2px 6px", fontSize: 10.5 },
5712
+ onClick: () => setPreviewMacro(previewMacro?.id === m.id ? null : m),
5713
+ children: "\u67E5\u770B\u811A\u672C"
5714
+ }
5715
+ ),
5716
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5717
+ "button",
5718
+ {
5719
+ "data-testid": `yudao-macro-delete-${m.id}`,
5720
+ type: "button",
5721
+ className: "yudao-sheet-btn",
5722
+ style: { padding: "2px 5px", fontSize: 10.5 },
5723
+ onClick: () => {
5724
+ commandService.syncExecuteCommand(import_univer_sheets2.DeleteSheetMacroCommand.id, {
5725
+ unitId,
5726
+ macroId: m.id
5727
+ });
5728
+ if (previewMacro?.id === m.id) setPreviewMacro(null);
5729
+ setMacroStatusMsg(`\u5DF2\u5220\u9664\u5B8F\u300C${m.name}\u300D`);
5730
+ },
5731
+ children: "\u5220\u9664"
5732
+ }
5733
+ )
5734
+ ] })
5735
+ ]
5736
+ },
5737
+ m.id
5738
+ )),
5739
+ previewMacro && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
5740
+ "div",
5741
+ {
5742
+ "data-testid": "yudao-macro-script-modal",
5743
+ style: {
5744
+ display: "flex",
5745
+ flexDirection: "column",
5746
+ gap: 5,
5747
+ padding: "6px 8px",
5748
+ borderRadius: 6,
5749
+ background: "#0F172A",
5750
+ color: "#E2E8F0",
5751
+ fontSize: 10.5
5752
+ },
5753
+ children: [
5754
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
5755
+ "div",
5756
+ {
5757
+ style: {
5758
+ display: "flex",
5759
+ alignItems: "center",
5760
+ justifyContent: "space-between",
5761
+ gap: 6
5762
+ },
5763
+ children: [
5764
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontWeight: 600, color: "#F8FAFC" }, children: [
5765
+ "Facade \u811A\u672C\u9884\u89C8\uFF1A",
5766
+ previewMacro.name
5767
+ ] }),
5768
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 4 }, children: [
5769
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5770
+ "button",
5771
+ {
5772
+ "data-testid": "yudao-macro-script-copy-btn",
5773
+ type: "button",
5774
+ className: "yudao-sheet-btn",
5775
+ style: { padding: "1px 6px", fontSize: 10 },
5776
+ onClick: () => {
5777
+ void globalThis.navigator?.clipboard?.writeText?.(
5778
+ previewMacro.generatedScript
5779
+ );
5780
+ setMacroStatusMsg(`\u5DF2\u590D\u5236\u300C${previewMacro.name}\u300D\u81EA\u52A8\u5316\u811A\u672C`);
5781
+ },
5782
+ children: "\u590D\u5236\u4EE3\u7801"
5783
+ }
5784
+ ),
5785
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5786
+ "button",
5787
+ {
5788
+ "data-testid": "yudao-macro-script-close-btn",
5789
+ type: "button",
5790
+ className: "yudao-sheet-btn",
5791
+ style: { padding: "1px 6px", fontSize: 10 },
5792
+ onClick: () => setPreviewMacro(null),
5793
+ children: "\u5173\u95ED"
5794
+ }
5795
+ )
5796
+ ] })
5797
+ ]
5798
+ }
5799
+ ),
5800
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5801
+ "pre",
5802
+ {
5803
+ "data-testid": "yudao-macro-script-code",
5804
+ style: {
5805
+ margin: 0,
5806
+ padding: "6px",
5807
+ borderRadius: 4,
5808
+ background: "#1E293B",
5809
+ color: "#93C5FD",
5810
+ fontFamily: "monospace",
5811
+ fontSize: 10,
5812
+ lineHeight: 1.45,
5813
+ maxHeight: 160,
5814
+ overflow: "auto",
5815
+ whiteSpace: "pre-wrap",
5816
+ wordBreak: "break-all"
5817
+ },
5818
+ children: previewMacro.generatedScript
5819
+ }
5820
+ )
5821
+ ]
5822
+ }
5823
+ ),
5824
+ macroStatusMsg && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5825
+ "div",
5826
+ {
5827
+ "data-testid": "yudao-macro-status",
5828
+ style: { fontSize: 10.5, color: "#4E5565", lineHeight: 1.35 },
5829
+ children: macroStatusMsg
3682
5830
  }
3683
5831
  )
3684
5832
  ] }),
@@ -5925,7 +8073,7 @@ var import_sheets3 = require("@univerjs/sheets");
5925
8073
  var import_sheets_ui4 = require("@univerjs/sheets-ui");
5926
8074
  var import_ui6 = require("@univerjs/ui");
5927
8075
  var import_univer_sheets5 = require("@yudaocode/univer-sheets");
5928
- var import_react5 = require("react");
8076
+ var import_react5 = __toESM(require("react"));
5929
8077
  var import_jsx_runtime5 = require("react/jsx-runtime");
5930
8078
  var QrCellImage = ({ text, size, errorLevel = "M", color, bgColor, logoDataUrl, logoSizeRatio }) => {
5931
8079
  const src = (0, import_react5.useMemo)(
@@ -6020,7 +8168,9 @@ var BuiltinSvgChart = ({ chart, data, onSelectItem }) => {
6020
8168
  index
6021
8169
  });
6022
8170
  };
6023
- const hasWave2Config = Boolean(chart.trendline) && chart.trendline !== "none" || Boolean(chart.errorBars && chart.errorBars.length > 0) || chart.yAxisScale === "log" || Boolean(chart.threeD) || chart.radarShape === "circle" || chart.radarFill !== void 0 || Boolean(chart.smooth) || cType === "lineSmooth" || cType === "lineStackedSmooth" || cType === "linePercentStackedSmooth" || chart.showLegend !== void 0 || Boolean(chart.legendPosition) || Boolean(chart.seriesOrientation) || Boolean(chart.series && chart.series.length > 0);
8171
+ const hasWave2Config = Boolean(chart.trendline) && chart.trendline !== "none" || Boolean(
8172
+ chart.errorBars && (Array.isArray(chart.errorBars) ? chart.errorBars.length > 0 : Boolean(chart.errorBars.type))
8173
+ ) || Boolean(chart.secondarySeriesIndices && chart.secondarySeriesIndices.length > 0) || Boolean(chart.comboLineSeriesIndices && chart.comboLineSeriesIndices.length > 0) || Boolean(chart.showDataLabels) || cType === "combo" || cType === "bubble" || cType === "scatter" || cType === "radar" || chart.yAxisScale === "log" || Boolean(chart.threeD) || chart.radarShape === "circle" || chart.radarFill !== void 0 || Boolean(chart.smooth) || cType === "lineSmooth" || cType === "lineStackedSmooth" || cType === "linePercentStackedSmooth" || chart.showLegend !== void 0 || Boolean(chart.legendPosition) || Boolean(chart.seriesOrientation) || Boolean(chart.series && chart.series.length > 0);
6024
8174
  if (!LEGACY_INLINE_CHART_TYPES.has(cType) || hasWave2Config) {
6025
8175
  const svgHtml = (0, import_univer_sheets5.renderSheetChartSvg)(chart, data).replace(
6026
8176
  "<svg ",
@@ -6166,40 +8316,6 @@ var BuiltinSvgChart = ({ chart, data, onSelectItem }) => {
6166
8316
  ] }, i);
6167
8317
  }) });
6168
8318
  }
6169
- if (cType === "radar") {
6170
- const count2 = Math.max(3, vals.length);
6171
- const cx = 130;
6172
- const cy = 70;
6173
- const rMax = 46;
6174
- const dataPoly = Array.from({ length: count2 }, (_, i) => {
6175
- const ang = -Math.PI / 2 + i / count2 * Math.PI * 2;
6176
- const rad = Math.max(0, vals[i] ?? 0) / maxVal * rMax;
6177
- return `${(cx + rad * Math.cos(ang)).toFixed(1)},${(cy + rad * Math.sin(ang)).toFixed(1)}`;
6178
- }).join(" ");
6179
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 260 136", style: { width: "100%", height: "100%", display: "block" }, children: [
6180
- [0.35, 0.7, 1].map((ratio, rIdx) => {
6181
- const ringPts = Array.from({ length: count2 }, (_, i) => {
6182
- const ang = -Math.PI / 2 + i / count2 * Math.PI * 2;
6183
- return `${(cx + rMax * ratio * Math.cos(ang)).toFixed(1)},${(cy + rMax * ratio * Math.sin(ang)).toFixed(1)}`;
6184
- }).join(" ");
6185
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("polygon", { points: ringPts, fill: "none", stroke: "#E3E5EA", strokeWidth: 0.8 }, rIdx);
6186
- }),
6187
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("polygon", { points: dataPoly, fill: "rgba(44, 83, 241, 0.14)", stroke: primaryColor, strokeWidth: 1.8 }),
6188
- Array.from({ length: count2 }, (_, i) => {
6189
- const ang = -Math.PI / 2 + i / count2 * Math.PI * 2;
6190
- const v = vals[i] ?? 0;
6191
- const rad = Math.max(0, v) / maxVal * rMax;
6192
- const px = cx + rad * Math.cos(ang);
6193
- const py = cy + rad * Math.sin(ang);
6194
- const lx = cx + (rMax + 14) * Math.cos(ang);
6195
- const ly = cy + (rMax + 11) * Math.sin(ang);
6196
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("g", { style: { cursor: "pointer" }, onClick: () => fireSelect(i, v), children: [
6197
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: px, cy: py, r: 2.8, fill: primaryColor }),
6198
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("text", { x: lx, y: ly, textAnchor: "middle", fontSize: 8.5, fill: "#4E5565", children: (cats[i] ?? `\u7EF4${i + 1}`).slice(0, 5) })
6199
- ] }, i);
6200
- })
6201
- ] });
6202
- }
6203
8319
  if (cType === "horizontalBar") {
6204
8320
  const count2 = Math.max(1, vals.length);
6205
8321
  const slotH = Math.min(24, 108 / count2);
@@ -7157,19 +9273,201 @@ var FloatingTimelineCard = ({ timeline, onMove, onRemove, onUpdateGranularity, o
7157
9273
  }
7158
9274
  );
7159
9275
  };
7160
- var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
9276
+ function getShapeAnchorMidpoints(sh) {
9277
+ const cx = sh.left + sh.width / 2;
9278
+ const cy = sh.top + sh.height / 2;
9279
+ return [
9280
+ { x: cx, y: sh.top },
9281
+ { x: sh.left + sh.width, y: cy },
9282
+ { x: cx, y: sh.top + sh.height },
9283
+ { x: sh.left, y: cy }
9284
+ ];
9285
+ }
9286
+ function findNearestAnchorMidpoint(px, py, candidates, excludeId, threshold = 22) {
9287
+ let best = null;
9288
+ for (const cand of candidates) {
9289
+ if (cand.id === excludeId || cand.shapeType === "line" || cand.shapeType === "connector") {
9290
+ continue;
9291
+ }
9292
+ for (const pt of getShapeAnchorMidpoints(cand)) {
9293
+ const d = Math.hypot(pt.x - px, pt.y - py);
9294
+ if (d <= threshold && (!best || d < best.dist)) {
9295
+ best = { shapeId: cand.id, x: pt.x, y: pt.y, dist: d };
9296
+ }
9297
+ }
9298
+ }
9299
+ return best ? { shapeId: best.shapeId, x: best.x, y: best.y } : null;
9300
+ }
9301
+ var FloatingShapeCard = ({
9302
+ shape,
9303
+ rawShape,
9304
+ allShapes,
9305
+ scrollX,
9306
+ scrollY,
9307
+ selected,
9308
+ displayText,
9309
+ onSelect,
9310
+ onUpdate,
9311
+ onRemove
9312
+ }) => {
7161
9313
  const fill = shape.fillColor || "#F3F5FF";
7162
9314
  const stroke = shape.strokeColor || "#2C53F1";
7163
9315
  const textColor = shape.textColor || "#1B1C1F";
9316
+ const isConnector = shape.shapeType === "line" || shape.shapeType === "connector";
9317
+ const resolvedBox = (0, import_react5.useMemo)(() => {
9318
+ if (!isConnector || !rawShape.startShapeId && !rawShape.endShapeId) {
9319
+ return { left: shape.left, top: shape.top, width: shape.width, height: shape.height };
9320
+ }
9321
+ let x1 = rawShape.left;
9322
+ let y1 = rawShape.top;
9323
+ let x2 = rawShape.left + rawShape.width;
9324
+ let y2 = rawShape.top + rawShape.height;
9325
+ if (rawShape.startShapeId) {
9326
+ const startTarget = allShapes.find((s) => s.id === rawShape.startShapeId);
9327
+ if (startTarget) {
9328
+ const mids = getShapeAnchorMidpoints(startTarget);
9329
+ mids.sort((a, b) => Math.hypot(a.x - x2, a.y - y2) - Math.hypot(b.x - x2, b.y - y2));
9330
+ x1 = mids[0].x;
9331
+ y1 = mids[0].y;
9332
+ }
9333
+ }
9334
+ if (rawShape.endShapeId) {
9335
+ const endTarget = allShapes.find((s) => s.id === rawShape.endShapeId);
9336
+ if (endTarget) {
9337
+ const mids = getShapeAnchorMidpoints(endTarget);
9338
+ mids.sort((a, b) => Math.hypot(a.x - x1, a.y - y1) - Math.hypot(b.x - x1, b.y - y1));
9339
+ x2 = mids[0].x;
9340
+ y2 = mids[0].y;
9341
+ }
9342
+ }
9343
+ const minX = Math.min(x1, x2) - scrollX;
9344
+ const minY = Math.min(y1, y2) - scrollY;
9345
+ return {
9346
+ left: minX,
9347
+ top: minY,
9348
+ width: Math.max(12, Math.abs(x2 - x1)),
9349
+ height: Math.max(12, Math.abs(y2 - y1))
9350
+ };
9351
+ }, [isConnector, rawShape, allShapes, shape.left, shape.top, shape.width, shape.height, scrollX, scrollY]);
7164
9352
  const handleDragStart = (e) => {
7165
9353
  e.preventDefault();
7166
9354
  e.stopPropagation();
9355
+ onSelect();
7167
9356
  const startX = e.clientX;
7168
9357
  const startY = e.clientY;
7169
- const origL = shape.left;
7170
- const origT = shape.top;
9358
+ const origL = rawShape.left;
9359
+ const origT = rawShape.top;
9360
+ const onMouseMove = (ev) => {
9361
+ const nextL = Math.max(4, origL + (ev.clientX - startX));
9362
+ const nextT = Math.max(4, origT + (ev.clientY - startY));
9363
+ if (isConnector) {
9364
+ const snapStart = findNearestAnchorMidpoint(nextL, nextT, allShapes, rawShape.id);
9365
+ const snapEnd = findNearestAnchorMidpoint(
9366
+ nextL + rawShape.width,
9367
+ nextT + rawShape.height,
9368
+ allShapes,
9369
+ rawShape.id
9370
+ );
9371
+ onUpdate({
9372
+ ...rawShape,
9373
+ left: snapStart ? snapStart.x : nextL,
9374
+ top: snapStart ? snapStart.y : nextT,
9375
+ startShapeId: snapStart?.shapeId,
9376
+ endShapeId: snapEnd?.shapeId
9377
+ });
9378
+ } else {
9379
+ onUpdate({ ...rawShape, left: nextL, top: nextT });
9380
+ }
9381
+ };
9382
+ const onMouseUp = () => {
9383
+ window.removeEventListener("mousemove", onMouseMove);
9384
+ window.removeEventListener("mouseup", onMouseUp);
9385
+ };
9386
+ window.addEventListener("mousemove", onMouseMove);
9387
+ window.addEventListener("mouseup", onMouseUp);
9388
+ };
9389
+ const handleResizeStart = (dir) => (e) => {
9390
+ e.preventDefault();
9391
+ e.stopPropagation();
9392
+ onSelect();
9393
+ const startX = e.clientX;
9394
+ const startY = e.clientY;
9395
+ const origL = rawShape.left;
9396
+ const origT = rawShape.top;
9397
+ const origW = rawShape.width;
9398
+ const origH = rawShape.height;
9399
+ const onMouseMove = (ev) => {
9400
+ const dx = ev.clientX - startX;
9401
+ const dy = ev.clientY - startY;
9402
+ let nextL = origL;
9403
+ let nextT = origT;
9404
+ let nextW = origW;
9405
+ let nextH = origH;
9406
+ if (dir.includes("e")) nextW = Math.max(20, origW + dx);
9407
+ if (dir.includes("s")) nextH = Math.max(16, origH + dy);
9408
+ if (dir.includes("w")) {
9409
+ const proposedW = Math.max(20, origW - dx);
9410
+ nextL = origL + (origW - proposedW);
9411
+ nextW = proposedW;
9412
+ }
9413
+ if (dir.includes("n")) {
9414
+ const proposedH = Math.max(16, origH - dy);
9415
+ nextT = origT + (origH - proposedH);
9416
+ nextH = proposedH;
9417
+ }
9418
+ if (isConnector) {
9419
+ const snapStart = dir.includes("w") || dir.includes("n") ? findNearestAnchorMidpoint(nextL, nextT, allShapes, rawShape.id) : null;
9420
+ const snapEnd = dir.includes("e") || dir.includes("s") ? findNearestAnchorMidpoint(nextL + nextW, nextT + nextH, allShapes, rawShape.id) : null;
9421
+ if (snapStart) {
9422
+ nextW = Math.max(12, nextL + nextW - snapStart.x);
9423
+ nextH = Math.max(12, nextT + nextH - snapStart.y);
9424
+ nextL = snapStart.x;
9425
+ nextT = snapStart.y;
9426
+ }
9427
+ if (snapEnd) {
9428
+ nextW = Math.max(12, snapEnd.x - nextL);
9429
+ nextH = Math.max(12, snapEnd.y - nextT);
9430
+ }
9431
+ onUpdate({
9432
+ ...rawShape,
9433
+ left: Math.round(nextL),
9434
+ top: Math.round(nextT),
9435
+ width: Math.round(nextW),
9436
+ height: Math.round(nextH),
9437
+ ...dir.includes("w") || dir.includes("n") ? { startShapeId: snapStart?.shapeId } : {},
9438
+ ...dir.includes("e") || dir.includes("s") ? { endShapeId: snapEnd?.shapeId } : {}
9439
+ });
9440
+ } else {
9441
+ onUpdate({
9442
+ ...rawShape,
9443
+ left: Math.round(nextL),
9444
+ top: Math.round(nextT),
9445
+ width: Math.round(nextW),
9446
+ height: Math.round(nextH)
9447
+ });
9448
+ }
9449
+ };
9450
+ const onMouseUp = () => {
9451
+ window.removeEventListener("mousemove", onMouseMove);
9452
+ window.removeEventListener("mouseup", onMouseUp);
9453
+ };
9454
+ window.addEventListener("mousemove", onMouseMove);
9455
+ window.addEventListener("mouseup", onMouseUp);
9456
+ };
9457
+ const handleRotateStart = (e) => {
9458
+ e.preventDefault();
9459
+ e.stopPropagation();
9460
+ onSelect();
9461
+ const boxEl = e.currentTarget.parentElement;
9462
+ if (!boxEl) return;
9463
+ const rect = boxEl.getBoundingClientRect();
9464
+ const cx = rect.left + rect.width / 2;
9465
+ const cy = rect.top + rect.height / 2;
7171
9466
  const onMouseMove = (ev) => {
7172
- onMove(Math.max(4, origL + (ev.clientX - startX)), Math.max(4, origT + (ev.clientY - startY)));
9467
+ const rad = Math.atan2(ev.clientY - cy, ev.clientX - cx);
9468
+ let deg = Math.round((rad * 180 / Math.PI + 90 + 360) % 360);
9469
+ if (ev.shiftKey) deg = Math.round(deg / 15) * 15;
9470
+ onUpdate({ ...rawShape, rotation: deg });
7173
9471
  };
7174
9472
  const onMouseUp = () => {
7175
9473
  window.removeEventListener("mousemove", onMouseMove);
@@ -7179,7 +9477,37 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7179
9477
  window.addEventListener("mouseup", onMouseUp);
7180
9478
  };
7181
9479
  const renderShapeGeometry = () => {
9480
+ const markerId = `yudao-arrow-${shape.id}`;
7182
9481
  switch (shape.shapeType) {
9482
+ case "line":
9483
+ case "connector":
9484
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
9485
+ (shape.arrowEnd || shape.shapeType === "connector") && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9486
+ "marker",
9487
+ {
9488
+ id: markerId,
9489
+ viewBox: "0 0 10 10",
9490
+ refX: "8",
9491
+ refY: "5",
9492
+ markerWidth: "6",
9493
+ markerHeight: "6",
9494
+ orient: "auto-start-reverse",
9495
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: stroke })
9496
+ }
9497
+ ) }),
9498
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9499
+ "line",
9500
+ {
9501
+ x1: 4,
9502
+ y1: 4,
9503
+ x2: 96,
9504
+ y2: 96,
9505
+ stroke,
9506
+ strokeWidth: shape.strokeWidth || 2.2,
9507
+ markerEnd: shape.arrowEnd || shape.shapeType === "connector" ? `url(#${markerId})` : void 0
9508
+ }
9509
+ )
9510
+ ] });
7183
9511
  case "roundRect":
7184
9512
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: 2, y: 2, width: 96, height: 96, rx: 14, fill, stroke, strokeWidth: 2 });
7185
9513
  case "ellipse":
@@ -7187,6 +9515,7 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7187
9515
  case "diamond":
7188
9516
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("polygon", { points: "50,3 97,50 50,97 3,50", fill, stroke, strokeWidth: 2 });
7189
9517
  case "arrow":
9518
+ case "rightArrow":
7190
9519
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7191
9520
  "polygon",
7192
9521
  {
@@ -7197,6 +9526,7 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7197
9526
  }
7198
9527
  );
7199
9528
  case "callout":
9529
+ case "wedgeRoundRectCallout":
7200
9530
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7201
9531
  "polygon",
7202
9532
  {
@@ -7211,19 +9541,32 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7211
9541
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: 2, y: 2, width: 96, height: 96, rx: 3, fill, stroke, strokeWidth: 2 });
7212
9542
  }
7213
9543
  };
9544
+ const handles = [
9545
+ { dir: "nw", style: { left: -4, top: -4 }, cursor: "nwse-resize" },
9546
+ { dir: "n", style: { left: "calc(50% - 4px)", top: -4 }, cursor: "ns-resize" },
9547
+ { dir: "ne", style: { right: -4, top: -4 }, cursor: "nesw-resize" },
9548
+ { dir: "e", style: { right: -4, top: "calc(50% - 4px)" }, cursor: "ew-resize" },
9549
+ { dir: "se", style: { right: -4, bottom: -4 }, cursor: "nwse-resize" },
9550
+ { dir: "s", style: { left: "calc(50% - 4px)", bottom: -4 }, cursor: "ns-resize" },
9551
+ { dir: "sw", style: { left: -4, bottom: -4 }, cursor: "nesw-resize" },
9552
+ { dir: "w", style: { left: -4, top: "calc(50% - 4px)" }, cursor: "ew-resize" }
9553
+ ];
7214
9554
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
7215
9555
  "div",
7216
9556
  {
7217
9557
  onMouseDown: handleDragStart,
7218
9558
  style: {
7219
9559
  position: "absolute",
7220
- left: shape.left,
7221
- top: shape.top,
7222
- width: shape.width,
7223
- height: shape.height,
9560
+ left: resolvedBox.left,
9561
+ top: resolvedBox.top,
9562
+ width: resolvedBox.width,
9563
+ height: resolvedBox.height,
9564
+ transform: rawShape.rotation ? `rotate(${rawShape.rotation}deg)` : void 0,
9565
+ transformOrigin: "center center",
9566
+ outline: selected ? "1.5px dashed #2C53F1" : void 0,
7224
9567
  pointerEvents: "auto",
7225
9568
  cursor: "move",
7226
- zIndex: 24,
9569
+ zIndex: selected ? 28 : 24,
7227
9570
  display: "flex",
7228
9571
  alignItems: "center",
7229
9572
  justifyContent: "center"
@@ -7234,18 +9577,18 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7234
9577
  {
7235
9578
  viewBox: "0 0 100 100",
7236
9579
  preserveAspectRatio: "none",
7237
- style: { position: "absolute", inset: 0, width: "100%", height: "100%" },
9580
+ style: { position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" },
7238
9581
  children: renderShapeGeometry()
7239
9582
  }
7240
9583
  ),
7241
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9584
+ !isConnector && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7242
9585
  "span",
7243
9586
  {
7244
9587
  style: {
7245
9588
  position: "relative",
7246
9589
  padding: "4px 8px",
7247
9590
  color: textColor,
7248
- fontSize: 12,
9591
+ fontSize: rawShape.fontSize || 12,
7249
9592
  fontWeight: 600,
7250
9593
  textAlign: "center",
7251
9594
  lineHeight: 1.3,
@@ -7255,6 +9598,43 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7255
9598
  children: displayText
7256
9599
  }
7257
9600
  ),
9601
+ selected && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
9602
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9603
+ "div",
9604
+ {
9605
+ onMouseDown: handleRotateStart,
9606
+ title: `\u62D6\u62FD\u65CB\u8F6C\u56FE\u5F62 (${rawShape.rotation ?? 0}\xB0)`,
9607
+ style: {
9608
+ position: "absolute",
9609
+ left: "calc(50% - 5px)",
9610
+ top: -20,
9611
+ width: 10,
9612
+ height: 10,
9613
+ borderRadius: "50%",
9614
+ background: "#FFFFFF",
9615
+ border: "2px solid #2C53F1",
9616
+ cursor: "grab"
9617
+ }
9618
+ }
9619
+ ),
9620
+ handles.map((h) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9621
+ "div",
9622
+ {
9623
+ onMouseDown: handleResizeStart(h.dir),
9624
+ style: {
9625
+ position: "absolute",
9626
+ width: 8,
9627
+ height: 8,
9628
+ borderRadius: 2,
9629
+ background: "#FFFFFF",
9630
+ border: "1.5px solid #2C53F1",
9631
+ cursor: h.cursor,
9632
+ ...h.style
9633
+ }
9634
+ },
9635
+ h.dir
9636
+ ))
9637
+ ] }),
7258
9638
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7259
9639
  "button",
7260
9640
  {
@@ -7306,6 +9686,8 @@ var SheetRichOverlayHost = () => {
7306
9686
  );
7307
9687
  const [tick, setTick] = (0, import_react5.useState)(0);
7308
9688
  const [drillToast, setDrillToast] = (0, import_react5.useState)(null);
9689
+ const [selectedShapeId, setSelectedShapeId] = (0, import_react5.useState)(null);
9690
+ const [pageBreakPreviewMode, setPageBreakPreviewMode] = (0, import_react5.useState)(false);
7309
9691
  (0, import_react5.useEffect)(() => {
7310
9692
  if (!workbook) return;
7311
9693
  const disp = commandService.onCommandExecuted((info) => {
@@ -7528,33 +9910,89 @@ var SheetRichOverlayHost = () => {
7528
9910
  );
7529
9911
  const outlines = (metadata.outlines ?? []).filter((o) => o.sheetId === activeSheetId);
7530
9912
  const outlinePills2 = [];
9913
+ let maxRowOutlineLevel = 0;
9914
+ let maxColOutlineLevel = 0;
7531
9915
  for (const o of outlines) {
7532
9916
  if (o.dimension === "row") {
7533
- const anchorRow = Math.max(0, o.startIndex - 1);
7534
- const coord = skeleton.getCellWithCoordByIndex(anchorRow, 0);
7535
- const top = (coord.startY - colHeaderH - vpScrollXY.y) * scaleY + 2;
9917
+ if (o.level > maxRowOutlineLevel) maxRowOutlineLevel = o.level;
9918
+ const startCoord = skeleton.getCellWithCoordByIndex(Math.max(0, o.startIndex), 0);
9919
+ const endCoord = skeleton.getCellWithCoordByIndex(Math.max(0, o.endIndex), 0);
9920
+ const top = (startCoord.startY - colHeaderH - vpScrollXY.y) * scaleY;
9921
+ const bottom = (endCoord.endY - colHeaderH - vpScrollXY.y) * scaleY;
7536
9922
  const left = Math.max(2, (o.level - 1) * 18 + 2);
7537
- if (top >= -16 && top <= canvasRect.height) {
7538
- outlinePills2.push({ outline: o, left, top });
9923
+ if (bottom >= -16 && top <= canvasRect.height) {
9924
+ outlinePills2.push({
9925
+ outline: o,
9926
+ left,
9927
+ top: Math.max(2, top + 2),
9928
+ spanSize: Math.max(16, bottom - top)
9929
+ });
7539
9930
  }
7540
9931
  } else {
7541
- const anchorCol = Math.max(0, o.startIndex - 1);
7542
- const coord = skeleton.getCellWithCoordByIndex(0, anchorCol);
7543
- const left = (coord.startX - rowHeaderW - vpScrollXY.x) * scaleX + 2;
9932
+ if (o.level > maxColOutlineLevel) maxColOutlineLevel = o.level;
9933
+ const startCoord = skeleton.getCellWithCoordByIndex(0, Math.max(0, o.startIndex));
9934
+ const endCoord = skeleton.getCellWithCoordByIndex(0, Math.max(0, o.endIndex));
9935
+ const left = (startCoord.startX - rowHeaderW - vpScrollXY.x) * scaleX;
9936
+ const right = (endCoord.endX - rowHeaderW - vpScrollXY.x) * scaleX;
7544
9937
  const top = Math.max(2, (o.level - 1) * 18 + 2);
7545
- if (left >= -16 && left <= canvasRect.width) {
7546
- outlinePills2.push({ outline: o, left, top });
9938
+ if (right >= -16 && left <= canvasRect.width) {
9939
+ outlinePills2.push({
9940
+ outline: o,
9941
+ left: Math.max(2, left + 2),
9942
+ top,
9943
+ spanSize: Math.max(16, right - left)
9944
+ });
7547
9945
  }
7548
9946
  }
7549
9947
  }
7550
- const printOrientation = metadata.printConfig?.paperOrientation ?? "A4_LANDSCAPE";
7551
- const showPageBreakLines = features.printTemplate && metadata.printConfig?.showPageBreakLines !== false;
7552
- const pageWidthPx = printOrientation === "A4_PORTRAIT" ? 680 : printOrientation === "A3_LANDSCAPE" ? 1360 : printOrientation === "INVOICE_240_140" || printOrientation === "INVOICE_240_93" ? 820 : 980;
9948
+ const effectiveSheetPrintCfg = (0, import_univer_sheets5.resolveWorksheetPrintConfig)(wbSnapWithMeta, activeSheetId, {
9949
+ printConfig: metadata.printConfig
9950
+ });
9951
+ const printOrientation = effectiveSheetPrintCfg.paperOrientation ?? effectiveSheetPrintCfg.orientation ?? metadata.printConfig?.paperOrientation ?? "A4_LANDSCAPE";
9952
+ const showPageBreakLines = features.printTemplate && (pageBreakPreviewMode || effectiveSheetPrintCfg.showPageBreakLines !== false);
9953
+ const isPortrait = printOrientation === "A4_PORTRAIT" || printOrientation === "portrait";
9954
+ const pageWidthPx = isPortrait ? 680 : printOrientation === "A3_LANDSCAPE" ? 1360 : printOrientation === "INVOICE_240_140" || printOrientation === "INVOICE_240_93" ? 820 : 980;
9955
+ const pageHeightPx = isPortrait ? 960 : 680;
7553
9956
  const pageBreakX = (pageWidthPx - vpScrollXY.x) * scaleX;
9957
+ const manualRowBreaks = Array.isArray(effectiveSheetPrintCfg.rowBreaks) ? effectiveSheetPrintCfg.rowBreaks.filter((n) => Number.isFinite(n) && n >= 1) : [];
9958
+ const manualColBreaks = Array.isArray(effectiveSheetPrintCfg.colBreaks) ? effectiveSheetPrintCfg.colBreaks.filter((n) => Number.isFinite(n) && n >= 1) : [];
9959
+ const rowBreakLines = [];
9960
+ for (const brkId of manualRowBreaks) {
9961
+ const c = skeleton.getCellWithCoordByIndex(Math.max(0, brkId - 1), 0);
9962
+ const y = (c.endY - colHeaderH - vpScrollXY.y) * scaleY;
9963
+ rowBreakLines.push({ y, breakId: brkId, manual: true });
9964
+ }
9965
+ if (pageBreakPreviewMode) {
9966
+ for (let p = 1; p <= 4; p++) {
9967
+ const autoY = (p * pageHeightPx - vpScrollXY.y) * scaleY;
9968
+ if (!rowBreakLines.some((l) => Math.abs(l.y - autoY) < 24)) {
9969
+ const estRow = Math.max(1, Math.round(p * pageHeightPx / 24));
9970
+ rowBreakLines.push({ y: autoY, breakId: estRow, manual: false });
9971
+ }
9972
+ }
9973
+ }
9974
+ const colBreakLines = [];
9975
+ for (const brkId of manualColBreaks) {
9976
+ const c = skeleton.getCellWithCoordByIndex(0, Math.max(0, brkId - 1));
9977
+ const x = (c.endX - rowHeaderW - vpScrollXY.x) * scaleX;
9978
+ colBreakLines.push({ x, breakId: brkId, manual: true });
9979
+ }
9980
+ if (!colBreakLines.some((l) => Math.abs(l.x - pageBreakX) < 24)) {
9981
+ const estCol = Math.max(1, Math.round(pageWidthPx / 88));
9982
+ colBreakLines.push({ x: pageBreakX, breakId: estCol, manual: false });
9983
+ }
7554
9984
  return {
7555
9985
  unitId: unitId2,
7556
9986
  sheetId: activeSheetId,
7557
9987
  sheetCfg: sheetCfg2,
9988
+ metadata,
9989
+ effectiveSheetPrintCfg,
9990
+ skeleton,
9991
+ scaleX,
9992
+ scaleY,
9993
+ vpScrollXY,
9994
+ rowHeaderW,
9995
+ colHeaderH,
7558
9996
  workbookSnapshot: workbook.save(),
7559
9997
  viewportBox: {
7560
9998
  left: canvasRect.left + rowHeaderW * scaleX,
@@ -7570,7 +10008,11 @@ var SheetRichOverlayHost = () => {
7570
10008
  timelines: timelines2,
7571
10009
  shapes: shapes2,
7572
10010
  outlinePills: outlinePills2,
7573
- overlayBackgroundUrl: metadata.printConfig?.overlayBackgroundUrl || metadata.printConfig?.backgroundImageUrl || "",
10011
+ maxRowOutlineLevel,
10012
+ maxColOutlineLevel,
10013
+ rowBreakLines: rowBreakLines.sort((a, b) => a.y - b.y),
10014
+ colBreakLines: colBreakLines.sort((a, b) => a.x - b.x),
10015
+ overlayBackgroundUrl: effectiveSheetPrintCfg.overlayBackgroundUrl || effectiveSheetPrintCfg.backgroundImageUrl || metadata.printConfig?.overlayBackgroundUrl || metadata.printConfig?.backgroundImageUrl || "",
7574
10016
  showPageBreakLines,
7575
10017
  pageBreakX,
7576
10018
  printOrientation
@@ -7579,6 +10021,7 @@ var SheetRichOverlayHost = () => {
7579
10021
  workbook,
7580
10022
  features.datasetBinding,
7581
10023
  features.printTemplate,
10024
+ pageBreakPreviewMode,
7582
10025
  tick,
7583
10026
  metaVersion,
7584
10027
  renderManagerService,
@@ -7600,7 +10043,8 @@ var SheetRichOverlayHost = () => {
7600
10043
  } = overlayState;
7601
10044
  const renderSparklineNode = (box) => {
7602
10045
  const spark = box.meta.sparkline;
7603
- const rng = (0, import_univer_sheets5.parseA1Range)(spark.dataRange);
10046
+ const rawRange = spark.dataRange.includes("!") ? spark.dataRange.slice(spark.dataRange.lastIndexOf("!") + 1) : spark.dataRange;
10047
+ const rng = (0, import_univer_sheets5.parseA1Range)(rawRange);
7604
10048
  if (!rng) return null;
7605
10049
  const vals = [];
7606
10050
  for (let r = rng.startRow; r <= rng.endRow; r++) {
@@ -7610,8 +10054,9 @@ var SheetRichOverlayHost = () => {
7610
10054
  }
7611
10055
  }
7612
10056
  if (vals.length === 0) return null;
7613
- const color = spark.color || "#2C53F1";
7614
- const negColor = spark.negativeColor || "#7D8698";
10057
+ const color = spark.colorSeries || spark.color || "#2C53F1";
10058
+ const negColor = spark.colorNegative || spark.negativeColor || "#7D8698";
10059
+ const mrkColor = spark.colorMarkers || spark.markerColor || "#1B1C1F";
7615
10060
  const highVal = Math.max(...vals);
7616
10061
  const lowVal = Math.min(...vals);
7617
10062
  const highIdx = vals.indexOf(highVal);
@@ -7620,8 +10065,8 @@ var SheetRichOverlayHost = () => {
7620
10065
  const max = Math.max(1, highVal);
7621
10066
  const span = max - min || 1;
7622
10067
  const isWinLoss = spark.type === "winLoss" || spark.type === "winloss";
7623
- const isHighlighted = (idx) => spark.showHighPoint && idx === highIdx || spark.showLowPoint && idx === lowIdx || spark.showFirstPoint && idx === 0 || spark.showLastPoint && idx === vals.length - 1;
7624
- if (spark.type === "bar" || isWinLoss) {
10068
+ const isHighlighted = (idx) => Boolean(spark.markers) || spark.showHighPoint && idx === highIdx || spark.showLowPoint && idx === lowIdx || spark.showFirstPoint && idx === 0 || spark.showLastPoint && idx === vals.length - 1;
10069
+ if (spark.type === "bar" || spark.type === "column" || isWinLoss) {
7625
10070
  const bw = Math.max(4, Math.floor(82 / vals.length) - 2);
7626
10071
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 96 24", style: { width: "92%", height: "78%" }, children: [
7627
10072
  isWinLoss && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", { x1: 4, y1: 12, x2: 92, y2: 12, stroke: "#E3E5EA", strokeWidth: 0.8 }),
@@ -7667,17 +10112,28 @@ var SheetRichOverlayHost = () => {
7667
10112
  });
7668
10113
  const pts = coords.map((p) => `${p.x.toFixed(1)},${p.y.toFixed(1)}`).join(" ");
7669
10114
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 96 24", style: { width: "92%", height: "78%" }, children: [
10115
+ spark.displayXAxis && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10116
+ "line",
10117
+ {
10118
+ x1: 4,
10119
+ y1: 20 - (0 - min) / span * 16,
10120
+ x2: 92,
10121
+ y2: 20 - (0 - min) / span * 16,
10122
+ stroke: "#CBD5E1",
10123
+ strokeWidth: 0.8
10124
+ }
10125
+ ),
7670
10126
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("polyline", { fill: "none", stroke: color, strokeWidth: 1.6, points: pts }),
7671
10127
  coords.map((p) => {
7672
10128
  const marker = isHighlighted(p.i);
7673
- if (!marker && !(p.v < 0 && spark.negativeColor)) return null;
10129
+ if (!marker && !(p.v < 0 && (spark.negativeColor || spark.colorNegative))) return null;
7674
10130
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7675
10131
  "circle",
7676
10132
  {
7677
10133
  cx: p.x,
7678
10134
  cy: p.y,
7679
10135
  r: 2.3,
7680
- fill: p.v < 0 && spark.negativeColor ? negColor : "#1B1C1F"
10136
+ fill: p.v < 0 && (spark.negativeColor || spark.colorNegative) ? negColor : mrkColor
7681
10137
  },
7682
10138
  p.i
7683
10139
  );
@@ -7713,39 +10169,201 @@ var SheetRichOverlayHost = () => {
7713
10169
  }
7714
10170
  }
7715
10171
  ),
7716
- overlayState.showPageBreakLines && overlayState.pageBreakX > 20 && overlayState.pageBreakX < viewportBox.width && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7717
- "div",
10172
+ features.printTemplate && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10173
+ "button",
7718
10174
  {
10175
+ type: "button",
10176
+ onClick: () => setPageBreakPreviewMode((v) => !v),
7719
10177
  style: {
7720
10178
  position: "absolute",
7721
- left: overlayState.pageBreakX,
7722
- top: 0,
7723
- bottom: 0,
7724
- borderLeft: "1px dashed #94A3B8",
7725
- pointerEvents: "none",
7726
- zIndex: 8
10179
+ top: 6,
10180
+ right: 10,
10181
+ background: pageBreakPreviewMode ? "#2C53F1" : "rgba(255,255,255,0.92)",
10182
+ color: pageBreakPreviewMode ? "#FFFFFF" : "#4E5565",
10183
+ border: `1px solid ${pageBreakPreviewMode ? "#2C53F1" : "#D2DAFA"}`,
10184
+ borderRadius: 999,
10185
+ fontSize: 10.5,
10186
+ fontWeight: 600,
10187
+ padding: "2px 8px",
10188
+ cursor: "pointer",
10189
+ pointerEvents: "auto",
10190
+ zIndex: 30
7727
10191
  },
7728
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7729
- "span",
10192
+ children: pageBreakPreviewMode ? "\u9000\u51FA\u5206\u9875\u9884\u89C8" : "\u5206\u9875\u9884\u89C8"
10193
+ }
10194
+ ),
10195
+ overlayState.showPageBreakLines && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
10196
+ overlayState.colBreakLines.map((cb, cbIdx) => {
10197
+ if (cb.x <= 12 || cb.x >= viewportBox.width) return null;
10198
+ const handleColBreakDrag = (e) => {
10199
+ e.preventDefault();
10200
+ e.stopPropagation();
10201
+ const onUp = (upEv) => {
10202
+ window.removeEventListener("mouseup", onUp);
10203
+ const localX = (upEv.clientX - viewportBox.left) / (overlayState.scaleX || 1) + overlayState.rowHeaderW + overlayState.vpScrollXY.x;
10204
+ let targetCol = 1;
10205
+ for (let c = 0; c < 120; c++) {
10206
+ const coord = overlayState.skeleton.getCellWithCoordByIndex(0, c);
10207
+ if (localX <= coord.endX) {
10208
+ targetCol = c + 1;
10209
+ break;
10210
+ }
10211
+ }
10212
+ const prevList = Array.isArray(overlayState.effectiveSheetPrintCfg.colBreaks) ? overlayState.effectiveSheetPrintCfg.colBreaks.filter((x) => x !== cb.breakId) : [];
10213
+ const nextCols = Array.from(/* @__PURE__ */ new Set([...prevList, targetCol])).sort((a, b) => a - b);
10214
+ const prevPrint = overlayState.metadata.printConfig ?? {};
10215
+ templateService.patchPrintConfig(unitId, {
10216
+ colBreaks: nextCols,
10217
+ bySheetId: {
10218
+ ...prevPrint.bySheetId ?? {},
10219
+ [sheetId]: {
10220
+ ...prevPrint.bySheetId?.[sheetId] ?? {},
10221
+ colBreaks: nextCols
10222
+ }
10223
+ }
10224
+ });
10225
+ };
10226
+ window.addEventListener("mouseup", onUp);
10227
+ };
10228
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10229
+ "div",
7730
10230
  {
10231
+ onMouseDown: handleColBreakDrag,
10232
+ title: "\u62D6\u62FD\u8C03\u6574\u7EB5\u5411\u5206\u9875\u7B26\u4F4D\u7F6E",
7731
10233
  style: {
7732
10234
  position: "absolute",
7733
- top: 4,
7734
- right: 4,
7735
- background: "#F9FAFB",
7736
- color: "#4E5565",
7737
- border: "1px solid #E3E5EA",
7738
- borderRadius: 4,
7739
- fontSize: 9.5,
7740
- fontWeight: 500,
7741
- padding: "1px 5px",
7742
- whiteSpace: "nowrap"
10235
+ left: cb.x,
10236
+ top: 0,
10237
+ bottom: 0,
10238
+ width: 5,
10239
+ borderLeft: cb.manual ? "2px solid #1D4ED8" : "1.5px dashed #3B82F6",
10240
+ cursor: "col-resize",
10241
+ pointerEvents: pageBreakPreviewMode || cb.manual ? "auto" : "none",
10242
+ zIndex: 9
7743
10243
  },
7744
- children: t("yudaoSheets.overlay.pageBreakBadge")
10244
+ children: cbIdx === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10245
+ "span",
10246
+ {
10247
+ style: {
10248
+ position: "absolute",
10249
+ top: 30,
10250
+ right: 6,
10251
+ background: "#F3F5FF",
10252
+ color: "#2C53F1",
10253
+ border: "1px solid #D2DAFA",
10254
+ borderRadius: 4,
10255
+ fontSize: 9.5,
10256
+ fontWeight: 600,
10257
+ padding: "1px 5px",
10258
+ whiteSpace: "nowrap",
10259
+ pointerEvents: "none"
10260
+ },
10261
+ children: t("yudaoSheets.overlay.pageBreakBadge")
10262
+ }
10263
+ )
10264
+ },
10265
+ `cb-${cbIdx}-${cb.breakId}`
10266
+ );
10267
+ }),
10268
+ overlayState.rowBreakLines.map((rb, rbIdx) => {
10269
+ if (rb.y <= 12 || rb.y >= viewportBox.height) return null;
10270
+ const handleRowBreakDrag = (e) => {
10271
+ e.preventDefault();
10272
+ e.stopPropagation();
10273
+ const onUp = (upEv) => {
10274
+ window.removeEventListener("mouseup", onUp);
10275
+ const localY = (upEv.clientY - viewportBox.top) / (overlayState.scaleY || 1) + overlayState.colHeaderH + overlayState.vpScrollXY.y;
10276
+ let targetRow = 1;
10277
+ for (let r = 0; r < 500; r++) {
10278
+ const coord = overlayState.skeleton.getCellWithCoordByIndex(r, 0);
10279
+ if (localY <= coord.endY) {
10280
+ targetRow = r + 1;
10281
+ break;
10282
+ }
10283
+ }
10284
+ const prevList = Array.isArray(overlayState.effectiveSheetPrintCfg.rowBreaks) ? overlayState.effectiveSheetPrintCfg.rowBreaks.filter((x) => x !== rb.breakId) : [];
10285
+ const nextRows = Array.from(/* @__PURE__ */ new Set([...prevList, targetRow])).sort((a, b) => a - b);
10286
+ const prevPrint = overlayState.metadata.printConfig ?? {};
10287
+ templateService.patchPrintConfig(unitId, {
10288
+ rowBreaks: nextRows,
10289
+ bySheetId: {
10290
+ ...prevPrint.bySheetId ?? {},
10291
+ [sheetId]: {
10292
+ ...prevPrint.bySheetId?.[sheetId] ?? {},
10293
+ rowBreaks: nextRows
10294
+ }
10295
+ }
10296
+ });
10297
+ };
10298
+ window.addEventListener("mouseup", onUp);
10299
+ };
10300
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10301
+ "div",
10302
+ {
10303
+ onMouseDown: handleRowBreakDrag,
10304
+ title: "\u62D6\u62FD\u8C03\u6574\u6A2A\u5411\u5206\u9875\u7B26\u4F4D\u7F6E",
10305
+ style: {
10306
+ position: "absolute",
10307
+ left: 0,
10308
+ right: 0,
10309
+ top: rb.y,
10310
+ height: 5,
10311
+ borderTop: rb.manual ? "2px solid #1D4ED8" : "1.5px dashed #3B82F6",
10312
+ cursor: "row-resize",
10313
+ pointerEvents: "auto",
10314
+ zIndex: 9
10315
+ }
10316
+ },
10317
+ `rb-${rbIdx}-${rb.breakId}`
10318
+ );
10319
+ }),
10320
+ pageBreakPreviewMode && (() => {
10321
+ const yStops = [0, ...overlayState.rowBreakLines.map((r) => r.y).filter((y) => y > 0)];
10322
+ const xStops = [0, ...overlayState.colBreakLines.map((c) => c.x).filter((x) => x > 0)];
10323
+ const marks = [];
10324
+ let pageSeq = 1;
10325
+ for (let rIdx = 0; rIdx < Math.min(3, yStops.length); rIdx++) {
10326
+ const y0 = yStops[rIdx];
10327
+ const y1 = yStops[rIdx + 1] ?? viewportBox.height;
10328
+ for (let cIdx = 0; cIdx < Math.min(2, xStops.length); cIdx++) {
10329
+ const x0 = xStops[cIdx];
10330
+ const x1 = xStops[cIdx + 1] ?? viewportBox.width;
10331
+ const cx = (x0 + Math.min(x1, viewportBox.width)) / 2;
10332
+ const cy = (y0 + Math.min(y1, viewportBox.height)) / 2;
10333
+ const pNum = pageSeq++;
10334
+ if (cx > 40 && cy > 30 && cx < viewportBox.width && cy < viewportBox.height) {
10335
+ marks.push(
10336
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
10337
+ "div",
10338
+ {
10339
+ style: {
10340
+ position: "absolute",
10341
+ left: cx,
10342
+ top: cy,
10343
+ transform: "translate(-50%, -50%)",
10344
+ fontSize: 28,
10345
+ fontWeight: 800,
10346
+ color: "rgba(37, 99, 235, 0.16)",
10347
+ letterSpacing: 2,
10348
+ pointerEvents: "none",
10349
+ userSelect: "none",
10350
+ zIndex: 7
10351
+ },
10352
+ children: [
10353
+ "\u7B2C ",
10354
+ pNum,
10355
+ " \u9875"
10356
+ ]
10357
+ },
10358
+ `wm-${pNum}`
10359
+ )
10360
+ );
10361
+ }
7745
10362
  }
7746
- )
7747
- }
7748
- ),
10363
+ }
10364
+ return marks;
10365
+ })()
10366
+ ] }),
7749
10367
  drillToast && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
7750
10368
  "div",
7751
10369
  {
@@ -8016,60 +10634,202 @@ var SheetRichOverlayHost = () => {
8016
10634
  },
8017
10635
  ch.id
8018
10636
  )),
8019
- outlinePills.map(({ outline, left, top }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
8020
- "button",
10637
+ (overlayState.maxRowOutlineLevel > 0 || overlayState.maxColOutlineLevel > 0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
10638
+ "div",
8021
10639
  {
8022
- type: "button",
8023
- title: `${outline.dimension === "row" ? "\u884C" : "\u5217"}\u5206\u7EA7\u7EC4\u5408 L${outline.level} (${outline.startIndex + 1}-${outline.endIndex + 1})`,
8024
- onClick: (e) => {
8025
- e.stopPropagation();
8026
- commandService.syncExecuteCommand(import_univer_sheets5.ToggleSheetOutlineCommand.id, {
8027
- unitId,
8028
- outlineId: outline.id
8029
- });
8030
- },
8031
10640
  style: {
8032
10641
  position: "absolute",
8033
- left,
8034
- top,
8035
- width: 16,
8036
- height: 16,
8037
- borderRadius: 4,
10642
+ left: 4,
10643
+ top: 4,
10644
+ display: "flex",
10645
+ alignItems: "center",
10646
+ gap: 3,
10647
+ padding: "2px 5px",
10648
+ borderRadius: 5,
10649
+ background: "rgba(249, 250, 251, 0.95)",
8038
10650
  border: "1px solid #D2DAFA",
8039
- background: outline.collapsed ? "#F3F5FF" : "#FFFFFF",
8040
- color: "#2C53F1",
8041
- fontSize: 11,
8042
- fontWeight: 700,
8043
- lineHeight: 1,
8044
- padding: 0,
8045
- cursor: "pointer",
8046
10651
  pointerEvents: "auto",
8047
- zIndex: 22
10652
+ zIndex: 23
8048
10653
  },
8049
- children: outline.collapsed ? "+" : "-"
8050
- },
8051
- outline.id
8052
- )),
10654
+ children: [
10655
+ overlayState.maxRowOutlineLevel > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { style: { display: "inline-flex", alignItems: "center", gap: 2 }, children: [
10656
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { fontSize: 9.5, color: "#4E5565", fontWeight: 600 }, children: "\u884C\u7EA7" }),
10657
+ Array.from({ length: overlayState.maxRowOutlineLevel + 1 }, (_, i) => i + 1).map(
10658
+ (lvl) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10659
+ "button",
10660
+ {
10661
+ type: "button",
10662
+ title: `\u5C55\u5F00\u884C\u5927\u7EB2\u81F3\u7B2C ${lvl} \u7EA7`,
10663
+ onClick: (e) => {
10664
+ e.stopPropagation();
10665
+ commandService.syncExecuteCommand(import_univer_sheets5.ExpandSheetOutlineToLevelCommand.id, {
10666
+ unitId,
10667
+ sheetId,
10668
+ dimension: "row",
10669
+ maxVisibleLevel: lvl
10670
+ });
10671
+ },
10672
+ style: {
10673
+ width: 15,
10674
+ height: 15,
10675
+ borderRadius: 3,
10676
+ border: "1px solid #CBD5E1",
10677
+ background: "#FFFFFF",
10678
+ color: "#1B1C1F",
10679
+ fontSize: 9.5,
10680
+ fontWeight: 700,
10681
+ padding: 0,
10682
+ cursor: "pointer"
10683
+ },
10684
+ children: lvl
10685
+ },
10686
+ `rlvl-${lvl}`
10687
+ )
10688
+ )
10689
+ ] }),
10690
+ overlayState.maxColOutlineLevel > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { style: { display: "inline-flex", alignItems: "center", gap: 2, marginLeft: 4 }, children: [
10691
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { fontSize: 9.5, color: "#4E5565", fontWeight: 600 }, children: "\u5217\u7EA7" }),
10692
+ Array.from({ length: overlayState.maxColOutlineLevel + 1 }, (_, i) => i + 1).map(
10693
+ (lvl) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10694
+ "button",
10695
+ {
10696
+ type: "button",
10697
+ title: `\u5C55\u5F00\u5217\u5927\u7EB2\u81F3\u7B2C ${lvl} \u7EA7`,
10698
+ onClick: (e) => {
10699
+ e.stopPropagation();
10700
+ commandService.syncExecuteCommand(import_univer_sheets5.ExpandSheetOutlineToLevelCommand.id, {
10701
+ unitId,
10702
+ sheetId,
10703
+ dimension: "column",
10704
+ maxVisibleLevel: lvl
10705
+ });
10706
+ },
10707
+ style: {
10708
+ width: 15,
10709
+ height: 15,
10710
+ borderRadius: 3,
10711
+ border: "1px solid #CBD5E1",
10712
+ background: "#FFFFFF",
10713
+ color: "#1B1C1F",
10714
+ fontSize: 9.5,
10715
+ fontWeight: 700,
10716
+ padding: 0,
10717
+ cursor: "pointer"
10718
+ },
10719
+ children: lvl
10720
+ },
10721
+ `clvl-${lvl}`
10722
+ )
10723
+ )
10724
+ ] }),
10725
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10726
+ "button",
10727
+ {
10728
+ type: "button",
10729
+ title: "\u65B0\u589E\u884C\u5206\u7EC4 (AddSheetOutlineGroupCommand)",
10730
+ onClick: (e) => {
10731
+ e.stopPropagation();
10732
+ commandService.syncExecuteCommand(import_univer_sheets5.AddSheetOutlineGroupCommand.id, {
10733
+ unitId,
10734
+ sheetId,
10735
+ dimension: "row",
10736
+ startIndex: 1,
10737
+ endIndex: 3
10738
+ });
10739
+ },
10740
+ style: {
10741
+ height: 15,
10742
+ borderRadius: 3,
10743
+ border: "1px solid #D2DAFA",
10744
+ background: "#F3F5FF",
10745
+ color: "#2C53F1",
10746
+ fontSize: 9.5,
10747
+ fontWeight: 600,
10748
+ padding: "0 4px",
10749
+ cursor: "pointer"
10750
+ },
10751
+ children: "+\u7EC4"
10752
+ }
10753
+ )
10754
+ ]
10755
+ }
10756
+ ),
10757
+ outlinePills.map(({ outline, left, top, spanSize }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react5.default.Fragment, { children: [
10758
+ !outline.collapsed && spanSize > 20 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10759
+ "div",
10760
+ {
10761
+ style: {
10762
+ position: "absolute",
10763
+ left: outline.dimension === "row" ? left + 7 : left + 16,
10764
+ top: outline.dimension === "row" ? top + 28 : top + 7,
10765
+ width: outline.dimension === "row" ? 4 : Math.max(4, spanSize - 18),
10766
+ height: outline.dimension === "row" ? Math.max(4, spanSize - 18) : 4,
10767
+ borderLeft: outline.dimension === "row" ? "2px solid #93C5FD" : void 0,
10768
+ borderBottom: outline.dimension === "row" ? "2px solid #93C5FD" : void 0,
10769
+ borderTop: outline.dimension === "column" ? "2px solid #93C5FD" : void 0,
10770
+ borderRight: outline.dimension === "column" ? "2px solid #93C5FD" : void 0,
10771
+ pointerEvents: "none",
10772
+ zIndex: 21
10773
+ }
10774
+ }
10775
+ ),
10776
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
10777
+ "button",
10778
+ {
10779
+ type: "button",
10780
+ title: `${outline.dimension === "row" ? "\u884C" : "\u5217"}\u5206\u7EA7\u7EC4\u5408 L${outline.level} (${outline.startIndex + 1}-${outline.endIndex + 1})`,
10781
+ onClick: (e) => {
10782
+ e.stopPropagation();
10783
+ commandService.syncExecuteCommand(import_univer_sheets5.ToggleSheetOutlineCollapseCommand.id, {
10784
+ unitId,
10785
+ outlineId: outline.id
10786
+ });
10787
+ },
10788
+ style: {
10789
+ position: "absolute",
10790
+ left,
10791
+ top: outline.dimension === "row" ? top + 24 : top,
10792
+ width: 16,
10793
+ height: 16,
10794
+ borderRadius: 4,
10795
+ border: "1px solid #D2DAFA",
10796
+ background: outline.collapsed ? "#F3F5FF" : "#FFFFFF",
10797
+ color: "#2C53F1",
10798
+ fontSize: 11,
10799
+ fontWeight: 700,
10800
+ lineHeight: 1,
10801
+ padding: 0,
10802
+ cursor: "pointer",
10803
+ pointerEvents: "auto",
10804
+ zIndex: 22
10805
+ },
10806
+ children: outline.collapsed ? "+" : "-"
10807
+ }
10808
+ )
10809
+ ] }, outline.id)),
8053
10810
  shapes.map((sh) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
8054
10811
  FloatingShapeCard,
8055
10812
  {
10813
+ rawShape: sh,
10814
+ allShapes: shapes,
10815
+ scrollX: overlayState.scrollX,
10816
+ scrollY: overlayState.scrollY,
10817
+ selected: selectedShapeId === sh.id,
8056
10818
  shape: {
8057
10819
  ...sh,
8058
10820
  left: sh.left - overlayState.scrollX,
8059
10821
  top: sh.top - overlayState.scrollY
8060
10822
  },
8061
10823
  displayText: (0, import_univer_sheets5.resolveShapeDisplayText)(sheetCfg, sh),
8062
- onMove: (nextVisL, nextVisT) => {
8063
- commandService.syncExecuteCommand(import_univer_sheets5.AddOrUpdateSheetShapeCommand.id, {
10824
+ onSelect: () => setSelectedShapeId(sh.id),
10825
+ onUpdate: (nextShape) => {
10826
+ commandService.syncExecuteCommand(import_univer_sheets5.UpdateSheetShapeCommand.id, {
8064
10827
  unitId,
8065
- shape: {
8066
- ...sh,
8067
- left: nextVisL + overlayState.scrollX,
8068
- top: nextVisT + overlayState.scrollY
8069
- }
10828
+ shape: nextShape
8070
10829
  });
8071
10830
  },
8072
10831
  onRemove: () => {
10832
+ if (selectedShapeId === sh.id) setSelectedShapeId(null);
8073
10833
  commandService.syncExecuteCommand(import_univer_sheets5.RemoveSheetShapeCommand.id, {
8074
10834
  unitId,
8075
10835
  shapeId: sh.id