@univerjs/ui 1.0.0-alpha.8 → 1.0.0-beta.0

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
@@ -29,19 +29,17 @@ let _univerjs_icons = require("@univerjs/icons");
29
29
  const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
30
30
  const EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
31
31
  function getEmbedBoundaryOwner(target) {
32
- var _ref, _getAttributeValue;
33
32
  if (!hasClosest(target)) return;
34
33
  const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
35
- return (_ref = (_getAttributeValue = getAttributeValue(target, "data-embed-interaction-boundary-owner")) !== null && _getAttributeValue !== void 0 ? _getAttributeValue : getAttributeValue(ownerElement, "data-embed-interaction-boundary-owner")) !== null && _ref !== void 0 ? _ref : void 0;
34
+ return getAttributeValue(target, "data-embed-interaction-boundary-owner") ?? getAttributeValue(ownerElement, "data-embed-interaction-boundary-owner") ?? void 0;
36
35
  }
37
36
  function isEmbedBoundaryTarget(target) {
38
37
  return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
39
38
  }
40
39
  function getEmbedChildUnitId(target) {
41
- var _ref2, _getAttributeValue2;
42
40
  if (!hasClosest(target)) return;
43
41
  const childRuntime = target.closest(`[${EMBED_CHILD_UNIT_ID_ATTRIBUTE}]`);
44
- return (_ref2 = (_getAttributeValue2 = getAttributeValue(target, "data-embed-child-unit-id")) !== null && _getAttributeValue2 !== void 0 ? _getAttributeValue2 : getAttributeValue(childRuntime, "data-embed-child-unit-id")) !== null && _ref2 !== void 0 ? _ref2 : void 0;
42
+ return getAttributeValue(target, "data-embed-child-unit-id") ?? getAttributeValue(childRuntime, "data-embed-child-unit-id") ?? void 0;
45
43
  }
46
44
  function keepInteractionInsideSameEmbedBoundary(event) {
47
45
  const owner = getEmbedBoundaryOwner(event.currentTarget);
@@ -52,9 +50,8 @@ function hasClosest(target) {
52
50
  return !!target && typeof target.closest === "function";
53
51
  }
54
52
  function getAttributeValue(target, name) {
55
- var _getAttribute$call;
56
53
  const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
57
- return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
54
+ return typeof getAttribute === "function" ? getAttribute.call(target, name) ?? void 0 : void 0;
58
55
  }
59
56
 
60
57
  //#endregion
@@ -921,14 +918,13 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
921
918
  return null;
922
919
  }
923
920
  getShortcutDisplay(shortcut) {
924
- var _KeyCodeToChar;
925
921
  const binding = this._getBindingFromItem(shortcut);
926
922
  if (!binding) return null;
927
923
  const ctrlKey = binding & 4096;
928
924
  const shiftKey = binding & 1024;
929
925
  const altKey = binding & 2048;
930
926
  const macCtrl = binding & 8192;
931
- const body = (_KeyCodeToChar = KeyCodeToChar[binding & 255]) !== null && _KeyCodeToChar !== void 0 ? _KeyCodeToChar : "<->";
927
+ const body = KeyCodeToChar[binding & 255] ?? "<->";
932
928
  if (this._platformService.isMac) return `${ctrlKey ? "⌘+" : ""}${shiftKey ? "⇧+" : ""}${altKey ? "⌥+" : ""}${macCtrl ? "⌃+" : ""}${body}`;
933
929
  return `${ctrlKey ? "Ctrl+" : ""}${shiftKey ? "Shift+" : ""}${altKey ? "Alt+" : ""}${body}`;
934
930
  }
@@ -948,26 +944,22 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
948
944
  _resolveKeyboardEvent(e) {
949
945
  const candidate = this.dispatch(e);
950
946
  if (candidate) {
951
- var _this$_getRuntimeServ, _this$_getRuntimeServ2;
952
- (_this$_getRuntimeServ = (_this$_getRuntimeServ2 = this._getRuntimeService(e, _univerjs_core.ICommandService)) === null || _this$_getRuntimeServ2 === void 0 ? void 0 : _this$_getRuntimeServ2.executeCommand(candidate.id, candidate.staticParameters)) !== null && _this$_getRuntimeServ !== void 0 || this._commandService.executeCommand(candidate.id, candidate.staticParameters);
947
+ var _this$_getRuntimeServ;
948
+ ((_this$_getRuntimeServ = this._getRuntimeService(e, _univerjs_core.ICommandService)) === null || _this$_getRuntimeServ === void 0 ? void 0 : _this$_getRuntimeServ.executeCommand(candidate.id, candidate.staticParameters)) ?? this._commandService.executeCommand(candidate.id, candidate.staticParameters);
953
949
  e.preventDefault();
954
950
  }
955
951
  }
956
952
  dispatch(e) {
957
- var _this$_getRuntimeServ3;
958
953
  if (this._forceEscaped || this._forceDisabled) return;
959
954
  if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
960
955
  const binding = this._deriveBindingFromEvent(e);
961
956
  if (binding === null) return;
962
957
  const shortcuts = this._shortCutMapping.get(binding);
963
958
  if (shortcuts === void 0) return;
964
- const contextService = (_this$_getRuntimeServ3 = this._getRuntimeService(e, _univerjs_core.IContextService)) !== null && _this$_getRuntimeServ3 !== void 0 ? _this$_getRuntimeServ3 : this._contextService;
965
- const candidateShortcut = Array.from(shortcuts).sort((s1, s2) => {
966
- var _s2$priority, _s1$priority;
967
- return ((_s2$priority = s2.priority) !== null && _s2$priority !== void 0 ? _s2$priority : 0) - ((_s1$priority = s1.priority) !== null && _s1$priority !== void 0 ? _s1$priority : 0);
968
- }).find((s) => {
969
- var _s$eventPreconditions, _s$eventPreconditions2, _s$preconditions, _s$preconditions2;
970
- return ((_s$eventPreconditions = (_s$eventPreconditions2 = s.eventPreconditions) === null || _s$eventPreconditions2 === void 0 ? void 0 : _s$eventPreconditions2.call(s, e)) !== null && _s$eventPreconditions !== void 0 ? _s$eventPreconditions : true) && ((_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s, contextService)) !== null && _s$preconditions !== void 0 ? _s$preconditions : true);
959
+ const contextService = this._getRuntimeService(e, _univerjs_core.IContextService) ?? this._contextService;
960
+ const candidateShortcut = Array.from(shortcuts).sort((s1, s2) => (s2.priority ?? 0) - (s1.priority ?? 0)).find((s) => {
961
+ var _s$eventPreconditions, _s$preconditions;
962
+ return (((_s$eventPreconditions = s.eventPreconditions) === null || _s$eventPreconditions === void 0 ? void 0 : _s$eventPreconditions.call(s, e)) ?? true) && (((_s$preconditions = s.preconditions) === null || _s$preconditions === void 0 ? void 0 : _s$preconditions.call(s, contextService)) ?? true);
971
963
  });
972
964
  if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) && (candidateShortcut === null || candidateShortcut === void 0 ? void 0 : candidateShortcut.nativeTextEditorBehavior) !== 1) return;
973
965
  return candidateShortcut;
@@ -1309,7 +1301,7 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1309
1301
  * @param target default is root menu
1310
1302
  */
1311
1303
  mergeMenu(source, target) {
1312
- const _target = target !== null && target !== void 0 ? target : this._menu;
1304
+ const _target = target ?? this._menu;
1313
1305
  for (const [key, value] of Object.entries(_target)) if (key in source) {
1314
1306
  const targetRecord = _target;
1315
1307
  const sourceRecord = source;
@@ -1376,7 +1368,6 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1376
1368
  * @returns Menu schema array or empty array if not found
1377
1369
  */
1378
1370
  getMenuByPositionKey(key) {
1379
- var _findKey;
1380
1371
  const findKey = (obj) => {
1381
1372
  if (key in obj) return this._buildMenuSchema(obj[key]);
1382
1373
  for (const k in obj) {
@@ -1387,7 +1378,7 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1387
1378
  }
1388
1379
  }
1389
1380
  };
1390
- return (_findKey = findKey(this._menu)) !== null && _findKey !== void 0 ? _findKey : [];
1381
+ return findKey(this._menu) ?? [];
1391
1382
  }
1392
1383
  /**
1393
1384
  * Get flat menu schema by position key
@@ -1411,7 +1402,7 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1411
1402
  };
1412
1403
  MenuManagerService = _MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
1413
1404
  function normalizeMenuOrder(order) {
1414
- return order !== null && order !== void 0 ? order : 0;
1405
+ return order ?? 0;
1415
1406
  }
1416
1407
  function isMenuSchemaRecord(value) {
1417
1408
  return value != null && typeof value === "object" && !Array.isArray(value);
@@ -1609,8 +1600,7 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
1609
1600
  const activatedTab = this._activatedTab$.getValue();
1610
1601
  const activeGroup = ribbon.find((group) => group.key === activatedTab);
1611
1602
  if (!activeGroup && this._contextualTabs.has(activatedTab)) {
1612
- var _ref, _ribbon$find;
1613
- const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
1603
+ const fallbackTab = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual) ?? ribbon.find((group) => group.key === "ribbon.start") ?? ribbon[0];
1614
1604
  if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
1615
1605
  } else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
1616
1606
  const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
@@ -1660,12 +1650,10 @@ function useObservableRef(observable, defaultValue) {
1660
1650
  const FEATURE_SEARCH_COMPONENT = "FeatureSearch";
1661
1651
  const FEATURE_SEARCH_DIALOG_ID = "FEATURE_SEARCH_DIALOG";
1662
1652
  function resolveParams(item, value) {
1663
- const params = typeof item.params === "function" ? item.params() : item.params;
1664
- return params !== null && params !== void 0 ? params : value === void 0 ? void 0 : { value };
1653
+ return (typeof item.params === "function" ? item.params() : item.params) ?? (value === void 0 ? void 0 : { value });
1665
1654
  }
1666
1655
  function resolveOptionParams(option) {
1667
- const params = typeof option.params === "function" ? option.params(option.value) : option.params;
1668
- return params !== null && params !== void 0 ? params : option.value === void 0 ? void 0 : { value: option.value };
1656
+ return (typeof option.params === "function" ? option.params(option.value) : option.params) ?? (option.value === void 0 ? void 0 : { value: option.value });
1669
1657
  }
1670
1658
  function deduplicate(items) {
1671
1659
  return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && _univerjs_core.Tools.diffValue(candidate.params, item.params)) === index);
@@ -1679,14 +1667,12 @@ function FeatureSearch() {
1679
1667
  const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
1680
1668
  const items = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
1681
1669
  function getItemTitle(item) {
1682
- var _ref, _item$title;
1683
- const titleKey = (_ref = (_item$title = item.title) !== null && _item$title !== void 0 ? _item$title : item.tooltip) !== null && _ref !== void 0 ? _ref : item.description;
1670
+ const titleKey = item.title ?? item.tooltip ?? item.description;
1684
1671
  return titleKey ? localeService.t(titleKey) : "";
1685
1672
  }
1686
1673
  function collectCandidates(schemas, path, keyPath, ancestors = [], parentTitle) {
1687
1674
  return schemas.flatMap((schema, index) => {
1688
- var _schema$title;
1689
- const schemaTitle = localeService.t((_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : "");
1675
+ const schemaTitle = localeService.t(schema.title ?? "");
1690
1676
  const schemaPath = schemaTitle ? [...path, schemaTitle] : path;
1691
1677
  const schemaKeyPath = [...keyPath, `${schema.key}:${index}`];
1692
1678
  const result = [];
@@ -1709,48 +1695,44 @@ function FeatureSearch() {
1709
1695
  });
1710
1696
  }
1711
1697
  function observeCandidate(candidate) {
1712
- var _item$hidden$$pipe, _item$hidden$, _item$disabled$$pipe, _item$disabled$, _item$value$$pipe, _item$value$;
1698
+ var _item$hidden$, _item$disabled$, _item$value$;
1713
1699
  const { item } = candidate;
1714
1700
  const hasOptions = item.type === 1 || item.type === 2;
1715
1701
  const selections = hasOptions ? item.selections : void 0;
1716
- const selections$ = (0, rxjs.isObservable)(selections) ? selections.pipe((0, rxjs_operators.startWith)([])) : (0, rxjs.of)(selections !== null && selections !== void 0 ? selections : []);
1702
+ const selections$ = (0, rxjs.isObservable)(selections) ? selections.pipe((0, rxjs_operators.startWith)([])) : (0, rxjs.of)(selections ?? []);
1717
1703
  return (0, rxjs.combineLatest)([
1718
1704
  candidate.ancestors.length ? (0, rxjs.combineLatest)(candidate.ancestors.map((ancestor) => {
1719
- var _ancestor$hidden$$pip, _ancestor$hidden$;
1720
- return (_ancestor$hidden$$pip = (_ancestor$hidden$ = ancestor.hidden$) === null || _ancestor$hidden$ === void 0 ? void 0 : _ancestor$hidden$.pipe((0, rxjs_operators.startWith)(true))) !== null && _ancestor$hidden$$pip !== void 0 ? _ancestor$hidden$$pip : (0, rxjs.of)(false);
1705
+ var _ancestor$hidden$;
1706
+ return ((_ancestor$hidden$ = ancestor.hidden$) === null || _ancestor$hidden$ === void 0 ? void 0 : _ancestor$hidden$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false);
1721
1707
  })).pipe((0, rxjs_operators.map)((states) => states.some(Boolean))) : (0, rxjs.of)(false),
1722
1708
  candidate.ancestors.length ? (0, rxjs.combineLatest)(candidate.ancestors.map((ancestor) => {
1723
- var _ancestor$disabled$$p, _ancestor$disabled$;
1724
- return (_ancestor$disabled$$p = (_ancestor$disabled$ = ancestor.disabled$) === null || _ancestor$disabled$ === void 0 ? void 0 : _ancestor$disabled$.pipe((0, rxjs_operators.startWith)(true))) !== null && _ancestor$disabled$$p !== void 0 ? _ancestor$disabled$$p : (0, rxjs.of)(false);
1709
+ var _ancestor$disabled$;
1710
+ return ((_ancestor$disabled$ = ancestor.disabled$) === null || _ancestor$disabled$ === void 0 ? void 0 : _ancestor$disabled$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false);
1725
1711
  })).pipe((0, rxjs_operators.map)((states) => states.some(Boolean))) : (0, rxjs.of)(false),
1726
- (_item$hidden$$pipe = (_item$hidden$ = item.hidden$) === null || _item$hidden$ === void 0 ? void 0 : _item$hidden$.pipe((0, rxjs_operators.startWith)(true))) !== null && _item$hidden$$pipe !== void 0 ? _item$hidden$$pipe : (0, rxjs.of)(false),
1727
- (_item$disabled$$pipe = (_item$disabled$ = item.disabled$) === null || _item$disabled$ === void 0 ? void 0 : _item$disabled$.pipe((0, rxjs_operators.startWith)(true))) !== null && _item$disabled$$pipe !== void 0 ? _item$disabled$$pipe : (0, rxjs.of)(false),
1728
- (_item$value$$pipe = (_item$value$ = item.value$) === null || _item$value$ === void 0 ? void 0 : _item$value$.pipe((0, rxjs_operators.startWith)(void 0))) !== null && _item$value$$pipe !== void 0 ? _item$value$$pipe : (0, rxjs.of)(void 0),
1712
+ ((_item$hidden$ = item.hidden$) === null || _item$hidden$ === void 0 ? void 0 : _item$hidden$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false),
1713
+ ((_item$disabled$ = item.disabled$) === null || _item$disabled$ === void 0 ? void 0 : _item$disabled$.pipe((0, rxjs_operators.startWith)(true))) ?? (0, rxjs.of)(false),
1714
+ ((_item$value$ = item.value$) === null || _item$value$ === void 0 ? void 0 : _item$value$.pipe((0, rxjs_operators.startWith)(void 0))) ?? (0, rxjs.of)(void 0),
1729
1715
  selections$
1730
1716
  ]).pipe((0, rxjs_operators.map)(([ancestorHidden, ancestorDisabled, hidden, disabled, value, options]) => {
1731
1717
  if (ancestorHidden || ancestorDisabled || hidden || disabled) return [];
1732
1718
  const title = getItemTitle(item);
1733
1719
  const path = candidate.path.join(" / ");
1734
1720
  const result = [];
1735
- if (title && item.type !== 1 && item.type !== 3) {
1736
- var _item$description, _item$commandId;
1737
- result.push({
1738
- key: candidate.key,
1739
- title,
1740
- parentTitle: candidate.parentTitle,
1741
- description: localeService.t((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : ""),
1742
- path,
1743
- commandId: (_item$commandId = item.commandId) !== null && _item$commandId !== void 0 ? _item$commandId : item.id,
1744
- params: resolveParams(item, value),
1745
- getParams: () => resolveParams(item, value)
1746
- });
1747
- }
1721
+ if (title && item.type !== 1 && item.type !== 3) result.push({
1722
+ key: candidate.key,
1723
+ title,
1724
+ parentTitle: candidate.parentTitle,
1725
+ description: localeService.t(item.description ?? ""),
1726
+ path,
1727
+ commandId: item.commandId ?? item.id,
1728
+ params: resolveParams(item, value),
1729
+ getParams: () => resolveParams(item, value)
1730
+ });
1748
1731
  if (hasOptions) options.forEach((option, index) => {
1749
- var _ref2, _ref3, _ref4, _option$commandId, _ref5, _ref6, _option$id;
1750
1732
  if (option.disabled || typeof option.label !== "string") return;
1751
- const commandId = (_ref2 = (_ref3 = (_ref4 = (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : option.id) !== null && _ref4 !== void 0 ? _ref4 : item.selectionsCommandId) !== null && _ref3 !== void 0 ? _ref3 : item.commandId) !== null && _ref2 !== void 0 ? _ref2 : item.id;
1733
+ const commandId = option.commandId ?? option.id ?? item.selectionsCommandId ?? item.commandId ?? item.id;
1752
1734
  result.push({
1753
- key: `${candidate.key}:option:${(_ref5 = (_ref6 = (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : option.commandId) !== null && _ref6 !== void 0 ? _ref6 : option.value) !== null && _ref5 !== void 0 ? _ref5 : index}`,
1735
+ key: `${candidate.key}:option:${option.id ?? option.commandId ?? option.value ?? index}`,
1754
1736
  title: localeService.t(option.label),
1755
1737
  parentTitle: title,
1756
1738
  description: "",
@@ -1783,35 +1765,32 @@ function FeatureSearch() {
1783
1765
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandInput, {
1784
1766
  autoFocus: true,
1785
1767
  placeholder: localeService.t("ui.featureSearch.placeholder")
1786
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandGroup, { children: items.map((item) => {
1787
- var _item$parentTitle;
1788
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandItem, {
1789
- value: item.key,
1790
- keywords: [
1791
- (_item$parentTitle = item.parentTitle) !== null && _item$parentTitle !== void 0 ? _item$parentTitle : "",
1792
- item.title,
1793
- item.description,
1794
- item.path
1795
- ],
1796
- onSelect: () => execute(item),
1797
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1798
- className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-1",
1799
- children: [item.parentTitle && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1800
- className: "univer-shrink-0",
1801
- children: item.parentTitle
1802
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1803
- className: "univer-text-gray-400",
1804
- children: "/"
1805
- })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1806
- className: "univer-truncate",
1807
- children: item.title
1808
- })]
1809
- }), item.path && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1810
- className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
1811
- children: item.path
1768
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CommandGroup, { children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CommandItem, {
1769
+ value: item.key,
1770
+ keywords: [
1771
+ item.parentTitle ?? "",
1772
+ item.title,
1773
+ item.description,
1774
+ item.path
1775
+ ],
1776
+ onSelect: () => execute(item),
1777
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1778
+ className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-1",
1779
+ children: [item.parentTitle && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1780
+ className: "univer-shrink-0",
1781
+ children: item.parentTitle
1782
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1783
+ className: "univer-text-gray-400",
1784
+ children: "/"
1785
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1786
+ className: "univer-truncate",
1787
+ children: item.title
1812
1788
  })]
1813
- }, item.key);
1814
- }) })] })]
1789
+ }), item.path && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1790
+ className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
1791
+ children: item.path
1792
+ })]
1793
+ }, item.key)) })] })]
1815
1794
  });
1816
1795
  }
1817
1796
 
@@ -1974,8 +1953,8 @@ var UIPartsService = class extends _univerjs_core.Disposable {
1974
1953
  });
1975
1954
  }
1976
1955
  isUIVisible(part) {
1977
- var _this$_uiVisible$get, _this$_disabledUIPart;
1978
- return ((_this$_uiVisible$get = this._uiVisible.get(part)) !== null && _this$_uiVisible$get !== void 0 ? _this$_uiVisible$get : true) && !((_this$_disabledUIPart = this._disabledUIParts.get(part)) === null || _this$_disabledUIPart === void 0 ? void 0 : _this$_disabledUIPart.size);
1956
+ var _this$_disabledUIPart;
1957
+ return (this._uiVisible.get(part) ?? true) && !((_this$_disabledUIPart = this._disabledUIParts.get(part)) === null || _this$_disabledUIPart === void 0 ? void 0 : _this$_disabledUIPart.size);
1979
1958
  }
1980
1959
  registerDisabledUIParts(parts, disabled$) {
1981
1960
  const uniqueParts = [...new Set(parts)];
@@ -1985,9 +1964,8 @@ var UIPartsService = class extends _univerjs_core.Disposable {
1985
1964
  if (disabled === nextDisabled) return;
1986
1965
  disabled = nextDisabled;
1987
1966
  uniqueParts.forEach((part) => {
1988
- var _this$_disabledUIPart2;
1989
1967
  const wasVisible = this.isUIVisible(part);
1990
- const registrations = (_this$_disabledUIPart2 = this._disabledUIParts.get(part)) !== null && _this$_disabledUIPart2 !== void 0 ? _this$_disabledUIPart2 : /* @__PURE__ */ new Set();
1968
+ const registrations = this._disabledUIParts.get(part) ?? /* @__PURE__ */ new Set();
1991
1969
  if (disabled) {
1992
1970
  registrations.add(registration);
1993
1971
  this._disabledUIParts.set(part, registrations);
@@ -2036,6 +2014,7 @@ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
2036
2014
  constructor(..._args) {
2037
2015
  super(..._args);
2038
2016
  _defineProperty(this, "_domLayerMap", /* @__PURE__ */ new Map());
2017
+ _defineProperty(this, "_scopedRenderRootCount", /* @__PURE__ */ new Map());
2039
2018
  _defineProperty(this, "_domLayers$", new rxjs.BehaviorSubject([]));
2040
2019
  _defineProperty(this, "domLayers$", this._domLayers$.asObservable());
2041
2020
  }
@@ -2058,6 +2037,20 @@ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
2058
2037
  this._domLayerMap.set(item.id, item);
2059
2038
  this._notice();
2060
2039
  }
2040
+ hasScopedRenderRoot(unitId) {
2041
+ return this._scopedRenderRootCount.has(unitId);
2042
+ }
2043
+ registerScopedRenderRoot(unitId) {
2044
+ this._scopedRenderRootCount.set(unitId, (this._scopedRenderRootCount.get(unitId) ?? 0) + 1);
2045
+ this._notice();
2046
+ return (0, _univerjs_core.toDisposable)(() => {
2047
+ const count = this._scopedRenderRootCount.get(unitId);
2048
+ if (count == null) return;
2049
+ if (count === 1) this._scopedRenderRootCount.delete(unitId);
2050
+ else this._scopedRenderRootCount.set(unitId, count - 1);
2051
+ this._notice();
2052
+ });
2053
+ }
2061
2054
  removeFloatDom(id) {
2062
2055
  if (this._domLayerMap.delete(id)) this._notice();
2063
2056
  }
@@ -2067,6 +2060,7 @@ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
2067
2060
  }
2068
2061
  dispose() {
2069
2062
  this._domLayerMap.clear();
2063
+ this._scopedRenderRootCount.clear();
2070
2064
  this._domLayers$.next([]);
2071
2065
  this._domLayers$.complete();
2072
2066
  super.dispose();
@@ -2113,9 +2107,8 @@ var CanvasFloatDomPreviewService = class extends _univerjs_core.Disposable {
2113
2107
  const LEGACY_WRAPPER_INSET = 2;
2114
2108
  const LEGACY_CONTENT_INSET = 4;
2115
2109
  function resolveFloatDomLayout(position, contentBox) {
2116
- var _contentBox$wrapperIn, _contentBox$contentIn, _position$opacity;
2117
- const wrapperInset = (_contentBox$wrapperIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.wrapperInset) !== null && _contentBox$wrapperIn !== void 0 ? _contentBox$wrapperIn : LEGACY_WRAPPER_INSET;
2118
- const contentInset = (_contentBox$contentIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) !== null && _contentBox$contentIn !== void 0 ? _contentBox$contentIn : LEGACY_CONTENT_INSET;
2110
+ const wrapperInset = (contentBox === null || contentBox === void 0 ? void 0 : contentBox.wrapperInset) ?? LEGACY_WRAPPER_INSET;
2111
+ const contentInset = (contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) ?? LEGACY_CONTENT_INSET;
2119
2112
  return {
2120
2113
  wrapper: {
2121
2114
  top: position.startY,
@@ -2123,7 +2116,7 @@ function resolveFloatDomLayout(position, contentBox) {
2123
2116
  width: Math.max(position.endX - position.startX - wrapperInset, 0),
2124
2117
  height: Math.max(position.endY - position.startY - wrapperInset, 0),
2125
2118
  transform: `rotate(${position.rotate}deg)`,
2126
- opacity: (_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1
2119
+ opacity: position.opacity ?? 1
2127
2120
  },
2128
2121
  inner: {
2129
2122
  width: position.width - contentInset,
@@ -2252,17 +2245,20 @@ function FloatDomSingleContent(props) {
2252
2245
  });
2253
2246
  }
2254
2247
  const FloatDom = ({ unitId }) => {
2255
- var _layers$filter;
2256
2248
  const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
2257
- const layers = (0, _wendellhu_redi_react_bindings.useObservable)((0, _wendellhu_redi_react_bindings.useDependency)(CanvasFloatDomService).domLayers$);
2249
+ const domLayerService = (0, _wendellhu_redi_react_bindings.useDependency)(CanvasFloatDomService);
2250
+ const layers = (0, _wendellhu_redi_react_bindings.useObservable)(domLayerService.domLayers$);
2258
2251
  const currentUnitId = resolveFloatDomCurrentUnitId(unitId, (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$));
2259
- return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => shouldRenderFloatDomLayer(layer[1], currentUnitId))) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
2260
- var _layer$1$domId;
2261
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingle, {
2262
- id: (_layer$1$domId = layer[1].domId) !== null && _layer$1$domId !== void 0 ? _layer$1$domId : layer[0],
2263
- layer: layer[1]
2264
- }, layer[0]);
2265
- });
2252
+ (0, react.useEffect)(() => {
2253
+ if (typeof unitId !== "string") return;
2254
+ const disposable = domLayerService.registerScopedRenderRoot(unitId);
2255
+ return () => disposable.dispose();
2256
+ }, [domLayerService, unitId]);
2257
+ const visibleLayers = typeof unitId === "string" ? layers === null || layers === void 0 ? void 0 : layers.filter((layer) => layer[1].unitId === unitId) : layers === null || layers === void 0 ? void 0 : layers.filter((layer) => !domLayerService.hasScopedRenderRoot(layer[1].unitId) && shouldRenderFloatDomLayer(layer[1], currentUnitId));
2258
+ return visibleLayers === null || visibleLayers === void 0 ? void 0 : visibleLayers.map((layer) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingle, {
2259
+ id: layer[1].domId ?? layer[0],
2260
+ layer: layer[1]
2261
+ }, layer[0]));
2266
2262
  };
2267
2263
  function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
2268
2264
  if (typeof unitId === "string") return unitId;
@@ -2274,9 +2270,8 @@ function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
2274
2270
  return null;
2275
2271
  }
2276
2272
  function resolveFloatDomOverflow(props) {
2277
- var _viewport$bleedWidth;
2278
2273
  const viewport = props.customBlockRenderViewport;
2279
- if (!(Number.isFinite(viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) && ((_viewport$bleedWidth = viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) !== null && _viewport$bleedWidth !== void 0 ? _viewport$bleedWidth : 0) > 0)) return {
2274
+ if (!(Number.isFinite(viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) && ((viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) ?? 0) > 0)) return {
2280
2275
  outerOverflow: "hidden",
2281
2276
  innerOverflow: "hidden"
2282
2277
  };
@@ -2400,11 +2395,10 @@ function calcPopupPosition(layout) {
2400
2395
  };
2401
2396
  }
2402
2397
  function RectPopup(props) {
2403
- var _uiConfig$popupRootId;
2404
2398
  const { mask, portal, children, anchorRect$, direction = "vertical", onClickOutside, excludeOutside, excludeRects, onPointerEnter, onPointerLeave, onClick, hidden, onContextMenu, zIndex = 1020, maskZIndex = 100, onMaskClick, noPushMinimumGap, autoRelayout = true } = props;
2405
2399
  const nodeRef = (0, react.useRef)(null);
2406
- const clickOtherFn = useEvent(onClickOutside !== null && onClickOutside !== void 0 ? onClickOutside : (() => {}));
2407
- const contextMenuFn = useEvent(onContextMenu !== null && onContextMenu !== void 0 ? onContextMenu : (() => {}));
2400
+ const clickOtherFn = useEvent(onClickOutside ?? (() => {}));
2401
+ const contextMenuFn = useEvent(onContextMenu ?? (() => {}));
2408
2402
  const positionRef = (0, react.useRef)({
2409
2403
  top: -9999,
2410
2404
  left: -9999
@@ -2413,7 +2407,7 @@ function RectPopup(props) {
2413
2407
  const configService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfigService);
2414
2408
  const anchorRectRef = (0, react.useRef)(void 0);
2415
2409
  const uiConfig = configService.getConfig(UI_PLUGIN_CONFIG_KEY);
2416
- const popupRootId = (_uiConfig$popupRootId = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) !== null && _uiConfig$popupRootId !== void 0 ? _uiConfig$popupRootId : "univer-popup-portal";
2410
+ const popupRootId = (uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) ?? "univer-popup-portal";
2417
2411
  const updatePosition = useEvent((position) => {
2418
2412
  requestAnimationFrame(() => {
2419
2413
  if (!nodeRef.current) return;
@@ -2456,11 +2450,10 @@ function RectPopup(props) {
2456
2450
  }, [anchorRect$, direction]);
2457
2451
  (0, react.useEffect)(() => {
2458
2452
  const handleClickOther = (e) => {
2459
- var _excludeRectsRef$curr;
2460
2453
  if (excludeOutside && (excludeOutside.indexOf(e.target) > -1 || excludeOutside.some((item) => item.contains(e.target)))) return;
2461
2454
  const x = e.clientX;
2462
2455
  const y = e.clientY;
2463
- const rects = [...(_excludeRectsRef$curr = excludeRectsRef === null || excludeRectsRef === void 0 ? void 0 : excludeRectsRef.current) !== null && _excludeRectsRef$curr !== void 0 ? _excludeRectsRef$curr : []];
2456
+ const rects = [...(excludeRectsRef === null || excludeRectsRef === void 0 ? void 0 : excludeRectsRef.current) ?? []];
2464
2457
  if (anchorRectRef.current) rects.push(anchorRectRef.current);
2465
2458
  for (const rect of rects) if (x <= rect.right && x >= rect.left && y <= rect.bottom && y >= rect.top) return;
2466
2459
  clickOtherFn(e);
@@ -2520,9 +2513,8 @@ RectPopup.useContext = () => (0, react.useContext)(RectPopupContext);
2520
2513
  //#region src/views/components/popup/CanvasPopup.tsx
2521
2514
  const SingleCanvasPopup = ({ popup, children }) => {
2522
2515
  const anchorRect$ = (0, react.useMemo)(() => popup.anchorRect$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler), (0, rxjs.map)((anchorRect) => {
2523
- var _popup$offset;
2524
2516
  const { bottom, left, right, top } = anchorRect;
2525
- const [x = 0, y = 0] = (_popup$offset = popup.offset) !== null && _popup$offset !== void 0 ? _popup$offset : [];
2517
+ const [x = 0, y = 0] = popup.offset ?? [];
2526
2518
  return {
2527
2519
  left: left - x,
2528
2520
  right: right + x,
@@ -2531,8 +2523,8 @@ const SingleCanvasPopup = ({ popup, children }) => {
2531
2523
  };
2532
2524
  })), [popup.anchorRect$, popup.offset]);
2533
2525
  const hiddenRects$ = (0, react.useMemo)(() => {
2534
- var _popup$hiddenRects$$p, _popup$hiddenRects$;
2535
- return (_popup$hiddenRects$$p = (_popup$hiddenRects$ = popup.hiddenRects$) === null || _popup$hiddenRects$ === void 0 ? void 0 : _popup$hiddenRects$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler))) !== null && _popup$hiddenRects$$p !== void 0 ? _popup$hiddenRects$$p : (0, rxjs.of)([]);
2526
+ var _popup$hiddenRects$;
2527
+ return ((_popup$hiddenRects$ = popup.hiddenRects$) === null || _popup$hiddenRects$ === void 0 ? void 0 : _popup$hiddenRects$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler))) ?? (0, rxjs.of)([]);
2536
2528
  }, [popup.hiddenRects$]);
2537
2529
  const excludeRectsRef = useObservableRef((0, react.useMemo)(() => {
2538
2530
  var _popup$excludeRects$;
@@ -2624,11 +2616,10 @@ var RibbonOverrideService = class extends _univerjs_core.Disposable {
2624
2616
  //#region src/views/components/ComponentContainer.tsx
2625
2617
  function ComponentContainer(props) {
2626
2618
  const { components, fallback, sharedProps } = props;
2627
- if (!components || components.size === 0) return fallback !== null && fallback !== void 0 ? fallback : null;
2619
+ if (!components || components.size === 0) return fallback ?? null;
2628
2620
  return Array.from(components.values()).map((component, index) => {
2629
- var _component$displayNam;
2630
2621
  return (0, react.createElement)(component, {
2631
- key: `${(_component$displayNam = component.displayName) !== null && _component$displayNam !== void 0 ? _component$displayNam : index}`,
2622
+ key: `${component.displayName ?? index}`,
2632
2623
  ...sharedProps
2633
2624
  });
2634
2625
  });
@@ -2641,9 +2632,8 @@ function ComponentContainer(props) {
2641
2632
  * component.
2642
2633
  */
2643
2634
  function useComponentsOfPart(part, injector) {
2644
- var _injector$get;
2645
2635
  const injectedUIPartsService = (0, _wendellhu_redi_react_bindings.useDependency)(IUIPartsService);
2646
- const uiPartsService = (_injector$get = injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) !== null && _injector$get !== void 0 ? _injector$get : injectedUIPartsService;
2636
+ const uiPartsService = (injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) ?? injectedUIPartsService;
2647
2637
  const changeInfo = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => uiPartsService.uiVisibleChange$.pipe((0, rxjs.filter)((ui) => ui.ui === part)), [part, uiPartsService]));
2648
2638
  const updateCounterRef = (0, react.useRef)(0);
2649
2639
  return (0, react.useMemo)(() => uiPartsService.isUIVisible(part) ? uiPartsService.getComponents(part) : /* @__PURE__ */ new Set(), [(0, _wendellhu_redi_react_bindings.useObservable)(() => uiPartsService.componentRegistered$.pipe((0, rxjs.filter)((key) => key === part), (0, rxjs.debounceTime)(200), (0, rxjs.map)(() => updateCounterRef.current += 1), (0, rxjs.startWith)(updateCounterRef.current += 1)), void 0, void 0, [
@@ -2701,8 +2691,7 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
2701
2691
  overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2702
2692
  className: "univer-grid univer-gap-1 univer-px-2 univer-py-1",
2703
2693
  children: ribbon.map((group) => {
2704
- var _iconMap;
2705
- const Icon = (_iconMap = iconMap[group.key]) !== null && _iconMap !== void 0 ? _iconMap : _univerjs_icons.MoreVerticalIcon;
2694
+ const Icon = iconMap[group.key] ?? _univerjs_icons.MoreVerticalIcon;
2706
2695
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
2707
2696
  "data-u-comp": "ribbon-group-btn",
2708
2697
  className: "univer-box-border univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-lg univer-px-2 univer-py-1.5 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
@@ -2766,14 +2755,13 @@ function placeRibbonGridItems(items) {
2766
2755
  const placements = /* @__PURE__ */ new Map();
2767
2756
  const fallbackItems = [];
2768
2757
  for (const item of items) {
2769
- var _layout$rowSpan, _layout$columnSpan, _layout$showLabel;
2770
2758
  const layout = item.gridLayout;
2771
2759
  if (!layout) {
2772
2760
  fallbackItems.push({ item });
2773
2761
  continue;
2774
2762
  }
2775
- const rowSpan = (_layout$rowSpan = layout.rowSpan) !== null && _layout$rowSpan !== void 0 ? _layout$rowSpan : 1;
2776
- const columnSpan = (_layout$columnSpan = layout.columnSpan) !== null && _layout$columnSpan !== void 0 ? _layout$columnSpan : 1;
2763
+ const rowSpan = layout.rowSpan ?? 1;
2764
+ const columnSpan = layout.columnSpan ?? 1;
2777
2765
  const cells = getCells(layout.row, layout.column, rowSpan, columnSpan);
2778
2766
  if (!isValidGridGeometry(layout, rowSpan, cells)) {
2779
2767
  fallbackItems.push({ item });
@@ -2785,7 +2773,7 @@ function placeRibbonGridItems(items) {
2785
2773
  column: layout.column,
2786
2774
  rowSpan,
2787
2775
  columnSpan,
2788
- showLabel: (_layout$showLabel = layout.showLabel) !== null && _layout$showLabel !== void 0 ? _layout$showLabel : false,
2776
+ showLabel: layout.showLabel ?? false,
2789
2777
  width: layout.width,
2790
2778
  iconSize: layout.iconSize
2791
2779
  };
@@ -2800,9 +2788,8 @@ function placeRibbonGridItems(items) {
2800
2788
  placements.set(item, placement);
2801
2789
  }
2802
2790
  for (const { item, layout } of fallbackItems) {
2803
- var _layout$rowSpan2, _layout$columnSpan2, _layout$showLabel2;
2804
- const rowSpan = (_layout$rowSpan2 = layout === null || layout === void 0 ? void 0 : layout.rowSpan) !== null && _layout$rowSpan2 !== void 0 ? _layout$rowSpan2 : 1;
2805
- const columnSpan = (_layout$columnSpan2 = layout === null || layout === void 0 ? void 0 : layout.columnSpan) !== null && _layout$columnSpan2 !== void 0 ? _layout$columnSpan2 : 1;
2791
+ const rowSpan = (layout === null || layout === void 0 ? void 0 : layout.rowSpan) ?? 1;
2792
+ const columnSpan = (layout === null || layout === void 0 ? void 0 : layout.columnSpan) ?? 1;
2806
2793
  const { row, column, cells } = findFirstAvailableCells(occupied, rowSpan, columnSpan);
2807
2794
  cells.forEach((cell) => occupied.add(cell));
2808
2795
  placements.set(item, {
@@ -2811,7 +2798,7 @@ function placeRibbonGridItems(items) {
2811
2798
  column,
2812
2799
  rowSpan,
2813
2800
  columnSpan,
2814
- showLabel: (_layout$showLabel2 = layout === null || layout === void 0 ? void 0 : layout.showLabel) !== null && _layout$showLabel2 !== void 0 ? _layout$showLabel2 : false,
2801
+ showLabel: (layout === null || layout === void 0 ? void 0 : layout.showLabel) ?? false,
2815
2802
  width: layout === null || layout === void 0 ? void 0 : layout.width,
2816
2803
  iconSize: layout === null || layout === void 0 ? void 0 : layout.iconSize
2817
2804
  });
@@ -2854,13 +2841,13 @@ function CustomLabel(props) {
2854
2841
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
2855
2842
  const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
2856
2843
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
2857
- const subscribedValue = (0, _wendellhu_redi_react_bindings.useObservable)(value$ !== null && value$ !== void 0 ? value$ : null, value);
2844
+ const subscribedValue = (0, _wendellhu_redi_react_bindings.useObservable)(value$ ?? null, value);
2858
2845
  const subscribedIcon = (0, _wendellhu_redi_react_bindings.useObservable)((0, rxjs.isObservable)(icon) ? icon : null, "");
2859
- const realIcon = (0, rxjs.isObservable)(icon) ? subscribedIcon : icon !== null && icon !== void 0 ? icon : "";
2846
+ const realIcon = (0, rxjs.isObservable)(icon) ? subscribedIcon : icon ?? "";
2860
2847
  const nodes = [];
2861
2848
  let index = 0;
2862
2849
  const realValue = (0, react.useMemo)(() => {
2863
- return value !== null && value !== void 0 ? value : subscribedValue;
2850
+ return value ?? subscribedValue;
2864
2851
  }, [subscribedValue, value]);
2865
2852
  const isValid = (0, react.useMemo)(() => {
2866
2853
  if (realValue && typeof realValue === "string") return new _univerjs_core.ColorKit(realValue).isValid;
@@ -2910,7 +2897,6 @@ function CustomLabel(props) {
2910
2897
  * @returns The menu item's status
2911
2898
  */
2912
2899
  function useToolbarItemStatus(menuItem) {
2913
- var _selectionsValue$2;
2914
2900
  const { disabled$, hidden$, activated$, value$ } = menuItem;
2915
2901
  let selectionsValue$;
2916
2902
  if (isMenuButtonSelectorItem(menuItem)) {
@@ -2920,23 +2906,20 @@ function useToolbarItemStatus(menuItem) {
2920
2906
  selectionsValue$ = selections === null || selections === void 0 || (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.value$;
2921
2907
  }
2922
2908
  }
2923
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$ !== null && disabled$ !== void 0 ? disabled$ : null, false);
2924
- const activated = (0, _wendellhu_redi_react_bindings.useObservable)(activated$ !== null && activated$ !== void 0 ? activated$ : null, false);
2925
- const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hidden$ !== null && hidden$ !== void 0 ? hidden$ : null, false);
2909
+ const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$ ?? null, false);
2910
+ const activated = (0, _wendellhu_redi_react_bindings.useObservable)(activated$ ?? null, false);
2911
+ const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hidden$ ?? null, false);
2926
2912
  return {
2927
2913
  disabled,
2928
- value: (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
2929
- var _selectionsValue$;
2930
- return (0, rxjs.merge)(value$ !== null && value$ !== void 0 ? value$ : rxjs.EMPTY, (_selectionsValue$ = selectionsValue$) !== null && _selectionsValue$ !== void 0 ? _selectionsValue$ : rxjs.EMPTY);
2931
- }, [selectionsValue$, value$])),
2914
+ value: (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => (0, rxjs.merge)(value$ ?? rxjs.EMPTY, selectionsValue$ ?? rxjs.EMPTY), [selectionsValue$, value$])),
2932
2915
  activated,
2933
2916
  hidden,
2934
- selectionsValue: (0, _wendellhu_redi_react_bindings.useObservable)((_selectionsValue$2 = selectionsValue$) !== null && _selectionsValue$2 !== void 0 ? _selectionsValue$2 : null)
2917
+ selectionsValue: (0, _wendellhu_redi_react_bindings.useObservable)(selectionsValue$ ?? null)
2935
2918
  };
2936
2919
  }
2937
2920
  function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
2938
2921
  const shortcutService = (0, _wendellhu_redi_react_bindings.useDependency)(IShortcutService);
2939
- const shortcutCommandId = commandId !== null && commandId !== void 0 ? commandId : id;
2922
+ const shortcutCommandId = commandId ?? id;
2940
2923
  return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => shortcut ? (0, rxjs.of)(shortcut) : shortcutService.shortcutChanged$.pipe((0, rxjs.map)(() => shortcutService.getShortcutDisplayOfCommand(shortcutCommandId)), (0, rxjs.startWith)(shortcutService.getShortcutDisplayOfCommand(shortcutCommandId))), [
2941
2924
  shortcut,
2942
2925
  shortcutService,
@@ -3144,8 +3127,8 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
3144
3127
  });
3145
3128
  }
3146
3129
  function getOptionKey(option) {
3147
- var _ref, _ref2, _option$id, _option$label2;
3148
- return String((_ref = (_ref2 = (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : option.commandId) !== null && _ref2 !== void 0 ? _ref2 : option.value) !== null && _ref !== void 0 ? _ref : typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name);
3130
+ var _option$label2;
3131
+ return String(option.id ?? option.commandId ?? option.value ?? (typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name));
3149
3132
  }
3150
3133
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
3151
3134
  const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
@@ -3157,11 +3140,11 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3157
3140
  const menuItems = (0, _wendellhu_redi_react_bindings.useObservable)(() => menuManagerService.menuChanged$.pipe((0, rxjs.map)(resolveMenuItems), (0, rxjs.startWith)(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
3158
3141
  const hiddenStates = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
3159
3142
  const itemStates = menuItems.map((item) => {
3160
- var _item$item$hidden$, _item$item;
3143
+ var _item$item;
3161
3144
  return (item.children ? (0, rxjs.combineLatest)(item.children.map((subItem) => {
3162
- var _subItem$item$hidden$, _subItem$item;
3163
- return (_subItem$item$hidden$ = (_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) !== null && _subItem$item$hidden$ !== void 0 ? _subItem$item$hidden$ : (0, rxjs.of)(false);
3164
- })).pipe((0, rxjs.map)((hiddenValues) => hiddenValues.every(Boolean))) : (_item$item$hidden$ = (_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) !== null && _item$item$hidden$ !== void 0 ? _item$item$hidden$ : (0, rxjs.of)(false)).pipe((0, rxjs.map)((hidden) => [String(item.key), hidden]));
3145
+ var _subItem$item;
3146
+ return ((_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) ?? (0, rxjs.of)(false);
3147
+ })).pipe((0, rxjs.map)((hiddenValues) => hiddenValues.every(Boolean))) : ((_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.map)((hidden) => [String(item.key), hidden]));
3165
3148
  });
3166
3149
  return itemStates.length ? (0, rxjs.merge)(...itemStates).pipe((0, rxjs.scan)((states, [key, hidden]) => ({
3167
3150
  ...states,
@@ -3196,15 +3179,15 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3196
3179
  children
3197
3180
  });
3198
3181
  if (options === null || options === void 0 ? void 0 : options.length) {
3199
- var _options$0$label;
3200
- const isSingleCustomPanel = options.length === 1 && typeof options[0].label === "object" && ((_options$0$label = options[0].label) === null || _options$0$label === void 0 ? void 0 : _options$0$label.hoverable) === false;
3182
+ var _options$0$label, _options$0$label$prop;
3183
+ const isSingleEmbeddedCustomPanel = filteredMenuItems.length === 0 && options.length === 1 && typeof options[0].label === "object" && ((_options$0$label = options[0].label) === null || _options$0$label === void 0 ? void 0 : _options$0$label.hoverable) === false && ((_options$0$label$prop = options[0].label.props) === null || _options$0$label$prop === void 0 ? void 0 : _options$0$label$prop.embedded) === true;
3201
3184
  const items = options.map((option) => {
3202
- var _option$label3, _option$label4;
3185
+ var _option$label3;
3203
3186
  return {
3204
3187
  type: "item",
3205
3188
  className: (0, _univerjs_design.clsx)({
3206
3189
  "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false,
3207
- "!univer-p-0": typeof option.label !== "string" && ((_option$label4 = option.label) === null || _option$label4 === void 0 ? void 0 : _option$label4.hoverable) === false
3190
+ "!univer-p-0": isSingleEmbeddedCustomPanel
3208
3191
  }),
3209
3192
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
3210
3193
  icon: option.icon,
@@ -3244,7 +3227,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3244
3227
  }
3245
3228
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
3246
3229
  align: "start",
3247
- className: (0, _univerjs_design.clsx)({ "!univer-p-0": isSingleCustomPanel }),
3230
+ className: (0, _univerjs_design.clsx)({ "!univer-p-0": isSingleEmbeddedCustomPanel }),
3248
3231
  items,
3249
3232
  disabled,
3250
3233
  open: dropdownVisible,
@@ -3383,7 +3366,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3383
3366
  commandService.executeCommand(commandId, params);
3384
3367
  };
3385
3368
  const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
3386
- const gridLabel = title !== null && title !== void 0 ? title : tooltip;
3369
+ const gridLabel = title ?? tooltip;
3387
3370
  const shortcutDisplay = useToolbarShortcutDisplay({
3388
3371
  id,
3389
3372
  commandId,
@@ -3401,8 +3384,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3401
3384
  const iconToDisplay = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
3402
3385
  if ((0, rxjs.isObservable)(icon)) return icon;
3403
3386
  else return new rxjs.Observable((subscribe) => {
3404
- var _options$find$icon, _options$find;
3405
- const v = (_options$find$icon = options === null || options === void 0 || (_options$find = options.find((o) => o.value === value)) === null || _options$find === void 0 ? void 0 : _options$find.icon) !== null && _options$find$icon !== void 0 ? _options$find$icon : icon;
3387
+ var _options$find;
3388
+ const v = (options === null || options === void 0 || (_options$find = options.find((o) => o.value === value)) === null || _options$find === void 0 ? void 0 : _options$find.icon) ?? icon;
3406
3389
  subscribe.next(v);
3407
3390
  });
3408
3391
  }, [
@@ -3411,17 +3394,16 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3411
3394
  value
3412
3395
  ]), void 0, true);
3413
3396
  function renderSelectorType(menuType) {
3414
- var _ref;
3415
3397
  const selectionsCommandId = props.selectionsCommandId;
3416
- const bId = commandId !== null && commandId !== void 0 ? commandId : id;
3417
- const sId = (_ref = selectionsCommandId !== null && selectionsCommandId !== void 0 ? selectionsCommandId : commandId) !== null && _ref !== void 0 ? _ref : id;
3398
+ const bId = commandId ?? id;
3399
+ const sId = selectionsCommandId ?? commandId ?? id;
3418
3400
  const titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
3419
3401
  function handleSelect(option) {
3420
3402
  if (disabled) return;
3421
3403
  let commandId = sId;
3422
3404
  if (option.id) commandId = option.id;
3423
3405
  const commandParams = typeof option.params === "function" ? option.params(option.value) : option.params;
3424
- executeCommand(commandId, commandParams !== null && commandParams !== void 0 ? commandParams : { value: option.value });
3406
+ executeCommand(commandId, commandParams ?? { value: option.value });
3425
3407
  }
3426
3408
  function handleSelectionsValueChange(value) {
3427
3409
  if (disabled) return;
@@ -3431,7 +3413,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3431
3413
  if (disabled) return;
3432
3414
  if (menuType === 2) {
3433
3415
  const commandParams = typeof params === "function" ? params() : params;
3434
- executeCommand(bId, commandParams !== null && commandParams !== void 0 ? commandParams : { value });
3416
+ executeCommand(bId, commandParams ?? { value });
3435
3417
  }
3436
3418
  }
3437
3419
  if (menuType === 2) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -3454,7 +3436,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3454
3436
  icon: iconToDisplay,
3455
3437
  iconSize,
3456
3438
  title: titleToDisplay,
3457
- value: iconColor !== null && iconColor !== void 0 ? iconColor : value,
3439
+ value: iconColor ?? value,
3458
3440
  label,
3459
3441
  onChange: handleSelectionsValueChange
3460
3442
  })
@@ -3522,8 +3504,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3522
3504
  });
3523
3505
  }
3524
3506
  function renderButtonType() {
3525
- var _label$name;
3526
- const isCustomComponent = componentManager.get(typeof label === "string" ? label : (_label$name = label === null || label === void 0 ? void 0 : label.name) !== null && _label$name !== void 0 ? _label$name : "");
3507
+ const isCustomComponent = componentManager.get(typeof label === "string" ? label : (label === null || label === void 0 ? void 0 : label.name) ?? "");
3527
3508
  const buttonClassName = (0, _univerjs_design.clsx)(grid && !large && "univer-h-full univer-min-w-8 [&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-8" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0");
3528
3509
  const buttonStyle = grid && large ? {
3529
3510
  textAlign: "center",
@@ -3553,9 +3534,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3553
3534
  active: activated,
3554
3535
  disabled,
3555
3536
  onClick: () => {
3556
- var _props$commandId;
3557
3537
  const commandParams = typeof params === "function" ? params() : params;
3558
- executeCommand((_props$commandId = props.commandId) !== null && _props$commandId !== void 0 ? _props$commandId : props.id, commandParams !== null && commandParams !== void 0 ? commandParams : typeof value === "undefined" ? void 0 : { value });
3538
+ executeCommand(props.commandId ?? props.id, commandParams ?? (typeof value === "undefined" ? void 0 : { value }));
3559
3539
  },
3560
3540
  onDoubleClick: () => props.subId && executeCommand(props.subId),
3561
3541
  children: icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
@@ -3595,14 +3575,13 @@ function RibbonGrid({ groups, title, className, ...props }) {
3595
3575
  role: "toolbar",
3596
3576
  "aria-label": localeService.t(title),
3597
3577
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownProvider, { children: groups.map((group) => {
3598
- var _group$children;
3599
3578
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3600
3579
  "data-u-comp": "ribbon-grid-group",
3601
3580
  className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
3602
3581
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3603
3582
  "data-testid": "ribbon-grid-group-grid",
3604
3583
  className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-2 univer-content-center univer-gap-x-1 univer-gap-y-2 univer-py-2 [&>div>span>span]:univer-h-full",
3605
- children: placeRibbonGridItems((_group$children = group.children) !== null && _group$children !== void 0 ? _group$children : []).map((placement) => placement.item.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3584
+ children: placeRibbonGridItems(group.children ?? []).map((placement) => placement.item.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3606
3585
  className: (0, _univerjs_design.clsx)("univer-flex univer-items-stretch [&>span>button]:univer-h-full [&>span]:univer-h-full", placement.width && "[&>span>span]:univer-w-full [&>span]:univer-w-full [&_[data-u-command]]:univer-w-full"),
3607
3586
  style: {
3608
3587
  gridRow: `${placement.row} / span ${placement.rowSpan}`,
@@ -3631,13 +3610,12 @@ function RibbonGrid({ groups, title, className, ...props }) {
3631
3610
  //#endregion
3632
3611
  //#region src/views/components/ribbon/Ribbon.tsx
3633
3612
  function Ribbon(props) {
3634
- var _ribbonOverride$ribbo;
3635
3613
  const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false, headerClassName } = props;
3636
3614
  const defaultRibbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
3637
3615
  const ribbonOverrideService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonOverrideService);
3638
3616
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3639
3617
  const ribbonOverride = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
3640
- const ribbonService = (_ribbonOverride$ribbo = ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) !== null && _ribbonOverride$ribbo !== void 0 ? _ribbonOverride$ribbo : defaultRibbonService;
3618
+ const ribbonService = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) ?? defaultRibbonService;
3641
3619
  const containerRef = (0, react.useRef)(null);
3642
3620
  const toolbarItemRefs = (0, react.useRef)({});
3643
3621
  const ribbonData = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.ribbon$, []);
@@ -3672,8 +3650,8 @@ function Ribbon(props) {
3672
3650
  ribbonService.setActivatedTab(group.key);
3673
3651
  }, [ribbonService]);
3674
3652
  const activeGroup = (0, react.useMemo)(() => {
3675
- var _ribbon$find$children, _ribbon$find2;
3676
- const allGroups = (_ribbon$find$children = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
3653
+ var _ribbon$find2;
3654
+ const allGroups = ((_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) ?? [];
3677
3655
  const visibleGroups = [];
3678
3656
  const hiddenGroups = [];
3679
3657
  for (const item of allGroups) if (item.children) {
@@ -3710,14 +3688,14 @@ function Ribbon(props) {
3710
3688
  for (const entry of entries) {
3711
3689
  ribbonService.setFakeToolbarVisible(true);
3712
3690
  timer = requestAnimationFrame(() => {
3713
- var _ribbon$find$children2, _ribbon$find3;
3691
+ var _ribbon$find3;
3714
3692
  const { width: avaliableWidth } = entry.contentRect;
3715
3693
  const sortedToolbarItems = Object.values(toolbarItemRefs.current).sort((a, b) => {
3716
3694
  return a.order - b.order || a.groupOrder - b.groupOrder || a.itemOrder - b.itemOrder;
3717
3695
  });
3718
3696
  const newCollapsedIds = [];
3719
3697
  let totalWidth = 32;
3720
- const gapWidth = (((_ribbon$find$children2 = (_ribbon$find3 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find3 === void 0 ? void 0 : _ribbon$find3.children) !== null && _ribbon$find$children2 !== void 0 ? _ribbon$find$children2 : []).length - 1) * 8;
3698
+ const gapWidth = ((((_ribbon$find3 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find3 === void 0 ? void 0 : _ribbon$find3.children) ?? []).length - 1) * 8;
3721
3699
  totalWidth += gapWidth;
3722
3700
  for (const { el, key } of sortedToolbarItems) {
3723
3701
  const { width } = el.getBoundingClientRect();
@@ -3865,7 +3843,6 @@ function Ribbon(props) {
3865
3843
  });
3866
3844
  }
3867
3845
  function RibbonOverrideRuntimeProvider(props) {
3868
- var _override$portalConta;
3869
3846
  const { override, children } = props;
3870
3847
  const config = (0, react.useContext)(_univerjs_design.ConfigContext);
3871
3848
  const injector = override === null || override === void 0 ? void 0 : override.injector;
@@ -3874,7 +3851,7 @@ function RibbonOverrideRuntimeProvider(props) {
3874
3851
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConnectedRibbonOverrideConfigProvider, {
3875
3852
  locale: config.locale,
3876
3853
  direction: config.direction,
3877
- mountContainer: (_override$portalConta = override.portalContainer) !== null && _override$portalConta !== void 0 ? _override$portalConta : config.mountContainer,
3854
+ mountContainer: override.portalContainer ?? config.mountContainer,
3878
3855
  children
3879
3856
  });
3880
3857
  }
@@ -3959,8 +3936,8 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
3959
3936
  _defineProperty(this, "disabled", false);
3960
3937
  }
3961
3938
  get visible() {
3962
- var _this$_currentHandler, _this$_currentHandler2;
3963
- return (_this$_currentHandler = (_this$_currentHandler2 = this._currentHandler) === null || _this$_currentHandler2 === void 0 ? void 0 : _this$_currentHandler2.visible) !== null && _this$_currentHandler !== void 0 ? _this$_currentHandler : false;
3939
+ var _this$_currentHandler;
3940
+ return ((_this$_currentHandler = this._currentHandler) === null || _this$_currentHandler === void 0 ? void 0 : _this$_currentHandler.visible) ?? false;
3964
3941
  }
3965
3942
  disable() {
3966
3943
  this.disabled = true;
@@ -3969,14 +3946,14 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
3969
3946
  this.disabled = false;
3970
3947
  }
3971
3948
  triggerContextMenu(event, menuType, context) {
3972
- var _this$_currentHandler3;
3949
+ var _this$_currentHandler2;
3973
3950
  event.stopPropagation();
3974
3951
  if (this.disabled) return;
3975
- (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType, context);
3952
+ (_this$_currentHandler2 = this._currentHandler) === null || _this$_currentHandler2 === void 0 || _this$_currentHandler2.handleContextMenu(event, menuType, context);
3976
3953
  }
3977
3954
  hideContextMenu() {
3978
- var _this$_currentHandler4;
3979
- (_this$_currentHandler4 = this._currentHandler) === null || _this$_currentHandler4 === void 0 || _this$_currentHandler4.hideContextMenu();
3955
+ var _this$_currentHandler3;
3956
+ (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.hideContextMenu();
3980
3957
  }
3981
3958
  registerContextMenuHandler(handler) {
3982
3959
  if (this._currentHandler) throw new Error("There is already a context menu handler!");
@@ -4170,11 +4147,10 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
4170
4147
  }),
4171
4148
  style: gridTemplateColumns ? { gridTemplateColumns } : void 0,
4172
4149
  children: items.map((item) => {
4173
- var _item$tooltip;
4174
4150
  const showTooltip = !isParagraphTVariant && item.tooltip;
4175
4151
  const ele = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4176
4152
  type: "button",
4177
- "aria-label": (_item$tooltip = item.tooltip) !== null && _item$tooltip !== void 0 ? _item$tooltip : item.key,
4153
+ "aria-label": item.tooltip ?? item.key,
4178
4154
  title: showTooltip ? item.tooltip : void 0,
4179
4155
  className: tinyMenuButtonVariants({
4180
4156
  variant,
@@ -4224,8 +4200,8 @@ function resolveMenuItemActiveState(itemId, observableActive, activeItemIds) {
4224
4200
  return observableActive;
4225
4201
  }
4226
4202
  function getTinyMenuChildStateKey(child) {
4227
- var _child$item$id, _child$item;
4228
- return (_child$item$id = (_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.id) !== null && _child$item$id !== void 0 ? _child$item$id : child.key;
4203
+ var _child$item;
4204
+ return ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.id) ?? child.key;
4229
4205
  }
4230
4206
  function getVisibleTinyMenuChildren(children, hiddenItemKeys) {
4231
4207
  const hiddenSet = new Set(hiddenItemKeys);
@@ -4250,10 +4226,9 @@ function QuickTileMenuItem(props) {
4250
4226
  }),
4251
4227
  disabled,
4252
4228
  onClick: () => {
4253
- var _menuItem$id;
4254
4229
  if (disabled) return;
4255
4230
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
4256
- label: (_menuItem$id = menuItem.id) !== null && _menuItem$id !== void 0 ? _menuItem$id : menuSchema.key,
4231
+ label: menuItem.id ?? menuSchema.key,
4257
4232
  commandId: menuItem.commandId,
4258
4233
  id: menuItem.id,
4259
4234
  params: menuItem.params,
@@ -4271,25 +4246,21 @@ function QuickTileMenuItem(props) {
4271
4246
  });
4272
4247
  }
4273
4248
  function UITinyMenuGroup(props) {
4274
- var _item$children;
4275
4249
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, hoverSuppressed, columns, sizeVariant = "default", layoutVariant = "default", onOptionSelect } = props;
4276
4250
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
4277
4251
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
4278
- const children = (_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : EMPTY_TINY_MENU_CHILDREN;
4252
+ const children = item.children ?? EMPTY_TINY_MENU_CHILDREN;
4279
4253
  const activeItems$ = (0, react.useMemo)(() => children.length ? (0, rxjs.combineLatest)(children.map((child) => {
4280
- var _child$item$activated, _child$item2;
4281
- return ((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
4254
+ var _child$item2;
4255
+ return (((_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
4282
4256
  })).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
4283
4257
  const hiddenItems$ = (0, react.useMemo)(() => children.length ? (0, rxjs.combineLatest)(children.map((child) => {
4284
- var _child$item$hidden$, _child$item3;
4285
- return ((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
4258
+ var _child$item3;
4259
+ return (((_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
4286
4260
  })).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
4287
4261
  const activeItems = (0, _wendellhu_redi_react_bindings.useObservable)(activeItems$, []);
4288
4262
  const hiddenItems = (0, _wendellhu_redi_react_bindings.useObservable)(hiddenItems$, []);
4289
- const visibleChildren = (0, react.useMemo)(() => {
4290
- var _item$children2;
4291
- return getVisibleTinyMenuChildren((_item$children2 = item.children) !== null && _item$children2 !== void 0 ? _item$children2 : [], [...hiddenItems, ...hiddenItemIds]);
4292
- }, [
4263
+ const visibleChildren = (0, react.useMemo)(() => getVisibleTinyMenuChildren(item.children ?? [], [...hiddenItems, ...hiddenItemIds]), [
4293
4264
  hiddenItemIds,
4294
4265
  hiddenItems,
4295
4266
  item.children
@@ -4301,15 +4272,15 @@ function UITinyMenuGroup(props) {
4301
4272
  layoutVariant,
4302
4273
  hoverSuppressed,
4303
4274
  items: visibleChildren.map((child) => {
4304
- var _child$item4, _child$item12, _child$item13, _child$item$id3, _child$item14, _child$item15;
4275
+ var _child$item4, _child$item12, _child$item13, _child$item14, _child$item15;
4305
4276
  const Icon = ((_child$item4 = child.item) === null || _child$item4 === void 0 ? void 0 : _child$item4.icon) ? iconManager.get(child.item.icon) : void 0;
4306
4277
  if (!Icon) return null;
4307
4278
  return {
4308
4279
  key: child.key,
4309
4280
  onClick: () => {
4310
- var _child$item$id2, _child$item5, _child$item6, _child$item7, _child$item8, _child$item9, _child$item10, _child$item11;
4281
+ var _child$item5, _child$item6, _child$item7, _child$item8, _child$item9, _child$item10, _child$item11;
4311
4282
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
4312
- label: (_child$item$id2 = (_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.id) !== null && _child$item$id2 !== void 0 ? _child$item$id2 : child.key,
4283
+ label: ((_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.id) ?? child.key,
4313
4284
  commandId: (_child$item6 = child.item) === null || _child$item6 === void 0 ? void 0 : _child$item6.commandId,
4314
4285
  id: (_child$item7 = child.item) === null || _child$item7 === void 0 ? void 0 : _child$item7.id,
4315
4286
  params: (_child$item8 = child.item) === null || _child$item8 === void 0 ? void 0 : _child$item8.params,
@@ -4320,16 +4291,16 @@ function UITinyMenuGroup(props) {
4320
4291
  className: "",
4321
4292
  iconClassName: ((_child$item12 = child.item) === null || _child$item12 === void 0 ? void 0 : _child$item12.icon) === "TextTypeIcon" ? sizeVariant === "paragraph-t" ? "!univer-size-4" : "!univer-size-3.5" : void 0,
4322
4293
  Icon,
4323
- active: resolveMenuItemActiveState((_child$item13 = child.item) === null || _child$item13 === void 0 ? void 0 : _child$item13.id, activeItems.includes((_child$item$id3 = (_child$item14 = child.item) === null || _child$item14 === void 0 ? void 0 : _child$item14.id) !== null && _child$item$id3 !== void 0 ? _child$item$id3 : ""), activeItemIds),
4294
+ active: resolveMenuItemActiveState((_child$item13 = child.item) === null || _child$item13 === void 0 ? void 0 : _child$item13.id, activeItems.includes(((_child$item14 = child.item) === null || _child$item14 === void 0 ? void 0 : _child$item14.id) ?? ""), activeItemIds),
4324
4295
  tooltip: ((_child$item15 = child.item) === null || _child$item15 === void 0 ? void 0 : _child$item15.tooltip) ? localeService.t(child.item.tooltip) : void 0
4325
4296
  };
4326
4297
  }).filter((child) => child != null)
4327
4298
  });
4328
4299
  }
4329
4300
  function UIQuickTileMenuGroup(props) {
4330
- var _item$children3;
4301
+ var _item$children;
4331
4302
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
4332
- if (!((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length)) return null;
4303
+ if (!((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length)) return null;
4333
4304
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4334
4305
  className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
4335
4306
  children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QuickTileMenuItem, {
@@ -4545,11 +4516,11 @@ function getContextMenuPanelClassName(sizeVariant) {
4545
4516
  function getContextMenuGroupClassName(sizeVariant) {
4546
4517
  return contextMenuGroupVariants({ sizeVariant });
4547
4518
  }
4548
- function isParagraphTHeaderQuickGroup(menuSchema, sizeVariant) {
4549
- return sizeVariant === "paragraph-t" && menuSchema.quickLayout === "icon" && CONTEXT_MENU_HEADER_QUICK_GROUP_KEYS.has(menuSchema.key);
4519
+ function isHeaderQuickGroup(menuSchema) {
4520
+ return menuSchema.quickLayout === "icon" && CONTEXT_MENU_HEADER_QUICK_GROUP_KEYS.has(menuSchema.key);
4550
4521
  }
4551
- function shouldClusterParagraphTHeaderQuickGroups(currentSchema, nextSchema, sizeVariant) {
4552
- return isParagraphTHeaderQuickGroup(currentSchema, sizeVariant) && !!nextSchema && isParagraphTHeaderQuickGroup(nextSchema, sizeVariant);
4522
+ function shouldClusterHeaderQuickGroups(currentSchema, nextSchema) {
4523
+ return isHeaderQuickGroup(currentSchema) && !!nextSchema && isHeaderQuickGroup(nextSchema);
4553
4524
  }
4554
4525
  function getContextMenuQuickGroupClassName(menuSchema, visibleSchemas, index, sizeVariant) {
4555
4526
  if (sizeVariant !== "paragraph-t" || !CONTEXT_MENU_HEADER_QUICK_GROUP_KEYS.has(menuSchema.key)) return getContextMenuGroupClassName(sizeVariant);
@@ -4602,7 +4573,7 @@ function getFirstMenuButtonByVisualOrder(buttons) {
4602
4573
  })[0];
4603
4574
  }
4604
4575
  function getNextMenuButtonByDirection(buttons, activeIndex, key) {
4605
- var _scoredCandidates$0$b, _scoredCandidates$;
4576
+ var _scoredCandidates$;
4606
4577
  const direction = key === "ArrowDown" || key === "ArrowRight" ? 1 : -1;
4607
4578
  const fallbackButton = buttons[activeIndex < 0 ? direction > 0 ? 0 : buttons.length - 1 : (activeIndex + direction + buttons.length) % buttons.length];
4608
4579
  const activeButton = activeIndex >= 0 ? buttons[activeIndex] : null;
@@ -4610,20 +4581,16 @@ function getNextMenuButtonByDirection(buttons, activeIndex, key) {
4610
4581
  const rows = getMenuButtonRows(buttons);
4611
4582
  const activeRowIndex = rows.findIndex((row) => row.includes(activeButton));
4612
4583
  const activeRow = rows[activeRowIndex];
4613
- if (activeRow && (key === "ArrowRight" || key === "ArrowLeft")) {
4614
- const nextRowButton = activeRow[activeRow.indexOf(activeButton) + (key === "ArrowRight" ? 1 : -1)];
4615
- return nextRowButton !== null && nextRowButton !== void 0 ? nextRowButton : fallbackButton;
4616
- }
4584
+ if (activeRow && (key === "ArrowRight" || key === "ArrowLeft")) return activeRow[activeRow.indexOf(activeButton) + (key === "ArrowRight" ? 1 : -1)] ?? fallbackButton;
4617
4585
  if (activeRow && (key === "ArrowDown" || key === "ArrowUp")) {
4618
4586
  const nextRow = rows[activeRowIndex + (key === "ArrowDown" ? 1 : -1)];
4619
4587
  if (nextRow) {
4620
- var _sort$;
4621
4588
  const activeCenter = getMenuButtonCenter(activeButton);
4622
- return (_sort$ = [...nextRow].sort((left, right) => Math.abs(getMenuButtonCenter(left).x - activeCenter.x) - Math.abs(getMenuButtonCenter(right).x - activeCenter.x))[0]) !== null && _sort$ !== void 0 ? _sort$ : fallbackButton;
4589
+ return [...nextRow].sort((left, right) => Math.abs(getMenuButtonCenter(left).x - activeCenter.x) - Math.abs(getMenuButtonCenter(right).x - activeCenter.x))[0] ?? fallbackButton;
4623
4590
  }
4624
4591
  }
4625
4592
  const activeCenter = getMenuButtonCenter(activeButton);
4626
- return (_scoredCandidates$0$b = (_scoredCandidates$ = buttons.filter((button) => button !== activeButton).map((button) => {
4593
+ return ((_scoredCandidates$ = buttons.filter((button) => button !== activeButton).map((button) => {
4627
4594
  const center = getMenuButtonCenter(button);
4628
4595
  const deltaX = center.x - activeCenter.x;
4629
4596
  const deltaY = center.y - activeCenter.y;
@@ -4634,14 +4601,14 @@ function getNextMenuButtonByDirection(buttons, activeIndex, key) {
4634
4601
  button,
4635
4602
  score: primaryDistance * 1e3 + secondaryDistance
4636
4603
  };
4637
- }).filter((candidate) => candidate != null).sort((left, right) => left.score - right.score)[0]) === null || _scoredCandidates$ === void 0 ? void 0 : _scoredCandidates$.button) !== null && _scoredCandidates$0$b !== void 0 ? _scoredCandidates$0$b : fallbackButton;
4604
+ }).filter((candidate) => candidate != null).sort((left, right) => left.score - right.score)[0]) === null || _scoredCandidates$ === void 0 ? void 0 : _scoredCandidates$.button) ?? fallbackButton;
4638
4605
  }
4639
- function getContextMenuSchemaRenderGroups(visibleSchemas, sizeVariant) {
4606
+ function getContextMenuSchemaRenderGroups(visibleSchemas, flowQuickGroups = false) {
4640
4607
  const renderGroups = [];
4641
4608
  for (let index = 0; index < visibleSchemas.length; index++) {
4642
4609
  const menuSchema = visibleSchemas[index];
4643
4610
  const nextSchema = visibleSchemas[index + 1];
4644
- if (shouldClusterParagraphTHeaderQuickGroups(menuSchema, nextSchema, sizeVariant)) {
4611
+ if (flowQuickGroups && shouldClusterHeaderQuickGroups(menuSchema, nextSchema)) {
4645
4612
  renderGroups.push({
4646
4613
  startIndex: index,
4647
4614
  endIndex: index + 1,
@@ -4658,6 +4625,15 @@ function getContextMenuSchemaRenderGroups(visibleSchemas, sizeVariant) {
4658
4625
  }
4659
4626
  return renderGroups;
4660
4627
  }
4628
+ function mergeContextMenuQuickGroupSchemas(menuSchemas) {
4629
+ const firstSchema = menuSchemas[0];
4630
+ return {
4631
+ ...firstSchema,
4632
+ key: menuSchemas.map((schema) => schema.key).join("-"),
4633
+ quickColumns: getContextMenuQuickGroupColumns(firstSchema),
4634
+ children: menuSchemas.flatMap((schema) => schema.children ?? [])
4635
+ };
4636
+ }
4661
4637
  function getContextMenuHeaderClassName(sizeVariant) {
4662
4638
  return contextMenuHeaderVariants({ sizeVariant });
4663
4639
  }
@@ -4668,12 +4644,12 @@ function getContextMenuSubmenuPanelClassName(sizeVariant) {
4668
4644
  return contextMenuSubmenuPanelVariants({ sizeVariant });
4669
4645
  }
4670
4646
  function ContextMenuPanel(props) {
4671
- var _layoutService$rootCo, _layoutService$rootCo2;
4672
- const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4647
+ var _layoutService$rootCo;
4648
+ const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, flowQuickGroups, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4673
4649
  const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
4674
4650
  const rootLayoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
4675
- const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
4676
- const layoutService = providedLayoutService !== null && providedLayoutService !== void 0 ? providedLayoutService : rootLayoutService;
4651
+ const menuManagerService = providedMenuManagerService ?? rootMenuManagerService;
4652
+ const layoutService = providedLayoutService ?? rootLayoutService;
4677
4653
  const [menuElement, setMenuElement] = (0, react.useState)(null);
4678
4654
  const [maxMenuHeight, setMaxMenuHeight] = (0, react.useState)(() => {
4679
4655
  if (typeof window === "undefined") return 240;
@@ -4686,23 +4662,21 @@ function ContextMenuPanel(props) {
4686
4662
  (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => menuManagerService.menuChanged$.pipe((0, rxjs.startWith)(void 0), (0, rxjs.scan)((version) => version + 1, 0)), [menuManagerService]), 0),
4687
4663
  menuSessionVersion
4688
4664
  ]);
4689
- const submenuPortalContainer = (_layoutService$rootCo = (_layoutService$rootCo2 = layoutService.rootContainerElement) === null || _layoutService$rootCo2 === void 0 || (_layoutService$rootCo2 = _layoutService$rootCo2.ownerDocument) === null || _layoutService$rootCo2 === void 0 ? void 0 : _layoutService$rootCo2.body) !== null && _layoutService$rootCo !== void 0 ? _layoutService$rootCo : typeof document !== "undefined" ? document.body : null;
4665
+ const submenuPortalContainer = ((_layoutService$rootCo = layoutService.rootContainerElement) === null || _layoutService$rootCo === void 0 || (_layoutService$rootCo = _layoutService$rootCo.ownerDocument) === null || _layoutService$rootCo === void 0 ? void 0 : _layoutService$rootCo.body) ?? (typeof document !== "undefined" ? document.body : null);
4690
4666
  useScrollYOverContainer(menuElement, layoutService.rootContainerElement);
4691
4667
  const getFocusableMenuButtons = (0, react.useCallback)(() => {
4692
4668
  if (!menuElement) return [];
4693
4669
  return Array.from(menuElement.querySelectorAll("button:not(:disabled)"));
4694
4670
  }, [menuElement]);
4695
4671
  (0, react.useEffect)(() => {
4696
- var _menuElement$ownerDoc;
4697
4672
  if (!autoFocus || !menuElement) return;
4698
- const view = (_menuElement$ownerDoc = menuElement.ownerDocument.defaultView) !== null && _menuElement$ownerDoc !== void 0 ? _menuElement$ownerDoc : window;
4673
+ const view = menuElement.ownerDocument.defaultView ?? window;
4699
4674
  const frameId = view.requestAnimationFrame(() => {
4700
4675
  if (autoFocusTarget === "container") {
4701
4676
  menuElement.focus();
4702
4677
  return;
4703
4678
  }
4704
- const firstButton = getFirstMenuButtonByVisualOrder(getFocusableMenuButtons());
4705
- (firstButton !== null && firstButton !== void 0 ? firstButton : menuElement).focus();
4679
+ (getFirstMenuButtonByVisualOrder(getFocusableMenuButtons()) ?? menuElement).focus();
4706
4680
  });
4707
4681
  return () => view.cancelAnimationFrame(frameId);
4708
4682
  }, [
@@ -4746,8 +4720,8 @@ function ContextMenuPanel(props) {
4746
4720
  onCancel
4747
4721
  ]);
4748
4722
  (0, react.useEffect)(() => {
4749
- var _layoutService$rootCo3, _layoutService$rootCo4;
4750
- const defaultView = (_layoutService$rootCo3 = (_layoutService$rootCo4 = layoutService.rootContainerElement) === null || _layoutService$rootCo4 === void 0 || (_layoutService$rootCo4 = _layoutService$rootCo4.ownerDocument) === null || _layoutService$rootCo4 === void 0 ? void 0 : _layoutService$rootCo4.defaultView) !== null && _layoutService$rootCo3 !== void 0 ? _layoutService$rootCo3 : typeof window !== "undefined" ? window : null;
4723
+ var _layoutService$rootCo2;
4724
+ const defaultView = ((_layoutService$rootCo2 = layoutService.rootContainerElement) === null || _layoutService$rootCo2 === void 0 || (_layoutService$rootCo2 = _layoutService$rootCo2.ownerDocument) === null || _layoutService$rootCo2 === void 0 ? void 0 : _layoutService$rootCo2.defaultView) ?? (typeof window !== "undefined" ? window : null);
4751
4725
  if (!defaultView) return;
4752
4726
  let frameId = 0;
4753
4727
  const updateMaxHeight = () => {
@@ -4782,6 +4756,7 @@ function ContextMenuPanel(props) {
4782
4756
  rootMenuElement: menuElement,
4783
4757
  activeItemIds,
4784
4758
  hiddenItemIds,
4759
+ flowQuickGroups,
4785
4760
  hoverSuppressed,
4786
4761
  sizeVariant,
4787
4762
  onMenuPointerEnter,
@@ -4792,7 +4767,7 @@ function ContextMenuPanel(props) {
4792
4767
  });
4793
4768
  }
4794
4769
  function ContextMenuMenu(props) {
4795
- const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
4770
+ const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, flowQuickGroups, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
4796
4771
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
4797
4772
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
4798
4773
  const [activeSubmenuKey, setActiveSubmenuKey] = (0, react.useState)(null);
@@ -4803,7 +4778,7 @@ function ContextMenuMenu(props) {
4803
4778
  return !hiddenGroupStates[item.key];
4804
4779
  });
4805
4780
  }, [hiddenGroupStates, menuSchemas]);
4806
- const renderGroups = (0, react.useMemo)(() => getContextMenuSchemaRenderGroups(visibleSchemas, sizeVariant), [sizeVariant, visibleSchemas]);
4781
+ const renderGroups = (0, react.useMemo)(() => getContextMenuSchemaRenderGroups(visibleSchemas, flowQuickGroups), [flowQuickGroups, visibleSchemas]);
4807
4782
  const renderQuickLayoutGroup = (menuSchema, index, renderAsClusterChild = false, hasSeparator = false) => {
4808
4783
  const titleNode = renderMenuSchemaHeader(menuSchema);
4809
4784
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -4831,10 +4806,13 @@ function ContextMenuMenu(props) {
4831
4806
  const menuSchema = groupedSchemas[0];
4832
4807
  const hasSeparator = shouldShowContextMenuGroupSeparator(visibleSchemas, endIndex);
4833
4808
  const titleNode = renderMenuSchemaHeader(menuSchema);
4834
- if (groupedSchemas.length > 1) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4835
- className: (0, _univerjs_design.clsx)(getContextMenuQuickGroupClusterClassName(sizeVariant), hasSeparator && _univerjs_design.borderBottomClassName),
4836
- children: groupedSchemas.map((groupedMenuSchema, groupedIndex) => renderQuickLayoutGroup(groupedMenuSchema, startIndex + groupedIndex, true))
4837
- }, groupedSchemas.map((schema) => schema.key).join("-"));
4809
+ if (groupedSchemas.length > 1) {
4810
+ const mergedMenuSchema = mergeContextMenuQuickGroupSchemas(groupedSchemas);
4811
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4812
+ className: (0, _univerjs_design.clsx)(getContextMenuQuickGroupClusterClassName(sizeVariant), hasSeparator && _univerjs_design.borderBottomClassName),
4813
+ children: renderQuickLayoutGroup(mergedMenuSchema, startIndex, true)
4814
+ }, groupedSchemas.map((schema) => schema.key).join("-"));
4815
+ }
4838
4816
  if (menuSchema.item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
4839
4817
  menuKey: menuSchema.key,
4840
4818
  menuItem: menuSchema.item,
@@ -5184,8 +5162,7 @@ function ContextMenuMenuItem(props) {
5184
5162
  children: [hasSelectionSubmenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5185
5163
  className: sizeVariant === "paragraph-t" ? "univer-grid univer-gap-2" : "univer-grid univer-gap-1",
5186
5164
  children: selections.map((option, index) => {
5187
- var _option$label;
5188
- const optionKey = `${menuItem.id}-${(_option$label = option.label) !== null && _option$label !== void 0 ? _option$label : option.id}-${index}`;
5165
+ const optionKey = `${menuItem.id}-${option.label ?? option.id}-${index}`;
5189
5166
  const optionSelected = typeof inputValue !== "undefined" && String(inputValue) === String(option.value);
5190
5167
  const optionSelectable = !isNonSelectableLabel(option.label);
5191
5168
  const optionHoverable = !isNonHoverableLabel(option.label);
@@ -5198,13 +5175,12 @@ function ContextMenuMenuItem(props) {
5198
5175
  label: option.label,
5199
5176
  icon: option.icon,
5200
5177
  onChange: (optionValue) => {
5201
- var _option$commandId;
5202
5178
  onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
5203
5179
  ...option,
5204
5180
  value: optionValue,
5205
5181
  id: menuItem.id,
5206
5182
  label: menuKey,
5207
- commandId: (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : selectionsCommandId
5183
+ commandId: option.commandId ?? selectionsCommandId
5208
5184
  });
5209
5185
  }
5210
5186
  })
@@ -5214,12 +5190,11 @@ function ContextMenuMenuItem(props) {
5214
5190
  className: optionClassName,
5215
5191
  disabled: option.disabled,
5216
5192
  onClick: () => {
5217
- var _option$commandId2;
5218
5193
  onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
5219
5194
  ...option,
5220
5195
  id: menuItem.id,
5221
5196
  label: menuKey,
5222
- commandId: (_option$commandId2 = option.commandId) !== null && _option$commandId2 !== void 0 ? _option$commandId2 : selectionsCommandId
5197
+ commandId: option.commandId ?? selectionsCommandId
5223
5198
  });
5224
5199
  },
5225
5200
  children: optionContentNode
@@ -5251,11 +5226,11 @@ function ContextMenuMenuItem(props) {
5251
5226
  function useContextGroupHiddenStates$1(menuSchemas) {
5252
5227
  return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
5253
5228
  const groupStates = menuSchemas.flatMap((menuSchema) => {
5254
- var _menuSchema$children$, _menuSchema$children3;
5255
- const hiddenObservables = (_menuSchema$children$ = (_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.map((childSchema) => {
5256
- var _childSchema$item$hid, _childSchema$item;
5257
- return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : (0, rxjs.of)(false);
5258
- })) !== null && _menuSchema$children$ !== void 0 ? _menuSchema$children$ : [];
5229
+ var _menuSchema$children3;
5230
+ const hiddenObservables = ((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.map((childSchema) => {
5231
+ var _childSchema$item;
5232
+ return ((_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) ?? (0, rxjs.of)(false);
5233
+ })) ?? [];
5259
5234
  return hiddenObservables.length ? [(0, rxjs.combineLatest)(hiddenObservables).pipe((0, rxjs.map)((values) => [menuSchema.key, values.every(Boolean)]))] : [];
5260
5235
  });
5261
5236
  return groupStates.length ? (0, rxjs.merge)(...groupStates).pipe((0, rxjs.scan)((states, [key, hidden]) => ({
@@ -5428,7 +5403,7 @@ function DesktopContextMenu() {
5428
5403
  const { label: id, commandId, value } = params;
5429
5404
  const rawParams = typeof params.params === "function" ? params.params() : params.params;
5430
5405
  const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
5431
- if (activeCommandService) activeCommandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
5406
+ if (activeCommandService) activeCommandService.executeCommand(commandId ?? id, commandParams);
5432
5407
  activeLayoutService.focus();
5433
5408
  handleClose();
5434
5409
  }
@@ -5592,7 +5567,7 @@ function Sidebar() {
5592
5567
  })]
5593
5568
  }),
5594
5569
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
5595
- className: "univer-box-border univer-cursor-default univer-px-4",
5570
+ className: "univer-box-border univer-min-w-0 univer-cursor-default univer-px-4",
5596
5571
  children: options === null || options === void 0 ? void 0 : options.children
5597
5572
  }),
5598
5573
  (options === null || options === void 0 ? void 0 : options.footer) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
@@ -5896,7 +5871,6 @@ function mountDesktopWorkbench(injector, options, mountContainer, onRendered) {
5896
5871
  }), mountContainer);
5897
5872
  }
5898
5873
  function DesktopWorkbenchContent(props) {
5899
- var _uiConfig$popupRootId;
5900
5874
  const { header = true, toolbar = true, footer = true, headerMenu = true, contextMenu = true, ribbonType = "classic", mountContainer, onRendered } = props;
5901
5875
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
5902
5876
  const lifecycleService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LifecycleService);
@@ -5916,7 +5890,7 @@ function DesktopWorkbenchContent(props) {
5916
5890
  const lifecycleStage = (0, _wendellhu_redi_react_bindings.useObservable)(lifecycleService.lifecycle$, lifecycleService.stage);
5917
5891
  const externalSkeletonVisible = (0, _wendellhu_redi_react_bindings.useObservable)(workbenchService.skeletonVisible$, void 0, true);
5918
5892
  const ready = lifecycleStage >= _univerjs_core.LifecycleStages.Ready;
5919
- const popupRootId = (_uiConfig$popupRootId = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) !== null && _uiConfig$popupRootId !== void 0 ? _uiConfig$popupRootId : "univer-popup-portal";
5893
+ const popupRootId = (uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) ?? "univer-popup-portal";
5920
5894
  (0, react.useLayoutEffect)(() => {
5921
5895
  const sub = themeService.currentTheme$.subscribe((theme) => {
5922
5896
  themeSwitcherService.injectThemeToHead(theme);
@@ -6171,7 +6145,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
6171
6145
  //#endregion
6172
6146
  //#region package.json
6173
6147
  var name = "@univerjs/ui";
6174
- var version = "1.0.0-alpha.8";
6148
+ var version = "1.0.0-beta.0";
6175
6149
 
6176
6150
  //#endregion
6177
6151
  //#region src/views/color-picker/interface.ts
@@ -6215,9 +6189,9 @@ const CommonLabel = (props) => {
6215
6189
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6216
6190
  className: "univer-truncate univer-text-sm",
6217
6191
  children: (0, react.useMemo)(() => {
6218
- var _selections$find$labe, _selections$find;
6192
+ var _selections$find;
6219
6193
  if (value == null) return "";
6220
- return localeService.t((_selections$find$labe = (_selections$find = selections.find((item) => item.value === value)) === null || _selections$find === void 0 ? void 0 : _selections$find.label) !== null && _selections$find$labe !== void 0 ? _selections$find$labe : "");
6194
+ return localeService.t(((_selections$find = selections.find((item) => item.value === value)) === null || _selections$find === void 0 ? void 0 : _selections$find.label) ?? "");
6221
6195
  }, [value, selections])
6222
6196
  });
6223
6197
  };
@@ -6253,10 +6227,9 @@ function ShortcutPanel() {
6253
6227
  const shortcuts = shortcutService.getAllShortcuts().filter((item) => !!item.group);
6254
6228
  const groupTitles = /* @__PURE__ */ new Map();
6255
6229
  for (const shortcut of shortcuts) {
6256
- var _shortcut$description;
6257
6230
  const group = shortcut.group;
6258
6231
  const shortcutItem = {
6259
- title: localeService.t((_shortcut$description = shortcut.description) !== null && _shortcut$description !== void 0 ? _shortcut$description : shortcut.id),
6232
+ title: localeService.t(shortcut.description ?? shortcut.id),
6260
6233
  shortcut: shortcutService.getShortcutDisplay(shortcut)
6261
6234
  };
6262
6235
  if (!/^\d+_/.test(group)) throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${group}!`);
@@ -21104,13 +21077,11 @@ function parseStoredRecentEmojis(value) {
21104
21077
  }
21105
21078
  }
21106
21079
  function getRandomEmoji(random = Math.random) {
21107
- var _allEmojis$Math$floor;
21108
21080
  const allEmojis = getAllEmojis();
21109
- return (_allEmojis$Math$floor = allEmojis[Math.floor(random() * allEmojis.length)]) !== null && _allEmojis$Math$floor !== void 0 ? _allEmojis$Math$floor : getDefaultRecentEmojis()[0];
21081
+ return allEmojis[Math.floor(random() * allEmojis.length)] ?? getDefaultRecentEmojis()[0];
21110
21082
  }
21111
21083
  function getLocalizedEmojiTitle(item, emojiTitles) {
21112
- var _emojiTitles$item$emo;
21113
- return (_emojiTitles$item$emo = emojiTitles === null || emojiTitles === void 0 ? void 0 : emojiTitles[item.emoji]) !== null && _emojiTitles$item$emo !== void 0 ? _emojiTitles$item$emo : item.title;
21084
+ return (emojiTitles === null || emojiTitles === void 0 ? void 0 : emojiTitles[item.emoji]) ?? item.title;
21114
21085
  }
21115
21086
  function getEmojiLocaleData(localeService) {
21116
21087
  const localePack = localeService.getLocales();
@@ -21133,37 +21104,54 @@ function normalizeStoredRecentEmojis(value) {
21133
21104
  const EMOJI_PICKER_COMPONENT = "ui.emoji-picker";
21134
21105
  const RECENTS_STORAGE_KEY = "univer.ui.recent-emojis";
21135
21106
  const ACTIVE_SECTION_SCROLL_OFFSET = 28;
21107
+ const EMOJI_COLUMN_COUNT = 10;
21108
+ const EMOJI_ROW_HEIGHT = 32;
21109
+ const EMOJI_SECTION_HEADER_HEIGHT = 24;
21110
+ const EMOJI_VIRTUAL_OVERSCAN = 3;
21136
21111
  function EmojiPicker(props) {
21137
- var _props$popup, _extraProps$recentSto;
21112
+ var _props$popup;
21138
21113
  const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
21139
21114
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21140
21115
  const localStorageService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ILocalStorageService);
21141
21116
  const currentLocale = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
21142
- const scrollRef = (0, react.useRef)(null);
21143
- const sectionRefs = (0, react.useRef)({});
21117
+ const scrollRef = (0, react.useRef)(void 0);
21118
+ const pendingSectionRef = (0, react.useRef)(null);
21144
21119
  const [query, setQuery] = (0, react.useState)("");
21145
21120
  const [activeEmoji, setActiveEmoji] = (0, react.useState)(extraProps === null || extraProps === void 0 ? void 0 : extraProps.activeEmoji);
21146
21121
  const [activeTab, setActiveTab] = (0, react.useState)("recent");
21147
21122
  const [recents, setRecents] = (0, react.useState)(() => getDefaultRecentEmojis());
21148
21123
  const deferredQuery = (0, react.useDeferredValue)(query);
21149
- const emojiLocaleData = (0, react.useMemo)(() => getEmojiLocaleData(localeService), [currentLocale, localeService]);
21124
+ const emojiLocaleData = getEmojiLocaleData(localeService);
21150
21125
  const searchResults = (0, react.useMemo)(() => searchEmojis(deferredQuery, emojiLocaleData.emojiSearchIndex), [deferredQuery, emojiLocaleData]);
21151
- const recentStorageKey = (_extraProps$recentSto = extraProps === null || extraProps === void 0 ? void 0 : extraProps.recentStorageKey) !== null && _extraProps$recentSto !== void 0 ? _extraProps$recentSto : RECENTS_STORAGE_KEY;
21126
+ const recentStorageKey = (extraProps === null || extraProps === void 0 ? void 0 : extraProps.recentStorageKey) ?? RECENTS_STORAGE_KEY;
21152
21127
  const isSearching = deferredQuery.trim().length > 0;
21153
- const normalSections = [{
21154
- key: "recent",
21155
- title: localeService.t("ui.emojiPicker.recents"),
21156
- emojis: recents
21157
- }, ...EMOJI_CATEGORIES.map((category) => ({
21158
- key: category.key,
21159
- title: localeService.t(category.titleKey),
21160
- emojis: emojis[category.key]
21161
- }))];
21162
- const renderedSections = (isSearching ? [{
21163
- key: "people",
21164
- title: localeService.t("ui.emojiPicker.searchResults"),
21165
- emojis: searchResults
21166
- }] : normalSections).filter((section) => section.emojis.length);
21128
+ const { rows, sectionPositions } = (0, react.useMemo)(() => {
21129
+ const normalSections = [{
21130
+ key: "recent",
21131
+ title: localeService.t("ui.emojiPicker.recents"),
21132
+ emojis: recents
21133
+ }, ...EMOJI_CATEGORIES.map((category) => ({
21134
+ key: category.key,
21135
+ title: localeService.t(category.titleKey),
21136
+ emojis: emojis[category.key]
21137
+ }))];
21138
+ return createEmojiVirtualRows(isSearching ? [{
21139
+ key: "people",
21140
+ title: localeService.t("ui.emojiPicker.searchResults"),
21141
+ emojis: searchResults
21142
+ }] : normalSections, currentLocale);
21143
+ }, [
21144
+ currentLocale,
21145
+ isSearching,
21146
+ localeService,
21147
+ recents,
21148
+ searchResults
21149
+ ]);
21150
+ const [virtualRows, { containerProps, scrollTo, wrapperStyle }] = useVirtualList(rows, {
21151
+ containerTarget: scrollRef,
21152
+ itemHeight: getEmojiVirtualRowHeight,
21153
+ overscan: EMOJI_VIRTUAL_OVERSCAN
21154
+ });
21167
21155
  (0, react.useEffect)(() => {
21168
21156
  let disposed = false;
21169
21157
  localStorageService.getItem(recentStorageKey).then((storedRecents) => {
@@ -21173,6 +21161,17 @@ function EmojiPicker(props) {
21173
21161
  disposed = true;
21174
21162
  };
21175
21163
  }, [localStorageService, recentStorageKey]);
21164
+ (0, react.useEffect)(() => {
21165
+ const pendingSection = pendingSectionRef.current;
21166
+ if (isSearching || !pendingSection) return;
21167
+ const position = sectionPositions.find((item) => item.key === pendingSection);
21168
+ if (position) scrollTo(position.rowIndex);
21169
+ pendingSectionRef.current = null;
21170
+ }, [
21171
+ isSearching,
21172
+ scrollTo,
21173
+ sectionPositions
21174
+ ]);
21176
21175
  const handleSelect = (item, options) => {
21177
21176
  var _props$onChange, _extraProps$onSelect;
21178
21177
  const nextRecents = promoteRecentEmoji(recents, item);
@@ -21186,16 +21185,19 @@ function EmojiPicker(props) {
21186
21185
  handleSelect(getRandomEmoji(), { keepOpen: true });
21187
21186
  };
21188
21187
  const handleScroll = (event) => {
21188
+ containerProps.onScroll(event);
21189
21189
  if (isSearching) return;
21190
- setActiveTab(getActiveSectionByScrollTop(normalSections, sectionRefs.current, event.currentTarget.scrollTop));
21190
+ setActiveTab(getActiveSectionByScrollTop(sectionPositions, event.currentTarget.scrollTop));
21191
21191
  };
21192
21192
  const scrollToSection = (section) => {
21193
21193
  setQuery("");
21194
21194
  setActiveTab(section);
21195
- requestAnimationFrame(() => {
21196
- const sectionElement = sectionRefs.current[section];
21197
- if (scrollRef.current && sectionElement) scrollRef.current.scrollTop = sectionElement.offsetTop;
21198
- });
21195
+ const position = sectionPositions.find((item) => item.key === section);
21196
+ if (!isSearching && position) {
21197
+ scrollTo(position.rowIndex);
21198
+ return;
21199
+ }
21200
+ pendingSectionRef.current = section;
21199
21201
  };
21200
21202
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
21201
21203
  "data-u-comp": EMOJI_PICKER_COMPONENT,
@@ -21223,17 +21225,19 @@ function EmojiPicker(props) {
21223
21225
  ref: scrollRef,
21224
21226
  className: (0, _univerjs_design.clsx)("univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3", _univerjs_design.scrollbarClassName),
21225
21227
  onScroll: handleScroll,
21226
- children: renderedSections.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21227
- className: "univer-flex univer-flex-col univer-gap-1.5 univer-pb-2",
21228
- children: renderedSections.map((section) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmojiSectionView, {
21228
+ children: rows.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21229
+ style: wrapperStyle,
21230
+ children: virtualRows.map(({ data: row }) => row.type === "header" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21231
+ style: { height: EMOJI_SECTION_HEADER_HEIGHT },
21232
+ className: "univer-flex univer-items-center univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
21233
+ children: row.title
21234
+ }, row.key) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmojiGrid, {
21229
21235
  activeEmoji,
21230
21236
  emojiTitles: emojiLocaleData.emojiTitles,
21231
- section,
21232
- onSelect: handleSelect,
21233
- refElement: (element) => {
21234
- sectionRefs.current[section.key] = element;
21235
- }
21236
- }, section.key))
21237
+ items: row.items,
21238
+ keyPrefix: row.key,
21239
+ onSelect: handleSelect
21240
+ }, row.key))
21237
21241
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21238
21242
  className: "univer-py-7 univer-text-center univer-text-sm univer-text-gray-400 dark:!univer-text-gray-500",
21239
21243
  children: localeService.t("ui.emojiPicker.noResults")
@@ -21243,12 +21247,12 @@ function EmojiPicker(props) {
21243
21247
  className: (0, _univerjs_design.clsx)("univer-flex univer-h-10 univer-shrink-0 univer-items-center univer-border-gray-200 univer-px-2.5 dark:!univer-border-gray-600 [&_svg]:univer-size-5", _univerjs_design.borderTopClassName),
21244
21248
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryButton, {
21245
21249
  selected: !isSearching && activeTab === "recent",
21246
- titleKey: "ui.emojiPicker.recents",
21250
+ title: localeService.t("ui.emojiPicker.recents"),
21247
21251
  onClick: () => scrollToSection("recent"),
21248
21252
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RecentIcon, {})
21249
21253
  }), EMOJI_CATEGORIES.map((category) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryButton, {
21250
21254
  selected: !isSearching && activeTab === category.key,
21251
- titleKey: category.titleKey,
21255
+ title: localeService.t(category.titleKey),
21252
21256
  onClick: () => scrollToSection(category.key),
21253
21257
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryIcon, { category: category.key })
21254
21258
  }, category.key))]
@@ -21256,25 +21260,10 @@ function EmojiPicker(props) {
21256
21260
  ]
21257
21261
  });
21258
21262
  }
21259
- function EmojiSectionView(props) {
21260
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
21261
- ref: props.refElement,
21262
- className: "univer-flex univer-flex-col univer-gap-1",
21263
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21264
- className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
21265
- children: props.section.title
21266
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmojiGrid, {
21267
- activeEmoji: props.activeEmoji,
21268
- emojiTitles: props.emojiTitles,
21269
- items: props.section.emojis,
21270
- keyPrefix: props.section.key,
21271
- onSelect: props.onSelect
21272
- })]
21273
- });
21274
- }
21275
21263
  function EmojiGrid(props) {
21276
21264
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21277
21265
  className: "univer-grid univer-grid-cols-10 univer-justify-between univer-gap-1",
21266
+ style: { height: EMOJI_ROW_HEIGHT },
21278
21267
  children: props.items.map((item) => {
21279
21268
  const title = getLocalizedEmojiTitle(item, props.emojiTitles);
21280
21269
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
@@ -21289,12 +21278,11 @@ function EmojiGrid(props) {
21289
21278
  });
21290
21279
  }
21291
21280
  function CategoryButton(props) {
21292
- const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21293
21281
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
21294
21282
  type: "button",
21295
- "aria-label": localeService.t(props.titleKey),
21283
+ "aria-label": props.title,
21296
21284
  "aria-selected": props.selected,
21297
- title: localeService.t(props.titleKey),
21285
+ title: props.title,
21298
21286
  className: (0, _univerjs_design.clsx)("univer-flex univer-h-[30px] univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 dark:!univer-text-gray-400", props.selected ? "univer-bg-primary-50 univer-text-primary-500 dark:!univer-bg-gray-800 dark:!univer-text-primary-400" : "hover:univer-bg-gray-50 hover:univer-text-gray-700 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-300"),
21299
21287
  onClick: props.onClick,
21300
21288
  children: props.children
@@ -21303,11 +21291,44 @@ function CategoryButton(props) {
21303
21291
  function writeRecents(localStorageService, storageKey, recents) {
21304
21292
  localStorageService.setItem(storageKey, recents).catch(() => void 0);
21305
21293
  }
21306
- function getActiveSectionByScrollTop(sections, sectionElements, scrollTop) {
21307
- let active = "recent";
21294
+ function createEmojiVirtualRows(sections, locale) {
21295
+ const rows = [];
21296
+ const sectionPositions = [];
21297
+ let top = 0;
21308
21298
  sections.forEach((section) => {
21309
- const element = sectionElements[section.key];
21310
- if (element && element.offsetTop <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) active = section.key;
21299
+ if (!section.emojis.length) return;
21300
+ sectionPositions.push({
21301
+ key: section.key,
21302
+ rowIndex: rows.length,
21303
+ top
21304
+ });
21305
+ rows.push({
21306
+ key: `${locale}-${section.key}-header`,
21307
+ title: section.title,
21308
+ type: "header"
21309
+ });
21310
+ top += EMOJI_SECTION_HEADER_HEIGHT;
21311
+ for (let start = 0; start < section.emojis.length; start += EMOJI_COLUMN_COUNT) {
21312
+ rows.push({
21313
+ items: section.emojis.slice(start, start + EMOJI_COLUMN_COUNT),
21314
+ key: `${locale}-${section.key}-${start / EMOJI_COLUMN_COUNT}`,
21315
+ type: "emojis"
21316
+ });
21317
+ top += EMOJI_ROW_HEIGHT;
21318
+ }
21319
+ });
21320
+ return {
21321
+ rows,
21322
+ sectionPositions
21323
+ };
21324
+ }
21325
+ function getEmojiVirtualRowHeight(_index, row) {
21326
+ return row.type === "header" ? EMOJI_SECTION_HEADER_HEIGHT : EMOJI_ROW_HEIGHT;
21327
+ }
21328
+ function getActiveSectionByScrollTop(sectionPositions, scrollTop) {
21329
+ let active = "recent";
21330
+ sectionPositions.forEach((position) => {
21331
+ if (position.top <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) active = position.key;
21311
21332
  });
21312
21333
  return active;
21313
21334
  }
@@ -21532,8 +21553,7 @@ let FontService = class FontService {
21532
21553
  constructor(_configService) {
21533
21554
  this._configService = _configService;
21534
21555
  _defineProperty(this, "fonts$", new rxjs.BehaviorSubject([]));
21535
- const config = this._configService.getConfig(UI_PLUGIN_CONFIG_KEY);
21536
- const { customFontFamily } = config !== null && config !== void 0 ? config : {};
21556
+ const { customFontFamily } = this._configService.getConfig("ui.config") ?? {};
21537
21557
  let fonts = [];
21538
21558
  if (customFontFamily) if (Array.isArray(customFontFamily)) fonts = [...DEFAULT_FONT_LIST, ...customFontFamily];
21539
21559
  else if (customFontFamily.override) fonts = [...customFontFamily.list];
@@ -21637,7 +21657,7 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
21637
21657
  fonts,
21638
21658
  localeService
21639
21659
  ]);
21640
- const inputValue = draftValue !== null && draftValue !== void 0 ? draftValue : viewValue;
21660
+ const inputValue = draftValue ?? viewValue;
21641
21661
  function resetValue() {
21642
21662
  setDraftValue(null);
21643
21663
  }
@@ -21765,8 +21785,8 @@ function FontFamilyDropdown(props) {
21765
21785
  const FontSize = (props) => {
21766
21786
  const { value, min, max, onChange, disabled$ } = props;
21767
21787
  const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
21768
- const [realValue, setRealValue] = (0, react.useState)(Number(value !== null && value !== void 0 ? value : 0));
21769
- const _value = (0, react.useMemo)(() => Number(value !== null && value !== void 0 ? value : realValue), [value]);
21788
+ const [realValue, setRealValue] = (0, react.useState)(Number(value ?? 0));
21789
+ const _value = (0, react.useMemo)(() => Number(value ?? realValue), [value]);
21770
21790
  function handleChange(value) {
21771
21791
  if (value === null) return;
21772
21792
  setRealValue(value);
@@ -21893,7 +21913,7 @@ const FONT_SIZE_COMPONENT = "UI_FONT_SIZE_COMPONENT";
21893
21913
  //#endregion
21894
21914
  //#region src/views/HeadingItem.tsx
21895
21915
  const HeadingItem = (props) => {
21896
- var _style$cl$rgb, _style$cl;
21916
+ var _style$cl;
21897
21917
  const { value, text } = props;
21898
21918
  const style = _univerjs_core.NAMED_STYLE_MAP[value];
21899
21919
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
@@ -21901,7 +21921,7 @@ const HeadingItem = (props) => {
21901
21921
  className: (0, _univerjs_design.clsx)("univer-text-sm", { "univer-font-bold": style === null || style === void 0 ? void 0 : style.bl }),
21902
21922
  style: {
21903
21923
  fontSize: style === null || style === void 0 ? void 0 : style.fs,
21904
- color: (_style$cl$rgb = style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) !== null && _style$cl$rgb !== void 0 ? _style$cl$rgb : void 0
21924
+ color: (style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? void 0
21905
21925
  },
21906
21926
  children: localeService.t(text)
21907
21927
  });
@@ -22007,7 +22027,6 @@ const DRAG_COMMIT_INTERVAL = 50;
22007
22027
  * Slider Component
22008
22028
  */
22009
22029
  function Slider(props) {
22010
- var _getSliderOffset;
22011
22030
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
22012
22031
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
22013
22032
  const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
@@ -22118,7 +22137,7 @@ function Slider(props) {
22118
22137
  window.addEventListener("pointerout", onPointerOut);
22119
22138
  }
22120
22139
  const visualValue = isDragging ? dragValue : value;
22121
- const sliderOffset = Math.min(Math.max((_getSliderOffset = getSliderOffset(visualValue)) !== null && _getSliderOffset !== void 0 ? _getSliderOffset : 0, 0), 100);
22140
+ const sliderOffset = Math.min(Math.max(getSliderOffset(visualValue) ?? 0, 0), 100);
22122
22141
  const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
22123
22142
  const ReduceIcon = iconManager.get("ReduceIcon");
22124
22143
  const IncreaseIcon = iconManager.get("IncreaseIcon");
@@ -22499,7 +22518,6 @@ FeatureSearchController = __decorate([__decorateParam(0, _univerjs_core.ICommand
22499
22518
  //#region src/views/components/ribbon/MobileRibbon.tsx
22500
22519
  const toolbarScrollOffset = 168;
22501
22520
  function MobileRibbon(props) {
22502
- var _activeGroup$children;
22503
22521
  const { headerMenuComponents, headerMenu = true } = props;
22504
22522
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
22505
22523
  const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
@@ -22510,7 +22528,7 @@ function MobileRibbon(props) {
22510
22528
  return index === -1 ? 0 : index;
22511
22529
  }, [activatedTab, ribbon]);
22512
22530
  const activeGroup = ribbon[activeIndex];
22513
- const activeGroups = (_activeGroup$children = activeGroup === null || activeGroup === void 0 ? void 0 : activeGroup.children) !== null && _activeGroup$children !== void 0 ? _activeGroup$children : [];
22531
+ const activeGroups = (activeGroup === null || activeGroup === void 0 ? void 0 : activeGroup.children) ?? [];
22514
22532
  const hasHeaderMenu = !!(headerMenu && headerMenuComponents && headerMenuComponents.size > 0);
22515
22533
  const toolbarScrollRef = (0, react.useRef)(null);
22516
22534
  const [canScrollLeft, setCanScrollLeft] = (0, react.useState)(false);
@@ -22631,8 +22649,8 @@ function MobileRibbon(props) {
22631
22649
  "data-u-comp": "mobile-ribbon-toolbar",
22632
22650
  className: "univer-flex univer-min-w-0 univer-items-center univer-gap-1.5 univer-overflow-x-auto univer-scroll-smooth univer-px-0.5 [&::-webkit-scrollbar]:univer-hidden",
22633
22651
  children: activeGroups.map((groupItem, groupIndex) => {
22634
- var _groupItem$children$f, _groupItem$children;
22635
- const groupItems = (_groupItem$children$f = (_groupItem$children = groupItem.children) === null || _groupItem$children === void 0 ? void 0 : _groupItem$children.filter((child) => !!child.item)) !== null && _groupItem$children$f !== void 0 ? _groupItem$children$f : [];
22652
+ var _groupItem$children;
22653
+ const groupItems = ((_groupItem$children = groupItem.children) === null || _groupItem$children === void 0 ? void 0 : _groupItem$children.filter((child) => !!child.item)) ?? [];
22636
22654
  if (!groupItems.length) return null;
22637
22655
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
22638
22656
  className: (0, _univerjs_design.clsx)("univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5 rtl:univer-pl-1.5 rtl:univer-pr-0", { [_univerjs_design.borderRightClassName]: groupIndex !== activeGroups.length - 1 }),
@@ -22663,11 +22681,10 @@ function MobileRibbon(props) {
22663
22681
  //#endregion
22664
22682
  //#region src/views/menu/mobile/MobileMenu.tsx
22665
22683
  function MobileMenu(props) {
22666
- var _viewStack;
22667
22684
  const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
22668
22685
  const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
22669
22686
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
22670
- const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
22687
+ const menuManagerService = providedMenuManagerService ?? rootMenuManagerService;
22671
22688
  const [viewStack, setViewStack] = (0, react.useState)([]);
22672
22689
  const menuSchemas = (0, react.useMemo)(() => {
22673
22690
  if (providedSchemas) return providedSchemas;
@@ -22684,7 +22701,7 @@ function MobileMenu(props) {
22684
22701
  (0, react.useEffect)(() => {
22685
22702
  setViewStack([]);
22686
22703
  }, [menuType, providedSchemas]);
22687
- const currentView = (_viewStack = viewStack[viewStack.length - 1]) !== null && _viewStack !== void 0 ? _viewStack : null;
22704
+ const currentView = viewStack[viewStack.length - 1] ?? null;
22688
22705
  if (!menuType && !providedSchemas) return null;
22689
22706
  const openView = (view) => setViewStack((stack) => [...stack, view]);
22690
22707
  const closeView = () => setViewStack((stack) => stack.slice(0, -1));
@@ -22812,24 +22829,20 @@ function MobileSchemaRow(props) {
22812
22829
  function MobileSelectionOptionsView(props) {
22813
22830
  const { options, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
22814
22831
  const inheritedDisabled = (0, _wendellhu_redi_react_bindings.useObservable)(inheritedDisabled$, false);
22815
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: options.map((option, index) => {
22816
- var _option$value;
22817
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSelectionOptionRow, {
22818
- option,
22819
- menuKey,
22820
- menuItem,
22821
- currentValue,
22822
- disabled: inheritedDisabled,
22823
- bordered: index !== options.length - 1,
22824
- onExecute
22825
- }, `${menuKey}-${String((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : index)}`);
22826
- }) });
22832
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSelectionOptionRow, {
22833
+ option,
22834
+ menuKey,
22835
+ menuItem,
22836
+ currentValue,
22837
+ disabled: inheritedDisabled,
22838
+ bordered: index !== options.length - 1,
22839
+ onExecute
22840
+ }, `${menuKey}-${String(option.value ?? index)}`)) });
22827
22841
  }
22828
22842
  function MobileSelectionOptionRow(props) {
22829
- var _option$value2;
22830
22843
  const { option, menuKey, menuItem, currentValue, disabled, bordered, onExecute } = props;
22831
22844
  const optionValue = (0, _wendellhu_redi_react_bindings.useObservable)(option.value$);
22832
- const displayValue = (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : optionValue;
22845
+ const displayValue = option.value ?? optionValue;
22833
22846
  const selected = displayValue === currentValue;
22834
22847
  const optionDisabled = disabled || Boolean(option.disabled);
22835
22848
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -22858,7 +22871,6 @@ function MobileSelectionOptionRow(props) {
22858
22871
  });
22859
22872
  }
22860
22873
  function useMobileSchemaInteraction(props) {
22861
- var _schema$children3;
22862
22874
  const { schema, menuManagerService, menuType, onOpenView, inheritedDisabled$ } = props;
22863
22875
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
22864
22876
  const menuItem = schema.item;
@@ -22885,7 +22897,7 @@ function useMobileSchemaInteraction(props) {
22885
22897
  return menuManagerService.getMenuByPositionKey(menuItem.id);
22886
22898
  }, [menuItem, menuManagerService]);
22887
22899
  if (!menuItem) return null;
22888
- const schemaChildren = (_schema$children3 = schema.children) !== null && _schema$children3 !== void 0 ? _schema$children3 : [];
22900
+ const schemaChildren = schema.children ?? [];
22889
22901
  const hasSubmenu = schemaChildren.length > 0 || selections.length > 0 || subMenuItems.length > 0;
22890
22902
  const currentValueText = typeof value === "string" || typeof value === "number" ? String(value) : "";
22891
22903
  const onPress = (onExecute) => {
@@ -22952,8 +22964,8 @@ function useContextGroupHiddenStates(menuSchemas) {
22952
22964
  const groupStates = menuSchemas.flatMap((menuSchema) => {
22953
22965
  var _menuSchema$children;
22954
22966
  const hiddenObservables = ((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length) ? getLeafItemSchemas(menuSchema.children).map((childSchema) => {
22955
- var _childSchema$item$hid, _childSchema$item;
22956
- return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : (0, rxjs.of)(false);
22967
+ var _childSchema$item;
22968
+ return ((_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) ?? (0, rxjs.of)(false);
22957
22969
  }) : [];
22958
22970
  return hiddenObservables.length ? [(0, rxjs.combineLatest)(hiddenObservables).pipe((0, rxjs.map)((values) => [menuSchema.key, values.every(Boolean)]))] : [];
22959
22971
  });
@@ -22965,8 +22977,8 @@ function useContextGroupHiddenStates(menuSchemas) {
22965
22977
  }
22966
22978
  function getLeafItemSchemas(schemas) {
22967
22979
  return schemas.reduce((acc, schema) => {
22968
- var _schema$children4;
22969
- if ((_schema$children4 = schema.children) === null || _schema$children4 === void 0 ? void 0 : _schema$children4.length) return [...acc, ...getLeafItemSchemas(schema.children)];
22980
+ var _schema$children3;
22981
+ if ((_schema$children3 = schema.children) === null || _schema$children3 === void 0 ? void 0 : _schema$children3.length) return [...acc, ...getLeafItemSchemas(schema.children)];
22970
22982
  if (schema.item) return [...acc, schema];
22971
22983
  return acc;
22972
22984
  }, []);
@@ -23034,8 +23046,7 @@ function MobileContextMenu() {
23034
23046
  menuType,
23035
23047
  menuManagerService: (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService,
23036
23048
  onOptionSelect: (params) => {
23037
- var _ref, _params$commandId;
23038
- const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
23049
+ const commandId = params.commandId ?? params.id ?? params.label;
23039
23050
  const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
23040
23051
  const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
23041
23052
  if (!commandId) return;
@@ -23488,7 +23499,7 @@ let BrowserClipboardService = class BrowserClipboardService extends _univerjs_co
23488
23499
  return await navigator.clipboard.write([new ClipboardItem({
23489
23500
  [PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
23490
23501
  [HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE }),
23491
- ...Object.fromEntries(Object.entries(customData !== null && customData !== void 0 ? customData : {}).map(([type, value]) => [type, new Blob([value], { type })]))
23502
+ ...Object.fromEntries(Object.entries(customData ?? {}).map(([type, value]) => [type, new Blob([value], { type })]))
23492
23503
  })]);
23493
23504
  } catch (error) {
23494
23505
  if (customData && Object.keys(customData).length) try {
@@ -23625,10 +23636,7 @@ function serializeSanitizedHtmlForClipboard(html) {
23625
23636
  return container.innerHTML;
23626
23637
  }
23627
23638
  function sanitizeHtmlNode(node) {
23628
- if (node.nodeType === Node.TEXT_NODE) {
23629
- var _node$textContent;
23630
- return document.createTextNode((_node$textContent = node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : "");
23631
- }
23639
+ if (node.nodeType === Node.TEXT_NODE) return document.createTextNode(node.textContent ?? "");
23632
23640
  if (node.nodeType !== Node.ELEMENT_NODE) return null;
23633
23641
  const sourceElement = node;
23634
23642
  const tagName = sourceElement.tagName.toLowerCase();
@@ -23957,11 +23965,10 @@ DesktopGalleryService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject
23957
23965
  var DesktopLocalFileService = class extends _univerjs_core.Disposable {
23958
23966
  openFile(options) {
23959
23967
  return new Promise((resolve) => {
23960
- var _options$accept, _options$multiple;
23961
23968
  const inputElement = document.createElement("input");
23962
23969
  inputElement.type = "file";
23963
- inputElement.accept = (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "";
23964
- inputElement.multiple = (_options$multiple = options === null || options === void 0 ? void 0 : options.multiple) !== null && _options$multiple !== void 0 ? _options$multiple : false;
23970
+ inputElement.accept = (options === null || options === void 0 ? void 0 : options.accept) ?? "";
23971
+ inputElement.multiple = (options === null || options === void 0 ? void 0 : options.multiple) ?? false;
23965
23972
  inputElement.onchange = (event) => {
23966
23973
  const fileList = event.target.files;
23967
23974
  if (fileList) resolve(Array.from(fileList));
@@ -24043,10 +24050,7 @@ var IndexedDBDriver = class {
24043
24050
  const store = await this._store("readonly");
24044
24051
  return new Promise((resolve, reject) => {
24045
24052
  const req = store.get(key);
24046
- req.onsuccess = () => {
24047
- var _req$result;
24048
- return resolve((_req$result = req.result) !== null && _req$result !== void 0 ? _req$result : null);
24049
- };
24053
+ req.onsuccess = () => resolve(req.result ?? null);
24050
24054
  req.onerror = () => reject(req.error);
24051
24055
  });
24052
24056
  }
@@ -24154,8 +24158,7 @@ var LocalStorageDriver = class {
24154
24158
  toRemove.forEach((k) => localStorage.removeItem(k));
24155
24159
  }
24156
24160
  async key(index) {
24157
- var _keys$index;
24158
- return (_keys$index = this._keys()[index]) !== null && _keys$index !== void 0 ? _keys$index : null;
24161
+ return this._keys()[index] ?? null;
24159
24162
  }
24160
24163
  async keys() {
24161
24164
  return this._keys();
@@ -24256,8 +24259,7 @@ let DesktopMessageService = class DesktopMessageService extends _univerjs_core.D
24256
24259
  (0, _univerjs_design.removeMessage)();
24257
24260
  }
24258
24261
  show(options) {
24259
- var _options$id;
24260
- const id = (_options$id = options.id) !== null && _options$id !== void 0 ? _options$id : `message-${Date.now()}-${messageId}`;
24262
+ const id = options.id ?? `message-${Date.now()}-${messageId}`;
24261
24263
  messageId += 1;
24262
24264
  (0, _univerjs_design.message)(Object.assign({}, options, { id }));
24263
24265
  return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_design.removeMessage)(id));
@@ -24685,8 +24687,7 @@ function handleDomToJson($dom) {
24685
24687
  let span = nodeList[`${i}`];
24686
24688
  let str;
24687
24689
  if (span.nodeName === "#text") {
24688
- var _span$textContent;
24689
- str = (_span$textContent = span.textContent) !== null && _span$textContent !== void 0 ? _span$textContent : "";
24690
+ str = span.textContent ?? "";
24690
24691
  span = span.parentElement;
24691
24692
  } else str = span.innerText;
24692
24693
  const textStyle = handleStringToStyle(span);
@@ -24718,8 +24719,8 @@ function handleDomToJson($dom) {
24718
24719
  * @returns
24719
24720
  */
24720
24721
  function handleStringToStyle($dom, cssStyle = "") {
24721
- var _$dom$style$cssText, _$dom$style;
24722
- let cssText = (_$dom$style$cssText = $dom === null || $dom === void 0 || (_$dom$style = $dom.style) === null || _$dom$style === void 0 ? void 0 : _$dom$style.cssText) !== null && _$dom$style$cssText !== void 0 ? _$dom$style$cssText : "";
24722
+ var _$dom$style;
24723
+ let cssText = ($dom === null || $dom === void 0 || (_$dom$style = $dom.style) === null || _$dom$style === void 0 ? void 0 : _$dom$style.cssText) ?? "";
24723
24724
  cssText += cssStyle;
24724
24725
  cssText = cssText.replace(/[\r\n]+/g, "");
24725
24726
  if (cssText.length === 0) return {};
@@ -25069,10 +25070,9 @@ function handelTableToJson(table) {
25069
25070
  while (c < colLen && data[r][c] != null) c++;
25070
25071
  if (c === colLen) return;
25071
25072
  if (data[r][c] == null) {
25072
- var _Number, _Number2;
25073
25073
  data[r][c] = cell;
25074
- const rowSpan = (_Number = Number(td.getAttribute("rowSpan"))) !== null && _Number !== void 0 ? _Number : 1;
25075
- const colSpan = (_Number2 = Number(td.getAttribute("colSpan"))) !== null && _Number2 !== void 0 ? _Number2 : 1;
25074
+ const rowSpan = Number(td.getAttribute("rowSpan")) ?? 1;
25075
+ const colSpan = Number(td.getAttribute("colSpan")) ?? 1;
25076
25076
  if (rowSpan > 1 || colSpan > 1) {
25077
25077
  const first = {
25078
25078
  rs: +rowSpan - 1,
@@ -25179,10 +25179,9 @@ function handelExcelToJson(html) {
25179
25179
  while (c < colLen && data[r][c] != null) c++;
25180
25180
  if (c === colLen) return;
25181
25181
  if (data[r][c] == null) {
25182
- var _Number3, _Number4;
25183
25182
  data[r][c] = cell;
25184
- const rowSpan = (_Number3 = Number(td.getAttribute("rowSpan"))) !== null && _Number3 !== void 0 ? _Number3 : 1;
25185
- const colSpan = (_Number4 = Number(td.getAttribute("colSpan"))) !== null && _Number4 !== void 0 ? _Number4 : 1;
25183
+ const rowSpan = Number(td.getAttribute("rowSpan")) ?? 1;
25184
+ const colSpan = Number(td.getAttribute("colSpan")) ?? 1;
25186
25185
  if (rowSpan > 1 || colSpan > 1) {
25187
25186
  const first = {
25188
25187
  rs: +rowSpan - 1,
@@ -25246,14 +25245,13 @@ function RegisteredPrintFloatDomSingle(props) {
25246
25245
  });
25247
25246
  }
25248
25247
  function PrintFloatDomSingleContent(props) {
25249
- var _position$startY, _position$startX;
25250
25248
  const { layer, id, position, Component } = props;
25251
25249
  const univerInstanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
25252
25250
  const domRef = (0, react.useRef)(null);
25253
25251
  const innerDomRef = (0, react.useRef)(null);
25254
25252
  const transformRef = (0, react.useRef)(`transform: rotate(${position === null || position === void 0 ? void 0 : position.rotate}deg) translate(${position === null || position === void 0 ? void 0 : position.startX}px, ${position === null || position === void 0 ? void 0 : position.startY}px)`);
25255
- const topRef = (0, react.useRef)((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
25256
- const leftRef = (0, react.useRef)((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
25253
+ const topRef = (0, react.useRef)((position === null || position === void 0 ? void 0 : position.startY) ?? 0);
25254
+ const leftRef = (0, react.useRef)((position === null || position === void 0 ? void 0 : position.startX) ?? 0);
25257
25255
  const layerProps = (0, react.useMemo)(() => ({
25258
25256
  data: layer.data,
25259
25257
  ...layer.props