@univerjs/ui 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +10 -7
- package/lib/cjs/index.js +136 -115
- package/lib/es/facade.js +10 -7
- package/lib/es/index.js +103 -82
- package/lib/facade.js +10 -7
- package/lib/index.css +5 -8
- package/lib/index.js +103 -82
- package/lib/types/common/component-manager.d.ts +17 -1
- package/lib/types/facade/f-univer.d.ts +5 -3
- package/lib/types/views/components/ribbon/ToolbarButton.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +18 -18
- package/package.json +10 -10
package/lib/es/facade.js
CHANGED
|
@@ -3,7 +3,7 @@ import { FBase, FEnum, FUniver } from "@univerjs/core/facade";
|
|
|
3
3
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
4
4
|
import { BuiltInUIPart, ComponentManager, CopyCommand, IDialogService, IFontService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, IUIPartsService, KeyCode, MenuItemType, MenuManagerPosition, PasteCommand, RibbonPosition, RibbonStartGroup, UI_PLUGIN_CONFIG_KEY, connectInjector } from "@univerjs/ui";
|
|
5
5
|
|
|
6
|
-
//#region \0@oxc-project+runtime@0.
|
|
6
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
7
7
|
function _typeof(o) {
|
|
8
8
|
"@babel/helpers - typeof";
|
|
9
9
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,7 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
18
18
|
function toPrimitive(t, r) {
|
|
19
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
20
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region \0@oxc-project+runtime@0.
|
|
30
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
31
31
|
function toPropertyKey(t) {
|
|
32
32
|
var i = toPrimitive(t, "string");
|
|
33
33
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
38
38
|
function _defineProperty(e, r, t) {
|
|
39
39
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
40
|
value: t,
|
|
@@ -45,7 +45,7 @@ function _defineProperty(e, r, t) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
48
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
49
49
|
function __decorateParam(paramIndex, decorator) {
|
|
50
50
|
return function(target, key) {
|
|
51
51
|
decorator(target, key, paramIndex);
|
|
@@ -53,7 +53,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region \0@oxc-project+runtime@0.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
57
57
|
function __decorate(decorators, target, key, desc) {
|
|
58
58
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
59
59
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -434,7 +434,10 @@ var FUniverUIMixin = class extends FUniver {
|
|
|
434
434
|
}
|
|
435
435
|
registerComponent(name, component, options) {
|
|
436
436
|
const componentManager = this._injector.get(ComponentManager);
|
|
437
|
-
return this.disposeWithMe(componentManager.register(name, component,
|
|
437
|
+
return this.disposeWithMe(componentManager.register(name, component, {
|
|
438
|
+
...options,
|
|
439
|
+
override: (options === null || options === void 0 ? void 0 : options.override) ?? true
|
|
440
|
+
}));
|
|
438
441
|
}
|
|
439
442
|
setCurrent(unitId) {
|
|
440
443
|
if (!this._injector.get(IRenderManagerService).getRenderUnitById(unitId)) throw new Error("Unit not found");
|
package/lib/es/index.js
CHANGED
|
@@ -55,7 +55,7 @@ function getAttributeValue(target, name) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
59
59
|
function _typeof(o) {
|
|
60
60
|
"@babel/helpers - typeof";
|
|
61
61
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -66,7 +66,7 @@ function _typeof(o) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region \0@oxc-project+runtime@0.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
70
70
|
function toPrimitive(t, r) {
|
|
71
71
|
if ("object" != _typeof(t) || !t) return t;
|
|
72
72
|
var e = t[Symbol.toPrimitive];
|
|
@@ -79,14 +79,14 @@ function toPrimitive(t, r) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
|
-
//#region \0@oxc-project+runtime@0.
|
|
82
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
83
83
|
function toPropertyKey(t) {
|
|
84
84
|
var i = toPrimitive(t, "string");
|
|
85
85
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
|
-
//#region \0@oxc-project+runtime@0.
|
|
89
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
90
90
|
function _defineProperty(e, r, t) {
|
|
91
91
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
92
92
|
value: t,
|
|
@@ -97,7 +97,7 @@ function _defineProperty(e, r, t) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
//#endregion
|
|
100
|
-
//#region \0@oxc-project+runtime@0.
|
|
100
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
101
101
|
function __decorateParam(paramIndex, decorator) {
|
|
102
102
|
return function(target, key) {
|
|
103
103
|
decorator(target, key, paramIndex);
|
|
@@ -105,7 +105,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
//#endregion
|
|
108
|
-
//#region \0@oxc-project+runtime@0.
|
|
108
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
109
109
|
function __decorate(decorators, target, key, desc) {
|
|
110
110
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
111
111
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -307,7 +307,8 @@ const ToggleShortcutPanelOperation = {
|
|
|
307
307
|
shortcutPanelService.open();
|
|
308
308
|
sidebarService.open({
|
|
309
309
|
header: { title: "ui.shortcut-panel.title" },
|
|
310
|
-
children: { label: ShortcutPanelComponentName }
|
|
310
|
+
children: { label: ShortcutPanelComponentName },
|
|
311
|
+
onClose: () => shortcutPanelService.close()
|
|
311
312
|
});
|
|
312
313
|
}
|
|
313
314
|
return true;
|
|
@@ -321,6 +322,7 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
321
322
|
super();
|
|
322
323
|
this._logService = _logService;
|
|
323
324
|
_defineProperty(this, "_components", /* @__PURE__ */ new Map());
|
|
325
|
+
_defineProperty(this, "_overrides", /* @__PURE__ */ new Map());
|
|
324
326
|
_defineProperty(this, "reactUtils", {
|
|
325
327
|
createElement,
|
|
326
328
|
useEffect,
|
|
@@ -330,19 +332,27 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
330
332
|
return component;
|
|
331
333
|
} });
|
|
332
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Register before the component is first rendered; mounted views do not subscribe to registry changes.
|
|
337
|
+
* Disposing an override reveals the current default, if it is still registered.
|
|
338
|
+
* @throws When another override is already registered for this name.
|
|
339
|
+
*/
|
|
333
340
|
register(name, component, options) {
|
|
334
|
-
const { framework = "react" } = options
|
|
341
|
+
const { framework = "react", override = false } = options ?? {};
|
|
342
|
+
const components = override ? this._overrides : this._components;
|
|
335
343
|
if (framework === "vue3" && !this._handler.vue3) throw new Error("[ComponentManager] Vue3 support is no longer built-in since v0.9.0, please install @univerjs/ui-adapter-vue3 plugin.");
|
|
336
|
-
if (
|
|
344
|
+
if (components.has(name)) {
|
|
337
345
|
var _this$_logService;
|
|
346
|
+
if (override) throw new Error(`[ComponentManager] Component ${name} already has an override.`);
|
|
338
347
|
(_this$_logService = this._logService) === null || _this$_logService === void 0 || _this$_logService.warn("[ComponentManager]", `Component ${name} already exists.`);
|
|
339
348
|
}
|
|
340
|
-
|
|
349
|
+
const registration = {
|
|
341
350
|
framework,
|
|
342
351
|
component
|
|
343
|
-
}
|
|
352
|
+
};
|
|
353
|
+
components.set(name, registration);
|
|
344
354
|
return toDisposable(() => {
|
|
345
|
-
|
|
355
|
+
if (components.get(name) === registration) components.delete(name);
|
|
346
356
|
});
|
|
347
357
|
}
|
|
348
358
|
setHandler(framework, handler) {
|
|
@@ -350,15 +360,25 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
350
360
|
}
|
|
351
361
|
get(name) {
|
|
352
362
|
if (!name) return;
|
|
353
|
-
const value = this._components.get(name);
|
|
363
|
+
const value = this._overrides.get(name) ?? this._components.get(name);
|
|
354
364
|
if (!value) return;
|
|
355
365
|
const frameworkHandler = this._handler[value.framework];
|
|
356
366
|
if (!frameworkHandler) throw new Error(`[ComponentManager] No handler found for framework: ${value.framework}`);
|
|
357
367
|
return frameworkHandler(value.component, name);
|
|
358
368
|
}
|
|
369
|
+
/** Check for a built-in default independently of any active host override. */
|
|
370
|
+
hasDefault(name) {
|
|
371
|
+
return this._components.has(name);
|
|
372
|
+
}
|
|
373
|
+
/** Remove the default registration. Overrides can only be removed through their registration disposable. */
|
|
359
374
|
delete(name) {
|
|
360
375
|
this._components.delete(name);
|
|
361
376
|
}
|
|
377
|
+
dispose() {
|
|
378
|
+
super.dispose();
|
|
379
|
+
this._components.clear();
|
|
380
|
+
this._overrides.clear();
|
|
381
|
+
}
|
|
362
382
|
};
|
|
363
383
|
ComponentManager = __decorate([__decorateParam(0, Optional(ILogService))], ComponentManager);
|
|
364
384
|
|
|
@@ -1654,27 +1674,33 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1654
1674
|
this._initRibbonSubscription();
|
|
1655
1675
|
}
|
|
1656
1676
|
setActivatedTab(tab) {
|
|
1677
|
+
if (this._disposed) return;
|
|
1657
1678
|
if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
|
|
1658
1679
|
this._activatedTab$.next(tab);
|
|
1659
1680
|
}
|
|
1660
1681
|
showContextualTab(tab, options) {
|
|
1682
|
+
if (this._disposed) return;
|
|
1661
1683
|
this._visibleContextualTabs.add(tab);
|
|
1662
1684
|
this._updateRibbon();
|
|
1663
1685
|
if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
|
|
1664
1686
|
}
|
|
1665
1687
|
hideContextualTab(tab) {
|
|
1688
|
+
if (this._disposed) return;
|
|
1666
1689
|
if (!this._visibleContextualTabs.delete(tab)) return;
|
|
1667
1690
|
this._updateRibbon();
|
|
1668
1691
|
}
|
|
1669
1692
|
hideAllContextualTabs() {
|
|
1693
|
+
if (this._disposed) return;
|
|
1670
1694
|
if (this._visibleContextualTabs.size === 0) return;
|
|
1671
1695
|
this._visibleContextualTabs.clear();
|
|
1672
1696
|
this._updateRibbon();
|
|
1673
1697
|
}
|
|
1674
1698
|
setCollapsedIds(ids) {
|
|
1699
|
+
if (this._disposed) return;
|
|
1675
1700
|
this._collapsedIds$.next(ids);
|
|
1676
1701
|
}
|
|
1677
1702
|
setFakeToolbarVisible(visible) {
|
|
1703
|
+
if (this._disposed) return;
|
|
1678
1704
|
this._fakeToolbarVisible$.next(visible);
|
|
1679
1705
|
}
|
|
1680
1706
|
_initRibbonSubscription() {
|
|
@@ -1684,15 +1710,16 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1684
1710
|
}
|
|
1685
1711
|
_updateRibbon() {
|
|
1686
1712
|
var _this$_hiddenSubscrip;
|
|
1713
|
+
if (this._disposed) return;
|
|
1687
1714
|
const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
|
|
1688
1715
|
const hiddenObservableMap = [];
|
|
1689
|
-
const
|
|
1716
|
+
const menusWithHiddenState = [];
|
|
1690
1717
|
for (const group of ribbon) if (group.children) {
|
|
1691
1718
|
for (const item of group.children) if (item.children) for (const child of item.children) {
|
|
1692
1719
|
var _child$item;
|
|
1693
1720
|
if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
|
|
1694
1721
|
hiddenObservableMap.push(child.item.hidden$);
|
|
1695
|
-
|
|
1722
|
+
menusWithHiddenState.push(child);
|
|
1696
1723
|
}
|
|
1697
1724
|
}
|
|
1698
1725
|
}
|
|
@@ -1704,10 +1731,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1704
1731
|
}
|
|
1705
1732
|
this._hiddenSubscription = combineLatest(hiddenObservableMap.map((hidden$) => hidden$.pipe(startWith$1(false)))).pipe(distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
|
|
1706
1733
|
const newRibbon = [];
|
|
1707
|
-
const
|
|
1708
|
-
if (hidden) return hiddenKeyMap[index];
|
|
1709
|
-
return null;
|
|
1710
|
-
}).filter((item) => !!item);
|
|
1734
|
+
const hiddenMenus = new Set(menusWithHiddenState.filter((_, index) => hiddenMap[index]));
|
|
1711
1735
|
for (const group of ribbon) {
|
|
1712
1736
|
var _group$children, _newGroup$children2;
|
|
1713
1737
|
const newGroup = {
|
|
@@ -1723,7 +1747,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1723
1747
|
let shouldAddItem = true;
|
|
1724
1748
|
if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
|
|
1725
1749
|
var _newItem$children2;
|
|
1726
|
-
for (const child of item.children) if (!
|
|
1750
|
+
for (const child of item.children) if (!hiddenMenus.has(child)) {
|
|
1727
1751
|
var _newItem$children;
|
|
1728
1752
|
(_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
|
|
1729
1753
|
}
|
|
@@ -1744,6 +1768,10 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1744
1768
|
}
|
|
1745
1769
|
this._setRibbon(newRibbon);
|
|
1746
1770
|
});
|
|
1771
|
+
if (this._disposed) {
|
|
1772
|
+
this._hiddenSubscription.unsubscribe();
|
|
1773
|
+
this._hiddenSubscription = null;
|
|
1774
|
+
}
|
|
1747
1775
|
}
|
|
1748
1776
|
_filterContextualTabs(ribbon) {
|
|
1749
1777
|
this._contextualTabs.clear();
|
|
@@ -1770,6 +1798,10 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1770
1798
|
}
|
|
1771
1799
|
dispose() {
|
|
1772
1800
|
var _this$_hiddenSubscrip2;
|
|
1801
|
+
if (this._disposed) return;
|
|
1802
|
+
super.dispose();
|
|
1803
|
+
this._visibleContextualTabs.clear();
|
|
1804
|
+
this._contextualTabs.clear();
|
|
1773
1805
|
(_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
|
|
1774
1806
|
this._hiddenSubscription = null;
|
|
1775
1807
|
this._ribbon$.next([]);
|
|
@@ -1777,7 +1809,6 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
|
|
|
1777
1809
|
this._activatedTab$.complete();
|
|
1778
1810
|
this._collapsedIds$.complete();
|
|
1779
1811
|
this._fakeToolbarVisible$.complete();
|
|
1780
|
-
super.dispose();
|
|
1781
1812
|
}
|
|
1782
1813
|
};
|
|
1783
1814
|
DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
|
|
@@ -3500,7 +3531,7 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
3500
3531
|
*/
|
|
3501
3532
|
const toolbarButtonClassName = `
|
|
3502
3533
|
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
3503
|
-
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-
|
|
3534
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-0 univer-py-0
|
|
3504
3535
|
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
3505
3536
|
dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
3506
3537
|
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
@@ -4031,7 +4062,7 @@ const toolbarSelectorRootVariants = cva("univer-toolbar-selector-root univer-ani
|
|
|
4031
4062
|
false: "univer-text-gray-900 dark:!univer-text-gray-0"
|
|
4032
4063
|
},
|
|
4033
4064
|
active: {
|
|
4034
|
-
true: "univer-bg-gray-200",
|
|
4065
|
+
true: "univer-bg-gray-200 dark:!univer-bg-gray-500",
|
|
4035
4066
|
false: ""
|
|
4036
4067
|
}
|
|
4037
4068
|
},
|
|
@@ -4302,7 +4333,7 @@ function RibbonGrid({ groups, title, className, ...props }) {
|
|
|
4302
4333
|
const placements = placeRibbonGridItems(group.children ?? []);
|
|
4303
4334
|
return /* @__PURE__ */ jsxs("div", {
|
|
4304
4335
|
"data-u-comp": "ribbon-grid-group",
|
|
4305
|
-
className: "univer-relative univer-box-border univer-flex univer-
|
|
4336
|
+
className: "univer-relative univer-box-border univer-flex univer-shrink-0 univer-flex-col univer-px-2",
|
|
4306
4337
|
children: [/* @__PURE__ */ jsx("div", {
|
|
4307
4338
|
"data-testid": "ribbon-grid-group-grid",
|
|
4308
4339
|
className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-[repeat(2,1.5rem)] univer-content-center univer-gap-2 univer-py-2 [&>div>span>span]:univer-h-full",
|
|
@@ -4721,52 +4752,6 @@ var ContextMenuHostService = class extends Disposable {
|
|
|
4721
4752
|
}
|
|
4722
4753
|
};
|
|
4723
4754
|
|
|
4724
|
-
//#endregion
|
|
4725
|
-
//#region src/views/hooks/layout.ts
|
|
4726
|
-
/**
|
|
4727
|
-
* These hooks are used for browser layout
|
|
4728
|
-
* Prefer to client-side
|
|
4729
|
-
*/
|
|
4730
|
-
/**
|
|
4731
|
-
* Allow the element to scroll when its height over the container height
|
|
4732
|
-
* @param element
|
|
4733
|
-
* Container means the window view that the element displays in.
|
|
4734
|
-
* Recommend pass the sheet mountContainer as container
|
|
4735
|
-
* @param container
|
|
4736
|
-
*/
|
|
4737
|
-
function useScrollYOverContainer(element, container) {
|
|
4738
|
-
const updater = useEvent(() => {
|
|
4739
|
-
if (!element || !container) return;
|
|
4740
|
-
const elStyle = element.style;
|
|
4741
|
-
const { y, height } = element.getBoundingClientRect();
|
|
4742
|
-
const containerRect = container.getBoundingClientRect();
|
|
4743
|
-
const scrolled = element.scrollHeight > height;
|
|
4744
|
-
const isOverViewport = y < 0 || y + height > containerRect.height;
|
|
4745
|
-
if (!isOverViewport && !scrolled) {
|
|
4746
|
-
elStyle.overflowY = "";
|
|
4747
|
-
elStyle.maxHeight = "";
|
|
4748
|
-
return;
|
|
4749
|
-
}
|
|
4750
|
-
if (isOverViewport) {
|
|
4751
|
-
elStyle.overflowY = "auto";
|
|
4752
|
-
elStyle.maxHeight = y < 0 ? `${element.scrollHeight + y}px` : `${containerRect.height - y}px`;
|
|
4753
|
-
}
|
|
4754
|
-
});
|
|
4755
|
-
useEffect(() => {
|
|
4756
|
-
if (!isBrowser() || !element || !container) return;
|
|
4757
|
-
updater();
|
|
4758
|
-
const resizeObserver = new ResizeObserver(updater);
|
|
4759
|
-
resizeObserver.observe(element);
|
|
4760
|
-
return () => {
|
|
4761
|
-
resizeObserver.disconnect();
|
|
4762
|
-
};
|
|
4763
|
-
}, [element, container]);
|
|
4764
|
-
}
|
|
4765
|
-
function useConfigValue(configKey) {
|
|
4766
|
-
const configService = useDependency(IConfigService);
|
|
4767
|
-
return useObservable(useMemo(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
|
|
4768
|
-
}
|
|
4769
|
-
|
|
4770
4755
|
//#endregion
|
|
4771
4756
|
//#region src/views/hooks/prevent-browser-zoom.ts
|
|
4772
4757
|
/**
|
|
@@ -5432,7 +5417,6 @@ function ContextMenuPanel(props) {
|
|
|
5432
5417
|
menuSessionVersion
|
|
5433
5418
|
]);
|
|
5434
5419
|
const submenuPortalContainer = ((_layoutService$rootCo = layoutService.rootContainerElement) === null || _layoutService$rootCo === void 0 || (_layoutService$rootCo = _layoutService$rootCo.ownerDocument) === null || _layoutService$rootCo === void 0 ? void 0 : _layoutService$rootCo.body) ?? (typeof document !== "undefined" ? document.body : null);
|
|
5435
|
-
useScrollYOverContainer(menuElement, layoutService.rootContainerElement);
|
|
5436
5420
|
useEffect(() => {
|
|
5437
5421
|
if (!menuElement) return;
|
|
5438
5422
|
return preventBrowserZoomInContainers([menuElement]);
|
|
@@ -6524,6 +6508,52 @@ function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
|
|
|
6524
6508
|
});
|
|
6525
6509
|
}
|
|
6526
6510
|
|
|
6511
|
+
//#endregion
|
|
6512
|
+
//#region src/views/hooks/layout.ts
|
|
6513
|
+
/**
|
|
6514
|
+
* These hooks are used for browser layout
|
|
6515
|
+
* Prefer to client-side
|
|
6516
|
+
*/
|
|
6517
|
+
/**
|
|
6518
|
+
* Allow the element to scroll when its height over the container height
|
|
6519
|
+
* @param element
|
|
6520
|
+
* Container means the window view that the element displays in.
|
|
6521
|
+
* Recommend pass the sheet mountContainer as container
|
|
6522
|
+
* @param container
|
|
6523
|
+
*/
|
|
6524
|
+
function useScrollYOverContainer(element, container) {
|
|
6525
|
+
const updater = useEvent(() => {
|
|
6526
|
+
if (!element || !container) return;
|
|
6527
|
+
const elStyle = element.style;
|
|
6528
|
+
const { y, height } = element.getBoundingClientRect();
|
|
6529
|
+
const containerRect = container.getBoundingClientRect();
|
|
6530
|
+
const scrolled = element.scrollHeight > height;
|
|
6531
|
+
const isOverViewport = y < 0 || y + height > containerRect.height;
|
|
6532
|
+
if (!isOverViewport && !scrolled) {
|
|
6533
|
+
elStyle.overflowY = "";
|
|
6534
|
+
elStyle.maxHeight = "";
|
|
6535
|
+
return;
|
|
6536
|
+
}
|
|
6537
|
+
if (isOverViewport) {
|
|
6538
|
+
elStyle.overflowY = "auto";
|
|
6539
|
+
elStyle.maxHeight = y < 0 ? `${element.scrollHeight + y}px` : `${containerRect.height - y}px`;
|
|
6540
|
+
}
|
|
6541
|
+
});
|
|
6542
|
+
useEffect(() => {
|
|
6543
|
+
if (!isBrowser() || !element || !container) return;
|
|
6544
|
+
updater();
|
|
6545
|
+
const resizeObserver = new ResizeObserver(updater);
|
|
6546
|
+
resizeObserver.observe(element);
|
|
6547
|
+
return () => {
|
|
6548
|
+
resizeObserver.disconnect();
|
|
6549
|
+
};
|
|
6550
|
+
}, [element, container]);
|
|
6551
|
+
}
|
|
6552
|
+
function useConfigValue(configKey) {
|
|
6553
|
+
const configService = useDependency(IConfigService);
|
|
6554
|
+
return useObservable(useMemo(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
|
|
6555
|
+
}
|
|
6556
|
+
|
|
6527
6557
|
//#endregion
|
|
6528
6558
|
//#region src/views/hooks/update-effect.ts
|
|
6529
6559
|
/**
|
|
@@ -7005,7 +7035,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
7005
7035
|
//#endregion
|
|
7006
7036
|
//#region package.json
|
|
7007
7037
|
var name = "@univerjs/ui";
|
|
7008
|
-
var version = "1.0
|
|
7038
|
+
var version = "1.1.0";
|
|
7009
7039
|
|
|
7010
7040
|
//#endregion
|
|
7011
7041
|
//#region src/views/color-picker/interface.ts
|
|
@@ -24528,7 +24558,7 @@ function MobileSchemaRow(props) {
|
|
|
24528
24558
|
if (disabled) return;
|
|
24529
24559
|
onExecute === null || onExecute === void 0 || onExecute({
|
|
24530
24560
|
commandId: menuItem.commandId,
|
|
24531
|
-
value: nextValue,
|
|
24561
|
+
value: typeof value === "number" && isRealNum(nextValue) ? Number(nextValue) : nextValue,
|
|
24532
24562
|
id: menuItem.id,
|
|
24533
24563
|
label: schema.key,
|
|
24534
24564
|
params: menuItem.params
|
|
@@ -26532,18 +26562,9 @@ function DialogItem(props) {
|
|
|
26532
26562
|
const ownerDocument = document;
|
|
26533
26563
|
const opener = ownerDocument.activeElement;
|
|
26534
26564
|
const owner = getEmbedBoundaryOwner(opener);
|
|
26535
|
-
const ownerWindow = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.defaultView;
|
|
26536
|
-
const handleCompositionEscape = (event) => {
|
|
26537
|
-
if (event.key === "Escape" && event.isComposing && event.target instanceof Element && event.target.closest("[role=\"dialog\"]") === dialogRef.current) {
|
|
26538
|
-
event.preventDefault();
|
|
26539
|
-
event.stopPropagation();
|
|
26540
|
-
}
|
|
26541
|
-
};
|
|
26542
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.addEventListener("keydown", handleCompositionEscape, true);
|
|
26543
26565
|
return () => {
|
|
26544
26566
|
openRef.current = false;
|
|
26545
26567
|
const content = dialogRef.current;
|
|
26546
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.removeEventListener("keydown", handleCompositionEscape, true);
|
|
26547
26568
|
if (props.mask === false) return;
|
|
26548
26569
|
queueMicrotask(() => {
|
|
26549
26570
|
if (openRef.current) return;
|
package/lib/facade.js
CHANGED
|
@@ -3,7 +3,7 @@ import { FBase, FEnum, FUniver } from "@univerjs/core/facade";
|
|
|
3
3
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
4
4
|
import { BuiltInUIPart, ComponentManager, CopyCommand, IDialogService, IFontService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, IUIPartsService, KeyCode, MenuItemType, MenuManagerPosition, PasteCommand, RibbonPosition, RibbonStartGroup, UI_PLUGIN_CONFIG_KEY, connectInjector } from "@univerjs/ui";
|
|
5
5
|
|
|
6
|
-
//#region \0@oxc-project+runtime@0.
|
|
6
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
7
7
|
function _typeof(o) {
|
|
8
8
|
"@babel/helpers - typeof";
|
|
9
9
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,7 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
18
18
|
function toPrimitive(t, r) {
|
|
19
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
20
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region \0@oxc-project+runtime@0.
|
|
30
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
31
31
|
function toPropertyKey(t) {
|
|
32
32
|
var i = toPrimitive(t, "string");
|
|
33
33
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
38
38
|
function _defineProperty(e, r, t) {
|
|
39
39
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
40
|
value: t,
|
|
@@ -45,7 +45,7 @@ function _defineProperty(e, r, t) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
48
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
49
49
|
function __decorateParam(paramIndex, decorator) {
|
|
50
50
|
return function(target, key) {
|
|
51
51
|
decorator(target, key, paramIndex);
|
|
@@ -53,7 +53,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region \0@oxc-project+runtime@0.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
57
57
|
function __decorate(decorators, target, key, desc) {
|
|
58
58
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
59
59
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -434,7 +434,10 @@ var FUniverUIMixin = class extends FUniver {
|
|
|
434
434
|
}
|
|
435
435
|
registerComponent(name, component, options) {
|
|
436
436
|
const componentManager = this._injector.get(ComponentManager);
|
|
437
|
-
return this.disposeWithMe(componentManager.register(name, component,
|
|
437
|
+
return this.disposeWithMe(componentManager.register(name, component, {
|
|
438
|
+
...options,
|
|
439
|
+
override: (options === null || options === void 0 ? void 0 : options.override) ?? true
|
|
440
|
+
}));
|
|
438
441
|
}
|
|
439
442
|
setCurrent(unitId) {
|
|
440
443
|
if (!this._injector.get(IRenderManagerService).getRenderUnitById(unitId)) throw new Error("Unit not found");
|
package/lib/index.css
CHANGED
|
@@ -52,10 +52,6 @@
|
|
|
52
52
|
right: .75rem;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.\!univer-bottom-0 {
|
|
56
|
-
bottom: 0 !important;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
55
|
.\!univer-bottom-0\.5 {
|
|
60
56
|
bottom: .125rem !important;
|
|
61
57
|
}
|
|
@@ -565,10 +561,6 @@
|
|
|
565
561
|
min-width: 3.5rem;
|
|
566
562
|
}
|
|
567
563
|
|
|
568
|
-
.univer-min-w-16 {
|
|
569
|
-
min-width: 4rem;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
564
|
.univer-min-w-44 {
|
|
573
565
|
min-width: 11rem;
|
|
574
566
|
}
|
|
@@ -1267,6 +1259,11 @@
|
|
|
1267
1259
|
padding-right: 1.5rem;
|
|
1268
1260
|
}
|
|
1269
1261
|
|
|
1262
|
+
.univer-py-0 {
|
|
1263
|
+
padding-top: 0;
|
|
1264
|
+
padding-bottom: 0;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1270
1267
|
.univer-py-0\.5 {
|
|
1271
1268
|
padding-top: .125rem;
|
|
1272
1269
|
padding-bottom: .125rem;
|