@univerjs/ui 1.0.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -55,7 +55,7 @@ function getAttributeValue(target, name) {
55
55
  }
56
56
 
57
57
  //#endregion
58
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
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.149.0/helpers/esm/toPrimitive.js
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.149.0/helpers/esm/toPropertyKey.js
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.149.0/helpers/esm/defineProperty.js
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.149.0/helpers/esm/decorateParam.js
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.149.0/helpers/esm/decorate.js
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;
@@ -1673,27 +1674,33 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1673
1674
  this._initRibbonSubscription();
1674
1675
  }
1675
1676
  setActivatedTab(tab) {
1677
+ if (this._disposed) return;
1676
1678
  if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
1677
1679
  this._activatedTab$.next(tab);
1678
1680
  }
1679
1681
  showContextualTab(tab, options) {
1682
+ if (this._disposed) return;
1680
1683
  this._visibleContextualTabs.add(tab);
1681
1684
  this._updateRibbon();
1682
1685
  if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
1683
1686
  }
1684
1687
  hideContextualTab(tab) {
1688
+ if (this._disposed) return;
1685
1689
  if (!this._visibleContextualTabs.delete(tab)) return;
1686
1690
  this._updateRibbon();
1687
1691
  }
1688
1692
  hideAllContextualTabs() {
1693
+ if (this._disposed) return;
1689
1694
  if (this._visibleContextualTabs.size === 0) return;
1690
1695
  this._visibleContextualTabs.clear();
1691
1696
  this._updateRibbon();
1692
1697
  }
1693
1698
  setCollapsedIds(ids) {
1699
+ if (this._disposed) return;
1694
1700
  this._collapsedIds$.next(ids);
1695
1701
  }
1696
1702
  setFakeToolbarVisible(visible) {
1703
+ if (this._disposed) return;
1697
1704
  this._fakeToolbarVisible$.next(visible);
1698
1705
  }
1699
1706
  _initRibbonSubscription() {
@@ -1703,15 +1710,16 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1703
1710
  }
1704
1711
  _updateRibbon() {
1705
1712
  var _this$_hiddenSubscrip;
1713
+ if (this._disposed) return;
1706
1714
  const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
1707
1715
  const hiddenObservableMap = [];
1708
- const hiddenKeyMap = [];
1716
+ const menusWithHiddenState = [];
1709
1717
  for (const group of ribbon) if (group.children) {
1710
1718
  for (const item of group.children) if (item.children) for (const child of item.children) {
1711
1719
  var _child$item;
1712
1720
  if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
1713
1721
  hiddenObservableMap.push(child.item.hidden$);
1714
- hiddenKeyMap.push(child.key);
1722
+ menusWithHiddenState.push(child);
1715
1723
  }
1716
1724
  }
1717
1725
  }
@@ -1723,10 +1731,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1723
1731
  }
1724
1732
  this._hiddenSubscription = combineLatest(hiddenObservableMap.map((hidden$) => hidden$.pipe(startWith$1(false)))).pipe(distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
1725
1733
  const newRibbon = [];
1726
- const hiddenPathMap = hiddenMap.map((hidden, index) => {
1727
- if (hidden) return hiddenKeyMap[index];
1728
- return null;
1729
- }).filter((item) => !!item);
1734
+ const hiddenMenus = new Set(menusWithHiddenState.filter((_, index) => hiddenMap[index]));
1730
1735
  for (const group of ribbon) {
1731
1736
  var _group$children, _newGroup$children2;
1732
1737
  const newGroup = {
@@ -1742,7 +1747,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1742
1747
  let shouldAddItem = true;
1743
1748
  if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
1744
1749
  var _newItem$children2;
1745
- for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
1750
+ for (const child of item.children) if (!hiddenMenus.has(child)) {
1746
1751
  var _newItem$children;
1747
1752
  (_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
1748
1753
  }
@@ -1763,6 +1768,10 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1763
1768
  }
1764
1769
  this._setRibbon(newRibbon);
1765
1770
  });
1771
+ if (this._disposed) {
1772
+ this._hiddenSubscription.unsubscribe();
1773
+ this._hiddenSubscription = null;
1774
+ }
1766
1775
  }
1767
1776
  _filterContextualTabs(ribbon) {
1768
1777
  this._contextualTabs.clear();
@@ -1789,6 +1798,10 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1789
1798
  }
1790
1799
  dispose() {
1791
1800
  var _this$_hiddenSubscrip2;
1801
+ if (this._disposed) return;
1802
+ super.dispose();
1803
+ this._visibleContextualTabs.clear();
1804
+ this._contextualTabs.clear();
1792
1805
  (_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
1793
1806
  this._hiddenSubscription = null;
1794
1807
  this._ribbon$.next([]);
@@ -1796,7 +1809,6 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1796
1809
  this._activatedTab$.complete();
1797
1810
  this._collapsedIds$.complete();
1798
1811
  this._fakeToolbarVisible$.complete();
1799
- super.dispose();
1800
1812
  }
1801
1813
  };
1802
1814
  DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
@@ -1822,17 +1834,23 @@ function useObservableRef(observable, defaultValue) {
1822
1834
 
1823
1835
  //#endregion
1824
1836
  //#region src/views/components/feature-search/FeatureSearch.tsx
1837
+ /**
1838
+ * Copyright 2023-present DreamNum Co., Ltd.
1839
+ *
1840
+ * Licensed under the Apache License, Version 2.0 (the "License");
1841
+ * you may not use this file except in compliance with the License.
1842
+ * You may obtain a copy of the License at
1843
+ *
1844
+ * http://www.apache.org/licenses/LICENSE-2.0
1845
+ *
1846
+ * Unless required by applicable law or agreed to in writing, software
1847
+ * distributed under the License is distributed on an "AS IS" BASIS,
1848
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1849
+ * See the License for the specific language governing permissions and
1850
+ * limitations under the License.
1851
+ */
1825
1852
  const FEATURE_SEARCH_COMPONENT = "FeatureSearch";
1826
1853
  const FEATURE_SEARCH_DIALOG_ID = "FEATURE_SEARCH_DIALOG";
1827
- function resolveParams(item, value) {
1828
- return (typeof item.params === "function" ? item.params() : item.params) ?? (value === void 0 ? void 0 : { value });
1829
- }
1830
- function resolveOptionParams(option) {
1831
- return (typeof option.params === "function" ? option.params(option.value) : option.params) ?? (option.value === void 0 ? void 0 : { value: option.value });
1832
- }
1833
- function deduplicate(items) {
1834
- return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && Tools.diffValue(candidate.params, item.params)) === index);
1835
- }
1836
1854
  function FeatureSearch() {
1837
1855
  const menuManagerService = useDependency(IMenuManagerService);
1838
1856
  const localeService = useDependency(LocaleService);
@@ -1841,6 +1859,15 @@ function FeatureSearch() {
1841
1859
  const layoutService = useDependency(ILayoutService);
1842
1860
  const ribbonService = useDependency(IRibbonService);
1843
1861
  const items$ = useMemo(() => {
1862
+ function resolveParams(item, value) {
1863
+ return (typeof item.params === "function" ? item.params() : item.params) ?? (value === void 0 ? void 0 : { value });
1864
+ }
1865
+ function resolveOptionParams(option) {
1866
+ return (typeof option.params === "function" ? option.params(option.value) : option.params) ?? (option.value === void 0 ? void 0 : { value: option.value });
1867
+ }
1868
+ function deduplicate(items) {
1869
+ return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && Tools.diffValue(candidate.params, item.params)) === index);
1870
+ }
1844
1871
  function getItemTitle(item) {
1845
1872
  const titleKey = item.title ?? item.tooltip ?? item.description;
1846
1873
  return titleKey ? localeService.t(titleKey) : "";
@@ -1965,7 +1992,7 @@ function FeatureSearch() {
1965
1992
  children: item.title
1966
1993
  })]
1967
1994
  }), item.path && /* @__PURE__ */ jsx("span", {
1968
- className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
1995
+ className: "univer-max-w-[50%] univer-truncate univer-text-xs univer-text-gray-400",
1969
1996
  children: item.path
1970
1997
  })]
1971
1998
  }, item.key)) })] })]
@@ -3208,6 +3235,21 @@ function useComponentsOfPart(part, injector) {
3208
3235
 
3209
3236
  //#endregion
3210
3237
  //#region src/views/components/ribbon/ribbon-menu/ClassicMenu.tsx
3238
+ /**
3239
+ * Copyright 2023-present DreamNum Co., Ltd.
3240
+ *
3241
+ * Licensed under the Apache License, Version 2.0 (the "License");
3242
+ * you may not use this file except in compliance with the License.
3243
+ * You may obtain a copy of the License at
3244
+ *
3245
+ * http://www.apache.org/licenses/LICENSE-2.0
3246
+ *
3247
+ * Unless required by applicable law or agreed to in writing, software
3248
+ * distributed under the License is distributed on an "AS IS" BASIS,
3249
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3250
+ * See the License for the specific language governing permissions and
3251
+ * limitations under the License.
3252
+ */
3211
3253
  function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
3212
3254
  const localeService = useDependency(LocaleService);
3213
3255
  return /* @__PURE__ */ jsx("div", {
@@ -3221,7 +3263,7 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
3221
3263
  "aria-selected": isActive,
3222
3264
  title: localeService.t(group.title || group.key),
3223
3265
  onClick: () => onSelectTab(group),
3224
- className: clsx("univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500 dark:!univer-focus:ring-primary-300 univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1 univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm univer-transition-colors", isActive ? "univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm dark:!univer-bg-primary-900 dark:!univer-text-primary-300" : "univer-hover:bg-gray-100 dark:!univer-hover:bg-gray-700 univer-bg-transparent univer-text-gray-700 dark:!univer-text-gray-200"),
3266
+ className: clsx("univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1 univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm univer-transition-colors focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-500 dark:focus:!univer-ring-primary-300", isActive ? "univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm dark:!univer-bg-primary-900 dark:!univer-text-primary-300" : "univer-bg-transparent univer-text-gray-700 hover:univer-bg-gray-100 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700"),
3225
3267
  children: localeService.t(group.title || group.key)
3226
3268
  }, group.key);
3227
3269
  })
@@ -4050,7 +4092,7 @@ const toolbarSelectorRootVariants = cva("univer-toolbar-selector-root univer-ani
4050
4092
  false: "univer-text-gray-900 dark:!univer-text-gray-0"
4051
4093
  },
4052
4094
  active: {
4053
- true: "univer-bg-gray-200",
4095
+ true: "univer-bg-gray-200 dark:!univer-bg-gray-500",
4054
4096
  false: ""
4055
4097
  }
4056
4098
  },
@@ -4321,7 +4363,7 @@ function RibbonGrid({ groups, title, className, ...props }) {
4321
4363
  const placements = placeRibbonGridItems(group.children ?? []);
4322
4364
  return /* @__PURE__ */ jsxs("div", {
4323
4365
  "data-u-comp": "ribbon-grid-group",
4324
- className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
4366
+ className: "univer-relative univer-box-border univer-flex univer-shrink-0 univer-flex-col univer-px-2",
4325
4367
  children: [/* @__PURE__ */ jsx("div", {
4326
4368
  "data-testid": "ribbon-grid-group-grid",
4327
4369
  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",
@@ -4740,52 +4782,6 @@ var ContextMenuHostService = class extends Disposable {
4740
4782
  }
4741
4783
  };
4742
4784
 
4743
- //#endregion
4744
- //#region src/views/hooks/layout.ts
4745
- /**
4746
- * These hooks are used for browser layout
4747
- * Prefer to client-side
4748
- */
4749
- /**
4750
- * Allow the element to scroll when its height over the container height
4751
- * @param element
4752
- * Container means the window view that the element displays in.
4753
- * Recommend pass the sheet mountContainer as container
4754
- * @param container
4755
- */
4756
- function useScrollYOverContainer(element, container) {
4757
- const updater = useEvent(() => {
4758
- if (!element || !container) return;
4759
- const elStyle = element.style;
4760
- const { y, height } = element.getBoundingClientRect();
4761
- const containerRect = container.getBoundingClientRect();
4762
- const scrolled = element.scrollHeight > height;
4763
- const isOverViewport = y < 0 || y + height > containerRect.height;
4764
- if (!isOverViewport && !scrolled) {
4765
- elStyle.overflowY = "";
4766
- elStyle.maxHeight = "";
4767
- return;
4768
- }
4769
- if (isOverViewport) {
4770
- elStyle.overflowY = "auto";
4771
- elStyle.maxHeight = y < 0 ? `${element.scrollHeight + y}px` : `${containerRect.height - y}px`;
4772
- }
4773
- });
4774
- useEffect(() => {
4775
- if (!isBrowser() || !element || !container) return;
4776
- updater();
4777
- const resizeObserver = new ResizeObserver(updater);
4778
- resizeObserver.observe(element);
4779
- return () => {
4780
- resizeObserver.disconnect();
4781
- };
4782
- }, [element, container]);
4783
- }
4784
- function useConfigValue(configKey) {
4785
- const configService = useDependency(IConfigService);
4786
- return useObservable(useMemo(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
4787
- }
4788
-
4789
4785
  //#endregion
4790
4786
  //#region src/views/hooks/prevent-browser-zoom.ts
4791
4787
  /**
@@ -4962,6 +4958,21 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
4962
4958
 
4963
4959
  //#endregion
4964
4960
  //#region src/views/menu/desktop/TinyMenuGroup.tsx
4961
+ /**
4962
+ * Copyright 2023-present DreamNum Co., Ltd.
4963
+ *
4964
+ * Licensed under the Apache License, Version 2.0 (the "License");
4965
+ * you may not use this file except in compliance with the License.
4966
+ * You may obtain a copy of the License at
4967
+ *
4968
+ * http://www.apache.org/licenses/LICENSE-2.0
4969
+ *
4970
+ * Unless required by applicable law or agreed to in writing, software
4971
+ * distributed under the License is distributed on an "AS IS" BASIS,
4972
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4973
+ * See the License for the specific language governing permissions and
4974
+ * limitations under the License.
4975
+ */
4965
4976
  const EMPTY_HIDDEN_ITEM_IDS = [];
4966
4977
  const EMPTY_TINY_MENU_CHILDREN = [];
4967
4978
  const quickTileMenuButtonVariants = 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-gray-0 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", {
@@ -5088,7 +5099,7 @@ function UIQuickTileMenuGroup(props) {
5088
5099
  const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
5089
5100
  if (!((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length)) return null;
5090
5101
  return /* @__PURE__ */ jsx("div", {
5091
- className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
5102
+ className: "univer-grid univer-grid-cols-3 univer-items-center univer-gap-1.5 univer-py-1",
5092
5103
  children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
5093
5104
  menuSchema,
5094
5105
  activeItemIds,
@@ -5451,7 +5462,6 @@ function ContextMenuPanel(props) {
5451
5462
  menuSessionVersion
5452
5463
  ]);
5453
5464
  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);
5454
- useScrollYOverContainer(menuElement, layoutService.rootContainerElement);
5455
5465
  useEffect(() => {
5456
5466
  if (!menuElement) return;
5457
5467
  return preventBrowserZoomInContainers([menuElement]);
@@ -6404,7 +6414,7 @@ function Sidebar() {
6404
6414
  }),
6405
6415
  style: { width: isDragging ? void 0 : width },
6406
6416
  children: [(options === null || options === void 0 ? void 0 : options.visible) && /* @__PURE__ */ jsx("div", {
6407
- className: "hover:univer-bg-primary-500/30 active:univer-bg-primary-500/50 univer-absolute univer-left-0 univer-top-0 univer-z-20 univer-h-full univer-w-1 univer-cursor-col-resize univer-transition-colors",
6417
+ className: "univer-absolute univer-left-0 univer-top-0 univer-z-20 univer-h-full univer-w-1 univer-cursor-col-resize univer-transition-colors hover:univer-bg-primary-500 active:univer-bg-primary-500",
6408
6418
  onMouseDown: handleResizeMouseDown,
6409
6419
  role: "separator",
6410
6420
  "aria-orientation": "vertical",
@@ -6435,7 +6445,7 @@ function Sidebar() {
6435
6445
  children: [options === null || options === void 0 ? void 0 : options.header, /* @__PURE__ */ jsx("button", {
6436
6446
  ref: closeButtonRef,
6437
6447
  type: "button",
6438
- className: "focus:univer-ring-primary-500/50 univer-flex univer-size-6 univer-cursor-pointer univer-appearance-none univer-items-center univer-justify-center 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",
6448
+ className: "univer-flex univer-size-6 univer-cursor-pointer univer-appearance-none univer-items-center univer-justify-center univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0 univer-text-gray-500 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-500 dark:!univer-text-gray-300",
6439
6449
  onClick: handleClose,
6440
6450
  "aria-label": localeService.t("ui.sidebar.close"),
6441
6451
  children: /* @__PURE__ */ jsx(CloseIcon, {})
@@ -6543,6 +6553,52 @@ function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
6543
6553
  });
6544
6554
  }
6545
6555
 
6556
+ //#endregion
6557
+ //#region src/views/hooks/layout.ts
6558
+ /**
6559
+ * These hooks are used for browser layout
6560
+ * Prefer to client-side
6561
+ */
6562
+ /**
6563
+ * Allow the element to scroll when its height over the container height
6564
+ * @param element
6565
+ * Container means the window view that the element displays in.
6566
+ * Recommend pass the sheet mountContainer as container
6567
+ * @param container
6568
+ */
6569
+ function useScrollYOverContainer(element, container) {
6570
+ const updater = useEvent(() => {
6571
+ if (!element || !container) return;
6572
+ const elStyle = element.style;
6573
+ const { y, height } = element.getBoundingClientRect();
6574
+ const containerRect = container.getBoundingClientRect();
6575
+ const scrolled = element.scrollHeight > height;
6576
+ const isOverViewport = y < 0 || y + height > containerRect.height;
6577
+ if (!isOverViewport && !scrolled) {
6578
+ elStyle.overflowY = "";
6579
+ elStyle.maxHeight = "";
6580
+ return;
6581
+ }
6582
+ if (isOverViewport) {
6583
+ elStyle.overflowY = "auto";
6584
+ elStyle.maxHeight = y < 0 ? `${element.scrollHeight + y}px` : `${containerRect.height - y}px`;
6585
+ }
6586
+ });
6587
+ useEffect(() => {
6588
+ if (!isBrowser() || !element || !container) return;
6589
+ updater();
6590
+ const resizeObserver = new ResizeObserver(updater);
6591
+ resizeObserver.observe(element);
6592
+ return () => {
6593
+ resizeObserver.disconnect();
6594
+ };
6595
+ }, [element, container]);
6596
+ }
6597
+ function useConfigValue(configKey) {
6598
+ const configService = useDependency(IConfigService);
6599
+ return useObservable(useMemo(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
6600
+ }
6601
+
6546
6602
  //#endregion
6547
6603
  //#region src/views/hooks/update-effect.ts
6548
6604
  /**
@@ -6618,16 +6674,8 @@ function useLatest(value) {
6618
6674
  ref.current = value;
6619
6675
  return ref;
6620
6676
  }
6621
- const useVirtualList = (list, options) => {
6622
- const { containerTarget, itemHeight, overscan = 5 } = options;
6677
+ function useVirtualListMetrics(list, itemHeight) {
6623
6678
  const itemHeightRef = useLatest(itemHeight);
6624
- const [size, setSize] = useState(null);
6625
- const scrollTriggerByScrollToFunc = useRef(false);
6626
- const [targetList, setTargetList] = useState([]);
6627
- const [wrapperStyle, setWrapperStyle] = useState({
6628
- height: void 0,
6629
- marginTop: void 0
6630
- });
6631
6679
  const getVisibleCount = (containerHeight, fromIndex) => {
6632
6680
  if (typeof itemHeightRef.current === "number") return Math.ceil(containerHeight / itemHeightRef.current);
6633
6681
  let sum = 0;
@@ -6658,29 +6706,18 @@ const useVirtualList = (list, options) => {
6658
6706
  if (typeof itemHeightRef.current === "number") return index * itemHeightRef.current;
6659
6707
  return list.slice(0, index).reduce((sum, _, i) => sum + itemHeightRef.current(i, list[i]), 0);
6660
6708
  };
6661
- const totalHeight = useMemo(() => {
6662
- if (isNumber(itemHeightRef.current)) return list.length * itemHeightRef.current;
6663
- return list.reduce((sum, _, index) => sum + itemHeightRef.current(index, list[index]), 0);
6664
- }, [list]);
6665
- const calculateRange = () => {
6666
- const container = containerTarget.current;
6667
- if (container) {
6668
- const { scrollTop, clientHeight } = container;
6669
- const offset = getOffset(scrollTop);
6670
- const visibleCount = getVisibleCount(clientHeight, offset);
6671
- const start = Math.max(0, offset - overscan);
6672
- const end = Math.min(list.length, offset + visibleCount + overscan);
6673
- const offsetTop = getDistanceTop(start);
6674
- setWrapperStyle({
6675
- height: `${totalHeight - offsetTop}px`,
6676
- marginTop: `${offsetTop}px`
6677
- });
6678
- setTargetList(list.slice(start, end).map((ele, index) => ({
6679
- data: ele,
6680
- index: index + start
6681
- })));
6682
- }
6709
+ return {
6710
+ getVisibleCount,
6711
+ getOffset,
6712
+ getDistanceTop,
6713
+ totalHeight: useMemo(() => {
6714
+ if (isNumber(itemHeightRef.current)) return list.length * itemHeightRef.current;
6715
+ return list.reduce((sum, _, index) => sum + itemHeightRef.current(index, list[index]), 0);
6716
+ }, [list])
6683
6717
  };
6718
+ }
6719
+ function useContainerSize(containerTarget) {
6720
+ const [size, setSize] = useState(null);
6684
6721
  useEffect(() => {
6685
6722
  if (containerTarget.current) {
6686
6723
  const getSize = () => {
@@ -6699,6 +6736,37 @@ const useVirtualList = (list, options) => {
6699
6736
  };
6700
6737
  }
6701
6738
  }, []);
6739
+ return size;
6740
+ }
6741
+ const useVirtualList = (list, options) => {
6742
+ const { containerTarget, itemHeight, overscan = 5 } = options;
6743
+ const { getVisibleCount, getOffset, getDistanceTop, totalHeight } = useVirtualListMetrics(list, itemHeight);
6744
+ const size = useContainerSize(containerTarget);
6745
+ const scrollTriggerByScrollToFunc = useRef(false);
6746
+ const [targetList, setTargetList] = useState([]);
6747
+ const [wrapperStyle, setWrapperStyle] = useState({
6748
+ height: void 0,
6749
+ marginTop: void 0
6750
+ });
6751
+ const calculateRange = () => {
6752
+ const container = containerTarget.current;
6753
+ if (container) {
6754
+ const { scrollTop, clientHeight } = container;
6755
+ const offset = getOffset(scrollTop);
6756
+ const visibleCount = getVisibleCount(clientHeight, offset);
6757
+ const start = Math.max(0, offset - overscan);
6758
+ const end = Math.min(list.length, offset + visibleCount + overscan);
6759
+ const offsetTop = getDistanceTop(start);
6760
+ setWrapperStyle({
6761
+ height: `${totalHeight - offsetTop}px`,
6762
+ marginTop: `${offsetTop}px`
6763
+ });
6764
+ setTargetList(list.slice(start, end).map((ele, index) => ({
6765
+ data: ele,
6766
+ index: index + start
6767
+ })));
6768
+ }
6769
+ };
6702
6770
  useEffect(() => {
6703
6771
  if (!(size === null || size === void 0 ? void 0 : size.width) || !(size === null || size === void 0 ? void 0 : size.height)) return;
6704
6772
  calculateRange();
@@ -7024,7 +7092,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
7024
7092
  //#endregion
7025
7093
  //#region package.json
7026
7094
  var name = "@univerjs/ui";
7027
- var version = "1.0.4";
7095
+ var version = "1.2.0";
7028
7096
 
7029
7097
  //#endregion
7030
7098
  //#region src/views/color-picker/interface.ts
@@ -22696,6 +22764,37 @@ function EmojiPicker(props) {
22696
22764
  const recentStorageKey = (extraProps === null || extraProps === void 0 ? void 0 : extraProps.recentStorageKey) ?? RECENTS_STORAGE_KEY;
22697
22765
  const isSearching = deferredQuery.trim().length > 0;
22698
22766
  const { rows, sectionPositions } = useMemo(() => {
22767
+ function createEmojiVirtualRows(sections, locale) {
22768
+ const rows = [];
22769
+ const sectionPositions = [];
22770
+ let top = 0;
22771
+ sections.forEach((section) => {
22772
+ if (!section.emojis.length) return;
22773
+ sectionPositions.push({
22774
+ key: section.key,
22775
+ rowIndex: rows.length,
22776
+ top
22777
+ });
22778
+ rows.push({
22779
+ key: `${locale}-${section.key}-header`,
22780
+ title: section.title,
22781
+ type: "header"
22782
+ });
22783
+ top += EMOJI_SECTION_HEADER_HEIGHT;
22784
+ for (let start = 0; start < section.emojis.length; start += EMOJI_COLUMN_COUNT) {
22785
+ rows.push({
22786
+ items: section.emojis.slice(start, start + EMOJI_COLUMN_COUNT),
22787
+ key: `${locale}-${section.key}-${start / EMOJI_COLUMN_COUNT}`,
22788
+ type: "emojis"
22789
+ });
22790
+ top += EMOJI_ROW_HEIGHT;
22791
+ }
22792
+ });
22793
+ return {
22794
+ rows,
22795
+ sectionPositions
22796
+ };
22797
+ }
22699
22798
  const normalSections = [{
22700
22799
  key: "recent",
22701
22800
  title: localeService.t("ui.emojiPicker.recents"),
@@ -22720,7 +22819,7 @@ function EmojiPicker(props) {
22720
22819
  ]);
22721
22820
  const [virtualRows, { containerProps, scrollTo, wrapperStyle }] = useVirtualList(rows, {
22722
22821
  containerTarget: scrollRef,
22723
- itemHeight: getEmojiVirtualRowHeight,
22822
+ itemHeight: (_index, row) => row.type === "header" ? EMOJI_SECTION_HEADER_HEIGHT : EMOJI_ROW_HEIGHT,
22724
22823
  overscan: EMOJI_VIRTUAL_OVERSCAN
22725
22824
  });
22726
22825
  useEffect(() => {
@@ -22752,6 +22851,16 @@ function EmojiPicker(props) {
22752
22851
  scrollTo,
22753
22852
  sectionPositions
22754
22853
  ]);
22854
+ function writeStorageItem(localStorageService, storageKey, value) {
22855
+ localStorageService.setItem(storageKey, value).catch(() => void 0);
22856
+ }
22857
+ function getActiveSectionByScrollTop(sectionPositions, scrollTop) {
22858
+ let active = "recent";
22859
+ sectionPositions.forEach((position) => {
22860
+ if (position.top <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) active = position.key;
22861
+ });
22862
+ return active;
22863
+ }
22755
22864
  const handleSelect = (item, options) => {
22756
22865
  var _props$onChange, _extraProps$onSelect;
22757
22866
  const nextRecents = promoteRecentEmoji(recents, item);
@@ -22916,7 +23025,7 @@ function EmojiButton(props) {
22916
23025
  type: "button",
22917
23026
  "aria-label": `${title}, ${props.moreTitle}`,
22918
23027
  title: `${title}, ${props.moreTitle}`,
22919
- className: "univer-bg-gray-0/90 dark:!univer-bg-gray-800/90 univer-absolute univer-bottom-0 univer-right-0 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-p-0 univer-text-gray-500 hover:univer-bg-gray-100 hover:univer-text-gray-700 focus-visible:univer-outline-none focus-visible:univer-ring-1 focus-visible:univer-ring-primary-600 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",
23028
+ className: "univer-absolute univer-bottom-0 univer-right-0 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-gray-0 univer-p-0 univer-text-gray-500 hover:univer-bg-gray-100 hover:univer-text-gray-700 focus-visible:univer-outline-none focus-visible:univer-ring-1 focus-visible:univer-ring-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",
22920
23029
  children: /* @__PURE__ */ jsx(MoreDownIcon, { className: "!univer-size-2.5" })
22921
23030
  })
22922
23031
  })]
@@ -23004,50 +23113,6 @@ function CategoryButton(props) {
23004
23113
  children: props.children
23005
23114
  });
23006
23115
  }
23007
- function writeStorageItem(localStorageService, storageKey, value) {
23008
- localStorageService.setItem(storageKey, value).catch(() => void 0);
23009
- }
23010
- function createEmojiVirtualRows(sections, locale) {
23011
- const rows = [];
23012
- const sectionPositions = [];
23013
- let top = 0;
23014
- sections.forEach((section) => {
23015
- if (!section.emojis.length) return;
23016
- sectionPositions.push({
23017
- key: section.key,
23018
- rowIndex: rows.length,
23019
- top
23020
- });
23021
- rows.push({
23022
- key: `${locale}-${section.key}-header`,
23023
- title: section.title,
23024
- type: "header"
23025
- });
23026
- top += EMOJI_SECTION_HEADER_HEIGHT;
23027
- for (let start = 0; start < section.emojis.length; start += EMOJI_COLUMN_COUNT) {
23028
- rows.push({
23029
- items: section.emojis.slice(start, start + EMOJI_COLUMN_COUNT),
23030
- key: `${locale}-${section.key}-${start / EMOJI_COLUMN_COUNT}`,
23031
- type: "emojis"
23032
- });
23033
- top += EMOJI_ROW_HEIGHT;
23034
- }
23035
- });
23036
- return {
23037
- rows,
23038
- sectionPositions
23039
- };
23040
- }
23041
- function getEmojiVirtualRowHeight(_index, row) {
23042
- return row.type === "header" ? EMOJI_SECTION_HEADER_HEIGHT : EMOJI_ROW_HEIGHT;
23043
- }
23044
- function getActiveSectionByScrollTop(sectionPositions, scrollTop) {
23045
- let active = "recent";
23046
- sectionPositions.forEach((position) => {
23047
- if (position.top <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) active = position.key;
23048
- });
23049
- return active;
23050
- }
23051
23116
  function CategoryIcon(props) {
23052
23117
  switch (props.category) {
23053
23118
  case "activity": return /* @__PURE__ */ jsx(ActivityIcon, {});
@@ -24111,7 +24176,7 @@ function MobileRibbonToolbar(props) {
24111
24176
  return /* @__PURE__ */ jsx("div", {
24112
24177
  className: clsx("univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5 rtl:univer-pl-1.5 rtl:univer-pr-0", { [borderRightClassName]: groupIndex !== activeGroups.length - 1 }),
24113
24178
  children: groupItems.map((child) => child.item && /* @__PURE__ */ jsx("div", {
24114
- className: clsx("[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-m-0 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-appearance-none [&_button]:!univer-rounded-md [&_button]:!univer-border-0 [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-px-1.5 [&_button]:!univer-leading-none [&_button]:!univer-outline-none [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0 [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none [&_input]:!univer-outline-none"),
24179
+ className: clsx("univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-m-0 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-appearance-none [&_button]:!univer-rounded-md [&_button]:!univer-border-0 [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-px-1.5 [&_button]:!univer-leading-none [&_button]:!univer-outline-none [&_button]:![font-family:inherit] [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0 [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none [&_input]:!univer-outline-none"),
24115
24180
  children: /* @__PURE__ */ jsx(MobileToolbarItem, {
24116
24181
  ...child.item,
24117
24182
  preserveStrokeWidth: true
@@ -24547,7 +24612,7 @@ function MobileSchemaRow(props) {
24547
24612
  if (disabled) return;
24548
24613
  onExecute === null || onExecute === void 0 || onExecute({
24549
24614
  commandId: menuItem.commandId,
24550
- value: nextValue,
24615
+ value: typeof value === "number" && isRealNum(nextValue) ? Number(nextValue) : nextValue,
24551
24616
  id: menuItem.id,
24552
24617
  label: schema.key,
24553
24618
  params: menuItem.params
@@ -27786,7 +27851,7 @@ function Slider(props) {
27786
27851
  onPointerDown: handlePointerDown,
27787
27852
  children: [
27788
27853
  /* @__PURE__ */ jsx("div", {
27789
- className: clsx("univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full", isRtl ? "univer-right-0" : "univer-left-0"),
27854
+ className: clsx("univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500", isRtl ? "univer-right-0" : "univer-left-0"),
27790
27855
  style: { width: `${sliderOffset}%` }
27791
27856
  }),
27792
27857
  /* @__PURE__ */ jsx("a", {