@yudaocode/univer-sheets-ui 1.6.217 → 1.6.218

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 = {
@@ -375,12 +379,14 @@ import {
375
379
  } from "@univerjs/sheets";
376
380
  import { useDependency as useDependency2, 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,
383
388
  BindSheetCellDatasetCommand,
389
+ buildPivotLinkedChart,
384
390
  buildWatchWindowSnapshot,
385
391
  cellCoordsToA1,
386
392
  colIndexToLetter,
@@ -403,6 +409,9 @@ import {
403
409
  InsertSheetFillRowCommand,
404
410
  ISheetIoService as ISheetIoService2,
405
411
  ISheetTemplateService as ISheetTemplateService2,
412
+ parseA1Range,
413
+ RefreshSheetPivotCommand,
414
+ RemoveSheetChartCommand,
406
415
  resolveSelectionMasterCell,
407
416
  RestoreSheetVersionCommand,
408
417
  SaveSheetVersionCommand,
@@ -416,6 +425,7 @@ import {
416
425
  traceFormulaDependents,
417
426
  traceFormulaPrecedents,
418
427
  UngroupSheetOutlineCommand,
428
+ UpdateSheetChartCommand,
419
429
  validateSheetFillFormAsync
420
430
  } from "@yudaocode/univer-sheets";
421
431
  import { useEffect, useState } from "react";
@@ -520,6 +530,23 @@ var SheetInspectorPanel = () => {
520
530
  const [qpDatasetCode, setQpDatasetCode] = useState("");
521
531
  const [qpTargetField, setQpTargetField] = useState("");
522
532
  const [qpDefaultVal, setQpDefaultVal] = useState("");
533
+ const [selectedChartId, setSelectedChartId] = useState("");
534
+ const [selectedPivotId, setSelectedPivotId] = useState("__new__");
535
+ const [pivotSourceRange, setPivotSourceRange] = useState("");
536
+ const [pivotChipTarget, setPivotChipTarget] = useState("rows");
537
+ const [pivotRowFields, setPivotRowFields] = useState([1]);
538
+ const [pivotColFields, setPivotColFields] = useState([]);
539
+ const [pivotValueFields, setPivotValueFields] = useState([
540
+ { colIndex: 5, aggFunc: "sum" }
541
+ ]);
542
+ const [pivotFilterFields, setPivotFilterFields] = useState([]);
543
+ const [pivotCalcFields, setPivotCalcFields] = useState([]);
544
+ const [calcFieldName, setCalcFieldName] = useState("");
545
+ const [calcFieldFormula, setCalcFieldFormula] = useState("");
546
+ const [watchInputRef, setWatchInputRef] = useState("");
547
+ const [evalSteps, setEvalSteps] = useState([]);
548
+ const [evalStepIdx, setEvalStepIdx] = useState(0);
549
+ const [evalCellKey, setEvalCellKey] = useState("");
523
550
  useEffect(() => {
524
551
  const sub = selectionService.selectionChanged$.subscribe(() => setSelTick((v) => v + 1));
525
552
  const disp = commandService.onCommandExecuted((info) => {
@@ -577,6 +604,63 @@ var SheetInspectorPanel = () => {
577
604
  const printCfg = metadata.printConfig ?? {};
578
605
  const protectionCfg = metadata.protection;
579
606
  const charts = metadata.charts ?? [];
607
+ const pivots = metadata.pivots ?? [];
608
+ const editingChart = charts.find((c) => c.id === selectedChartId) ?? charts[0];
609
+ const activePivot = selectedPivotId !== "__new__" ? pivots.find((p) => p.id === selectedPivotId) : void 0;
610
+ const pivotSrcSheet = (activePivot?.sourceSheetId ? workbook.getSheetBySheetId(activePivot.sourceSheetId) : null) ?? sheet;
611
+ const rawPivotRangePart = (pivotSourceRange || activePivot?.sourceRange || "").trim().replace(/^.*!/, "");
612
+ const parsedPivotRange = rawPivotRangePart ? parseA1Range(rawPivotRangePart) : null;
613
+ const pivotHeaderRow = parsedPivotRange ? parsedPivotRange.startRow : 0;
614
+ const pivotStartCol = parsedPivotRange ? parsedPivotRange.startColumn : 0;
615
+ const pivotEndCol = (() => {
616
+ if (parsedPivotRange) {
617
+ return Math.max(parsedPivotRange.startColumn, parsedPivotRange.endColumn);
618
+ }
619
+ let maxCol = 6;
620
+ for (let c = 0; c < 20; c++) {
621
+ const v = pivotSrcSheet.getCellRaw(0, c)?.v;
622
+ if (v !== void 0 && v !== null && String(v).trim() !== "") {
623
+ maxCol = Math.max(maxCol, c);
624
+ }
625
+ }
626
+ return maxCol;
627
+ })();
628
+ const pivotSourceColumns = [];
629
+ for (let c = pivotStartCol; c <= pivotEndCol; c++) {
630
+ const hdrVal = pivotSrcSheet.getCellRaw(pivotHeaderRow, c)?.v;
631
+ const hdrStr = hdrVal !== void 0 && hdrVal !== null ? String(hdrVal).trim() : "";
632
+ pivotSourceColumns.push({
633
+ colIndex: c,
634
+ rawHeader: hdrStr || `${colIndexToLetter(c)}\u5217`,
635
+ label: hdrStr ? `${hdrStr} (${colIndexToLetter(c)})` : `${colIndexToLetter(c)} \u5217`
636
+ });
637
+ }
638
+ const resolvePivotFieldCol = (fieldOrIdx, fallback = 0) => {
639
+ if (typeof fieldOrIdx === "number" && Number.isFinite(fieldOrIdx)) return fieldOrIdx;
640
+ if (typeof fieldOrIdx === "string") {
641
+ const tStr = fieldOrIdx.trim();
642
+ if (/^\d+$/.test(tStr)) return Number(tStr);
643
+ const hit = pivotSourceColumns.find(
644
+ (col) => col.rawHeader.toLowerCase() === tStr.toLowerCase()
645
+ );
646
+ if (hit) return hit.colIndex;
647
+ }
648
+ return fallback;
649
+ };
650
+ const getPivotColumnLabel = (colIdx) => pivotSourceColumns.find((col) => col.colIndex === colIdx)?.rawHeader ?? `${colIndexToLetter(Math.max(0, colIdx))}\u5217`;
651
+ const getPivotFilterChoices = (colIdx) => {
652
+ const startR = pivotHeaderRow + 1;
653
+ const endR = parsedPivotRange ? Math.min(parsedPivotRange.endRow, startR + 200) : Math.min(pivotSrcSheet.getRowCount() - 1, startR + 150);
654
+ const seen = /* @__PURE__ */ new Set();
655
+ for (let r = startR; r <= endR; r++) {
656
+ const val = pivotSrcSheet.getCellRaw(r, colIdx)?.v;
657
+ if (val !== void 0 && val !== null && String(val).trim() !== "") {
658
+ seen.add(String(val).trim());
659
+ if (seen.size >= 24) break;
660
+ }
661
+ }
662
+ return Array.from(seen);
663
+ };
580
664
  const activeAlertRule = cellMeta.alertRules?.[0];
581
665
  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
666
  const currentExprMatch = typeof activeCell?.v === "string" ? activeCell.v.trim().match(singleExprRe) : null;
@@ -1986,7 +2070,9 @@ var SheetInspectorPanel = () => {
1986
2070
  /* @__PURE__ */ jsx2("option", { value: "ellipse", children: "\u692D\u5706 (Ellipse)" }),
1987
2071
  /* @__PURE__ */ jsx2("option", { value: "diamond", children: "\u83F1\u5F62 (Diamond)" }),
1988
2072
  /* @__PURE__ */ jsx2("option", { value: "arrow", children: "\u53F3\u5411\u7BAD\u5934 (Arrow)" }),
1989
- /* @__PURE__ */ jsx2("option", { value: "callout", children: "\u6807\u6CE8\u6C14\u6CE1 (Callout)" })
2073
+ /* @__PURE__ */ jsx2("option", { value: "callout", children: "\u6807\u6CE8\u6C14\u6CE1 (Callout)" }),
2074
+ /* @__PURE__ */ jsx2("option", { value: "line", children: "\u8FDE\u63A5\u76F4\u7EBF (Line)" }),
2075
+ /* @__PURE__ */ jsx2("option", { value: "connector", children: "\u7BAD\u5934\u8FDE\u63A5\u7EBF (Connector)" })
1990
2076
  ]
1991
2077
  }
1992
2078
  )
@@ -2037,7 +2123,8 @@ var SheetInspectorPanel = () => {
2037
2123
  left: 360,
2038
2124
  top: 56,
2039
2125
  width: 148,
2040
- height: 60
2126
+ height: shapeType === "line" || shapeType === "connector" ? 36 : 60,
2127
+ ...shapeType === "connector" ? { arrowEnd: true } : {}
2041
2128
  }
2042
2129
  });
2043
2130
  },
@@ -2319,24 +2406,30 @@ var SheetInspectorPanel = () => {
2319
2406
  className: "yudao-sheet-btn is-soft-primary",
2320
2407
  onClick: () => {
2321
2408
  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
2409
+ const newId = `chart-${generateRandomId(5)}`;
2410
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2411
+ unitId,
2412
+ chart: {
2413
+ id: newId,
2414
+ sheetId: sheet.getSheetId(),
2415
+ title: chartTitle || "\u4E1A\u52A1\u7EDF\u8BA1\u56FE",
2416
+ chartType,
2417
+ categoryRange: chartCatRange || "B6:B9",
2418
+ valueRange: chartValRange || "F6:F9",
2419
+ smooth: isSmoothEnabled ? true : void 0,
2420
+ showLegend: chartShowLegend,
2421
+ legendPosition: chartShowLegend ? chartLegendPos : "none",
2422
+ trendline: chartTrendline !== "none" ? chartTrendline : void 0,
2423
+ ...chartType === "combo" ? { comboLineSeriesIndices: [1], secondarySeriesIndices: [1] } : {},
2424
+ yAxisScale: chartLogScale ? "log" : "linear",
2425
+ threeD: chartThreeD ? { rotX: 15, rotY: 20 } : void 0,
2426
+ left: 520,
2427
+ top: 48 + charts.length * 24,
2428
+ width: 280,
2429
+ height: 175
2430
+ }
2339
2431
  });
2432
+ setSelectedChartId(newId);
2340
2433
  },
2341
2434
  children: "+ \u63D2\u5165\u6D6E\u52A8\u56FE\u8868"
2342
2435
  }
@@ -2375,144 +2468,1212 @@ var SheetInspectorPanel = () => {
2375
2468
  }
2376
2469
  )
2377
2470
  ] }),
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",
2471
+ editingChart && /* @__PURE__ */ jsxs2(
2472
+ "div",
2476
2473
  {
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
- }),
2474
+ "data-testid": "yudao-chart-inspector",
2475
+ style: {
2476
+ display: "flex",
2477
+ flexDirection: "column",
2478
+ gap: 6,
2479
+ padding: "7px 8px",
2480
+ borderRadius: 6,
2481
+ background: "#F9FAFB",
2482
+ border: "1px solid #E3E5EA"
2483
+ },
2494
2484
  children: [
2495
- "\u751F\u6210\u4EA4\u53C9\u900F\u89C6\u8868 Sheet",
2496
- withPivotChart ? " + \u8054\u52A8\u900F\u89C6\u56FE" : ""
2485
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2486
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u56FE\u8868\u914D\u7F6E\u5668 (Chart Inspector)" }),
2487
+ /* @__PURE__ */ jsx2(
2488
+ "button",
2489
+ {
2490
+ type: "button",
2491
+ className: "yudao-sheet-btn",
2492
+ style: { padding: "1px 6px", fontSize: 10.5, color: "#DC2626" },
2493
+ onClick: () => {
2494
+ commandService.syncExecuteCommand(RemoveSheetChartCommand.id, {
2495
+ unitId,
2496
+ chartId: editingChart.id
2497
+ });
2498
+ },
2499
+ children: "\u5220\u9664\u56FE\u8868"
2500
+ }
2501
+ )
2502
+ ] }),
2503
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2504
+ /* @__PURE__ */ jsx2("span", { children: "\u9009\u62E9\u5DF2\u6709\u56FE\u8868" }),
2505
+ /* @__PURE__ */ jsx2(
2506
+ "select",
2507
+ {
2508
+ "data-testid": "yudao-chart-inspector-select",
2509
+ value: editingChart.id,
2510
+ onChange: (e) => setSelectedChartId(e.target.value),
2511
+ children: charts.map((c) => /* @__PURE__ */ jsxs2("option", { value: c.id, children: [
2512
+ c.title || c.id,
2513
+ " (",
2514
+ c.chartType,
2515
+ c.pivotId ? " \xB7 \u900F\u89C6\u56FE" : "",
2516
+ ")"
2517
+ ] }, c.id))
2518
+ }
2519
+ )
2520
+ ] }),
2521
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 4 }, children: [
2522
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2523
+ /* @__PURE__ */ jsx2("span", { children: "\u56FE\u8868\u7C7B\u578B" }),
2524
+ /* @__PURE__ */ jsx2(
2525
+ "select",
2526
+ {
2527
+ "data-testid": "yudao-chart-inspector-type",
2528
+ value: editingChart.chartType,
2529
+ onChange: (e) => {
2530
+ const nextType = e.target.value;
2531
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2532
+ unitId,
2533
+ chart: {
2534
+ ...editingChart,
2535
+ chartType: nextType,
2536
+ ...nextType === "combo" && !editingChart.comboLineSeriesIndices?.length ? {
2537
+ comboLineSeriesIndices: [1],
2538
+ secondarySeriesIndices: editingChart.secondarySeriesIndices?.length ? editingChart.secondarySeriesIndices : [1]
2539
+ } : {}
2540
+ }
2541
+ });
2542
+ },
2543
+ 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))
2544
+ }
2545
+ )
2546
+ ] }),
2547
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2548
+ /* @__PURE__ */ jsx2("span", { children: "\u6807\u9898" }),
2549
+ /* @__PURE__ */ jsx2(
2550
+ "input",
2551
+ {
2552
+ type: "text",
2553
+ value: editingChart.title,
2554
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2555
+ unitId,
2556
+ chart: { ...editingChart, title: e.target.value }
2557
+ })
2558
+ }
2559
+ )
2560
+ ] })
2561
+ ] }),
2562
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2563
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2564
+ /* @__PURE__ */ jsx2("span", { children: "X / \u5206\u7C7B\u533A\u95F4" }),
2565
+ /* @__PURE__ */ jsx2(
2566
+ "input",
2567
+ {
2568
+ "data-testid": "yudao-chart-inspector-cat-range",
2569
+ type: "text",
2570
+ value: editingChart.categoryRange,
2571
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2572
+ unitId,
2573
+ chart: { ...editingChart, categoryRange: e.target.value }
2574
+ })
2575
+ }
2576
+ )
2577
+ ] }),
2578
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2579
+ /* @__PURE__ */ jsx2("span", { children: "Y / \u7CFB\u5217\u533A\u95F4" }),
2580
+ /* @__PURE__ */ jsx2(
2581
+ "input",
2582
+ {
2583
+ "data-testid": "yudao-chart-inspector-val-range",
2584
+ type: "text",
2585
+ value: editingChart.valueRange,
2586
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2587
+ unitId,
2588
+ chart: { ...editingChart, valueRange: e.target.value }
2589
+ })
2590
+ }
2591
+ )
2592
+ ] })
2593
+ ] }),
2594
+ (() => {
2595
+ const trObj = typeof editingChart.trendline === "object" && editingChart.trendline ? editingChart.trendline : typeof editingChart.trendline === "string" && editingChart.trendline !== "none" ? {
2596
+ type: editingChart.trendline === "movingAverage" ? "movingAvg" : editingChart.trendline
2597
+ } : void 0;
2598
+ const trType = trObj?.type ?? "none";
2599
+ const errObj = Array.isArray(editingChart.errorBars) ? editingChart.errorBars[0] ? {
2600
+ type: editingChart.errorBars[0].valueType === "fixed" ? "fixedVal" : editingChart.errorBars[0].valueType === "stdev" ? "stdDev" : "percentage",
2601
+ value: editingChart.errorBars[0].value
2602
+ } : void 0 : editingChart.errorBars;
2603
+ const errType = errObj?.type ?? "none";
2604
+ 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";
2605
+ const hasSecondary = (editingChart.secondarySeriesIndices?.length ?? 0) > 0;
2606
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
2607
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2608
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2609
+ /* @__PURE__ */ jsx2("span", { children: "\u8D8B\u52BF\u7EBF\u7C7B\u578B" }),
2610
+ /* @__PURE__ */ jsxs2(
2611
+ "select",
2612
+ {
2613
+ "data-testid": "yudao-chart-inspector-trendline",
2614
+ value: trType,
2615
+ onChange: (e) => {
2616
+ const val = e.target.value;
2617
+ const nextTr = val === "none" ? void 0 : {
2618
+ type: val,
2619
+ ...val === "polynomial" ? { order: trObj?.order ?? 2 } : {},
2620
+ ...val === "movingAvg" ? { period: trObj?.period ?? 2 } : {},
2621
+ displayEquation: trObj?.displayEquation,
2622
+ displayRSqr: trObj?.displayRSqr
2623
+ };
2624
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2625
+ unitId,
2626
+ chart: { ...editingChart, trendline: nextTr }
2627
+ });
2628
+ },
2629
+ children: [
2630
+ /* @__PURE__ */ jsx2("option", { value: "none", children: "\u65E0\u8D8B\u52BF\u7EBF" }),
2631
+ /* @__PURE__ */ jsx2("option", { value: "linear", children: "\u7EBF\u6027 (Linear)" }),
2632
+ /* @__PURE__ */ jsx2("option", { value: "exponential", children: "\u6307\u6570 (Exponential)" }),
2633
+ /* @__PURE__ */ jsx2("option", { value: "polynomial", children: "\u591A\u9879\u5F0F (Polynomial)" }),
2634
+ /* @__PURE__ */ jsx2("option", { value: "movingAvg", children: "\u79FB\u52A8\u5E73\u5747 (MovingAvg)" })
2635
+ ]
2636
+ }
2637
+ )
2638
+ ] }),
2639
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2640
+ /* @__PURE__ */ jsx2("span", { children: "\u8BEF\u5DEE\u7EBF (Error Bars)" }),
2641
+ /* @__PURE__ */ jsxs2(
2642
+ "select",
2643
+ {
2644
+ "data-testid": "yudao-chart-inspector-errbars",
2645
+ value: errType,
2646
+ onChange: (e) => {
2647
+ const val = e.target.value;
2648
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2649
+ unitId,
2650
+ chart: {
2651
+ ...editingChart,
2652
+ errorBars: val === "none" ? void 0 : {
2653
+ type: val,
2654
+ value: errObj?.value ?? (val === "percentage" ? 10 : val === "fixedVal" ? 5 : 1)
2655
+ }
2656
+ }
2657
+ });
2658
+ },
2659
+ children: [
2660
+ /* @__PURE__ */ jsx2("option", { value: "none", children: "\u65E0\u8BEF\u5DEE\u7EBF" }),
2661
+ /* @__PURE__ */ jsx2("option", { value: "percentage", children: "\u767E\u5206\u6BD4 (%)" }),
2662
+ /* @__PURE__ */ jsx2("option", { value: "fixedVal", children: "\u56FA\u5B9A\u503C (Fixed)" }),
2663
+ /* @__PURE__ */ jsx2("option", { value: "stdDev", children: "\u6807\u51C6\u5DEE (StdDev)" })
2664
+ ]
2665
+ }
2666
+ )
2667
+ ] })
2668
+ ] }),
2669
+ (trType === "polynomial" || trType === "movingAvg" || errType !== "none") && /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2670
+ trType === "polynomial" && /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2671
+ /* @__PURE__ */ jsx2("span", { children: "\u591A\u9879\u5F0F\u9636\u6570 (2-6)" }),
2672
+ /* @__PURE__ */ jsx2(
2673
+ "input",
2674
+ {
2675
+ type: "number",
2676
+ min: 2,
2677
+ max: 6,
2678
+ value: trObj?.order ?? 2,
2679
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2680
+ unitId,
2681
+ chart: {
2682
+ ...editingChart,
2683
+ trendline: {
2684
+ ...trObj,
2685
+ order: Math.max(2, Math.min(6, Number(e.target.value) || 2))
2686
+ }
2687
+ }
2688
+ })
2689
+ }
2690
+ )
2691
+ ] }),
2692
+ trType === "movingAvg" && /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2693
+ /* @__PURE__ */ jsx2("span", { children: "\u79FB\u52A8\u5E73\u5747\u5468\u671F" }),
2694
+ /* @__PURE__ */ jsx2(
2695
+ "input",
2696
+ {
2697
+ type: "number",
2698
+ min: 2,
2699
+ max: 12,
2700
+ value: trObj?.period ?? 2,
2701
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2702
+ unitId,
2703
+ chart: {
2704
+ ...editingChart,
2705
+ trendline: {
2706
+ ...trObj,
2707
+ period: Math.max(2, Math.min(12, Number(e.target.value) || 2))
2708
+ }
2709
+ }
2710
+ })
2711
+ }
2712
+ )
2713
+ ] }),
2714
+ errType !== "none" && /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2715
+ /* @__PURE__ */ jsx2("span", { children: "\u8BEF\u5DEE\u6570\u503C" }),
2716
+ /* @__PURE__ */ jsx2(
2717
+ "input",
2718
+ {
2719
+ type: "number",
2720
+ min: 0,
2721
+ step: "0.5",
2722
+ value: errObj?.value ?? 10,
2723
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2724
+ unitId,
2725
+ chart: {
2726
+ ...editingChart,
2727
+ errorBars: {
2728
+ type: errType,
2729
+ value: Math.max(0, Number(e.target.value) || 0)
2730
+ }
2731
+ }
2732
+ })
2733
+ }
2734
+ )
2735
+ ] })
2736
+ ] }),
2737
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr auto", gap: 6, alignItems: "end" }, children: [
2738
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2739
+ /* @__PURE__ */ jsx2("span", { children: "\u56FE\u4F8B\u4F4D\u7F6E" }),
2740
+ /* @__PURE__ */ jsxs2(
2741
+ "select",
2742
+ {
2743
+ "data-testid": "yudao-chart-inspector-legend",
2744
+ value: legVal,
2745
+ onChange: (e) => {
2746
+ const nextPos = e.target.value;
2747
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2748
+ unitId,
2749
+ chart: {
2750
+ ...editingChart,
2751
+ showLegend: nextPos !== "none",
2752
+ legendPosition: nextPos
2753
+ }
2754
+ });
2755
+ },
2756
+ children: [
2757
+ /* @__PURE__ */ jsx2("option", { value: "r", children: "\u53F3\u4FA7 (Right)" }),
2758
+ /* @__PURE__ */ jsx2("option", { value: "t", children: "\u9876\u90E8 (Top)" }),
2759
+ /* @__PURE__ */ jsx2("option", { value: "b", children: "\u5E95\u90E8 (Bottom)" }),
2760
+ /* @__PURE__ */ jsx2("option", { value: "l", children: "\u5DE6\u4FA7 (Left)" }),
2761
+ /* @__PURE__ */ jsx2("option", { value: "none", children: "\u9690\u85CF\u56FE\u4F8B (None)" })
2762
+ ]
2763
+ }
2764
+ )
2765
+ ] }),
2766
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2767
+ /* @__PURE__ */ jsx2("span", { children: "\u4E3B\u8272" }),
2768
+ /* @__PURE__ */ jsx2(
2769
+ "input",
2770
+ {
2771
+ type: "color",
2772
+ style: { width: 38, height: 25, padding: 1 },
2773
+ value: editingChart.palette?.[0] ?? "#2C53F1",
2774
+ onChange: (e) => {
2775
+ const rest = editingChart.palette?.slice(1) ?? [
2776
+ "#10B981",
2777
+ "#F59E0B",
2778
+ "#EF4444",
2779
+ "#8B5CF6"
2780
+ ];
2781
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2782
+ unitId,
2783
+ chart: {
2784
+ ...editingChart,
2785
+ palette: [e.target.value, ...rest]
2786
+ }
2787
+ });
2788
+ }
2789
+ }
2790
+ )
2791
+ ] })
2792
+ ] }),
2793
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexWrap: "wrap", gap: 10, fontSize: 11, color: "#31363F" }, children: [
2794
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
2795
+ /* @__PURE__ */ jsx2(
2796
+ "input",
2797
+ {
2798
+ "data-testid": "yudao-chart-inspector-secondary-axis",
2799
+ type: "checkbox",
2800
+ checked: hasSecondary,
2801
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2802
+ unitId,
2803
+ chart: {
2804
+ ...editingChart,
2805
+ secondarySeriesIndices: e.target.checked ? [1] : void 0,
2806
+ ...e.target.checked && editingChart.chartType === "combo" ? {
2807
+ comboLineSeriesIndices: editingChart.comboLineSeriesIndices?.length ? editingChart.comboLineSeriesIndices : [1]
2808
+ } : {}
2809
+ }
2810
+ })
2811
+ }
2812
+ ),
2813
+ /* @__PURE__ */ jsx2("span", { children: "\u53CC\u8F74\u6B21\u5750\u6807\u8F74 (\u53F3\u4FA7\u8F74)" })
2814
+ ] }),
2815
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
2816
+ /* @__PURE__ */ jsx2(
2817
+ "input",
2818
+ {
2819
+ type: "checkbox",
2820
+ checked: Boolean(editingChart.showDataLabels || editingChart.dataLabels?.showVal),
2821
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2822
+ unitId,
2823
+ chart: {
2824
+ ...editingChart,
2825
+ showDataLabels: e.target.checked,
2826
+ dataLabels: {
2827
+ ...editingChart.dataLabels,
2828
+ showVal: e.target.checked
2829
+ }
2830
+ }
2831
+ })
2832
+ }
2833
+ ),
2834
+ /* @__PURE__ */ jsx2("span", { children: "\u663E\u793A\u6570\u636E\u6807\u7B7E" })
2835
+ ] }),
2836
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" }, children: [
2837
+ /* @__PURE__ */ jsx2(
2838
+ "input",
2839
+ {
2840
+ type: "checkbox",
2841
+ checked: Boolean(editingChart.smooth),
2842
+ onChange: (e) => commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
2843
+ unitId,
2844
+ chart: { ...editingChart, smooth: e.target.checked }
2845
+ })
2846
+ }
2847
+ ),
2848
+ /* @__PURE__ */ jsx2("span", { children: "\u5E73\u6ED1\u66F2\u7EBF" })
2849
+ ] })
2850
+ ] })
2851
+ ] });
2852
+ })()
2497
2853
  ]
2498
2854
  }
2499
2855
  ),
2500
2856
  /* @__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
- }
2512
- )
2513
- ] }),
2514
- /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2515
- /* @__PURE__ */ jsx2("span", { children: "\u7B5B\u9009\u5217" }),
2857
+ /* @__PURE__ */ jsxs2(
2858
+ "div",
2859
+ {
2860
+ "data-testid": "yudao-pivot-configurator",
2861
+ style: { display: "flex", flexDirection: "column", gap: 6 },
2862
+ children: [
2863
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2864
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "\u56DB\u8C61\u9650\u6570\u636E\u900F\u89C6\u8868\u914D\u7F6E\u9762\u677F" }),
2865
+ pivots.length > 0 && /* @__PURE__ */ jsxs2(
2866
+ "span",
2867
+ {
2868
+ style: {
2869
+ fontSize: 10,
2870
+ padding: "1px 6px",
2871
+ borderRadius: 999,
2872
+ background: "#EEF2FF",
2873
+ color: "#2C53F1"
2874
+ },
2875
+ children: [
2876
+ pivots.length,
2877
+ " \u4E2A\u900F\u89C6\u8868"
2878
+ ]
2879
+ }
2880
+ )
2881
+ ] }),
2882
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2883
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2884
+ /* @__PURE__ */ jsx2("span", { children: "\u900F\u89C6\u8868\u5B9E\u4F8B" }),
2885
+ /* @__PURE__ */ jsxs2(
2886
+ "select",
2887
+ {
2888
+ "data-testid": "yudao-pivot-instance-select",
2889
+ value: activePivot ? activePivot.id : "__new__",
2890
+ onChange: (e) => {
2891
+ const nextId = e.target.value;
2892
+ setSelectedPivotId(nextId);
2893
+ const found = pivots.find((p) => p.id === nextId);
2894
+ if (found) {
2895
+ setPivotSourceRange(found.sourceRange ?? "");
2896
+ const rows = (found.rowFields ?? found.rowDimCols ?? []).map(
2897
+ (f) => resolvePivotFieldCol(f, 0)
2898
+ );
2899
+ const cols = (found.columnFields ?? found.colDimCols ?? []).map(
2900
+ (f) => resolvePivotFieldCol(f, 0)
2901
+ );
2902
+ const vals = found.valueFields && found.valueFields.length > 0 ? found.valueFields.map((vf) => ({
2903
+ ...vf,
2904
+ colIndex: resolvePivotFieldCol(vf.colIndex ?? vf.field, 0)
2905
+ })) : [{ colIndex: found.valueCol ?? 0, aggFunc: found.aggFunc ?? "SUM" }];
2906
+ setPivotRowFields(rows);
2907
+ setPivotColFields(cols);
2908
+ setPivotValueFields(vals);
2909
+ setPivotFilterFields(
2910
+ (found.filterFields ?? []).map((ff) => ({
2911
+ ...ff,
2912
+ colIndex: resolvePivotFieldCol(ff.colIndex ?? ff.field, 0)
2913
+ }))
2914
+ );
2915
+ setPivotCalcFields(found.calculatedFields ?? []);
2916
+ if (rows[0] !== void 0) setPivotRowCol(rows[0]);
2917
+ setPivotColCol(cols[0] ?? -1);
2918
+ if (vals[0]) {
2919
+ setPivotValCol(resolvePivotFieldCol(vals[0].colIndex ?? vals[0].field, 0));
2920
+ setPivotAgg(vals[0].aggFunc);
2921
+ }
2922
+ }
2923
+ },
2924
+ children: [
2925
+ /* @__PURE__ */ jsx2("option", { value: "__new__", children: "+ \u65B0\u5EFA\u6570\u636E\u900F\u89C6\u8868" }),
2926
+ pivots.map((p, idx) => /* @__PURE__ */ jsx2("option", { value: p.id ?? `__idx_${idx}`, children: p.name || p.targetSheetName || `PivotTable${idx + 1}` }, p.id ?? idx))
2927
+ ]
2928
+ }
2929
+ )
2930
+ ] }),
2931
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
2932
+ /* @__PURE__ */ jsx2("span", { children: "\u6570\u636E\u6E90\u533A\u95F4 (\u53EF\u9009)" }),
2933
+ /* @__PURE__ */ jsx2(
2934
+ "input",
2935
+ {
2936
+ type: "text",
2937
+ placeholder: "\u9ED8\u8BA4\u6574\u8868\u5982 A1:F20",
2938
+ value: pivotSourceRange,
2939
+ onChange: (e) => setPivotSourceRange(e.target.value)
2940
+ }
2941
+ )
2942
+ ] })
2943
+ ] }),
2944
+ /* @__PURE__ */ jsxs2(
2945
+ "div",
2946
+ {
2947
+ style: {
2948
+ padding: "5px 6px",
2949
+ borderRadius: 6,
2950
+ background: "#F8FAFC",
2951
+ border: "1px solid #E2E8F0",
2952
+ display: "flex",
2953
+ flexDirection: "column",
2954
+ gap: 4
2955
+ },
2956
+ children: [
2957
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
2958
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#475569" }, children: "\u6E90\u5B57\u6BB5\u5217\u8868\uFF08\u70B9\u51FB\u6DFB\u52A0\u81F3\uFF1A" }),
2959
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", gap: 2 }, children: [
2960
+ { key: "rows", label: "\u884C" },
2961
+ { key: "cols", label: "\u5217" },
2962
+ { key: "values", label: "\u503C" },
2963
+ { key: "filters", label: "\u7B5B\u9009" }
2964
+ ].map((q) => /* @__PURE__ */ jsx2(
2965
+ "button",
2966
+ {
2967
+ type: "button",
2968
+ onClick: () => setPivotChipTarget(q.key),
2969
+ style: {
2970
+ fontSize: 10,
2971
+ padding: "1px 5px",
2972
+ borderRadius: 4,
2973
+ border: "1px solid",
2974
+ borderColor: pivotChipTarget === q.key ? "#2C53F1" : "#CBD5E1",
2975
+ background: pivotChipTarget === q.key ? "#EEF2FF" : "#FFFFFF",
2976
+ color: pivotChipTarget === q.key ? "#2C53F1" : "#475569",
2977
+ cursor: "pointer"
2978
+ },
2979
+ children: q.label
2980
+ },
2981
+ q.key
2982
+ )) })
2983
+ ] }),
2984
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: pivotSourceColumns.map((col) => /* @__PURE__ */ jsxs2(
2985
+ "button",
2986
+ {
2987
+ type: "button",
2988
+ onClick: () => {
2989
+ if (pivotChipTarget === "rows") {
2990
+ if (!pivotRowFields.includes(col.colIndex)) {
2991
+ const next = [...pivotRowFields, col.colIndex];
2992
+ setPivotRowFields(next);
2993
+ setPivotRowCol(next[0]);
2994
+ }
2995
+ } else if (pivotChipTarget === "cols") {
2996
+ if (!pivotColFields.includes(col.colIndex)) {
2997
+ const next = [...pivotColFields, col.colIndex];
2998
+ setPivotColFields(next);
2999
+ setPivotColCol(next[0]);
3000
+ }
3001
+ } else if (pivotChipTarget === "values") {
3002
+ const next = [
3003
+ ...pivotValueFields,
3004
+ { colIndex: col.colIndex, aggFunc: "sum" }
3005
+ ];
3006
+ setPivotValueFields(next);
3007
+ setPivotValCol(col.colIndex);
3008
+ } else if (!pivotFilterFields.some((f) => f.colIndex === col.colIndex)) {
3009
+ setPivotFilterFields([...pivotFilterFields, { colIndex: col.colIndex }]);
3010
+ }
3011
+ },
3012
+ style: {
3013
+ fontSize: 10.5,
3014
+ padding: "2px 6px",
3015
+ borderRadius: 999,
3016
+ border: "1px solid #CBD5E1",
3017
+ background: "#FFFFFF",
3018
+ color: "#1E293B",
3019
+ cursor: "pointer"
3020
+ },
3021
+ children: [
3022
+ "+ ",
3023
+ col.label
3024
+ ]
3025
+ },
3026
+ col.colIndex
3027
+ )) })
3028
+ ]
3029
+ }
3030
+ ),
3031
+ /* @__PURE__ */ jsxs2(
3032
+ "div",
3033
+ {
3034
+ "data-testid": "yudao-pivot-quadrants",
3035
+ style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 5 },
3036
+ children: [
3037
+ /* @__PURE__ */ jsxs2(
3038
+ "div",
3039
+ {
3040
+ style: {
3041
+ padding: "5px 6px",
3042
+ borderRadius: 6,
3043
+ border: "1px solid #E2E8F0",
3044
+ background: "#FFFFFF",
3045
+ display: "flex",
3046
+ flexDirection: "column",
3047
+ gap: 4,
3048
+ minHeight: 74
3049
+ },
3050
+ children: [
3051
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3052
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u7B5B\u9009\u5668 (Filters)" }),
3053
+ /* @__PURE__ */ jsxs2(
3054
+ "select",
3055
+ {
3056
+ value: "",
3057
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3058
+ onChange: (e) => {
3059
+ if (e.target.value === "") return;
3060
+ const c = Number(e.target.value);
3061
+ if (!pivotFilterFields.some((f) => f.colIndex === c)) {
3062
+ setPivotFilterFields([...pivotFilterFields, { colIndex: c }]);
3063
+ }
3064
+ },
3065
+ children: [
3066
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3067
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3068
+ ]
3069
+ }
3070
+ )
3071
+ ] }),
3072
+ pivotFilterFields.length === 0 && /* @__PURE__ */ jsx2("span", { style: { fontSize: 10, color: "#94A3B8" }, children: "\u672A\u8BBE\u7F6E\u62A5\u8868\u7B5B\u9009" }),
3073
+ pivotFilterFields.map((ff, ffIdx) => {
3074
+ const ffCol = resolvePivotFieldCol(ff.colIndex ?? ff.field, 0);
3075
+ const choices = getPivotFilterChoices(ffCol);
3076
+ return /* @__PURE__ */ jsxs2(
3077
+ "div",
3078
+ {
3079
+ style: {
3080
+ display: "flex",
3081
+ flexDirection: "column",
3082
+ gap: 2,
3083
+ padding: "3px 4px",
3084
+ borderRadius: 4,
3085
+ background: "#F8FAFC",
3086
+ fontSize: 10
3087
+ },
3088
+ children: [
3089
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
3090
+ /* @__PURE__ */ jsx2("span", { style: { fontWeight: 500, color: "#1E293B" }, children: getPivotColumnLabel(ffCol) }),
3091
+ /* @__PURE__ */ jsx2(
3092
+ "button",
3093
+ {
3094
+ type: "button",
3095
+ onClick: () => setPivotFilterFields(
3096
+ pivotFilterFields.filter((_, idx) => idx !== ffIdx)
3097
+ ),
3098
+ style: {
3099
+ border: "none",
3100
+ background: "transparent",
3101
+ color: "#64748B",
3102
+ cursor: "pointer",
3103
+ fontSize: 11,
3104
+ padding: "0 2px"
3105
+ },
3106
+ children: "\xD7"
3107
+ }
3108
+ )
3109
+ ] }),
3110
+ /* @__PURE__ */ jsxs2(
3111
+ "select",
3112
+ {
3113
+ value: ff.selectedValues?.length === 1 ? ff.selectedValues[0] : "__all__",
3114
+ style: { fontSize: 10, padding: "1px 2px" },
3115
+ onChange: (e) => {
3116
+ const v = e.target.value;
3117
+ setPivotFilterFields(
3118
+ pivotFilterFields.map(
3119
+ (item, idx) => idx === ffIdx ? { ...item, selectedValues: v === "__all__" ? void 0 : [v] } : item
3120
+ )
3121
+ );
3122
+ },
3123
+ children: [
3124
+ /* @__PURE__ */ jsx2("option", { value: "__all__", children: "(\u5168\u90E8\u503C)" }),
3125
+ choices.map((val) => /* @__PURE__ */ jsx2("option", { value: val, children: val }, val))
3126
+ ]
3127
+ }
3128
+ )
3129
+ ]
3130
+ },
3131
+ `${ffCol}-${ffIdx}`
3132
+ );
3133
+ })
3134
+ ]
3135
+ }
3136
+ ),
3137
+ /* @__PURE__ */ jsxs2(
3138
+ "div",
3139
+ {
3140
+ style: {
3141
+ padding: "5px 6px",
3142
+ borderRadius: 6,
3143
+ border: "1px solid #E2E8F0",
3144
+ background: "#FFFFFF",
3145
+ display: "flex",
3146
+ flexDirection: "column",
3147
+ gap: 4,
3148
+ minHeight: 74
3149
+ },
3150
+ children: [
3151
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3152
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u5217\u7EF4\u5EA6 (Columns)" }),
3153
+ /* @__PURE__ */ jsxs2(
3154
+ "select",
3155
+ {
3156
+ value: "",
3157
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3158
+ onChange: (e) => {
3159
+ if (e.target.value === "") return;
3160
+ const c = Number(e.target.value);
3161
+ if (!pivotColFields.includes(c)) {
3162
+ const next = [...pivotColFields, c];
3163
+ setPivotColFields(next);
3164
+ setPivotColCol(next[0]);
3165
+ }
3166
+ },
3167
+ children: [
3168
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3169
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3170
+ ]
3171
+ }
3172
+ )
3173
+ ] }),
3174
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexWrap: "wrap", gap: 3 }, children: [
3175
+ pivotColFields.length === 0 && /* @__PURE__ */ jsx2("span", { style: { fontSize: 10, color: "#94A3B8" }, children: "\u65E0\u4EA4\u53C9\u5217\uFF08\u4E00\u7EF4\u6C47\u603B\uFF09" }),
3176
+ pivotColFields.map((colIdx) => /* @__PURE__ */ jsxs2(
3177
+ "span",
3178
+ {
3179
+ style: {
3180
+ display: "inline-flex",
3181
+ alignItems: "center",
3182
+ gap: 3,
3183
+ fontSize: 10,
3184
+ padding: "2px 5px",
3185
+ borderRadius: 4,
3186
+ background: "#EEF2FF",
3187
+ color: "#2C53F1"
3188
+ },
3189
+ children: [
3190
+ getPivotColumnLabel(colIdx),
3191
+ /* @__PURE__ */ jsx2(
3192
+ "button",
3193
+ {
3194
+ type: "button",
3195
+ onClick: () => {
3196
+ const next = pivotColFields.filter((x) => x !== colIdx);
3197
+ setPivotColFields(next);
3198
+ setPivotColCol(next[0] ?? -1);
3199
+ },
3200
+ style: {
3201
+ border: "none",
3202
+ background: "transparent",
3203
+ color: "#2C53F1",
3204
+ cursor: "pointer",
3205
+ padding: 0,
3206
+ fontSize: 11
3207
+ },
3208
+ children: "\xD7"
3209
+ }
3210
+ )
3211
+ ]
3212
+ },
3213
+ colIdx
3214
+ ))
3215
+ ] })
3216
+ ]
3217
+ }
3218
+ ),
3219
+ /* @__PURE__ */ jsxs2(
3220
+ "div",
3221
+ {
3222
+ style: {
3223
+ padding: "5px 6px",
3224
+ borderRadius: 6,
3225
+ border: "1px solid #E2E8F0",
3226
+ background: "#FFFFFF",
3227
+ display: "flex",
3228
+ flexDirection: "column",
3229
+ gap: 4,
3230
+ minHeight: 74
3231
+ },
3232
+ children: [
3233
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3234
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u884C\u7EF4\u5EA6 (Rows)" }),
3235
+ /* @__PURE__ */ jsxs2(
3236
+ "select",
3237
+ {
3238
+ value: "",
3239
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3240
+ onChange: (e) => {
3241
+ if (e.target.value === "") return;
3242
+ const c = Number(e.target.value);
3243
+ if (!pivotRowFields.includes(c)) {
3244
+ const next = [...pivotRowFields, c];
3245
+ setPivotRowFields(next);
3246
+ setPivotRowCol(next[0]);
3247
+ }
3248
+ },
3249
+ children: [
3250
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3251
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3252
+ ]
3253
+ }
3254
+ )
3255
+ ] }),
3256
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: 3 }, children: pivotRowFields.map((colIdx) => /* @__PURE__ */ jsxs2(
3257
+ "span",
3258
+ {
3259
+ style: {
3260
+ display: "inline-flex",
3261
+ alignItems: "center",
3262
+ gap: 3,
3263
+ fontSize: 10,
3264
+ padding: "2px 5px",
3265
+ borderRadius: 4,
3266
+ background: "#ECFDF5",
3267
+ color: "#047857"
3268
+ },
3269
+ children: [
3270
+ getPivotColumnLabel(colIdx),
3271
+ pivotRowFields.length > 1 && /* @__PURE__ */ jsx2(
3272
+ "button",
3273
+ {
3274
+ type: "button",
3275
+ onClick: () => {
3276
+ const next = pivotRowFields.filter((x) => x !== colIdx);
3277
+ setPivotRowFields(next);
3278
+ if (next[0] !== void 0) setPivotRowCol(next[0]);
3279
+ },
3280
+ style: {
3281
+ border: "none",
3282
+ background: "transparent",
3283
+ color: "#047857",
3284
+ cursor: "pointer",
3285
+ padding: 0,
3286
+ fontSize: 11
3287
+ },
3288
+ children: "\xD7"
3289
+ }
3290
+ )
3291
+ ]
3292
+ },
3293
+ colIdx
3294
+ )) })
3295
+ ]
3296
+ }
3297
+ ),
3298
+ /* @__PURE__ */ jsxs2(
3299
+ "div",
3300
+ {
3301
+ style: {
3302
+ padding: "5px 6px",
3303
+ borderRadius: 6,
3304
+ border: "1px solid #E2E8F0",
3305
+ background: "#FFFFFF",
3306
+ display: "flex",
3307
+ flexDirection: "column",
3308
+ gap: 4,
3309
+ minHeight: 74
3310
+ },
3311
+ children: [
3312
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
3313
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u503C\u6307\u6807 (Values)" }),
3314
+ /* @__PURE__ */ jsxs2(
3315
+ "select",
3316
+ {
3317
+ value: "",
3318
+ style: { fontSize: 10, padding: "0 2px", maxWidth: 68 },
3319
+ onChange: (e) => {
3320
+ if (e.target.value === "") return;
3321
+ const c = Number(e.target.value);
3322
+ const next = [
3323
+ ...pivotValueFields,
3324
+ { colIndex: c, aggFunc: "sum" }
3325
+ ];
3326
+ setPivotValueFields(next);
3327
+ setPivotValCol(c);
3328
+ },
3329
+ children: [
3330
+ /* @__PURE__ */ jsx2("option", { value: "", children: "+ \u5B57\u6BB5" }),
3331
+ pivotSourceColumns.map((c) => /* @__PURE__ */ jsx2("option", { value: c.colIndex, children: c.label }, c.colIndex))
3332
+ ]
3333
+ }
3334
+ )
3335
+ ] }),
3336
+ pivotValueFields.map((vf, idx) => {
3337
+ const vfCol = resolvePivotFieldCol(vf.colIndex ?? vf.field, 0);
3338
+ return /* @__PURE__ */ jsxs2(
3339
+ "div",
3340
+ {
3341
+ style: {
3342
+ display: "flex",
3343
+ alignItems: "center",
3344
+ justifyContent: "space-between",
3345
+ gap: 2,
3346
+ padding: "2px 4px",
3347
+ borderRadius: 4,
3348
+ background: "#FFFBEB",
3349
+ fontSize: 10
3350
+ },
3351
+ children: [
3352
+ /* @__PURE__ */ jsx2(
3353
+ "span",
3354
+ {
3355
+ style: {
3356
+ color: "#92400E",
3357
+ fontWeight: 500,
3358
+ overflow: "hidden",
3359
+ textOverflow: "ellipsis",
3360
+ whiteSpace: "nowrap"
3361
+ },
3362
+ children: getPivotColumnLabel(vfCol)
3363
+ }
3364
+ ),
3365
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: 2 }, children: [
3366
+ /* @__PURE__ */ jsxs2(
3367
+ "select",
3368
+ {
3369
+ value: vf.aggFunc.toLowerCase(),
3370
+ style: { fontSize: 10, padding: "0 2px" },
3371
+ onChange: (e) => {
3372
+ const nextAgg = e.target.value;
3373
+ const next = pivotValueFields.map(
3374
+ (item, i) => i === idx ? { ...item, aggFunc: nextAgg } : item
3375
+ );
3376
+ setPivotValueFields(next);
3377
+ if (idx === 0) setPivotAgg(nextAgg.toUpperCase());
3378
+ },
3379
+ children: [
3380
+ /* @__PURE__ */ jsx2("option", { value: "sum", children: "\u6C42\u548C" }),
3381
+ /* @__PURE__ */ jsx2("option", { value: "count", children: "\u8BA1\u6570" }),
3382
+ /* @__PURE__ */ jsx2("option", { value: "avg", children: "\u5E73\u5747" }),
3383
+ /* @__PURE__ */ jsx2("option", { value: "max", children: "\u6700\u5927" }),
3384
+ /* @__PURE__ */ jsx2("option", { value: "min", children: "\u6700\u5C0F" }),
3385
+ /* @__PURE__ */ jsx2("option", { value: "stdev", children: "\u6807\u51C6\u5DEE" }),
3386
+ /* @__PURE__ */ jsx2("option", { value: "var", children: "\u65B9\u5DEE" })
3387
+ ]
3388
+ }
3389
+ ),
3390
+ pivotValueFields.length > 1 && /* @__PURE__ */ jsx2(
3391
+ "button",
3392
+ {
3393
+ type: "button",
3394
+ onClick: () => setPivotValueFields(pivotValueFields.filter((_, i) => i !== idx)),
3395
+ style: {
3396
+ border: "none",
3397
+ background: "transparent",
3398
+ color: "#92400E",
3399
+ cursor: "pointer",
3400
+ padding: 0,
3401
+ fontSize: 11
3402
+ },
3403
+ children: "\xD7"
3404
+ }
3405
+ )
3406
+ ] })
3407
+ ]
3408
+ },
3409
+ `${vfCol}-${idx}`
3410
+ );
3411
+ })
3412
+ ]
3413
+ }
3414
+ )
3415
+ ]
3416
+ }
3417
+ ),
3418
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
3419
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3420
+ /* @__PURE__ */ jsx2("span", { children: "\u503C\u663E\u793A\u65B9\u5F0F" }),
3421
+ /* @__PURE__ */ jsxs2(
3422
+ "select",
3423
+ {
3424
+ value: pivotShowAs,
3425
+ onChange: (e) => setPivotShowAs(e.target.value),
3426
+ children: [
3427
+ /* @__PURE__ */ jsx2("option", { value: "normal", children: "\u5E38\u89C4\u6C47\u603B\u503C" }),
3428
+ /* @__PURE__ */ jsx2("option", { value: "percentOfGrandTotal", children: "\u5360\u603B\u8BA1\u767E\u5206\u6BD4" }),
3429
+ /* @__PURE__ */ jsx2("option", { value: "percentOfRow", children: "\u5360\u884C\u6C47\u603B\u767E\u5206\u6BD4" }),
3430
+ /* @__PURE__ */ jsx2("option", { value: "percentOfColumn", children: "\u5360\u5217\u6C47\u603B\u767E\u5206\u6BD4" }),
3431
+ /* @__PURE__ */ jsx2("option", { value: "runningTotal", children: "\u6309\u5217\u7D2F\u8BA1\u503C" }),
3432
+ /* @__PURE__ */ jsx2("option", { value: "rankDesc", children: "\u964D\u5E8F\u6392\u540D" })
3433
+ ]
3434
+ }
3435
+ )
3436
+ ] }),
3437
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3438
+ /* @__PURE__ */ jsx2("span", { children: "\u884C\u65E5\u671F\u5206\u7EC4" }),
3439
+ /* @__PURE__ */ jsxs2(
3440
+ "select",
3441
+ {
3442
+ value: pivotDateGroup,
3443
+ onChange: (e) => setPivotDateGroup(e.target.value),
3444
+ children: [
3445
+ /* @__PURE__ */ jsx2("option", { value: "", children: "\u4E0D\u6309\u65E5\u671F\u5206\u7EC4" }),
3446
+ /* @__PURE__ */ jsx2("option", { value: "year", children: "\u6309\u5E74\u4EFD (YYYY\u5E74)" }),
3447
+ /* @__PURE__ */ jsx2("option", { value: "quarter", children: "\u6309\u5B63\u5EA6 (YYYY-QN)" }),
3448
+ /* @__PURE__ */ jsx2("option", { value: "month", children: "\u6309\u6708\u4EFD (YYYY-MM)" })
3449
+ ]
3450
+ }
3451
+ )
3452
+ ] })
3453
+ ] }),
3454
+ /* @__PURE__ */ jsxs2(
3455
+ "div",
3456
+ {
3457
+ style: {
3458
+ display: "flex",
3459
+ flexDirection: "column",
3460
+ gap: 4,
3461
+ padding: "5px 6px",
3462
+ borderRadius: 6,
3463
+ background: "#F8FAFC",
3464
+ border: "1px solid #E2E8F0"
3465
+ },
3466
+ children: [
3467
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#334155" }, children: "\u8BA1\u7B97\u5B57\u6BB5 (Calculated Fields)" }),
3468
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.8fr 1.2fr auto", gap: 4 }, children: [
3469
+ /* @__PURE__ */ jsx2(
3470
+ "input",
3471
+ {
3472
+ type: "text",
3473
+ placeholder: "\u540D\u79F0\u5982 \u6BDB\u5229\u7387",
3474
+ style: { fontSize: 10.5, padding: "3px 5px" },
3475
+ value: calcFieldName,
3476
+ onChange: (e) => setCalcFieldName(e.target.value)
3477
+ }
3478
+ ),
3479
+ /* @__PURE__ */ jsx2(
3480
+ "input",
3481
+ {
3482
+ type: "text",
3483
+ placeholder: "\u516C\u5F0F\u5982 \u5229\u6DA6 / \u9500\u552E\u989D",
3484
+ style: { fontSize: 10.5, padding: "3px 5px" },
3485
+ value: calcFieldFormula,
3486
+ onChange: (e) => setCalcFieldFormula(e.target.value)
3487
+ }
3488
+ ),
3489
+ /* @__PURE__ */ jsx2(
3490
+ "button",
3491
+ {
3492
+ type: "button",
3493
+ className: "yudao-sheet-btn",
3494
+ style: { padding: "2px 6px", fontSize: 10.5 },
3495
+ onClick: () => {
3496
+ const n = calcFieldName.trim();
3497
+ const f = calcFieldFormula.trim();
3498
+ if (!n || !f) return;
3499
+ setPivotCalcFields([
3500
+ ...pivotCalcFields.filter((c) => c.name !== n),
3501
+ { name: n, formula: f }
3502
+ ]);
3503
+ setCalcFieldName("");
3504
+ setCalcFieldFormula("");
3505
+ },
3506
+ children: "+ \u6DFB\u52A0"
3507
+ }
3508
+ )
3509
+ ] }),
3510
+ pivotCalcFields.length > 0 && /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: pivotCalcFields.map((cf) => /* @__PURE__ */ jsxs2(
3511
+ "span",
3512
+ {
3513
+ style: {
3514
+ display: "inline-flex",
3515
+ alignItems: "center",
3516
+ gap: 4,
3517
+ fontSize: 10,
3518
+ padding: "2px 6px",
3519
+ borderRadius: 4,
3520
+ background: "#F3E8FF",
3521
+ color: "#6B21A8"
3522
+ },
3523
+ children: [
3524
+ cf.name,
3525
+ " = ",
3526
+ cf.formula,
3527
+ /* @__PURE__ */ jsx2(
3528
+ "button",
3529
+ {
3530
+ type: "button",
3531
+ onClick: () => setPivotCalcFields(pivotCalcFields.filter((x) => x.name !== cf.name)),
3532
+ style: {
3533
+ border: "none",
3534
+ background: "transparent",
3535
+ color: "#6B21A8",
3536
+ cursor: "pointer",
3537
+ padding: 0,
3538
+ fontSize: 11
3539
+ },
3540
+ children: "\xD7"
3541
+ }
3542
+ )
3543
+ ]
3544
+ },
3545
+ cf.name
3546
+ )) })
3547
+ ]
3548
+ }
3549
+ ),
3550
+ /* @__PURE__ */ jsxs2("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer", fontSize: 11 }, children: [
3551
+ /* @__PURE__ */ jsx2(
3552
+ "input",
3553
+ {
3554
+ type: "checkbox",
3555
+ checked: withPivotChart,
3556
+ onChange: (e) => setWithPivotChart(e.target.checked)
3557
+ }
3558
+ ),
3559
+ /* @__PURE__ */ jsx2("span", { children: "\u65B0\u5EFA\u65F6\u540C\u6B65\u751F\u6210\u8054\u52A8\u900F\u89C6\u56FE (PivotChart)" })
3560
+ ] }),
3561
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 4 }, children: [
3562
+ /* @__PURE__ */ jsx2(
3563
+ "button",
3564
+ {
3565
+ "data-testid": "yudao-pivot-apply-btn",
3566
+ type: "button",
3567
+ className: "yudao-sheet-btn is-soft-primary",
3568
+ onClick: () => {
3569
+ const effectiveRows = pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol];
3570
+ const effectiveVals = pivotValueFields.length > 0 ? pivotValueFields : [{ colIndex: pivotValCol, aggFunc: pivotAgg }];
3571
+ const firstVal = effectiveVals[0];
3572
+ const builtConfig = {
3573
+ ...activePivot ?? {},
3574
+ ...pivotSourceRange.trim() ? { sourceRange: pivotSourceRange.trim() } : {},
3575
+ rowDimCols: effectiveRows,
3576
+ rowFields: effectiveRows,
3577
+ colDimCols: pivotColFields,
3578
+ columnFields: pivotColFields,
3579
+ valueCol: firstVal.colIndex,
3580
+ aggFunc: firstVal.aggFunc.toUpperCase(),
3581
+ valueFields: effectiveVals,
3582
+ filterFields: pivotFilterFields.length > 0 ? pivotFilterFields : void 0,
3583
+ calculatedFields: pivotCalcFields.length > 0 ? pivotCalcFields : void 0,
3584
+ valueShowAs: pivotShowAs,
3585
+ ...pivotDateGroup ? { dateGroupBy: pivotDateGroup } : {},
3586
+ showSubtotals: true,
3587
+ withPivotChart,
3588
+ pivotChartType: chartType
3589
+ };
3590
+ if (activePivot?.id) {
3591
+ templateService.addOrUpdatePivot(unitId, builtConfig);
3592
+ commandService.syncExecuteCommand(RefreshSheetPivotCommand.id, {
3593
+ unitId,
3594
+ pivotId: activePivot.id
3595
+ });
3596
+ } else {
3597
+ commandService.syncExecuteCommand(GenerateSheetPivotCommand.id, {
3598
+ unitId,
3599
+ sourceSubUnitId: sheet.getSheetId(),
3600
+ pivotConfig: builtConfig
3601
+ });
3602
+ }
3603
+ },
3604
+ children: activePivot ? "\u5E94\u7528\u5E76\u5237\u65B0\u900F\u89C6\u8868" : `\u751F\u6210\u900F\u89C6\u8868${withPivotChart ? " + \u900F\u89C6\u56FE" : ""}`
3605
+ }
3606
+ ),
3607
+ /* @__PURE__ */ jsx2(
3608
+ "button",
3609
+ {
3610
+ "data-testid": "yudao-pivot-create-chart-btn",
3611
+ type: "button",
3612
+ className: "yudao-sheet-btn",
3613
+ onClick: () => {
3614
+ const targetPivot = activePivot ?? pivots[pivots.length - 1];
3615
+ if (targetPivot?.targetSheetId) {
3616
+ const pivotSheet = workbook.getSheetBySheetId(targetPivot.targetSheetId);
3617
+ if (pivotSheet) {
3618
+ const pSnap = pivotSheet.getConfig();
3619
+ const linked = buildPivotLinkedChart(
3620
+ pSnap,
3621
+ { ...targetPivot, pivotChartType: chartType },
3622
+ targetPivot.targetSheetId
3623
+ );
3624
+ if (linked) {
3625
+ commandService.syncExecuteCommand(UpdateSheetChartCommand.id, {
3626
+ unitId,
3627
+ chart: linked
3628
+ });
3629
+ setSelectedChartId(linked.id);
3630
+ return;
3631
+ }
3632
+ }
3633
+ }
3634
+ commandService.syncExecuteCommand(GenerateSheetPivotCommand.id, {
3635
+ unitId,
3636
+ sourceSubUnitId: sheet.getSheetId(),
3637
+ pivotConfig: {
3638
+ ...pivotSourceRange.trim() ? { sourceRange: pivotSourceRange.trim() } : {},
3639
+ rowDimCols: pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol],
3640
+ rowFields: pivotRowFields.length > 0 ? pivotRowFields : [pivotRowCol],
3641
+ colDimCols: pivotColFields,
3642
+ columnFields: pivotColFields,
3643
+ valueCol: pivotValueFields[0]?.colIndex ?? pivotValCol,
3644
+ aggFunc: (pivotValueFields[0]?.aggFunc ?? pivotAgg).toUpperCase(),
3645
+ valueFields: pivotValueFields,
3646
+ filterFields: pivotFilterFields.length > 0 ? pivotFilterFields : void 0,
3647
+ calculatedFields: pivotCalcFields.length > 0 ? pivotCalcFields : void 0,
3648
+ showSubtotals: true,
3649
+ withPivotChart: true,
3650
+ pivotChartType: chartType
3651
+ }
3652
+ });
3653
+ },
3654
+ children: "+ \u521B\u5EFA\u900F\u89C6\u56FE"
3655
+ }
3656
+ )
3657
+ ] })
3658
+ ]
3659
+ }
3660
+ ),
3661
+ /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
3662
+ /* @__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" }),
3663
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 0.8fr 1fr", gap: 4 }, children: [
3664
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3665
+ /* @__PURE__ */ jsx2("span", { children: "\u6570\u636E\u533A\u95F4" }),
3666
+ /* @__PURE__ */ jsx2(
3667
+ "input",
3668
+ {
3669
+ type: "text",
3670
+ value: slicerRange,
3671
+ onChange: (e) => setSlicerRange(e.target.value)
3672
+ }
3673
+ )
3674
+ ] }),
3675
+ /* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
3676
+ /* @__PURE__ */ jsx2("span", { children: "\u7B5B\u9009\u5217" }),
2516
3677
  /* @__PURE__ */ jsx2("select", { value: slicerCol, onChange: (e) => setSlicerCol(Number(e.target.value)), children: [0, 1, 2, 3, 4, 5].map((c) => /* @__PURE__ */ jsxs2("option", { value: c, children: [
2517
3678
  colIndexToLetter(c),
2518
3679
  " \u5217"
@@ -2619,11 +3780,11 @@ var SheetInspectorPanel = () => {
2619
3780
  ),
2620
3781
  /* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
2621
3782
  /* @__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 (",
3783
+ "\u516C\u5F0F\u6C42\u503C\u4E0E\u76D1\u89C6\u7A97\u53E3 (",
2623
3784
  activeRef,
2624
3785
  ")"
2625
3786
  ] }),
2626
- /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 4 }, children: [
3787
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
2627
3788
  /* @__PURE__ */ jsx2(
2628
3789
  "button",
2629
3790
  {
@@ -2661,64 +3822,231 @@ var SheetInspectorPanel = () => {
2661
3822
  },
2662
3823
  children: "\u8FFD\u8E2A\u4ECE\u5C5E\u5355\u5143\u683C"
2663
3824
  }
2664
- ),
2665
- /* @__PURE__ */ jsx2(
2666
- "button",
2667
- {
2668
- type: "button",
2669
- className: "yudao-sheet-btn",
2670
- onClick: () => {
2671
- const steps = evaluateFormulaSteps(
2672
- workbook.save(),
2673
- sheet.getSheetId(),
2674
- activeRow,
2675
- activeCol
2676
- );
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
- });
2714
- },
2715
- children: [
2716
- "+ \u76D1\u89C6\u5F53\u524D\u5355\u5143\u683C ",
2717
- activeRef
2718
- ]
2719
- }
2720
3825
  )
2721
3826
  ] }),
3827
+ /* @__PURE__ */ jsxs2(
3828
+ "div",
3829
+ {
3830
+ "data-testid": "yudao-formula-step-evaluator",
3831
+ style: {
3832
+ display: "flex",
3833
+ flexDirection: "column",
3834
+ gap: 5,
3835
+ padding: "6px 7px",
3836
+ borderRadius: 6,
3837
+ background: "#F8FAFC",
3838
+ border: "1px solid #E2E8F0"
3839
+ },
3840
+ children: [
3841
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr auto", gap: 4 }, children: [
3842
+ /* @__PURE__ */ jsx2(
3843
+ "button",
3844
+ {
3845
+ "data-testid": "yudao-formula-step-into",
3846
+ type: "button",
3847
+ className: "yudao-sheet-btn is-soft-primary",
3848
+ onClick: () => {
3849
+ const key = `${sheet.getSheetId()}:${activeRef}`;
3850
+ const steps = evaluateFormulaSteps(
3851
+ workbook.save(),
3852
+ sheet.getSheetId(),
3853
+ activeRow,
3854
+ activeCol
3855
+ );
3856
+ setEvalCellKey(key);
3857
+ setEvalSteps(steps);
3858
+ const nextIdx = evalCellKey === key && evalSteps.length === steps.length ? Math.min(steps.length - 1, evalStepIdx + 1) : 0;
3859
+ setEvalStepIdx(nextIdx);
3860
+ setAuditOutput(steps.join(" => "));
3861
+ },
3862
+ children: "\u6B65\u5165\u6C42\u503C (Step Into)"
3863
+ }
3864
+ ),
3865
+ /* @__PURE__ */ jsx2(
3866
+ "button",
3867
+ {
3868
+ "data-testid": "yudao-formula-eval-next",
3869
+ type: "button",
3870
+ className: "yudao-sheet-btn",
3871
+ onClick: () => {
3872
+ const key = `${sheet.getSheetId()}:${activeRef}`;
3873
+ const steps = evalCellKey === key && evalSteps.length > 0 ? evalSteps : evaluateFormulaSteps(
3874
+ workbook.save(),
3875
+ sheet.getSheetId(),
3876
+ activeRow,
3877
+ activeCol
3878
+ );
3879
+ const nextIdx = evalCellKey === key ? Math.min(steps.length - 1, evalStepIdx + 1) : 0;
3880
+ setEvalCellKey(key);
3881
+ setEvalSteps(steps);
3882
+ setEvalStepIdx(nextIdx);
3883
+ setAuditOutput(steps[nextIdx] ?? "");
3884
+ },
3885
+ children: "\u4E0B\u4E00\u6B65\u6C42\u503C (Next)"
3886
+ }
3887
+ ),
3888
+ /* @__PURE__ */ jsx2(
3889
+ "button",
3890
+ {
3891
+ type: "button",
3892
+ className: "yudao-sheet-btn",
3893
+ style: { padding: "2px 7px", fontSize: 10.5 },
3894
+ onClick: () => {
3895
+ setEvalStepIdx(0);
3896
+ },
3897
+ children: "\u91CD\u7F6E"
3898
+ }
3899
+ )
3900
+ ] }),
3901
+ evalSteps.length > 0 && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: 3, fontSize: 10.5 }, children: [
3902
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", justifyContent: "space-between", color: "#475569" }, children: [
3903
+ /* @__PURE__ */ jsxs2("span", { children: [
3904
+ "\u5F53\u524D\u6C42\u503C\u5B50\u8868\u8FBE\u5F0F (",
3905
+ evalCellKey.split(":")[1] ?? activeRef,
3906
+ ")"
3907
+ ] }),
3908
+ /* @__PURE__ */ jsxs2("span", { style: { fontWeight: 600, color: "#2C53F1" }, children: [
3909
+ "\u6B65\u9AA4 ",
3910
+ Math.min(evalStepIdx + 1, evalSteps.length),
3911
+ " / ",
3912
+ evalSteps.length
3913
+ ] })
3914
+ ] }),
3915
+ /* @__PURE__ */ jsx2(
3916
+ "div",
3917
+ {
3918
+ "data-testid": "yudao-formula-current-step",
3919
+ style: {
3920
+ padding: "4px 6px",
3921
+ borderRadius: 4,
3922
+ background: "#EEF2FF",
3923
+ border: "1px solid #C7D2FE",
3924
+ color: "#1E1B4B",
3925
+ fontFamily: "monospace",
3926
+ wordBreak: "break-all"
3927
+ },
3928
+ children: evalSteps[Math.min(evalStepIdx, evalSteps.length - 1)]
3929
+ }
3930
+ )
3931
+ ] })
3932
+ ]
3933
+ }
3934
+ ),
3935
+ /* @__PURE__ */ jsxs2(
3936
+ "div",
3937
+ {
3938
+ "data-testid": "yudao-formula-watch-window",
3939
+ style: { display: "flex", flexDirection: "column", gap: 4 },
3940
+ children: [
3941
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 4 }, children: [
3942
+ /* @__PURE__ */ jsxs2("span", { style: { fontSize: 11, fontWeight: 600, color: "#4E5565" }, children: [
3943
+ "\u76D1\u89C6\u7A97\u53E3 (",
3944
+ (metadata.watchCells ?? []).length,
3945
+ " \u9879)"
3946
+ ] }),
3947
+ /* @__PURE__ */ jsxs2(
3948
+ "button",
3949
+ {
3950
+ type: "button",
3951
+ className: "yudao-sheet-btn",
3952
+ style: { padding: "2px 8px", fontSize: 10.5 },
3953
+ onClick: () => {
3954
+ const curList = metadata.watchCells ?? [];
3955
+ const sid = sheet.getSheetId();
3956
+ if (curList.some((w) => w.sheetId === sid && w.row === activeRow && w.col === activeCol)) {
3957
+ return;
3958
+ }
3959
+ templateService.setTemplateMetadata(unitId, {
3960
+ ...metadata,
3961
+ watchCells: [
3962
+ ...curList,
3963
+ {
3964
+ id: `watch-${generateRandomId(5)}`,
3965
+ sheetId: sid,
3966
+ row: activeRow,
3967
+ col: activeCol,
3968
+ cellRef: activeRef
3969
+ }
3970
+ ]
3971
+ });
3972
+ },
3973
+ children: [
3974
+ "+ \u76D1\u89C6\u5F53\u524D\u683C ",
3975
+ activeRef
3976
+ ]
3977
+ }
3978
+ )
3979
+ ] }),
3980
+ /* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr auto", gap: 4 }, children: [
3981
+ /* @__PURE__ */ jsx2(
3982
+ "input",
3983
+ {
3984
+ "data-testid": "yudao-watch-ref-input",
3985
+ type: "text",
3986
+ placeholder: "\u8F93\u5165\u5F15\u7528\u5982 Sheet1!D10 \u6216 F10",
3987
+ style: { fontSize: 11, padding: "3px 6px" },
3988
+ value: watchInputRef,
3989
+ onChange: (e) => setWatchInputRef(e.target.value)
3990
+ }
3991
+ ),
3992
+ /* @__PURE__ */ jsx2(
3993
+ "button",
3994
+ {
3995
+ "data-testid": "yudao-watch-add-input-btn",
3996
+ type: "button",
3997
+ className: "yudao-sheet-btn is-soft-primary",
3998
+ style: { padding: "2px 8px", fontSize: 10.5 },
3999
+ onClick: () => {
4000
+ const raw = watchInputRef.trim();
4001
+ if (!raw) return;
4002
+ let targetSheet = sheet;
4003
+ let cellPart = raw;
4004
+ const bangIdx = raw.lastIndexOf("!");
4005
+ if (bangIdx > 0) {
4006
+ const sheetToken = raw.slice(0, bangIdx).trim().replace(/^'+|'+$/g, "");
4007
+ cellPart = raw.slice(bangIdx + 1).trim();
4008
+ const snap = workbook.save();
4009
+ for (const sid2 of snap.sheetOrder ?? Object.keys(snap.sheets ?? {})) {
4010
+ const ws = workbook.getSheetBySheetId(sid2);
4011
+ if (ws && (ws.getName() === sheetToken || ws.getSheetId() === sheetToken)) {
4012
+ targetSheet = ws;
4013
+ break;
4014
+ }
4015
+ }
4016
+ }
4017
+ const cleanCell = cellPart.replace(/\$/g, "").toUpperCase();
4018
+ const coords = a1ToCellCoords(cleanCell);
4019
+ if (!coords) return;
4020
+ const sid = targetSheet.getSheetId();
4021
+ const curList = metadata.watchCells ?? [];
4022
+ if (curList.some(
4023
+ (w) => w.sheetId === sid && w.row === coords.row && w.col === coords.col
4024
+ )) {
4025
+ setWatchInputRef("");
4026
+ return;
4027
+ }
4028
+ templateService.setTemplateMetadata(unitId, {
4029
+ ...metadata,
4030
+ watchCells: [
4031
+ ...curList,
4032
+ {
4033
+ id: `watch-${generateRandomId(5)}`,
4034
+ sheetId: sid,
4035
+ row: coords.row,
4036
+ col: coords.col,
4037
+ cellRef: cellCoordsToA1(coords.row, coords.col)
4038
+ }
4039
+ ]
4040
+ });
4041
+ setWatchInputRef("");
4042
+ },
4043
+ children: "+ \u6DFB\u52A0\u76D1\u89C6"
4044
+ }
4045
+ )
4046
+ ] })
4047
+ ]
4048
+ }
4049
+ ),
2722
4050
  (metadata.watchCells ?? []).length > 0 && /* @__PURE__ */ jsx2(
2723
4051
  "div",
2724
4052
  {
@@ -5789,21 +7117,22 @@ import { SetRangeValuesMutation as SetRangeValuesMutation3, SetWorksheetActiveOp
5789
7117
  import { SheetScrollManagerService, SheetSkeletonManagerService } from "@univerjs/sheets-ui";
5790
7118
  import { useDependency as useDependency5, useObservable as useObservable5 } from "@univerjs/ui";
5791
7119
  import {
5792
- AddOrUpdateSheetShapeCommand as AddOrUpdateSheetShapeCommand2,
5793
7120
  AddOrUpdateSheetSlicerCommand as AddOrUpdateSheetSlicerCommand2,
5794
7121
  AddOrUpdateSheetTimelineCommand as AddOrUpdateSheetTimelineCommand2,
7122
+ AddSheetOutlineGroupCommand,
5795
7123
  ApplySheetSlicerSelectionCommand,
5796
7124
  ApplySheetTimelineFilterCommand,
5797
7125
  BindSheetCellDatasetCommand as BindSheetCellDatasetCommand3,
5798
7126
  cellCoordsToA1 as cellCoordsToA13,
5799
7127
  colIndexToLetter as colIndexToLetter2,
5800
7128
  evaluateWorksheetConditionalVisuals,
7129
+ ExpandSheetOutlineToLevelCommand as ExpandSheetOutlineToLevelCommand2,
5801
7130
  extractSlicerMembers,
5802
7131
  getCellYudaoMeta as getCellYudaoMeta2,
5803
7132
  hasCellPlaceholder,
5804
7133
  ISheetIoService as ISheetIoService4,
5805
7134
  ISheetTemplateService as ISheetTemplateService5,
5806
- parseA1Range,
7135
+ parseA1Range as parseA1Range2,
5807
7136
  RemoveSheetShapeCommand,
5808
7137
  RemoveSheetSlicerCommand,
5809
7138
  RemoveSheetTimelineCommand,
@@ -5815,9 +7144,11 @@ import {
5815
7144
  resolveSelectionMasterCell as resolveSelectionMasterCell3,
5816
7145
  resolveShapeDisplayText,
5817
7146
  resolveSheetChartData,
5818
- ToggleSheetOutlineCommand
7147
+ resolveWorksheetPrintConfig,
7148
+ ToggleSheetOutlineCollapseCommand,
7149
+ UpdateSheetShapeCommand
5819
7150
  } from "@yudaocode/univer-sheets";
5820
- import { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState4 } from "react";
7151
+ import React4, { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState4 } from "react";
5821
7152
  import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
5822
7153
  var QrCellImage = ({ text, size, errorLevel = "M", color, bgColor, logoDataUrl, logoSizeRatio }) => {
5823
7154
  const src = useMemo(
@@ -5912,7 +7243,9 @@ var BuiltinSvgChart = ({ chart, data, onSelectItem }) => {
5912
7243
  index
5913
7244
  });
5914
7245
  };
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);
7246
+ const hasWave2Config = Boolean(chart.trendline) && chart.trendline !== "none" || Boolean(
7247
+ chart.errorBars && (Array.isArray(chart.errorBars) ? chart.errorBars.length > 0 : Boolean(chart.errorBars.type))
7248
+ ) || 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
7249
  if (!LEGACY_INLINE_CHART_TYPES.has(cType) || hasWave2Config) {
5917
7250
  const svgHtml = renderSheetChartSvg(chart, data).replace(
5918
7251
  "<svg ",
@@ -6058,40 +7391,6 @@ var BuiltinSvgChart = ({ chart, data, onSelectItem }) => {
6058
7391
  ] }, i);
6059
7392
  }) });
6060
7393
  }
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
7394
  if (cType === "horizontalBar") {
6096
7395
  const count2 = Math.max(1, vals.length);
6097
7396
  const slotH = Math.min(24, 108 / count2);
@@ -7049,19 +8348,201 @@ var FloatingTimelineCard = ({ timeline, onMove, onRemove, onUpdateGranularity, o
7049
8348
  }
7050
8349
  );
7051
8350
  };
7052
- var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
8351
+ function getShapeAnchorMidpoints(sh) {
8352
+ const cx = sh.left + sh.width / 2;
8353
+ const cy = sh.top + sh.height / 2;
8354
+ return [
8355
+ { x: cx, y: sh.top },
8356
+ { x: sh.left + sh.width, y: cy },
8357
+ { x: cx, y: sh.top + sh.height },
8358
+ { x: sh.left, y: cy }
8359
+ ];
8360
+ }
8361
+ function findNearestAnchorMidpoint(px, py, candidates, excludeId, threshold = 22) {
8362
+ let best = null;
8363
+ for (const cand of candidates) {
8364
+ if (cand.id === excludeId || cand.shapeType === "line" || cand.shapeType === "connector") {
8365
+ continue;
8366
+ }
8367
+ for (const pt of getShapeAnchorMidpoints(cand)) {
8368
+ const d = Math.hypot(pt.x - px, pt.y - py);
8369
+ if (d <= threshold && (!best || d < best.dist)) {
8370
+ best = { shapeId: cand.id, x: pt.x, y: pt.y, dist: d };
8371
+ }
8372
+ }
8373
+ }
8374
+ return best ? { shapeId: best.shapeId, x: best.x, y: best.y } : null;
8375
+ }
8376
+ var FloatingShapeCard = ({
8377
+ shape,
8378
+ rawShape,
8379
+ allShapes,
8380
+ scrollX,
8381
+ scrollY,
8382
+ selected,
8383
+ displayText,
8384
+ onSelect,
8385
+ onUpdate,
8386
+ onRemove
8387
+ }) => {
7053
8388
  const fill = shape.fillColor || "#F3F5FF";
7054
8389
  const stroke = shape.strokeColor || "#2C53F1";
7055
8390
  const textColor = shape.textColor || "#1B1C1F";
8391
+ const isConnector = shape.shapeType === "line" || shape.shapeType === "connector";
8392
+ const resolvedBox = useMemo(() => {
8393
+ if (!isConnector || !rawShape.startShapeId && !rawShape.endShapeId) {
8394
+ return { left: shape.left, top: shape.top, width: shape.width, height: shape.height };
8395
+ }
8396
+ let x1 = rawShape.left;
8397
+ let y1 = rawShape.top;
8398
+ let x2 = rawShape.left + rawShape.width;
8399
+ let y2 = rawShape.top + rawShape.height;
8400
+ if (rawShape.startShapeId) {
8401
+ const startTarget = allShapes.find((s) => s.id === rawShape.startShapeId);
8402
+ if (startTarget) {
8403
+ const mids = getShapeAnchorMidpoints(startTarget);
8404
+ mids.sort((a, b) => Math.hypot(a.x - x2, a.y - y2) - Math.hypot(b.x - x2, b.y - y2));
8405
+ x1 = mids[0].x;
8406
+ y1 = mids[0].y;
8407
+ }
8408
+ }
8409
+ if (rawShape.endShapeId) {
8410
+ const endTarget = allShapes.find((s) => s.id === rawShape.endShapeId);
8411
+ if (endTarget) {
8412
+ const mids = getShapeAnchorMidpoints(endTarget);
8413
+ mids.sort((a, b) => Math.hypot(a.x - x1, a.y - y1) - Math.hypot(b.x - x1, b.y - y1));
8414
+ x2 = mids[0].x;
8415
+ y2 = mids[0].y;
8416
+ }
8417
+ }
8418
+ const minX = Math.min(x1, x2) - scrollX;
8419
+ const minY = Math.min(y1, y2) - scrollY;
8420
+ return {
8421
+ left: minX,
8422
+ top: minY,
8423
+ width: Math.max(12, Math.abs(x2 - x1)),
8424
+ height: Math.max(12, Math.abs(y2 - y1))
8425
+ };
8426
+ }, [isConnector, rawShape, allShapes, shape.left, shape.top, shape.width, shape.height, scrollX, scrollY]);
7056
8427
  const handleDragStart = (e) => {
7057
8428
  e.preventDefault();
7058
8429
  e.stopPropagation();
8430
+ onSelect();
8431
+ const startX = e.clientX;
8432
+ const startY = e.clientY;
8433
+ const origL = rawShape.left;
8434
+ const origT = rawShape.top;
8435
+ const onMouseMove = (ev) => {
8436
+ const nextL = Math.max(4, origL + (ev.clientX - startX));
8437
+ const nextT = Math.max(4, origT + (ev.clientY - startY));
8438
+ if (isConnector) {
8439
+ const snapStart = findNearestAnchorMidpoint(nextL, nextT, allShapes, rawShape.id);
8440
+ const snapEnd = findNearestAnchorMidpoint(
8441
+ nextL + rawShape.width,
8442
+ nextT + rawShape.height,
8443
+ allShapes,
8444
+ rawShape.id
8445
+ );
8446
+ onUpdate({
8447
+ ...rawShape,
8448
+ left: snapStart ? snapStart.x : nextL,
8449
+ top: snapStart ? snapStart.y : nextT,
8450
+ startShapeId: snapStart?.shapeId,
8451
+ endShapeId: snapEnd?.shapeId
8452
+ });
8453
+ } else {
8454
+ onUpdate({ ...rawShape, left: nextL, top: nextT });
8455
+ }
8456
+ };
8457
+ const onMouseUp = () => {
8458
+ window.removeEventListener("mousemove", onMouseMove);
8459
+ window.removeEventListener("mouseup", onMouseUp);
8460
+ };
8461
+ window.addEventListener("mousemove", onMouseMove);
8462
+ window.addEventListener("mouseup", onMouseUp);
8463
+ };
8464
+ const handleResizeStart = (dir) => (e) => {
8465
+ e.preventDefault();
8466
+ e.stopPropagation();
8467
+ onSelect();
7059
8468
  const startX = e.clientX;
7060
8469
  const startY = e.clientY;
7061
- const origL = shape.left;
7062
- const origT = shape.top;
8470
+ const origL = rawShape.left;
8471
+ const origT = rawShape.top;
8472
+ const origW = rawShape.width;
8473
+ const origH = rawShape.height;
8474
+ const onMouseMove = (ev) => {
8475
+ const dx = ev.clientX - startX;
8476
+ const dy = ev.clientY - startY;
8477
+ let nextL = origL;
8478
+ let nextT = origT;
8479
+ let nextW = origW;
8480
+ let nextH = origH;
8481
+ if (dir.includes("e")) nextW = Math.max(20, origW + dx);
8482
+ if (dir.includes("s")) nextH = Math.max(16, origH + dy);
8483
+ if (dir.includes("w")) {
8484
+ const proposedW = Math.max(20, origW - dx);
8485
+ nextL = origL + (origW - proposedW);
8486
+ nextW = proposedW;
8487
+ }
8488
+ if (dir.includes("n")) {
8489
+ const proposedH = Math.max(16, origH - dy);
8490
+ nextT = origT + (origH - proposedH);
8491
+ nextH = proposedH;
8492
+ }
8493
+ if (isConnector) {
8494
+ const snapStart = dir.includes("w") || dir.includes("n") ? findNearestAnchorMidpoint(nextL, nextT, allShapes, rawShape.id) : null;
8495
+ const snapEnd = dir.includes("e") || dir.includes("s") ? findNearestAnchorMidpoint(nextL + nextW, nextT + nextH, allShapes, rawShape.id) : null;
8496
+ if (snapStart) {
8497
+ nextW = Math.max(12, nextL + nextW - snapStart.x);
8498
+ nextH = Math.max(12, nextT + nextH - snapStart.y);
8499
+ nextL = snapStart.x;
8500
+ nextT = snapStart.y;
8501
+ }
8502
+ if (snapEnd) {
8503
+ nextW = Math.max(12, snapEnd.x - nextL);
8504
+ nextH = Math.max(12, snapEnd.y - nextT);
8505
+ }
8506
+ onUpdate({
8507
+ ...rawShape,
8508
+ left: Math.round(nextL),
8509
+ top: Math.round(nextT),
8510
+ width: Math.round(nextW),
8511
+ height: Math.round(nextH),
8512
+ ...dir.includes("w") || dir.includes("n") ? { startShapeId: snapStart?.shapeId } : {},
8513
+ ...dir.includes("e") || dir.includes("s") ? { endShapeId: snapEnd?.shapeId } : {}
8514
+ });
8515
+ } else {
8516
+ onUpdate({
8517
+ ...rawShape,
8518
+ left: Math.round(nextL),
8519
+ top: Math.round(nextT),
8520
+ width: Math.round(nextW),
8521
+ height: Math.round(nextH)
8522
+ });
8523
+ }
8524
+ };
8525
+ const onMouseUp = () => {
8526
+ window.removeEventListener("mousemove", onMouseMove);
8527
+ window.removeEventListener("mouseup", onMouseUp);
8528
+ };
8529
+ window.addEventListener("mousemove", onMouseMove);
8530
+ window.addEventListener("mouseup", onMouseUp);
8531
+ };
8532
+ const handleRotateStart = (e) => {
8533
+ e.preventDefault();
8534
+ e.stopPropagation();
8535
+ onSelect();
8536
+ const boxEl = e.currentTarget.parentElement;
8537
+ if (!boxEl) return;
8538
+ const rect = boxEl.getBoundingClientRect();
8539
+ const cx = rect.left + rect.width / 2;
8540
+ const cy = rect.top + rect.height / 2;
7063
8541
  const onMouseMove = (ev) => {
7064
- onMove(Math.max(4, origL + (ev.clientX - startX)), Math.max(4, origT + (ev.clientY - startY)));
8542
+ const rad = Math.atan2(ev.clientY - cy, ev.clientX - cx);
8543
+ let deg = Math.round((rad * 180 / Math.PI + 90 + 360) % 360);
8544
+ if (ev.shiftKey) deg = Math.round(deg / 15) * 15;
8545
+ onUpdate({ ...rawShape, rotation: deg });
7065
8546
  };
7066
8547
  const onMouseUp = () => {
7067
8548
  window.removeEventListener("mousemove", onMouseMove);
@@ -7071,7 +8552,37 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7071
8552
  window.addEventListener("mouseup", onMouseUp);
7072
8553
  };
7073
8554
  const renderShapeGeometry = () => {
8555
+ const markerId = `yudao-arrow-${shape.id}`;
7074
8556
  switch (shape.shapeType) {
8557
+ case "line":
8558
+ case "connector":
8559
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
8560
+ (shape.arrowEnd || shape.shapeType === "connector") && /* @__PURE__ */ jsx5("defs", { children: /* @__PURE__ */ jsx5(
8561
+ "marker",
8562
+ {
8563
+ id: markerId,
8564
+ viewBox: "0 0 10 10",
8565
+ refX: "8",
8566
+ refY: "5",
8567
+ markerWidth: "6",
8568
+ markerHeight: "6",
8569
+ orient: "auto-start-reverse",
8570
+ children: /* @__PURE__ */ jsx5("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: stroke })
8571
+ }
8572
+ ) }),
8573
+ /* @__PURE__ */ jsx5(
8574
+ "line",
8575
+ {
8576
+ x1: 4,
8577
+ y1: 4,
8578
+ x2: 96,
8579
+ y2: 96,
8580
+ stroke,
8581
+ strokeWidth: shape.strokeWidth || 2.2,
8582
+ markerEnd: shape.arrowEnd || shape.shapeType === "connector" ? `url(#${markerId})` : void 0
8583
+ }
8584
+ )
8585
+ ] });
7075
8586
  case "roundRect":
7076
8587
  return /* @__PURE__ */ jsx5("rect", { x: 2, y: 2, width: 96, height: 96, rx: 14, fill, stroke, strokeWidth: 2 });
7077
8588
  case "ellipse":
@@ -7079,6 +8590,7 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7079
8590
  case "diamond":
7080
8591
  return /* @__PURE__ */ jsx5("polygon", { points: "50,3 97,50 50,97 3,50", fill, stroke, strokeWidth: 2 });
7081
8592
  case "arrow":
8593
+ case "rightArrow":
7082
8594
  return /* @__PURE__ */ jsx5(
7083
8595
  "polygon",
7084
8596
  {
@@ -7089,6 +8601,7 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7089
8601
  }
7090
8602
  );
7091
8603
  case "callout":
8604
+ case "wedgeRoundRectCallout":
7092
8605
  return /* @__PURE__ */ jsx5(
7093
8606
  "polygon",
7094
8607
  {
@@ -7103,19 +8616,32 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7103
8616
  return /* @__PURE__ */ jsx5("rect", { x: 2, y: 2, width: 96, height: 96, rx: 3, fill, stroke, strokeWidth: 2 });
7104
8617
  }
7105
8618
  };
8619
+ const handles = [
8620
+ { dir: "nw", style: { left: -4, top: -4 }, cursor: "nwse-resize" },
8621
+ { dir: "n", style: { left: "calc(50% - 4px)", top: -4 }, cursor: "ns-resize" },
8622
+ { dir: "ne", style: { right: -4, top: -4 }, cursor: "nesw-resize" },
8623
+ { dir: "e", style: { right: -4, top: "calc(50% - 4px)" }, cursor: "ew-resize" },
8624
+ { dir: "se", style: { right: -4, bottom: -4 }, cursor: "nwse-resize" },
8625
+ { dir: "s", style: { left: "calc(50% - 4px)", bottom: -4 }, cursor: "ns-resize" },
8626
+ { dir: "sw", style: { left: -4, bottom: -4 }, cursor: "nesw-resize" },
8627
+ { dir: "w", style: { left: -4, top: "calc(50% - 4px)" }, cursor: "ew-resize" }
8628
+ ];
7106
8629
  return /* @__PURE__ */ jsxs5(
7107
8630
  "div",
7108
8631
  {
7109
8632
  onMouseDown: handleDragStart,
7110
8633
  style: {
7111
8634
  position: "absolute",
7112
- left: shape.left,
7113
- top: shape.top,
7114
- width: shape.width,
7115
- height: shape.height,
8635
+ left: resolvedBox.left,
8636
+ top: resolvedBox.top,
8637
+ width: resolvedBox.width,
8638
+ height: resolvedBox.height,
8639
+ transform: rawShape.rotation ? `rotate(${rawShape.rotation}deg)` : void 0,
8640
+ transformOrigin: "center center",
8641
+ outline: selected ? "1.5px dashed #2C53F1" : void 0,
7116
8642
  pointerEvents: "auto",
7117
8643
  cursor: "move",
7118
- zIndex: 24,
8644
+ zIndex: selected ? 28 : 24,
7119
8645
  display: "flex",
7120
8646
  alignItems: "center",
7121
8647
  justifyContent: "center"
@@ -7126,18 +8652,18 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7126
8652
  {
7127
8653
  viewBox: "0 0 100 100",
7128
8654
  preserveAspectRatio: "none",
7129
- style: { position: "absolute", inset: 0, width: "100%", height: "100%" },
8655
+ style: { position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" },
7130
8656
  children: renderShapeGeometry()
7131
8657
  }
7132
8658
  ),
7133
- /* @__PURE__ */ jsx5(
8659
+ !isConnector && /* @__PURE__ */ jsx5(
7134
8660
  "span",
7135
8661
  {
7136
8662
  style: {
7137
8663
  position: "relative",
7138
8664
  padding: "4px 8px",
7139
8665
  color: textColor,
7140
- fontSize: 12,
8666
+ fontSize: rawShape.fontSize || 12,
7141
8667
  fontWeight: 600,
7142
8668
  textAlign: "center",
7143
8669
  lineHeight: 1.3,
@@ -7147,6 +8673,43 @@ var FloatingShapeCard = ({ shape, displayText, onMove, onRemove }) => {
7147
8673
  children: displayText
7148
8674
  }
7149
8675
  ),
8676
+ selected && /* @__PURE__ */ jsxs5(Fragment3, { children: [
8677
+ /* @__PURE__ */ jsx5(
8678
+ "div",
8679
+ {
8680
+ onMouseDown: handleRotateStart,
8681
+ title: `\u62D6\u62FD\u65CB\u8F6C\u56FE\u5F62 (${rawShape.rotation ?? 0}\xB0)`,
8682
+ style: {
8683
+ position: "absolute",
8684
+ left: "calc(50% - 5px)",
8685
+ top: -20,
8686
+ width: 10,
8687
+ height: 10,
8688
+ borderRadius: "50%",
8689
+ background: "#FFFFFF",
8690
+ border: "2px solid #2C53F1",
8691
+ cursor: "grab"
8692
+ }
8693
+ }
8694
+ ),
8695
+ handles.map((h) => /* @__PURE__ */ jsx5(
8696
+ "div",
8697
+ {
8698
+ onMouseDown: handleResizeStart(h.dir),
8699
+ style: {
8700
+ position: "absolute",
8701
+ width: 8,
8702
+ height: 8,
8703
+ borderRadius: 2,
8704
+ background: "#FFFFFF",
8705
+ border: "1.5px solid #2C53F1",
8706
+ cursor: h.cursor,
8707
+ ...h.style
8708
+ }
8709
+ },
8710
+ h.dir
8711
+ ))
8712
+ ] }),
7150
8713
  /* @__PURE__ */ jsx5(
7151
8714
  "button",
7152
8715
  {
@@ -7198,6 +8761,8 @@ var SheetRichOverlayHost = () => {
7198
8761
  );
7199
8762
  const [tick, setTick] = useState4(0);
7200
8763
  const [drillToast, setDrillToast] = useState4(null);
8764
+ const [selectedShapeId, setSelectedShapeId] = useState4(null);
8765
+ const [pageBreakPreviewMode, setPageBreakPreviewMode] = useState4(false);
7201
8766
  useEffect4(() => {
7202
8767
  if (!workbook) return;
7203
8768
  const disp = commandService.onCommandExecuted((info) => {
@@ -7420,33 +8985,89 @@ var SheetRichOverlayHost = () => {
7420
8985
  );
7421
8986
  const outlines = (metadata.outlines ?? []).filter((o) => o.sheetId === activeSheetId);
7422
8987
  const outlinePills2 = [];
8988
+ let maxRowOutlineLevel = 0;
8989
+ let maxColOutlineLevel = 0;
7423
8990
  for (const o of outlines) {
7424
8991
  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;
8992
+ if (o.level > maxRowOutlineLevel) maxRowOutlineLevel = o.level;
8993
+ const startCoord = skeleton.getCellWithCoordByIndex(Math.max(0, o.startIndex), 0);
8994
+ const endCoord = skeleton.getCellWithCoordByIndex(Math.max(0, o.endIndex), 0);
8995
+ const top = (startCoord.startY - colHeaderH - vpScrollXY.y) * scaleY;
8996
+ const bottom = (endCoord.endY - colHeaderH - vpScrollXY.y) * scaleY;
7428
8997
  const left = Math.max(2, (o.level - 1) * 18 + 2);
7429
- if (top >= -16 && top <= canvasRect.height) {
7430
- outlinePills2.push({ outline: o, left, top });
8998
+ if (bottom >= -16 && top <= canvasRect.height) {
8999
+ outlinePills2.push({
9000
+ outline: o,
9001
+ left,
9002
+ top: Math.max(2, top + 2),
9003
+ spanSize: Math.max(16, bottom - top)
9004
+ });
7431
9005
  }
7432
9006
  } 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;
9007
+ if (o.level > maxColOutlineLevel) maxColOutlineLevel = o.level;
9008
+ const startCoord = skeleton.getCellWithCoordByIndex(0, Math.max(0, o.startIndex));
9009
+ const endCoord = skeleton.getCellWithCoordByIndex(0, Math.max(0, o.endIndex));
9010
+ const left = (startCoord.startX - rowHeaderW - vpScrollXY.x) * scaleX;
9011
+ const right = (endCoord.endX - rowHeaderW - vpScrollXY.x) * scaleX;
7436
9012
  const top = Math.max(2, (o.level - 1) * 18 + 2);
7437
- if (left >= -16 && left <= canvasRect.width) {
7438
- outlinePills2.push({ outline: o, left, top });
9013
+ if (right >= -16 && left <= canvasRect.width) {
9014
+ outlinePills2.push({
9015
+ outline: o,
9016
+ left: Math.max(2, left + 2),
9017
+ top,
9018
+ spanSize: Math.max(16, right - left)
9019
+ });
7439
9020
  }
7440
9021
  }
7441
9022
  }
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;
9023
+ const effectiveSheetPrintCfg = resolveWorksheetPrintConfig(wbSnapWithMeta, activeSheetId, {
9024
+ printConfig: metadata.printConfig
9025
+ });
9026
+ const printOrientation = effectiveSheetPrintCfg.paperOrientation ?? effectiveSheetPrintCfg.orientation ?? metadata.printConfig?.paperOrientation ?? "A4_LANDSCAPE";
9027
+ const showPageBreakLines = features.printTemplate && (pageBreakPreviewMode || effectiveSheetPrintCfg.showPageBreakLines !== false);
9028
+ const isPortrait = printOrientation === "A4_PORTRAIT" || printOrientation === "portrait";
9029
+ const pageWidthPx = isPortrait ? 680 : printOrientation === "A3_LANDSCAPE" ? 1360 : printOrientation === "INVOICE_240_140" || printOrientation === "INVOICE_240_93" ? 820 : 980;
9030
+ const pageHeightPx = isPortrait ? 960 : 680;
7445
9031
  const pageBreakX = (pageWidthPx - vpScrollXY.x) * scaleX;
9032
+ const manualRowBreaks = Array.isArray(effectiveSheetPrintCfg.rowBreaks) ? effectiveSheetPrintCfg.rowBreaks.filter((n) => Number.isFinite(n) && n >= 1) : [];
9033
+ const manualColBreaks = Array.isArray(effectiveSheetPrintCfg.colBreaks) ? effectiveSheetPrintCfg.colBreaks.filter((n) => Number.isFinite(n) && n >= 1) : [];
9034
+ const rowBreakLines = [];
9035
+ for (const brkId of manualRowBreaks) {
9036
+ const c = skeleton.getCellWithCoordByIndex(Math.max(0, brkId - 1), 0);
9037
+ const y = (c.endY - colHeaderH - vpScrollXY.y) * scaleY;
9038
+ rowBreakLines.push({ y, breakId: brkId, manual: true });
9039
+ }
9040
+ if (pageBreakPreviewMode) {
9041
+ for (let p = 1; p <= 4; p++) {
9042
+ const autoY = (p * pageHeightPx - vpScrollXY.y) * scaleY;
9043
+ if (!rowBreakLines.some((l) => Math.abs(l.y - autoY) < 24)) {
9044
+ const estRow = Math.max(1, Math.round(p * pageHeightPx / 24));
9045
+ rowBreakLines.push({ y: autoY, breakId: estRow, manual: false });
9046
+ }
9047
+ }
9048
+ }
9049
+ const colBreakLines = [];
9050
+ for (const brkId of manualColBreaks) {
9051
+ const c = skeleton.getCellWithCoordByIndex(0, Math.max(0, brkId - 1));
9052
+ const x = (c.endX - rowHeaderW - vpScrollXY.x) * scaleX;
9053
+ colBreakLines.push({ x, breakId: brkId, manual: true });
9054
+ }
9055
+ if (!colBreakLines.some((l) => Math.abs(l.x - pageBreakX) < 24)) {
9056
+ const estCol = Math.max(1, Math.round(pageWidthPx / 88));
9057
+ colBreakLines.push({ x: pageBreakX, breakId: estCol, manual: false });
9058
+ }
7446
9059
  return {
7447
9060
  unitId: unitId2,
7448
9061
  sheetId: activeSheetId,
7449
9062
  sheetCfg: sheetCfg2,
9063
+ metadata,
9064
+ effectiveSheetPrintCfg,
9065
+ skeleton,
9066
+ scaleX,
9067
+ scaleY,
9068
+ vpScrollXY,
9069
+ rowHeaderW,
9070
+ colHeaderH,
7450
9071
  workbookSnapshot: workbook.save(),
7451
9072
  viewportBox: {
7452
9073
  left: canvasRect.left + rowHeaderW * scaleX,
@@ -7462,7 +9083,11 @@ var SheetRichOverlayHost = () => {
7462
9083
  timelines: timelines2,
7463
9084
  shapes: shapes2,
7464
9085
  outlinePills: outlinePills2,
7465
- overlayBackgroundUrl: metadata.printConfig?.overlayBackgroundUrl || metadata.printConfig?.backgroundImageUrl || "",
9086
+ maxRowOutlineLevel,
9087
+ maxColOutlineLevel,
9088
+ rowBreakLines: rowBreakLines.sort((a, b) => a.y - b.y),
9089
+ colBreakLines: colBreakLines.sort((a, b) => a.x - b.x),
9090
+ overlayBackgroundUrl: effectiveSheetPrintCfg.overlayBackgroundUrl || effectiveSheetPrintCfg.backgroundImageUrl || metadata.printConfig?.overlayBackgroundUrl || metadata.printConfig?.backgroundImageUrl || "",
7466
9091
  showPageBreakLines,
7467
9092
  pageBreakX,
7468
9093
  printOrientation
@@ -7471,6 +9096,7 @@ var SheetRichOverlayHost = () => {
7471
9096
  workbook,
7472
9097
  features.datasetBinding,
7473
9098
  features.printTemplate,
9099
+ pageBreakPreviewMode,
7474
9100
  tick,
7475
9101
  metaVersion,
7476
9102
  renderManagerService,
@@ -7492,7 +9118,8 @@ var SheetRichOverlayHost = () => {
7492
9118
  } = overlayState;
7493
9119
  const renderSparklineNode = (box) => {
7494
9120
  const spark = box.meta.sparkline;
7495
- const rng = parseA1Range(spark.dataRange);
9121
+ const rawRange = spark.dataRange.includes("!") ? spark.dataRange.slice(spark.dataRange.lastIndexOf("!") + 1) : spark.dataRange;
9122
+ const rng = parseA1Range2(rawRange);
7496
9123
  if (!rng) return null;
7497
9124
  const vals = [];
7498
9125
  for (let r = rng.startRow; r <= rng.endRow; r++) {
@@ -7502,8 +9129,9 @@ var SheetRichOverlayHost = () => {
7502
9129
  }
7503
9130
  }
7504
9131
  if (vals.length === 0) return null;
7505
- const color = spark.color || "#2C53F1";
7506
- const negColor = spark.negativeColor || "#7D8698";
9132
+ const color = spark.colorSeries || spark.color || "#2C53F1";
9133
+ const negColor = spark.colorNegative || spark.negativeColor || "#7D8698";
9134
+ const mrkColor = spark.colorMarkers || spark.markerColor || "#1B1C1F";
7507
9135
  const highVal = Math.max(...vals);
7508
9136
  const lowVal = Math.min(...vals);
7509
9137
  const highIdx = vals.indexOf(highVal);
@@ -7512,8 +9140,8 @@ var SheetRichOverlayHost = () => {
7512
9140
  const max = Math.max(1, highVal);
7513
9141
  const span = max - min || 1;
7514
9142
  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) {
9143
+ const isHighlighted = (idx) => Boolean(spark.markers) || spark.showHighPoint && idx === highIdx || spark.showLowPoint && idx === lowIdx || spark.showFirstPoint && idx === 0 || spark.showLastPoint && idx === vals.length - 1;
9144
+ if (spark.type === "bar" || spark.type === "column" || isWinLoss) {
7517
9145
  const bw = Math.max(4, Math.floor(82 / vals.length) - 2);
7518
9146
  return /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 96 24", style: { width: "92%", height: "78%" }, children: [
7519
9147
  isWinLoss && /* @__PURE__ */ jsx5("line", { x1: 4, y1: 12, x2: 92, y2: 12, stroke: "#E3E5EA", strokeWidth: 0.8 }),
@@ -7559,17 +9187,28 @@ var SheetRichOverlayHost = () => {
7559
9187
  });
7560
9188
  const pts = coords.map((p) => `${p.x.toFixed(1)},${p.y.toFixed(1)}`).join(" ");
7561
9189
  return /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 96 24", style: { width: "92%", height: "78%" }, children: [
9190
+ spark.displayXAxis && /* @__PURE__ */ jsx5(
9191
+ "line",
9192
+ {
9193
+ x1: 4,
9194
+ y1: 20 - (0 - min) / span * 16,
9195
+ x2: 92,
9196
+ y2: 20 - (0 - min) / span * 16,
9197
+ stroke: "#CBD5E1",
9198
+ strokeWidth: 0.8
9199
+ }
9200
+ ),
7562
9201
  /* @__PURE__ */ jsx5("polyline", { fill: "none", stroke: color, strokeWidth: 1.6, points: pts }),
7563
9202
  coords.map((p) => {
7564
9203
  const marker = isHighlighted(p.i);
7565
- if (!marker && !(p.v < 0 && spark.negativeColor)) return null;
9204
+ if (!marker && !(p.v < 0 && (spark.negativeColor || spark.colorNegative))) return null;
7566
9205
  return /* @__PURE__ */ jsx5(
7567
9206
  "circle",
7568
9207
  {
7569
9208
  cx: p.x,
7570
9209
  cy: p.y,
7571
9210
  r: 2.3,
7572
- fill: p.v < 0 && spark.negativeColor ? negColor : "#1B1C1F"
9211
+ fill: p.v < 0 && (spark.negativeColor || spark.colorNegative) ? negColor : mrkColor
7573
9212
  },
7574
9213
  p.i
7575
9214
  );
@@ -7605,39 +9244,201 @@ var SheetRichOverlayHost = () => {
7605
9244
  }
7606
9245
  }
7607
9246
  ),
7608
- overlayState.showPageBreakLines && overlayState.pageBreakX > 20 && overlayState.pageBreakX < viewportBox.width && /* @__PURE__ */ jsx5(
7609
- "div",
9247
+ features.printTemplate && /* @__PURE__ */ jsx5(
9248
+ "button",
7610
9249
  {
9250
+ type: "button",
9251
+ onClick: () => setPageBreakPreviewMode((v) => !v),
7611
9252
  style: {
7612
9253
  position: "absolute",
7613
- left: overlayState.pageBreakX,
7614
- top: 0,
7615
- bottom: 0,
7616
- borderLeft: "1px dashed #94A3B8",
7617
- pointerEvents: "none",
7618
- zIndex: 8
9254
+ top: 6,
9255
+ right: 10,
9256
+ background: pageBreakPreviewMode ? "#2C53F1" : "rgba(255,255,255,0.92)",
9257
+ color: pageBreakPreviewMode ? "#FFFFFF" : "#4E5565",
9258
+ border: `1px solid ${pageBreakPreviewMode ? "#2C53F1" : "#D2DAFA"}`,
9259
+ borderRadius: 999,
9260
+ fontSize: 10.5,
9261
+ fontWeight: 600,
9262
+ padding: "2px 8px",
9263
+ cursor: "pointer",
9264
+ pointerEvents: "auto",
9265
+ zIndex: 30
7619
9266
  },
7620
- children: /* @__PURE__ */ jsx5(
7621
- "span",
9267
+ children: pageBreakPreviewMode ? "\u9000\u51FA\u5206\u9875\u9884\u89C8" : "\u5206\u9875\u9884\u89C8"
9268
+ }
9269
+ ),
9270
+ overlayState.showPageBreakLines && /* @__PURE__ */ jsxs5(Fragment3, { children: [
9271
+ overlayState.colBreakLines.map((cb, cbIdx) => {
9272
+ if (cb.x <= 12 || cb.x >= viewportBox.width) return null;
9273
+ const handleColBreakDrag = (e) => {
9274
+ e.preventDefault();
9275
+ e.stopPropagation();
9276
+ const onUp = (upEv) => {
9277
+ window.removeEventListener("mouseup", onUp);
9278
+ const localX = (upEv.clientX - viewportBox.left) / (overlayState.scaleX || 1) + overlayState.rowHeaderW + overlayState.vpScrollXY.x;
9279
+ let targetCol = 1;
9280
+ for (let c = 0; c < 120; c++) {
9281
+ const coord = overlayState.skeleton.getCellWithCoordByIndex(0, c);
9282
+ if (localX <= coord.endX) {
9283
+ targetCol = c + 1;
9284
+ break;
9285
+ }
9286
+ }
9287
+ const prevList = Array.isArray(overlayState.effectiveSheetPrintCfg.colBreaks) ? overlayState.effectiveSheetPrintCfg.colBreaks.filter((x) => x !== cb.breakId) : [];
9288
+ const nextCols = Array.from(/* @__PURE__ */ new Set([...prevList, targetCol])).sort((a, b) => a - b);
9289
+ const prevPrint = overlayState.metadata.printConfig ?? {};
9290
+ templateService.patchPrintConfig(unitId, {
9291
+ colBreaks: nextCols,
9292
+ bySheetId: {
9293
+ ...prevPrint.bySheetId ?? {},
9294
+ [sheetId]: {
9295
+ ...prevPrint.bySheetId?.[sheetId] ?? {},
9296
+ colBreaks: nextCols
9297
+ }
9298
+ }
9299
+ });
9300
+ };
9301
+ window.addEventListener("mouseup", onUp);
9302
+ };
9303
+ return /* @__PURE__ */ jsx5(
9304
+ "div",
7622
9305
  {
9306
+ onMouseDown: handleColBreakDrag,
9307
+ title: "\u62D6\u62FD\u8C03\u6574\u7EB5\u5411\u5206\u9875\u7B26\u4F4D\u7F6E",
7623
9308
  style: {
7624
9309
  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"
9310
+ left: cb.x,
9311
+ top: 0,
9312
+ bottom: 0,
9313
+ width: 5,
9314
+ borderLeft: cb.manual ? "2px solid #1D4ED8" : "1.5px dashed #3B82F6",
9315
+ cursor: "col-resize",
9316
+ pointerEvents: pageBreakPreviewMode || cb.manual ? "auto" : "none",
9317
+ zIndex: 9
7635
9318
  },
7636
- children: t("yudaoSheets.overlay.pageBreakBadge")
9319
+ children: cbIdx === 0 && /* @__PURE__ */ jsx5(
9320
+ "span",
9321
+ {
9322
+ style: {
9323
+ position: "absolute",
9324
+ top: 30,
9325
+ right: 6,
9326
+ background: "#F3F5FF",
9327
+ color: "#2C53F1",
9328
+ border: "1px solid #D2DAFA",
9329
+ borderRadius: 4,
9330
+ fontSize: 9.5,
9331
+ fontWeight: 600,
9332
+ padding: "1px 5px",
9333
+ whiteSpace: "nowrap",
9334
+ pointerEvents: "none"
9335
+ },
9336
+ children: t("yudaoSheets.overlay.pageBreakBadge")
9337
+ }
9338
+ )
9339
+ },
9340
+ `cb-${cbIdx}-${cb.breakId}`
9341
+ );
9342
+ }),
9343
+ overlayState.rowBreakLines.map((rb, rbIdx) => {
9344
+ if (rb.y <= 12 || rb.y >= viewportBox.height) return null;
9345
+ const handleRowBreakDrag = (e) => {
9346
+ e.preventDefault();
9347
+ e.stopPropagation();
9348
+ const onUp = (upEv) => {
9349
+ window.removeEventListener("mouseup", onUp);
9350
+ const localY = (upEv.clientY - viewportBox.top) / (overlayState.scaleY || 1) + overlayState.colHeaderH + overlayState.vpScrollXY.y;
9351
+ let targetRow = 1;
9352
+ for (let r = 0; r < 500; r++) {
9353
+ const coord = overlayState.skeleton.getCellWithCoordByIndex(r, 0);
9354
+ if (localY <= coord.endY) {
9355
+ targetRow = r + 1;
9356
+ break;
9357
+ }
9358
+ }
9359
+ const prevList = Array.isArray(overlayState.effectiveSheetPrintCfg.rowBreaks) ? overlayState.effectiveSheetPrintCfg.rowBreaks.filter((x) => x !== rb.breakId) : [];
9360
+ const nextRows = Array.from(/* @__PURE__ */ new Set([...prevList, targetRow])).sort((a, b) => a - b);
9361
+ const prevPrint = overlayState.metadata.printConfig ?? {};
9362
+ templateService.patchPrintConfig(unitId, {
9363
+ rowBreaks: nextRows,
9364
+ bySheetId: {
9365
+ ...prevPrint.bySheetId ?? {},
9366
+ [sheetId]: {
9367
+ ...prevPrint.bySheetId?.[sheetId] ?? {},
9368
+ rowBreaks: nextRows
9369
+ }
9370
+ }
9371
+ });
9372
+ };
9373
+ window.addEventListener("mouseup", onUp);
9374
+ };
9375
+ return /* @__PURE__ */ jsx5(
9376
+ "div",
9377
+ {
9378
+ onMouseDown: handleRowBreakDrag,
9379
+ title: "\u62D6\u62FD\u8C03\u6574\u6A2A\u5411\u5206\u9875\u7B26\u4F4D\u7F6E",
9380
+ style: {
9381
+ position: "absolute",
9382
+ left: 0,
9383
+ right: 0,
9384
+ top: rb.y,
9385
+ height: 5,
9386
+ borderTop: rb.manual ? "2px solid #1D4ED8" : "1.5px dashed #3B82F6",
9387
+ cursor: "row-resize",
9388
+ pointerEvents: "auto",
9389
+ zIndex: 9
9390
+ }
9391
+ },
9392
+ `rb-${rbIdx}-${rb.breakId}`
9393
+ );
9394
+ }),
9395
+ pageBreakPreviewMode && (() => {
9396
+ const yStops = [0, ...overlayState.rowBreakLines.map((r) => r.y).filter((y) => y > 0)];
9397
+ const xStops = [0, ...overlayState.colBreakLines.map((c) => c.x).filter((x) => x > 0)];
9398
+ const marks = [];
9399
+ let pageSeq = 1;
9400
+ for (let rIdx = 0; rIdx < Math.min(3, yStops.length); rIdx++) {
9401
+ const y0 = yStops[rIdx];
9402
+ const y1 = yStops[rIdx + 1] ?? viewportBox.height;
9403
+ for (let cIdx = 0; cIdx < Math.min(2, xStops.length); cIdx++) {
9404
+ const x0 = xStops[cIdx];
9405
+ const x1 = xStops[cIdx + 1] ?? viewportBox.width;
9406
+ const cx = (x0 + Math.min(x1, viewportBox.width)) / 2;
9407
+ const cy = (y0 + Math.min(y1, viewportBox.height)) / 2;
9408
+ const pNum = pageSeq++;
9409
+ if (cx > 40 && cy > 30 && cx < viewportBox.width && cy < viewportBox.height) {
9410
+ marks.push(
9411
+ /* @__PURE__ */ jsxs5(
9412
+ "div",
9413
+ {
9414
+ style: {
9415
+ position: "absolute",
9416
+ left: cx,
9417
+ top: cy,
9418
+ transform: "translate(-50%, -50%)",
9419
+ fontSize: 28,
9420
+ fontWeight: 800,
9421
+ color: "rgba(37, 99, 235, 0.16)",
9422
+ letterSpacing: 2,
9423
+ pointerEvents: "none",
9424
+ userSelect: "none",
9425
+ zIndex: 7
9426
+ },
9427
+ children: [
9428
+ "\u7B2C ",
9429
+ pNum,
9430
+ " \u9875"
9431
+ ]
9432
+ },
9433
+ `wm-${pNum}`
9434
+ )
9435
+ );
9436
+ }
7637
9437
  }
7638
- )
7639
- }
7640
- ),
9438
+ }
9439
+ return marks;
9440
+ })()
9441
+ ] }),
7641
9442
  drillToast && /* @__PURE__ */ jsx5(
7642
9443
  "div",
7643
9444
  {
@@ -7908,60 +9709,202 @@ var SheetRichOverlayHost = () => {
7908
9709
  },
7909
9710
  ch.id
7910
9711
  )),
7911
- outlinePills.map(({ outline, left, top }) => /* @__PURE__ */ jsx5(
7912
- "button",
9712
+ (overlayState.maxRowOutlineLevel > 0 || overlayState.maxColOutlineLevel > 0) && /* @__PURE__ */ jsxs5(
9713
+ "div",
7913
9714
  {
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
9715
  style: {
7924
9716
  position: "absolute",
7925
- left,
7926
- top,
7927
- width: 16,
7928
- height: 16,
7929
- borderRadius: 4,
9717
+ left: 4,
9718
+ top: 4,
9719
+ display: "flex",
9720
+ alignItems: "center",
9721
+ gap: 3,
9722
+ padding: "2px 5px",
9723
+ borderRadius: 5,
9724
+ background: "rgba(249, 250, 251, 0.95)",
7930
9725
  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
9726
  pointerEvents: "auto",
7939
- zIndex: 22
9727
+ zIndex: 23
7940
9728
  },
7941
- children: outline.collapsed ? "+" : "-"
7942
- },
7943
- outline.id
7944
- )),
9729
+ children: [
9730
+ overlayState.maxRowOutlineLevel > 0 && /* @__PURE__ */ jsxs5("span", { style: { display: "inline-flex", alignItems: "center", gap: 2 }, children: [
9731
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 9.5, color: "#4E5565", fontWeight: 600 }, children: "\u884C\u7EA7" }),
9732
+ Array.from({ length: overlayState.maxRowOutlineLevel + 1 }, (_, i) => i + 1).map(
9733
+ (lvl) => /* @__PURE__ */ jsx5(
9734
+ "button",
9735
+ {
9736
+ type: "button",
9737
+ title: `\u5C55\u5F00\u884C\u5927\u7EB2\u81F3\u7B2C ${lvl} \u7EA7`,
9738
+ onClick: (e) => {
9739
+ e.stopPropagation();
9740
+ commandService.syncExecuteCommand(ExpandSheetOutlineToLevelCommand2.id, {
9741
+ unitId,
9742
+ sheetId,
9743
+ dimension: "row",
9744
+ maxVisibleLevel: lvl
9745
+ });
9746
+ },
9747
+ style: {
9748
+ width: 15,
9749
+ height: 15,
9750
+ borderRadius: 3,
9751
+ border: "1px solid #CBD5E1",
9752
+ background: "#FFFFFF",
9753
+ color: "#1B1C1F",
9754
+ fontSize: 9.5,
9755
+ fontWeight: 700,
9756
+ padding: 0,
9757
+ cursor: "pointer"
9758
+ },
9759
+ children: lvl
9760
+ },
9761
+ `rlvl-${lvl}`
9762
+ )
9763
+ )
9764
+ ] }),
9765
+ overlayState.maxColOutlineLevel > 0 && /* @__PURE__ */ jsxs5("span", { style: { display: "inline-flex", alignItems: "center", gap: 2, marginLeft: 4 }, children: [
9766
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 9.5, color: "#4E5565", fontWeight: 600 }, children: "\u5217\u7EA7" }),
9767
+ Array.from({ length: overlayState.maxColOutlineLevel + 1 }, (_, i) => i + 1).map(
9768
+ (lvl) => /* @__PURE__ */ jsx5(
9769
+ "button",
9770
+ {
9771
+ type: "button",
9772
+ title: `\u5C55\u5F00\u5217\u5927\u7EB2\u81F3\u7B2C ${lvl} \u7EA7`,
9773
+ onClick: (e) => {
9774
+ e.stopPropagation();
9775
+ commandService.syncExecuteCommand(ExpandSheetOutlineToLevelCommand2.id, {
9776
+ unitId,
9777
+ sheetId,
9778
+ dimension: "column",
9779
+ maxVisibleLevel: lvl
9780
+ });
9781
+ },
9782
+ style: {
9783
+ width: 15,
9784
+ height: 15,
9785
+ borderRadius: 3,
9786
+ border: "1px solid #CBD5E1",
9787
+ background: "#FFFFFF",
9788
+ color: "#1B1C1F",
9789
+ fontSize: 9.5,
9790
+ fontWeight: 700,
9791
+ padding: 0,
9792
+ cursor: "pointer"
9793
+ },
9794
+ children: lvl
9795
+ },
9796
+ `clvl-${lvl}`
9797
+ )
9798
+ )
9799
+ ] }),
9800
+ /* @__PURE__ */ jsx5(
9801
+ "button",
9802
+ {
9803
+ type: "button",
9804
+ title: "\u65B0\u589E\u884C\u5206\u7EC4 (AddSheetOutlineGroupCommand)",
9805
+ onClick: (e) => {
9806
+ e.stopPropagation();
9807
+ commandService.syncExecuteCommand(AddSheetOutlineGroupCommand.id, {
9808
+ unitId,
9809
+ sheetId,
9810
+ dimension: "row",
9811
+ startIndex: 1,
9812
+ endIndex: 3
9813
+ });
9814
+ },
9815
+ style: {
9816
+ height: 15,
9817
+ borderRadius: 3,
9818
+ border: "1px solid #D2DAFA",
9819
+ background: "#F3F5FF",
9820
+ color: "#2C53F1",
9821
+ fontSize: 9.5,
9822
+ fontWeight: 600,
9823
+ padding: "0 4px",
9824
+ cursor: "pointer"
9825
+ },
9826
+ children: "+\u7EC4"
9827
+ }
9828
+ )
9829
+ ]
9830
+ }
9831
+ ),
9832
+ outlinePills.map(({ outline, left, top, spanSize }) => /* @__PURE__ */ jsxs5(React4.Fragment, { children: [
9833
+ !outline.collapsed && spanSize > 20 && /* @__PURE__ */ jsx5(
9834
+ "div",
9835
+ {
9836
+ style: {
9837
+ position: "absolute",
9838
+ left: outline.dimension === "row" ? left + 7 : left + 16,
9839
+ top: outline.dimension === "row" ? top + 28 : top + 7,
9840
+ width: outline.dimension === "row" ? 4 : Math.max(4, spanSize - 18),
9841
+ height: outline.dimension === "row" ? Math.max(4, spanSize - 18) : 4,
9842
+ borderLeft: outline.dimension === "row" ? "2px solid #93C5FD" : void 0,
9843
+ borderBottom: outline.dimension === "row" ? "2px solid #93C5FD" : void 0,
9844
+ borderTop: outline.dimension === "column" ? "2px solid #93C5FD" : void 0,
9845
+ borderRight: outline.dimension === "column" ? "2px solid #93C5FD" : void 0,
9846
+ pointerEvents: "none",
9847
+ zIndex: 21
9848
+ }
9849
+ }
9850
+ ),
9851
+ /* @__PURE__ */ jsx5(
9852
+ "button",
9853
+ {
9854
+ type: "button",
9855
+ title: `${outline.dimension === "row" ? "\u884C" : "\u5217"}\u5206\u7EA7\u7EC4\u5408 L${outline.level} (${outline.startIndex + 1}-${outline.endIndex + 1})`,
9856
+ onClick: (e) => {
9857
+ e.stopPropagation();
9858
+ commandService.syncExecuteCommand(ToggleSheetOutlineCollapseCommand.id, {
9859
+ unitId,
9860
+ outlineId: outline.id
9861
+ });
9862
+ },
9863
+ style: {
9864
+ position: "absolute",
9865
+ left,
9866
+ top: outline.dimension === "row" ? top + 24 : top,
9867
+ width: 16,
9868
+ height: 16,
9869
+ borderRadius: 4,
9870
+ border: "1px solid #D2DAFA",
9871
+ background: outline.collapsed ? "#F3F5FF" : "#FFFFFF",
9872
+ color: "#2C53F1",
9873
+ fontSize: 11,
9874
+ fontWeight: 700,
9875
+ lineHeight: 1,
9876
+ padding: 0,
9877
+ cursor: "pointer",
9878
+ pointerEvents: "auto",
9879
+ zIndex: 22
9880
+ },
9881
+ children: outline.collapsed ? "+" : "-"
9882
+ }
9883
+ )
9884
+ ] }, outline.id)),
7945
9885
  shapes.map((sh) => /* @__PURE__ */ jsx5(
7946
9886
  FloatingShapeCard,
7947
9887
  {
9888
+ rawShape: sh,
9889
+ allShapes: shapes,
9890
+ scrollX: overlayState.scrollX,
9891
+ scrollY: overlayState.scrollY,
9892
+ selected: selectedShapeId === sh.id,
7948
9893
  shape: {
7949
9894
  ...sh,
7950
9895
  left: sh.left - overlayState.scrollX,
7951
9896
  top: sh.top - overlayState.scrollY
7952
9897
  },
7953
9898
  displayText: resolveShapeDisplayText(sheetCfg, sh),
7954
- onMove: (nextVisL, nextVisT) => {
7955
- commandService.syncExecuteCommand(AddOrUpdateSheetShapeCommand2.id, {
9899
+ onSelect: () => setSelectedShapeId(sh.id),
9900
+ onUpdate: (nextShape) => {
9901
+ commandService.syncExecuteCommand(UpdateSheetShapeCommand.id, {
7956
9902
  unitId,
7957
- shape: {
7958
- ...sh,
7959
- left: nextVisL + overlayState.scrollX,
7960
- top: nextVisT + overlayState.scrollY
7961
- }
9903
+ shape: nextShape
7962
9904
  });
7963
9905
  },
7964
9906
  onRemove: () => {
9907
+ if (selectedShapeId === sh.id) setSelectedShapeId(null);
7965
9908
  commandService.syncExecuteCommand(RemoveSheetShapeCommand.id, {
7966
9909
  unitId,
7967
9910
  shapeId: sh.id