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