@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/es/index.js CHANGED
@@ -275,6 +275,10 @@ var OpenSheetIoModalOperation = {
275
275
  function mergeImportedTemplateMetadata(prevMeta, importedMeta) {
276
276
  const next = { ...prevMeta, ...importedMeta };
277
277
  if (!importedMeta.charts) delete next.charts;
278
+ if (!importedMeta.shapes) delete next.shapes;
279
+ if (!importedMeta.outlines) delete next.outlines;
280
+ if (!importedMeta.pivots) delete next.pivots;
281
+ if (!importedMeta.sparklines) delete next.sparklines;
278
282
  return next;
279
283
  }
280
284
  var ImportSheetFileOperation = {
@@ -373,28 +377,36 @@ import {
373
377
  SetWorksheetActiveOperation,
374
378
  SheetsSelectionsService
375
379
  } from "@univerjs/sheets";
376
- import { useDependency as useDependency2, useObservable as useObservable2 } from "@univerjs/ui";
380
+ import { useDependency as useDependency2, useInjector, useObservable as useObservable2 } from "@univerjs/ui";
377
381
  import {
382
+ a1ToCellCoords,
378
383
  AddOrUpdateSheetShapeCommand,
379
384
  AddOrUpdateSheetSlicerCommand,
380
385
  AddOrUpdateSheetTimelineCommand,
381
386
  ApplyImportedSheetDataCommand,
382
387
  ApplyImportedWorkbookDataCommand as ApplyImportedWorkbookDataCommand2,
388
+ ApplySheetScenarioCommand,
383
389
  BindSheetCellDatasetCommand,
390
+ buildPivotLinkedChart,
384
391
  buildWatchWindowSnapshot,
385
392
  cellCoordsToA1,
386
393
  colIndexToLetter,
387
394
  DeleteSheetFillRowCommand,
395
+ DeleteSheetMacroCommand,
396
+ DeleteSheetScenarioCommand,
388
397
  evaluateFormulaSteps,
389
398
  ExpandSheetOutlineToLevelCommand,
390
399
  exportSheetReportPackage,
391
400
  extractCellPlaceholders,
392
401
  extractSheetFillChangeset,
393
402
  extractSheetFillValues,
403
+ GenerateScenarioSummaryCommand,
394
404
  GenerateSheetPivotCommand,
395
405
  generateSheetFormulaByPrompt,
396
406
  generateSheetReportByPrompt,
397
407
  getCellYudaoMeta,
408
+ getWorkbookMacros,
409
+ getWorkbookScenarios,
398
410
  GoalSeekSheetCommand,
399
411
  GroupSheetOutlineCommand,
400
412
  importExcelIntoFillWorkbook,
@@ -402,20 +414,30 @@ import {
402
414
  InsertChartSheetCommand,
403
415
  InsertSheetFillRowCommand,
404
416
  ISheetIoService as ISheetIoService2,
417
+ ISheetMacroService,
405
418
  ISheetTemplateService as ISheetTemplateService2,
419
+ parseA1Range,
420
+ RefreshSheetPivotCommand,
421
+ RemoveSheetChartCommand,
422
+ ReplaySheetMacroCommand,
406
423
  resolveSelectionMasterCell,
407
424
  RestoreSheetVersionCommand,
425
+ RunSheetDataTableCommand,
426
+ SaveSheetScenarioCommand,
408
427
  SaveSheetVersionCommand,
409
428
  scanWorkbookBoundCells,
410
429
  SetSheetCellMetaCommand,
411
430
  SetSheetQueryParamFieldsCommand,
412
431
  SetWorkbookStructureLockCommand,
413
432
  SHEET_CHART_TYPE_GROUPS,
433
+ StartSheetMacroRecordCommand,
434
+ StopSheetMacroRecordCommand,
414
435
  ToggleSheetGroupCollapseCommand,
415
436
  ToggleSheetTreeNodeCommand,
416
437
  traceFormulaDependents,
417
438
  traceFormulaPrecedents,
418
439
  UngroupSheetOutlineCommand,
440
+ UpdateSheetChartCommand,
419
441
  validateSheetFillFormAsync
420
442
  } from "@yudaocode/univer-sheets";
421
443
  import { useEffect, useState } from "react";
@@ -466,9 +488,24 @@ var SheetInspectorPanel = () => {
466
488
  const templateService = useDependency2(ISheetTemplateService2);
467
489
  const ioService = useDependency2(ISheetIoService2);
468
490
  const featureService = useDependency2(ISheetsUIFeatureService);
491
+ const injector = useInjector();
492
+ const macroService = (() => {
493
+ try {
494
+ return injector.get(ISheetMacroService);
495
+ } catch {
496
+ return void 0;
497
+ }
498
+ })();
469
499
  const features = useObservable2(featureService.features$, featureService.getFeatures());
470
500
  const metaVersion = useObservable2(templateService.metadataChange$, "");
471
501
  const protWarn = useObservable2(templateService.protectionWarning$, null);
502
+ const defaultMacroRecState = {
503
+ recording: false,
504
+ stepCount: 0,
505
+ steps: []
506
+ };
507
+ const macroRecState = useObservable2(macroService?.recordingState$, defaultMacroRecState);
508
+ const macroListVer = useObservable2(macroService?.macrosChange$, "");
472
509
  const workbook = useObservable2(
473
510
  () => instanceService.getCurrentTypeOfUnit$(UniverInstanceType2.UNIVER_SHEET),
474
511
  instanceService.getCurrentUnitOfType(UniverInstanceType2.UNIVER_SHEET),
@@ -520,6 +557,38 @@ var SheetInspectorPanel = () => {
520
557
  const [qpDatasetCode, setQpDatasetCode] = useState("");
521
558
  const [qpTargetField, setQpTargetField] = useState("");
522
559
  const [qpDefaultVal, setQpDefaultVal] = useState("");
560
+ const [selectedChartId, setSelectedChartId] = useState("");
561
+ const [selectedPivotId, setSelectedPivotId] = useState("__new__");
562
+ const [pivotSourceRange, setPivotSourceRange] = useState("");
563
+ const [pivotChipTarget, setPivotChipTarget] = useState("rows");
564
+ const [pivotRowFields, setPivotRowFields] = useState([1]);
565
+ const [pivotColFields, setPivotColFields] = useState([]);
566
+ const [pivotValueFields, setPivotValueFields] = useState([
567
+ { colIndex: 5, aggFunc: "sum" }
568
+ ]);
569
+ const [pivotFilterFields, setPivotFilterFields] = useState([]);
570
+ const [pivotCalcFields, setPivotCalcFields] = useState([]);
571
+ const [calcFieldName, setCalcFieldName] = useState("");
572
+ const [calcFieldFormula, setCalcFieldFormula] = useState("");
573
+ const [watchInputRef, setWatchInputRef] = useState("");
574
+ const [evalSteps, setEvalSteps] = useState([]);
575
+ const [evalStepIdx, setEvalStepIdx] = useState(0);
576
+ const [evalCellKey, setEvalCellKey] = useState("");
577
+ const [scenarioNameInput, setScenarioNameInput] = useState("\u4E50\u89C2\u589E\u957F\u65B9\u6848");
578
+ const [scenarioCellsInput, setScenarioCellsInput] = useState("B2=120, B3=0.18");
579
+ const [scenarioResultsInput, setScenarioResultsInput] = useState("F10");
580
+ const [scenarioCommentInput, setScenarioCommentInput] = useState("");
581
+ const [whatIfMode, setWhatIfMode] = useState("1var");
582
+ const [dtInputCell, setDtInputCell] = useState("B2");
583
+ const [dtInputValues, setDtInputValues] = useState("80, 100, 120");
584
+ const [dtFormulaCells, setDtFormulaCells] = useState("F10");
585
+ const [dtColInputCell, setDtColInputCell] = useState("B3");
586
+ const [dtColValues, setDtColValues] = useState("10, 20, 30");
587
+ const [dtOutputTopLeft, setDtOutputTopLeft] = useState("H2");
588
+ const [whatIfStatusMsg, setWhatIfStatusMsg] = useState("");
589
+ const [macroNameInput, setMacroNameInput] = useState("");
590
+ const [macroStatusMsg, setMacroStatusMsg] = useState("");
591
+ const [previewMacro, setPreviewMacro] = useState(null);
523
592
  useEffect(() => {
524
593
  const sub = selectionService.selectionChanged$.subscribe(() => setSelTick((v) => v + 1));
525
594
  const disp = commandService.onCommandExecuted((info) => {
@@ -535,6 +604,7 @@ var SheetInspectorPanel = () => {
535
604
  if (!workbook) return null;
536
605
  void selTick;
537
606
  void metaVersion;
607
+ void macroListVer;
538
608
  const unitId = workbook.getUnitId();
539
609
  const sheet = workbook.getActiveSheet();
540
610
  if (!sheet) return null;
@@ -577,6 +647,63 @@ var SheetInspectorPanel = () => {
577
647
  const printCfg = metadata.printConfig ?? {};
578
648
  const protectionCfg = metadata.protection;
579
649
  const charts = metadata.charts ?? [];
650
+ const pivots = metadata.pivots ?? [];
651
+ const editingChart = charts.find((c) => c.id === selectedChartId) ?? charts[0];
652
+ const activePivot = selectedPivotId !== "__new__" ? pivots.find((p) => p.id === selectedPivotId) : void 0;
653
+ const pivotSrcSheet = (activePivot?.sourceSheetId ? workbook.getSheetBySheetId(activePivot.sourceSheetId) : null) ?? sheet;
654
+ const rawPivotRangePart = (pivotSourceRange || activePivot?.sourceRange || "").trim().replace(/^.*!/, "");
655
+ const parsedPivotRange = rawPivotRangePart ? parseA1Range(rawPivotRangePart) : null;
656
+ const pivotHeaderRow = parsedPivotRange ? parsedPivotRange.startRow : 0;
657
+ const pivotStartCol = parsedPivotRange ? parsedPivotRange.startColumn : 0;
658
+ const pivotEndCol = (() => {
659
+ if (parsedPivotRange) {
660
+ return Math.max(parsedPivotRange.startColumn, parsedPivotRange.endColumn);
661
+ }
662
+ let maxCol = 6;
663
+ for (let c = 0; c < 20; c++) {
664
+ const v = pivotSrcSheet.getCellRaw(0, c)?.v;
665
+ if (v !== void 0 && v !== null && String(v).trim() !== "") {
666
+ maxCol = Math.max(maxCol, c);
667
+ }
668
+ }
669
+ return maxCol;
670
+ })();
671
+ const pivotSourceColumns = [];
672
+ for (let c = pivotStartCol; c <= pivotEndCol; c++) {
673
+ const hdrVal = pivotSrcSheet.getCellRaw(pivotHeaderRow, c)?.v;
674
+ const hdrStr = hdrVal !== void 0 && hdrVal !== null ? String(hdrVal).trim() : "";
675
+ pivotSourceColumns.push({
676
+ colIndex: c,
677
+ rawHeader: hdrStr || `${colIndexToLetter(c)}\u5217`,
678
+ label: hdrStr ? `${hdrStr} (${colIndexToLetter(c)})` : `${colIndexToLetter(c)} \u5217`
679
+ });
680
+ }
681
+ const resolvePivotFieldCol = (fieldOrIdx, fallback = 0) => {
682
+ if (typeof fieldOrIdx === "number" && Number.isFinite(fieldOrIdx)) return fieldOrIdx;
683
+ if (typeof fieldOrIdx === "string") {
684
+ const tStr = fieldOrIdx.trim();
685
+ if (/^\d+$/.test(tStr)) return Number(tStr);
686
+ const hit = pivotSourceColumns.find(
687
+ (col) => col.rawHeader.toLowerCase() === tStr.toLowerCase()
688
+ );
689
+ if (hit) return hit.colIndex;
690
+ }
691
+ return fallback;
692
+ };
693
+ const getPivotColumnLabel = (colIdx) => pivotSourceColumns.find((col) => col.colIndex === colIdx)?.rawHeader ?? `${colIndexToLetter(Math.max(0, colIdx))}\u5217`;
694
+ const getPivotFilterChoices = (colIdx) => {
695
+ const startR = pivotHeaderRow + 1;
696
+ const endR = parsedPivotRange ? Math.min(parsedPivotRange.endRow, startR + 200) : Math.min(pivotSrcSheet.getRowCount() - 1, startR + 150);
697
+ const seen = /* @__PURE__ */ new Set();
698
+ for (let r = startR; r <= endR; r++) {
699
+ const val = pivotSrcSheet.getCellRaw(r, colIdx)?.v;
700
+ if (val !== void 0 && val !== null && String(val).trim() !== "") {
701
+ seen.add(String(val).trim());
702
+ if (seen.size >= 24) break;
703
+ }
704
+ }
705
+ return Array.from(seen);
706
+ };
580
707
  const activeAlertRule = cellMeta.alertRules?.[0];
581
708
  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;
582
709
  const currentExprMatch = typeof activeCell?.v === "string" ? activeCell.v.trim().match(singleExprRe) : null;
@@ -1986,7 +2113,9 @@ var SheetInspectorPanel = () => {
1986
2113
  /* @__PURE__ */ jsx2("option", { value: "ellipse", children: "\u692D\u5706 (Ellipse)" }),
1987
2114
  /* @__PURE__ */ jsx2("option", { value: "diamond", children: "\u83F1\u5F62 (Diamond)" }),
1988
2115
  /* @__PURE__ */ jsx2("option", { value: "arrow", children: "\u53F3\u5411\u7BAD\u5934 (Arrow)" }),
1989
- /* @__PURE__ */ jsx2("option", { value: "callout", children: "\u6807\u6CE8\u6C14\u6CE1 (Callout)" })
2116
+ /* @__PURE__ */ jsx2("option", { value: "callout", children: "\u6807\u6CE8\u6C14\u6CE1 (Callout)" }),
2117
+ /* @__PURE__ */ jsx2("option", { value: "line", children: "\u8FDE\u63A5\u76F4\u7EBF (Line)" }),
2118
+ /* @__PURE__ */ jsx2("option", { value: "connector", children: "\u7BAD\u5934\u8FDE\u63A5\u7EBF (Connector)" })
1990
2119
  ]
1991
2120
  }
1992
2121
  )
@@ -2037,7 +2166,8 @@ var SheetInspectorPanel = () => {
2037
2166
  left: 360,
2038
2167
  top: 56,
2039
2168
  width: 148,
2040
- height: 60
2169
+ height: shapeType === "line" || shapeType === "connector" ? 36 : 60,
2170
+ ...shapeType === "connector" ? { arrowEnd: true } : {}
2041
2171
  }
2042
2172
  });
2043
2173
  },
@@ -2319,24 +2449,30 @@ var SheetInspectorPanel = () => {
2319
2449
  className: "yudao-sheet-btn is-soft-primary",
2320
2450
  onClick: () => {
2321
2451
  const isSmoothEnabled = chartType.startsWith("line") && (chartSmooth || chartType.endsWith("Smooth"));
2322
- templateService.addOrUpdateChart(unitId, {
2323
- id: `chart-${generateRandomId(5)}`,
2324
- sheetId: sheet.getSheetId(),
2325
- title: chartTitle || "\u4E1A\u52A1\u7EDF\u8BA1\u56FE",
2326
- chartType,
2327
- categoryRange: chartCatRange || "B6:B9",
2328
- valueRange: chartValRange || "F6:F9",
2329
- smooth: isSmoothEnabled ? true : void 0,
2330
- showLegend: chartShowLegend,
2331
- legendPosition: chartShowLegend ? chartLegendPos : void 0,
2332
- trendline: chartTrendline !== "none" ? chartTrendline : void 0,
2333
- yAxisScale: chartLogScale ? "log" : "linear",
2334
- threeD: chartThreeD ? { rotX: 15, rotY: 20 } : void 0,
2335
- left: 520,
2336
- top: 48 + charts.length * 24,
2337
- width: 280,
2338
- height: 175
2452
+ const newId = `chart-${generateRandomId(5)}`;
2453
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2454
+ unitId,
2455
+ chart: {
2456
+ id: newId,
2457
+ sheetId: sheet.getSheetId(),
2458
+ title: chartTitle || "\u4E1A\u52A1\u7EDF\u8BA1\u56FE",
2459
+ chartType,
2460
+ categoryRange: chartCatRange || "B6:B9",
2461
+ valueRange: chartValRange || "F6:F9",
2462
+ smooth: isSmoothEnabled ? true : void 0,
2463
+ showLegend: chartShowLegend,
2464
+ legendPosition: chartShowLegend ? chartLegendPos : "none",
2465
+ trendline: chartTrendline !== "none" ? chartTrendline : void 0,
2466
+ ...chartType === "combo" ? { comboLineSeriesIndices: [1], secondarySeriesIndices: [1] } : {},
2467
+ yAxisScale: chartLogScale ? "log" : "linear",
2468
+ threeD: chartThreeD ? { rotX: 15, rotY: 20 } : void 0,
2469
+ left: 520,
2470
+ top: 48 + charts.length * 24,
2471
+ width: 280,
2472
+ height: 175
2473
+ }
2339
2474
  });
2475
+ setSelectedChartId(newId);
2340
2476
  },
2341
2477
  children: "+ \u63D2\u5165\u6D6E\u52A8\u56FE\u8868"
2342
2478
  }
@@ -2375,140 +2511,1208 @@ var SheetInspectorPanel = () => {
2375
2511
  }
2376
2512
  )
2377
2513
  ] }),
2378
- /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2379
- /* @__PURE__ */ jsx2("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" }),
2380
- /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2381
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2382
- /* @__PURE__ */ jsx2("span", { children: "\u884C\u7EF4\u5EA6\u5217" }),
2383
- /* @__PURE__ */ jsx2("select", { value: pivotRowCol, onChange: (e) => setPivotRowCol(Number(e.target.value)), children: [0, 1, 2, 3, 4, 5].map((c) => /* @__PURE__ */ jsxs2("option", { value: c, children: [
2384
- colIndexToLetter(c),
2385
- " \u5217"
2386
- ] }, c)) })
2387
- ] }),
2388
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2389
- /* @__PURE__ */ jsx2("span", { children: "\u5217\u7EF4\u5EA6\uFF08\u53EF\u9009\u4EA4\u53C9\uFF09" }),
2390
- /* @__PURE__ */ jsxs2("select", { value: pivotColCol, onChange: (e) => setPivotColCol(Number(e.target.value)), children: [
2391
- /* @__PURE__ */ jsx2("option", { value: -1, children: "\u65E0\uFF08\u4E00\u7EF4\u6C47\u603B\uFF09" }),
2392
- [0, 1, 2, 3, 4, 5].map((c) => /* @__PURE__ */ jsxs2("option", { value: c, children: [
2393
- colIndexToLetter(c),
2394
- " \u5217"
2395
- ] }, c))
2396
- ] })
2397
- ] }),
2398
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2399
- /* @__PURE__ */ jsx2("span", { children: "\u7EDF\u8BA1\u6570\u503C\u5217" }),
2400
- /* @__PURE__ */ jsx2("select", { value: pivotValCol, onChange: (e) => setPivotValCol(Number(e.target.value)), children: [0, 1, 2, 3, 4, 5, 6].map((c) => /* @__PURE__ */ jsxs2("option", { value: c, children: [
2401
- colIndexToLetter(c),
2402
- " \u5217"
2403
- ] }, c)) })
2404
- ] }),
2405
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2406
- /* @__PURE__ */ jsx2("span", { children: "\u805A\u5408\u51FD\u6570 (11 \u79CD)" }),
2407
- /* @__PURE__ */ jsxs2(
2408
- "select",
2409
- {
2410
- value: pivotAgg,
2411
- onChange: (e) => setPivotAgg(e.target.value),
2412
- children: [
2413
- /* @__PURE__ */ jsx2("option", { value: "SUM", children: "\u6C42\u548C (SUM)" }),
2414
- /* @__PURE__ */ jsx2("option", { value: "COUNT", children: "\u6570\u503C\u8BA1\u6570 (COUNT)" }),
2415
- /* @__PURE__ */ jsx2("option", { value: "COUNTA", children: "\u975E\u7A7A\u8BA1\u6570 (COUNTA)" }),
2416
- /* @__PURE__ */ jsx2("option", { value: "AVG", children: "\u5747\u503C (AVG)" }),
2417
- /* @__PURE__ */ jsx2("option", { value: "MAX", children: "\u6700\u5927\u503C (MAX)" }),
2418
- /* @__PURE__ */ jsx2("option", { value: "MIN", children: "\u6700\u5C0F\u503C (MIN)" }),
2419
- /* @__PURE__ */ jsx2("option", { value: "PRODUCT", children: "\u4E58\u79EF (PRODUCT)" }),
2420
- /* @__PURE__ */ jsx2("option", { value: "STDEV", children: "\u6837\u672C\u6807\u51C6\u5DEE (STDEV)" }),
2421
- /* @__PURE__ */ jsx2("option", { value: "STDEVP", children: "\u603B\u4F53\u6807\u51C6\u5DEE (STDEVP)" }),
2422
- /* @__PURE__ */ jsx2("option", { value: "VAR", children: "\u6837\u672C\u65B9\u5DEE (VAR)" }),
2423
- /* @__PURE__ */ jsx2("option", { value: "VARP", children: "\u603B\u4F53\u65B9\u5DEE (VARP)" })
2424
- ]
2425
- }
2426
- )
2427
- ] }),
2428
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2429
- /* @__PURE__ */ jsx2("span", { children: "\u503C\u663E\u793A\u65B9\u5F0F" }),
2430
- /* @__PURE__ */ jsxs2(
2431
- "select",
2432
- {
2433
- value: pivotShowAs,
2434
- onChange: (e) => setPivotShowAs(e.target.value),
2435
- children: [
2436
- /* @__PURE__ */ jsx2("option", { value: "normal", children: "\u5E38\u89C4\u6C47\u603B\u503C" }),
2437
- /* @__PURE__ */ jsx2("option", { value: "percentOfGrandTotal", children: "\u5360\u603B\u8BA1\u767E\u5206\u6BD4" }),
2438
- /* @__PURE__ */ jsx2("option", { value: "percentOfRow", children: "\u5360\u884C\u6C47\u603B\u767E\u5206\u6BD4" }),
2439
- /* @__PURE__ */ jsx2("option", { value: "percentOfColumn", children: "\u5360\u5217\u6C47\u603B\u767E\u5206\u6BD4" }),
2440
- /* @__PURE__ */ jsx2("option", { value: "runningTotal", children: "\u6309\u5217\u7D2F\u8BA1\u503C" }),
2441
- /* @__PURE__ */ jsx2("option", { value: "rankDesc", children: "\u964D\u5E8F\u6392\u540D" })
2442
- ]
2443
- }
2444
- )
2445
- ] }),
2446
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2447
- /* @__PURE__ */ jsx2("span", { children: "\u884C\u7EF4\u5EA6\u65E5\u671F\u5206\u7EC4" }),
2448
- /* @__PURE__ */ jsxs2(
2449
- "select",
2450
- {
2451
- value: pivotDateGroup,
2452
- onChange: (e) => setPivotDateGroup(e.target.value),
2453
- children: [
2454
- /* @__PURE__ */ jsx2("option", { value: "", children: "\u4E0D\u6309\u65E5\u671F\u5206\u7EC4" }),
2455
- /* @__PURE__ */ jsx2("option", { value: "year", children: "\u6309\u5E74\u4EFD (YYYY\u5E74)" }),
2456
- /* @__PURE__ */ jsx2("option", { value: "quarter", children: "\u6309\u5B63\u5EA6 (YYYY-QN)" }),
2457
- /* @__PURE__ */ jsx2("option", { value: "month", children: "\u6309\u6708\u4EFD (YYYY-MM)" })
2458
- ]
2459
- }
2460
- )
2461
- ] })
2462
- ] }),
2463
- /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer", fontSize: 11.5 }, children: [
2464
- /* @__PURE__ */ jsx2(
2465
- "input",
2466
- {
2467
- type: "checkbox",
2468
- checked: withPivotChart,
2469
- onChange: (e) => setWithPivotChart(e.target.checked)
2470
- }
2471
- ),
2472
- /* @__PURE__ */ jsx2("span", { children: "\u540C\u6B65\u751F\u6210\u900F\u89C6\u8054\u52A8\u56FE\u8868 (Pivot Chart)" })
2473
- ] }),
2474
- /* @__PURE__ */ jsxs2(
2475
- "button",
2514
+ editingChart && /* @__PURE__ */ jsxs2(
2515
+ "div",
2476
2516
  {
2477
- type: "button",
2478
- className: "yudao-sheet-btn",
2479
- onClick: () => commandService.syncExecuteCommand(GenerateSheetPivotCommand.id, {
2480
- unitId,
2481
- sourceSubUnitId: sheet.getSheetId(),
2482
- pivotConfig: {
2483
- rowDimCols: [pivotRowCol],
2484
- colDimCols: pivotColCol >= 0 ? [pivotColCol] : [],
2485
- valueCol: pivotValCol,
2486
- aggFunc: pivotAgg,
2487
- valueShowAs: pivotShowAs,
2488
- ...pivotDateGroup ? { dateGroupBy: pivotDateGroup } : {},
2489
- showSubtotals: true,
2490
- withPivotChart,
2491
- pivotChartType: chartType
2492
- }
2493
- }),
2517
+ "data-testid": "yudao-chart-inspector",
2518
+ style: {
2519
+ display: "flex",
2520
+ flexDirection: "column",
2521
+ gap: 6,
2522
+ padding: "7px 8px",
2523
+ borderRadius: 6,
2524
+ background: "#F9FAFB",
2525
+ border: "1px solid #E3E5EA"
2526
+ },
2494
2527
  children: [
2495
- "\u751F\u6210\u4EA4\u53C9\u900F\u89C6\u8868 Sheet",
2496
- withPivotChart ? " + \u8054\u52A8\u900F\u89C6\u56FE" : ""
2528
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2529
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u56FE\u8868\u914D\u7F6E\u5668 (Chart Inspector)" }),
2530
+ /* @__PURE__ */ jsx2(
2531
+ "button",
2532
+ {
2533
+ type: "button",
2534
+ className: "yudao-sheet-btn",
2535
+ style: { padding: "1px 6px", fontSize: 10.5, color: "#DC2626" },
2536
+ onClick: () => {
2537
+ commandService.syncExecuteCommand(RemoveSheetChartCommand.id, {
2538
+ unitId,
2539
+ chartId: editingChart.id
2540
+ });
2541
+ },
2542
+ children: "\u5220\u9664\u56FE\u8868"
2543
+ }
2544
+ )
2545
+ ] }),
2546
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2547
+ /* @__PURE__ */ jsx2("span", { children: "\u9009\u62E9\u5DF2\u6709\u56FE\u8868" }),
2548
+ /* @__PURE__ */ jsx2(
2549
+ "select",
2550
+ {
2551
+ "data-testid": "yudao-chart-inspector-select",
2552
+ value: editingChart.id,
2553
+ onChange: (e) => setSelectedChartId(e.target.value),
2554
+ children: charts.map((c) => /* @__PURE__ */ jsxs2("option", { value: c.id, children: [
2555
+ c.title || c.id,
2556
+ " (",
2557
+ c.chartType,
2558
+ c.pivotId ? " \xB7 \u900F\u89C6\u56FE" : "",
2559
+ ")"
2560
+ ] }, c.id))
2561
+ }
2562
+ )
2563
+ ] }),
2564
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 4 }, children: [
2565
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2566
+ /* @__PURE__ */ jsx2("span", { children: "\u56FE\u8868\u7C7B\u578B" }),
2567
+ /* @__PURE__ */ jsx2(
2568
+ "select",
2569
+ {
2570
+ "data-testid": "yudao-chart-inspector-type",
2571
+ value: editingChart.chartType,
2572
+ onChange: (e) => {
2573
+ const nextType = e.target.value;
2574
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2575
+ unitId,
2576
+ chart: {
2577
+ ...editingChart,
2578
+ chartType: nextType,
2579
+ ...nextType === "combo" && !editingChart.comboLineSeriesIndices?.length ? {
2580
+ comboLineSeriesIndices: [1],
2581
+ secondarySeriesIndices: editingChart.secondarySeriesIndices?.length ? editingChart.secondarySeriesIndices : [1]
2582
+ } : {}
2583
+ }
2584
+ });
2585
+ },
2586
+ children: SHEET_CHART_TYPE_GROUPS.map((grp) => /* @__PURE__ */ jsx2("optgroup", { label: grp.label, children: grp.options.map((opt) => /* @__PURE__ */ jsx2("option", { value: opt.value, children: opt.label }, opt.value)) }, grp.category))
2587
+ }
2588
+ )
2589
+ ] }),
2590
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2591
+ /* @__PURE__ */ jsx2("span", { children: "\u6807\u9898" }),
2592
+ /* @__PURE__ */ jsx2(
2593
+ "input",
2594
+ {
2595
+ type: "text",
2596
+ value: editingChart.title,
2597
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2598
+ unitId,
2599
+ chart: { ...editingChart, title: e.target.value }
2600
+ })
2601
+ }
2602
+ )
2603
+ ] })
2604
+ ] }),
2605
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2606
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2607
+ /* @__PURE__ */ jsx2("span", { children: "X / \u5206\u7C7B\u533A\u95F4" }),
2608
+ /* @__PURE__ */ jsx2(
2609
+ "input",
2610
+ {
2611
+ "data-testid": "yudao-chart-inspector-cat-range",
2612
+ type: "text",
2613
+ value: editingChart.categoryRange,
2614
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2615
+ unitId,
2616
+ chart: { ...editingChart, categoryRange: e.target.value }
2617
+ })
2618
+ }
2619
+ )
2620
+ ] }),
2621
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2622
+ /* @__PURE__ */ jsx2("span", { children: "Y / \u7CFB\u5217\u533A\u95F4" }),
2623
+ /* @__PURE__ */ jsx2(
2624
+ "input",
2625
+ {
2626
+ "data-testid": "yudao-chart-inspector-val-range",
2627
+ type: "text",
2628
+ value: editingChart.valueRange,
2629
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2630
+ unitId,
2631
+ chart: { ...editingChart, valueRange: e.target.value }
2632
+ })
2633
+ }
2634
+ )
2635
+ ] })
2636
+ ] }),
2637
+ (() => {
2638
+ const trObj = typeof editingChart.trendline === "object" && editingChart.trendline ? editingChart.trendline : typeof editingChart.trendline === "string" && editingChart.trendline !== "none" ? {
2639
+ type: editingChart.trendline === "movingAverage" ? "movingAvg" : editingChart.trendline
2640
+ } : void 0;
2641
+ const trType = trObj?.type ?? "none";
2642
+ const errObj = Array.isArray(editingChart.errorBars) ? editingChart.errorBars[0] ? {
2643
+ type: editingChart.errorBars[0].valueType === "fixed" ? "fixedVal" : editingChart.errorBars[0].valueType === "stdev" ? "stdDev" : "percentage",
2644
+ value: editingChart.errorBars[0].value
2645
+ } : void 0 : editingChart.errorBars;
2646
+ const errType = errObj?.type ?? "none";
2647
+ 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";
2648
+ const hasSecondary = (editingChart.secondarySeriesIndices?.length ?? 0) > 0;
2649
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
2650
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2651
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2652
+ /* @__PURE__ */ jsx2("span", { children: "\u8D8B\u52BF\u7EBF\u7C7B\u578B" }),
2653
+ /* @__PURE__ */ jsxs2(
2654
+ "select",
2655
+ {
2656
+ "data-testid": "yudao-chart-inspector-trendline",
2657
+ value: trType,
2658
+ onChange: (e) => {
2659
+ const val = e.target.value;
2660
+ const nextTr = val === "none" ? void 0 : {
2661
+ type: val,
2662
+ ...val === "polynomial" ? { order: trObj?.order ?? 2 } : {},
2663
+ ...val === "movingAvg" ? { period: trObj?.period ?? 2 } : {},
2664
+ displayEquation: trObj?.displayEquation,
2665
+ displayRSqr: trObj?.displayRSqr
2666
+ };
2667
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2668
+ unitId,
2669
+ chart: { ...editingChart, trendline: nextTr }
2670
+ });
2671
+ },
2672
+ children: [
2673
+ /* @__PURE__ */ jsx2("option", { value: "none", children: "\u65E0\u8D8B\u52BF\u7EBF" }),
2674
+ /* @__PURE__ */ jsx2("option", { value: "linear", children: "\u7EBF\u6027 (Linear)" }),
2675
+ /* @__PURE__ */ jsx2("option", { value: "exponential", children: "\u6307\u6570 (Exponential)" }),
2676
+ /* @__PURE__ */ jsx2("option", { value: "polynomial", children: "\u591A\u9879\u5F0F (Polynomial)" }),
2677
+ /* @__PURE__ */ jsx2("option", { value: "movingAvg", children: "\u79FB\u52A8\u5E73\u5747 (MovingAvg)" })
2678
+ ]
2679
+ }
2680
+ )
2681
+ ] }),
2682
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2683
+ /* @__PURE__ */ jsx2("span", { children: "\u8BEF\u5DEE\u7EBF (Error Bars)" }),
2684
+ /* @__PURE__ */ jsxs2(
2685
+ "select",
2686
+ {
2687
+ "data-testid": "yudao-chart-inspector-errbars",
2688
+ value: errType,
2689
+ onChange: (e) => {
2690
+ const val = e.target.value;
2691
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2692
+ unitId,
2693
+ chart: {
2694
+ ...editingChart,
2695
+ errorBars: val === "none" ? void 0 : {
2696
+ type: val,
2697
+ value: errObj?.value ?? (val === "percentage" ? 10 : val === "fixedVal" ? 5 : 1)
2698
+ }
2699
+ }
2700
+ });
2701
+ },
2702
+ children: [
2703
+ /* @__PURE__ */ jsx2("option", { value: "none", children: "\u65E0\u8BEF\u5DEE\u7EBF" }),
2704
+ /* @__PURE__ */ jsx2("option", { value: "percentage", children: "\u767E\u5206\u6BD4 (%)" }),
2705
+ /* @__PURE__ */ jsx2("option", { value: "fixedVal", children: "\u56FA\u5B9A\u503C (Fixed)" }),
2706
+ /* @__PURE__ */ jsx2("option", { value: "stdDev", children: "\u6807\u51C6\u5DEE (StdDev)" })
2707
+ ]
2708
+ }
2709
+ )
2710
+ ] })
2711
+ ] }),
2712
+ (trType === "polynomial" || trType === "movingAvg" || errType !== "none") && /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2713
+ trType === "polynomial" && /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2714
+ /* @__PURE__ */ jsx2("span", { children: "\u591A\u9879\u5F0F\u9636\u6570 (2-6)" }),
2715
+ /* @__PURE__ */ jsx2(
2716
+ "input",
2717
+ {
2718
+ type: "number",
2719
+ min: 2,
2720
+ max: 6,
2721
+ value: trObj?.order ?? 2,
2722
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2723
+ unitId,
2724
+ chart: {
2725
+ ...editingChart,
2726
+ trendline: {
2727
+ ...trObj,
2728
+ order: Math.max(2, Math.min(6, Number(e.target.value) || 2))
2729
+ }
2730
+ }
2731
+ })
2732
+ }
2733
+ )
2734
+ ] }),
2735
+ trType === "movingAvg" && /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2736
+ /* @__PURE__ */ jsx2("span", { children: "\u79FB\u52A8\u5E73\u5747\u5468\u671F" }),
2737
+ /* @__PURE__ */ jsx2(
2738
+ "input",
2739
+ {
2740
+ type: "number",
2741
+ min: 2,
2742
+ max: 12,
2743
+ value: trObj?.period ?? 2,
2744
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2745
+ unitId,
2746
+ chart: {
2747
+ ...editingChart,
2748
+ trendline: {
2749
+ ...trObj,
2750
+ period: Math.max(2, Math.min(12, Number(e.target.value) || 2))
2751
+ }
2752
+ }
2753
+ })
2754
+ }
2755
+ )
2756
+ ] }),
2757
+ errType !== "none" && /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2758
+ /* @__PURE__ */ jsx2("span", { children: "\u8BEF\u5DEE\u6570\u503C" }),
2759
+ /* @__PURE__ */ jsx2(
2760
+ "input",
2761
+ {
2762
+ type: "number",
2763
+ min: 0,
2764
+ step: "0.5",
2765
+ value: errObj?.value ?? 10,
2766
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2767
+ unitId,
2768
+ chart: {
2769
+ ...editingChart,
2770
+ errorBars: {
2771
+ type: errType,
2772
+ value: Math.max(0, Number(e.target.value) || 0)
2773
+ }
2774
+ }
2775
+ })
2776
+ }
2777
+ )
2778
+ ] })
2779
+ ] }),
2780
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr auto", gap: 6, alignItems: "end" }, children: [
2781
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2782
+ /* @__PURE__ */ jsx2("span", { children: "\u56FE\u4F8B\u4F4D\u7F6E" }),
2783
+ /* @__PURE__ */ jsxs2(
2784
+ "select",
2785
+ {
2786
+ "data-testid": "yudao-chart-inspector-legend",
2787
+ value: legVal,
2788
+ onChange: (e) => {
2789
+ const nextPos = e.target.value;
2790
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2791
+ unitId,
2792
+ chart: {
2793
+ ...editingChart,
2794
+ showLegend: nextPos !== "none",
2795
+ legendPosition: nextPos
2796
+ }
2797
+ });
2798
+ },
2799
+ children: [
2800
+ /* @__PURE__ */ jsx2("option", { value: "r", children: "\u53F3\u4FA7 (Right)" }),
2801
+ /* @__PURE__ */ jsx2("option", { value: "t", children: "\u9876\u90E8 (Top)" }),
2802
+ /* @__PURE__ */ jsx2("option", { value: "b", children: "\u5E95\u90E8 (Bottom)" }),
2803
+ /* @__PURE__ */ jsx2("option", { value: "l", children: "\u5DE6\u4FA7 (Left)" }),
2804
+ /* @__PURE__ */ jsx2("option", { value: "none", children: "\u9690\u85CF\u56FE\u4F8B (None)" })
2805
+ ]
2806
+ }
2807
+ )
2808
+ ] }),
2809
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2810
+ /* @__PURE__ */ jsx2("span", { children: "\u4E3B\u8272" }),
2811
+ /* @__PURE__ */ jsx2(
2812
+ "input",
2813
+ {
2814
+ type: "color",
2815
+ style: { width: 38, height: 25, padding: 1 },
2816
+ value: editingChart.palette?.[0] ?? "#2C53F1",
2817
+ onChange: (e) => {
2818
+ const rest = editingChart.palette?.slice(1) ?? [
2819
+ "#10B981",
2820
+ "#F59E0B",
2821
+ "#EF4444",
2822
+ "#8B5CF6"
2823
+ ];
2824
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2825
+ unitId,
2826
+ chart: {
2827
+ ...editingChart,
2828
+ palette: [e.target.value, ...rest]
2829
+ }
2830
+ });
2831
+ }
2832
+ }
2833
+ )
2834
+ ] })
2835
+ ] }),
2836
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexWrap: "wrap", gap: 10, fontSize: 11, color: "#31363F" }, children: [
2837
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
2838
+ /* @__PURE__ */ jsx2(
2839
+ "input",
2840
+ {
2841
+ "data-testid": "yudao-chart-inspector-secondary-axis",
2842
+ type: "checkbox",
2843
+ checked: hasSecondary,
2844
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2845
+ unitId,
2846
+ chart: {
2847
+ ...editingChart,
2848
+ secondarySeriesIndices: e.target.checked ? [1] : void 0,
2849
+ ...e.target.checked && editingChart.chartType === "combo" ? {
2850
+ comboLineSeriesIndices: editingChart.comboLineSeriesIndices?.length ? editingChart.comboLineSeriesIndices : [1]
2851
+ } : {}
2852
+ }
2853
+ })
2854
+ }
2855
+ ),
2856
+ /* @__PURE__ */ jsx2("span", { children: "\u53CC\u8F74\u6B21\u5750\u6807\u8F74 (\u53F3\u4FA7\u8F74)" })
2857
+ ] }),
2858
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
2859
+ /* @__PURE__ */ jsx2(
2860
+ "input",
2861
+ {
2862
+ type: "checkbox",
2863
+ checked: Boolean(editingChart.showDataLabels || editingChart.dataLabels?.showVal),
2864
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2865
+ unitId,
2866
+ chart: {
2867
+ ...editingChart,
2868
+ showDataLabels: e.target.checked,
2869
+ dataLabels: {
2870
+ ...editingChart.dataLabels,
2871
+ showVal: e.target.checked
2872
+ }
2873
+ }
2874
+ })
2875
+ }
2876
+ ),
2877
+ /* @__PURE__ */ jsx2("span", { children: "\u663E\u793A\u6570\u636E\u6807\u7B7E" })
2878
+ ] }),
2879
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
2880
+ /* @__PURE__ */ jsx2(
2881
+ "input",
2882
+ {
2883
+ type: "checkbox",
2884
+ checked: Boolean(editingChart.smooth),
2885
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2886
+ unitId,
2887
+ chart: { ...editingChart, smooth: e.target.checked }
2888
+ })
2889
+ }
2890
+ ),
2891
+ /* @__PURE__ */ jsx2("span", { children: "\u5E73\u6ED1\u66F2\u7EBF" })
2892
+ ] })
2893
+ ] })
2894
+ ] });
2895
+ })()
2497
2896
  ]
2498
2897
  }
2499
2898
  ),
2500
2899
  /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2501
- /* @__PURE__ */ jsx2("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u4EA4\u4E92\u5F0F\u5207\u7247\u5668 & \u65E5\u671F\u65F6\u95F4\u8F74\u7B5B\u9009" }),
2502
- /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 0.8fr 1fr", gap: 4 }, children: [
2503
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2504
- /* @__PURE__ */ jsx2("span", { children: "\u6570\u636E\u533A\u95F4" }),
2505
- /* @__PURE__ */ jsx2(
2506
- "input",
2507
- {
2508
- type: "text",
2509
- value: slicerRange,
2510
- onChange: (e) => setSlicerRange(e.target.value)
2511
- }
2900
+ /* @__PURE__ */ jsxs2(
2901
+ "div",
2902
+ {
2903
+ "data-testid": "yudao-pivot-configurator",
2904
+ style: { display: "flex", flexDirection: "column", gap: 6 },
2905
+ children: [
2906
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2907
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u56DB\u8C61\u9650\u6570\u636E\u900F\u89C6\u8868\u914D\u7F6E\u9762\u677F" }),
2908
+ pivots.length > 0 && /* @__PURE__ */ jsxs2(
2909
+ "span",
2910
+ {
2911
+ style: {
2912
+ fontSize: 10,
2913
+ padding: "1px 6px",
2914
+ borderRadius: 999,
2915
+ background: "#EEF2FF",
2916
+ color: "#2C53F1"
2917
+ },
2918
+ children: [
2919
+ pivots.length,
2920
+ " \u4E2A\u900F\u89C6\u8868"
2921
+ ]
2922
+ }
2923
+ )
2924
+ ] }),
2925
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2926
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2927
+ /* @__PURE__ */ jsx2("span", { children: "\u900F\u89C6\u8868\u5B9E\u4F8B" }),
2928
+ /* @__PURE__ */ jsxs2(
2929
+ "select",
2930
+ {
2931
+ "data-testid": "yudao-pivot-instance-select",
2932
+ value: activePivot ? activePivot.id : "__new__",
2933
+ onChange: (e) => {
2934
+ const nextId = e.target.value;
2935
+ setSelectedPivotId(nextId);
2936
+ const found = pivots.find((p) => p.id === nextId);
2937
+ if (found) {
2938
+ setPivotSourceRange(found.sourceRange ?? "");
2939
+ const rows = (found.rowFields ?? found.rowDimCols ?? []).map(
2940
+ (f) => resolvePivotFieldCol(f, 0)
2941
+ );
2942
+ const cols = (found.columnFields ?? found.colDimCols ?? []).map(
2943
+ (f) => resolvePivotFieldCol(f, 0)
2944
+ );
2945
+ const vals = found.valueFields && found.valueFields.length > 0 ? found.valueFields.map((vf) => ({
2946
+ ...vf,
2947
+ colIndex: resolvePivotFieldCol(vf.colIndex ?? vf.field, 0)
2948
+ })) : [{ colIndex: found.valueCol ?? 0, aggFunc: found.aggFunc ?? "SUM" }];
2949
+ setPivotRowFields(rows);
2950
+ setPivotColFields(cols);
2951
+ setPivotValueFields(vals);
2952
+ setPivotFilterFields(
2953
+ (found.filterFields ?? []).map((ff) => ({
2954
+ ...ff,
2955
+ colIndex: resolvePivotFieldCol(ff.colIndex ?? ff.field, 0)
2956
+ }))
2957
+ );
2958
+ setPivotCalcFields(found.calculatedFields ?? []);
2959
+ if (rows[0] !== void 0) setPivotRowCol(rows[0]);
2960
+ setPivotColCol(cols[0] ?? -1);
2961
+ if (vals[0]) {
2962
+ setPivotValCol(resolvePivotFieldCol(vals[0].colIndex ?? vals[0].field, 0));
2963
+ setPivotAgg(vals[0].aggFunc);
2964
+ }
2965
+ }
2966
+ },
2967
+ children: [
2968
+ /* @__PURE__ */ jsx2("option", { value: "__new__", children: "+ \u65B0\u5EFA\u6570\u636E\u900F\u89C6\u8868" }),
2969
+ pivots.map((p, idx) => /* @__PURE__ */ jsx2("option", { value: p.id ?? `__idx_${idx}`, children: p.name || p.targetSheetName || `PivotTable${idx + 1}` }, p.id ?? idx))
2970
+ ]
2971
+ }
2972
+ )
2973
+ ] }),
2974
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2975
+ /* @__PURE__ */ jsx2("span", { children: "\u6570\u636E\u6E90\u533A\u95F4 (\u53EF\u9009)" }),
2976
+ /* @__PURE__ */ jsx2(
2977
+ "input",
2978
+ {
2979
+ type: "text",
2980
+ placeholder: "\u9ED8\u8BA4\u6574\u8868\u5982 A1:F20",
2981
+ value: pivotSourceRange,
2982
+ onChange: (e) => setPivotSourceRange(e.target.value)
2983
+ }
2984
+ )
2985
+ ] })
2986
+ ] }),
2987
+ /* @__PURE__ */ jsxs2(
2988
+ "div",
2989
+ {
2990
+ style: {
2991
+ padding: "5px 6px",
2992
+ borderRadius: 6,
2993
+ background: "#F8FAFC",
2994
+ border: "1px solid #E2E8F0",
2995
+ display: "flex",
2996
+ flexDirection: "column",
2997
+ gap: 4
2998
+ },
2999
+ children: [
3000
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
3001
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#475569" }, children: "\u6E90\u5B57\u6BB5\u5217\u8868\uFF08\u70B9\u51FB\u6DFB\u52A0\u81F3\uFF1A" }),
3002
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", gap: 2 }, children: [
3003
+ { key: "rows", label: "\u884C" },
3004
+ { key: "cols", label: "\u5217" },
3005
+ { key: "values", label: "\u503C" },
3006
+ { key: "filters", label: "\u7B5B\u9009" }
3007
+ ].map((q) => /* @__PURE__ */ jsx2(
3008
+ "button",
3009
+ {
3010
+ type: "button",
3011
+ onClick: () => setPivotChipTarget(q.key),
3012
+ style: {
3013
+ fontSize: 10,
3014
+ padding: "1px 5px",
3015
+ borderRadius: 4,
3016
+ border: "1px solid",
3017
+ borderColor: pivotChipTarget === q.key ? "#2C53F1" : "#CBD5E1",
3018
+ background: pivotChipTarget === q.key ? "#EEF2FF" : "#FFFFFF",
3019
+ color: pivotChipTarget === q.key ? "#2C53F1" : "#475569",
3020
+ cursor: "pointer"
3021
+ },
3022
+ children: q.label
3023
+ },
3024
+ q.key
3025
+ )) })
3026
+ ] }),
3027
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: pivotSourceColumns.map((col) => /* @__PURE__ */ jsxs2(
3028
+ "button",
3029
+ {
3030
+ type: "button",
3031
+ onClick: () => {
3032
+ if (pivotChipTarget === "rows") {
3033
+ if (!pivotRowFields.includes(col.colIndex)) {
3034
+ const next = [...pivotRowFields, col.colIndex];
3035
+ setPivotRowFields(next);
3036
+ setPivotRowCol(next[0]);
3037
+ }
3038
+ } else if (pivotChipTarget === "cols") {
3039
+ if (!pivotColFields.includes(col.colIndex)) {
3040
+ const next = [...pivotColFields, col.colIndex];
3041
+ setPivotColFields(next);
3042
+ setPivotColCol(next[0]);
3043
+ }
3044
+ } else if (pivotChipTarget === "values") {
3045
+ const next = [
3046
+ ...pivotValueFields,
3047
+ { colIndex: col.colIndex, aggFunc: "sum" }
3048
+ ];
3049
+ setPivotValueFields(next);
3050
+ setPivotValCol(col.colIndex);
3051
+ } else if (!pivotFilterFields.some((f) => f.colIndex === col.colIndex)) {
3052
+ setPivotFilterFields([...pivotFilterFields, { colIndex: col.colIndex }]);
3053
+ }
3054
+ },
3055
+ style: {
3056
+ fontSize: 10.5,
3057
+ padding: "2px 6px",
3058
+ borderRadius: 999,
3059
+ border: "1px solid #CBD5E1",
3060
+ background: "#FFFFFF",
3061
+ color: "#1E293B",
3062
+ cursor: "pointer"
3063
+ },
3064
+ children: [
3065
+ "+ ",
3066
+ col.label
3067
+ ]
3068
+ },
3069
+ col.colIndex
3070
+ )) })
3071
+ ]
3072
+ }
3073
+ ),
3074
+ /* @__PURE__ */ jsxs2(
3075
+ "div",
3076
+ {
3077
+ "data-testid": "yudao-pivot-quadrants",
3078
+ style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 5 },
3079
+ children: [
3080
+ /* @__PURE__ */ jsxs2(
3081
+ "div",
3082
+ {
3083
+ style: {
3084
+ padding: "5px 6px",
3085
+ borderRadius: 6,
3086
+ border: "1px solid #E2E8F0",
3087
+ background: "#FFFFFF",
3088
+ display: "flex",
3089
+ flexDirection: "column",
3090
+ gap: 4,
3091
+ minHeight: 74
3092
+ },
3093
+ children: [
3094
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3095
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u7B5B\u9009\u5668 (Filters)" }),
3096
+ /* @__PURE__ */ jsxs2(
3097
+ "select",
3098
+ {
3099
+ value: "",
3100
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3101
+ onChange: (e) => {
3102
+ if (e.target.value === "") return;
3103
+ const c = Number(e.target.value);
3104
+ if (!pivotFilterFields.some((f) => f.colIndex === c)) {
3105
+ setPivotFilterFields([...pivotFilterFields, { colIndex: c }]);
3106
+ }
3107
+ },
3108
+ children: [
3109
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3110
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3111
+ ]
3112
+ }
3113
+ )
3114
+ ] }),
3115
+ pivotFilterFields.length === 0 && /* @__PURE__ */ jsx2("span", { style: { fontSize: 10, color: "#94A3B8" }, children: "\u672A\u8BBE\u7F6E\u62A5\u8868\u7B5B\u9009" }),
3116
+ pivotFilterFields.map((ff, ffIdx) => {
3117
+ const ffCol = resolvePivotFieldCol(ff.colIndex ?? ff.field, 0);
3118
+ const choices = getPivotFilterChoices(ffCol);
3119
+ return /* @__PURE__ */ jsxs2(
3120
+ "div",
3121
+ {
3122
+ style: {
3123
+ display: "flex",
3124
+ flexDirection: "column",
3125
+ gap: 2,
3126
+ padding: "3px 4px",
3127
+ borderRadius: 4,
3128
+ background: "#F8FAFC",
3129
+ fontSize: 10
3130
+ },
3131
+ children: [
3132
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
3133
+ /* @__PURE__ */ jsx2("span", { style: { fontWeight: 500, color: "#1E293B" }, children: getPivotColumnLabel(ffCol) }),
3134
+ /* @__PURE__ */ jsx2(
3135
+ "button",
3136
+ {
3137
+ type: "button",
3138
+ onClick: () => setPivotFilterFields(
3139
+ pivotFilterFields.filter((_, idx) => idx !== ffIdx)
3140
+ ),
3141
+ style: {
3142
+ border: "none",
3143
+ background: "transparent",
3144
+ color: "#64748B",
3145
+ cursor: "pointer",
3146
+ fontSize: 11,
3147
+ padding: "0 2px"
3148
+ },
3149
+ children: "\xD7"
3150
+ }
3151
+ )
3152
+ ] }),
3153
+ /* @__PURE__ */ jsxs2(
3154
+ "select",
3155
+ {
3156
+ value: ff.selectedValues?.length === 1 ? ff.selectedValues[0] : "__all__",
3157
+ style: { fontSize: 10, padding: "1px 2px" },
3158
+ onChange: (e) => {
3159
+ const v = e.target.value;
3160
+ setPivotFilterFields(
3161
+ pivotFilterFields.map(
3162
+ (item, idx) => idx === ffIdx ? { ...item, selectedValues: v === "__all__" ? void 0 : [v] } : item
3163
+ )
3164
+ );
3165
+ },
3166
+ children: [
3167
+ /* @__PURE__ */ jsx2("option", { value: "__all__", children: "(\u5168\u90E8\u503C)" }),
3168
+ choices.map((val) => /* @__PURE__ */ jsx2("option", { value: val, children: val }, val))
3169
+ ]
3170
+ }
3171
+ )
3172
+ ]
3173
+ },
3174
+ `${ffCol}-${ffIdx}`
3175
+ );
3176
+ })
3177
+ ]
3178
+ }
3179
+ ),
3180
+ /* @__PURE__ */ jsxs2(
3181
+ "div",
3182
+ {
3183
+ style: {
3184
+ padding: "5px 6px",
3185
+ borderRadius: 6,
3186
+ border: "1px solid #E2E8F0",
3187
+ background: "#FFFFFF",
3188
+ display: "flex",
3189
+ flexDirection: "column",
3190
+ gap: 4,
3191
+ minHeight: 74
3192
+ },
3193
+ children: [
3194
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3195
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u5217\u7EF4\u5EA6 (Columns)" }),
3196
+ /* @__PURE__ */ jsxs2(
3197
+ "select",
3198
+ {
3199
+ value: "",
3200
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3201
+ onChange: (e) => {
3202
+ if (e.target.value === "") return;
3203
+ const c = Number(e.target.value);
3204
+ if (!pivotColFields.includes(c)) {
3205
+ const next = [...pivotColFields, c];
3206
+ setPivotColFields(next);
3207
+ setPivotColCol(next[0]);
3208
+ }
3209
+ },
3210
+ children: [
3211
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3212
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3213
+ ]
3214
+ }
3215
+ )
3216
+ ] }),
3217
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexWrap: "wrap", gap: 3 }, children: [
3218
+ pivotColFields.length === 0 && /* @__PURE__ */ jsx2("span", { style: { fontSize: 10, color: "#94A3B8" }, children: "\u65E0\u4EA4\u53C9\u5217\uFF08\u4E00\u7EF4\u6C47\u603B\uFF09" }),
3219
+ pivotColFields.map((colIdx) => /* @__PURE__ */ jsxs2(
3220
+ "span",
3221
+ {
3222
+ style: {
3223
+ display: "inline-flex",
3224
+ alignItems: "center",
3225
+ gap: 3,
3226
+ fontSize: 10,
3227
+ padding: "2px 5px",
3228
+ borderRadius: 4,
3229
+ background: "#EEF2FF",
3230
+ color: "#2C53F1"
3231
+ },
3232
+ children: [
3233
+ getPivotColumnLabel(colIdx),
3234
+ /* @__PURE__ */ jsx2(
3235
+ "button",
3236
+ {
3237
+ type: "button",
3238
+ onClick: () => {
3239
+ const next = pivotColFields.filter((x) => x !== colIdx);
3240
+ setPivotColFields(next);
3241
+ setPivotColCol(next[0] ?? -1);
3242
+ },
3243
+ style: {
3244
+ border: "none",
3245
+ background: "transparent",
3246
+ color: "#2C53F1",
3247
+ cursor: "pointer",
3248
+ padding: 0,
3249
+ fontSize: 11
3250
+ },
3251
+ children: "\xD7"
3252
+ }
3253
+ )
3254
+ ]
3255
+ },
3256
+ colIdx
3257
+ ))
3258
+ ] })
3259
+ ]
3260
+ }
3261
+ ),
3262
+ /* @__PURE__ */ jsxs2(
3263
+ "div",
3264
+ {
3265
+ style: {
3266
+ padding: "5px 6px",
3267
+ borderRadius: 6,
3268
+ border: "1px solid #E2E8F0",
3269
+ background: "#FFFFFF",
3270
+ display: "flex",
3271
+ flexDirection: "column",
3272
+ gap: 4,
3273
+ minHeight: 74
3274
+ },
3275
+ children: [
3276
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3277
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u884C\u7EF4\u5EA6 (Rows)" }),
3278
+ /* @__PURE__ */ jsxs2(
3279
+ "select",
3280
+ {
3281
+ value: "",
3282
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3283
+ onChange: (e) => {
3284
+ if (e.target.value === "") return;
3285
+ const c = Number(e.target.value);
3286
+ if (!pivotRowFields.includes(c)) {
3287
+ const next = [...pivotRowFields, c];
3288
+ setPivotRowFields(next);
3289
+ setPivotRowCol(next[0]);
3290
+ }
3291
+ },
3292
+ children: [
3293
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3294
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3295
+ ]
3296
+ }
3297
+ )
3298
+ ] }),
3299
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: 3 }, children: pivotRowFields.map((colIdx) => /* @__PURE__ */ jsxs2(
3300
+ "span",
3301
+ {
3302
+ style: {
3303
+ display: "inline-flex",
3304
+ alignItems: "center",
3305
+ gap: 3,
3306
+ fontSize: 10,
3307
+ padding: "2px 5px",
3308
+ borderRadius: 4,
3309
+ background: "#ECFDF5",
3310
+ color: "#047857"
3311
+ },
3312
+ children: [
3313
+ getPivotColumnLabel(colIdx),
3314
+ pivotRowFields.length > 1 && /* @__PURE__ */ jsx2(
3315
+ "button",
3316
+ {
3317
+ type: "button",
3318
+ onClick: () => {
3319
+ const next = pivotRowFields.filter((x) => x !== colIdx);
3320
+ setPivotRowFields(next);
3321
+ if (next[0] !== void 0) setPivotRowCol(next[0]);
3322
+ },
3323
+ style: {
3324
+ border: "none",
3325
+ background: "transparent",
3326
+ color: "#047857",
3327
+ cursor: "pointer",
3328
+ padding: 0,
3329
+ fontSize: 11
3330
+ },
3331
+ children: "\xD7"
3332
+ }
3333
+ )
3334
+ ]
3335
+ },
3336
+ colIdx
3337
+ )) })
3338
+ ]
3339
+ }
3340
+ ),
3341
+ /* @__PURE__ */ jsxs2(
3342
+ "div",
3343
+ {
3344
+ style: {
3345
+ padding: "5px 6px",
3346
+ borderRadius: 6,
3347
+ border: "1px solid #E2E8F0",
3348
+ background: "#FFFFFF",
3349
+ display: "flex",
3350
+ flexDirection: "column",
3351
+ gap: 4,
3352
+ minHeight: 74
3353
+ },
3354
+ children: [
3355
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3356
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u503C\u6307\u6807 (Values)" }),
3357
+ /* @__PURE__ */ jsxs2(
3358
+ "select",
3359
+ {
3360
+ value: "",
3361
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3362
+ onChange: (e) => {
3363
+ if (e.target.value === "") return;
3364
+ const c = Number(e.target.value);
3365
+ const next = [
3366
+ ...pivotValueFields,
3367
+ { colIndex: c, aggFunc: "sum" }
3368
+ ];
3369
+ setPivotValueFields(next);
3370
+ setPivotValCol(c);
3371
+ },
3372
+ children: [
3373
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3374
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3375
+ ]
3376
+ }
3377
+ )
3378
+ ] }),
3379
+ pivotValueFields.map((vf, idx) => {
3380
+ const vfCol = resolvePivotFieldCol(vf.colIndex ?? vf.field, 0);
3381
+ return /* @__PURE__ */ jsxs2(
3382
+ "div",
3383
+ {
3384
+ style: {
3385
+ display: "flex",
3386
+ alignItems: "center",
3387
+ justifyContent: "space-between",
3388
+ gap: 2,
3389
+ padding: "2px 4px",
3390
+ borderRadius: 4,
3391
+ background: "#FFFBEB",
3392
+ fontSize: 10
3393
+ },
3394
+ children: [
3395
+ /* @__PURE__ */ jsx2(
3396
+ "span",
3397
+ {
3398
+ style: {
3399
+ color: "#92400E",
3400
+ fontWeight: 500,
3401
+ overflow: "hidden",
3402
+ textOverflow: "ellipsis",
3403
+ whiteSpace: "nowrap"
3404
+ },
3405
+ children: getPivotColumnLabel(vfCol)
3406
+ }
3407
+ ),
3408
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: 2 }, children: [
3409
+ /* @__PURE__ */ jsxs2(
3410
+ "select",
3411
+ {
3412
+ value: vf.aggFunc.toLowerCase(),
3413
+ style: { fontSize: 10, padding: "0 2px" },
3414
+ onChange: (e) => {
3415
+ const nextAgg = e.target.value;
3416
+ const next = pivotValueFields.map(
3417
+ (item, i) => i === idx ? { ...item, aggFunc: nextAgg } : item
3418
+ );
3419
+ setPivotValueFields(next);
3420
+ if (idx === 0) setPivotAgg(nextAgg.toUpperCase());
3421
+ },
3422
+ children: [
3423
+ /* @__PURE__ */ jsx2("option", { value: "sum", children: "\u6C42\u548C" }),
3424
+ /* @__PURE__ */ jsx2("option", { value: "count", children: "\u8BA1\u6570" }),
3425
+ /* @__PURE__ */ jsx2("option", { value: "avg", children: "\u5E73\u5747" }),
3426
+ /* @__PURE__ */ jsx2("option", { value: "max", children: "\u6700\u5927" }),
3427
+ /* @__PURE__ */ jsx2("option", { value: "min", children: "\u6700\u5C0F" }),
3428
+ /* @__PURE__ */ jsx2("option", { value: "stdev", children: "\u6807\u51C6\u5DEE" }),
3429
+ /* @__PURE__ */ jsx2("option", { value: "var", children: "\u65B9\u5DEE" })
3430
+ ]
3431
+ }
3432
+ ),
3433
+ pivotValueFields.length > 1 && /* @__PURE__ */ jsx2(
3434
+ "button",
3435
+ {
3436
+ type: "button",
3437
+ onClick: () => setPivotValueFields(pivotValueFields.filter((_, i) => i !== idx)),
3438
+ style: {
3439
+ border: "none",
3440
+ background: "transparent",
3441
+ color: "#92400E",
3442
+ cursor: "pointer",
3443
+ padding: 0,
3444
+ fontSize: 11
3445
+ },
3446
+ children: "\xD7"
3447
+ }
3448
+ )
3449
+ ] })
3450
+ ]
3451
+ },
3452
+ `${vfCol}-${idx}`
3453
+ );
3454
+ })
3455
+ ]
3456
+ }
3457
+ )
3458
+ ]
3459
+ }
3460
+ ),
3461
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
3462
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3463
+ /* @__PURE__ */ jsx2("span", { children: "\u503C\u663E\u793A\u65B9\u5F0F" }),
3464
+ /* @__PURE__ */ jsxs2(
3465
+ "select",
3466
+ {
3467
+ value: pivotShowAs,
3468
+ onChange: (e) => setPivotShowAs(e.target.value),
3469
+ children: [
3470
+ /* @__PURE__ */ jsx2("option", { value: "normal", children: "\u5E38\u89C4\u6C47\u603B\u503C" }),
3471
+ /* @__PURE__ */ jsx2("option", { value: "percentOfGrandTotal", children: "\u5360\u603B\u8BA1\u767E\u5206\u6BD4" }),
3472
+ /* @__PURE__ */ jsx2("option", { value: "percentOfRow", children: "\u5360\u884C\u6C47\u603B\u767E\u5206\u6BD4" }),
3473
+ /* @__PURE__ */ jsx2("option", { value: "percentOfColumn", children: "\u5360\u5217\u6C47\u603B\u767E\u5206\u6BD4" }),
3474
+ /* @__PURE__ */ jsx2("option", { value: "runningTotal", children: "\u6309\u5217\u7D2F\u8BA1\u503C" }),
3475
+ /* @__PURE__ */ jsx2("option", { value: "rankDesc", children: "\u964D\u5E8F\u6392\u540D" })
3476
+ ]
3477
+ }
3478
+ )
3479
+ ] }),
3480
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3481
+ /* @__PURE__ */ jsx2("span", { children: "\u884C\u65E5\u671F\u5206\u7EC4" }),
3482
+ /* @__PURE__ */ jsxs2(
3483
+ "select",
3484
+ {
3485
+ value: pivotDateGroup,
3486
+ onChange: (e) => setPivotDateGroup(e.target.value),
3487
+ children: [
3488
+ /* @__PURE__ */ jsx2("option", { value: "", children: "\u4E0D\u6309\u65E5\u671F\u5206\u7EC4" }),
3489
+ /* @__PURE__ */ jsx2("option", { value: "year", children: "\u6309\u5E74\u4EFD (YYYY\u5E74)" }),
3490
+ /* @__PURE__ */ jsx2("option", { value: "quarter", children: "\u6309\u5B63\u5EA6 (YYYY-QN)" }),
3491
+ /* @__PURE__ */ jsx2("option", { value: "month", children: "\u6309\u6708\u4EFD (YYYY-MM)" })
3492
+ ]
3493
+ }
3494
+ )
3495
+ ] })
3496
+ ] }),
3497
+ /* @__PURE__ */ jsxs2(
3498
+ "div",
3499
+ {
3500
+ style: {
3501
+ display: "flex",
3502
+ flexDirection: "column",
3503
+ gap: 4,
3504
+ padding: "5px 6px",
3505
+ borderRadius: 6,
3506
+ background: "#F8FAFC",
3507
+ border: "1px solid #E2E8F0"
3508
+ },
3509
+ children: [
3510
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u8BA1\u7B97\u5B57\u6BB5 (Calculated Fields)" }),
3511
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.8fr 1.2fr auto", gap: 4 }, children: [
3512
+ /* @__PURE__ */ jsx2(
3513
+ "input",
3514
+ {
3515
+ type: "text",
3516
+ placeholder: "\u540D\u79F0\u5982 \u6BDB\u5229\u7387",
3517
+ style: { fontSize: 10.5, padding: "3px 5px" },
3518
+ value: calcFieldName,
3519
+ onChange: (e) => setCalcFieldName(e.target.value)
3520
+ }
3521
+ ),
3522
+ /* @__PURE__ */ jsx2(
3523
+ "input",
3524
+ {
3525
+ type: "text",
3526
+ placeholder: "\u516C\u5F0F\u5982 \u5229\u6DA6 / \u9500\u552E\u989D",
3527
+ style: { fontSize: 10.5, padding: "3px 5px" },
3528
+ value: calcFieldFormula,
3529
+ onChange: (e) => setCalcFieldFormula(e.target.value)
3530
+ }
3531
+ ),
3532
+ /* @__PURE__ */ jsx2(
3533
+ "button",
3534
+ {
3535
+ type: "button",
3536
+ className: "yudao-sheet-btn",
3537
+ style: { padding: "2px 6px", fontSize: 10.5 },
3538
+ onClick: () => {
3539
+ const n = calcFieldName.trim();
3540
+ const f = calcFieldFormula.trim();
3541
+ if (!n || !f) return;
3542
+ setPivotCalcFields([
3543
+ ...pivotCalcFields.filter((c) => c.name !== n),
3544
+ { name: n, formula: f }
3545
+ ]);
3546
+ setCalcFieldName("");
3547
+ setCalcFieldFormula("");
3548
+ },
3549
+ children: "+ \u6DFB\u52A0"
3550
+ }
3551
+ )
3552
+ ] }),
3553
+ pivotCalcFields.length > 0 && /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: pivotCalcFields.map((cf) => /* @__PURE__ */ jsxs2(
3554
+ "span",
3555
+ {
3556
+ style: {
3557
+ display: "inline-flex",
3558
+ alignItems: "center",
3559
+ gap: 4,
3560
+ fontSize: 10,
3561
+ padding: "2px 6px",
3562
+ borderRadius: 4,
3563
+ background: "#F3E8FF",
3564
+ color: "#6B21A8"
3565
+ },
3566
+ children: [
3567
+ cf.name,
3568
+ " = ",
3569
+ cf.formula,
3570
+ /* @__PURE__ */ jsx2(
3571
+ "button",
3572
+ {
3573
+ type: "button",
3574
+ onClick: () => setPivotCalcFields(pivotCalcFields.filter((x) => x.name !== cf.name)),
3575
+ style: {
3576
+ border: "none",
3577
+ background: "transparent",
3578
+ color: "#6B21A8",
3579
+ cursor: "pointer",
3580
+ padding: 0,
3581
+ fontSize: 11
3582
+ },
3583
+ children: "\xD7"
3584
+ }
3585
+ )
3586
+ ]
3587
+ },
3588
+ cf.name
3589
+ )) })
3590
+ ]
3591
+ }
3592
+ ),
3593
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer", fontSize: 11 }, children: [
3594
+ /* @__PURE__ */ jsx2(
3595
+ "input",
3596
+ {
3597
+ type: "checkbox",
3598
+ checked: withPivotChart,
3599
+ onChange: (e) => setWithPivotChart(e.target.checked)
3600
+ }
3601
+ ),
3602
+ /* @__PURE__ */ jsx2("span", { children: "\u65B0\u5EFA\u65F6\u540C\u6B65\u751F\u6210\u8054\u52A8\u900F\u89C6\u56FE (PivotChart)" })
3603
+ ] }),
3604
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 4 }, children: [
3605
+ /* @__PURE__ */ jsx2(
3606
+ "button",
3607
+ {
3608
+ "data-testid": "yudao-pivot-apply-btn",
3609
+ type: "button",
3610
+ className: "yudao-sheet-btn is-soft-primary",
3611
+ onClick: () => {
3612
+ const effectiveRows = pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol];
3613
+ const effectiveVals = pivotValueFields.length > 0 ? pivotValueFields : [{ colIndex: pivotValCol, aggFunc: pivotAgg }];
3614
+ const firstVal = effectiveVals[0];
3615
+ const builtConfig = {
3616
+ ...activePivot ?? {},
3617
+ ...pivotSourceRange.trim() ? { sourceRange: pivotSourceRange.trim() } : {},
3618
+ rowDimCols: effectiveRows,
3619
+ rowFields: effectiveRows,
3620
+ colDimCols: pivotColFields,
3621
+ columnFields: pivotColFields,
3622
+ valueCol: firstVal.colIndex,
3623
+ aggFunc: firstVal.aggFunc.toUpperCase(),
3624
+ valueFields: effectiveVals,
3625
+ filterFields: pivotFilterFields.length > 0 ? pivotFilterFields : void 0,
3626
+ calculatedFields: pivotCalcFields.length > 0 ? pivotCalcFields : void 0,
3627
+ valueShowAs: pivotShowAs,
3628
+ ...pivotDateGroup ? { dateGroupBy: pivotDateGroup } : {},
3629
+ showSubtotals: true,
3630
+ withPivotChart,
3631
+ pivotChartType: chartType
3632
+ };
3633
+ if (activePivot?.id) {
3634
+ templateService.addOrUpdatePivot(unitId, builtConfig);
3635
+ commandService.syncExecuteCommand(RefreshSheetPivotCommand.id, {
3636
+ unitId,
3637
+ pivotId: activePivot.id
3638
+ });
3639
+ } else {
3640
+ commandService.syncExecuteCommand(GenerateSheetPivotCommand.id, {
3641
+ unitId,
3642
+ sourceSubUnitId: sheet.getSheetId(),
3643
+ pivotConfig: builtConfig
3644
+ });
3645
+ }
3646
+ },
3647
+ children: activePivot ? "\u5E94\u7528\u5E76\u5237\u65B0\u900F\u89C6\u8868" : `\u751F\u6210\u900F\u89C6\u8868${withPivotChart ? " + \u900F\u89C6\u56FE" : ""}`
3648
+ }
3649
+ ),
3650
+ /* @__PURE__ */ jsx2(
3651
+ "button",
3652
+ {
3653
+ "data-testid": "yudao-pivot-create-chart-btn",
3654
+ type: "button",
3655
+ className: "yudao-sheet-btn",
3656
+ onClick: () => {
3657
+ const targetPivot = activePivot ?? pivots[pivots.length - 1];
3658
+ if (targetPivot?.targetSheetId) {
3659
+ const pivotSheet = workbook.getSheetBySheetId(targetPivot.targetSheetId);
3660
+ if (pivotSheet) {
3661
+ const pSnap = pivotSheet.getConfig();
3662
+ const linked = buildPivotLinkedChart(
3663
+ pSnap,
3664
+ { ...targetPivot, pivotChartType: chartType },
3665
+ targetPivot.targetSheetId
3666
+ );
3667
+ if (linked) {
3668
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
3669
+ unitId,
3670
+ chart: linked
3671
+ });
3672
+ setSelectedChartId(linked.id);
3673
+ return;
3674
+ }
3675
+ }
3676
+ }
3677
+ commandService.syncExecuteCommand(GenerateSheetPivotCommand.id, {
3678
+ unitId,
3679
+ sourceSubUnitId: sheet.getSheetId(),
3680
+ pivotConfig: {
3681
+ ...pivotSourceRange.trim() ? { sourceRange: pivotSourceRange.trim() } : {},
3682
+ rowDimCols: pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol],
3683
+ rowFields: pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol],
3684
+ colDimCols: pivotColFields,
3685
+ columnFields: pivotColFields,
3686
+ valueCol: pivotValueFields[0]?.colIndex ?? pivotValCol,
3687
+ aggFunc: (pivotValueFields[0]?.aggFunc ?? pivotAgg).toUpperCase(),
3688
+ valueFields: pivotValueFields,
3689
+ filterFields: pivotFilterFields.length > 0 ? pivotFilterFields : void 0,
3690
+ calculatedFields: pivotCalcFields.length > 0 ? pivotCalcFields : void 0,
3691
+ showSubtotals: true,
3692
+ withPivotChart: true,
3693
+ pivotChartType: chartType
3694
+ }
3695
+ });
3696
+ },
3697
+ children: "+ \u521B\u5EFA\u900F\u89C6\u56FE"
3698
+ }
3699
+ )
3700
+ ] })
3701
+ ]
3702
+ }
3703
+ ),
3704
+ /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
3705
+ /* @__PURE__ */ jsx2("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u4EA4\u4E92\u5F0F\u5207\u7247\u5668 & \u65E5\u671F\u65F6\u95F4\u8F74\u7B5B\u9009" }),
3706
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 0.8fr 1fr", gap: 4 }, children: [
3707
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3708
+ /* @__PURE__ */ jsx2("span", { children: "\u6570\u636E\u533A\u95F4" }),
3709
+ /* @__PURE__ */ jsx2(
3710
+ "input",
3711
+ {
3712
+ type: "text",
3713
+ value: slicerRange,
3714
+ onChange: (e) => setSlicerRange(e.target.value)
3715
+ }
2512
3716
  )
2513
3717
  ] }),
2514
3718
  /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
@@ -2619,11 +3823,11 @@ var SheetInspectorPanel = () => {
2619
3823
  ),
2620
3824
  /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2621
3825
  /* @__PURE__ */ jsxs2("div", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: [
2622
- "\u516C\u5F0F\u5BA1\u6838 \xB7 \u76D1\u89C6\u7A97\u53E3 \xB7 \u5355\u53D8\u91CF\u6C42\u89E3 (",
3826
+ "\u516C\u5F0F\u6C42\u503C\u4E0E\u76D1\u89C6\u7A97\u53E3 (",
2623
3827
  activeRef,
2624
3828
  ")"
2625
3829
  ] }),
2626
- /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 4 }, children: [
3830
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2627
3831
  /* @__PURE__ */ jsx2(
2628
3832
  "button",
2629
3833
  {
@@ -2640,26 +3844,7 @@ var SheetInspectorPanel = () => {
2640
3844
  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`
2641
3845
  );
2642
3846
  },
2643
- children: "\u8FFD\u8E2A\u5F15\u7528\u5355\u5143\u683C"
2644
- }
2645
- ),
2646
- /* @__PURE__ */ jsx2(
2647
- "button",
2648
- {
2649
- type: "button",
2650
- className: "yudao-sheet-btn",
2651
- onClick: () => {
2652
- const nodes = traceFormulaDependents(
2653
- workbook.save(),
2654
- sheet.getSheetId(),
2655
- activeRow,
2656
- activeCol
2657
- );
2658
- setAuditOutput(
2659
- nodes.length > 0 ? `\u4ECE\u5C5E\u9879: ${nodes.map((n) => `${n.sheetName}!${n.cellRef}`).join(", ")}` : `${activeRef} \u65E0\u4ECE\u5C5E\u4F9D\u8D56\u516C\u5F0F`
2660
- );
2661
- },
2662
- children: "\u8FFD\u8E2A\u4ECE\u5C5E\u5355\u5143\u683C"
3847
+ children: "\u8FFD\u8E2A\u5F15\u7528\u5355\u5143\u683C"
2663
3848
  }
2664
3849
  ),
2665
3850
  /* @__PURE__ */ jsx2(
@@ -2668,57 +3853,243 @@ var SheetInspectorPanel = () => {
2668
3853
  type: "button",
2669
3854
  className: "yudao-sheet-btn",
2670
3855
  onClick: () => {
2671
- const steps = evaluateFormulaSteps(
3856
+ const nodes = traceFormulaDependents(
2672
3857
  workbook.save(),
2673
3858
  sheet.getSheetId(),
2674
3859
  activeRow,
2675
3860
  activeCol
2676
3861
  );
2677
- setAuditOutput(steps.join(" => "));
2678
- },
2679
- children: "\u516C\u5F0F\u5206\u6B65\u6C42\u503C"
2680
- }
2681
- )
2682
- ] }),
2683
- /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2684
- /* @__PURE__ */ jsxs2("span", { style: { fontSize: 11, color: "#4E5565" }, children: [
2685
- "\u76D1\u89C6\u7A97\u53E3 (",
2686
- (metadata.watchCells ?? []).length,
2687
- " \u9879)"
2688
- ] }),
2689
- /* @__PURE__ */ jsxs2(
2690
- "button",
2691
- {
2692
- type: "button",
2693
- className: "yudao-sheet-btn",
2694
- style: { padding: "2px 8px", fontSize: 10.5 },
2695
- onClick: () => {
2696
- const curList = metadata.watchCells ?? [];
2697
- const sid = sheet.getSheetId();
2698
- if (curList.some((w) => w.sheetId === sid && w.row === activeRow && w.col === activeCol)) {
2699
- return;
2700
- }
2701
- templateService.setTemplateMetadata(unitId, {
2702
- ...metadata,
2703
- watchCells: [
2704
- ...curList,
2705
- {
2706
- id: `watch-${generateRandomId(5)}`,
2707
- sheetId: sid,
2708
- row: activeRow,
2709
- col: activeCol,
2710
- cellRef: activeRef
2711
- }
2712
- ]
2713
- });
3862
+ setAuditOutput(
3863
+ nodes.length > 0 ? `\u4ECE\u5C5E\u9879: ${nodes.map((n) => `${n.sheetName}!${n.cellRef}`).join(", ")}` : `${activeRef} \u65E0\u4ECE\u5C5E\u4F9D\u8D56\u516C\u5F0F`
3864
+ );
2714
3865
  },
2715
- children: [
2716
- "+ \u76D1\u89C6\u5F53\u524D\u5355\u5143\u683C ",
2717
- activeRef
2718
- ]
3866
+ children: "\u8FFD\u8E2A\u4ECE\u5C5E\u5355\u5143\u683C"
2719
3867
  }
2720
3868
  )
2721
3869
  ] }),
3870
+ /* @__PURE__ */ jsxs2(
3871
+ "div",
3872
+ {
3873
+ "data-testid": "yudao-formula-step-evaluator",
3874
+ style: {
3875
+ display: "flex",
3876
+ flexDirection: "column",
3877
+ gap: 5,
3878
+ padding: "6px 7px",
3879
+ borderRadius: 6,
3880
+ background: "#F8FAFC",
3881
+ border: "1px solid #E2E8F0"
3882
+ },
3883
+ children: [
3884
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr auto", gap: 4 }, children: [
3885
+ /* @__PURE__ */ jsx2(
3886
+ "button",
3887
+ {
3888
+ "data-testid": "yudao-formula-step-into",
3889
+ type: "button",
3890
+ className: "yudao-sheet-btn is-soft-primary",
3891
+ onClick: () => {
3892
+ const key = `${sheet.getSheetId()}:${activeRef}`;
3893
+ const steps = evaluateFormulaSteps(
3894
+ workbook.save(),
3895
+ sheet.getSheetId(),
3896
+ activeRow,
3897
+ activeCol
3898
+ );
3899
+ setEvalCellKey(key);
3900
+ setEvalSteps(steps);
3901
+ const nextIdx = evalCellKey === key && evalSteps.length === steps.length ? Math.min(steps.length - 1, evalStepIdx + 1) : 0;
3902
+ setEvalStepIdx(nextIdx);
3903
+ setAuditOutput(steps.join(" => "));
3904
+ },
3905
+ children: "\u6B65\u5165\u6C42\u503C (Step Into)"
3906
+ }
3907
+ ),
3908
+ /* @__PURE__ */ jsx2(
3909
+ "button",
3910
+ {
3911
+ "data-testid": "yudao-formula-eval-next",
3912
+ type: "button",
3913
+ className: "yudao-sheet-btn",
3914
+ onClick: () => {
3915
+ const key = `${sheet.getSheetId()}:${activeRef}`;
3916
+ const steps = evalCellKey === key && evalSteps.length > 0 ? evalSteps : evaluateFormulaSteps(
3917
+ workbook.save(),
3918
+ sheet.getSheetId(),
3919
+ activeRow,
3920
+ activeCol
3921
+ );
3922
+ const nextIdx = evalCellKey === key ? Math.min(steps.length - 1, evalStepIdx + 1) : 0;
3923
+ setEvalCellKey(key);
3924
+ setEvalSteps(steps);
3925
+ setEvalStepIdx(nextIdx);
3926
+ setAuditOutput(steps[nextIdx] ?? "");
3927
+ },
3928
+ children: "\u4E0B\u4E00\u6B65\u6C42\u503C (Next)"
3929
+ }
3930
+ ),
3931
+ /* @__PURE__ */ jsx2(
3932
+ "button",
3933
+ {
3934
+ type: "button",
3935
+ className: "yudao-sheet-btn",
3936
+ style: { padding: "2px 7px", fontSize: 10.5 },
3937
+ onClick: () => {
3938
+ setEvalStepIdx(0);
3939
+ },
3940
+ children: "\u91CD\u7F6E"
3941
+ }
3942
+ )
3943
+ ] }),
3944
+ evalSteps.length > 0 && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: 3, fontSize: 10.5 }, children: [
3945
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", justifyContent: "space-between", color: "#475569" }, children: [
3946
+ /* @__PURE__ */ jsxs2("span", { children: [
3947
+ "\u5F53\u524D\u6C42\u503C\u5B50\u8868\u8FBE\u5F0F (",
3948
+ evalCellKey.split(":")[1] ?? activeRef,
3949
+ ")"
3950
+ ] }),
3951
+ /* @__PURE__ */ jsxs2("span", { style: { fontWeight: 600, color: "#2C53F1" }, children: [
3952
+ "\u6B65\u9AA4 ",
3953
+ Math.min(evalStepIdx + 1, evalSteps.length),
3954
+ " / ",
3955
+ evalSteps.length
3956
+ ] })
3957
+ ] }),
3958
+ /* @__PURE__ */ jsx2(
3959
+ "div",
3960
+ {
3961
+ "data-testid": "yudao-formula-current-step",
3962
+ style: {
3963
+ padding: "4px 6px",
3964
+ borderRadius: 4,
3965
+ background: "#EEF2FF",
3966
+ border: "1px solid #C7D2FE",
3967
+ color: "#1E1B4B",
3968
+ fontFamily: "monospace",
3969
+ wordBreak: "break-all"
3970
+ },
3971
+ children: evalSteps[Math.min(evalStepIdx, evalSteps.length - 1)]
3972
+ }
3973
+ )
3974
+ ] })
3975
+ ]
3976
+ }
3977
+ ),
3978
+ /* @__PURE__ */ jsxs2(
3979
+ "div",
3980
+ {
3981
+ "data-testid": "yudao-formula-watch-window",
3982
+ style: { display: "flex", flexDirection: "column", gap: 4 },
3983
+ children: [
3984
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
3985
+ /* @__PURE__ */ jsxs2("span", { style: { fontSize: 11, fontWeight: 600, color: "#4E5565" }, children: [
3986
+ "\u76D1\u89C6\u7A97\u53E3 (",
3987
+ (metadata.watchCells ?? []).length,
3988
+ " \u9879)"
3989
+ ] }),
3990
+ /* @__PURE__ */ jsxs2(
3991
+ "button",
3992
+ {
3993
+ type: "button",
3994
+ className: "yudao-sheet-btn",
3995
+ style: { padding: "2px 8px", fontSize: 10.5 },
3996
+ onClick: () => {
3997
+ const curList = metadata.watchCells ?? [];
3998
+ const sid = sheet.getSheetId();
3999
+ if (curList.some((w) => w.sheetId === sid && w.row === activeRow && w.col === activeCol)) {
4000
+ return;
4001
+ }
4002
+ templateService.setTemplateMetadata(unitId, {
4003
+ ...metadata,
4004
+ watchCells: [
4005
+ ...curList,
4006
+ {
4007
+ id: `watch-${generateRandomId(5)}`,
4008
+ sheetId: sid,
4009
+ row: activeRow,
4010
+ col: activeCol,
4011
+ cellRef: activeRef
4012
+ }
4013
+ ]
4014
+ });
4015
+ },
4016
+ children: [
4017
+ "+ \u76D1\u89C6\u5F53\u524D\u683C ",
4018
+ activeRef
4019
+ ]
4020
+ }
4021
+ )
4022
+ ] }),
4023
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr auto", gap: 4 }, children: [
4024
+ /* @__PURE__ */ jsx2(
4025
+ "input",
4026
+ {
4027
+ "data-testid": "yudao-watch-ref-input",
4028
+ type: "text",
4029
+ placeholder: "\u8F93\u5165\u5F15\u7528\u5982 Sheet1!D10 \u6216 F10",
4030
+ style: { fontSize: 11, padding: "3px 6px" },
4031
+ value: watchInputRef,
4032
+ onChange: (e) => setWatchInputRef(e.target.value)
4033
+ }
4034
+ ),
4035
+ /* @__PURE__ */ jsx2(
4036
+ "button",
4037
+ {
4038
+ "data-testid": "yudao-watch-add-input-btn",
4039
+ type: "button",
4040
+ className: "yudao-sheet-btn is-soft-primary",
4041
+ style: { padding: "2px 8px", fontSize: 10.5 },
4042
+ onClick: () => {
4043
+ const raw = watchInputRef.trim();
4044
+ if (!raw) return;
4045
+ let targetSheet = sheet;
4046
+ let cellPart = raw;
4047
+ const bangIdx = raw.lastIndexOf("!");
4048
+ if (bangIdx > 0) {
4049
+ const sheetToken = raw.slice(0, bangIdx).trim().replace(/^'+|'+$/g, "");
4050
+ cellPart = raw.slice(bangIdx + 1).trim();
4051
+ const snap = workbook.save();
4052
+ for (const sid2 of snap.sheetOrder ?? Object.keys(snap.sheets ?? {})) {
4053
+ const ws = workbook.getSheetBySheetId(sid2);
4054
+ if (ws && (ws.getName() === sheetToken || ws.getSheetId() === sheetToken)) {
4055
+ targetSheet = ws;
4056
+ break;
4057
+ }
4058
+ }
4059
+ }
4060
+ const cleanCell = cellPart.replace(/\$/g, "").toUpperCase();
4061
+ const coords = a1ToCellCoords(cleanCell);
4062
+ if (!coords) return;
4063
+ const sid = targetSheet.getSheetId();
4064
+ const curList = metadata.watchCells ?? [];
4065
+ if (curList.some(
4066
+ (w) => w.sheetId === sid && w.row === coords.row && w.col === coords.col
4067
+ )) {
4068
+ setWatchInputRef("");
4069
+ return;
4070
+ }
4071
+ templateService.setTemplateMetadata(unitId, {
4072
+ ...metadata,
4073
+ watchCells: [
4074
+ ...curList,
4075
+ {
4076
+ id: `watch-${generateRandomId(5)}`,
4077
+ sheetId: sid,
4078
+ row: coords.row,
4079
+ col: coords.col,
4080
+ cellRef: cellCoordsToA1(coords.row, coords.col)
4081
+ }
4082
+ ]
4083
+ });
4084
+ setWatchInputRef("");
4085
+ },
4086
+ children: "+ \u6DFB\u52A0\u76D1\u89C6"
4087
+ }
4088
+ )
4089
+ ] })
4090
+ ]
4091
+ }
4092
+ ),
2722
4093
  (metadata.watchCells ?? []).length > 0 && /* @__PURE__ */ jsx2(
2723
4094
  "div",
2724
4095
  {
@@ -2843,6 +4214,527 @@ var SheetInspectorPanel = () => {
2843
4214
  },
2844
4215
  children: auditOutput
2845
4216
  }
4217
+ ),
4218
+ /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
4219
+ /* @__PURE__ */ jsxs2(
4220
+ "div",
4221
+ {
4222
+ "data-testid": "yudao-whatif-scenarios-card",
4223
+ style: {
4224
+ display: "flex",
4225
+ flexDirection: "column",
4226
+ gap: 6,
4227
+ padding: "7px 8px",
4228
+ borderRadius: 6,
4229
+ background: "#F8FAFC",
4230
+ border: "1px solid #E2E8F0"
4231
+ },
4232
+ children: [
4233
+ /* @__PURE__ */ jsxs2(
4234
+ "div",
4235
+ {
4236
+ style: {
4237
+ display: "flex",
4238
+ alignItems: "center",
4239
+ justifyContent: "space-between",
4240
+ gap: 6
4241
+ },
4242
+ children: [
4243
+ /* @__PURE__ */ jsxs2(
4244
+ "span",
4245
+ {
4246
+ style: {
4247
+ display: "inline-flex",
4248
+ alignItems: "center",
4249
+ gap: 5,
4250
+ fontSize: 11.5,
4251
+ fontWeight: 600,
4252
+ color: "#1B1C1F"
4253
+ },
4254
+ children: [
4255
+ /* @__PURE__ */ jsxs2(
4256
+ "svg",
4257
+ {
4258
+ width: "13",
4259
+ height: "13",
4260
+ viewBox: "0 0 16 16",
4261
+ fill: "none",
4262
+ "aria-hidden": "true",
4263
+ children: [
4264
+ /* @__PURE__ */ jsx2(
4265
+ "rect",
4266
+ {
4267
+ x: "1.5",
4268
+ y: "2.5",
4269
+ width: "13",
4270
+ height: "11",
4271
+ rx: "2",
4272
+ stroke: "#2C53F1",
4273
+ strokeWidth: "1.3"
4274
+ }
4275
+ ),
4276
+ /* @__PURE__ */ jsx2("path", { d: "M1.5 6H14.5M6 6V13.5", stroke: "#2C53F1", strokeWidth: "1.2" })
4277
+ ]
4278
+ }
4279
+ ),
4280
+ /* @__PURE__ */ jsx2("span", { children: "\u6A21\u62DF\u5206\u6790\u4E0E\u65B9\u6848\u7BA1\u7406\u5668" })
4281
+ ]
4282
+ }
4283
+ ),
4284
+ /* @__PURE__ */ jsxs2("span", { style: { fontSize: 10, color: "#64748B" }, children: [
4285
+ getWorkbookScenarios(workbook).length,
4286
+ " \u4E2A\u65B9\u6848"
4287
+ ] })
4288
+ ]
4289
+ }
4290
+ ),
4291
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
4292
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4293
+ /* @__PURE__ */ jsx2("span", { children: "\u65B9\u6848\u540D\u79F0" }),
4294
+ /* @__PURE__ */ jsx2(
4295
+ "input",
4296
+ {
4297
+ "data-testid": "yudao-scenario-name-input",
4298
+ type: "text",
4299
+ placeholder: "\u5982\uFF1A\u4E50\u89C2\u589E\u957F\u65B9\u6848",
4300
+ value: scenarioNameInput,
4301
+ onChange: (e) => setScenarioNameInput(e.target.value)
4302
+ }
4303
+ )
4304
+ ] }),
4305
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4306
+ /* @__PURE__ */ jsx2("span", { children: "\u7ED3\u679C\u76EE\u6807\u683C (\u9017\u53F7\u5206\u9694)" }),
4307
+ /* @__PURE__ */ jsx2(
4308
+ "input",
4309
+ {
4310
+ "data-testid": "yudao-scenario-results-input",
4311
+ type: "text",
4312
+ placeholder: "\u5982 F10, G10",
4313
+ value: scenarioResultsInput,
4314
+ onChange: (e) => setScenarioResultsInput(e.target.value)
4315
+ }
4316
+ )
4317
+ ] })
4318
+ ] }),
4319
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4320
+ /* @__PURE__ */ jsx2("span", { children: "\u53EF\u53D8\u5355\u5143\u683C\u8D4B\u503C (\u683C\u5F0F: B2=120, B3=0.18)" }),
4321
+ /* @__PURE__ */ jsx2(
4322
+ "input",
4323
+ {
4324
+ "data-testid": "yudao-scenario-cells-input",
4325
+ type: "text",
4326
+ placeholder: "\u5982 B2=120, B3=0.18",
4327
+ value: scenarioCellsInput,
4328
+ onChange: (e) => setScenarioCellsInput(e.target.value)
4329
+ }
4330
+ )
4331
+ ] }),
4332
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4333
+ /* @__PURE__ */ jsx2("span", { children: "\u65B9\u6848\u5907\u6CE8 (\u53EF\u9009)" }),
4334
+ /* @__PURE__ */ jsx2(
4335
+ "input",
4336
+ {
4337
+ "data-testid": "yudao-scenario-comment-input",
4338
+ type: "text",
4339
+ placeholder: "\u8BB0\u5F55\u5047\u8BBE\u524D\u63D0\u6761\u4EF6",
4340
+ value: scenarioCommentInput,
4341
+ onChange: (e) => setScenarioCommentInput(e.target.value)
4342
+ }
4343
+ )
4344
+ ] }),
4345
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1.2fr", gap: 4 }, children: [
4346
+ /* @__PURE__ */ jsx2(
4347
+ "button",
4348
+ {
4349
+ "data-testid": "yudao-scenario-save-btn",
4350
+ type: "button",
4351
+ className: "yudao-sheet-btn is-soft-primary",
4352
+ onClick: () => {
4353
+ const changingCells = scenarioCellsInput.split(/[,;\n]+/).map((seg) => seg.trim()).filter(Boolean).map((pair) => {
4354
+ const eqIdx = pair.indexOf("=");
4355
+ if (eqIdx <= 0) return null;
4356
+ const cellA1 = pair.slice(0, eqIdx).trim();
4357
+ const rawVal = pair.slice(eqIdx + 1).trim();
4358
+ if (!cellA1) return null;
4359
+ if (/^true$/i.test(rawVal)) return { cellA1, value: true };
4360
+ if (/^false$/i.test(rawVal)) return { cellA1, value: false };
4361
+ const asNum = Number(rawVal);
4362
+ return {
4363
+ cellA1,
4364
+ value: rawVal !== "" && Number.isFinite(asNum) ? asNum : rawVal
4365
+ };
4366
+ }).filter((item) => item !== null);
4367
+ if (changingCells.length === 0) {
4368
+ setWhatIfStatusMsg("\u8BF7\u586B\u5199\u81F3\u5C11\u4E00\u9879\u53EF\u53D8\u5355\u5143\u683C\uFF08\u4F8B\u5982 B2=120\uFF09");
4369
+ return;
4370
+ }
4371
+ const resultCells = scenarioResultsInput.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
4372
+ const ok = commandService.syncExecuteCommand(SaveSheetScenarioCommand.id, {
4373
+ unitId,
4374
+ scenario: {
4375
+ name: scenarioNameInput.trim() || "\u672A\u547D\u540D\u65B9\u6848",
4376
+ comment: scenarioCommentInput.trim() || void 0,
4377
+ sheetId: sheet.getSheetId(),
4378
+ changingCells,
4379
+ resultCells: resultCells.length > 0 ? resultCells : void 0
4380
+ }
4381
+ });
4382
+ if (ok) {
4383
+ setWhatIfStatusMsg(
4384
+ `\u5DF2\u4FDD\u5B58\u65B9\u6848\u300C${scenarioNameInput.trim() || "\u672A\u547D\u540D\u65B9\u6848"}\u300D\uFF08${changingCells.length} \u9879\u53EF\u53D8\u683C\uFF09`
4385
+ );
4386
+ }
4387
+ },
4388
+ children: "\u4FDD\u5B58\u65B9\u6848"
4389
+ }
4390
+ ),
4391
+ /* @__PURE__ */ jsx2(
4392
+ "button",
4393
+ {
4394
+ "data-testid": "yudao-scenario-summary-btn",
4395
+ type: "button",
4396
+ className: "yudao-sheet-btn",
4397
+ onClick: () => {
4398
+ const resultCellsA1 = scenarioResultsInput.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
4399
+ const ok = commandService.syncExecuteCommand(
4400
+ GenerateScenarioSummaryCommand.id,
4401
+ {
4402
+ unitId,
4403
+ sheetId: sheet.getSheetId(),
4404
+ resultCellsA1: resultCellsA1.length > 0 ? resultCellsA1 : void 0
4405
+ }
4406
+ );
4407
+ setWhatIfStatusMsg(
4408
+ 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"
4409
+ );
4410
+ },
4411
+ children: "\u4E00\u952E\u751F\u6210\u65B9\u6848\u6458\u8981\u8868"
4412
+ }
4413
+ )
4414
+ ] }),
4415
+ getWorkbookScenarios(workbook).length > 0 && /* @__PURE__ */ jsx2(
4416
+ "div",
4417
+ {
4418
+ "data-testid": "yudao-scenario-list",
4419
+ style: { display: "flex", flexDirection: "column", gap: 3 },
4420
+ children: getWorkbookScenarios(workbook).map((sc) => /* @__PURE__ */ jsxs2(
4421
+ "div",
4422
+ {
4423
+ style: {
4424
+ display: "flex",
4425
+ alignItems: "center",
4426
+ justifyContent: "space-between",
4427
+ gap: 4,
4428
+ padding: "4px 6px",
4429
+ borderRadius: 5,
4430
+ background: "#FFFFFF",
4431
+ border: "1px solid #E2E8F0",
4432
+ fontSize: 10.5
4433
+ },
4434
+ children: [
4435
+ /* @__PURE__ */ jsxs2("div", { style: { minWidth: 0, flex: 1 }, children: [
4436
+ /* @__PURE__ */ jsx2("div", { style: { fontWeight: 600, color: "#1E293B" }, children: sc.name }),
4437
+ /* @__PURE__ */ jsx2("div", { style: { color: "#64748B", fontSize: 10 }, children: sc.changingCells.map((c) => `${c.cellA1}=${String(c.value)}`).join(", ") })
4438
+ ] }),
4439
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 3 }, children: [
4440
+ /* @__PURE__ */ jsx2(
4441
+ "button",
4442
+ {
4443
+ "data-testid": `yudao-scenario-apply-${sc.id}`,
4444
+ type: "button",
4445
+ className: "yudao-sheet-btn is-soft-primary",
4446
+ style: { padding: "1px 6px", fontSize: 10 },
4447
+ onClick: () => {
4448
+ const ok = commandService.syncExecuteCommand(
4449
+ ApplySheetScenarioCommand.id,
4450
+ {
4451
+ unitId,
4452
+ scenarioId: sc.id
4453
+ }
4454
+ );
4455
+ if (ok) {
4456
+ setWhatIfStatusMsg(`\u5DF2\u5207\u6362\u5E94\u7528\u65B9\u6848\u300C${sc.name}\u300D`);
4457
+ }
4458
+ },
4459
+ children: "\u5207\u6362"
4460
+ }
4461
+ ),
4462
+ /* @__PURE__ */ jsx2(
4463
+ "button",
4464
+ {
4465
+ "data-testid": `yudao-scenario-delete-${sc.id}`,
4466
+ type: "button",
4467
+ className: "yudao-sheet-btn",
4468
+ style: { padding: "1px 5px", fontSize: 10 },
4469
+ onClick: () => {
4470
+ commandService.syncExecuteCommand(DeleteSheetScenarioCommand.id, {
4471
+ unitId,
4472
+ scenarioId: sc.id
4473
+ });
4474
+ setWhatIfStatusMsg(`\u5DF2\u5220\u9664\u65B9\u6848\u300C${sc.name}\u300D`);
4475
+ },
4476
+ children: "\u5220\u9664"
4477
+ }
4478
+ )
4479
+ ] })
4480
+ ]
4481
+ },
4482
+ sc.id
4483
+ ))
4484
+ }
4485
+ ),
4486
+ /* @__PURE__ */ jsxs2(
4487
+ "div",
4488
+ {
4489
+ style: {
4490
+ borderTop: "1px dashed #CBD5E1",
4491
+ paddingTop: 5,
4492
+ display: "flex",
4493
+ flexDirection: "column",
4494
+ gap: 5
4495
+ },
4496
+ children: [
4497
+ /* @__PURE__ */ jsxs2(
4498
+ "div",
4499
+ {
4500
+ className: "yudao-sheet-segmented",
4501
+ style: { gridTemplateColumns: "1fr 1fr" },
4502
+ children: [
4503
+ /* @__PURE__ */ jsx2(
4504
+ "button",
4505
+ {
4506
+ "data-testid": "yudao-datatable-mode-1var",
4507
+ type: "button",
4508
+ className: `yudao-sheet-segmented-item ${whatIfMode === "1var" ? "is-active" : ""}`,
4509
+ style: { padding: "3px 4px", fontSize: 10.5 },
4510
+ onClick: () => setWhatIfMode("1var"),
4511
+ children: "\u5355\u53D8\u91CF\u6A21\u62DF\u8FD0\u7B97\u8868"
4512
+ }
4513
+ ),
4514
+ /* @__PURE__ */ jsx2(
4515
+ "button",
4516
+ {
4517
+ "data-testid": "yudao-datatable-mode-2var",
4518
+ type: "button",
4519
+ className: `yudao-sheet-segmented-item ${whatIfMode === "2var" ? "is-active" : ""}`,
4520
+ style: { padding: "3px 4px", fontSize: 10.5 },
4521
+ onClick: () => setWhatIfMode("2var"),
4522
+ children: "\u53CC\u53D8\u91CF\u4EA4\u53C9\u6A21\u62DF\u8868"
4523
+ }
4524
+ )
4525
+ ]
4526
+ }
4527
+ ),
4528
+ whatIfMode === "1var" ? /* @__PURE__ */ jsxs2(Fragment, { children: [
4529
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
4530
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4531
+ /* @__PURE__ */ jsx2("span", { children: "\u8F93\u5165\u53D8\u91CF\u683C" }),
4532
+ /* @__PURE__ */ jsx2(
4533
+ "input",
4534
+ {
4535
+ "data-testid": "yudao-dt-input-cell",
4536
+ type: "text",
4537
+ value: dtInputCell,
4538
+ onChange: (e) => setDtInputCell(e.target.value)
4539
+ }
4540
+ )
4541
+ ] }),
4542
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4543
+ /* @__PURE__ */ jsx2("span", { children: "\u5019\u9009\u8F93\u5165\u5E8F\u5217 (\u9017\u53F7\u5206\u9694)" }),
4544
+ /* @__PURE__ */ jsx2(
4545
+ "input",
4546
+ {
4547
+ "data-testid": "yudao-dt-input-values",
4548
+ type: "text",
4549
+ value: dtInputValues,
4550
+ onChange: (e) => setDtInputValues(e.target.value)
4551
+ }
4552
+ )
4553
+ ] })
4554
+ ] }),
4555
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
4556
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4557
+ /* @__PURE__ */ jsx2("span", { children: "\u76EE\u6807\u516C\u5F0F\u683C (\u53EF\u591A\u4E2A)" }),
4558
+ /* @__PURE__ */ jsx2(
4559
+ "input",
4560
+ {
4561
+ "data-testid": "yudao-dt-formula-cells",
4562
+ type: "text",
4563
+ value: dtFormulaCells,
4564
+ onChange: (e) => setDtFormulaCells(e.target.value)
4565
+ }
4566
+ )
4567
+ ] }),
4568
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4569
+ /* @__PURE__ */ jsx2("span", { children: "\u8F93\u51FA\u5DE6\u4E0A\u89D2 (\u53EF\u9009)" }),
4570
+ /* @__PURE__ */ jsx2(
4571
+ "input",
4572
+ {
4573
+ "data-testid": "yudao-dt-output-cell",
4574
+ type: "text",
4575
+ placeholder: "\u5982 H2",
4576
+ value: dtOutputTopLeft,
4577
+ onChange: (e) => setDtOutputTopLeft(e.target.value)
4578
+ }
4579
+ )
4580
+ ] })
4581
+ ] })
4582
+ ] }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
4583
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
4584
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4585
+ /* @__PURE__ */ jsx2("span", { children: "\u884C\u53D8\u91CF\u683C" }),
4586
+ /* @__PURE__ */ jsx2(
4587
+ "input",
4588
+ {
4589
+ "data-testid": "yudao-dt-row-input-cell",
4590
+ type: "text",
4591
+ value: dtInputCell,
4592
+ onChange: (e) => setDtInputCell(e.target.value)
4593
+ }
4594
+ )
4595
+ ] }),
4596
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4597
+ /* @__PURE__ */ jsx2("span", { children: "\u884C\u5019\u9009\u503C (\u9017\u53F7\u5206\u9694)" }),
4598
+ /* @__PURE__ */ jsx2(
4599
+ "input",
4600
+ {
4601
+ "data-testid": "yudao-dt-row-values",
4602
+ type: "text",
4603
+ value: dtInputValues,
4604
+ onChange: (e) => setDtInputValues(e.target.value)
4605
+ }
4606
+ )
4607
+ ] })
4608
+ ] }),
4609
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
4610
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4611
+ /* @__PURE__ */ jsx2("span", { children: "\u5217\u53D8\u91CF\u683C" }),
4612
+ /* @__PURE__ */ jsx2(
4613
+ "input",
4614
+ {
4615
+ "data-testid": "yudao-dt-col-input-cell",
4616
+ type: "text",
4617
+ value: dtColInputCell,
4618
+ onChange: (e) => setDtColInputCell(e.target.value)
4619
+ }
4620
+ )
4621
+ ] }),
4622
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4623
+ /* @__PURE__ */ jsx2("span", { children: "\u5217\u5019\u9009\u503C (\u9017\u53F7\u5206\u9694)" }),
4624
+ /* @__PURE__ */ jsx2(
4625
+ "input",
4626
+ {
4627
+ "data-testid": "yudao-dt-col-values",
4628
+ type: "text",
4629
+ value: dtColValues,
4630
+ onChange: (e) => setDtColValues(e.target.value)
4631
+ }
4632
+ )
4633
+ ] })
4634
+ ] }),
4635
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
4636
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4637
+ /* @__PURE__ */ jsx2("span", { children: "\u76EE\u6807\u516C\u5F0F\u683C" }),
4638
+ /* @__PURE__ */ jsx2(
4639
+ "input",
4640
+ {
4641
+ "data-testid": "yudao-dt-target-formula",
4642
+ type: "text",
4643
+ value: dtFormulaCells,
4644
+ onChange: (e) => setDtFormulaCells(e.target.value)
4645
+ }
4646
+ )
4647
+ ] }),
4648
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
4649
+ /* @__PURE__ */ jsx2("span", { children: "\u8F93\u51FA\u5DE6\u4E0A\u89D2 (\u53EF\u9009)" }),
4650
+ /* @__PURE__ */ jsx2(
4651
+ "input",
4652
+ {
4653
+ "data-testid": "yudao-dt-output-cell",
4654
+ type: "text",
4655
+ placeholder: "\u5982 H2",
4656
+ value: dtOutputTopLeft,
4657
+ onChange: (e) => setDtOutputTopLeft(e.target.value)
4658
+ }
4659
+ )
4660
+ ] })
4661
+ ] })
4662
+ ] }),
4663
+ /* @__PURE__ */ jsx2(
4664
+ "button",
4665
+ {
4666
+ "data-testid": "yudao-datatable-run-btn",
4667
+ type: "button",
4668
+ className: "yudao-sheet-btn is-soft-primary",
4669
+ onClick: () => {
4670
+ const parseCandidateValues = (raw) => raw.split(/[,;]+/).map((s) => s.trim()).filter(Boolean).map((tok) => {
4671
+ const n = Number(tok);
4672
+ return Number.isFinite(n) ? n : tok;
4673
+ });
4674
+ if (whatIfMode === "1var") {
4675
+ const inputVals = parseCandidateValues(dtInputValues);
4676
+ const fCells = dtFormulaCells.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
4677
+ commandService.syncExecuteCommand(RunSheetDataTableCommand.id, {
4678
+ unitId,
4679
+ mode: "1var",
4680
+ sheetId: sheet.getSheetId(),
4681
+ inputCellA1: dtInputCell.trim(),
4682
+ inputValues: inputVals,
4683
+ formulaCellsA1: fCells,
4684
+ outputTopLeftA1: dtOutputTopLeft.trim() || void 0,
4685
+ onResult: (res) => {
4686
+ setWhatIfStatusMsg(
4687
+ `\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(" ")}`
4688
+ );
4689
+ }
4690
+ });
4691
+ } else {
4692
+ const rVals = parseCandidateValues(dtInputValues);
4693
+ const cVals = parseCandidateValues(dtColValues);
4694
+ const targetF = dtFormulaCells.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean)[0] ?? "F10";
4695
+ commandService.syncExecuteCommand(RunSheetDataTableCommand.id, {
4696
+ unitId,
4697
+ mode: "2var",
4698
+ sheetId: sheet.getSheetId(),
4699
+ rowInputCellA1: dtInputCell.trim(),
4700
+ colInputCellA1: dtColInputCell.trim(),
4701
+ rowValues: rVals,
4702
+ colValues: cVals,
4703
+ targetFormulaA1: targetF,
4704
+ outputTopLeftA1: dtOutputTopLeft.trim() || void 0,
4705
+ onResult: (res) => {
4706
+ setWhatIfStatusMsg(
4707
+ `\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(" ")}`
4708
+ );
4709
+ }
4710
+ });
4711
+ }
4712
+ },
4713
+ children: "\u8BA1\u7B97\u5E76\u8F93\u51FA\u6A21\u62DF\u8FD0\u7B97\u8868"
4714
+ }
4715
+ )
4716
+ ]
4717
+ }
4718
+ ),
4719
+ whatIfStatusMsg && /* @__PURE__ */ jsx2(
4720
+ "div",
4721
+ {
4722
+ "data-testid": "yudao-whatif-status",
4723
+ style: {
4724
+ fontSize: 10.5,
4725
+ padding: "4px 6px",
4726
+ borderRadius: 5,
4727
+ background: "#EEF2FF",
4728
+ border: "1px solid #C7D2FE",
4729
+ color: "#1E1B4B",
4730
+ lineHeight: 1.35,
4731
+ wordBreak: "break-all"
4732
+ },
4733
+ children: whatIfStatusMsg
4734
+ }
4735
+ )
4736
+ ]
4737
+ }
2846
4738
  )
2847
4739
  ] }),
2848
4740
  features.datasetBinding && activeSubTab === "fill" && /* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section", children: [
@@ -3501,10 +5393,274 @@ var SheetInspectorPanel = () => {
3501
5393
  /* @__PURE__ */ jsx2(
3502
5394
  "button",
3503
5395
  {
3504
- type: "button",
3505
- className: "yudao-sheet-btn is-soft-primary",
3506
- onClick: () => commandService.syncExecuteCommand(OpenSheetModalOperation.id, { tab: "print" }),
3507
- children: "\u6253\u5F00\u5957\u6253\u4E0E\u5206\u9875\u6253\u5370\u9884\u89C8"
5396
+ type: "button",
5397
+ className: "yudao-sheet-btn is-soft-primary",
5398
+ onClick: () => commandService.syncExecuteCommand(OpenSheetModalOperation.id, { tab: "print" }),
5399
+ children: "\u6253\u5F00\u5957\u6253\u4E0E\u5206\u9875\u6253\u5370\u9884\u89C8"
5400
+ }
5401
+ )
5402
+ ] }),
5403
+ /* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section", "data-testid": "yudao-macro-recorder-card", children: [
5404
+ /* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section-title", children: [
5405
+ /* @__PURE__ */ jsxs2("span", { style: { display: "inline-flex", alignItems: "center", gap: 5 }, children: [
5406
+ /* @__PURE__ */ jsxs2("svg", { width: "13", height: "13", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
5407
+ /* @__PURE__ */ jsx2(
5408
+ "circle",
5409
+ {
5410
+ cx: "8",
5411
+ cy: "8",
5412
+ r: "6",
5413
+ stroke: macroRecState.recording ? "#DC2626" : "#2C53F1",
5414
+ strokeWidth: "1.4"
5415
+ }
5416
+ ),
5417
+ macroRecState.recording ? /* @__PURE__ */ jsx2("rect", { x: "5.5", y: "5.5", width: "5", height: "5", rx: "1", fill: "#DC2626" }) : /* @__PURE__ */ jsx2("polygon", { points: "6.5,5 11.5,8 6.5,11", fill: "#2C53F1" })
5418
+ ] }),
5419
+ /* @__PURE__ */ jsx2("span", { children: "\u64CD\u4F5C\u5B8F\u5F55\u5236\u4E0E\u56DE\u653E" })
5420
+ ] }),
5421
+ /* @__PURE__ */ jsx2(
5422
+ "span",
5423
+ {
5424
+ "data-testid": "yudao-macro-badge",
5425
+ style: {
5426
+ fontSize: 10,
5427
+ fontWeight: 500,
5428
+ padding: "1px 6px",
5429
+ borderRadius: 999,
5430
+ background: macroRecState.recording ? "#FEF2F2" : "#F3F5FF",
5431
+ color: macroRecState.recording ? "#DC2626" : "#2C53F1"
5432
+ },
5433
+ children: macroRecState.recording ? `\u5F55\u5236\u4E2D (${macroRecState.stepCount} \u6B65)` : `${(macroService ? macroService.getMacros(unitId) : getWorkbookMacros(workbook)).length} \u4E2A\u5B8F`
5434
+ }
5435
+ )
5436
+ ] }),
5437
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 4 }, children: [
5438
+ /* @__PURE__ */ jsx2(
5439
+ "input",
5440
+ {
5441
+ "data-testid": "yudao-macro-name-input",
5442
+ type: "text",
5443
+ style: {
5444
+ flex: 1,
5445
+ minWidth: 0,
5446
+ fontSize: 11.5,
5447
+ padding: "4px 6px",
5448
+ borderRadius: 6,
5449
+ border: "1px solid #E3E5EA",
5450
+ background: "#FFFFFF",
5451
+ color: "#1B1C1F",
5452
+ outline: "none"
5453
+ },
5454
+ placeholder: "\u5B8F\u540D\u79F0\uFF08\u5982\uFF1A\u6708\u5EA6\u62A5\u8868\u6E05\u6D17\uFF09",
5455
+ value: macroNameInput,
5456
+ onChange: (e) => setMacroNameInput(e.target.value)
5457
+ }
5458
+ ),
5459
+ !macroRecState.recording ? /* @__PURE__ */ jsx2(
5460
+ "button",
5461
+ {
5462
+ "data-testid": "yudao-macro-start-btn",
5463
+ type: "button",
5464
+ className: "yudao-sheet-btn is-soft-primary",
5465
+ onClick: () => {
5466
+ commandService.syncExecuteCommand(StartSheetMacroRecordCommand.id, {
5467
+ unitId,
5468
+ name: macroNameInput.trim() || void 0
5469
+ });
5470
+ 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");
5471
+ },
5472
+ children: "\u5F00\u59CB\u5F55\u5236"
5473
+ }
5474
+ ) : /* @__PURE__ */ jsx2(
5475
+ "button",
5476
+ {
5477
+ "data-testid": "yudao-macro-stop-btn",
5478
+ type: "button",
5479
+ className: "yudao-sheet-btn",
5480
+ style: { borderColor: "#FCA5A5", color: "#B91C1C", background: "#FEF2F2" },
5481
+ onClick: () => {
5482
+ commandService.syncExecuteCommand(StopSheetMacroRecordCommand.id, {
5483
+ unitId,
5484
+ name: macroNameInput.trim() || void 0,
5485
+ onSaved: (saved) => {
5486
+ setMacroStatusMsg(`\u5DF2\u4FDD\u5B58\u64CD\u4F5C\u5B8F\u300C${saved.name}\u300D\uFF08\u5171 ${saved.steps.length} \u6B65\uFF09`);
5487
+ setMacroNameInput("");
5488
+ }
5489
+ });
5490
+ },
5491
+ children: "\u505C\u6B62\u4FDD\u5B58"
5492
+ }
5493
+ )
5494
+ ] }),
5495
+ (macroService ? macroService.getMacros(unitId) : getWorkbookMacros(workbook)).map((m) => /* @__PURE__ */ jsxs2(
5496
+ "div",
5497
+ {
5498
+ "data-testid": `yudao-macro-item-${m.id}`,
5499
+ style: {
5500
+ display: "flex",
5501
+ alignItems: "center",
5502
+ justifyContent: "space-between",
5503
+ gap: 6,
5504
+ padding: "4px 6px",
5505
+ background: "#FFFFFF",
5506
+ border: "1px solid #E3E5EA",
5507
+ borderRadius: 6,
5508
+ fontSize: 11
5509
+ },
5510
+ children: [
5511
+ /* @__PURE__ */ jsxs2("div", { style: { minWidth: 0, flex: 1 }, children: [
5512
+ /* @__PURE__ */ jsx2("div", { style: { fontWeight: 600, color: "#1B1C1F" }, children: m.name }),
5513
+ /* @__PURE__ */ jsxs2("div", { style: { color: "#7D8698", fontSize: 10 }, children: [
5514
+ m.steps.length,
5515
+ " \u6B65\u81EA\u52A8\u5316\u6307\u4EE4"
5516
+ ] })
5517
+ ] }),
5518
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 3 }, children: [
5519
+ /* @__PURE__ */ jsx2(
5520
+ "button",
5521
+ {
5522
+ "data-testid": `yudao-macro-replay-${m.id}`,
5523
+ type: "button",
5524
+ className: "yudao-sheet-btn is-soft-primary",
5525
+ style: { padding: "2px 6px", fontSize: 10.5 },
5526
+ onClick: () => {
5527
+ const ok = commandService.syncExecuteCommand(ReplaySheetMacroCommand.id, {
5528
+ unitId,
5529
+ macroId: m.id,
5530
+ sheetId: sheet.getSheetId()
5531
+ });
5532
+ setMacroStatusMsg(
5533
+ 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`
5534
+ );
5535
+ },
5536
+ children: "\u4E00\u952E\u56DE\u653E"
5537
+ }
5538
+ ),
5539
+ /* @__PURE__ */ jsx2(
5540
+ "button",
5541
+ {
5542
+ "data-testid": `yudao-macro-view-script-${m.id}`,
5543
+ type: "button",
5544
+ className: "yudao-sheet-btn",
5545
+ style: { padding: "2px 6px", fontSize: 10.5 },
5546
+ onClick: () => setPreviewMacro(previewMacro?.id === m.id ? null : m),
5547
+ children: "\u67E5\u770B\u811A\u672C"
5548
+ }
5549
+ ),
5550
+ /* @__PURE__ */ jsx2(
5551
+ "button",
5552
+ {
5553
+ "data-testid": `yudao-macro-delete-${m.id}`,
5554
+ type: "button",
5555
+ className: "yudao-sheet-btn",
5556
+ style: { padding: "2px 5px", fontSize: 10.5 },
5557
+ onClick: () => {
5558
+ commandService.syncExecuteCommand(DeleteSheetMacroCommand.id, {
5559
+ unitId,
5560
+ macroId: m.id
5561
+ });
5562
+ if (previewMacro?.id === m.id) setPreviewMacro(null);
5563
+ setMacroStatusMsg(`\u5DF2\u5220\u9664\u5B8F\u300C${m.name}\u300D`);
5564
+ },
5565
+ children: "\u5220\u9664"
5566
+ }
5567
+ )
5568
+ ] })
5569
+ ]
5570
+ },
5571
+ m.id
5572
+ )),
5573
+ previewMacro && /* @__PURE__ */ jsxs2(
5574
+ "div",
5575
+ {
5576
+ "data-testid": "yudao-macro-script-modal",
5577
+ style: {
5578
+ display: "flex",
5579
+ flexDirection: "column",
5580
+ gap: 5,
5581
+ padding: "6px 8px",
5582
+ borderRadius: 6,
5583
+ background: "#0F172A",
5584
+ color: "#E2E8F0",
5585
+ fontSize: 10.5
5586
+ },
5587
+ children: [
5588
+ /* @__PURE__ */ jsxs2(
5589
+ "div",
5590
+ {
5591
+ style: {
5592
+ display: "flex",
5593
+ alignItems: "center",
5594
+ justifyContent: "space-between",
5595
+ gap: 6
5596
+ },
5597
+ children: [
5598
+ /* @__PURE__ */ jsxs2("span", { style: { fontWeight: 600, color: "#F8FAFC" }, children: [
5599
+ "Facade \u811A\u672C\u9884\u89C8\uFF1A",
5600
+ previewMacro.name
5601
+ ] }),
5602
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 4 }, children: [
5603
+ /* @__PURE__ */ jsx2(
5604
+ "button",
5605
+ {
5606
+ "data-testid": "yudao-macro-script-copy-btn",
5607
+ type: "button",
5608
+ className: "yudao-sheet-btn",
5609
+ style: { padding: "1px 6px", fontSize: 10 },
5610
+ onClick: () => {
5611
+ void globalThis.navigator?.clipboard?.writeText?.(
5612
+ previewMacro.generatedScript
5613
+ );
5614
+ setMacroStatusMsg(`\u5DF2\u590D\u5236\u300C${previewMacro.name}\u300D\u81EA\u52A8\u5316\u811A\u672C`);
5615
+ },
5616
+ children: "\u590D\u5236\u4EE3\u7801"
5617
+ }
5618
+ ),
5619
+ /* @__PURE__ */ jsx2(
5620
+ "button",
5621
+ {
5622
+ "data-testid": "yudao-macro-script-close-btn",
5623
+ type: "button",
5624
+ className: "yudao-sheet-btn",
5625
+ style: { padding: "1px 6px", fontSize: 10 },
5626
+ onClick: () => setPreviewMacro(null),
5627
+ children: "\u5173\u95ED"
5628
+ }
5629
+ )
5630
+ ] })
5631
+ ]
5632
+ }
5633
+ ),
5634
+ /* @__PURE__ */ jsx2(
5635
+ "pre",
5636
+ {
5637
+ "data-testid": "yudao-macro-script-code",
5638
+ style: {
5639
+ margin: 0,
5640
+ padding: "6px",
5641
+ borderRadius: 4,
5642
+ background: "#1E293B",
5643
+ color: "#93C5FD",
5644
+ fontFamily: "monospace",
5645
+ fontSize: 10,
5646
+ lineHeight: 1.45,
5647
+ maxHeight: 160,
5648
+ overflow: "auto",
5649
+ whiteSpace: "pre-wrap",
5650
+ wordBreak: "break-all"
5651
+ },
5652
+ children: previewMacro.generatedScript
5653
+ }
5654
+ )
5655
+ ]
5656
+ }
5657
+ ),
5658
+ macroStatusMsg && /* @__PURE__ */ jsx2(
5659
+ "div",
5660
+ {
5661
+ "data-testid": "yudao-macro-status",
5662
+ style: { fontSize: 10.5, color: "#4E5565", lineHeight: 1.35 },
5663
+ children: macroStatusMsg
3508
5664
  }
3509
5665
  )
3510
5666
  ] }),
@@ -5789,21 +7945,22 @@ import { SetRangeValuesMutation as SetRangeValuesMutation3, SetWorksheetActiveOp
5789
7945
  import { SheetScrollManagerService, SheetSkeletonManagerService } from "@univerjs/sheets-ui";
5790
7946
  import { useDependency as useDependency5, useObservable as useObservable5 } from "@univerjs/ui";
5791
7947
  import {
5792
- AddOrUpdateSheetShapeCommand as AddOrUpdateSheetShapeCommand2,
5793
7948
  AddOrUpdateSheetSlicerCommand as AddOrUpdateSheetSlicerCommand2,
5794
7949
  AddOrUpdateSheetTimelineCommand as AddOrUpdateSheetTimelineCommand2,
7950
+ AddSheetOutlineGroupCommand,
5795
7951
  ApplySheetSlicerSelectionCommand,
5796
7952
  ApplySheetTimelineFilterCommand,
5797
7953
  BindSheetCellDatasetCommand as BindSheetCellDatasetCommand3,
5798
7954
  cellCoordsToA1 as cellCoordsToA13,
5799
7955
  colIndexToLetter as colIndexToLetter2,
5800
7956
  evaluateWorksheetConditionalVisuals,
7957
+ ExpandSheetOutlineToLevelCommand as ExpandSheetOutlineToLevelCommand2,
5801
7958
  extractSlicerMembers,
5802
7959
  getCellYudaoMeta as getCellYudaoMeta2,
5803
7960
  hasCellPlaceholder,
5804
7961
  ISheetIoService as ISheetIoService4,
5805
7962
  ISheetTemplateService as ISheetTemplateService5,
5806
- parseA1Range,
7963
+ parseA1Range as parseA1Range2,
5807
7964
  RemoveSheetShapeCommand,
5808
7965
  RemoveSheetSlicerCommand,
5809
7966
  RemoveSheetTimelineCommand,
@@ -5815,9 +7972,11 @@ import {
5815
7972
  resolveSelectionMasterCell as resolveSelectionMasterCell3,
5816
7973
  resolveShapeDisplayText,
5817
7974
  resolveSheetChartData,
5818
- ToggleSheetOutlineCommand
7975
+ resolveWorksheetPrintConfig,
7976
+ ToggleSheetOutlineCollapseCommand,
7977
+ UpdateSheetShapeCommand
5819
7978
  } from "@yudaocode/univer-sheets";
5820
- import { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState4 } from "react";
7979
+ import React4, { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState4 } from "react";
5821
7980
  import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
5822
7981
  var QrCellImage = ({ text, size, errorLevel = "M", color, bgColor, logoDataUrl, logoSizeRatio }) => {
5823
7982
  const src = useMemo(
@@ -5912,7 +8071,9 @@ var BuiltinSvgChart = ({ chart, data, onSelectItem }) => {
5912
8071
  index
5913
8072
  });
5914
8073
  };
5915
- 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);
8074
+ const hasWave2Config = Boolean(chart.trendline) && chart.trendline !== "none" || Boolean(
8075
+ chart.errorBars && (Array.isArray(chart.errorBars) ? chart.errorBars.length > 0 : Boolean(chart.errorBars.type))
8076
+ ) || 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);
5916
8077
  if (!LEGACY_INLINE_CHART_TYPES.has(cType) || hasWave2Config) {
5917
8078
  const svgHtml = renderSheetChartSvg(chart, data).replace(
5918
8079
  "<svg ",
@@ -6058,40 +8219,6 @@ var BuiltinSvgChart = ({ chart, data, onSelectItem }) => {
6058
8219
  ] }, i);
6059
8220
  }) });
6060
8221
  }
6061
- if (cType === "radar") {
6062
- const count2 = Math.max(3, vals.length);
6063
- const cx = 130;
6064
- const cy = 70;
6065
- const rMax = 46;
6066
- const dataPoly = Array.from({ length: count2 }, (_, i) => {
6067
- const ang = -Math.PI / 2 + i / count2 * Math.PI * 2;
6068
- const rad = Math.max(0, vals[i] ?? 0) / maxVal * rMax;
6069
- return `${(cx + rad * Math.cos(ang)).toFixed(1)},${(cy + rad * Math.sin(ang)).toFixed(1)}`;
6070
- }).join(" ");
6071
- return /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 260 136", style: { width: "100%", height: "100%", display: "block" }, children: [
6072
- [0.35, 0.7, 1].map((ratio, rIdx) => {
6073
- const ringPts = Array.from({ length: count2 }, (_, i) => {
6074
- const ang = -Math.PI / 2 + i / count2 * Math.PI * 2;
6075
- return `${(cx + rMax * ratio * Math.cos(ang)).toFixed(1)},${(cy + rMax * ratio * Math.sin(ang)).toFixed(1)}`;
6076
- }).join(" ");
6077
- return /* @__PURE__ */ jsx5("polygon", { points: ringPts, fill: "none", stroke: "#E3E5EA", strokeWidth: 0.8 }, rIdx);
6078
- }),
6079
- /* @__PURE__ */ jsx5("polygon", { points: dataPoly, fill: "rgba(44, 83, 241, 0.14)", stroke: primaryColor, strokeWidth: 1.8 }),
6080
- Array.from({ length: count2 }, (_, i) => {
6081
- const ang = -Math.PI / 2 + i / count2 * Math.PI * 2;
6082
- const v = vals[i] ?? 0;
6083
- const rad = Math.max(0, v) / maxVal * rMax;
6084
- const px = cx + rad * Math.cos(ang);
6085
- const py = cy + rad * Math.sin(ang);
6086
- const lx = cx + (rMax + 14) * Math.cos(ang);
6087
- const ly = cy + (rMax + 11) * Math.sin(ang);
6088
- return /* @__PURE__ */ jsxs5("g", { style: { cursor: "pointer" }, onClick: () => fireSelect(i, v), children: [
6089
- /* @__PURE__ */ jsx5("circle", { cx: px, cy: py, r: 2.8, fill: primaryColor }),
6090
- /* @__PURE__ */ jsx5("text", { x: lx, y: ly, textAnchor: "middle", fontSize: 8.5, fill: "#4E5565", children: (cats[i] ?? `\u7EF4${i + 1}`).slice(0, 5) })
6091
- ] }, i);
6092
- })
6093
- ] });
6094
- }
6095
8222
  if (cType === "horizontalBar") {
6096
8223
  const count2 = Math.max(1, vals.length);
6097
8224
  const slotH = Math.min(24, 108 / count2);
@@ -7049,19 +9176,201 @@ var FloatingTimelineCard = ({ timeline, onMove, onRemove, onUpdateGranularity, o
7049
9176
  }
7050
9177
  );
7051
9178
  };
7052
- var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
9179
+ function getShapeAnchorMidpoints(sh) {
9180
+ const cx = sh.left + sh.width / 2;
9181
+ const cy = sh.top + sh.height / 2;
9182
+ return [
9183
+ { x: cx, y: sh.top },
9184
+ { x: sh.left + sh.width, y: cy },
9185
+ { x: cx, y: sh.top + sh.height },
9186
+ { x: sh.left, y: cy }
9187
+ ];
9188
+ }
9189
+ function findNearestAnchorMidpoint(px, py, candidates, excludeId, threshold = 22) {
9190
+ let best = null;
9191
+ for (const cand of candidates) {
9192
+ if (cand.id === excludeId || cand.shapeType === "line" || cand.shapeType === "connector") {
9193
+ continue;
9194
+ }
9195
+ for (const pt of getShapeAnchorMidpoints(cand)) {
9196
+ const d = Math.hypot(pt.x - px, pt.y - py);
9197
+ if (d <= threshold && (!best || d < best.dist)) {
9198
+ best = { shapeId: cand.id, x: pt.x, y: pt.y, dist: d };
9199
+ }
9200
+ }
9201
+ }
9202
+ return best ? { shapeId: best.shapeId, x: best.x, y: best.y } : null;
9203
+ }
9204
+ var FloatingShapeCard = ({
9205
+ shape,
9206
+ rawShape,
9207
+ allShapes,
9208
+ scrollX,
9209
+ scrollY,
9210
+ selected,
9211
+ displayText,
9212
+ onSelect,
9213
+ onUpdate,
9214
+ onRemove
9215
+ }) => {
7053
9216
  const fill = shape.fillColor || "#F3F5FF";
7054
9217
  const stroke = shape.strokeColor || "#2C53F1";
7055
9218
  const textColor = shape.textColor || "#1B1C1F";
9219
+ const isConnector = shape.shapeType === "line" || shape.shapeType === "connector";
9220
+ const resolvedBox = useMemo(() => {
9221
+ if (!isConnector || !rawShape.startShapeId && !rawShape.endShapeId) {
9222
+ return { left: shape.left, top: shape.top, width: shape.width, height: shape.height };
9223
+ }
9224
+ let x1 = rawShape.left;
9225
+ let y1 = rawShape.top;
9226
+ let x2 = rawShape.left + rawShape.width;
9227
+ let y2 = rawShape.top + rawShape.height;
9228
+ if (rawShape.startShapeId) {
9229
+ const startTarget = allShapes.find((s) => s.id === rawShape.startShapeId);
9230
+ if (startTarget) {
9231
+ const mids = getShapeAnchorMidpoints(startTarget);
9232
+ mids.sort((a, b) => Math.hypot(a.x - x2, a.y - y2) - Math.hypot(b.x - x2, b.y - y2));
9233
+ x1 = mids[0].x;
9234
+ y1 = mids[0].y;
9235
+ }
9236
+ }
9237
+ if (rawShape.endShapeId) {
9238
+ const endTarget = allShapes.find((s) => s.id === rawShape.endShapeId);
9239
+ if (endTarget) {
9240
+ const mids = getShapeAnchorMidpoints(endTarget);
9241
+ mids.sort((a, b) => Math.hypot(a.x - x1, a.y - y1) - Math.hypot(b.x - x1, b.y - y1));
9242
+ x2 = mids[0].x;
9243
+ y2 = mids[0].y;
9244
+ }
9245
+ }
9246
+ const minX = Math.min(x1, x2) - scrollX;
9247
+ const minY = Math.min(y1, y2) - scrollY;
9248
+ return {
9249
+ left: minX,
9250
+ top: minY,
9251
+ width: Math.max(12, Math.abs(x2 - x1)),
9252
+ height: Math.max(12, Math.abs(y2 - y1))
9253
+ };
9254
+ }, [isConnector, rawShape, allShapes, shape.left, shape.top, shape.width, shape.height, scrollX, scrollY]);
7056
9255
  const handleDragStart = (e) => {
7057
9256
  e.preventDefault();
7058
9257
  e.stopPropagation();
9258
+ onSelect();
7059
9259
  const startX = e.clientX;
7060
9260
  const startY = e.clientY;
7061
- const origL = shape.left;
7062
- const origT = shape.top;
9261
+ const origL = rawShape.left;
9262
+ const origT = rawShape.top;
9263
+ const onMouseMove = (ev) => {
9264
+ const nextL = Math.max(4, origL + (ev.clientX - startX));
9265
+ const nextT = Math.max(4, origT + (ev.clientY - startY));
9266
+ if (isConnector) {
9267
+ const snapStart = findNearestAnchorMidpoint(nextL, nextT, allShapes, rawShape.id);
9268
+ const snapEnd = findNearestAnchorMidpoint(
9269
+ nextL + rawShape.width,
9270
+ nextT + rawShape.height,
9271
+ allShapes,
9272
+ rawShape.id
9273
+ );
9274
+ onUpdate({
9275
+ ...rawShape,
9276
+ left: snapStart ? snapStart.x : nextL,
9277
+ top: snapStart ? snapStart.y : nextT,
9278
+ startShapeId: snapStart?.shapeId,
9279
+ endShapeId: snapEnd?.shapeId
9280
+ });
9281
+ } else {
9282
+ onUpdate({ ...rawShape, left: nextL, top: nextT });
9283
+ }
9284
+ };
9285
+ const onMouseUp = () => {
9286
+ window.removeEventListener("mousemove", onMouseMove);
9287
+ window.removeEventListener("mouseup", onMouseUp);
9288
+ };
9289
+ window.addEventListener("mousemove", onMouseMove);
9290
+ window.addEventListener("mouseup", onMouseUp);
9291
+ };
9292
+ const handleResizeStart = (dir) => (e) => {
9293
+ e.preventDefault();
9294
+ e.stopPropagation();
9295
+ onSelect();
9296
+ const startX = e.clientX;
9297
+ const startY = e.clientY;
9298
+ const origL = rawShape.left;
9299
+ const origT = rawShape.top;
9300
+ const origW = rawShape.width;
9301
+ const origH = rawShape.height;
9302
+ const onMouseMove = (ev) => {
9303
+ const dx = ev.clientX - startX;
9304
+ const dy = ev.clientY - startY;
9305
+ let nextL = origL;
9306
+ let nextT = origT;
9307
+ let nextW = origW;
9308
+ let nextH = origH;
9309
+ if (dir.includes("e")) nextW = Math.max(20, origW + dx);
9310
+ if (dir.includes("s")) nextH = Math.max(16, origH + dy);
9311
+ if (dir.includes("w")) {
9312
+ const proposedW = Math.max(20, origW - dx);
9313
+ nextL = origL + (origW - proposedW);
9314
+ nextW = proposedW;
9315
+ }
9316
+ if (dir.includes("n")) {
9317
+ const proposedH = Math.max(16, origH - dy);
9318
+ nextT = origT + (origH - proposedH);
9319
+ nextH = proposedH;
9320
+ }
9321
+ if (isConnector) {
9322
+ const snapStart = dir.includes("w") || dir.includes("n") ? findNearestAnchorMidpoint(nextL, nextT, allShapes, rawShape.id) : null;
9323
+ const snapEnd = dir.includes("e") || dir.includes("s") ? findNearestAnchorMidpoint(nextL + nextW, nextT + nextH, allShapes, rawShape.id) : null;
9324
+ if (snapStart) {
9325
+ nextW = Math.max(12, nextL + nextW - snapStart.x);
9326
+ nextH = Math.max(12, nextT + nextH - snapStart.y);
9327
+ nextL = snapStart.x;
9328
+ nextT = snapStart.y;
9329
+ }
9330
+ if (snapEnd) {
9331
+ nextW = Math.max(12, snapEnd.x - nextL);
9332
+ nextH = Math.max(12, snapEnd.y - nextT);
9333
+ }
9334
+ onUpdate({
9335
+ ...rawShape,
9336
+ left: Math.round(nextL),
9337
+ top: Math.round(nextT),
9338
+ width: Math.round(nextW),
9339
+ height: Math.round(nextH),
9340
+ ...dir.includes("w") || dir.includes("n") ? { startShapeId: snapStart?.shapeId } : {},
9341
+ ...dir.includes("e") || dir.includes("s") ? { endShapeId: snapEnd?.shapeId } : {}
9342
+ });
9343
+ } else {
9344
+ onUpdate({
9345
+ ...rawShape,
9346
+ left: Math.round(nextL),
9347
+ top: Math.round(nextT),
9348
+ width: Math.round(nextW),
9349
+ height: Math.round(nextH)
9350
+ });
9351
+ }
9352
+ };
9353
+ const onMouseUp = () => {
9354
+ window.removeEventListener("mousemove", onMouseMove);
9355
+ window.removeEventListener("mouseup", onMouseUp);
9356
+ };
9357
+ window.addEventListener("mousemove", onMouseMove);
9358
+ window.addEventListener("mouseup", onMouseUp);
9359
+ };
9360
+ const handleRotateStart = (e) => {
9361
+ e.preventDefault();
9362
+ e.stopPropagation();
9363
+ onSelect();
9364
+ const boxEl = e.currentTarget.parentElement;
9365
+ if (!boxEl) return;
9366
+ const rect = boxEl.getBoundingClientRect();
9367
+ const cx = rect.left + rect.width / 2;
9368
+ const cy = rect.top + rect.height / 2;
7063
9369
  const onMouseMove = (ev) => {
7064
- onMove(Math.max(4, origL + (ev.clientX - startX)), Math.max(4, origT + (ev.clientY - startY)));
9370
+ const rad = Math.atan2(ev.clientY - cy, ev.clientX - cx);
9371
+ let deg = Math.round((rad * 180 / Math.PI + 90 + 360) % 360);
9372
+ if (ev.shiftKey) deg = Math.round(deg / 15) * 15;
9373
+ onUpdate({ ...rawShape, rotation: deg });
7065
9374
  };
7066
9375
  const onMouseUp = () => {
7067
9376
  window.removeEventListener("mousemove", onMouseMove);
@@ -7071,7 +9380,37 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7071
9380
  window.addEventListener("mouseup", onMouseUp);
7072
9381
  };
7073
9382
  const renderShapeGeometry = () => {
9383
+ const markerId = `yudao-arrow-${shape.id}`;
7074
9384
  switch (shape.shapeType) {
9385
+ case "line":
9386
+ case "connector":
9387
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
9388
+ (shape.arrowEnd || shape.shapeType === "connector") && /* @__PURE__ */ jsx5("defs", { children: /* @__PURE__ */ jsx5(
9389
+ "marker",
9390
+ {
9391
+ id: markerId,
9392
+ viewBox: "0 0 10 10",
9393
+ refX: "8",
9394
+ refY: "5",
9395
+ markerWidth: "6",
9396
+ markerHeight: "6",
9397
+ orient: "auto-start-reverse",
9398
+ children: /* @__PURE__ */ jsx5("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: stroke })
9399
+ }
9400
+ ) }),
9401
+ /* @__PURE__ */ jsx5(
9402
+ "line",
9403
+ {
9404
+ x1: 4,
9405
+ y1: 4,
9406
+ x2: 96,
9407
+ y2: 96,
9408
+ stroke,
9409
+ strokeWidth: shape.strokeWidth || 2.2,
9410
+ markerEnd: shape.arrowEnd || shape.shapeType === "connector" ? `url(#${markerId})` : void 0
9411
+ }
9412
+ )
9413
+ ] });
7075
9414
  case "roundRect":
7076
9415
  return /* @__PURE__ */ jsx5("rect", { x: 2, y: 2, width: 96, height: 96, rx: 14, fill, stroke, strokeWidth: 2 });
7077
9416
  case "ellipse":
@@ -7079,6 +9418,7 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7079
9418
  case "diamond":
7080
9419
  return /* @__PURE__ */ jsx5("polygon", { points: "50,3 97,50 50,97 3,50", fill, stroke, strokeWidth: 2 });
7081
9420
  case "arrow":
9421
+ case "rightArrow":
7082
9422
  return /* @__PURE__ */ jsx5(
7083
9423
  "polygon",
7084
9424
  {
@@ -7089,6 +9429,7 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7089
9429
  }
7090
9430
  );
7091
9431
  case "callout":
9432
+ case "wedgeRoundRectCallout":
7092
9433
  return /* @__PURE__ */ jsx5(
7093
9434
  "polygon",
7094
9435
  {
@@ -7103,19 +9444,32 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7103
9444
  return /* @__PURE__ */ jsx5("rect", { x: 2, y: 2, width: 96, height: 96, rx: 3, fill, stroke, strokeWidth: 2 });
7104
9445
  }
7105
9446
  };
9447
+ const handles = [
9448
+ { dir: "nw", style: { left: -4, top: -4 }, cursor: "nwse-resize" },
9449
+ { dir: "n", style: { left: "calc(50% - 4px)", top: -4 }, cursor: "ns-resize" },
9450
+ { dir: "ne", style: { right: -4, top: -4 }, cursor: "nesw-resize" },
9451
+ { dir: "e", style: { right: -4, top: "calc(50% - 4px)" }, cursor: "ew-resize" },
9452
+ { dir: "se", style: { right: -4, bottom: -4 }, cursor: "nwse-resize" },
9453
+ { dir: "s", style: { left: "calc(50% - 4px)", bottom: -4 }, cursor: "ns-resize" },
9454
+ { dir: "sw", style: { left: -4, bottom: -4 }, cursor: "nesw-resize" },
9455
+ { dir: "w", style: { left: -4, top: "calc(50% - 4px)" }, cursor: "ew-resize" }
9456
+ ];
7106
9457
  return /* @__PURE__ */ jsxs5(
7107
9458
  "div",
7108
9459
  {
7109
9460
  onMouseDown: handleDragStart,
7110
9461
  style: {
7111
9462
  position: "absolute",
7112
- left: shape.left,
7113
- top: shape.top,
7114
- width: shape.width,
7115
- height: shape.height,
9463
+ left: resolvedBox.left,
9464
+ top: resolvedBox.top,
9465
+ width: resolvedBox.width,
9466
+ height: resolvedBox.height,
9467
+ transform: rawShape.rotation ? `rotate(${rawShape.rotation}deg)` : void 0,
9468
+ transformOrigin: "center center",
9469
+ outline: selected ? "1.5px dashed #2C53F1" : void 0,
7116
9470
  pointerEvents: "auto",
7117
9471
  cursor: "move",
7118
- zIndex: 24,
9472
+ zIndex: selected ? 28 : 24,
7119
9473
  display: "flex",
7120
9474
  alignItems: "center",
7121
9475
  justifyContent: "center"
@@ -7126,18 +9480,18 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7126
9480
  {
7127
9481
  viewBox: "0 0 100 100",
7128
9482
  preserveAspectRatio: "none",
7129
- style: { position: "absolute", inset: 0, width: "100%", height: "100%" },
9483
+ style: { position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" },
7130
9484
  children: renderShapeGeometry()
7131
9485
  }
7132
9486
  ),
7133
- /* @__PURE__ */ jsx5(
9487
+ !isConnector && /* @__PURE__ */ jsx5(
7134
9488
  "span",
7135
9489
  {
7136
9490
  style: {
7137
9491
  position: "relative",
7138
9492
  padding: "4px 8px",
7139
9493
  color: textColor,
7140
- fontSize: 12,
9494
+ fontSize: rawShape.fontSize || 12,
7141
9495
  fontWeight: 600,
7142
9496
  textAlign: "center",
7143
9497
  lineHeight: 1.3,
@@ -7147,6 +9501,43 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7147
9501
  children: displayText
7148
9502
  }
7149
9503
  ),
9504
+ selected && /* @__PURE__ */ jsxs5(Fragment3, { children: [
9505
+ /* @__PURE__ */ jsx5(
9506
+ "div",
9507
+ {
9508
+ onMouseDown: handleRotateStart,
9509
+ title: `\u62D6\u62FD\u65CB\u8F6C\u56FE\u5F62 (${rawShape.rotation ?? 0}\xB0)`,
9510
+ style: {
9511
+ position: "absolute",
9512
+ left: "calc(50% - 5px)",
9513
+ top: -20,
9514
+ width: 10,
9515
+ height: 10,
9516
+ borderRadius: "50%",
9517
+ background: "#FFFFFF",
9518
+ border: "2px solid #2C53F1",
9519
+ cursor: "grab"
9520
+ }
9521
+ }
9522
+ ),
9523
+ handles.map((h) => /* @__PURE__ */ jsx5(
9524
+ "div",
9525
+ {
9526
+ onMouseDown: handleResizeStart(h.dir),
9527
+ style: {
9528
+ position: "absolute",
9529
+ width: 8,
9530
+ height: 8,
9531
+ borderRadius: 2,
9532
+ background: "#FFFFFF",
9533
+ border: "1.5px solid #2C53F1",
9534
+ cursor: h.cursor,
9535
+ ...h.style
9536
+ }
9537
+ },
9538
+ h.dir
9539
+ ))
9540
+ ] }),
7150
9541
  /* @__PURE__ */ jsx5(
7151
9542
  "button",
7152
9543
  {
@@ -7198,6 +9589,8 @@ var SheetRichOverlayHost = () => {
7198
9589
  );
7199
9590
  const [tick, setTick] = useState4(0);
7200
9591
  const [drillToast, setDrillToast] = useState4(null);
9592
+ const [selectedShapeId, setSelectedShapeId] = useState4(null);
9593
+ const [pageBreakPreviewMode, setPageBreakPreviewMode] = useState4(false);
7201
9594
  useEffect4(() => {
7202
9595
  if (!workbook) return;
7203
9596
  const disp = commandService.onCommandExecuted((info) => {
@@ -7420,33 +9813,89 @@ var SheetRichOverlayHost = () => {
7420
9813
  );
7421
9814
  const outlines = (metadata.outlines ?? []).filter((o) => o.sheetId === activeSheetId);
7422
9815
  const outlinePills2 = [];
9816
+ let maxRowOutlineLevel = 0;
9817
+ let maxColOutlineLevel = 0;
7423
9818
  for (const o of outlines) {
7424
9819
  if (o.dimension === "row") {
7425
- const anchorRow = Math.max(0, o.startIndex - 1);
7426
- const coord = skeleton.getCellWithCoordByIndex(anchorRow, 0);
7427
- const top = (coord.startY - colHeaderH - vpScrollXY.y) * scaleY + 2;
9820
+ if (o.level > maxRowOutlineLevel) maxRowOutlineLevel = o.level;
9821
+ const startCoord = skeleton.getCellWithCoordByIndex(Math.max(0, o.startIndex), 0);
9822
+ const endCoord = skeleton.getCellWithCoordByIndex(Math.max(0, o.endIndex), 0);
9823
+ const top = (startCoord.startY - colHeaderH - vpScrollXY.y) * scaleY;
9824
+ const bottom = (endCoord.endY - colHeaderH - vpScrollXY.y) * scaleY;
7428
9825
  const left = Math.max(2, (o.level - 1) * 18 + 2);
7429
- if (top >= -16 && top <= canvasRect.height) {
7430
- outlinePills2.push({ outline: o, left, top });
9826
+ if (bottom >= -16 && top <= canvasRect.height) {
9827
+ outlinePills2.push({
9828
+ outline: o,
9829
+ left,
9830
+ top: Math.max(2, top + 2),
9831
+ spanSize: Math.max(16, bottom - top)
9832
+ });
7431
9833
  }
7432
9834
  } else {
7433
- const anchorCol = Math.max(0, o.startIndex - 1);
7434
- const coord = skeleton.getCellWithCoordByIndex(0, anchorCol);
7435
- const left = (coord.startX - rowHeaderW - vpScrollXY.x) * scaleX + 2;
9835
+ if (o.level > maxColOutlineLevel) maxColOutlineLevel = o.level;
9836
+ const startCoord = skeleton.getCellWithCoordByIndex(0, Math.max(0, o.startIndex));
9837
+ const endCoord = skeleton.getCellWithCoordByIndex(0, Math.max(0, o.endIndex));
9838
+ const left = (startCoord.startX - rowHeaderW - vpScrollXY.x) * scaleX;
9839
+ const right = (endCoord.endX - rowHeaderW - vpScrollXY.x) * scaleX;
7436
9840
  const top = Math.max(2, (o.level - 1) * 18 + 2);
7437
- if (left >= -16 && left <= canvasRect.width) {
7438
- outlinePills2.push({ outline: o, left, top });
9841
+ if (right >= -16 && left <= canvasRect.width) {
9842
+ outlinePills2.push({
9843
+ outline: o,
9844
+ left: Math.max(2, left + 2),
9845
+ top,
9846
+ spanSize: Math.max(16, right - left)
9847
+ });
7439
9848
  }
7440
9849
  }
7441
9850
  }
7442
- const printOrientation = metadata.printConfig?.paperOrientation ?? "A4_LANDSCAPE";
7443
- const showPageBreakLines = features.printTemplate && metadata.printConfig?.showPageBreakLines !== false;
7444
- const pageWidthPx = printOrientation === "A4_PORTRAIT" ? 680 : printOrientation === "A3_LANDSCAPE" ? 1360 : printOrientation === "INVOICE_240_140" || printOrientation === "INVOICE_240_93" ? 820 : 980;
9851
+ const effectiveSheetPrintCfg = resolveWorksheetPrintConfig(wbSnapWithMeta, activeSheetId, {
9852
+ printConfig: metadata.printConfig
9853
+ });
9854
+ const printOrientation = effectiveSheetPrintCfg.paperOrientation ?? effectiveSheetPrintCfg.orientation ?? metadata.printConfig?.paperOrientation ?? "A4_LANDSCAPE";
9855
+ const showPageBreakLines = features.printTemplate && (pageBreakPreviewMode || effectiveSheetPrintCfg.showPageBreakLines !== false);
9856
+ const isPortrait = printOrientation === "A4_PORTRAIT" || printOrientation === "portrait";
9857
+ const pageWidthPx = isPortrait ? 680 : printOrientation === "A3_LANDSCAPE" ? 1360 : printOrientation === "INVOICE_240_140" || printOrientation === "INVOICE_240_93" ? 820 : 980;
9858
+ const pageHeightPx = isPortrait ? 960 : 680;
7445
9859
  const pageBreakX = (pageWidthPx - vpScrollXY.x) * scaleX;
9860
+ const manualRowBreaks = Array.isArray(effectiveSheetPrintCfg.rowBreaks) ? effectiveSheetPrintCfg.rowBreaks.filter((n) => Number.isFinite(n) && n >= 1) : [];
9861
+ const manualColBreaks = Array.isArray(effectiveSheetPrintCfg.colBreaks) ? effectiveSheetPrintCfg.colBreaks.filter((n) => Number.isFinite(n) && n >= 1) : [];
9862
+ const rowBreakLines = [];
9863
+ for (const brkId of manualRowBreaks) {
9864
+ const c = skeleton.getCellWithCoordByIndex(Math.max(0, brkId - 1), 0);
9865
+ const y = (c.endY - colHeaderH - vpScrollXY.y) * scaleY;
9866
+ rowBreakLines.push({ y, breakId: brkId, manual: true });
9867
+ }
9868
+ if (pageBreakPreviewMode) {
9869
+ for (let p = 1; p <= 4; p++) {
9870
+ const autoY = (p * pageHeightPx - vpScrollXY.y) * scaleY;
9871
+ if (!rowBreakLines.some((l) => Math.abs(l.y - autoY) < 24)) {
9872
+ const estRow = Math.max(1, Math.round(p * pageHeightPx / 24));
9873
+ rowBreakLines.push({ y: autoY, breakId: estRow, manual: false });
9874
+ }
9875
+ }
9876
+ }
9877
+ const colBreakLines = [];
9878
+ for (const brkId of manualColBreaks) {
9879
+ const c = skeleton.getCellWithCoordByIndex(0, Math.max(0, brkId - 1));
9880
+ const x = (c.endX - rowHeaderW - vpScrollXY.x) * scaleX;
9881
+ colBreakLines.push({ x, breakId: brkId, manual: true });
9882
+ }
9883
+ if (!colBreakLines.some((l) => Math.abs(l.x - pageBreakX) < 24)) {
9884
+ const estCol = Math.max(1, Math.round(pageWidthPx / 88));
9885
+ colBreakLines.push({ x: pageBreakX, breakId: estCol, manual: false });
9886
+ }
7446
9887
  return {
7447
9888
  unitId: unitId2,
7448
9889
  sheetId: activeSheetId,
7449
9890
  sheetCfg: sheetCfg2,
9891
+ metadata,
9892
+ effectiveSheetPrintCfg,
9893
+ skeleton,
9894
+ scaleX,
9895
+ scaleY,
9896
+ vpScrollXY,
9897
+ rowHeaderW,
9898
+ colHeaderH,
7450
9899
  workbookSnapshot: workbook.save(),
7451
9900
  viewportBox: {
7452
9901
  left: canvasRect.left + rowHeaderW * scaleX,
@@ -7462,7 +9911,11 @@ var SheetRichOverlayHost = () => {
7462
9911
  timelines: timelines2,
7463
9912
  shapes: shapes2,
7464
9913
  outlinePills: outlinePills2,
7465
- overlayBackgroundUrl: metadata.printConfig?.overlayBackgroundUrl || metadata.printConfig?.backgroundImageUrl || "",
9914
+ maxRowOutlineLevel,
9915
+ maxColOutlineLevel,
9916
+ rowBreakLines: rowBreakLines.sort((a, b) => a.y - b.y),
9917
+ colBreakLines: colBreakLines.sort((a, b) => a.x - b.x),
9918
+ overlayBackgroundUrl: effectiveSheetPrintCfg.overlayBackgroundUrl || effectiveSheetPrintCfg.backgroundImageUrl || metadata.printConfig?.overlayBackgroundUrl || metadata.printConfig?.backgroundImageUrl || "",
7466
9919
  showPageBreakLines,
7467
9920
  pageBreakX,
7468
9921
  printOrientation
@@ -7471,6 +9924,7 @@ var SheetRichOverlayHost = () => {
7471
9924
  workbook,
7472
9925
  features.datasetBinding,
7473
9926
  features.printTemplate,
9927
+ pageBreakPreviewMode,
7474
9928
  tick,
7475
9929
  metaVersion,
7476
9930
  renderManagerService,
@@ -7492,7 +9946,8 @@ var SheetRichOverlayHost = () => {
7492
9946
  } = overlayState;
7493
9947
  const renderSparklineNode = (box) => {
7494
9948
  const spark = box.meta.sparkline;
7495
- const rng = parseA1Range(spark.dataRange);
9949
+ const rawRange = spark.dataRange.includes("!") ? spark.dataRange.slice(spark.dataRange.lastIndexOf("!") + 1) : spark.dataRange;
9950
+ const rng = parseA1Range2(rawRange);
7496
9951
  if (!rng) return null;
7497
9952
  const vals = [];
7498
9953
  for (let r = rng.startRow; r <= rng.endRow; r++) {
@@ -7502,8 +9957,9 @@ var SheetRichOverlayHost = () => {
7502
9957
  }
7503
9958
  }
7504
9959
  if (vals.length === 0) return null;
7505
- const color = spark.color || "#2C53F1";
7506
- const negColor = spark.negativeColor || "#7D8698";
9960
+ const color = spark.colorSeries || spark.color || "#2C53F1";
9961
+ const negColor = spark.colorNegative || spark.negativeColor || "#7D8698";
9962
+ const mrkColor = spark.colorMarkers || spark.markerColor || "#1B1C1F";
7507
9963
  const highVal = Math.max(...vals);
7508
9964
  const lowVal = Math.min(...vals);
7509
9965
  const highIdx = vals.indexOf(highVal);
@@ -7512,8 +9968,8 @@ var SheetRichOverlayHost = () => {
7512
9968
  const max = Math.max(1, highVal);
7513
9969
  const span = max - min || 1;
7514
9970
  const isWinLoss = spark.type === "winLoss" || spark.type === "winloss";
7515
- const isHighlighted = (idx) => spark.showHighPoint && idx === highIdx || spark.showLowPoint && idx === lowIdx || spark.showFirstPoint && idx === 0 || spark.showLastPoint && idx === vals.length - 1;
7516
- if (spark.type === "bar" || isWinLoss) {
9971
+ const isHighlighted = (idx) => Boolean(spark.markers) || spark.showHighPoint && idx === highIdx || spark.showLowPoint && idx === lowIdx || spark.showFirstPoint && idx === 0 || spark.showLastPoint && idx === vals.length - 1;
9972
+ if (spark.type === "bar" || spark.type === "column" || isWinLoss) {
7517
9973
  const bw = Math.max(4, Math.floor(82 / vals.length) - 2);
7518
9974
  return /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 96 24", style: { width: "92%", height: "78%" }, children: [
7519
9975
  isWinLoss && /* @__PURE__ */ jsx5("line", { x1: 4, y1: 12, x2: 92, y2: 12, stroke: "#E3E5EA", strokeWidth: 0.8 }),
@@ -7559,17 +10015,28 @@ var SheetRichOverlayHost = () => {
7559
10015
  });
7560
10016
  const pts = coords.map((p) => `${p.x.toFixed(1)},${p.y.toFixed(1)}`).join(" ");
7561
10017
  return /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 96 24", style: { width: "92%", height: "78%" }, children: [
10018
+ spark.displayXAxis && /* @__PURE__ */ jsx5(
10019
+ "line",
10020
+ {
10021
+ x1: 4,
10022
+ y1: 20 - (0 - min) / span * 16,
10023
+ x2: 92,
10024
+ y2: 20 - (0 - min) / span * 16,
10025
+ stroke: "#CBD5E1",
10026
+ strokeWidth: 0.8
10027
+ }
10028
+ ),
7562
10029
  /* @__PURE__ */ jsx5("polyline", { fill: "none", stroke: color, strokeWidth: 1.6, points: pts }),
7563
10030
  coords.map((p) => {
7564
10031
  const marker = isHighlighted(p.i);
7565
- if (!marker && !(p.v < 0 && spark.negativeColor)) return null;
10032
+ if (!marker && !(p.v < 0 && (spark.negativeColor || spark.colorNegative))) return null;
7566
10033
  return /* @__PURE__ */ jsx5(
7567
10034
  "circle",
7568
10035
  {
7569
10036
  cx: p.x,
7570
10037
  cy: p.y,
7571
10038
  r: 2.3,
7572
- fill: p.v < 0 && spark.negativeColor ? negColor : "#1B1C1F"
10039
+ fill: p.v < 0 && (spark.negativeColor || spark.colorNegative) ? negColor : mrkColor
7573
10040
  },
7574
10041
  p.i
7575
10042
  );
@@ -7605,39 +10072,201 @@ var SheetRichOverlayHost = () => {
7605
10072
  }
7606
10073
  }
7607
10074
  ),
7608
- overlayState.showPageBreakLines && overlayState.pageBreakX > 20 && overlayState.pageBreakX < viewportBox.width && /* @__PURE__ */ jsx5(
7609
- "div",
10075
+ features.printTemplate && /* @__PURE__ */ jsx5(
10076
+ "button",
7610
10077
  {
10078
+ type: "button",
10079
+ onClick: () => setPageBreakPreviewMode((v) => !v),
7611
10080
  style: {
7612
10081
  position: "absolute",
7613
- left: overlayState.pageBreakX,
7614
- top: 0,
7615
- bottom: 0,
7616
- borderLeft: "1px dashed #94A3B8",
7617
- pointerEvents: "none",
7618
- zIndex: 8
10082
+ top: 6,
10083
+ right: 10,
10084
+ background: pageBreakPreviewMode ? "#2C53F1" : "rgba(255,255,255,0.92)",
10085
+ color: pageBreakPreviewMode ? "#FFFFFF" : "#4E5565",
10086
+ border: `1px solid ${pageBreakPreviewMode ? "#2C53F1" : "#D2DAFA"}`,
10087
+ borderRadius: 999,
10088
+ fontSize: 10.5,
10089
+ fontWeight: 600,
10090
+ padding: "2px 8px",
10091
+ cursor: "pointer",
10092
+ pointerEvents: "auto",
10093
+ zIndex: 30
7619
10094
  },
7620
- children: /* @__PURE__ */ jsx5(
7621
- "span",
10095
+ children: pageBreakPreviewMode ? "\u9000\u51FA\u5206\u9875\u9884\u89C8" : "\u5206\u9875\u9884\u89C8"
10096
+ }
10097
+ ),
10098
+ overlayState.showPageBreakLines && /* @__PURE__ */ jsxs5(Fragment3, { children: [
10099
+ overlayState.colBreakLines.map((cb, cbIdx) => {
10100
+ if (cb.x <= 12 || cb.x >= viewportBox.width) return null;
10101
+ const handleColBreakDrag = (e) => {
10102
+ e.preventDefault();
10103
+ e.stopPropagation();
10104
+ const onUp = (upEv) => {
10105
+ window.removeEventListener("mouseup", onUp);
10106
+ const localX = (upEv.clientX - viewportBox.left) / (overlayState.scaleX || 1) + overlayState.rowHeaderW + overlayState.vpScrollXY.x;
10107
+ let targetCol = 1;
10108
+ for (let c = 0; c < 120; c++) {
10109
+ const coord = overlayState.skeleton.getCellWithCoordByIndex(0, c);
10110
+ if (localX <= coord.endX) {
10111
+ targetCol = c + 1;
10112
+ break;
10113
+ }
10114
+ }
10115
+ const prevList = Array.isArray(overlayState.effectiveSheetPrintCfg.colBreaks) ? overlayState.effectiveSheetPrintCfg.colBreaks.filter((x) => x !== cb.breakId) : [];
10116
+ const nextCols = Array.from(/* @__PURE__ */ new Set([...prevList, targetCol])).sort((a, b) => a - b);
10117
+ const prevPrint = overlayState.metadata.printConfig ?? {};
10118
+ templateService.patchPrintConfig(unitId, {
10119
+ colBreaks: nextCols,
10120
+ bySheetId: {
10121
+ ...prevPrint.bySheetId ?? {},
10122
+ [sheetId]: {
10123
+ ...prevPrint.bySheetId?.[sheetId] ?? {},
10124
+ colBreaks: nextCols
10125
+ }
10126
+ }
10127
+ });
10128
+ };
10129
+ window.addEventListener("mouseup", onUp);
10130
+ };
10131
+ return /* @__PURE__ */ jsx5(
10132
+ "div",
7622
10133
  {
10134
+ onMouseDown: handleColBreakDrag,
10135
+ title: "\u62D6\u62FD\u8C03\u6574\u7EB5\u5411\u5206\u9875\u7B26\u4F4D\u7F6E",
7623
10136
  style: {
7624
10137
  position: "absolute",
7625
- top: 4,
7626
- right: 4,
7627
- background: "#F9FAFB",
7628
- color: "#4E5565",
7629
- border: "1px solid #E3E5EA",
7630
- borderRadius: 4,
7631
- fontSize: 9.5,
7632
- fontWeight: 500,
7633
- padding: "1px 5px",
7634
- whiteSpace: "nowrap"
10138
+ left: cb.x,
10139
+ top: 0,
10140
+ bottom: 0,
10141
+ width: 5,
10142
+ borderLeft: cb.manual ? "2px solid #1D4ED8" : "1.5px dashed #3B82F6",
10143
+ cursor: "col-resize",
10144
+ pointerEvents: pageBreakPreviewMode || cb.manual ? "auto" : "none",
10145
+ zIndex: 9
7635
10146
  },
7636
- children: t("yudaoSheets.overlay.pageBreakBadge")
10147
+ children: cbIdx === 0 && /* @__PURE__ */ jsx5(
10148
+ "span",
10149
+ {
10150
+ style: {
10151
+ position: "absolute",
10152
+ top: 30,
10153
+ right: 6,
10154
+ background: "#F3F5FF",
10155
+ color: "#2C53F1",
10156
+ border: "1px solid #D2DAFA",
10157
+ borderRadius: 4,
10158
+ fontSize: 9.5,
10159
+ fontWeight: 600,
10160
+ padding: "1px 5px",
10161
+ whiteSpace: "nowrap",
10162
+ pointerEvents: "none"
10163
+ },
10164
+ children: t("yudaoSheets.overlay.pageBreakBadge")
10165
+ }
10166
+ )
10167
+ },
10168
+ `cb-${cbIdx}-${cb.breakId}`
10169
+ );
10170
+ }),
10171
+ overlayState.rowBreakLines.map((rb, rbIdx) => {
10172
+ if (rb.y <= 12 || rb.y >= viewportBox.height) return null;
10173
+ const handleRowBreakDrag = (e) => {
10174
+ e.preventDefault();
10175
+ e.stopPropagation();
10176
+ const onUp = (upEv) => {
10177
+ window.removeEventListener("mouseup", onUp);
10178
+ const localY = (upEv.clientY - viewportBox.top) / (overlayState.scaleY || 1) + overlayState.colHeaderH + overlayState.vpScrollXY.y;
10179
+ let targetRow = 1;
10180
+ for (let r = 0; r < 500; r++) {
10181
+ const coord = overlayState.skeleton.getCellWithCoordByIndex(r, 0);
10182
+ if (localY <= coord.endY) {
10183
+ targetRow = r + 1;
10184
+ break;
10185
+ }
10186
+ }
10187
+ const prevList = Array.isArray(overlayState.effectiveSheetPrintCfg.rowBreaks) ? overlayState.effectiveSheetPrintCfg.rowBreaks.filter((x) => x !== rb.breakId) : [];
10188
+ const nextRows = Array.from(/* @__PURE__ */ new Set([...prevList, targetRow])).sort((a, b) => a - b);
10189
+ const prevPrint = overlayState.metadata.printConfig ?? {};
10190
+ templateService.patchPrintConfig(unitId, {
10191
+ rowBreaks: nextRows,
10192
+ bySheetId: {
10193
+ ...prevPrint.bySheetId ?? {},
10194
+ [sheetId]: {
10195
+ ...prevPrint.bySheetId?.[sheetId] ?? {},
10196
+ rowBreaks: nextRows
10197
+ }
10198
+ }
10199
+ });
10200
+ };
10201
+ window.addEventListener("mouseup", onUp);
10202
+ };
10203
+ return /* @__PURE__ */ jsx5(
10204
+ "div",
10205
+ {
10206
+ onMouseDown: handleRowBreakDrag,
10207
+ title: "\u62D6\u62FD\u8C03\u6574\u6A2A\u5411\u5206\u9875\u7B26\u4F4D\u7F6E",
10208
+ style: {
10209
+ position: "absolute",
10210
+ left: 0,
10211
+ right: 0,
10212
+ top: rb.y,
10213
+ height: 5,
10214
+ borderTop: rb.manual ? "2px solid #1D4ED8" : "1.5px dashed #3B82F6",
10215
+ cursor: "row-resize",
10216
+ pointerEvents: "auto",
10217
+ zIndex: 9
10218
+ }
10219
+ },
10220
+ `rb-${rbIdx}-${rb.breakId}`
10221
+ );
10222
+ }),
10223
+ pageBreakPreviewMode && (() => {
10224
+ const yStops = [0, ...overlayState.rowBreakLines.map((r) => r.y).filter((y) => y > 0)];
10225
+ const xStops = [0, ...overlayState.colBreakLines.map((c) => c.x).filter((x) => x > 0)];
10226
+ const marks = [];
10227
+ let pageSeq = 1;
10228
+ for (let rIdx = 0; rIdx < Math.min(3, yStops.length); rIdx++) {
10229
+ const y0 = yStops[rIdx];
10230
+ const y1 = yStops[rIdx + 1] ?? viewportBox.height;
10231
+ for (let cIdx = 0; cIdx < Math.min(2, xStops.length); cIdx++) {
10232
+ const x0 = xStops[cIdx];
10233
+ const x1 = xStops[cIdx + 1] ?? viewportBox.width;
10234
+ const cx = (x0 + Math.min(x1, viewportBox.width)) / 2;
10235
+ const cy = (y0 + Math.min(y1, viewportBox.height)) / 2;
10236
+ const pNum = pageSeq++;
10237
+ if (cx > 40 && cy > 30 && cx < viewportBox.width && cy < viewportBox.height) {
10238
+ marks.push(
10239
+ /* @__PURE__ */ jsxs5(
10240
+ "div",
10241
+ {
10242
+ style: {
10243
+ position: "absolute",
10244
+ left: cx,
10245
+ top: cy,
10246
+ transform: "translate(-50%, -50%)",
10247
+ fontSize: 28,
10248
+ fontWeight: 800,
10249
+ color: "rgba(37, 99, 235, 0.16)",
10250
+ letterSpacing: 2,
10251
+ pointerEvents: "none",
10252
+ userSelect: "none",
10253
+ zIndex: 7
10254
+ },
10255
+ children: [
10256
+ "\u7B2C ",
10257
+ pNum,
10258
+ " \u9875"
10259
+ ]
10260
+ },
10261
+ `wm-${pNum}`
10262
+ )
10263
+ );
10264
+ }
7637
10265
  }
7638
- )
7639
- }
7640
- ),
10266
+ }
10267
+ return marks;
10268
+ })()
10269
+ ] }),
7641
10270
  drillToast && /* @__PURE__ */ jsx5(
7642
10271
  "div",
7643
10272
  {
@@ -7908,60 +10537,202 @@ var SheetRichOverlayHost = () => {
7908
10537
  },
7909
10538
  ch.id
7910
10539
  )),
7911
- outlinePills.map(({ outline, left, top }) => /* @__PURE__ */ jsx5(
7912
- "button",
10540
+ (overlayState.maxRowOutlineLevel > 0 || overlayState.maxColOutlineLevel > 0) && /* @__PURE__ */ jsxs5(
10541
+ "div",
7913
10542
  {
7914
- type: "button",
7915
- title: `${outline.dimension === "row" ? "\u884C" : "\u5217"}\u5206\u7EA7\u7EC4\u5408 L${outline.level} (${outline.startIndex + 1}-${outline.endIndex + 1})`,
7916
- onClick: (e) => {
7917
- e.stopPropagation();
7918
- commandService.syncExecuteCommand(ToggleSheetOutlineCommand.id, {
7919
- unitId,
7920
- outlineId: outline.id
7921
- });
7922
- },
7923
10543
  style: {
7924
10544
  position: "absolute",
7925
- left,
7926
- top,
7927
- width: 16,
7928
- height: 16,
7929
- borderRadius: 4,
10545
+ left: 4,
10546
+ top: 4,
10547
+ display: "flex",
10548
+ alignItems: "center",
10549
+ gap: 3,
10550
+ padding: "2px 5px",
10551
+ borderRadius: 5,
10552
+ background: "rgba(249, 250, 251, 0.95)",
7930
10553
  border: "1px solid #D2DAFA",
7931
- background: outline.collapsed ? "#F3F5FF" : "#FFFFFF",
7932
- color: "#2C53F1",
7933
- fontSize: 11,
7934
- fontWeight: 700,
7935
- lineHeight: 1,
7936
- padding: 0,
7937
- cursor: "pointer",
7938
10554
  pointerEvents: "auto",
7939
- zIndex: 22
10555
+ zIndex: 23
7940
10556
  },
7941
- children: outline.collapsed ? "+" : "-"
7942
- },
7943
- outline.id
7944
- )),
10557
+ children: [
10558
+ overlayState.maxRowOutlineLevel > 0 && /* @__PURE__ */ jsxs5("span", { style: { display: "inline-flex", alignItems: "center", gap: 2 }, children: [
10559
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 9.5, color: "#4E5565", fontWeight: 600 }, children: "\u884C\u7EA7" }),
10560
+ Array.from({ length: overlayState.maxRowOutlineLevel + 1 }, (_, i) => i + 1).map(
10561
+ (lvl) => /* @__PURE__ */ jsx5(
10562
+ "button",
10563
+ {
10564
+ type: "button",
10565
+ title: `\u5C55\u5F00\u884C\u5927\u7EB2\u81F3\u7B2C ${lvl} \u7EA7`,
10566
+ onClick: (e) => {
10567
+ e.stopPropagation();
10568
+ commandService.syncExecuteCommand(ExpandSheetOutlineToLevelCommand2.id, {
10569
+ unitId,
10570
+ sheetId,
10571
+ dimension: "row",
10572
+ maxVisibleLevel: lvl
10573
+ });
10574
+ },
10575
+ style: {
10576
+ width: 15,
10577
+ height: 15,
10578
+ borderRadius: 3,
10579
+ border: "1px solid #CBD5E1",
10580
+ background: "#FFFFFF",
10581
+ color: "#1B1C1F",
10582
+ fontSize: 9.5,
10583
+ fontWeight: 700,
10584
+ padding: 0,
10585
+ cursor: "pointer"
10586
+ },
10587
+ children: lvl
10588
+ },
10589
+ `rlvl-${lvl}`
10590
+ )
10591
+ )
10592
+ ] }),
10593
+ overlayState.maxColOutlineLevel > 0 && /* @__PURE__ */ jsxs5("span", { style: { display: "inline-flex", alignItems: "center", gap: 2, marginLeft: 4 }, children: [
10594
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 9.5, color: "#4E5565", fontWeight: 600 }, children: "\u5217\u7EA7" }),
10595
+ Array.from({ length: overlayState.maxColOutlineLevel + 1 }, (_, i) => i + 1).map(
10596
+ (lvl) => /* @__PURE__ */ jsx5(
10597
+ "button",
10598
+ {
10599
+ type: "button",
10600
+ title: `\u5C55\u5F00\u5217\u5927\u7EB2\u81F3\u7B2C ${lvl} \u7EA7`,
10601
+ onClick: (e) => {
10602
+ e.stopPropagation();
10603
+ commandService.syncExecuteCommand(ExpandSheetOutlineToLevelCommand2.id, {
10604
+ unitId,
10605
+ sheetId,
10606
+ dimension: "column",
10607
+ maxVisibleLevel: lvl
10608
+ });
10609
+ },
10610
+ style: {
10611
+ width: 15,
10612
+ height: 15,
10613
+ borderRadius: 3,
10614
+ border: "1px solid #CBD5E1",
10615
+ background: "#FFFFFF",
10616
+ color: "#1B1C1F",
10617
+ fontSize: 9.5,
10618
+ fontWeight: 700,
10619
+ padding: 0,
10620
+ cursor: "pointer"
10621
+ },
10622
+ children: lvl
10623
+ },
10624
+ `clvl-${lvl}`
10625
+ )
10626
+ )
10627
+ ] }),
10628
+ /* @__PURE__ */ jsx5(
10629
+ "button",
10630
+ {
10631
+ type: "button",
10632
+ title: "\u65B0\u589E\u884C\u5206\u7EC4 (AddSheetOutlineGroupCommand)",
10633
+ onClick: (e) => {
10634
+ e.stopPropagation();
10635
+ commandService.syncExecuteCommand(AddSheetOutlineGroupCommand.id, {
10636
+ unitId,
10637
+ sheetId,
10638
+ dimension: "row",
10639
+ startIndex: 1,
10640
+ endIndex: 3
10641
+ });
10642
+ },
10643
+ style: {
10644
+ height: 15,
10645
+ borderRadius: 3,
10646
+ border: "1px solid #D2DAFA",
10647
+ background: "#F3F5FF",
10648
+ color: "#2C53F1",
10649
+ fontSize: 9.5,
10650
+ fontWeight: 600,
10651
+ padding: "0 4px",
10652
+ cursor: "pointer"
10653
+ },
10654
+ children: "+\u7EC4"
10655
+ }
10656
+ )
10657
+ ]
10658
+ }
10659
+ ),
10660
+ outlinePills.map(({ outline, left, top, spanSize }) => /* @__PURE__ */ jsxs5(React4.Fragment, { children: [
10661
+ !outline.collapsed && spanSize > 20 && /* @__PURE__ */ jsx5(
10662
+ "div",
10663
+ {
10664
+ style: {
10665
+ position: "absolute",
10666
+ left: outline.dimension === "row" ? left + 7 : left + 16,
10667
+ top: outline.dimension === "row" ? top + 28 : top + 7,
10668
+ width: outline.dimension === "row" ? 4 : Math.max(4, spanSize - 18),
10669
+ height: outline.dimension === "row" ? Math.max(4, spanSize - 18) : 4,
10670
+ borderLeft: outline.dimension === "row" ? "2px solid #93C5FD" : void 0,
10671
+ borderBottom: outline.dimension === "row" ? "2px solid #93C5FD" : void 0,
10672
+ borderTop: outline.dimension === "column" ? "2px solid #93C5FD" : void 0,
10673
+ borderRight: outline.dimension === "column" ? "2px solid #93C5FD" : void 0,
10674
+ pointerEvents: "none",
10675
+ zIndex: 21
10676
+ }
10677
+ }
10678
+ ),
10679
+ /* @__PURE__ */ jsx5(
10680
+ "button",
10681
+ {
10682
+ type: "button",
10683
+ title: `${outline.dimension === "row" ? "\u884C" : "\u5217"}\u5206\u7EA7\u7EC4\u5408 L${outline.level} (${outline.startIndex + 1}-${outline.endIndex + 1})`,
10684
+ onClick: (e) => {
10685
+ e.stopPropagation();
10686
+ commandService.syncExecuteCommand(ToggleSheetOutlineCollapseCommand.id, {
10687
+ unitId,
10688
+ outlineId: outline.id
10689
+ });
10690
+ },
10691
+ style: {
10692
+ position: "absolute",
10693
+ left,
10694
+ top: outline.dimension === "row" ? top + 24 : top,
10695
+ width: 16,
10696
+ height: 16,
10697
+ borderRadius: 4,
10698
+ border: "1px solid #D2DAFA",
10699
+ background: outline.collapsed ? "#F3F5FF" : "#FFFFFF",
10700
+ color: "#2C53F1",
10701
+ fontSize: 11,
10702
+ fontWeight: 700,
10703
+ lineHeight: 1,
10704
+ padding: 0,
10705
+ cursor: "pointer",
10706
+ pointerEvents: "auto",
10707
+ zIndex: 22
10708
+ },
10709
+ children: outline.collapsed ? "+" : "-"
10710
+ }
10711
+ )
10712
+ ] }, outline.id)),
7945
10713
  shapes.map((sh) => /* @__PURE__ */ jsx5(
7946
10714
  FloatingShapeCard,
7947
10715
  {
10716
+ rawShape: sh,
10717
+ allShapes: shapes,
10718
+ scrollX: overlayState.scrollX,
10719
+ scrollY: overlayState.scrollY,
10720
+ selected: selectedShapeId === sh.id,
7948
10721
  shape: {
7949
10722
  ...sh,
7950
10723
  left: sh.left - overlayState.scrollX,
7951
10724
  top: sh.top - overlayState.scrollY
7952
10725
  },
7953
10726
  displayText: resolveShapeDisplayText(sheetCfg, sh),
7954
- onMove: (nextVisL, nextVisT) => {
7955
- commandService.syncExecuteCommand(AddOrUpdateSheetShapeCommand2.id, {
10727
+ onSelect: () => setSelectedShapeId(sh.id),
10728
+ onUpdate: (nextShape) => {
10729
+ commandService.syncExecuteCommand(UpdateSheetShapeCommand.id, {
7956
10730
  unitId,
7957
- shape: {
7958
- ...sh,
7959
- left: nextVisL + overlayState.scrollX,
7960
- top: nextVisT + overlayState.scrollY
7961
- }
10731
+ shape: nextShape
7962
10732
  });
7963
10733
  },
7964
10734
  onRemove: () => {
10735
+ if (selectedShapeId === sh.id) setSelectedShapeId(null);
7965
10736
  commandService.syncExecuteCommand(RemoveSheetShapeCommand.id, {
7966
10737
  unitId,
7967
10738
  shapeId: sh.id