@univerjs/ui 0.22.1 → 0.23.0-insiders.20260522-e8f2a3b

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/index.js CHANGED
@@ -2274,6 +2274,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2274
2274
  key,
2275
2275
  order: value.order,
2276
2276
  title: value.title,
2277
+ contextual: value.contextual,
2277
2278
  quickLayout: value.quickLayout
2278
2279
  };
2279
2280
  if (value.menuItemFactory) {
@@ -2905,6 +2906,7 @@ function RectPopup(props) {
2905
2906
  window.removeEventListener("contextmenu", handleContextMenu);
2906
2907
  };
2907
2908
  }, [contextMenuFn]);
2909
+ const dir = useObservable(useDependency(LocaleService).direction$);
2908
2910
  const ele = /* @__PURE__ */ jsxs(Fragment$1, { children: [mask && /* @__PURE__ */ jsx("div", {
2909
2911
  "data-u-comp": "rect-popup-mask",
2910
2912
  className: "univer-fixed univer-inset-0 univer-z-[100]",
@@ -2913,6 +2915,7 @@ function RectPopup(props) {
2913
2915
  }), /* @__PURE__ */ jsx("section", {
2914
2916
  "data-u-comp": "rect-popup",
2915
2917
  ref: nodeRef,
2918
+ dir,
2916
2919
  className: clsx("univer-pointer-events-auto univer-fixed univer-left-[-9999px] univer-top-[-9999px] univer-z-[1020]", {
2917
2920
  "univer-hidden": hidden,
2918
2921
  "univer-animate-in univer-fade-in-70": !hidden
@@ -3033,11 +3036,29 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3033
3036
  _defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
3034
3037
  _defineProperty(this, "_fakeToolbarVisible$", new BehaviorSubject(false));
3035
3038
  _defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
3039
+ _defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
3040
+ _defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
3041
+ _defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
3036
3042
  this._initRibbonSubscription();
3037
3043
  }
3038
3044
  setActivatedTab(tab) {
3045
+ if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
3039
3046
  this._activatedTab$.next(tab);
3040
3047
  }
3048
+ showContextualTab(tab, options) {
3049
+ this._visibleContextualTabs.add(tab);
3050
+ this._updateRibbon();
3051
+ if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
3052
+ }
3053
+ hideContextualTab(tab) {
3054
+ if (!this._visibleContextualTabs.delete(tab)) return;
3055
+ this._updateRibbon();
3056
+ }
3057
+ hideAllContextualTabs() {
3058
+ if (this._visibleContextualTabs.size === 0) return;
3059
+ this._visibleContextualTabs.clear();
3060
+ this._updateRibbon();
3061
+ }
3041
3062
  setCollapsedIds(ids) {
3042
3063
  this._collapsedIds$.next(ids);
3043
3064
  }
@@ -3050,7 +3071,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3050
3071
  }));
3051
3072
  }
3052
3073
  _updateRibbon() {
3053
- const ribbon = this._menuManagerService.getMenuByPositionKey("ribbon");
3074
+ const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
3054
3075
  const hiddenObservableMap = [];
3055
3076
  const hiddenKeyMap = [];
3056
3077
  for (const group of ribbon) if (group.children) {
@@ -3063,7 +3084,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3063
3084
  }
3064
3085
  }
3065
3086
  if (hiddenObservableMap.length === 0) {
3066
- this._ribbon$.next(ribbon);
3087
+ this._setRibbon(ribbon);
3067
3088
  return;
3068
3089
  }
3069
3090
  combineLatest(hiddenObservableMap).pipe(startWith$1(new Array(hiddenObservableMap.length).fill(false))).subscribe((hiddenMap) => {
@@ -3106,9 +3127,29 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3106
3127
  return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
3107
3128
  })) newRibbon.push(newGroup);
3108
3129
  }
3109
- this._ribbon$.next(newRibbon);
3130
+ this._setRibbon(newRibbon);
3110
3131
  }).unsubscribe();
3111
3132
  }
3133
+ _filterContextualTabs(ribbon) {
3134
+ this._contextualTabs.clear();
3135
+ ribbon.forEach((group) => {
3136
+ if (group.contextual) this._contextualTabs.add(group.key);
3137
+ });
3138
+ return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
3139
+ }
3140
+ _setRibbon(ribbon) {
3141
+ const activatedTab = this._activatedTab$.getValue();
3142
+ const activeGroup = ribbon.find((group) => group.key === activatedTab);
3143
+ if (!activeGroup && this._contextualTabs.has(activatedTab)) {
3144
+ var _ref, _ribbon$find;
3145
+ 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];
3146
+ if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
3147
+ } else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
3148
+ this._ribbon$.next(ribbon);
3149
+ }
3150
+ _isContextualTab(tab) {
3151
+ return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
3152
+ }
3112
3153
  };
3113
3154
  DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
3114
3155
 
@@ -3199,7 +3240,8 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
3199
3240
  overlay: /* @__PURE__ */ jsx("div", {
3200
3241
  className: "univer-grid univer-gap-1 univer-px-2 univer-py-1",
3201
3242
  children: ribbon.map((group) => {
3202
- const Icon = iconMap[group.key];
3243
+ var _iconMap;
3244
+ const Icon = (_iconMap = iconMap[group.key]) !== null && _iconMap !== void 0 ? _iconMap : MoreFunctionIcon;
3203
3245
  return /* @__PURE__ */ jsxs("a", {
3204
3246
  "data-u-comp": "ribbon-group-btn",
3205
3247
  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",
@@ -3423,9 +3465,20 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3423
3465
  const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
3424
3466
  const menuManagerService = useDependency(IMenuManagerService);
3425
3467
  const [hiddenStates, setHiddenStates] = useState({});
3468
+ const [menuVersion, setMenuVersion] = useState(0);
3469
+ useEffect(() => {
3470
+ const subscription = menuManagerService.menuChanged$.subscribe(() => {
3471
+ setMenuVersion((version) => version + 1);
3472
+ });
3473
+ return () => subscription.unsubscribe();
3474
+ }, [menuManagerService]);
3426
3475
  const menuItems = useMemo(() => {
3427
3476
  return menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
3428
- }, [menuId]);
3477
+ }, [
3478
+ menuId,
3479
+ menuManagerService,
3480
+ menuVersion
3481
+ ]);
3429
3482
  const filteredMenuItems = useMemo(() => {
3430
3483
  return menuItems.filter((item) => {
3431
3484
  var _item$key;
@@ -4189,6 +4242,7 @@ function ContextMenuPanel(props) {
4189
4242
  onWheel: (event) => event.stopPropagation(),
4190
4243
  children: /* @__PURE__ */ jsx(ContextMenuMenu, {
4191
4244
  menuSchemas: menuItems,
4245
+ menuSessionVersion,
4192
4246
  submenuPortalContainer,
4193
4247
  onOptionSelect,
4194
4248
  maxMenuHeight
@@ -4196,7 +4250,7 @@ function ContextMenuPanel(props) {
4196
4250
  });
4197
4251
  }
4198
4252
  function ContextMenuMenu(props) {
4199
- const { menuSchemas, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
4253
+ const { menuSchemas, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
4200
4254
  const localeService = useDependency(LocaleService);
4201
4255
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
4202
4256
  const visibleSchemas = useMemo(() => {
@@ -4211,6 +4265,7 @@ function ContextMenuMenu(props) {
4211
4265
  if (menuSchema.item) return /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4212
4266
  menuKey: menuSchema.key,
4213
4267
  menuItem: menuSchema.item,
4268
+ menuSessionVersion,
4214
4269
  submenuPortalContainer,
4215
4270
  onOptionSelect,
4216
4271
  maxMenuHeight
@@ -4234,6 +4289,7 @@ function ContextMenuMenu(props) {
4234
4289
  }), menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4235
4290
  menuKey: childSchema.key,
4236
4291
  menuItem: childSchema.item,
4292
+ menuSessionVersion,
4237
4293
  submenuPortalContainer,
4238
4294
  onOptionSelect,
4239
4295
  maxMenuHeight
@@ -4242,7 +4298,8 @@ function ContextMenuMenu(props) {
4242
4298
  }) });
4243
4299
  }
4244
4300
  function ContextMenuMenuItem(props) {
4245
- const { menuKey, menuItem, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
4301
+ const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
4302
+ const direction = useObservable(useDependency(LocaleService).direction$);
4246
4303
  const menuManagerService = useDependency(IMenuManagerService);
4247
4304
  const disabled = useObservable(menuItem.disabled$, false);
4248
4305
  const activated = useObservable(menuItem.activated$, false);
@@ -4275,7 +4332,8 @@ function ContextMenuMenuItem(props) {
4275
4332
  }, [
4276
4333
  menuItem.id,
4277
4334
  menuItem.type,
4278
- menuManagerService
4335
+ menuManagerService,
4336
+ menuSessionVersion
4279
4337
  ]);
4280
4338
  const hasSelectionSubmenu = selections.length > 0;
4281
4339
  const hasSubItemSubmenu = subMenuItems.length > 0;
@@ -4394,6 +4452,7 @@ function ContextMenuMenuItem(props) {
4394
4452
  children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
4395
4453
  }), hasSubmenu && submenuVisible && (submenuPortalContainer ? createPortal(/* @__PURE__ */ jsx("div", {
4396
4454
  ref: submenuElementRef,
4455
+ dir: direction,
4397
4456
  ["data-u-context-menu-submenu"]: "true",
4398
4457
  className: "univer-z-[1080] univer-w-max univer-max-w-[calc(100vw-16px)]",
4399
4458
  style: {
@@ -4470,6 +4529,7 @@ function ContextMenuMenuItem(props) {
4470
4529
  })
4471
4530
  }), hasSubItemSubmenu && /* @__PURE__ */ jsx(ContextMenuMenu, {
4472
4531
  menuSchemas: subMenuItems,
4532
+ menuSessionVersion,
4473
4533
  submenuPortalContainer,
4474
4534
  onOptionSelect: onSubmenuOptionSelect,
4475
4535
  maxMenuHeight
@@ -4659,54 +4719,6 @@ function DesktopContextMenu() {
4659
4719
  });
4660
4720
  }
4661
4721
 
4662
- //#endregion
4663
- //#region src/services/global-zone/global-zone.service.ts
4664
- const IGlobalZoneService = createIdentifier("univer.global-zone-service");
4665
-
4666
- //#endregion
4667
- //#region src/views/components/global-zone/GlobalZone.tsx
4668
- /**
4669
- * Copyright 2023-present DreamNum Co., Ltd.
4670
- *
4671
- * Licensed under the Apache License, Version 2.0 (the "License");
4672
- * you may not use this file except in compliance with the License.
4673
- * You may obtain a copy of the License at
4674
- *
4675
- * http://www.apache.org/licenses/LICENSE-2.0
4676
- *
4677
- * Unless required by applicable law or agreed to in writing, software
4678
- * distributed under the License is distributed on an "AS IS" BASIS,
4679
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4680
- * See the License for the specific language governing permissions and
4681
- * limitations under the License.
4682
- */
4683
- function GlobalZone() {
4684
- const globalZoneService = useDependency(IGlobalZoneService);
4685
- const [visible, setVisible] = useState(false);
4686
- const componentKey = useObservable(globalZoneService.componentKey$, globalZoneService.componentKey);
4687
- const componentManager = useDependency(ComponentManager);
4688
- const Component = useMemo(() => {
4689
- const Component = componentManager.get(componentKey !== null && componentKey !== void 0 ? componentKey : "");
4690
- if (Component) return Component;
4691
- }, [componentKey, componentManager]);
4692
- useEffect(() => {
4693
- const subscription = globalZoneService.visible$.subscribe((val) => {
4694
- setVisible(val);
4695
- });
4696
- return () => {
4697
- subscription.unsubscribe();
4698
- };
4699
- }, [globalZoneService.visible$]);
4700
- if (!visible) return null;
4701
- return /* @__PURE__ */ jsx("section", {
4702
- className: clsx("univer-absolute univer-bg-gray-100", {
4703
- "univer-hidden": !visible,
4704
- "univer-inset-0 univer-z-[100] univer-block univer-size-full": visible
4705
- }),
4706
- children: Component && /* @__PURE__ */ jsx(Component, {})
4707
- });
4708
- }
4709
-
4710
4722
  //#endregion
4711
4723
  //#region src/views/components/sidebar/Sidebar.tsx
4712
4724
  function Sidebar() {
@@ -4890,11 +4902,14 @@ function DesktopWorkbenchContent(props) {
4890
4902
  if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
4891
4903
  }, [onRendered]);
4892
4904
  const [locale, setLocale] = useState(localeService.getLocales());
4905
+ const [direction, setDirection] = useState(localeService.getDirection());
4893
4906
  const portalContainer = useMemo(() => document.createElement("div"), []);
4894
4907
  useEffect(() => {
4895
4908
  document.body.appendChild(portalContainer);
4896
4909
  const subscriptions = [localeService.localeChanged$.subscribe(() => {
4897
4910
  setLocale(localeService.getLocales());
4911
+ }), localeService.direction$.subscribe(() => {
4912
+ setDirection(localeService.getDirection());
4898
4913
  })];
4899
4914
  return () => {
4900
4915
  subscriptions.forEach((subscription) => subscription.unsubscribe());
@@ -4905,76 +4920,82 @@ function DesktopWorkbenchContent(props) {
4905
4920
  mountContainer,
4906
4921
  portalContainer
4907
4922
  ]);
4923
+ useEffect(() => {
4924
+ portalContainer.dir = direction;
4925
+ }, [direction, portalContainer]);
4908
4926
  return /* @__PURE__ */ jsxs(ConfigProvider, {
4909
4927
  locale: locale === null || locale === void 0 ? void 0 : locale.design,
4928
+ direction,
4910
4929
  mountContainer: portalContainer,
4911
- children: [
4912
- /* @__PURE__ */ jsxs("div", {
4913
- "data-u-comp": "workbench-layout",
4914
- className: clsx("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
4915
- tabIndex: -1,
4916
- onBlur: (e) => e.stopPropagation(),
4917
- onContextMenu: (e) => e.preventDefault(),
4918
- children: [
4919
- /* @__PURE__ */ jsx("div", {
4920
- className: "univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800",
4921
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: customHeaderComponents }, "custom-header")
4922
- }),
4923
- header && toolbar && /* @__PURE__ */ jsx("header", {
4924
- "data-u-comp": "headerbar",
4925
- className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
4926
- children: /* @__PURE__ */ jsx(ComponentContainer, {
4927
- components: toolbarComponents,
4928
- sharedProps: {
4929
- ribbonType,
4930
- headerMenuComponents,
4931
- headerMenu
4932
- }
4933
- }, "toolbar")
4934
- }),
4935
- /* @__PURE__ */ jsxs("section", {
4936
- className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
4937
- children: [
4938
- /* @__PURE__ */ jsxs("div", {
4939
- className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
4940
- children: [
4941
- /* @__PURE__ */ jsx("aside", {
4942
- "data-u-comp": "left-sidebar",
4943
- className: "univer-h-full",
4944
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
4945
- }),
4946
- /* @__PURE__ */ jsxs("section", {
4947
- className: clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", borderBottomClassName),
4948
- children: [/* @__PURE__ */ jsx("header", { children: header && /* @__PURE__ */ jsx(ComponentContainer, { components: headerComponents }, "header") }), /* @__PURE__ */ jsx("section", {
4949
- className: "univer-relative univer-overflow-hidden dark:!univer-bg-gray-900",
4950
- ref: contentRef,
4951
- "data-range-selector": true,
4952
- onContextMenu: (e) => e.preventDefault(),
4953
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: contentComponents }, "content")
4954
- })]
4955
- }),
4956
- /* @__PURE__ */ jsx("aside", {
4957
- "data-u-comp": "right-sidebar",
4958
- className: "univer-z-[100] univer-h-full",
4959
- children: /* @__PURE__ */ jsx(Sidebar, {})
4960
- })
4961
- ]
4962
- }),
4963
- footer && /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(ComponentContainer, {
4964
- components: footerComponents,
4965
- sharedProps: { contextMenu }
4966
- }, "footer") }),
4967
- /* @__PURE__ */ jsx(ZenZone, {})
4968
- ]
4969
- })
4970
- ]
4971
- }),
4972
- /* @__PURE__ */ jsx(ComponentContainer, { components: globalComponents }, "global"),
4973
- /* @__PURE__ */ jsx(GlobalZone, {}),
4974
- contextMenu && /* @__PURE__ */ jsx(DesktopContextMenu, {}),
4975
- /* @__PURE__ */ jsx(FloatingContainer, {}),
4976
- /* @__PURE__ */ jsx("div", { id: popupRootId })
4977
- ]
4930
+ children: [/* @__PURE__ */ jsxs("div", {
4931
+ "data-u-comp": "workbench-layout",
4932
+ className: clsx("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
4933
+ tabIndex: -1,
4934
+ onBlur: (e) => e.stopPropagation(),
4935
+ onContextMenu: (e) => e.preventDefault(),
4936
+ dir: direction,
4937
+ children: [
4938
+ /* @__PURE__ */ jsx("div", {
4939
+ className: "univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800",
4940
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: customHeaderComponents }, "custom-header")
4941
+ }),
4942
+ header && toolbar && /* @__PURE__ */ jsx("header", {
4943
+ "data-u-comp": "headerbar",
4944
+ className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
4945
+ children: /* @__PURE__ */ jsx(ComponentContainer, {
4946
+ components: toolbarComponents,
4947
+ sharedProps: {
4948
+ ribbonType,
4949
+ headerMenuComponents,
4950
+ headerMenu
4951
+ }
4952
+ }, "toolbar")
4953
+ }),
4954
+ /* @__PURE__ */ jsxs("section", {
4955
+ className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
4956
+ children: [
4957
+ /* @__PURE__ */ jsxs("div", {
4958
+ className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
4959
+ children: [
4960
+ /* @__PURE__ */ jsx("aside", {
4961
+ "data-u-comp": "left-sidebar",
4962
+ className: "univer-h-full",
4963
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
4964
+ }),
4965
+ /* @__PURE__ */ jsxs("section", {
4966
+ className: clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", borderBottomClassName),
4967
+ children: [/* @__PURE__ */ jsx("header", { children: header && /* @__PURE__ */ jsx(ComponentContainer, { components: headerComponents }, "header") }), /* @__PURE__ */ jsx("section", {
4968
+ className: "univer-relative univer-overflow-hidden dark:!univer-bg-gray-900",
4969
+ ref: contentRef,
4970
+ "data-range-selector": true,
4971
+ onContextMenu: (e) => e.preventDefault(),
4972
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: contentComponents }, "content")
4973
+ })]
4974
+ }),
4975
+ /* @__PURE__ */ jsx("aside", {
4976
+ "data-u-comp": "right-sidebar",
4977
+ className: "univer-z-[100] univer-h-full",
4978
+ children: /* @__PURE__ */ jsx(Sidebar, {})
4979
+ })
4980
+ ]
4981
+ }),
4982
+ footer && /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(ComponentContainer, {
4983
+ components: footerComponents,
4984
+ sharedProps: { contextMenu }
4985
+ }, "footer") }),
4986
+ /* @__PURE__ */ jsx(ZenZone, {})
4987
+ ]
4988
+ })
4989
+ ]
4990
+ }), /* @__PURE__ */ jsxs("div", {
4991
+ dir: direction,
4992
+ children: [
4993
+ /* @__PURE__ */ jsx(ComponentContainer, { components: globalComponents }, "global"),
4994
+ contextMenu && /* @__PURE__ */ jsx(DesktopContextMenu, {}),
4995
+ /* @__PURE__ */ jsx(FloatingContainer, {}),
4996
+ /* @__PURE__ */ jsx("div", { id: popupRootId })
4997
+ ]
4998
+ })]
4978
4999
  });
4979
5000
  }
4980
5001
  function FloatingContainer() {
@@ -5140,7 +5161,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
5140
5161
  //#endregion
5141
5162
  //#region package.json
5142
5163
  var name = "@univerjs/ui";
5143
- var version = "0.22.1";
5164
+ var version = "0.23.0-insiders.20260522-e8f2a3b";
5144
5165
 
5145
5166
  //#endregion
5146
5167
  //#region src/views/components/ribbon/MobileRibbon.tsx
@@ -5637,6 +5658,7 @@ function MobileContextMenu() {
5637
5658
  const commandService = useDependency(ICommandService);
5638
5659
  const layoutService = useDependency(ILayoutService);
5639
5660
  const localeService = useDependency(LocaleService);
5661
+ const direction = useObservable(localeService.direction$);
5640
5662
  const { mountContainer } = useContext(ConfigContext);
5641
5663
  visibleRef.current = visible;
5642
5664
  useEffect(() => {
@@ -5676,6 +5698,7 @@ function MobileContextMenu() {
5676
5698
  }, [localeService, menuType]);
5677
5699
  if (!mountContainer || !visible) return null;
5678
5700
  return createPortal(/* @__PURE__ */ jsxs("div", {
5701
+ dir: direction,
5679
5702
  className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
5680
5703
  children: [/* @__PURE__ */ jsx("button", {
5681
5704
  type: "button",
@@ -5752,6 +5775,7 @@ function MobileWorkbench(props) {
5752
5775
  if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
5753
5776
  }, [onRendered]);
5754
5777
  const [locale, setLocale] = useState(localeService.getLocales());
5778
+ const [direction, setDirection] = useState(localeService.getDirection());
5755
5779
  const portalContainer = useMemo(() => document.createElement("div"), []);
5756
5780
  useLayoutEffect(() => {
5757
5781
  const sub = themeService.currentTheme$.subscribe((theme) => {
@@ -5765,6 +5789,8 @@ function MobileWorkbench(props) {
5765
5789
  document.body.appendChild(portalContainer);
5766
5790
  const subscriptions = [localeService.localeChanged$.subscribe(() => {
5767
5791
  setLocale(localeService.getLocales());
5792
+ }), localeService.direction$.subscribe(() => {
5793
+ setDirection(localeService.getDirection());
5768
5794
  })];
5769
5795
  return () => {
5770
5796
  subscriptions.forEach((subscription) => subscription.unsubscribe());
@@ -5775,65 +5801,68 @@ function MobileWorkbench(props) {
5775
5801
  mountContainer,
5776
5802
  portalContainer
5777
5803
  ]);
5804
+ useEffect(() => {
5805
+ portalContainer.dir = direction;
5806
+ }, [direction, portalContainer]);
5778
5807
  return /* @__PURE__ */ jsxs(ConfigProvider, {
5779
5808
  locale: locale === null || locale === void 0 ? void 0 : locale.design,
5809
+ direction,
5780
5810
  mountContainer: portalContainer,
5781
- children: [
5782
- /* @__PURE__ */ jsxs("div", {
5783
- "data-u-comp": "app-layout",
5784
- className: clsx("univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
5785
- tabIndex: -1,
5786
- onBlur: (e) => e.stopPropagation(),
5787
- onContextMenu: (e) => e.preventDefault(),
5788
- children: [header && toolbar && /* @__PURE__ */ jsx("header", {
5789
- "data-u-comp": "headerbar",
5790
- className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
5791
- children: /* @__PURE__ */ jsx(ComponentContainer, {
5792
- components: toolbarComponents,
5793
- sharedProps: {
5794
- ribbonType,
5795
- headerMenuComponents,
5796
- headerMenu
5797
- }
5798
- }, "toolbar")
5799
- }), /* @__PURE__ */ jsxs("section", {
5800
- className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
5801
- children: [
5802
- /* @__PURE__ */ jsxs("div", {
5803
- className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
5804
- children: [
5805
- /* @__PURE__ */ jsx("aside", {
5806
- className: "univer-h-full",
5807
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
5808
- }),
5809
- /* @__PURE__ */ jsxs("section", {
5810
- className: clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", borderBottomClassName),
5811
- children: [/* @__PURE__ */ jsx("header", {
5812
- className: "univer-w-screen",
5813
- children: header && /* @__PURE__ */ jsx(ComponentContainer, { components: headerComponents }, "header")
5814
- }), /* @__PURE__ */ jsx("section", {
5815
- ref: contentRef,
5816
- className: "univer-relative univer-overflow-hidden",
5817
- "data-range-selector": true,
5818
- onContextMenu: (e) => e.preventDefault(),
5819
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: contentComponents }, "content")
5820
- })]
5821
- }),
5822
- /* @__PURE__ */ jsx("aside", {
5823
- className: "univer-h-full",
5824
- children: /* @__PURE__ */ jsx(Sidebar, {})
5825
- })
5826
- ]
5827
- }),
5828
- footer && /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(ComponentContainer, { components: footerComponents }, "footer") }),
5829
- /* @__PURE__ */ jsx(GlobalZone, {}),
5830
- /* @__PURE__ */ jsx(ZenZone, {})
5831
- ]
5832
- })]
5833
- }),
5834
- /* @__PURE__ */ jsx(ComponentContainer, { components: globalComponents }, "global"),
5835
- contextMenu && /* @__PURE__ */ jsx(MobileContextMenu, {})
5836
- ]
5811
+ children: [/* @__PURE__ */ jsxs("div", {
5812
+ "data-u-comp": "app-layout",
5813
+ className: clsx("univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800", { "univer-dark": darkMode }),
5814
+ tabIndex: -1,
5815
+ onBlur: (e) => e.stopPropagation(),
5816
+ onContextMenu: (e) => e.preventDefault(),
5817
+ dir: direction,
5818
+ children: [header && toolbar && /* @__PURE__ */ jsx("header", {
5819
+ "data-u-comp": "headerbar",
5820
+ className: "univer-relative univer-z-10 univer-w-full univer-overflow-hidden",
5821
+ children: /* @__PURE__ */ jsx(ComponentContainer, {
5822
+ components: toolbarComponents,
5823
+ sharedProps: {
5824
+ ribbonType,
5825
+ headerMenuComponents,
5826
+ headerMenu
5827
+ }
5828
+ }, "toolbar")
5829
+ }), /* @__PURE__ */ jsxs("section", {
5830
+ className: "univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",
5831
+ children: [
5832
+ /* @__PURE__ */ jsxs("div", {
5833
+ className: "univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",
5834
+ children: [
5835
+ /* @__PURE__ */ jsx("aside", {
5836
+ className: "univer-h-full",
5837
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: leftSidebarComponents }, "left-sidebar")
5838
+ }),
5839
+ /* @__PURE__ */ jsxs("section", {
5840
+ className: clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800", borderBottomClassName),
5841
+ children: [/* @__PURE__ */ jsx("header", {
5842
+ className: "univer-w-screen",
5843
+ children: header && /* @__PURE__ */ jsx(ComponentContainer, { components: headerComponents }, "header")
5844
+ }), /* @__PURE__ */ jsx("section", {
5845
+ ref: contentRef,
5846
+ className: "univer-relative univer-overflow-hidden",
5847
+ "data-range-selector": true,
5848
+ onContextMenu: (e) => e.preventDefault(),
5849
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: contentComponents }, "content")
5850
+ })]
5851
+ }),
5852
+ /* @__PURE__ */ jsx("aside", {
5853
+ className: "univer-h-full",
5854
+ children: /* @__PURE__ */ jsx(Sidebar, {})
5855
+ })
5856
+ ]
5857
+ }),
5858
+ footer && /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(ComponentContainer, { components: footerComponents }, "footer") }),
5859
+ /* @__PURE__ */ jsx(ZenZone, {})
5860
+ ]
5861
+ })]
5862
+ }), /* @__PURE__ */ jsxs("div", {
5863
+ dir: direction,
5864
+ children: [/* @__PURE__ */ jsx(ComponentContainer, { components: globalComponents }, "global"), contextMenu && /* @__PURE__ */ jsx(MobileContextMenu, {})]
5865
+ })]
5837
5866
  });
5838
5867
  }
5839
5868
 
@@ -6602,37 +6631,6 @@ let DesktopGalleryService = class DesktopGalleryService extends Disposable {
6602
6631
  };
6603
6632
  DesktopGalleryService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IUIPartsService)], DesktopGalleryService);
6604
6633
 
6605
- //#endregion
6606
- //#region src/services/global-zone/desktop-global-zone.service.ts
6607
- let DesktopGlobalZoneService = class DesktopGlobalZoneService {
6608
- constructor(_componentManager) {
6609
- this._componentManager = _componentManager;
6610
- _defineProperty(this, "visible$", new Subject());
6611
- _defineProperty(this, "componentKey$", new Subject());
6612
- _defineProperty(this, "_componentKey", "");
6613
- }
6614
- get componentKey() {
6615
- return this._componentKey;
6616
- }
6617
- set(key, component) {
6618
- this._componentManager.register(key, component);
6619
- this.componentKey$.next(key);
6620
- this._componentKey = key;
6621
- return toDisposable(() => {
6622
- this._componentManager.delete(key);
6623
- this.visible$.complete();
6624
- this.componentKey$.complete();
6625
- });
6626
- }
6627
- open() {
6628
- this.visible$.next(true);
6629
- }
6630
- close() {
6631
- this.visible$.next(false);
6632
- }
6633
- };
6634
- DesktopGlobalZoneService = __decorate([__decorateParam(0, Inject(ComponentManager))], DesktopGlobalZoneService);
6635
-
6636
6634
  //#endregion
6637
6635
  //#region src/services/local-file/desktop-local-file.service.ts
6638
6636
  var DesktopLocalFileService = class extends Disposable {
@@ -6724,7 +6722,13 @@ var DesktopLocalStorageService = class {
6724
6722
  * limitations under the License.
6725
6723
  */
6726
6724
  function MessageContainer() {
6727
- return /* @__PURE__ */ jsx(Messager, { theme: useObservable(useDependency(ThemeService).darkMode$) ? "dark" : "light" });
6725
+ const localeService = useDependency(LocaleService);
6726
+ const darkMode = useObservable(useDependency(ThemeService).darkMode$);
6727
+ const direction = useObservable(localeService.direction$);
6728
+ return /* @__PURE__ */ jsx(Messager, {
6729
+ theme: darkMode ? "dark" : "light",
6730
+ dir: direction
6731
+ });
6728
6732
  }
6729
6733
 
6730
6734
  //#endregion
@@ -6763,7 +6767,13 @@ DesktopMessageService = __decorate([__decorateParam(0, Inject(Injector)), __deco
6763
6767
  //#endregion
6764
6768
  //#region src/components/notification/Notification.tsx
6765
6769
  function Notification() {
6766
- return /* @__PURE__ */ jsx(Toaster, { theme: useObservable(useDependency(ThemeService).darkMode$) ? "dark" : "light" });
6770
+ const localeService = useDependency(LocaleService);
6771
+ const darkMode = useObservable(useDependency(ThemeService).darkMode$);
6772
+ const direction = useObservable(localeService.direction$);
6773
+ return /* @__PURE__ */ jsx(Toaster, {
6774
+ theme: darkMode ? "dark" : "light",
6775
+ dir: direction
6776
+ });
6767
6777
  }
6768
6778
  const notification = { show: (options) => {
6769
6779
  const { type = "message", title, content, duration, closable = true, position = "top-right" } = options;
@@ -6963,10 +6973,6 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
6963
6973
  useClass: DesktopZenZoneService,
6964
6974
  lazy: true
6965
6975
  }],
6966
- [IGlobalZoneService, {
6967
- useClass: DesktopGlobalZoneService,
6968
- lazy: true
6969
- }],
6970
6976
  [IMessageService, {
6971
6977
  useClass: DesktopMessageService,
6972
6978
  lazy: true
@@ -7064,10 +7070,6 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
7064
7070
  useClass: DesktopZenZoneService,
7065
7071
  lazy: true
7066
7072
  }],
7067
- [IGlobalZoneService, {
7068
- useClass: DesktopGlobalZoneService,
7069
- lazy: true
7070
- }],
7071
7073
  [IMessageService, {
7072
7074
  useClass: DesktopMessageService,
7073
7075
  lazy: true
@@ -7744,7 +7746,7 @@ function extractFontFamily(styleStr) {
7744
7746
  }
7745
7747
 
7746
7748
  //#endregion
7747
- //#region src/views/components/dom/print.tsx
7749
+ //#region src/views/components/dom/Print.tsx
7748
7750
  const PrintFloatDomSingle = memo((props) => {
7749
7751
  var _position$startY, _position$startX;
7750
7752
  const { layer, id, position } = props;
@@ -7812,4 +7814,4 @@ const PrintFloatDomSingle = memo((props) => {
7812
7814
  });
7813
7815
 
7814
7816
  //#endregion
7815
- export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopGlobalZoneService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, DesktopZenZoneService, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontSize, GlobalZone, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, IGlobalZoneService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZenZone, connectDependencies, connectInjector, getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, sanitizeParsedHtml, splitSpanText, supportClipboardAPI, t, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
7817
+ export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, DesktopZenZoneService, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZenZone, connectDependencies, connectInjector, getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, sanitizeParsedHtml, splitSpanText, supportClipboardAPI, t, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };