@yudaocode/univer-sheets-ui 1.6.218 → 1.6.219
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cjs/index.js +816 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +829 -1
- package/lib/es/index.js.map +1 -1
- package/package.json +3 -3
package/lib/es/index.js
CHANGED
|
@@ -377,7 +377,7 @@ import {
|
|
|
377
377
|
SetWorksheetActiveOperation,
|
|
378
378
|
SheetsSelectionsService
|
|
379
379
|
} from "@univerjs/sheets";
|
|
380
|
-
import { useDependency as useDependency2, useObservable as useObservable2 } from "@univerjs/ui";
|
|
380
|
+
import { useDependency as useDependency2, useInjector, useObservable as useObservable2 } from "@univerjs/ui";
|
|
381
381
|
import {
|
|
382
382
|
a1ToCellCoords,
|
|
383
383
|
AddOrUpdateSheetShapeCommand,
|
|
@@ -385,22 +385,28 @@ import {
|
|
|
385
385
|
AddOrUpdateSheetTimelineCommand,
|
|
386
386
|
ApplyImportedSheetDataCommand,
|
|
387
387
|
ApplyImportedWorkbookDataCommand as ApplyImportedWorkbookDataCommand2,
|
|
388
|
+
ApplySheetScenarioCommand,
|
|
388
389
|
BindSheetCellDatasetCommand,
|
|
389
390
|
buildPivotLinkedChart,
|
|
390
391
|
buildWatchWindowSnapshot,
|
|
391
392
|
cellCoordsToA1,
|
|
392
393
|
colIndexToLetter,
|
|
393
394
|
DeleteSheetFillRowCommand,
|
|
395
|
+
DeleteSheetMacroCommand,
|
|
396
|
+
DeleteSheetScenarioCommand,
|
|
394
397
|
evaluateFormulaSteps,
|
|
395
398
|
ExpandSheetOutlineToLevelCommand,
|
|
396
399
|
exportSheetReportPackage,
|
|
397
400
|
extractCellPlaceholders,
|
|
398
401
|
extractSheetFillChangeset,
|
|
399
402
|
extractSheetFillValues,
|
|
403
|
+
GenerateScenarioSummaryCommand,
|
|
400
404
|
GenerateSheetPivotCommand,
|
|
401
405
|
generateSheetFormulaByPrompt,
|
|
402
406
|
generateSheetReportByPrompt,
|
|
403
407
|
getCellYudaoMeta,
|
|
408
|
+
getWorkbookMacros,
|
|
409
|
+
getWorkbookScenarios,
|
|
404
410
|
GoalSeekSheetCommand,
|
|
405
411
|
GroupSheetOutlineCommand,
|
|
406
412
|
importExcelIntoFillWorkbook,
|
|
@@ -408,18 +414,24 @@ import {
|
|
|
408
414
|
InsertChartSheetCommand,
|
|
409
415
|
InsertSheetFillRowCommand,
|
|
410
416
|
ISheetIoService as ISheetIoService2,
|
|
417
|
+
ISheetMacroService,
|
|
411
418
|
ISheetTemplateService as ISheetTemplateService2,
|
|
412
419
|
parseA1Range,
|
|
413
420
|
RefreshSheetPivotCommand,
|
|
414
421
|
RemoveSheetChartCommand,
|
|
422
|
+
ReplaySheetMacroCommand,
|
|
415
423
|
resolveSelectionMasterCell,
|
|
416
424
|
RestoreSheetVersionCommand,
|
|
425
|
+
RunSheetDataTableCommand,
|
|
426
|
+
SaveSheetScenarioCommand,
|
|
417
427
|
SaveSheetVersionCommand,
|
|
418
428
|
scanWorkbookBoundCells,
|
|
419
429
|
SetSheetCellMetaCommand,
|
|
420
430
|
SetSheetQueryParamFieldsCommand,
|
|
421
431
|
SetWorkbookStructureLockCommand,
|
|
422
432
|
SHEET_CHART_TYPE_GROUPS,
|
|
433
|
+
StartSheetMacroRecordCommand,
|
|
434
|
+
StopSheetMacroRecordCommand,
|
|
423
435
|
ToggleSheetGroupCollapseCommand,
|
|
424
436
|
ToggleSheetTreeNodeCommand,
|
|
425
437
|
traceFormulaDependents,
|
|
@@ -476,9 +488,24 @@ var SheetInspectorPanel = () => {
|
|
|
476
488
|
const templateService = useDependency2(ISheetTemplateService2);
|
|
477
489
|
const ioService = useDependency2(ISheetIoService2);
|
|
478
490
|
const featureService = useDependency2(ISheetsUIFeatureService);
|
|
491
|
+
const injector = useInjector();
|
|
492
|
+
const macroService = (() => {
|
|
493
|
+
try {
|
|
494
|
+
return injector.get(ISheetMacroService);
|
|
495
|
+
} catch {
|
|
496
|
+
return void 0;
|
|
497
|
+
}
|
|
498
|
+
})();
|
|
479
499
|
const features = useObservable2(featureService.features$, featureService.getFeatures());
|
|
480
500
|
const metaVersion = useObservable2(templateService.metadataChange$, "");
|
|
481
501
|
const protWarn = useObservable2(templateService.protectionWarning$, null);
|
|
502
|
+
const defaultMacroRecState = {
|
|
503
|
+
recording: false,
|
|
504
|
+
stepCount: 0,
|
|
505
|
+
steps: []
|
|
506
|
+
};
|
|
507
|
+
const macroRecState = useObservable2(macroService?.recordingState$, defaultMacroRecState);
|
|
508
|
+
const macroListVer = useObservable2(macroService?.macrosChange$, "");
|
|
482
509
|
const workbook = useObservable2(
|
|
483
510
|
() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType2.UNIVER_SHEET),
|
|
484
511
|
instanceService.getCurrentUnitOfType(UniverInstanceType2.UNIVER_SHEET),
|
|
@@ -547,6 +574,21 @@ var SheetInspectorPanel = () => {
|
|
|
547
574
|
const [evalSteps, setEvalSteps] = useState([]);
|
|
548
575
|
const [evalStepIdx, setEvalStepIdx] = useState(0);
|
|
549
576
|
const [evalCellKey, setEvalCellKey] = useState("");
|
|
577
|
+
const [scenarioNameInput, setScenarioNameInput] = useState("\u4E50\u89C2\u589E\u957F\u65B9\u6848");
|
|
578
|
+
const [scenarioCellsInput, setScenarioCellsInput] = useState("B2=120, B3=0.18");
|
|
579
|
+
const [scenarioResultsInput, setScenarioResultsInput] = useState("F10");
|
|
580
|
+
const [scenarioCommentInput, setScenarioCommentInput] = useState("");
|
|
581
|
+
const [whatIfMode, setWhatIfMode] = useState("1var");
|
|
582
|
+
const [dtInputCell, setDtInputCell] = useState("B2");
|
|
583
|
+
const [dtInputValues, setDtInputValues] = useState("80, 100, 120");
|
|
584
|
+
const [dtFormulaCells, setDtFormulaCells] = useState("F10");
|
|
585
|
+
const [dtColInputCell, setDtColInputCell] = useState("B3");
|
|
586
|
+
const [dtColValues, setDtColValues] = useState("10, 20, 30");
|
|
587
|
+
const [dtOutputTopLeft, setDtOutputTopLeft] = useState("H2");
|
|
588
|
+
const [whatIfStatusMsg, setWhatIfStatusMsg] = useState("");
|
|
589
|
+
const [macroNameInput, setMacroNameInput] = useState("");
|
|
590
|
+
const [macroStatusMsg, setMacroStatusMsg] = useState("");
|
|
591
|
+
const [previewMacro, setPreviewMacro] = useState(null);
|
|
550
592
|
useEffect(() => {
|
|
551
593
|
const sub = selectionService.selectionChanged$.subscribe(() => setSelTick((v) => v + 1));
|
|
552
594
|
const disp = commandService.onCommandExecuted((info) => {
|
|
@@ -562,6 +604,7 @@ var SheetInspectorPanel = () => {
|
|
|
562
604
|
if (!workbook) return null;
|
|
563
605
|
void selTick;
|
|
564
606
|
void metaVersion;
|
|
607
|
+
void macroListVer;
|
|
565
608
|
const unitId = workbook.getUnitId();
|
|
566
609
|
const sheet = workbook.getActiveSheet();
|
|
567
610
|
if (!sheet) return null;
|
|
@@ -4171,6 +4214,527 @@ var SheetInspectorPanel = () => {
|
|
|
4171
4214
|
},
|
|
4172
4215
|
children: auditOutput
|
|
4173
4216
|
}
|
|
4217
|
+
),
|
|
4218
|
+
/* @__PURE__ */ jsx2("hr", { style: { border: "none", borderTop: "1px solid #E3E5EA", margin: "4px 0" } }),
|
|
4219
|
+
/* @__PURE__ */ jsxs2(
|
|
4220
|
+
"div",
|
|
4221
|
+
{
|
|
4222
|
+
"data-testid": "yudao-whatif-scenarios-card",
|
|
4223
|
+
style: {
|
|
4224
|
+
display: "flex",
|
|
4225
|
+
flexDirection: "column",
|
|
4226
|
+
gap: 6,
|
|
4227
|
+
padding: "7px 8px",
|
|
4228
|
+
borderRadius: 6,
|
|
4229
|
+
background: "#F8FAFC",
|
|
4230
|
+
border: "1px solid #E2E8F0"
|
|
4231
|
+
},
|
|
4232
|
+
children: [
|
|
4233
|
+
/* @__PURE__ */ jsxs2(
|
|
4234
|
+
"div",
|
|
4235
|
+
{
|
|
4236
|
+
style: {
|
|
4237
|
+
display: "flex",
|
|
4238
|
+
alignItems: "center",
|
|
4239
|
+
justifyContent: "space-between",
|
|
4240
|
+
gap: 6
|
|
4241
|
+
},
|
|
4242
|
+
children: [
|
|
4243
|
+
/* @__PURE__ */ jsxs2(
|
|
4244
|
+
"span",
|
|
4245
|
+
{
|
|
4246
|
+
style: {
|
|
4247
|
+
display: "inline-flex",
|
|
4248
|
+
alignItems: "center",
|
|
4249
|
+
gap: 5,
|
|
4250
|
+
fontSize: 11.5,
|
|
4251
|
+
fontWeight: 600,
|
|
4252
|
+
color: "#1B1C1F"
|
|
4253
|
+
},
|
|
4254
|
+
children: [
|
|
4255
|
+
/* @__PURE__ */ jsxs2(
|
|
4256
|
+
"svg",
|
|
4257
|
+
{
|
|
4258
|
+
width: "13",
|
|
4259
|
+
height: "13",
|
|
4260
|
+
viewBox: "0 0 16 16",
|
|
4261
|
+
fill: "none",
|
|
4262
|
+
"aria-hidden": "true",
|
|
4263
|
+
children: [
|
|
4264
|
+
/* @__PURE__ */ jsx2(
|
|
4265
|
+
"rect",
|
|
4266
|
+
{
|
|
4267
|
+
x: "1.5",
|
|
4268
|
+
y: "2.5",
|
|
4269
|
+
width: "13",
|
|
4270
|
+
height: "11",
|
|
4271
|
+
rx: "2",
|
|
4272
|
+
stroke: "#2C53F1",
|
|
4273
|
+
strokeWidth: "1.3"
|
|
4274
|
+
}
|
|
4275
|
+
),
|
|
4276
|
+
/* @__PURE__ */ jsx2("path", { d: "M1.5 6H14.5M6 6V13.5", stroke: "#2C53F1", strokeWidth: "1.2" })
|
|
4277
|
+
]
|
|
4278
|
+
}
|
|
4279
|
+
),
|
|
4280
|
+
/* @__PURE__ */ jsx2("span", { children: "\u6A21\u62DF\u5206\u6790\u4E0E\u65B9\u6848\u7BA1\u7406\u5668" })
|
|
4281
|
+
]
|
|
4282
|
+
}
|
|
4283
|
+
),
|
|
4284
|
+
/* @__PURE__ */ jsxs2("span", { style: { fontSize: 10, color: "#64748B" }, children: [
|
|
4285
|
+
getWorkbookScenarios(workbook).length,
|
|
4286
|
+
" \u4E2A\u65B9\u6848"
|
|
4287
|
+
] })
|
|
4288
|
+
]
|
|
4289
|
+
}
|
|
4290
|
+
),
|
|
4291
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
|
|
4292
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4293
|
+
/* @__PURE__ */ jsx2("span", { children: "\u65B9\u6848\u540D\u79F0" }),
|
|
4294
|
+
/* @__PURE__ */ jsx2(
|
|
4295
|
+
"input",
|
|
4296
|
+
{
|
|
4297
|
+
"data-testid": "yudao-scenario-name-input",
|
|
4298
|
+
type: "text",
|
|
4299
|
+
placeholder: "\u5982\uFF1A\u4E50\u89C2\u589E\u957F\u65B9\u6848",
|
|
4300
|
+
value: scenarioNameInput,
|
|
4301
|
+
onChange: (e) => setScenarioNameInput(e.target.value)
|
|
4302
|
+
}
|
|
4303
|
+
)
|
|
4304
|
+
] }),
|
|
4305
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4306
|
+
/* @__PURE__ */ jsx2("span", { children: "\u7ED3\u679C\u76EE\u6807\u683C (\u9017\u53F7\u5206\u9694)" }),
|
|
4307
|
+
/* @__PURE__ */ jsx2(
|
|
4308
|
+
"input",
|
|
4309
|
+
{
|
|
4310
|
+
"data-testid": "yudao-scenario-results-input",
|
|
4311
|
+
type: "text",
|
|
4312
|
+
placeholder: "\u5982 F10, G10",
|
|
4313
|
+
value: scenarioResultsInput,
|
|
4314
|
+
onChange: (e) => setScenarioResultsInput(e.target.value)
|
|
4315
|
+
}
|
|
4316
|
+
)
|
|
4317
|
+
] })
|
|
4318
|
+
] }),
|
|
4319
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4320
|
+
/* @__PURE__ */ jsx2("span", { children: "\u53EF\u53D8\u5355\u5143\u683C\u8D4B\u503C (\u683C\u5F0F: B2=120, B3=0.18)" }),
|
|
4321
|
+
/* @__PURE__ */ jsx2(
|
|
4322
|
+
"input",
|
|
4323
|
+
{
|
|
4324
|
+
"data-testid": "yudao-scenario-cells-input",
|
|
4325
|
+
type: "text",
|
|
4326
|
+
placeholder: "\u5982 B2=120, B3=0.18",
|
|
4327
|
+
value: scenarioCellsInput,
|
|
4328
|
+
onChange: (e) => setScenarioCellsInput(e.target.value)
|
|
4329
|
+
}
|
|
4330
|
+
)
|
|
4331
|
+
] }),
|
|
4332
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4333
|
+
/* @__PURE__ */ jsx2("span", { children: "\u65B9\u6848\u5907\u6CE8 (\u53EF\u9009)" }),
|
|
4334
|
+
/* @__PURE__ */ jsx2(
|
|
4335
|
+
"input",
|
|
4336
|
+
{
|
|
4337
|
+
"data-testid": "yudao-scenario-comment-input",
|
|
4338
|
+
type: "text",
|
|
4339
|
+
placeholder: "\u8BB0\u5F55\u5047\u8BBE\u524D\u63D0\u6761\u4EF6",
|
|
4340
|
+
value: scenarioCommentInput,
|
|
4341
|
+
onChange: (e) => setScenarioCommentInput(e.target.value)
|
|
4342
|
+
}
|
|
4343
|
+
)
|
|
4344
|
+
] }),
|
|
4345
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1.2fr", gap: 4 }, children: [
|
|
4346
|
+
/* @__PURE__ */ jsx2(
|
|
4347
|
+
"button",
|
|
4348
|
+
{
|
|
4349
|
+
"data-testid": "yudao-scenario-save-btn",
|
|
4350
|
+
type: "button",
|
|
4351
|
+
className: "yudao-sheet-btn is-soft-primary",
|
|
4352
|
+
onClick: () => {
|
|
4353
|
+
const changingCells = scenarioCellsInput.split(/[,;\n]+/).map((seg) => seg.trim()).filter(Boolean).map((pair) => {
|
|
4354
|
+
const eqIdx = pair.indexOf("=");
|
|
4355
|
+
if (eqIdx <= 0) return null;
|
|
4356
|
+
const cellA1 = pair.slice(0, eqIdx).trim();
|
|
4357
|
+
const rawVal = pair.slice(eqIdx + 1).trim();
|
|
4358
|
+
if (!cellA1) return null;
|
|
4359
|
+
if (/^true$/i.test(rawVal)) return { cellA1, value: true };
|
|
4360
|
+
if (/^false$/i.test(rawVal)) return { cellA1, value: false };
|
|
4361
|
+
const asNum = Number(rawVal);
|
|
4362
|
+
return {
|
|
4363
|
+
cellA1,
|
|
4364
|
+
value: rawVal !== "" && Number.isFinite(asNum) ? asNum : rawVal
|
|
4365
|
+
};
|
|
4366
|
+
}).filter((item) => item !== null);
|
|
4367
|
+
if (changingCells.length === 0) {
|
|
4368
|
+
setWhatIfStatusMsg("\u8BF7\u586B\u5199\u81F3\u5C11\u4E00\u9879\u53EF\u53D8\u5355\u5143\u683C\uFF08\u4F8B\u5982 B2=120\uFF09");
|
|
4369
|
+
return;
|
|
4370
|
+
}
|
|
4371
|
+
const resultCells = scenarioResultsInput.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
|
|
4372
|
+
const ok = commandService.syncExecuteCommand(SaveSheetScenarioCommand.id, {
|
|
4373
|
+
unitId,
|
|
4374
|
+
scenario: {
|
|
4375
|
+
name: scenarioNameInput.trim() || "\u672A\u547D\u540D\u65B9\u6848",
|
|
4376
|
+
comment: scenarioCommentInput.trim() || void 0,
|
|
4377
|
+
sheetId: sheet.getSheetId(),
|
|
4378
|
+
changingCells,
|
|
4379
|
+
resultCells: resultCells.length > 0 ? resultCells : void 0
|
|
4380
|
+
}
|
|
4381
|
+
});
|
|
4382
|
+
if (ok) {
|
|
4383
|
+
setWhatIfStatusMsg(
|
|
4384
|
+
`\u5DF2\u4FDD\u5B58\u65B9\u6848\u300C${scenarioNameInput.trim() || "\u672A\u547D\u540D\u65B9\u6848"}\u300D\uFF08${changingCells.length} \u9879\u53EF\u53D8\u683C\uFF09`
|
|
4385
|
+
);
|
|
4386
|
+
}
|
|
4387
|
+
},
|
|
4388
|
+
children: "\u4FDD\u5B58\u65B9\u6848"
|
|
4389
|
+
}
|
|
4390
|
+
),
|
|
4391
|
+
/* @__PURE__ */ jsx2(
|
|
4392
|
+
"button",
|
|
4393
|
+
{
|
|
4394
|
+
"data-testid": "yudao-scenario-summary-btn",
|
|
4395
|
+
type: "button",
|
|
4396
|
+
className: "yudao-sheet-btn",
|
|
4397
|
+
onClick: () => {
|
|
4398
|
+
const resultCellsA1 = scenarioResultsInput.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
|
|
4399
|
+
const ok = commandService.syncExecuteCommand(
|
|
4400
|
+
GenerateScenarioSummaryCommand.id,
|
|
4401
|
+
{
|
|
4402
|
+
unitId,
|
|
4403
|
+
sheetId: sheet.getSheetId(),
|
|
4404
|
+
resultCellsA1: resultCellsA1.length > 0 ? resultCellsA1 : void 0
|
|
4405
|
+
}
|
|
4406
|
+
);
|
|
4407
|
+
setWhatIfStatusMsg(
|
|
4408
|
+
ok ? "\u5DF2\u751F\u6210/\u66F4\u65B0\u300C\u65B9\u6848\u6458\u8981\u300D\u5BF9\u6BD4\u5DE5\u4F5C\u8868" : "\u751F\u6210\u65B9\u6848\u6458\u8981\u5931\u8D25"
|
|
4409
|
+
);
|
|
4410
|
+
},
|
|
4411
|
+
children: "\u4E00\u952E\u751F\u6210\u65B9\u6848\u6458\u8981\u8868"
|
|
4412
|
+
}
|
|
4413
|
+
)
|
|
4414
|
+
] }),
|
|
4415
|
+
getWorkbookScenarios(workbook).length > 0 && /* @__PURE__ */ jsx2(
|
|
4416
|
+
"div",
|
|
4417
|
+
{
|
|
4418
|
+
"data-testid": "yudao-scenario-list",
|
|
4419
|
+
style: { display: "flex", flexDirection: "column", gap: 3 },
|
|
4420
|
+
children: getWorkbookScenarios(workbook).map((sc) => /* @__PURE__ */ jsxs2(
|
|
4421
|
+
"div",
|
|
4422
|
+
{
|
|
4423
|
+
style: {
|
|
4424
|
+
display: "flex",
|
|
4425
|
+
alignItems: "center",
|
|
4426
|
+
justifyContent: "space-between",
|
|
4427
|
+
gap: 4,
|
|
4428
|
+
padding: "4px 6px",
|
|
4429
|
+
borderRadius: 5,
|
|
4430
|
+
background: "#FFFFFF",
|
|
4431
|
+
border: "1px solid #E2E8F0",
|
|
4432
|
+
fontSize: 10.5
|
|
4433
|
+
},
|
|
4434
|
+
children: [
|
|
4435
|
+
/* @__PURE__ */ jsxs2("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
4436
|
+
/* @__PURE__ */ jsx2("div", { style: { fontWeight: 600, color: "#1E293B" }, children: sc.name }),
|
|
4437
|
+
/* @__PURE__ */ jsx2("div", { style: { color: "#64748B", fontSize: 10 }, children: sc.changingCells.map((c) => `${c.cellA1}=${String(c.value)}`).join(", ") })
|
|
4438
|
+
] }),
|
|
4439
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 3 }, children: [
|
|
4440
|
+
/* @__PURE__ */ jsx2(
|
|
4441
|
+
"button",
|
|
4442
|
+
{
|
|
4443
|
+
"data-testid": `yudao-scenario-apply-${sc.id}`,
|
|
4444
|
+
type: "button",
|
|
4445
|
+
className: "yudao-sheet-btn is-soft-primary",
|
|
4446
|
+
style: { padding: "1px 6px", fontSize: 10 },
|
|
4447
|
+
onClick: () => {
|
|
4448
|
+
const ok = commandService.syncExecuteCommand(
|
|
4449
|
+
ApplySheetScenarioCommand.id,
|
|
4450
|
+
{
|
|
4451
|
+
unitId,
|
|
4452
|
+
scenarioId: sc.id
|
|
4453
|
+
}
|
|
4454
|
+
);
|
|
4455
|
+
if (ok) {
|
|
4456
|
+
setWhatIfStatusMsg(`\u5DF2\u5207\u6362\u5E94\u7528\u65B9\u6848\u300C${sc.name}\u300D`);
|
|
4457
|
+
}
|
|
4458
|
+
},
|
|
4459
|
+
children: "\u5207\u6362"
|
|
4460
|
+
}
|
|
4461
|
+
),
|
|
4462
|
+
/* @__PURE__ */ jsx2(
|
|
4463
|
+
"button",
|
|
4464
|
+
{
|
|
4465
|
+
"data-testid": `yudao-scenario-delete-${sc.id}`,
|
|
4466
|
+
type: "button",
|
|
4467
|
+
className: "yudao-sheet-btn",
|
|
4468
|
+
style: { padding: "1px 5px", fontSize: 10 },
|
|
4469
|
+
onClick: () => {
|
|
4470
|
+
commandService.syncExecuteCommand(DeleteSheetScenarioCommand.id, {
|
|
4471
|
+
unitId,
|
|
4472
|
+
scenarioId: sc.id
|
|
4473
|
+
});
|
|
4474
|
+
setWhatIfStatusMsg(`\u5DF2\u5220\u9664\u65B9\u6848\u300C${sc.name}\u300D`);
|
|
4475
|
+
},
|
|
4476
|
+
children: "\u5220\u9664"
|
|
4477
|
+
}
|
|
4478
|
+
)
|
|
4479
|
+
] })
|
|
4480
|
+
]
|
|
4481
|
+
},
|
|
4482
|
+
sc.id
|
|
4483
|
+
))
|
|
4484
|
+
}
|
|
4485
|
+
),
|
|
4486
|
+
/* @__PURE__ */ jsxs2(
|
|
4487
|
+
"div",
|
|
4488
|
+
{
|
|
4489
|
+
style: {
|
|
4490
|
+
borderTop: "1px dashed #CBD5E1",
|
|
4491
|
+
paddingTop: 5,
|
|
4492
|
+
display: "flex",
|
|
4493
|
+
flexDirection: "column",
|
|
4494
|
+
gap: 5
|
|
4495
|
+
},
|
|
4496
|
+
children: [
|
|
4497
|
+
/* @__PURE__ */ jsxs2(
|
|
4498
|
+
"div",
|
|
4499
|
+
{
|
|
4500
|
+
className: "yudao-sheet-segmented",
|
|
4501
|
+
style: { gridTemplateColumns: "1fr 1fr" },
|
|
4502
|
+
children: [
|
|
4503
|
+
/* @__PURE__ */ jsx2(
|
|
4504
|
+
"button",
|
|
4505
|
+
{
|
|
4506
|
+
"data-testid": "yudao-datatable-mode-1var",
|
|
4507
|
+
type: "button",
|
|
4508
|
+
className: `yudao-sheet-segmented-item ${whatIfMode === "1var" ? "is-active" : ""}`,
|
|
4509
|
+
style: { padding: "3px 4px", fontSize: 10.5 },
|
|
4510
|
+
onClick: () => setWhatIfMode("1var"),
|
|
4511
|
+
children: "\u5355\u53D8\u91CF\u6A21\u62DF\u8FD0\u7B97\u8868"
|
|
4512
|
+
}
|
|
4513
|
+
),
|
|
4514
|
+
/* @__PURE__ */ jsx2(
|
|
4515
|
+
"button",
|
|
4516
|
+
{
|
|
4517
|
+
"data-testid": "yudao-datatable-mode-2var",
|
|
4518
|
+
type: "button",
|
|
4519
|
+
className: `yudao-sheet-segmented-item ${whatIfMode === "2var" ? "is-active" : ""}`,
|
|
4520
|
+
style: { padding: "3px 4px", fontSize: 10.5 },
|
|
4521
|
+
onClick: () => setWhatIfMode("2var"),
|
|
4522
|
+
children: "\u53CC\u53D8\u91CF\u4EA4\u53C9\u6A21\u62DF\u8868"
|
|
4523
|
+
}
|
|
4524
|
+
)
|
|
4525
|
+
]
|
|
4526
|
+
}
|
|
4527
|
+
),
|
|
4528
|
+
whatIfMode === "1var" ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
4529
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
|
|
4530
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4531
|
+
/* @__PURE__ */ jsx2("span", { children: "\u8F93\u5165\u53D8\u91CF\u683C" }),
|
|
4532
|
+
/* @__PURE__ */ jsx2(
|
|
4533
|
+
"input",
|
|
4534
|
+
{
|
|
4535
|
+
"data-testid": "yudao-dt-input-cell",
|
|
4536
|
+
type: "text",
|
|
4537
|
+
value: dtInputCell,
|
|
4538
|
+
onChange: (e) => setDtInputCell(e.target.value)
|
|
4539
|
+
}
|
|
4540
|
+
)
|
|
4541
|
+
] }),
|
|
4542
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4543
|
+
/* @__PURE__ */ jsx2("span", { children: "\u5019\u9009\u8F93\u5165\u5E8F\u5217 (\u9017\u53F7\u5206\u9694)" }),
|
|
4544
|
+
/* @__PURE__ */ jsx2(
|
|
4545
|
+
"input",
|
|
4546
|
+
{
|
|
4547
|
+
"data-testid": "yudao-dt-input-values",
|
|
4548
|
+
type: "text",
|
|
4549
|
+
value: dtInputValues,
|
|
4550
|
+
onChange: (e) => setDtInputValues(e.target.value)
|
|
4551
|
+
}
|
|
4552
|
+
)
|
|
4553
|
+
] })
|
|
4554
|
+
] }),
|
|
4555
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
|
|
4556
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4557
|
+
/* @__PURE__ */ jsx2("span", { children: "\u76EE\u6807\u516C\u5F0F\u683C (\u53EF\u591A\u4E2A)" }),
|
|
4558
|
+
/* @__PURE__ */ jsx2(
|
|
4559
|
+
"input",
|
|
4560
|
+
{
|
|
4561
|
+
"data-testid": "yudao-dt-formula-cells",
|
|
4562
|
+
type: "text",
|
|
4563
|
+
value: dtFormulaCells,
|
|
4564
|
+
onChange: (e) => setDtFormulaCells(e.target.value)
|
|
4565
|
+
}
|
|
4566
|
+
)
|
|
4567
|
+
] }),
|
|
4568
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4569
|
+
/* @__PURE__ */ jsx2("span", { children: "\u8F93\u51FA\u5DE6\u4E0A\u89D2 (\u53EF\u9009)" }),
|
|
4570
|
+
/* @__PURE__ */ jsx2(
|
|
4571
|
+
"input",
|
|
4572
|
+
{
|
|
4573
|
+
"data-testid": "yudao-dt-output-cell",
|
|
4574
|
+
type: "text",
|
|
4575
|
+
placeholder: "\u5982 H2",
|
|
4576
|
+
value: dtOutputTopLeft,
|
|
4577
|
+
onChange: (e) => setDtOutputTopLeft(e.target.value)
|
|
4578
|
+
}
|
|
4579
|
+
)
|
|
4580
|
+
] })
|
|
4581
|
+
] })
|
|
4582
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
4583
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
|
|
4584
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4585
|
+
/* @__PURE__ */ jsx2("span", { children: "\u884C\u53D8\u91CF\u683C" }),
|
|
4586
|
+
/* @__PURE__ */ jsx2(
|
|
4587
|
+
"input",
|
|
4588
|
+
{
|
|
4589
|
+
"data-testid": "yudao-dt-row-input-cell",
|
|
4590
|
+
type: "text",
|
|
4591
|
+
value: dtInputCell,
|
|
4592
|
+
onChange: (e) => setDtInputCell(e.target.value)
|
|
4593
|
+
}
|
|
4594
|
+
)
|
|
4595
|
+
] }),
|
|
4596
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4597
|
+
/* @__PURE__ */ jsx2("span", { children: "\u884C\u5019\u9009\u503C (\u9017\u53F7\u5206\u9694)" }),
|
|
4598
|
+
/* @__PURE__ */ jsx2(
|
|
4599
|
+
"input",
|
|
4600
|
+
{
|
|
4601
|
+
"data-testid": "yudao-dt-row-values",
|
|
4602
|
+
type: "text",
|
|
4603
|
+
value: dtInputValues,
|
|
4604
|
+
onChange: (e) => setDtInputValues(e.target.value)
|
|
4605
|
+
}
|
|
4606
|
+
)
|
|
4607
|
+
] })
|
|
4608
|
+
] }),
|
|
4609
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 4 }, children: [
|
|
4610
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4611
|
+
/* @__PURE__ */ jsx2("span", { children: "\u5217\u53D8\u91CF\u683C" }),
|
|
4612
|
+
/* @__PURE__ */ jsx2(
|
|
4613
|
+
"input",
|
|
4614
|
+
{
|
|
4615
|
+
"data-testid": "yudao-dt-col-input-cell",
|
|
4616
|
+
type: "text",
|
|
4617
|
+
value: dtColInputCell,
|
|
4618
|
+
onChange: (e) => setDtColInputCell(e.target.value)
|
|
4619
|
+
}
|
|
4620
|
+
)
|
|
4621
|
+
] }),
|
|
4622
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4623
|
+
/* @__PURE__ */ jsx2("span", { children: "\u5217\u5019\u9009\u503C (\u9017\u53F7\u5206\u9694)" }),
|
|
4624
|
+
/* @__PURE__ */ jsx2(
|
|
4625
|
+
"input",
|
|
4626
|
+
{
|
|
4627
|
+
"data-testid": "yudao-dt-col-values",
|
|
4628
|
+
type: "text",
|
|
4629
|
+
value: dtColValues,
|
|
4630
|
+
onChange: (e) => setDtColValues(e.target.value)
|
|
4631
|
+
}
|
|
4632
|
+
)
|
|
4633
|
+
] })
|
|
4634
|
+
] }),
|
|
4635
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
|
|
4636
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4637
|
+
/* @__PURE__ */ jsx2("span", { children: "\u76EE\u6807\u516C\u5F0F\u683C" }),
|
|
4638
|
+
/* @__PURE__ */ jsx2(
|
|
4639
|
+
"input",
|
|
4640
|
+
{
|
|
4641
|
+
"data-testid": "yudao-dt-target-formula",
|
|
4642
|
+
type: "text",
|
|
4643
|
+
value: dtFormulaCells,
|
|
4644
|
+
onChange: (e) => setDtFormulaCells(e.target.value)
|
|
4645
|
+
}
|
|
4646
|
+
)
|
|
4647
|
+
] }),
|
|
4648
|
+
/* @__PURE__ */ jsxs2("label", { className: "yudao-sheet-field-row", children: [
|
|
4649
|
+
/* @__PURE__ */ jsx2("span", { children: "\u8F93\u51FA\u5DE6\u4E0A\u89D2 (\u53EF\u9009)" }),
|
|
4650
|
+
/* @__PURE__ */ jsx2(
|
|
4651
|
+
"input",
|
|
4652
|
+
{
|
|
4653
|
+
"data-testid": "yudao-dt-output-cell",
|
|
4654
|
+
type: "text",
|
|
4655
|
+
placeholder: "\u5982 H2",
|
|
4656
|
+
value: dtOutputTopLeft,
|
|
4657
|
+
onChange: (e) => setDtOutputTopLeft(e.target.value)
|
|
4658
|
+
}
|
|
4659
|
+
)
|
|
4660
|
+
] })
|
|
4661
|
+
] })
|
|
4662
|
+
] }),
|
|
4663
|
+
/* @__PURE__ */ jsx2(
|
|
4664
|
+
"button",
|
|
4665
|
+
{
|
|
4666
|
+
"data-testid": "yudao-datatable-run-btn",
|
|
4667
|
+
type: "button",
|
|
4668
|
+
className: "yudao-sheet-btn is-soft-primary",
|
|
4669
|
+
onClick: () => {
|
|
4670
|
+
const parseCandidateValues = (raw) => raw.split(/[,;]+/).map((s) => s.trim()).filter(Boolean).map((tok) => {
|
|
4671
|
+
const n = Number(tok);
|
|
4672
|
+
return Number.isFinite(n) ? n : tok;
|
|
4673
|
+
});
|
|
4674
|
+
if (whatIfMode === "1var") {
|
|
4675
|
+
const inputVals = parseCandidateValues(dtInputValues);
|
|
4676
|
+
const fCells = dtFormulaCells.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
|
|
4677
|
+
commandService.syncExecuteCommand(RunSheetDataTableCommand.id, {
|
|
4678
|
+
unitId,
|
|
4679
|
+
mode: "1var",
|
|
4680
|
+
sheetId: sheet.getSheetId(),
|
|
4681
|
+
inputCellA1: dtInputCell.trim(),
|
|
4682
|
+
inputValues: inputVals,
|
|
4683
|
+
formulaCellsA1: fCells,
|
|
4684
|
+
outputTopLeftA1: dtOutputTopLeft.trim() || void 0,
|
|
4685
|
+
onResult: (res) => {
|
|
4686
|
+
setWhatIfStatusMsg(
|
|
4687
|
+
`\u5355\u53D8\u91CF\u6A21\u62DF\u5B8C\u6210 (${res.matrix.length}\xD7${res.formulaCellsA1.length})${res.outputRangeA1 ? ` -> \u5DF2\u5199\u5165 ${res.outputRangeA1}` : ""}: ${res.matrix.map((r) => `[${r.join(", ")}]`).join(" ")}`
|
|
4688
|
+
);
|
|
4689
|
+
}
|
|
4690
|
+
});
|
|
4691
|
+
} else {
|
|
4692
|
+
const rVals = parseCandidateValues(dtInputValues);
|
|
4693
|
+
const cVals = parseCandidateValues(dtColValues);
|
|
4694
|
+
const targetF = dtFormulaCells.split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean)[0] ?? "F10";
|
|
4695
|
+
commandService.syncExecuteCommand(RunSheetDataTableCommand.id, {
|
|
4696
|
+
unitId,
|
|
4697
|
+
mode: "2var",
|
|
4698
|
+
sheetId: sheet.getSheetId(),
|
|
4699
|
+
rowInputCellA1: dtInputCell.trim(),
|
|
4700
|
+
colInputCellA1: dtColInputCell.trim(),
|
|
4701
|
+
rowValues: rVals,
|
|
4702
|
+
colValues: cVals,
|
|
4703
|
+
targetFormulaA1: targetF,
|
|
4704
|
+
outputTopLeftA1: dtOutputTopLeft.trim() || void 0,
|
|
4705
|
+
onResult: (res) => {
|
|
4706
|
+
setWhatIfStatusMsg(
|
|
4707
|
+
`\u53CC\u53D8\u91CF\u6A21\u62DF\u5B8C\u6210 (${res.colValues.length}\xD7${res.rowValues.length})${res.outputRangeA1 ? ` -> \u5DF2\u5199\u5165 ${res.outputRangeA1}` : ""}: ${res.matrix.map((r) => `[${r.join(", ")}]`).join(" ")}`
|
|
4708
|
+
);
|
|
4709
|
+
}
|
|
4710
|
+
});
|
|
4711
|
+
}
|
|
4712
|
+
},
|
|
4713
|
+
children: "\u8BA1\u7B97\u5E76\u8F93\u51FA\u6A21\u62DF\u8FD0\u7B97\u8868"
|
|
4714
|
+
}
|
|
4715
|
+
)
|
|
4716
|
+
]
|
|
4717
|
+
}
|
|
4718
|
+
),
|
|
4719
|
+
whatIfStatusMsg && /* @__PURE__ */ jsx2(
|
|
4720
|
+
"div",
|
|
4721
|
+
{
|
|
4722
|
+
"data-testid": "yudao-whatif-status",
|
|
4723
|
+
style: {
|
|
4724
|
+
fontSize: 10.5,
|
|
4725
|
+
padding: "4px 6px",
|
|
4726
|
+
borderRadius: 5,
|
|
4727
|
+
background: "#EEF2FF",
|
|
4728
|
+
border: "1px solid #C7D2FE",
|
|
4729
|
+
color: "#1E1B4B",
|
|
4730
|
+
lineHeight: 1.35,
|
|
4731
|
+
wordBreak: "break-all"
|
|
4732
|
+
},
|
|
4733
|
+
children: whatIfStatusMsg
|
|
4734
|
+
}
|
|
4735
|
+
)
|
|
4736
|
+
]
|
|
4737
|
+
}
|
|
4174
4738
|
)
|
|
4175
4739
|
] }),
|
|
4176
4740
|
features.datasetBinding && activeSubTab === "fill" && /* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section", children: [
|
|
@@ -4836,6 +5400,270 @@ var SheetInspectorPanel = () => {
|
|
|
4836
5400
|
}
|
|
4837
5401
|
)
|
|
4838
5402
|
] }),
|
|
5403
|
+
/* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section", "data-testid": "yudao-macro-recorder-card", children: [
|
|
5404
|
+
/* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section-title", children: [
|
|
5405
|
+
/* @__PURE__ */ jsxs2("span", { style: { display: "inline-flex", alignItems: "center", gap: 5 }, children: [
|
|
5406
|
+
/* @__PURE__ */ jsxs2("svg", { width: "13", height: "13", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
|
|
5407
|
+
/* @__PURE__ */ jsx2(
|
|
5408
|
+
"circle",
|
|
5409
|
+
{
|
|
5410
|
+
cx: "8",
|
|
5411
|
+
cy: "8",
|
|
5412
|
+
r: "6",
|
|
5413
|
+
stroke: macroRecState.recording ? "#DC2626" : "#2C53F1",
|
|
5414
|
+
strokeWidth: "1.4"
|
|
5415
|
+
}
|
|
5416
|
+
),
|
|
5417
|
+
macroRecState.recording ? /* @__PURE__ */ jsx2("rect", { x: "5.5", y: "5.5", width: "5", height: "5", rx: "1", fill: "#DC2626" }) : /* @__PURE__ */ jsx2("polygon", { points: "6.5,5 11.5,8 6.5,11", fill: "#2C53F1" })
|
|
5418
|
+
] }),
|
|
5419
|
+
/* @__PURE__ */ jsx2("span", { children: "\u64CD\u4F5C\u5B8F\u5F55\u5236\u4E0E\u56DE\u653E" })
|
|
5420
|
+
] }),
|
|
5421
|
+
/* @__PURE__ */ jsx2(
|
|
5422
|
+
"span",
|
|
5423
|
+
{
|
|
5424
|
+
"data-testid": "yudao-macro-badge",
|
|
5425
|
+
style: {
|
|
5426
|
+
fontSize: 10,
|
|
5427
|
+
fontWeight: 500,
|
|
5428
|
+
padding: "1px 6px",
|
|
5429
|
+
borderRadius: 999,
|
|
5430
|
+
background: macroRecState.recording ? "#FEF2F2" : "#F3F5FF",
|
|
5431
|
+
color: macroRecState.recording ? "#DC2626" : "#2C53F1"
|
|
5432
|
+
},
|
|
5433
|
+
children: macroRecState.recording ? `\u5F55\u5236\u4E2D (${macroRecState.stepCount} \u6B65)` : `${(macroService ? macroService.getMacros(unitId) : getWorkbookMacros(workbook)).length} \u4E2A\u5B8F`
|
|
5434
|
+
}
|
|
5435
|
+
)
|
|
5436
|
+
] }),
|
|
5437
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 4 }, children: [
|
|
5438
|
+
/* @__PURE__ */ jsx2(
|
|
5439
|
+
"input",
|
|
5440
|
+
{
|
|
5441
|
+
"data-testid": "yudao-macro-name-input",
|
|
5442
|
+
type: "text",
|
|
5443
|
+
style: {
|
|
5444
|
+
flex: 1,
|
|
5445
|
+
minWidth: 0,
|
|
5446
|
+
fontSize: 11.5,
|
|
5447
|
+
padding: "4px 6px",
|
|
5448
|
+
borderRadius: 6,
|
|
5449
|
+
border: "1px solid #E3E5EA",
|
|
5450
|
+
background: "#FFFFFF",
|
|
5451
|
+
color: "#1B1C1F",
|
|
5452
|
+
outline: "none"
|
|
5453
|
+
},
|
|
5454
|
+
placeholder: "\u5B8F\u540D\u79F0\uFF08\u5982\uFF1A\u6708\u5EA6\u62A5\u8868\u6E05\u6D17\uFF09",
|
|
5455
|
+
value: macroNameInput,
|
|
5456
|
+
onChange: (e) => setMacroNameInput(e.target.value)
|
|
5457
|
+
}
|
|
5458
|
+
),
|
|
5459
|
+
!macroRecState.recording ? /* @__PURE__ */ jsx2(
|
|
5460
|
+
"button",
|
|
5461
|
+
{
|
|
5462
|
+
"data-testid": "yudao-macro-start-btn",
|
|
5463
|
+
type: "button",
|
|
5464
|
+
className: "yudao-sheet-btn is-soft-primary",
|
|
5465
|
+
onClick: () => {
|
|
5466
|
+
commandService.syncExecuteCommand(StartSheetMacroRecordCommand.id, {
|
|
5467
|
+
unitId,
|
|
5468
|
+
name: macroNameInput.trim() || void 0
|
|
5469
|
+
});
|
|
5470
|
+
setMacroStatusMsg("\u5DF2\u5F00\u59CB\u5F55\u5236\u5DE5\u4F5C\u8868\u64CD\u4F5C\uFF08\u4EC5\u8BB0\u5F55\u6570\u636E/\u6837\u5F0F/\u5206\u6790\u53D8\u66F4\uFF0C\u5FFD\u7565\u9009\u533A\u6EDA\u52A8\uFF09");
|
|
5471
|
+
},
|
|
5472
|
+
children: "\u5F00\u59CB\u5F55\u5236"
|
|
5473
|
+
}
|
|
5474
|
+
) : /* @__PURE__ */ jsx2(
|
|
5475
|
+
"button",
|
|
5476
|
+
{
|
|
5477
|
+
"data-testid": "yudao-macro-stop-btn",
|
|
5478
|
+
type: "button",
|
|
5479
|
+
className: "yudao-sheet-btn",
|
|
5480
|
+
style: { borderColor: "#FCA5A5", color: "#B91C1C", background: "#FEF2F2" },
|
|
5481
|
+
onClick: () => {
|
|
5482
|
+
commandService.syncExecuteCommand(StopSheetMacroRecordCommand.id, {
|
|
5483
|
+
unitId,
|
|
5484
|
+
name: macroNameInput.trim() || void 0,
|
|
5485
|
+
onSaved: (saved) => {
|
|
5486
|
+
setMacroStatusMsg(`\u5DF2\u4FDD\u5B58\u64CD\u4F5C\u5B8F\u300C${saved.name}\u300D\uFF08\u5171 ${saved.steps.length} \u6B65\uFF09`);
|
|
5487
|
+
setMacroNameInput("");
|
|
5488
|
+
}
|
|
5489
|
+
});
|
|
5490
|
+
},
|
|
5491
|
+
children: "\u505C\u6B62\u4FDD\u5B58"
|
|
5492
|
+
}
|
|
5493
|
+
)
|
|
5494
|
+
] }),
|
|
5495
|
+
(macroService ? macroService.getMacros(unitId) : getWorkbookMacros(workbook)).map((m) => /* @__PURE__ */ jsxs2(
|
|
5496
|
+
"div",
|
|
5497
|
+
{
|
|
5498
|
+
"data-testid": `yudao-macro-item-${m.id}`,
|
|
5499
|
+
style: {
|
|
5500
|
+
display: "flex",
|
|
5501
|
+
alignItems: "center",
|
|
5502
|
+
justifyContent: "space-between",
|
|
5503
|
+
gap: 6,
|
|
5504
|
+
padding: "4px 6px",
|
|
5505
|
+
background: "#FFFFFF",
|
|
5506
|
+
border: "1px solid #E3E5EA",
|
|
5507
|
+
borderRadius: 6,
|
|
5508
|
+
fontSize: 11
|
|
5509
|
+
},
|
|
5510
|
+
children: [
|
|
5511
|
+
/* @__PURE__ */ jsxs2("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
5512
|
+
/* @__PURE__ */ jsx2("div", { style: { fontWeight: 600, color: "#1B1C1F" }, children: m.name }),
|
|
5513
|
+
/* @__PURE__ */ jsxs2("div", { style: { color: "#7D8698", fontSize: 10 }, children: [
|
|
5514
|
+
m.steps.length,
|
|
5515
|
+
" \u6B65\u81EA\u52A8\u5316\u6307\u4EE4"
|
|
5516
|
+
] })
|
|
5517
|
+
] }),
|
|
5518
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 3 }, children: [
|
|
5519
|
+
/* @__PURE__ */ jsx2(
|
|
5520
|
+
"button",
|
|
5521
|
+
{
|
|
5522
|
+
"data-testid": `yudao-macro-replay-${m.id}`,
|
|
5523
|
+
type: "button",
|
|
5524
|
+
className: "yudao-sheet-btn is-soft-primary",
|
|
5525
|
+
style: { padding: "2px 6px", fontSize: 10.5 },
|
|
5526
|
+
onClick: () => {
|
|
5527
|
+
const ok = commandService.syncExecuteCommand(ReplaySheetMacroCommand.id, {
|
|
5528
|
+
unitId,
|
|
5529
|
+
macroId: m.id,
|
|
5530
|
+
sheetId: sheet.getSheetId()
|
|
5531
|
+
});
|
|
5532
|
+
setMacroStatusMsg(
|
|
5533
|
+
ok ? `\u5DF2\u5728\u5DE5\u4F5C\u8868\u300C${sheet.getName()}\u300D\u4E00\u952E\u56DE\u653E\u5B8F\u300C${m.name}\u300D` : `\u56DE\u653E\u5B8F\u300C${m.name}\u300D\u5931\u8D25`
|
|
5534
|
+
);
|
|
5535
|
+
},
|
|
5536
|
+
children: "\u4E00\u952E\u56DE\u653E"
|
|
5537
|
+
}
|
|
5538
|
+
),
|
|
5539
|
+
/* @__PURE__ */ jsx2(
|
|
5540
|
+
"button",
|
|
5541
|
+
{
|
|
5542
|
+
"data-testid": `yudao-macro-view-script-${m.id}`,
|
|
5543
|
+
type: "button",
|
|
5544
|
+
className: "yudao-sheet-btn",
|
|
5545
|
+
style: { padding: "2px 6px", fontSize: 10.5 },
|
|
5546
|
+
onClick: () => setPreviewMacro(previewMacro?.id === m.id ? null : m),
|
|
5547
|
+
children: "\u67E5\u770B\u811A\u672C"
|
|
5548
|
+
}
|
|
5549
|
+
),
|
|
5550
|
+
/* @__PURE__ */ jsx2(
|
|
5551
|
+
"button",
|
|
5552
|
+
{
|
|
5553
|
+
"data-testid": `yudao-macro-delete-${m.id}`,
|
|
5554
|
+
type: "button",
|
|
5555
|
+
className: "yudao-sheet-btn",
|
|
5556
|
+
style: { padding: "2px 5px", fontSize: 10.5 },
|
|
5557
|
+
onClick: () => {
|
|
5558
|
+
commandService.syncExecuteCommand(DeleteSheetMacroCommand.id, {
|
|
5559
|
+
unitId,
|
|
5560
|
+
macroId: m.id
|
|
5561
|
+
});
|
|
5562
|
+
if (previewMacro?.id === m.id) setPreviewMacro(null);
|
|
5563
|
+
setMacroStatusMsg(`\u5DF2\u5220\u9664\u5B8F\u300C${m.name}\u300D`);
|
|
5564
|
+
},
|
|
5565
|
+
children: "\u5220\u9664"
|
|
5566
|
+
}
|
|
5567
|
+
)
|
|
5568
|
+
] })
|
|
5569
|
+
]
|
|
5570
|
+
},
|
|
5571
|
+
m.id
|
|
5572
|
+
)),
|
|
5573
|
+
previewMacro && /* @__PURE__ */ jsxs2(
|
|
5574
|
+
"div",
|
|
5575
|
+
{
|
|
5576
|
+
"data-testid": "yudao-macro-script-modal",
|
|
5577
|
+
style: {
|
|
5578
|
+
display: "flex",
|
|
5579
|
+
flexDirection: "column",
|
|
5580
|
+
gap: 5,
|
|
5581
|
+
padding: "6px 8px",
|
|
5582
|
+
borderRadius: 6,
|
|
5583
|
+
background: "#0F172A",
|
|
5584
|
+
color: "#E2E8F0",
|
|
5585
|
+
fontSize: 10.5
|
|
5586
|
+
},
|
|
5587
|
+
children: [
|
|
5588
|
+
/* @__PURE__ */ jsxs2(
|
|
5589
|
+
"div",
|
|
5590
|
+
{
|
|
5591
|
+
style: {
|
|
5592
|
+
display: "flex",
|
|
5593
|
+
alignItems: "center",
|
|
5594
|
+
justifyContent: "space-between",
|
|
5595
|
+
gap: 6
|
|
5596
|
+
},
|
|
5597
|
+
children: [
|
|
5598
|
+
/* @__PURE__ */ jsxs2("span", { style: { fontWeight: 600, color: "#F8FAFC" }, children: [
|
|
5599
|
+
"Facade \u811A\u672C\u9884\u89C8\uFF1A",
|
|
5600
|
+
previewMacro.name
|
|
5601
|
+
] }),
|
|
5602
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 4 }, children: [
|
|
5603
|
+
/* @__PURE__ */ jsx2(
|
|
5604
|
+
"button",
|
|
5605
|
+
{
|
|
5606
|
+
"data-testid": "yudao-macro-script-copy-btn",
|
|
5607
|
+
type: "button",
|
|
5608
|
+
className: "yudao-sheet-btn",
|
|
5609
|
+
style: { padding: "1px 6px", fontSize: 10 },
|
|
5610
|
+
onClick: () => {
|
|
5611
|
+
void globalThis.navigator?.clipboard?.writeText?.(
|
|
5612
|
+
previewMacro.generatedScript
|
|
5613
|
+
);
|
|
5614
|
+
setMacroStatusMsg(`\u5DF2\u590D\u5236\u300C${previewMacro.name}\u300D\u81EA\u52A8\u5316\u811A\u672C`);
|
|
5615
|
+
},
|
|
5616
|
+
children: "\u590D\u5236\u4EE3\u7801"
|
|
5617
|
+
}
|
|
5618
|
+
),
|
|
5619
|
+
/* @__PURE__ */ jsx2(
|
|
5620
|
+
"button",
|
|
5621
|
+
{
|
|
5622
|
+
"data-testid": "yudao-macro-script-close-btn",
|
|
5623
|
+
type: "button",
|
|
5624
|
+
className: "yudao-sheet-btn",
|
|
5625
|
+
style: { padding: "1px 6px", fontSize: 10 },
|
|
5626
|
+
onClick: () => setPreviewMacro(null),
|
|
5627
|
+
children: "\u5173\u95ED"
|
|
5628
|
+
}
|
|
5629
|
+
)
|
|
5630
|
+
] })
|
|
5631
|
+
]
|
|
5632
|
+
}
|
|
5633
|
+
),
|
|
5634
|
+
/* @__PURE__ */ jsx2(
|
|
5635
|
+
"pre",
|
|
5636
|
+
{
|
|
5637
|
+
"data-testid": "yudao-macro-script-code",
|
|
5638
|
+
style: {
|
|
5639
|
+
margin: 0,
|
|
5640
|
+
padding: "6px",
|
|
5641
|
+
borderRadius: 4,
|
|
5642
|
+
background: "#1E293B",
|
|
5643
|
+
color: "#93C5FD",
|
|
5644
|
+
fontFamily: "monospace",
|
|
5645
|
+
fontSize: 10,
|
|
5646
|
+
lineHeight: 1.45,
|
|
5647
|
+
maxHeight: 160,
|
|
5648
|
+
overflow: "auto",
|
|
5649
|
+
whiteSpace: "pre-wrap",
|
|
5650
|
+
wordBreak: "break-all"
|
|
5651
|
+
},
|
|
5652
|
+
children: previewMacro.generatedScript
|
|
5653
|
+
}
|
|
5654
|
+
)
|
|
5655
|
+
]
|
|
5656
|
+
}
|
|
5657
|
+
),
|
|
5658
|
+
macroStatusMsg && /* @__PURE__ */ jsx2(
|
|
5659
|
+
"div",
|
|
5660
|
+
{
|
|
5661
|
+
"data-testid": "yudao-macro-status",
|
|
5662
|
+
style: { fontSize: 10.5, color: "#4E5565", lineHeight: 1.35 },
|
|
5663
|
+
children: macroStatusMsg
|
|
5664
|
+
}
|
|
5665
|
+
)
|
|
5666
|
+
] }),
|
|
4839
5667
|
features.versionHistory && /* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section", children: [
|
|
4840
5668
|
/* @__PURE__ */ jsxs2("div", { className: "yudao-sheet-section-title", children: [
|
|
4841
5669
|
/* @__PURE__ */ jsx2("span", { children: "\u7248\u672C\u5386\u53F2\u4E0E\u62A5\u8868\u8FC1\u79FB\u5305" }),
|