@univerjs/ui 1.0.0-alpha.3 → 1.0.0-alpha.4

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.
Files changed (96) hide show
  1. package/lib/cjs/index.js +671 -638
  2. package/lib/cjs/locale/ar-SA.js +11 -0
  3. package/lib/cjs/locale/ca-ES.js +11 -0
  4. package/lib/cjs/locale/de-DE.js +11 -0
  5. package/lib/cjs/locale/en-US.js +11 -0
  6. package/lib/cjs/locale/es-ES.js +11 -0
  7. package/lib/cjs/locale/fa-IR.js +11 -0
  8. package/lib/cjs/locale/fr-FR.js +11 -0
  9. package/lib/cjs/locale/id-ID.js +11 -0
  10. package/lib/cjs/locale/it-IT.js +11 -0
  11. package/lib/cjs/locale/ja-JP.js +11 -0
  12. package/lib/cjs/locale/ko-KR.js +11 -0
  13. package/lib/cjs/locale/pl-PL.js +11 -0
  14. package/lib/cjs/locale/pt-BR.js +11 -0
  15. package/lib/cjs/locale/ru-RU.js +11 -0
  16. package/lib/cjs/locale/sk-SK.js +11 -0
  17. package/lib/cjs/locale/vi-VN.js +11 -0
  18. package/lib/cjs/locale/zh-CN.js +11 -0
  19. package/lib/cjs/locale/zh-HK.js +11 -0
  20. package/lib/cjs/locale/zh-TW.js +11 -0
  21. package/lib/es/index.js +674 -643
  22. package/lib/es/locale/ar-SA.js +11 -0
  23. package/lib/es/locale/ca-ES.js +11 -0
  24. package/lib/es/locale/de-DE.js +11 -0
  25. package/lib/es/locale/en-US.js +11 -0
  26. package/lib/es/locale/es-ES.js +11 -0
  27. package/lib/es/locale/fa-IR.js +11 -0
  28. package/lib/es/locale/fr-FR.js +11 -0
  29. package/lib/es/locale/id-ID.js +11 -0
  30. package/lib/es/locale/it-IT.js +11 -0
  31. package/lib/es/locale/ja-JP.js +11 -0
  32. package/lib/es/locale/ko-KR.js +11 -0
  33. package/lib/es/locale/pl-PL.js +11 -0
  34. package/lib/es/locale/pt-BR.js +11 -0
  35. package/lib/es/locale/ru-RU.js +11 -0
  36. package/lib/es/locale/sk-SK.js +11 -0
  37. package/lib/es/locale/vi-VN.js +11 -0
  38. package/lib/es/locale/zh-CN.js +11 -0
  39. package/lib/es/locale/zh-HK.js +11 -0
  40. package/lib/es/locale/zh-TW.js +11 -0
  41. package/lib/index.js +674 -643
  42. package/lib/locale/ar-SA.js +11 -0
  43. package/lib/locale/ca-ES.js +11 -0
  44. package/lib/locale/de-DE.js +11 -0
  45. package/lib/locale/en-US.js +11 -0
  46. package/lib/locale/es-ES.js +11 -0
  47. package/lib/locale/fa-IR.js +11 -0
  48. package/lib/locale/fr-FR.js +11 -0
  49. package/lib/locale/id-ID.js +11 -0
  50. package/lib/locale/it-IT.js +11 -0
  51. package/lib/locale/ja-JP.js +11 -0
  52. package/lib/locale/ko-KR.js +11 -0
  53. package/lib/locale/pl-PL.js +11 -0
  54. package/lib/locale/pt-BR.js +11 -0
  55. package/lib/locale/ru-RU.js +11 -0
  56. package/lib/locale/sk-SK.js +11 -0
  57. package/lib/locale/vi-VN.js +11 -0
  58. package/lib/locale/zh-CN.js +11 -0
  59. package/lib/locale/zh-HK.js +11 -0
  60. package/lib/locale/zh-TW.js +11 -0
  61. package/lib/types/commands/operations/toggle-fullscreen.operation.d.ts +17 -0
  62. package/lib/types/controllers/ui/ui-desktop.controller.d.ts +1 -3
  63. package/lib/types/controllers/ui/ui-mobile.controller.d.ts +1 -3
  64. package/lib/types/index.d.ts +2 -1
  65. package/lib/types/locale/en-US.d.ts +13 -0
  66. package/lib/types/services/before-close/before-close.service.d.ts +3 -2
  67. package/lib/types/services/menu/menu.d.ts +3 -2
  68. package/lib/types/services/menu/types.d.ts +1 -0
  69. package/lib/types/services/popup/canvas-popup.service.d.ts +3 -0
  70. package/lib/types/views/components/dom/FloatDom.d.ts +1 -1
  71. package/lib/types/views/components/dom/Print.d.ts +1 -1
  72. package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
  73. package/lib/types/views/index.d.ts +1 -1
  74. package/lib/types/views/slider/ZoomInput.d.ts +25 -0
  75. package/lib/types/views/slider/index.d.ts +1 -0
  76. package/lib/umd/index.js +13 -13
  77. package/lib/umd/locale/ar-SA.js +1 -1
  78. package/lib/umd/locale/ca-ES.js +1 -1
  79. package/lib/umd/locale/de-DE.js +1 -1
  80. package/lib/umd/locale/en-US.js +1 -1
  81. package/lib/umd/locale/es-ES.js +1 -1
  82. package/lib/umd/locale/fa-IR.js +1 -1
  83. package/lib/umd/locale/fr-FR.js +1 -1
  84. package/lib/umd/locale/id-ID.js +1 -1
  85. package/lib/umd/locale/it-IT.js +1 -1
  86. package/lib/umd/locale/ja-JP.js +1 -1
  87. package/lib/umd/locale/ko-KR.js +1 -1
  88. package/lib/umd/locale/pl-PL.js +1 -1
  89. package/lib/umd/locale/pt-BR.js +1 -1
  90. package/lib/umd/locale/ru-RU.js +1 -1
  91. package/lib/umd/locale/sk-SK.js +1 -1
  92. package/lib/umd/locale/vi-VN.js +1 -1
  93. package/lib/umd/locale/zh-CN.js +1 -1
  94. package/lib/umd/locale/zh-HK.js +1 -1
  95. package/lib/umd/locale/zh-TW.js +1 -1
  96. package/package.json +8 -8
package/lib/cjs/index.js CHANGED
@@ -10,6 +10,47 @@ let react_jsx_runtime = require("react/jsx-runtime");
10
10
  let react_dom = require("react-dom");
11
11
  let _univerjs_icons = require("@univerjs/icons");
12
12
 
13
+ //#region src/utils/embed-boundary.ts
14
+ /**
15
+ * Copyright 2023-present DreamNum Co., Ltd.
16
+ *
17
+ * Licensed under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS,
25
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ * See the License for the specific language governing permissions and
27
+ * limitations under the License.
28
+ */
29
+ const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
30
+ function getEmbedBoundaryOwner(target) {
31
+ var _ref, _getAttributeValue;
32
+ if (!hasClosest(target)) return;
33
+ 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;
35
+ }
36
+ function isEmbedBoundaryTarget(target) {
37
+ return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
38
+ }
39
+ function keepInteractionInsideSameEmbedBoundary(event) {
40
+ const owner = getEmbedBoundaryOwner(event.currentTarget);
41
+ if (!owner) return;
42
+ if (getEmbedBoundaryOwner(event.target) === owner) event.preventDefault();
43
+ }
44
+ function hasClosest(target) {
45
+ return !!target && typeof target.closest === "function";
46
+ }
47
+ function getAttributeValue(target, name) {
48
+ var _getAttribute$call;
49
+ const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
50
+ return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
51
+ }
52
+
53
+ //#endregion
13
54
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
14
55
  function _typeof(o) {
15
56
  "@babel/helpers - typeof";
@@ -51,6 +92,157 @@ function _defineProperty(e, r, t) {
51
92
  }) : e[r] = t, e;
52
93
  }
53
94
 
95
+ //#endregion
96
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
97
+ function __decorateParam(paramIndex, decorator) {
98
+ return function(target, key) {
99
+ decorator(target, key, paramIndex);
100
+ };
101
+ }
102
+
103
+ //#endregion
104
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
105
+ function __decorate(decorators, target, key, desc) {
106
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
107
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
108
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
109
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
110
+ }
111
+
112
+ //#endregion
113
+ //#region src/services/layout/layout.service.ts
114
+ const FOCUSING_UNIVER = "FOCUSING_UNIVER";
115
+ const givingBackFocusElements = [
116
+ "app-layout",
117
+ "button",
118
+ "sheet-bar-append-button",
119
+ "render-canvas",
120
+ "workbench-layout"
121
+ ];
122
+ const ILayoutService = (0, _univerjs_core.createIdentifier)("ui.layout-service");
123
+ let DesktopLayoutService = class DesktopLayoutService extends _univerjs_core.Disposable {
124
+ get isFocused() {
125
+ return this._isFocused;
126
+ }
127
+ constructor(_contextService, _univerInstanceService) {
128
+ super();
129
+ this._contextService = _contextService;
130
+ this._univerInstanceService = _univerInstanceService;
131
+ _defineProperty(this, "_rootContainerElement", null);
132
+ _defineProperty(this, "_isFocused", false);
133
+ _defineProperty(this, "_focusHandlers", /* @__PURE__ */ new Map());
134
+ _defineProperty(this, "_contentElements", []);
135
+ _defineProperty(this, "_allContainers", []);
136
+ this._initUniverFocusListener();
137
+ this._initEditorStatus();
138
+ }
139
+ get rootContainerElement() {
140
+ return this._rootContainerElement;
141
+ }
142
+ focus() {
143
+ const currentFocused = this._univerInstanceService.getFocusedUnit();
144
+ if (!currentFocused) return;
145
+ let handler;
146
+ if (currentFocused instanceof _univerjs_core.Workbook) handler = this._focusHandlers.get(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
147
+ else if (currentFocused instanceof _univerjs_core.DocumentDataModel) handler = this._focusHandlers.get(_univerjs_core.UniverInstanceType.UNIVER_DOC);
148
+ else if ((currentFocused === null || currentFocused === void 0 ? void 0 : currentFocused.type) === _univerjs_core.UniverInstanceType.UNIVER_SLIDE) handler = this._focusHandlers.get(_univerjs_core.UniverInstanceType.UNIVER_SLIDE);
149
+ if (handler) handler(currentFocused.getUnitId());
150
+ }
151
+ registerFocusHandler(type, handler) {
152
+ if (this._focusHandlers.has(type)) throw new Error(`[DesktopLayoutService]: handler of type ${type} bas been registered!`);
153
+ this._focusHandlers.set(type, handler);
154
+ return (0, _univerjs_core.toDisposable)(() => this._focusHandlers.delete(type));
155
+ }
156
+ registerContentElement(container) {
157
+ if (this._contentElements.indexOf(container) === -1) {
158
+ this._contentElements.push(container);
159
+ return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._contentElements, container));
160
+ }
161
+ throw new Error("[DesktopLayoutService]: content container already registered!");
162
+ }
163
+ getContentElement() {
164
+ return this._contentElements[0];
165
+ }
166
+ registerRootContainerElement(container) {
167
+ if (this._rootContainerElement) throw new Error("[DesktopLayoutService]: root container already registered!");
168
+ this._rootContainerElement = container;
169
+ const dis = this.registerContainerElement(container);
170
+ return (0, _univerjs_core.toDisposable)(() => {
171
+ this._rootContainerElement = null;
172
+ dis.dispose();
173
+ });
174
+ }
175
+ registerContainerElement(container) {
176
+ if (this._allContainers.indexOf(container) === -1) {
177
+ this._allContainers.push(container);
178
+ return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._allContainers, container));
179
+ }
180
+ throw new Error("[LayoutService]: container already registered!");
181
+ }
182
+ checkElementInCurrentContainers(element) {
183
+ return this._allContainers.some((container) => container.contains(element));
184
+ }
185
+ checkContentIsFocused() {
186
+ return this._contentElements.some((contentEl) => contentEl === document.activeElement || contentEl.contains(document.activeElement));
187
+ }
188
+ _initUniverFocusListener() {
189
+ this.disposeWithMe((0, rxjs.fromEvent)(window, "focusin").subscribe((event) => {
190
+ var _this$_rootContainerE;
191
+ const target = event.target;
192
+ if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item) && !isEmbedBoundaryTarget(target)) {
193
+ queueMicrotask(() => {
194
+ const targetUnitId = getFocusUnitIdFromElement(target);
195
+ if (targetUnitId && this._univerInstanceService.getUnit(targetUnitId)) this._univerInstanceService.focusUnit(targetUnitId);
196
+ this.focus();
197
+ this._isFocused = true;
198
+ this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
199
+ this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
200
+ });
201
+ return;
202
+ }
203
+ if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
204
+ else this._isFocused = false;
205
+ this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
206
+ this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
207
+ }));
208
+ }
209
+ _initEditorStatus() {
210
+ this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
211
+ }
212
+ };
213
+ DesktopLayoutService = __decorate([__decorateParam(0, _univerjs_core.IContextService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DesktopLayoutService);
214
+ function getFocusingUniverEditorStatus() {
215
+ var _document$activeEleme;
216
+ return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
217
+ }
218
+ function getFocusUnitIdFromElement(target) {
219
+ return target.dataset.uUnitId;
220
+ }
221
+
222
+ //#endregion
223
+ //#region src/commands/operations/toggle-fullscreen.operation.ts
224
+ const ToggleFullscreenOperation = {
225
+ id: "base-ui.operation.toggle-fullscreen",
226
+ type: _univerjs_core.CommandType.OPERATION,
227
+ handler: (accessor) => {
228
+ const root = accessor.get(ILayoutService).rootContainerElement;
229
+ if (!root) return false;
230
+ const document = root.ownerDocument;
231
+ try {
232
+ if (document.fullscreenElement) {
233
+ if (!document.exitFullscreen) return false;
234
+ document.exitFullscreen().catch(() => {});
235
+ } else {
236
+ if (!root.requestFullscreen) return false;
237
+ root.requestFullscreen().catch(() => {});
238
+ }
239
+ return true;
240
+ } catch {
241
+ return false;
242
+ }
243
+ }
244
+ };
245
+
54
246
  //#endregion
55
247
  //#region src/services/shortcut/shortcut-panel.service.ts
56
248
  /**
@@ -118,23 +310,6 @@ const ToggleShortcutPanelOperation = {
118
310
  }
119
311
  };
120
312
 
121
- //#endregion
122
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
123
- function __decorateParam(paramIndex, decorator) {
124
- return function(target, key) {
125
- decorator(target, key, paramIndex);
126
- };
127
- }
128
-
129
- //#endregion
130
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
131
- function __decorate(decorators, target, key, desc) {
132
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
133
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
134
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
135
- return c > 3 && r && Object.defineProperty(target, key, r), r;
136
- }
137
-
138
313
  //#endregion
139
314
  //#region src/common/component-manager.ts
140
315
  let ComponentManager = class ComponentManager extends _univerjs_core.Disposable {
@@ -612,168 +787,17 @@ let MetaKeys = /* @__PURE__ */ function(MetaKeys) {
612
787
  /** Option key on MacOS. Alt key on other systems. */
613
788
  MetaKeys[MetaKeys["ALT"] = 2048] = "ALT";
614
789
  /** Command key on MacOS. Ctrl key on other systems. */
615
- MetaKeys[MetaKeys["CTRL_COMMAND"] = 4096] = "CTRL_COMMAND";
616
- /** Ctrl key for MacOS. Not valid on other systems. */
617
- MetaKeys[MetaKeys["MAC_CTRL"] = 8192] = "MAC_CTRL";
618
- return MetaKeys;
619
- }({});
620
-
621
- //#endregion
622
- //#region src/common/lifecycle.ts
623
- function fromGlobalEvent(type, listener, options) {
624
- window.addEventListener(type, listener, options);
625
- return (0, _univerjs_core.toDisposable)(() => window.removeEventListener(type, listener, options));
626
- }
627
-
628
- //#endregion
629
- //#region src/utils/embed-boundary.ts
630
- /**
631
- * Copyright 2023-present DreamNum Co., Ltd.
632
- *
633
- * Licensed under the Apache License, Version 2.0 (the "License");
634
- * you may not use this file except in compliance with the License.
635
- * You may obtain a copy of the License at
636
- *
637
- * http://www.apache.org/licenses/LICENSE-2.0
638
- *
639
- * Unless required by applicable law or agreed to in writing, software
640
- * distributed under the License is distributed on an "AS IS" BASIS,
641
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
642
- * See the License for the specific language governing permissions and
643
- * limitations under the License.
644
- */
645
- const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
646
- function getEmbedBoundaryOwner(target) {
647
- var _ref, _getAttributeValue;
648
- if (!hasClosest(target)) return;
649
- const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
650
- 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;
651
- }
652
- function isEmbedBoundaryTarget(target) {
653
- return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
654
- }
655
- function keepInteractionInsideSameEmbedBoundary(event) {
656
- const owner = getEmbedBoundaryOwner(event.currentTarget);
657
- if (!owner) return;
658
- if (getEmbedBoundaryOwner(event.target) === owner) event.preventDefault();
659
- }
660
- function hasClosest(target) {
661
- return !!target && typeof target.closest === "function";
662
- }
663
- function getAttributeValue(target, name) {
664
- var _getAttribute$call;
665
- const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
666
- return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
667
- }
668
-
669
- //#endregion
670
- //#region src/services/layout/layout.service.ts
671
- const FOCUSING_UNIVER = "FOCUSING_UNIVER";
672
- const givingBackFocusElements = [
673
- "app-layout",
674
- "button",
675
- "sheet-bar-append-button",
676
- "render-canvas",
677
- "workbench-layout"
678
- ];
679
- const ILayoutService = (0, _univerjs_core.createIdentifier)("ui.layout-service");
680
- let DesktopLayoutService = class DesktopLayoutService extends _univerjs_core.Disposable {
681
- get isFocused() {
682
- return this._isFocused;
683
- }
684
- constructor(_contextService, _univerInstanceService) {
685
- super();
686
- this._contextService = _contextService;
687
- this._univerInstanceService = _univerInstanceService;
688
- _defineProperty(this, "_rootContainerElement", null);
689
- _defineProperty(this, "_isFocused", false);
690
- _defineProperty(this, "_focusHandlers", /* @__PURE__ */ new Map());
691
- _defineProperty(this, "_contentElements", []);
692
- _defineProperty(this, "_allContainers", []);
693
- this._initUniverFocusListener();
694
- this._initEditorStatus();
695
- }
696
- get rootContainerElement() {
697
- return this._rootContainerElement;
698
- }
699
- focus() {
700
- const currentFocused = this._univerInstanceService.getFocusedUnit();
701
- if (!currentFocused) return;
702
- let handler;
703
- if (currentFocused instanceof _univerjs_core.Workbook) handler = this._focusHandlers.get(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
704
- else if (currentFocused instanceof _univerjs_core.DocumentDataModel) handler = this._focusHandlers.get(_univerjs_core.UniverInstanceType.UNIVER_DOC);
705
- else if ((currentFocused === null || currentFocused === void 0 ? void 0 : currentFocused.type) === _univerjs_core.UniverInstanceType.UNIVER_SLIDE) handler = this._focusHandlers.get(_univerjs_core.UniverInstanceType.UNIVER_SLIDE);
706
- if (handler) handler(currentFocused.getUnitId());
707
- }
708
- registerFocusHandler(type, handler) {
709
- if (this._focusHandlers.has(type)) throw new Error(`[DesktopLayoutService]: handler of type ${type} bas been registered!`);
710
- this._focusHandlers.set(type, handler);
711
- return (0, _univerjs_core.toDisposable)(() => this._focusHandlers.delete(type));
712
- }
713
- registerContentElement(container) {
714
- if (this._contentElements.indexOf(container) === -1) {
715
- this._contentElements.push(container);
716
- return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._contentElements, container));
717
- }
718
- throw new Error("[DesktopLayoutService]: content container already registered!");
719
- }
720
- getContentElement() {
721
- return this._contentElements[0];
722
- }
723
- registerRootContainerElement(container) {
724
- if (this._rootContainerElement) throw new Error("[DesktopLayoutService]: root container already registered!");
725
- this._rootContainerElement = container;
726
- const dis = this.registerContainerElement(container);
727
- return (0, _univerjs_core.toDisposable)(() => {
728
- this._rootContainerElement = null;
729
- dis.dispose();
730
- });
731
- }
732
- registerContainerElement(container) {
733
- if (this._allContainers.indexOf(container) === -1) {
734
- this._allContainers.push(container);
735
- return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._allContainers, container));
736
- }
737
- throw new Error("[LayoutService]: container already registered!");
738
- }
739
- checkElementInCurrentContainers(element) {
740
- return this._allContainers.some((container) => container.contains(element));
741
- }
742
- checkContentIsFocused() {
743
- return this._contentElements.some((contentEl) => contentEl === document.activeElement || contentEl.contains(document.activeElement));
744
- }
745
- _initUniverFocusListener() {
746
- this.disposeWithMe((0, rxjs.fromEvent)(window, "focusin").subscribe((event) => {
747
- var _this$_rootContainerE;
748
- const target = event.target;
749
- if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item) && !isEmbedBoundaryTarget(target)) {
750
- queueMicrotask(() => {
751
- const targetUnitId = getFocusUnitIdFromElement(target);
752
- if (targetUnitId && this._univerInstanceService.getUnit(targetUnitId)) this._univerInstanceService.focusUnit(targetUnitId);
753
- this.focus();
754
- this._isFocused = true;
755
- this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
756
- this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
757
- });
758
- return;
759
- }
760
- if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
761
- else this._isFocused = false;
762
- this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
763
- this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
764
- }));
765
- }
766
- _initEditorStatus() {
767
- this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
768
- }
769
- };
770
- DesktopLayoutService = __decorate([__decorateParam(0, _univerjs_core.IContextService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DesktopLayoutService);
771
- function getFocusingUniverEditorStatus() {
772
- var _document$activeEleme;
773
- return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
774
- }
775
- function getFocusUnitIdFromElement(target) {
776
- return target.dataset.uUnitId;
790
+ MetaKeys[MetaKeys["CTRL_COMMAND"] = 4096] = "CTRL_COMMAND";
791
+ /** Ctrl key for MacOS. Not valid on other systems. */
792
+ MetaKeys[MetaKeys["MAC_CTRL"] = 8192] = "MAC_CTRL";
793
+ return MetaKeys;
794
+ }({});
795
+
796
+ //#endregion
797
+ //#region src/common/lifecycle.ts
798
+ function fromGlobalEvent(type, listener, options) {
799
+ window.addEventListener(type, listener, options);
800
+ return (0, _univerjs_core.toDisposable)(() => window.removeEventListener(type, listener, options));
777
801
  }
778
802
 
779
803
  //#endregion
@@ -999,6 +1023,7 @@ let SharedController = class SharedController extends _univerjs_core.Disposable
999
1023
  this._registerShortcuts();
1000
1024
  }
1001
1025
  _registerCommands() {
1026
+ this.disposeWithMe(this._commandService.registerCommand(ToggleFullscreenOperation));
1002
1027
  [
1003
1028
  CutCommand,
1004
1029
  CopyCommand,
@@ -1053,6 +1078,7 @@ let RibbonStartGroup = /* @__PURE__ */ function(RibbonStartGroup) {
1053
1078
  }({});
1054
1079
  let RibbonInsertGroup = /* @__PURE__ */ function(RibbonInsertGroup) {
1055
1080
  RibbonInsertGroup["EDIT"] = "ribbon.insert.edit";
1081
+ RibbonInsertGroup["CELL"] = "ribbon.insert.cell";
1056
1082
  RibbonInsertGroup["MEDIA"] = "ribbon.insert.media";
1057
1083
  RibbonInsertGroup["OTHERS"] = "ribbon.insert.others";
1058
1084
  return RibbonInsertGroup;
@@ -1132,7 +1158,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1132
1158
  title: "ui.ribbon.insert",
1133
1159
  ["ribbon.insert.edit"]: { order: 0 },
1134
1160
  ["ribbon.insert.media"]: { order: 1 },
1135
- ["ribbon.insert.others"]: { order: 2 }
1161
+ ["ribbon.insert.cell"]: { order: 2 },
1162
+ ["ribbon.insert.others"]: { order: 3 }
1136
1163
  },
1137
1164
  ["ribbon.formulas"]: {
1138
1165
  order: 2,
@@ -1677,13 +1704,29 @@ function applyFloatDomLayout(wrapper, inner, layout) {
1677
1704
  innerStyle.bottom = innerLayout.bottom === "auto" ? "auto" : `${innerLayout.bottom}px`;
1678
1705
  }
1679
1706
  const FloatDomSingle = (0, react.memo)((props) => {
1707
+ const { layer } = props;
1708
+ return typeof layer.componentKey === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RegisteredFloatDomSingle, {
1709
+ ...props,
1710
+ componentKey: layer.componentKey
1711
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingleContent, {
1712
+ ...props,
1713
+ Component: layer.componentKey
1714
+ });
1715
+ });
1716
+ function RegisteredFloatDomSingle(props) {
1717
+ const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
1718
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingleContent, {
1719
+ ...props,
1720
+ Component: componentManager.get(props.componentKey)
1721
+ });
1722
+ }
1723
+ function FloatDomSingleContent(props) {
1680
1724
  var _layer$contentBox, _layer$contentBox2;
1681
- const { layer, id } = props;
1725
+ const { layer, id, Component } = props;
1682
1726
  const univerInstanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
1683
1727
  const position = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => layer.position$.pipe((0, rxjs.first)()), [layer.position$]));
1684
1728
  const domRef = (0, react.useRef)(null);
1685
1729
  const innerDomRef = (0, react.useRef)(null);
1686
- const Component = typeof layer.componentKey === "string" ? (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager).get(layer.componentKey) : layer.componentKey;
1687
1730
  const layerProps = (0, react.useMemo)(() => ({
1688
1731
  data: layer.data,
1689
1732
  ...layer.props,
@@ -1755,7 +1798,7 @@ const FloatDomSingle = (0, react.memo)((props) => {
1755
1798
  children: component
1756
1799
  })
1757
1800
  });
1758
- });
1801
+ }
1759
1802
  const FloatDom = ({ unitId }) => {
1760
1803
  var _layers$filter;
1761
1804
  const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
@@ -2024,7 +2067,6 @@ RectPopup.useContext = () => (0, react.useContext)(RectPopupContext);
2024
2067
  //#endregion
2025
2068
  //#region src/views/components/popup/CanvasPopup.tsx
2026
2069
  const SingleCanvasPopup = ({ popup, children }) => {
2027
- const [hidden, setHidden] = (0, react.useState)(false);
2028
2070
  const anchorRect$ = (0, react.useMemo)(() => popup.anchorRect$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler), (0, rxjs.map)((anchorRect) => {
2029
2071
  var _popup$offset;
2030
2072
  const { bottom, left, right, top } = anchorRect;
@@ -2045,26 +2087,21 @@ const SingleCanvasPopup = ({ popup, children }) => {
2045
2087
  return (_popup$excludeRects$ = popup.excludeRects$) === null || _popup$excludeRects$ === void 0 ? void 0 : _popup$excludeRects$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler));
2046
2088
  }, [popup.excludeRects$]), popup.excludeRects);
2047
2089
  const { canvasElement, hideOnInvisible = true, hiddenType = "destroy" } = popup;
2048
- (0, react.useEffect)(() => {
2049
- if (!hideOnInvisible) return;
2050
- const anchorRectSub = (0, rxjs.combineLatest)([anchorRect$, hiddenRects$]).subscribe(([rectWithOffset, hiddenRects]) => {
2051
- const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
2052
- const rectHeight = rectWithOffset.bottom - rectWithOffset.top;
2053
- const rectWidth = rectWithOffset.right - rectWithOffset.left;
2054
- const isInHiddenRect = hiddenRects.some((hiddenRect) => {
2055
- const bufferY = Math.min(.5 * rectHeight, 10);
2056
- const bufferX = Math.min(.5 * rectWidth, 10);
2057
- return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
2058
- });
2059
- if (rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect) setHidden(true);
2060
- else setHidden(false);
2090
+ const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hideOnInvisible ? () => (0, rxjs.combineLatest)([anchorRect$, hiddenRects$]).pipe((0, rxjs.map)(([rectWithOffset, hiddenRects]) => {
2091
+ const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
2092
+ const rectHeight = rectWithOffset.bottom - rectWithOffset.top;
2093
+ const rectWidth = rectWithOffset.right - rectWithOffset.left;
2094
+ const isInHiddenRect = hiddenRects.some((hiddenRect) => {
2095
+ const bufferY = Math.min(.5 * rectHeight, 10);
2096
+ const bufferX = Math.min(.5 * rectWidth, 10);
2097
+ return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
2061
2098
  });
2062
- return () => anchorRectSub.unsubscribe();
2063
- }, [
2064
- canvasElement,
2065
- hideOnInvisible,
2099
+ return rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect;
2100
+ })) : null, false, false, [
2066
2101
  anchorRect$,
2067
- hiddenRects$
2102
+ canvasElement,
2103
+ hiddenRects$,
2104
+ hideOnInvisible
2068
2105
  ]);
2069
2106
  if (hidden && hiddenType === "destroy") return null;
2070
2107
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RectPopup, {
@@ -2307,7 +2344,8 @@ function ComponentContainer(props) {
2307
2344
  */
2308
2345
  function useComponentsOfPart(part, injector) {
2309
2346
  var _injector$get;
2310
- const uiPartsService = (_injector$get = injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) !== null && _injector$get !== void 0 ? _injector$get : (0, _wendellhu_redi_react_bindings.useDependency)(IUIPartsService);
2347
+ const injectedUIPartsService = (0, _wendellhu_redi_react_bindings.useDependency)(IUIPartsService);
2348
+ const uiPartsService = (_injector$get = injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) !== null && _injector$get !== void 0 ? _injector$get : injectedUIPartsService;
2311
2349
  const changeInfo = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => uiPartsService.uiVisibleChange$.pipe((0, rxjs.filter)((ui) => ui.ui === part)), [part, uiPartsService]));
2312
2350
  const updateCounterRef = (0, react.useRef)(0);
2313
2351
  return (0, react.useMemo)(() => uiPartsService.isUIVisible(part) ? uiPartsService.getComponents(part) : /* @__PURE__ */ new Set(), [(0, _wendellhu_redi_react_bindings.useObservable)(() => uiPartsService.componentRegistered$.pipe((0, rxjs.filter)((key) => key === part), (0, rxjs.debounceTime)(200), (0, rxjs.map)(() => updateCounterRef.current += 1), (0, rxjs.startWith)(updateCounterRef.current += 1)), void 0, void 0, [
@@ -2484,33 +2522,14 @@ function CustomLabel(props) {
2484
2522
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
2485
2523
  const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
2486
2524
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
2487
- const [subscribedValue, setSubscribedValue] = (0, react.useState)(value);
2488
- const [realIcon, setRealIcon] = (0, react.useState)("");
2525
+ const subscribedValue = (0, _wendellhu_redi_react_bindings.useObservable)(value$ !== null && value$ !== void 0 ? value$ : null, value);
2526
+ const subscribedIcon = (0, _wendellhu_redi_react_bindings.useObservable)((0, rxjs.isObservable)(icon) ? icon : null, "");
2527
+ const realIcon = (0, rxjs.isObservable)(icon) ? subscribedIcon : icon !== null && icon !== void 0 ? icon : "";
2489
2528
  const nodes = [];
2490
2529
  let index = 0;
2491
- (0, react.useEffect)(() => {
2492
- if (value$) {
2493
- const subscription = value$.subscribe((v) => {
2494
- setSubscribedValue(v);
2495
- });
2496
- return () => {
2497
- subscription.unsubscribe();
2498
- };
2499
- }
2500
- }, [value$]);
2501
2530
  const realValue = (0, react.useMemo)(() => {
2502
2531
  return value !== null && value !== void 0 ? value : subscribedValue;
2503
2532
  }, [subscribedValue, value]);
2504
- (0, react.useEffect)(() => {
2505
- let subscription = null;
2506
- if ((0, rxjs.isObservable)(icon)) subscription = icon.subscribe((v) => {
2507
- setRealIcon(v);
2508
- });
2509
- else setRealIcon(icon !== null && icon !== void 0 ? icon : "");
2510
- return () => {
2511
- subscription === null || subscription === void 0 || subscription.unsubscribe();
2512
- };
2513
- }, [icon]);
2514
2533
  const isValid = (0, react.useMemo)(() => {
2515
2534
  if (realValue && typeof realValue === "string") return new _univerjs_core.ColorKit(realValue).isValid;
2516
2535
  return false;
@@ -2555,6 +2574,7 @@ function CustomLabel(props) {
2555
2574
  * @returns The menu item's status
2556
2575
  */
2557
2576
  function useToolbarItemStatus(menuItem) {
2577
+ var _selectionsValue$2;
2558
2578
  const { disabled$, hidden$, activated$, value$ } = menuItem;
2559
2579
  let selectionsValue$;
2560
2580
  if (isMenuButtonSelectorItem(menuItem)) {
@@ -2564,37 +2584,18 @@ function useToolbarItemStatus(menuItem) {
2564
2584
  selectionsValue$ = selections === null || selections === void 0 || (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.value$;
2565
2585
  }
2566
2586
  }
2567
- const [value, setValue] = (0, react.useState)();
2568
- const [disabled, setDisabled] = (0, react.useState)(false);
2569
- const [activated, setActivated] = (0, react.useState)(false);
2570
- const [hidden, setHidden] = (0, react.useState)(false);
2571
- const [selectionsValue, setSelectionsValue] = (0, react.useState)();
2572
- (0, react.useEffect)(() => {
2573
- const subscriptions = [];
2574
- disabled$ && subscriptions.push(disabled$.subscribe((disabled) => setDisabled(disabled)));
2575
- hidden$ && subscriptions.push(hidden$.subscribe((hidden) => setHidden(hidden)));
2576
- activated$ && subscriptions.push(activated$.subscribe((activated) => setActivated(activated)));
2577
- value$ && subscriptions.push(value$.subscribe((value) => {
2578
- setValue(value);
2579
- }));
2580
- selectionsValue$ && subscriptions.push(selectionsValue$.subscribe((value) => {
2581
- setSelectionsValue(value);
2582
- setValue(value);
2583
- }));
2584
- return () => subscriptions.forEach((subscription) => subscription.unsubscribe());
2585
- }, [
2586
- activated$,
2587
- disabled$,
2588
- hidden$,
2589
- value$,
2590
- selectionsValue$
2591
- ]);
2587
+ const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$ !== null && disabled$ !== void 0 ? disabled$ : null, false);
2588
+ const activated = (0, _wendellhu_redi_react_bindings.useObservable)(activated$ !== null && activated$ !== void 0 ? activated$ : null, false);
2589
+ const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hidden$ !== null && hidden$ !== void 0 ? hidden$ : null, false);
2592
2590
  return {
2593
2591
  disabled,
2594
- value,
2592
+ value: (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
2593
+ var _selectionsValue$;
2594
+ return (0, rxjs.merge)(value$ !== null && value$ !== void 0 ? value$ : rxjs.EMPTY, (_selectionsValue$ = selectionsValue$) !== null && _selectionsValue$ !== void 0 ? _selectionsValue$ : rxjs.EMPTY);
2595
+ }, [selectionsValue$, value$])),
2595
2596
  activated,
2596
2597
  hidden,
2597
- selectionsValue
2598
+ selectionsValue: (0, _wendellhu_redi_react_bindings.useObservable)((_selectionsValue$2 = selectionsValue$) !== null && _selectionsValue$2 !== void 0 ? _selectionsValue$2 : null)
2598
2599
  };
2599
2600
  }
2600
2601
  function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
@@ -2686,9 +2687,8 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
2686
2687
  var _option$label;
2687
2688
  const onChange = (v) => {
2688
2689
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
2689
- value: v,
2690
- label: option === null || option === void 0 ? void 0 : option.label,
2691
- commandId: option === null || option === void 0 ? void 0 : option.commandId
2690
+ ...option,
2691
+ value: v
2692
2692
  });
2693
2693
  };
2694
2694
  const hasCheckMark = typeof option.label === "string" || typeof option.label === "object" && ((_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.selectable) !== false;
@@ -2718,21 +2718,21 @@ function getOptionKey(option) {
2718
2718
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
2719
2719
  const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
2720
2720
  const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
2721
- const [hiddenStates, setHiddenStates] = (0, react.useState)({});
2722
- const [menuVersion, setMenuVersion] = (0, react.useState)(0);
2723
- (0, react.useEffect)(() => {
2724
- const subscription = menuManagerService.menuChanged$.subscribe(() => {
2725
- setMenuVersion((version) => version + 1);
2721
+ const resolveMenuItems = () => menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
2722
+ const menuItems = (0, _wendellhu_redi_react_bindings.useObservable)(() => menuManagerService.menuChanged$.pipe((0, rxjs.map)(resolveMenuItems), (0, rxjs.startWith)(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
2723
+ const hiddenStates = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
2724
+ const itemStates = menuItems.map((item) => {
2725
+ var _item$item$hidden$, _item$item;
2726
+ return (item.children ? (0, rxjs.combineLatest)(item.children.map((subItem) => {
2727
+ var _subItem$item$hidden$, _subItem$item;
2728
+ return (_subItem$item$hidden$ = (_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) !== null && _subItem$item$hidden$ !== void 0 ? _subItem$item$hidden$ : (0, rxjs.of)(false);
2729
+ })).pipe((0, rxjs.map)((hiddenValues) => hiddenValues.every(Boolean))) : (_item$item$hidden$ = (_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) !== null && _item$item$hidden$ !== void 0 ? _item$item$hidden$ : (0, rxjs.of)(false)).pipe((0, rxjs.map)((hidden) => [String(item.key), hidden]));
2726
2730
  });
2727
- return () => subscription.unsubscribe();
2728
- }, [menuManagerService]);
2729
- const menuItems = (0, react.useMemo)(() => {
2730
- return menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
2731
- }, [
2732
- menuId,
2733
- menuManagerService,
2734
- menuVersion
2735
- ]);
2731
+ return itemStates.length ? (0, rxjs.merge)(...itemStates).pipe((0, rxjs.scan)((states, [key, hidden]) => ({
2732
+ ...states,
2733
+ [key]: hidden
2734
+ }), {}), (0, rxjs.startWith)({})) : (0, rxjs.of)({});
2735
+ }, [menuItems]), {});
2736
2736
  const filteredMenuItems = (0, react.useMemo)(() => {
2737
2737
  return menuItems.filter((item) => {
2738
2738
  var _item$key;
@@ -2750,39 +2750,6 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2750
2750
  onOptionSelect(option);
2751
2751
  setDropdownVisible(false);
2752
2752
  }
2753
- (0, react.useEffect)(() => {
2754
- const subscriptions = [];
2755
- menuItems.forEach((item) => {
2756
- if (!item.children) {
2757
- var _item$item;
2758
- if ((_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.hidden$) {
2759
- const sub = item.item.hidden$.subscribe((hidden) => {
2760
- setHiddenStates((prev) => ({
2761
- ...prev,
2762
- [item.key]: hidden
2763
- }));
2764
- });
2765
- subscriptions.push(sub);
2766
- }
2767
- } else {
2768
- const sub = (0, rxjs.combineLatest)(item.children.map((subItem) => {
2769
- var _subItem$item$hidden$, _subItem$item;
2770
- return (_subItem$item$hidden$ = (_subItem$item = subItem.item) === null || _subItem$item === void 0 ? void 0 : _subItem$item.hidden$) !== null && _subItem$item$hidden$ !== void 0 ? _subItem$item$hidden$ : (0, rxjs.of)(false);
2771
- })).subscribe((hiddenValues) => {
2772
- const isAllHidden = hiddenValues.every((hidden) => hidden === true);
2773
- setHiddenStates((prev) => ({
2774
- ...prev,
2775
- [item.key]: isAllHidden
2776
- }));
2777
- });
2778
- subscriptions.push(sub);
2779
- }
2780
- });
2781
- return () => {
2782
- subscriptions.forEach((sub) => sub === null || sub === void 0 ? void 0 : sub.unsubscribe());
2783
- setHiddenStates({});
2784
- };
2785
- }, [menuItems]);
2786
2753
  if (slot) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownWrapper, {
2787
2754
  disabled,
2788
2755
  overlay: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
@@ -3009,7 +2976,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3009
2976
  if (disabled) return;
3010
2977
  let commandId = sId;
3011
2978
  if (option.id) commandId = option.id;
3012
- executeCommand(commandId, { value: option.value });
2979
+ const commandParams = typeof option.params === "function" ? option.params(option.value) : option.params;
2980
+ executeCommand(commandId, commandParams !== null && commandParams !== void 0 ? commandParams : { value: option.value });
3013
2981
  }
3014
2982
  function handleSelectionsValueChange(value) {
3015
2983
  if (disabled) return;
@@ -3017,7 +2985,10 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3017
2985
  }
3018
2986
  function handleClick() {
3019
2987
  if (disabled) return;
3020
- if (menuType === 2) executeCommand(bId, { value });
2988
+ if (menuType === 2) {
2989
+ const commandParams = typeof params === "function" ? params() : params;
2990
+ executeCommand(bId, commandParams !== null && commandParams !== void 0 ? commandParams : { value });
2991
+ }
3021
2992
  }
3022
2993
  if (menuType === 2) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3023
2994
  "data-u-command": id,
@@ -3082,7 +3053,6 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3082
3053
  function renderButtonType() {
3083
3054
  var _label$name;
3084
3055
  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 : "");
3085
- const commandValue = (value !== null && value !== void 0 ? value : typeof params === "function") ? params() : params;
3086
3056
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
3087
3057
  "data-u-command": id,
3088
3058
  className: "univer-text-sm",
@@ -3091,7 +3061,8 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
3091
3061
  disabled,
3092
3062
  onClick: () => {
3093
3063
  var _props$commandId;
3094
- return executeCommand((_props$commandId = props.commandId) !== null && _props$commandId !== void 0 ? _props$commandId : props.id, commandValue);
3064
+ const commandParams = typeof params === "function" ? params() : params;
3065
+ 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 });
3095
3066
  },
3096
3067
  onDoubleClick: () => props.subId && executeCommand(props.subId),
3097
3068
  children: isCustomComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
@@ -3668,6 +3639,7 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
3668
3639
  //#endregion
3669
3640
  //#region src/views/menu/desktop/TinyMenuGroup.tsx
3670
3641
  const EMPTY_HIDDEN_ITEM_IDS = [];
3642
+ const EMPTY_TINY_MENU_CHILDREN = [];
3671
3643
  const quickTileMenuButtonVariants = (0, _univerjs_design.cva)("univer-relative univer-box-border univer-flex univer-size-12 univer-w-full univer-appearance-none univer-flex-col univer-items-center univer-justify-center univer-gap-0.5 univer-rounded-lg univer-border-none univer-bg-white univer-p-0 univer-font-medium univer-text-gray-700 univer-outline-none univer-transition-all focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-700 dark:!univer-text-gray-100", {
3672
3644
  variants: {
3673
3645
  disabled: {
@@ -3735,52 +3707,24 @@ function QuickTileMenuItem(props) {
3735
3707
  });
3736
3708
  }
3737
3709
  function UITinyMenuGroup(props) {
3710
+ var _item$children;
3738
3711
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, hoverSuppressed, columns, sizeVariant = "default", layoutVariant = "default", onOptionSelect } = props;
3739
- const [activeItems, setActiveItems] = (0, react.useState)([]);
3740
- const [hiddenItems, setHiddenItems] = (0, react.useState)([]);
3741
3712
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
3742
3713
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3743
- (0, react.useEffect)(() => {
3744
- const { children } = item;
3745
- if (!children) return;
3746
- const observables = children.map((child) => {
3747
- var _child$item$activated, _child$item2;
3748
- return (0, _univerjs_core.convertObservableToBehaviorSubject)((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : (0, rxjs.of)(false), false);
3749
- });
3750
- const subscription = (0, rxjs.combineLatest)(observables).subscribe((activedArr) => {
3751
- const activeItems = [];
3752
- for (let index = 0; index < activedArr.length; index++) if (activedArr[index]) activeItems.push(getTinyMenuChildStateKey(children[index]));
3753
- setActiveItems(activeItems);
3754
- });
3755
- return () => {
3756
- subscription.unsubscribe();
3757
- observables.forEach((observable) => {
3758
- observable.complete();
3759
- });
3760
- };
3761
- }, [item]);
3762
- (0, react.useEffect)(() => {
3763
- const { children } = item;
3764
- if (!children) return;
3765
- const observables = children.map((child) => {
3766
- var _child$item$hidden$, _child$item3;
3767
- return (0, _univerjs_core.convertObservableToBehaviorSubject)((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : (0, rxjs.of)(false), false);
3768
- });
3769
- const subscription = (0, rxjs.combineLatest)(observables).subscribe((hiddenArr) => {
3770
- const hiddenItems = [];
3771
- for (let index = 0; index < hiddenArr.length; index++) if (hiddenArr[index]) hiddenItems.push(getTinyMenuChildStateKey(children[index]));
3772
- setHiddenItems(hiddenItems);
3773
- });
3774
- return () => {
3775
- subscription.unsubscribe();
3776
- observables.forEach((observable) => {
3777
- observable.complete();
3778
- });
3779
- };
3780
- }, [item]);
3714
+ const children = (_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : EMPTY_TINY_MENU_CHILDREN;
3715
+ const activeItems$ = (0, react.useMemo)(() => children.length ? (0, rxjs.combineLatest)(children.map((child) => {
3716
+ var _child$item$activated, _child$item2;
3717
+ return ((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
3718
+ })).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
3719
+ const hiddenItems$ = (0, react.useMemo)(() => children.length ? (0, rxjs.combineLatest)(children.map((child) => {
3720
+ var _child$item$hidden$, _child$item3;
3721
+ return ((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
3722
+ })).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
3723
+ const activeItems = (0, _wendellhu_redi_react_bindings.useObservable)(activeItems$, []);
3724
+ const hiddenItems = (0, _wendellhu_redi_react_bindings.useObservable)(hiddenItems$, []);
3781
3725
  const visibleChildren = (0, react.useMemo)(() => {
3782
- var _item$children;
3783
- return getVisibleTinyMenuChildren((_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : [], [...hiddenItems, ...hiddenItemIds]);
3726
+ var _item$children2;
3727
+ return getVisibleTinyMenuChildren((_item$children2 = item.children) !== null && _item$children2 !== void 0 ? _item$children2 : [], [...hiddenItems, ...hiddenItemIds]);
3784
3728
  }, [
3785
3729
  hiddenItemIds,
3786
3730
  hiddenItems,
@@ -3819,9 +3763,9 @@ function UITinyMenuGroup(props) {
3819
3763
  });
3820
3764
  }
3821
3765
  function UIQuickTileMenuGroup(props) {
3822
- var _item$children2;
3766
+ var _item$children3;
3823
3767
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
3824
- if (!((_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length)) return null;
3768
+ if (!((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length)) return null;
3825
3769
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3826
3770
  className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
3827
3771
  children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QuickTileMenuItem, {
@@ -4637,7 +4581,7 @@ function ContextMenuMenuItem(props) {
4637
4581
  }), hasSubmenu && submenuVisible && (submenuPortalContainer ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4638
4582
  ref: submenuElementRef,
4639
4583
  dir: direction,
4640
- ["data-u-context-menu-submenu"]: "true",
4584
+ "data-u-context-menu-submenu": "true",
4641
4585
  className: "univer-z-[1080] univer-w-max univer-max-w-[calc(100vw-16px)]",
4642
4586
  style: {
4643
4587
  position: "fixed",
@@ -4736,28 +4680,20 @@ function ContextMenuMenuItem(props) {
4736
4680
  });
4737
4681
  }
4738
4682
  function useContextGroupHiddenStates$1(menuSchemas) {
4739
- const [hiddenStates, setHiddenStates] = (0, react.useState)({});
4740
- (0, react.useEffect)(() => {
4741
- const subscriptions = menuSchemas.map((menuSchema) => {
4742
- var _menuSchema$children3;
4743
- if (!((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.length)) return null;
4744
- return (0, rxjs.combineLatest)(menuSchema.children.map((childSchema) => {
4683
+ return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
4684
+ const groupStates = menuSchemas.flatMap((menuSchema) => {
4685
+ var _menuSchema$children$, _menuSchema$children3;
4686
+ const hiddenObservables = (_menuSchema$children$ = (_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.map((childSchema) => {
4745
4687
  var _childSchema$item$hid, _childSchema$item;
4746
4688
  return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : (0, rxjs.of)(false);
4747
- })).subscribe((hiddenValues) => {
4748
- const isAllHidden = hiddenValues.every((hidden) => hidden === true);
4749
- setHiddenStates((state) => ({
4750
- ...state,
4751
- [menuSchema.key]: isAllHidden
4752
- }));
4753
- });
4689
+ })) !== null && _menuSchema$children$ !== void 0 ? _menuSchema$children$ : [];
4690
+ return hiddenObservables.length ? [(0, rxjs.combineLatest)(hiddenObservables).pipe((0, rxjs.map)((values) => [menuSchema.key, values.every(Boolean)]))] : [];
4754
4691
  });
4755
- return () => {
4756
- subscriptions.forEach((subscription) => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe());
4757
- setHiddenStates({});
4758
- };
4759
- }, [menuSchemas]);
4760
- return hiddenStates;
4692
+ return groupStates.length ? (0, rxjs.merge)(...groupStates).pipe((0, rxjs.scan)((states, [key, hidden]) => ({
4693
+ ...states,
4694
+ [key]: hidden
4695
+ }), {}), (0, rxjs.startWith)({})) : (0, rxjs.of)({});
4696
+ }, [menuSchemas]), {});
4761
4697
  }
4762
4698
 
4763
4699
  //#endregion
@@ -4935,6 +4871,7 @@ function DesktopContextMenu() {
4935
4871
  const MIN_SIDEBAR_WIDTH = 280;
4936
4872
  const MAX_SIDEBAR_WIDTH = 800;
4937
4873
  function Sidebar() {
4874
+ const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
4938
4875
  const sidebarService = (0, _wendellhu_redi_react_bindings.useDependency)(ISidebarService);
4939
4876
  const sidebarOptions = (0, _wendellhu_redi_react_bindings.useObservable)(sidebarService.sidebarOptions$);
4940
4877
  const scrollRef = (0, react.useRef)(null);
@@ -5041,7 +4978,7 @@ function Sidebar() {
5041
4978
  "data-u-comp": "sidebar",
5042
4979
  role: "complementary",
5043
4980
  "aria-expanded": !!(options === null || options === void 0 ? void 0 : options.visible),
5044
- "aria-label": "Sidebar panel",
4981
+ "aria-label": localeService.t("ui.sidebar.panel"),
5045
4982
  className: (0, _univerjs_design.clsx)("univer-relative univer-h-full univer-flex-shrink-0 univer-bg-white univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-white", {
5046
4983
  "univer-w-96 univer-translate-x-0": options === null || options === void 0 ? void 0 : options.visible,
5047
4984
  "univer-w-0 univer-translate-x-full": !(options === null || options === void 0 ? void 0 : options.visible)
@@ -5052,7 +4989,7 @@ function Sidebar() {
5052
4989
  onMouseDown: handleResizeMouseDown,
5053
4990
  role: "separator",
5054
4991
  "aria-orientation": "vertical",
5055
- "aria-label": "Resize sidebar",
4992
+ "aria-label": localeService.t("ui.sidebar.resize"),
5056
4993
  tabIndex: 0,
5057
4994
  onKeyDown: (e) => {
5058
4995
  if (!sidebarRef.current) return;
@@ -5081,7 +5018,7 @@ function Sidebar() {
5081
5018
  type: "button",
5082
5019
  className: "focus:univer-ring-primary-500/50 univer-cursor-pointer univer-appearance-none univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0 univer-text-gray-500 focus:univer-outline-none focus:univer-ring-2 dark:!univer-text-gray-300",
5083
5020
  onClick: handleClose,
5084
- "aria-label": "Close sidebar",
5021
+ "aria-label": localeService.t("ui.sidebar.close"),
5085
5022
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CloseIcon, {})
5086
5023
  })]
5087
5024
  }),
@@ -5326,39 +5263,23 @@ function DesktopWorkbenchContent(props) {
5326
5263
  sub.unsubscribe();
5327
5264
  };
5328
5265
  }, []);
5329
- const [darkMode, setDarkMode] = (0, react.useState)(false);
5266
+ const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$, themeService.darkMode);
5330
5267
  (0, react.useLayoutEffect)(() => {
5331
- const sub = themeService.darkMode$.subscribe((darkMode) => {
5332
- setDarkMode(darkMode);
5333
- if (darkMode) document.documentElement.classList.add("univer-dark");
5334
- else document.documentElement.classList.remove("univer-dark");
5335
- });
5336
- return () => {
5337
- sub.unsubscribe();
5338
- };
5339
- }, []);
5268
+ if (darkMode) document.documentElement.classList.add("univer-dark");
5269
+ else document.documentElement.classList.remove("univer-dark");
5270
+ }, [darkMode]);
5340
5271
  (0, react.useEffect)(() => {
5341
5272
  if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
5342
5273
  }, [onRendered]);
5343
- const [locale, setLocale] = (0, react.useState)(localeService.getLocales());
5344
- const [direction, setDirection] = (0, react.useState)(localeService.getDirection());
5274
+ const locale = (0, _wendellhu_redi_react_bindings.useObservable)(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
5275
+ const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
5345
5276
  const portalContainer = (0, react.useMemo)(() => document.createElement("div"), []);
5346
5277
  (0, react.useEffect)(() => {
5347
5278
  document.body.appendChild(portalContainer);
5348
- const subscriptions = [localeService.localeChanged$.subscribe(() => {
5349
- setLocale(localeService.getLocales());
5350
- }), localeService.direction$.subscribe(() => {
5351
- setDirection(localeService.getDirection());
5352
- })];
5353
5279
  return () => {
5354
- subscriptions.forEach((subscription) => subscription.unsubscribe());
5355
5280
  document.body.removeChild(portalContainer);
5356
5281
  };
5357
- }, [
5358
- localeService,
5359
- mountContainer,
5360
- portalContainer
5361
- ]);
5282
+ }, [mountContainer, portalContainer]);
5362
5283
  (0, react.useEffect)(() => {
5363
5284
  portalContainer.dir = direction;
5364
5285
  }, [direction, portalContainer]);
@@ -5518,17 +5439,15 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
5518
5439
  //#endregion
5519
5440
  //#region src/controllers/ui/ui-desktop.controller.ts
5520
5441
  let DesktopUIController = class DesktopUIController extends SingleUnitUIController {
5521
- constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService, _componentManager) {
5442
+ constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
5522
5443
  super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
5523
5444
  this._config = _config;
5524
- this._componentManager = _componentManager;
5525
5445
  menuManagerService.mergeMenu(menuSchema);
5526
5446
  this._initBuiltinComponents(uiPartsService);
5527
5447
  this._bootstrapWorkbench();
5528
5448
  }
5529
5449
  dispose() {
5530
5450
  super.dispose();
5531
- this._componentManager.dispose();
5532
5451
  }
5533
5452
  bootstrap(callback) {
5534
5453
  return bootstrap$1(this._injector, this._config, callback);
@@ -5546,8 +5465,7 @@ DesktopUIController = __decorate([
5546
5465
  __decorateParam(4, ILayoutService),
5547
5466
  __decorateParam(5, _univerjs_core.IUniverInstanceService),
5548
5467
  __decorateParam(6, IMenuManagerService),
5549
- __decorateParam(7, IUIPartsService),
5550
- __decorateParam(8, (0, _univerjs_core.Inject)(ComponentManager))
5468
+ __decorateParam(7, IUIPartsService)
5551
5469
  ], DesktopUIController);
5552
5470
  function bootstrap$1(injector, options, callback) {
5553
5471
  let mountContainer;
@@ -5580,7 +5498,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
5580
5498
  //#endregion
5581
5499
  //#region package.json
5582
5500
  var name = "@univerjs/ui";
5583
- var version = "1.0.0-alpha.3";
5501
+ var version = "1.0.0-alpha.4";
5584
5502
 
5585
5503
  //#endregion
5586
5504
  //#region src/views/color-picker/interface.ts
@@ -20734,72 +20652,207 @@ function CategoryIcon(props) {
20734
20652
  //#region src/services/font.service.ts
20735
20653
  const IFontService = (0, _univerjs_core.createIdentifier)("univer.font-service");
20736
20654
  const DEFAULT_FONT_LIST = [
20737
- {
20738
- value: "Arial",
20739
- label: "ui.fontFamily.arial",
20740
- category: "sans-serif"
20741
- },
20742
- {
20743
- value: "Times New Roman",
20744
- label: "ui.fontFamily.times-new-roman",
20745
- category: "serif"
20746
- },
20747
- {
20748
- value: "Tahoma",
20749
- label: "ui.fontFamily.tahoma",
20750
- category: "sans-serif"
20751
- },
20752
- {
20753
- value: "Verdana",
20754
- label: "ui.fontFamily.verdana",
20755
- category: "sans-serif"
20756
- },
20757
- {
20758
- value: "Microsoft YaHei",
20759
- label: "ui.fontFamily.microsoft-yahei",
20760
- category: "sans-serif"
20761
- },
20762
- {
20763
- value: "SimSun",
20764
- label: "ui.fontFamily.simsun",
20765
- category: "serif"
20766
- },
20767
- {
20768
- value: "SimHei",
20769
- label: "ui.fontFamily.simhei",
20770
- category: "sans-serif"
20771
- },
20772
- {
20773
- value: "Kaiti",
20774
- label: "ui.fontFamily.kaiti",
20775
- category: "serif"
20776
- },
20777
- {
20778
- value: "FangSong",
20779
- label: "ui.fontFamily.fangsong",
20780
- category: "serif"
20781
- },
20782
- {
20783
- value: "NSimSun",
20784
- label: "ui.fontFamily.nsimsun",
20785
- category: "serif"
20786
- },
20787
- {
20788
- value: "STXinwei",
20789
- label: "ui.fontFamily.stxinwei",
20790
- category: "serif"
20791
- },
20792
- {
20793
- value: "STXingkai",
20794
- label: "ui.fontFamily.stxingkai",
20795
- category: "serif"
20796
- },
20797
- {
20798
- value: "STLiti",
20799
- label: "ui.fontFamily.stliti",
20800
- category: "serif"
20801
- }
20802
- ];
20655
+ "宋体",
20656
+ "Arial",
20657
+ "Baskerville",
20658
+ "Comic Sans MS",
20659
+ "Courier New",
20660
+ "Helvetica",
20661
+ "Times New Roman",
20662
+ "Verdana",
20663
+ "Apple LiGothic",
20664
+ "Apple LiSung",
20665
+ "Hei",
20666
+ "Kai",
20667
+ "LiHei Pro",
20668
+ "LiSong Pro",
20669
+ "STFangsong",
20670
+ "STHeiti",
20671
+ "STKaiti",
20672
+ "STSong",
20673
+ "报隶-繁",
20674
+ "报隶-简",
20675
+ "冬青黑体简体中文",
20676
+ "黑体-繁",
20677
+ "黑体-简",
20678
+ "华文仿宋",
20679
+ "华文楷体",
20680
+ "华文宋体",
20681
+ "楷体-繁",
20682
+ "楷体-简",
20683
+ "兰亭黑-繁",
20684
+ "兰亭黑-简",
20685
+ "隶变-繁",
20686
+ "隶变-简",
20687
+ "凌慧体-繁",
20688
+ "凌慧体-简",
20689
+ "翩翩体-繁",
20690
+ "翩翩体-简",
20691
+ "苹方-繁",
20692
+ "苹方-港",
20693
+ "苹方-简",
20694
+ "手札体-繁",
20695
+ "手札体-简",
20696
+ "宋体-繁",
20697
+ "宋体-简",
20698
+ "娃娃体-繁",
20699
+ "娃娃体-简",
20700
+ "魏碑-繁",
20701
+ "魏碑-简",
20702
+ "行楷-繁",
20703
+ "行楷-简",
20704
+ "雅痞-繁",
20705
+ "雅痞-简",
20706
+ "圆体-繁",
20707
+ "圆体-简",
20708
+ "Arial Black",
20709
+ "Big Caslon",
20710
+ "Courier",
20711
+ "Didot",
20712
+ "Futura",
20713
+ "Georgia",
20714
+ "Helvetica Neue",
20715
+ "Optima",
20716
+ "Times",
20717
+ "Tahoma",
20718
+ "BIZ UDGothic",
20719
+ "BIZ UDMincho",
20720
+ "Hiragino Maru Gothic Pro",
20721
+ "Hiragino Maru Gothic ProN",
20722
+ "Hiragino Mincho Pro",
20723
+ "Hiragino Mincho ProN",
20724
+ "Hiragino Sans",
20725
+ "Klee",
20726
+ "Osaka",
20727
+ "Toppan Bunkyu Gothic",
20728
+ "Toppan Bunkyu Midashi Gothic",
20729
+ "Toppan Bunkyu Midashi Mincho",
20730
+ "Toppan Bunkyu Mincho",
20731
+ "Tsukushi A Round Gothic",
20732
+ "Tsukushi B Round Gothic",
20733
+ "YuKyokasho",
20734
+ "YuKyokasho Yoko",
20735
+ "YuMincho +36p Kana",
20736
+ "American Typewriter",
20737
+ "Andale Mono",
20738
+ "Apple Chancery",
20739
+ "Apple SD Gothic Neo",
20740
+ "Apple Symbols",
20741
+ "AppleGothic",
20742
+ "AppleMyungjo",
20743
+ "Arial Unicode MS",
20744
+ "Athelas",
20745
+ "Avenir",
20746
+ "Avenir Next",
20747
+ "Avenir Next Condensed",
20748
+ "Ayuthaya",
20749
+ "Bangla MN",
20750
+ "Bangla Sangam MN",
20751
+ "Bauhaus 93",
20752
+ "Bodoni 72",
20753
+ "Bodoni 72 Oldstyle",
20754
+ "Bodoni 72 Smallcaps",
20755
+ "Bodoni Ornaments",
20756
+ "Bookshelf Symbol 7",
20757
+ "Bradley Hand",
20758
+ "Chalkboard",
20759
+ "Chalkboard SE",
20760
+ "Chalkduster",
20761
+ "Charter",
20762
+ "Cochin",
20763
+ "Copperplate",
20764
+ "Devanagari Sangam MN",
20765
+ "Din Alternate",
20766
+ "Euphemia UCAS",
20767
+ "Galvji",
20768
+ "Geneva",
20769
+ "Gill Sans",
20770
+ "Gujarati Sangam MN",
20771
+ "GungSeo",
20772
+ "Gurmukhi MN",
20773
+ "Gurmukhi Sangam MN",
20774
+ "HeadLineA",
20775
+ "Herculanum",
20776
+ "Hiragino Kaku Gothic Pro",
20777
+ "Hiragino Kaku Gothic ProN",
20778
+ "Hiragino Kaku Gothic Std",
20779
+ "Hiragino Kaku Gothic StdN",
20780
+ "Hoefler Text",
20781
+ "Impact",
20782
+ "InaiMathi",
20783
+ "Iowan Old Style",
20784
+ "Kannada MN",
20785
+ "Kannada Sangam MN",
20786
+ "Kefa",
20787
+ "Khmer MN",
20788
+ "Khmer Sangam MN",
20789
+ "Kohinoor Bangla",
20790
+ "Kohinoor Devanagari",
20791
+ "Kohinoor Telugu",
20792
+ "Krungthep",
20793
+ "Lao MN",
20794
+ "Lao Sangam MN",
20795
+ "Lucida Grande",
20796
+ "Luminari",
20797
+ "Malayalam MN",
20798
+ "Malayalam Sangam MN",
20799
+ "Marion",
20800
+ "Marker Felt",
20801
+ "Menlo",
20802
+ "Microsoft Sans Serif",
20803
+ "Modern No. 20",
20804
+ "Monaco",
20805
+ "Mukta Mahee",
20806
+ "Nanum Brush Script",
20807
+ "Nanum Gothic",
20808
+ "Nanum Myeongjo",
20809
+ "Nanum Pen Script",
20810
+ "Noteworthy",
20811
+ "Oriya MN",
20812
+ "Oriya Sangam MN",
20813
+ "Palatino",
20814
+ "Papyrus",
20815
+ "PCMyungjo",
20816
+ "Phosphate",
20817
+ "PilGi",
20818
+ "Plantagenet Cherokee",
20819
+ "PT Mono",
20820
+ "PT Sans",
20821
+ "PT Sans Caption",
20822
+ "PT Serif",
20823
+ "PT Serif Caption",
20824
+ "Rockwell",
20825
+ "Sathu",
20826
+ "Savoye LET",
20827
+ "Seravek",
20828
+ "Shree Devanagari 714",
20829
+ "SignPainter",
20830
+ "Silom",
20831
+ "Sinhala MN",
20832
+ "Sinhala Sangam MN",
20833
+ "Skia",
20834
+ "Snell Roundhand",
20835
+ "STIXGeneral",
20836
+ "Sukhumvit Set",
20837
+ "Superclarendon",
20838
+ "Tamil MN",
20839
+ "Tamil Sangam MN",
20840
+ "Telugu MN",
20841
+ "Telugu Sangam MN",
20842
+ "Trattatello",
20843
+ "Trebuchet MS",
20844
+ "Webdings",
20845
+ "Wingdings",
20846
+ "Wingdings 2",
20847
+ "Wingdings 3",
20848
+ "YuGothic",
20849
+ "YuGothic Light",
20850
+ "YuGothic Medium",
20851
+ "Zapfino"
20852
+ ].map((value) => ({
20853
+ value,
20854
+ label: value
20855
+ }));
20803
20856
  let FontService = class FontService {
20804
20857
  constructor(_configService) {
20805
20858
  this._configService = _configService;
@@ -20882,17 +20935,8 @@ FontService = __decorate([__decorateParam(0, _univerjs_core.IConfigService)], Fo
20882
20935
  //#region src/views/font-family/use-font-list.ts
20883
20936
  function useFontList() {
20884
20937
  const fontService = (0, _wendellhu_redi_react_bindings.useDependency)(IFontService);
20885
- const [fonts, setFonts] = (0, react.useState)(() => fontService.getFonts());
20886
- (0, react.useEffect)(() => {
20887
- const subscription = fontService.fonts$.subscribe((fonts) => {
20888
- setFonts(fonts);
20889
- });
20890
- return () => {
20891
- subscription.unsubscribe();
20892
- };
20893
- }, [fontService]);
20894
20938
  return {
20895
- fonts,
20939
+ fonts: (0, _wendellhu_redi_react_bindings.useObservable)(fontService.fonts$, fontService.getFonts()),
20896
20940
  fontService
20897
20941
  };
20898
20942
  }
@@ -21189,6 +21233,97 @@ const HeadingItem = (props) => {
21189
21233
  };
21190
21234
  const HEADING_ITEM_COMPONENT = "UI_COMPONENT_HEADING_ITEM";
21191
21235
 
21236
+ //#endregion
21237
+ //#region src/views/slider/ZoomInput.tsx
21238
+ function ZoomInput(props) {
21239
+ const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
21240
+ const { value = 100, min = 0, max = 400, shortcuts, disabled = false, className, onChange } = props;
21241
+ const isEditingRef = (0, react.useRef)(false);
21242
+ const [listVisible, setListVisible] = (0, react.useState)(false);
21243
+ const [inputValue, setInputValue] = (0, react.useState)(() => `${value}%`);
21244
+ (0, react.useEffect)(() => {
21245
+ if (!isEditingRef.current) setInputValue(`${value}%`);
21246
+ }, [value]);
21247
+ function clampValue(value) {
21248
+ return Math.min(Math.max(value, min), max);
21249
+ }
21250
+ function handleSelect(value) {
21251
+ if (disabled) return;
21252
+ setListVisible(false);
21253
+ onChange === null || onChange === void 0 || onChange(value);
21254
+ }
21255
+ function parseInput(rawValue) {
21256
+ const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
21257
+ if (normalizedValue === "") return null;
21258
+ const parsedValue = Number(normalizedValue);
21259
+ if (!Number.isFinite(parsedValue)) return null;
21260
+ return Math.round(clampValue(parsedValue));
21261
+ }
21262
+ function handleFocus() {
21263
+ if (disabled) return;
21264
+ isEditingRef.current = true;
21265
+ setInputValue(String(value));
21266
+ }
21267
+ function commitInput() {
21268
+ if (disabled || !isEditingRef.current) return;
21269
+ const parsedValue = parseInput(inputValue);
21270
+ isEditingRef.current = false;
21271
+ if (parsedValue == null) {
21272
+ setInputValue(`${value}%`);
21273
+ return;
21274
+ }
21275
+ setInputValue(`${parsedValue}%`);
21276
+ if (parsedValue !== value) onChange === null || onChange === void 0 || onChange(parsedValue);
21277
+ }
21278
+ function handleKeyDown(e) {
21279
+ e.stopPropagation();
21280
+ if (e.key === "Enter") {
21281
+ e.preventDefault();
21282
+ commitInput();
21283
+ e.currentTarget.blur();
21284
+ }
21285
+ }
21286
+ const items = [{
21287
+ type: "radio",
21288
+ value: value.toString(),
21289
+ options: shortcuts.map((item) => ({
21290
+ value: item.toString(),
21291
+ label: `${item}%`
21292
+ })),
21293
+ onSelect: (value) => handleSelect(+value)
21294
+ }];
21295
+ const MoreDownIcon = iconManager.get("MoreDownIcon");
21296
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21297
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-white dark:!univer-border-gray-600 dark:!univer-bg-gray-800", className, { "univer-opacity-60": disabled }),
21298
+ onClick: (e) => e.stopPropagation(),
21299
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
21300
+ className: "univer-box-border univer-h-6 univer-w-[52px] univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-[52px] [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
21301
+ inputClass: "univer-w-[52px]",
21302
+ size: "mini",
21303
+ value: inputValue,
21304
+ disabled,
21305
+ type: "text",
21306
+ onChange: setInputValue,
21307
+ onFocus: handleFocus,
21308
+ onBlur: commitInput,
21309
+ onKeyDown: handleKeyDown
21310
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
21311
+ align: "end",
21312
+ items,
21313
+ open: listVisible,
21314
+ disabled,
21315
+ onOpenChange: setListVisible,
21316
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
21317
+ className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
21318
+ size: "small",
21319
+ variant: "text",
21320
+ disabled,
21321
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
21322
+ })
21323
+ })]
21324
+ });
21325
+ }
21326
+
21192
21327
  //#endregion
21193
21328
  //#region src/views/slider/Slider.tsx
21194
21329
  const SLIDER_WIDTH = 116;
@@ -21203,18 +21338,12 @@ function Slider(props) {
21203
21338
  const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
21204
21339
  const isRtl = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection()) === "rtl";
21205
21340
  const sliderInnerRailRef = (0, react.useRef)(null);
21206
- const isEditingZoomRef = (0, react.useRef)(false);
21207
21341
  const dragValueRef = (0, react.useRef)(value);
21208
21342
  const pendingDragValueRef = (0, react.useRef)(null);
21209
21343
  const lastCommittedDragValueRef = (0, react.useRef)(value);
21210
21344
  const dragCommitTimerRef = (0, react.useRef)(null);
21211
- const [zoomListVisible, setZoomListVisible] = (0, react.useState)(false);
21212
21345
  const [isDragging, setIsDragging] = (0, react.useState)(false);
21213
21346
  const [dragValue, setDragValue] = (0, react.useState)(value);
21214
- const [zoomInputValue, setZoomInputValue] = (0, react.useState)(() => `${value}%`);
21215
- (0, react.useEffect)(() => {
21216
- if (!isEditingZoomRef.current) setZoomInputValue(`${value}%`);
21217
- }, [value]);
21218
21347
  (0, react.useEffect)(() => () => {
21219
21348
  clearDragCommitTimer();
21220
21349
  }, []);
@@ -21313,61 +21442,11 @@ function Slider(props) {
21313
21442
  window.addEventListener("pointerup", onPointerUp);
21314
21443
  window.addEventListener("pointerout", onPointerOut);
21315
21444
  }
21316
- function handleSelectZoomLevel(value) {
21317
- if (disabled) return;
21318
- setZoomListVisible(false);
21319
- onChange && onChange(value);
21320
- }
21321
- function parseExactZoomInput(rawValue) {
21322
- const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
21323
- if (normalizedValue === "") return null;
21324
- const parsedValue = Number(normalizedValue);
21325
- if (!Number.isFinite(parsedValue)) return null;
21326
- return Math.round(clampValue(parsedValue));
21327
- }
21328
- function handleExactZoomFocus() {
21329
- if (disabled) return;
21330
- isEditingZoomRef.current = true;
21331
- setZoomInputValue(String(value));
21332
- }
21333
- function commitExactZoomInput() {
21334
- if (disabled) return;
21335
- if (!isEditingZoomRef.current) return;
21336
- const parsedValue = parseExactZoomInput(zoomInputValue);
21337
- isEditingZoomRef.current = false;
21338
- if (parsedValue == null) {
21339
- setZoomInputValue(`${value}%`);
21340
- return;
21341
- }
21342
- setZoomInputValue(`${parsedValue}%`);
21343
- if (parsedValue !== value) onChange && onChange(parsedValue);
21344
- }
21345
- function handleExactZoomChange(value) {
21346
- setZoomInputValue(value);
21347
- }
21348
- function handleInputKeyDown(e) {
21349
- e.stopPropagation();
21350
- if (e.key === "Enter") {
21351
- e.preventDefault();
21352
- commitExactZoomInput();
21353
- e.currentTarget.blur();
21354
- }
21355
- }
21356
- const items = [{
21357
- type: "radio",
21358
- value: value.toString(),
21359
- options: shortcuts.map((item) => ({
21360
- value: item.toString(),
21361
- label: `${item}%`
21362
- })),
21363
- onSelect: (value) => handleSelectZoomLevel(+value)
21364
- }];
21365
21445
  const visualValue = isDragging ? dragValue : value;
21366
21446
  const sliderOffset = Math.min(Math.max((_getSliderOffset = getSliderOffset(visualValue)) !== null && _getSliderOffset !== void 0 ? _getSliderOffset : 0, 0), 100);
21367
21447
  const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
21368
21448
  const ReduceIcon = iconManager.get("ReduceIcon");
21369
21449
  const IncreaseIcon = iconManager.get("IncreaseIcon");
21370
- const MoreDownIcon = iconManager.get("MoreDownIcon");
21371
21450
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21372
21451
  className: (0, _univerjs_design.clsx)("univer-flex univer-select-none univer-items-center univer-gap-1.5", { "univer-cursor-not-allowed": disabled }),
21373
21452
  children: [
@@ -21425,33 +21504,13 @@ function Slider(props) {
21425
21504
  onClick: () => handleStep(10),
21426
21505
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IncreaseIcon, { className: "univer-text-gray-500" })
21427
21506
  }),
21428
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21429
- className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-white dark:!univer-border-gray-600 dark:!univer-bg-gray-800", { "univer-opacity-60": disabled }),
21430
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
21431
- className: "univer-box-border univer-h-6 univer-w-[52px] univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-[52px] [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
21432
- inputClass: "univer-w-[52px]",
21433
- size: "mini",
21434
- value: zoomInputValue,
21435
- disabled,
21436
- type: "text",
21437
- onChange: handleExactZoomChange,
21438
- onFocus: handleExactZoomFocus,
21439
- onBlur: commitExactZoomInput,
21440
- onKeyDown: handleInputKeyDown
21441
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
21442
- align: "end",
21443
- items,
21444
- open: zoomListVisible,
21445
- disabled,
21446
- onOpenChange: setZoomListVisible,
21447
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
21448
- className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
21449
- size: "small",
21450
- variant: "text",
21451
- disabled,
21452
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
21453
- })
21454
- })]
21507
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomInput, {
21508
+ value,
21509
+ min,
21510
+ max,
21511
+ shortcuts,
21512
+ disabled,
21513
+ onChange
21455
21514
  })
21456
21515
  ]
21457
21516
  });
@@ -21484,11 +21543,13 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
21484
21543
  }
21485
21544
  _registerIcons() {
21486
21545
  this.disposeWithMe(this._iconManager.register({
21546
+ ExpandIcon: _univerjs_icons.ExpandIcon,
21487
21547
  IncreaseIcon: _univerjs_icons.IncreaseIcon,
21488
21548
  MoreDownIcon: _univerjs_icons.MoreDownIcon,
21489
21549
  RedoIcon: _univerjs_icons.RedoIcon,
21490
21550
  ReduceIcon: _univerjs_icons.ReduceIcon,
21491
21551
  ShortcutIcon: _univerjs_icons.ShortcutIcon,
21552
+ ShrinkIcon: _univerjs_icons.ShrinkIcon,
21492
21553
  UndoIcon: _univerjs_icons.UndoIcon
21493
21554
  }));
21494
21555
  }
@@ -21579,7 +21640,7 @@ function MobileRibbon(props) {
21579
21640
  type: "button",
21580
21641
  className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-size-7 univer-rounded-md univer-text-gray-500 univer-transition-colors hover:univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700 dark:active:!univer-bg-gray-600", { "univer-opacity-40": activeIndex === 0 }),
21581
21642
  disabled: activeIndex === 0,
21582
- "aria-label": "Previous",
21643
+ "aria-label": localeService.t("ui.navigation.previous"),
21583
21644
  onClick: () => selectTab(activeIndex - 1),
21584
21645
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, { className: "univer-rotate-180 univer-text-sm" })
21585
21646
  })
@@ -21616,7 +21677,7 @@ function MobileRibbon(props) {
21616
21677
  dark:active:!univer-bg-gray-600
21617
21678
  `, { "univer-opacity-40": activeIndex >= ribbon.length - 1 }),
21618
21679
  disabled: activeIndex >= ribbon.length - 1,
21619
- "aria-label": "Next",
21680
+ "aria-label": localeService.t("ui.navigation.next"),
21620
21681
  onClick: () => selectTab(activeIndex + 1),
21621
21682
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: "univer-text-sm" })
21622
21683
  }), hasHeaderMenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -21636,7 +21697,7 @@ function MobileRibbon(props) {
21636
21697
  dark:!univer-text-gray-300
21637
21698
  `, { "univer-opacity-30": !canScrollLeft }),
21638
21699
  disabled: !canScrollLeft,
21639
- "aria-label": "Previous",
21700
+ "aria-label": localeService.t("ui.navigation.previous"),
21640
21701
  onClick: () => scrollToolbar("left"),
21641
21702
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, { className: "univer-text-sm" })
21642
21703
  }),
@@ -21665,7 +21726,7 @@ function MobileRibbon(props) {
21665
21726
  dark:!univer-text-gray-300
21666
21727
  `, { "univer-opacity-30": !canScrollRight }),
21667
21728
  disabled: !canScrollRight,
21668
- "aria-label": "Next",
21729
+ "aria-label": localeService.t("ui.navigation.next"),
21669
21730
  onClick: () => scrollToolbar("right"),
21670
21731
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: "univer-text-sm" })
21671
21732
  })
@@ -21680,6 +21741,7 @@ function MobileMenu(props) {
21680
21741
  var _viewStack;
21681
21742
  const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
21682
21743
  const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
21744
+ const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21683
21745
  const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
21684
21746
  const [viewStack, setViewStack] = (0, react.useState)([]);
21685
21747
  const menuSchemas = (0, react.useMemo)(() => {
@@ -21708,7 +21770,7 @@ function MobileMenu(props) {
21708
21770
  children: [
21709
21771
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
21710
21772
  type: "button",
21711
- "aria-label": "Back",
21773
+ "aria-label": localeService.t("ui.navigation.back"),
21712
21774
  className: "univer-flex univer-size-8 univer-appearance-none univer-items-center univer-justify-center univer-rounded-full univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-700 hover:univer-bg-gray-100 active:univer-bg-gray-200",
21713
21775
  onClick: closeView,
21714
21776
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, { className: "univer-text-base" })
@@ -21944,30 +22006,20 @@ function getMenuSchemaTitle(schema, localeService) {
21944
22006
  return schema.key;
21945
22007
  }
21946
22008
  function useContextGroupHiddenStates(menuSchemas) {
21947
- const [hiddenStates, setHiddenStates] = (0, react.useState)({});
21948
- (0, react.useEffect)(() => {
21949
- const subscriptions = menuSchemas.map((menuSchema) => {
22009
+ return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => {
22010
+ const groupStates = menuSchemas.flatMap((menuSchema) => {
21950
22011
  var _menuSchema$children;
21951
- if (!((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length)) return null;
21952
- const hiddenObservables = getLeafItemSchemas(menuSchema.children).map((childSchema) => {
22012
+ const hiddenObservables = ((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length) ? getLeafItemSchemas(menuSchema.children).map((childSchema) => {
21953
22013
  var _childSchema$item$hid, _childSchema$item;
21954
22014
  return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : (0, rxjs.of)(false);
21955
- });
21956
- if (!hiddenObservables.length) return null;
21957
- return (0, rxjs.combineLatest)(hiddenObservables).subscribe((hiddenValues) => {
21958
- const isAllHidden = hiddenValues.every((hidden) => hidden === true);
21959
- setHiddenStates((state) => ({
21960
- ...state,
21961
- [menuSchema.key]: isAllHidden
21962
- }));
21963
- });
22015
+ }) : [];
22016
+ return hiddenObservables.length ? [(0, rxjs.combineLatest)(hiddenObservables).pipe((0, rxjs.map)((values) => [menuSchema.key, values.every(Boolean)]))] : [];
21964
22017
  });
21965
- return () => {
21966
- subscriptions.forEach((subscription) => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe());
21967
- setHiddenStates({});
21968
- };
21969
- }, [menuSchemas]);
21970
- return hiddenStates;
22018
+ return groupStates.length ? (0, rxjs.merge)(...groupStates).pipe((0, rxjs_operators.scan)((states, [key, hidden]) => ({
22019
+ ...states,
22020
+ [key]: hidden
22021
+ }), {}), (0, rxjs_operators.startWith)({})) : (0, rxjs.of)({});
22022
+ }, [menuSchemas]), {});
21971
22023
  }
21972
22024
  function getLeafItemSchemas(schemas) {
21973
22025
  return schemas.reduce((acc, schema) => {
@@ -22110,20 +22162,12 @@ function MobileWorkbench(props) {
22110
22162
  const leftSidebarComponents = useComponentsOfPart("left-sidebar");
22111
22163
  const globalComponents = useComponentsOfPart("global");
22112
22164
  const toolbarComponents = useComponentsOfPart("toolbar");
22113
- const [darkMode, setDarkMode] = (0, react.useState)(false);
22114
- (0, react.useEffect)(() => {
22115
- const sub = themeService.darkMode$.subscribe((darkMode) => {
22116
- setDarkMode(darkMode);
22117
- });
22118
- return () => {
22119
- sub.unsubscribe();
22120
- };
22121
- }, []);
22165
+ const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$, themeService.darkMode);
22122
22166
  (0, react.useEffect)(() => {
22123
22167
  if (contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
22124
22168
  }, [onRendered]);
22125
- const [locale, setLocale] = (0, react.useState)(localeService.getLocales());
22126
- const [direction, setDirection] = (0, react.useState)(localeService.getDirection());
22169
+ const locale = (0, _wendellhu_redi_react_bindings.useObservable)(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
22170
+ const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
22127
22171
  const portalContainer = (0, react.useMemo)(() => document.createElement("div"), []);
22128
22172
  (0, react.useLayoutEffect)(() => {
22129
22173
  const sub = themeService.currentTheme$.subscribe((theme) => {
@@ -22135,20 +22179,10 @@ function MobileWorkbench(props) {
22135
22179
  }, []);
22136
22180
  (0, react.useEffect)(() => {
22137
22181
  document.body.appendChild(portalContainer);
22138
- const subscriptions = [localeService.localeChanged$.subscribe(() => {
22139
- setLocale(localeService.getLocales());
22140
- }), localeService.direction$.subscribe(() => {
22141
- setDirection(localeService.getDirection());
22142
- })];
22143
22182
  return () => {
22144
- subscriptions.forEach((subscription) => subscription.unsubscribe());
22145
22183
  document.body.removeChild(portalContainer);
22146
22184
  };
22147
- }, [
22148
- localeService,
22149
- mountContainer,
22150
- portalContainer
22151
- ]);
22185
+ }, [mountContainer, portalContainer]);
22152
22186
  (0, react.useEffect)(() => {
22153
22187
  portalContainer.dir = direction;
22154
22188
  }, [direction, portalContainer]);
@@ -22213,17 +22247,15 @@ function MobileWorkbench(props) {
22213
22247
  //#endregion
22214
22248
  //#region src/controllers/ui/ui-mobile.controller.ts
22215
22249
  let MobileUIController = class MobileUIController extends SingleUnitUIController {
22216
- constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService, _componentManager) {
22250
+ constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
22217
22251
  super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
22218
22252
  this._config = _config;
22219
- this._componentManager = _componentManager;
22220
22253
  menuManagerService.mergeMenu(menuSchema);
22221
22254
  this._initBuiltinComponents(uiPartsService);
22222
22255
  this._bootstrapWorkbench();
22223
22256
  }
22224
22257
  dispose() {
22225
22258
  super.dispose();
22226
- this._componentManager.dispose();
22227
22259
  }
22228
22260
  bootstrap(callback) {
22229
22261
  return bootstrap(this._injector, this._config, callback);
@@ -22241,8 +22273,7 @@ MobileUIController = __decorate([
22241
22273
  __decorateParam(4, ILayoutService),
22242
22274
  __decorateParam(5, _univerjs_core.IUniverInstanceService),
22243
22275
  __decorateParam(6, IMenuManagerService),
22244
- __decorateParam(7, IUIPartsService),
22245
- __decorateParam(8, (0, _univerjs_core.Inject)(ComponentManager))
22276
+ __decorateParam(7, IUIPartsService)
22246
22277
  ], MobileUIController);
22247
22278
  function bootstrap(injector, options, callback) {
22248
22279
  let mountContainer;
@@ -22276,9 +22307,10 @@ const INotificationService = (0, _univerjs_core.createIdentifier)("ui.notificati
22276
22307
  //#region src/services/before-close/before-close.service.ts
22277
22308
  const IBeforeCloseService = (0, _univerjs_core.createIdentifier)("univer.ui.before-close-service");
22278
22309
  let DesktopBeforeCloseService = class DesktopBeforeCloseService extends _univerjs_core.Disposable {
22279
- constructor(_notificationService) {
22310
+ constructor(_notificationService, _localeService) {
22280
22311
  super();
22281
22312
  this._notificationService = _notificationService;
22313
+ this._localeService = _localeService;
22282
22314
  _defineProperty(this, "_beforeUnloadCallbacks", []);
22283
22315
  _defineProperty(this, "_onCloseCallbacks", []);
22284
22316
  _defineProperty(this, "_beforeUnloadHandler", void 0);
@@ -22289,7 +22321,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends _univerj
22289
22321
  if (message) {
22290
22322
  this._notificationService.show({
22291
22323
  type: "error",
22292
- title: "Some changes are not saved",
22324
+ title: this._localeService.t("ui.beforeClose.title"),
22293
22325
  content: message
22294
22326
  });
22295
22327
  if (typeof event === "undefined") event = window.event;
@@ -22326,7 +22358,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends _univerj
22326
22358
  window.addEventListener("unload", this._unloadHandler);
22327
22359
  }
22328
22360
  };
22329
- DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService)], DesktopBeforeCloseService);
22361
+ DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))], DesktopBeforeCloseService);
22330
22362
 
22331
22363
  //#endregion
22332
22364
  //#region src/utils/html.ts
@@ -22759,17 +22791,7 @@ const ContextConfirm = (props) => {
22759
22791
  });
22760
22792
  };
22761
22793
  function ConfirmPart() {
22762
- const confirmService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfirmService);
22763
- const [confirmOptions, setConfirmOptions] = (0, react.useState)([]);
22764
- (0, react.useEffect)(() => {
22765
- const subscription = confirmService.confirmOptions$.subscribe((options) => {
22766
- setConfirmOptions(options);
22767
- });
22768
- return () => {
22769
- subscription.unsubscribe();
22770
- };
22771
- }, []);
22772
- const props = confirmOptions.map((options) => {
22794
+ const props = (0, _wendellhu_redi_react_bindings.useObservable)((0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfirmService).confirmOptions$, []).map((options) => {
22773
22795
  const { children, title, ...restProps } = options;
22774
22796
  const confirmProps = restProps;
22775
22797
  for (const key of ["children", "title"]) {
@@ -22846,14 +22868,7 @@ const IDialogService = (0, _univerjs_core.createIdentifier)("univer.ui.dialog-se
22846
22868
  //#endregion
22847
22869
  //#region src/views/components/dialog-part/DialogPart.tsx
22848
22870
  function DialogPart() {
22849
- const dialogService = (0, _wendellhu_redi_react_bindings.useDependency)(IDialogService);
22850
- const [dialogOptions, setDialogOptions] = (0, react.useState)([]);
22851
- (0, react.useEffect)(() => {
22852
- const subscription = dialogService.getDialogs$().subscribe((options) => {
22853
- setDialogOptions(options);
22854
- });
22855
- return () => subscription.unsubscribe();
22856
- }, []);
22871
+ const dialogOptions = (0, _wendellhu_redi_react_bindings.useObservable)((0, _wendellhu_redi_react_bindings.useDependency)(IDialogService).getDialogs$(), []);
22857
22872
  const attrs = (0, react.useMemo)(() => dialogOptions.map((options) => {
22858
22873
  const { children, title, footer, ...restProps } = options;
22859
22874
  const dialogProps = restProps;
@@ -24258,15 +24273,31 @@ function extractFontFamily(styleStr) {
24258
24273
  //#endregion
24259
24274
  //#region src/views/components/dom/Print.tsx
24260
24275
  const PrintFloatDomSingle = (0, react.memo)((props) => {
24276
+ const { layer } = props;
24277
+ return typeof layer.componentKey === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RegisteredPrintFloatDomSingle, {
24278
+ ...props,
24279
+ componentKey: layer.componentKey
24280
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PrintFloatDomSingleContent, {
24281
+ ...props,
24282
+ Component: layer.componentKey
24283
+ });
24284
+ });
24285
+ function RegisteredPrintFloatDomSingle(props) {
24286
+ const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
24287
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PrintFloatDomSingleContent, {
24288
+ ...props,
24289
+ Component: componentManager.get(props.componentKey)
24290
+ });
24291
+ }
24292
+ function PrintFloatDomSingleContent(props) {
24261
24293
  var _position$startY, _position$startX;
24262
- const { layer, id, position } = props;
24294
+ const { layer, id, position, Component } = props;
24263
24295
  const univerInstanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
24264
24296
  const domRef = (0, react.useRef)(null);
24265
24297
  const innerDomRef = (0, react.useRef)(null);
24266
24298
  const transformRef = (0, react.useRef)(`transform: rotate(${position === null || position === void 0 ? void 0 : position.rotate}deg) translate(${position === null || position === void 0 ? void 0 : position.startX}px, ${position === null || position === void 0 ? void 0 : position.startY}px)`);
24267
24299
  const topRef = (0, react.useRef)((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
24268
24300
  const leftRef = (0, react.useRef)((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
24269
- const Component = typeof layer.componentKey === "string" ? (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager).get(layer.componentKey) : layer.componentKey;
24270
24301
  const layerProps = (0, react.useMemo)(() => ({
24271
24302
  data: layer.data,
24272
24303
  ...layer.props
@@ -24321,7 +24352,7 @@ const PrintFloatDomSingle = (0, react.memo)((props) => {
24321
24352
  children: component
24322
24353
  })
24323
24354
  });
24324
- });
24355
+ }
24325
24356
 
24326
24357
  //#endregion
24327
24358
  //#region src/views/progress-bar/ProgressBar.tsx
@@ -24632,6 +24663,7 @@ exports.SingleCanvasPopup = SingleCanvasPopup;
24632
24663
  exports.SingleUnitUIController = SingleUnitUIController;
24633
24664
  exports.Slider = Slider;
24634
24665
  exports.ThemeSwitcherService = ThemeSwitcherService;
24666
+ exports.ToggleFullscreenOperation = ToggleFullscreenOperation;
24635
24667
  exports.ToggleShortcutPanelOperation = ToggleShortcutPanelOperation;
24636
24668
  exports.ToolbarButton = ToolbarButton;
24637
24669
  exports.ToolbarItem = ToolbarItem;
@@ -24660,6 +24692,7 @@ Object.defineProperty(exports, 'WithDependency', {
24660
24692
  }
24661
24693
  });
24662
24694
  exports.ZIndexManager = ZIndexManager;
24695
+ exports.ZoomInput = ZoomInput;
24663
24696
  Object.defineProperty(exports, 'connectDependencies', {
24664
24697
  enumerable: true,
24665
24698
  get: function () {