@yudaocode/univer-sheets-ui 1.6.206 → 1.6.208

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -121,6 +121,7 @@ function resolveSheetsUIFeatures(raw) {
121
121
  fieldDrag: raw?.fieldDrag ?? true,
122
122
  syntaxSelector: raw?.syntaxSelector ?? true,
123
123
  advancedCellBinding: raw?.advancedCellBinding ?? true,
124
+ contextualCellBinding: Boolean(raw?.contextualCellBinding),
124
125
  builtinPreviewModal: raw?.builtinPreviewModal ?? true
125
126
  };
126
127
  }
@@ -315,7 +316,8 @@ var enUS = {
315
316
  emptyBoundCells: "No dataset bindings found (or data already expanded; press Ctrl+Z to restore template).",
316
317
  kindList: "Vertical List",
317
318
  kindCrossTab: "Cross-Tab Horizontal",
318
- kindScalar: "Scalar Value"
319
+ kindScalar: "Scalar Value",
320
+ hiddenSheetBadge: "Hidden"
319
321
  },
320
322
  inspector: {
321
323
  activeCellLabel: "Active Cell: ",
@@ -330,6 +332,7 @@ var enUS = {
330
332
  subTabAnalytics: "Analytics",
331
333
  subTabFill: "Form Fill",
332
334
  datasetSectionTitle: "Dataset & Cross-Tab Expansion",
335
+ mergedCellExpandHint: "Merged cells only support vertical expansion without grouping",
333
336
  cellFilterTitle: "Cell Dataset Filter (cellFilterConditions)",
334
337
  cellFilterAddBtn: "+ Add Filter",
335
338
  cellFilterEmptyHint: "No cell-level filter configured (supports field or $param.xxx rules)",
@@ -411,7 +414,8 @@ var zhCN = {
411
414
  emptyBoundCells: "\u5F53\u524D\u5DE5\u4F5C\u7C3F\u6682\u65E0\u7ED1\u5B9A\u8868\u8FBE\u5F0F\uFF08\u6216\u5DF2\u5B8C\u6210\u6570\u636E\u586B\u5145\uFF0C\u6309 Ctrl+Z \u53EF\u56DE\u5230\u6A21\u677F\u6001\uFF09\u3002",
412
415
  kindList: "\u5217\u8868\u81EA\u52A8\u4E0B\u63A8",
413
416
  kindCrossTab: "\u6A2A\u5411\u4EA4\u53C9\u6269\u5C55",
414
- kindScalar: "\u5355\u503C\u586B\u5145"
417
+ kindScalar: "\u5355\u503C\u586B\u5145",
418
+ hiddenSheetBadge: "\u9690\u85CF\u8868"
415
419
  },
416
420
  inspector: {
417
421
  activeCellLabel: "\u5F53\u524D\u5355\u5143\u683C\uFF1A",
@@ -426,6 +430,7 @@ var zhCN = {
426
430
  subTabAnalytics: "\u900F\u89C6",
427
431
  subTabFill: "\u586B\u62A5",
428
432
  datasetSectionTitle: "\u6570\u636E\u96C6\u4E0E\u4EA4\u53C9\u6269\u5C55",
433
+ mergedCellExpandHint: "\u5408\u5E76\u5355\u5143\u683C\u4EC5\u652F\u6301\u7EB5\u5411\u6269\u5C55\u4E14\u4E0D\u5206\u7EC4",
429
434
  cellFilterTitle: "\u5355\u5143\u683C\u6570\u636E\u8FC7\u6EE4\u6761\u4EF6 (cellFilterConditions)",
430
435
  cellFilterAddBtn: "+ \u6DFB\u52A0\u8FC7\u6EE4",
431
436
  cellFilterEmptyHint: "\u672A\u914D\u7F6E\u5355\u5143\u683C\u7EA7\u8FC7\u6EE4\u6761\u4EF6\uFF08\u652F\u6301\u6309\u5B57\u6BB5\u6216 $param.xxx \u52A8\u6001\u7B5B\u9009\uFF09",
@@ -621,16 +626,24 @@ var SheetInspectorPanel = () => {
621
626
  const metadata = templateService.getTemplateMetadata(unitId);
622
627
  const effectiveSyntax = templateService.getPlaceholderSyntax(unitId);
623
628
  const effectiveImplicitExpand = templateService.getImplicitExpand(unitId);
629
+ const parseSyntax = features.contextualCellBinding ? effectiveSyntax : "any";
624
630
  const allFields = (metadata.datasets ?? []).flatMap((g) => g.fields);
625
631
  const boundCount = (0, import_univer_sheets2.scanWorkbookBoundCells)(workbook.save(), metadata.sampleData, {
626
- implicitExpand: effectiveImplicitExpand
632
+ implicitExpand: effectiveImplicitExpand,
633
+ placeholderSyntax: parseSyntax
627
634
  }).length;
628
635
  const printCfg = metadata.printConfig ?? {};
629
636
  const protectionCfg = metadata.protection;
630
637
  const charts = metadata.charts ?? [];
631
638
  const activeAlertRule = cellMeta.alertRules?.[0];
632
- const currentExprMatch = typeof activeCell?.v === "string" ? activeCell.v.trim().match(/^(?:\$|#)\{(#?[\p{L}\p{N}_.\[\]-]+)\}$/u) : null;
633
- const currentBoundKey = currentExprMatch?.[1] ?? "";
639
+ 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;
640
+ const currentExprMatch = typeof activeCell?.v === "string" ? activeCell.v.trim().match(singleExprRe) : null;
641
+ const currentBoundKey = currentExprMatch?.[1]?.trim() ?? "";
642
+ const isMergedCell = Boolean(resolvedMaster.mergeRange);
643
+ const restrictMergedExpand = features.contextualCellBinding && isMergedCell;
644
+ const cellPlaceholders = (0, import_univer_sheets2.extractCellPlaceholders)(activeCell, { syntax: parseSyntax });
645
+ const isDynamicBoundCell = features.contextualCellBinding ? cellPlaceholders.length > 0 : true;
646
+ const showStaticAutoOption = !features.contextualCellBinding || !isDynamicBoundCell;
634
647
  const hasExplicitListToken = typeof activeCell?.v === "string" && (activeCell.v.includes("${#") || activeCell.v.includes("#{#") || activeCell.v.includes("[]."));
635
648
  const resolvedExpandValue = cellMeta.expand ?? (hasExplicitListToken ? "v" : effectiveImplicitExpand);
636
649
  const patchCellMeta = (patch) => {
@@ -937,7 +950,7 @@ var SheetInspectorPanel = () => {
937
950
  }
938
951
  )
939
952
  ] }),
940
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
953
+ isDynamicBoundCell && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
941
954
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6269\u5C55\u65B9\u5411\uFF08\u652F\u6301\u4EA4\u53C9\u8868\u6A2A\u5411\u88C2\u53D8\u5217\uFF09" }),
942
955
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
943
956
  "select",
@@ -946,13 +959,13 @@ var SheetInspectorPanel = () => {
946
959
  onChange: (e) => patchCellMeta({ expand: e.target.value }),
947
960
  children: [
948
961
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "v", children: "\u7EB5\u5411\u5411\u4E0B\u6269\u5C55\u884C (List)" }),
949
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "h", children: "\u6A2A\u5411\u5411\u53F3\u6269\u5C55\u5217 (Cross-Tab \u4EA4\u53C9\u8868)" }),
962
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "h", disabled: restrictMergedExpand && resolvedExpandValue !== "h", children: "\u6A2A\u5411\u5411\u53F3\u6269\u5C55\u5217 (Cross-Tab \u4EA4\u53C9\u8868)" }),
950
963
  (features.advancedCellBinding || resolvedExpandValue === "none") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "none", children: "\u4E0D\u6269\u5C55\uFF08\u9759\u6001\u5355\u503C\u66FF\u6362\uFF09" })
951
964
  ]
952
965
  }
953
966
  )
954
967
  ] }),
955
- features.advancedCellBinding && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
968
+ features.advancedCellBinding && isDynamicBoundCell && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
956
969
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
957
970
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-sheet-field-row", children: [
958
971
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5DE6\u7236\u683C (leftParentCell)" }),
@@ -1152,18 +1165,20 @@ var SheetInspectorPanel = () => {
1152
1165
  ] })
1153
1166
  ] }),
1154
1167
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 5 }, children: [
1155
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1168
+ isDynamicBoundCell && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1156
1169
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1157
1170
  "input",
1158
1171
  {
1159
1172
  type: "checkbox",
1160
1173
  checked: Boolean(cellMeta.group),
1174
+ disabled: restrictMergedExpand && !cellMeta.group,
1161
1175
  onChange: (e) => patchCellMeta({ group: e.target.checked })
1162
1176
  }
1163
1177
  ),
1164
1178
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u76F8\u90BB\u76F8\u540C\u5206\u7EC4\u503C\u81EA\u52A8\u7EB5\u5411\u5408\u5E76\u5355\u5143\u683C (Group)" })
1165
1179
  ] }),
1166
- features.advancedCellBinding && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1180
+ isDynamicBoundCell && restrictMergedExpand && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: 11, color: "#7D8698" }, children: t("yudaoSheets.inspector.mergedCellExpandHint") }),
1181
+ features.advancedCellBinding && isDynamicBoundCell && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1167
1182
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1168
1183
  "input",
1169
1184
  {
@@ -1174,18 +1189,20 @@ var SheetInspectorPanel = () => {
1174
1189
  ),
1175
1190
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u81EA\u52A8\u751F\u6210\u9012\u589E\u5E8F\u53F7 (=SEQ / \u6309\u7EC4\u91CD\u6392)" })
1176
1191
  ] }),
1177
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1192
+ showStaticAutoOption && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1178
1193
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1179
1194
  "input",
1180
1195
  {
1181
1196
  type: "checkbox",
1182
- checked: Boolean(cellMeta.auto || activeCell?.custom?.auto),
1183
- onChange: (e) => patchCellMeta({ auto: e.target.checked || void 0 })
1197
+ checked: Boolean(cellMeta.auto),
1198
+ onChange: (e) => patchCellMeta({
1199
+ auto: templateService.getCellMetaLayout(unitId) === "flat" ? e.target.checked : e.target.checked || void 0
1200
+ })
1184
1201
  }
1185
1202
  ),
1186
1203
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u4F34\u968F\u540C\u884C\u5217\u8868\u81EA\u52A8\u590D\u5236\u6269\u5C55 (auto)" })
1187
1204
  ] }),
1188
- features.advancedCellBinding && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1205
+ features.advancedCellBinding && isDynamicBoundCell && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" }, children: [
1189
1206
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1190
1207
  "input",
1191
1208
  {
@@ -1320,7 +1337,7 @@ var SheetInspectorPanel = () => {
1320
1337
  )
1321
1338
  ] })
1322
1339
  ] }),
1323
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1340
+ (isDynamicBoundCell || Boolean(cellMeta.hideIf)) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1324
1341
  "div",
1325
1342
  {
1326
1343
  style: {
@@ -3661,10 +3678,8 @@ var SheetLeftSidebar = () => {
3661
3678
  const effectiveImplicitExpand = templateService.getImplicitExpand(unitId);
3662
3679
  const datasets = metadata.datasets ?? [];
3663
3680
  const boundCells = (0, import_univer_sheets3.scanWorkbookBoundCells)(workbook.save(), metadata.sampleData, {
3664
- implicitExpand: effectiveImplicitExpand
3665
- }).filter((item) => {
3666
- const sh = workbook.getSheetBySheetId(item.sheetId);
3667
- return sh ? !sh.isSheetHidden() : true;
3681
+ implicitExpand: effectiveImplicitExpand,
3682
+ placeholderSyntax: features.contextualCellBinding ? effectiveSyntax : "any"
3668
3683
  });
3669
3684
  const handleJumpToCell = (item) => {
3670
3685
  try {
@@ -3827,39 +3842,50 @@ var SheetLeftSidebar = () => {
3827
3842
  },
3828
3843
  group.id || group.name
3829
3844
  ))
3830
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "yudao-sheet-left-body", children: boundCells.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: 12, color: "#7D8698", textAlign: "center", padding: "24px 8px" }, children: t("yudaoSheets.leftSidebar.emptyBoundCells") }) : boundCells.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3831
- "div",
3832
- {
3833
- className: "yudao-sheet-section",
3834
- style: { padding: "8px 10px", cursor: "pointer", background: "#FFFFFF" },
3835
- onClick: () => handleJumpToCell(item),
3836
- children: [
3837
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
3838
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("strong", { style: { color: "#1B1C1F", fontSize: 12 }, children: [
3839
- item.sheetName,
3840
- "!",
3841
- item.cellRef
3845
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "yudao-sheet-left-body", children: boundCells.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: 12, color: "#7D8698", textAlign: "center", padding: "24px 8px" }, children: t("yudaoSheets.leftSidebar.emptyBoundCells") }) : boundCells.map((item) => {
3846
+ const isHiddenSheet = Boolean(workbook.getSheetBySheetId(item.sheetId)?.isSheetHidden());
3847
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3848
+ "div",
3849
+ {
3850
+ className: "yudao-sheet-section",
3851
+ style: {
3852
+ padding: "8px 10px",
3853
+ cursor: isHiddenSheet ? "not-allowed" : "pointer",
3854
+ opacity: isHiddenSheet ? 0.72 : 1,
3855
+ background: "#FFFFFF"
3856
+ },
3857
+ onClick: () => handleJumpToCell(item),
3858
+ children: [
3859
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
3860
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("strong", { style: { color: "#1B1C1F", fontSize: 12 }, children: [
3861
+ item.sheetName,
3862
+ "!",
3863
+ item.cellRef
3864
+ ] }),
3865
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3866
+ "span",
3867
+ {
3868
+ style: {
3869
+ fontSize: 10,
3870
+ fontWeight: 500,
3871
+ padding: "1px 6px",
3872
+ borderRadius: 999,
3873
+ background: item.kind === "list" || item.kind === "crossTab" ? "#F3F5FF" : "#EEEFF1",
3874
+ color: item.kind === "list" || item.kind === "crossTab" ? "#2C53F1" : "#4E5565"
3875
+ },
3876
+ children: [
3877
+ isHiddenSheet ? `${t("yudaoSheets.leftSidebar.hiddenSheetBadge")} \xB7 ` : "",
3878
+ item.kind === "crossTab" ? t("yudaoSheets.leftSidebar.kindCrossTab") : item.kind === "list" ? t("yudaoSheets.leftSidebar.kindList") : t("yudaoSheets.leftSidebar.kindScalar")
3879
+ ]
3880
+ }
3881
+ )
3842
3882
  ] }),
3843
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3844
- "span",
3845
- {
3846
- style: {
3847
- fontSize: 10,
3848
- fontWeight: 500,
3849
- padding: "1px 6px",
3850
- borderRadius: 999,
3851
- background: item.kind === "list" || item.kind === "crossTab" ? "#F3F5FF" : "#EEEFF1",
3852
- color: item.kind === "list" || item.kind === "crossTab" ? "#2C53F1" : "#4E5565"
3853
- },
3854
- children: item.kind === "crossTab" ? t("yudaoSheets.leftSidebar.kindCrossTab") : item.kind === "list" ? t("yudaoSheets.leftSidebar.kindList") : t("yudaoSheets.leftSidebar.kindScalar")
3855
- }
3856
- )
3857
- ] }),
3858
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { style: { fontSize: 11, color: "#7D8698", wordBreak: "break-all" }, children: item.rawText })
3859
- ]
3860
- },
3861
- `${item.sheetId}_${item.row}_${item.col}`
3862
- )) })
3883
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { style: { fontSize: 11, color: "#7D8698", wordBreak: "break-all" }, children: item.rawText })
3884
+ ]
3885
+ },
3886
+ `${item.sheetId}_${item.row}_${item.col}`
3887
+ );
3888
+ }) })
3863
3889
  ] });
3864
3890
  };
3865
3891