@univerjs/ui 1.0.0-beta.1 → 1.0.0-beta.2

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
@@ -1,5 +1,5 @@
1
1
  import { BaselineOffset, BorderStyleTypes, ColorKit, CommandType, DependentOn, Disposable, DocumentDataModel, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_FX_BAR_EDITOR, FOCUSING_UNIVER_EDITOR, ICommandService, IConfigService, IConfirmService, IContextService, ILocalStorageService, ILogService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, LifecycleUnreachableError, LocaleService, NAMED_STYLE_MAP, NamedStyleType, Optional, Plugin, Quantity, RedoCommand, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommand, UniverInstanceType, Workbook, createIdentifier, dedupeBy, generateRandomId, getBorderStyleType, isInternalEditorID, isRealNum, merge, mergeOverrideWithDependencies, registerDependencies, remove, throttle, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { BehaviorSubject, EMPTY, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, isObservable, map, merge as merge$1, of, scan, startWith, switchMap, throttleTime } from "rxjs";
2
+ import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, isObservable, map, merge as merge$1, of, scan, startWith, switchMap, throttleTime } from "rxjs";
3
3
  import { Fragment, cloneElement, createContext, createElement, forwardRef, memo, useCallback, useContext, useDeferredValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { Button, ColorPicker, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, ConfigContext, ConfigProvider, Confirm, Dialog, Dropdown, DropdownMenu, Gallery, HoverCard, Input, InputNumber, KBD, MessageType, Messager, Popup, Toaster, Tooltip, borderBottomClassName, borderClassName, borderLeftBottomClassName, borderRightClassName, borderTopClassName, clsx, cva, divideXClassName, divideYClassName, isBrowser, message, removeMessage, render, resetButtonClassName, scrollbarClassName, toast, unmount } from "@univerjs/design";
5
5
  import { IRenderManagerService, UniverRenderEnginePlugin, ptToPx } from "@univerjs/engine-render";
@@ -2573,9 +2573,11 @@ const SingleCanvasPopup = ({ popup, children }) => {
2573
2573
  var _popup$excludeRects$;
2574
2574
  return (_popup$excludeRects$ = popup.excludeRects$) === null || _popup$excludeRects$ === void 0 ? void 0 : _popup$excludeRects$.pipe(throttleTime(0, animationFrameScheduler));
2575
2575
  }, [popup.excludeRects$]), popup.excludeRects);
2576
- const { canvasElement, constrainToCanvas = false, hideOnInvisible = true, hiddenType = "destroy" } = popup;
2576
+ const { boundaryInsets, canvasElement, constrainToCanvas = false, hideOnInvisible = true, hiddenType = "destroy" } = popup;
2577
2577
  const hidden = useObservable(hideOnInvisible ? () => combineLatest([anchorRect$, hiddenRects$]).pipe(map(([rectWithOffset, hiddenRects]) => {
2578
2578
  const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
2579
+ const insetTop = constrainToCanvas ? (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.top) ?? 0 : 0;
2580
+ const insetLeft = constrainToCanvas ? (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.left) ?? 0 : 0;
2579
2581
  const rectHeight = rectWithOffset.bottom - rectWithOffset.top;
2580
2582
  const rectWidth = rectWithOffset.right - rectWithOffset.left;
2581
2583
  const isInHiddenRect = hiddenRects.some((hiddenRect) => {
@@ -2583,10 +2585,12 @@ const SingleCanvasPopup = ({ popup, children }) => {
2583
2585
  const bufferX = Math.min(.5 * rectWidth, 10);
2584
2586
  return rectWithOffset.top >= hiddenRect.top - bufferY && rectWithOffset.bottom <= hiddenRect.bottom + bufferY && rectWithOffset.left >= hiddenRect.left - bufferX && rectWithOffset.right <= hiddenRect.right + bufferX;
2585
2587
  });
2586
- return rectWithOffset.bottom < top || rectWithOffset.top > bottom || rectWithOffset.right < left || rectWithOffset.left > right || isInHiddenRect;
2588
+ return rectWithOffset.bottom < top + insetTop || rectWithOffset.top > bottom || rectWithOffset.right < left + insetLeft || rectWithOffset.left > right || isInHiddenRect;
2587
2589
  })) : null, false, false, [
2588
2590
  anchorRect$,
2591
+ boundaryInsets,
2589
2592
  canvasElement,
2593
+ constrainToCanvas,
2590
2594
  hiddenRects$,
2591
2595
  hideOnInvisible
2592
2596
  ]);
@@ -2743,7 +2747,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
2743
2747
  onClick: () => handleSelectTab(group),
2744
2748
  children: [/* @__PURE__ */ jsx("span", {
2745
2749
  className: clsx("univer-box-border univer-flex univer-size-9 univer-flex-shrink-0 univer-items-center univer-justify-center univer-rounded-lg", borderClassName),
2746
- children: /* @__PURE__ */ jsx(Icon, { className: "univer-text-gray-500 dark:!univer-text-gray-300" })
2750
+ children: /* @__PURE__ */ jsx(Icon, {
2751
+ className: "univer-text-gray-500 dark:!univer-text-gray-300",
2752
+ preserveStrokeWidth: true
2753
+ })
2747
2754
  }), /* @__PURE__ */ jsxs("span", {
2748
2755
  className: "univer-flex univer-flex-col",
2749
2756
  children: [/* @__PURE__ */ jsx("strong", {
@@ -2761,7 +2768,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
2761
2768
  children: /* @__PURE__ */ jsxs("a", {
2762
2769
  className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-gray-0 dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
2763
2770
  onClick: () => setGroupSelectorVisible(true),
2764
- children: [localeService.t(activatedTabTitle), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
2771
+ children: [localeService.t(activatedTabTitle), /* @__PURE__ */ jsx(MoreDownIcon, {
2772
+ className: "univer-text-gray-200 dark:!univer-text-gray-500",
2773
+ preserveStrokeWidth: true
2774
+ })]
2765
2775
  })
2766
2776
  });
2767
2777
  }
@@ -2881,7 +2891,7 @@ function getCells(row, column, rowSpan, columnSpan) {
2881
2891
  * @param props
2882
2892
  */
2883
2893
  function CustomLabel(props) {
2884
- const { className, iconSize, title, icon, label, value, value$ } = props;
2894
+ const { className, iconSize, preserveStrokeWidth, title, icon, label, value, value$ } = props;
2885
2895
  const localeService = useDependency(LocaleService);
2886
2896
  const componentManager = useDependency(ComponentManager);
2887
2897
  const iconManager = useDependency(IconManager);
@@ -2905,7 +2915,8 @@ function CustomLabel(props) {
2905
2915
  width: iconSize,
2906
2916
  height: iconSize
2907
2917
  } : void 0,
2908
- extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" }
2918
+ extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" },
2919
+ preserveStrokeWidth
2909
2920
  }, index++));
2910
2921
  }
2911
2922
  if (label) {
@@ -3066,6 +3077,7 @@ function ToolbarTooltip(props) {
3066
3077
  }, [popupOpen]);
3067
3078
  return /* @__PURE__ */ jsx(Tooltip, {
3068
3079
  ...tooltipProps,
3080
+ className: clsx("univer-fill-mode-backwards univer-delay-100", tooltipProps.className),
3069
3081
  visible: !popupOpen && tooltipVisible,
3070
3082
  onVisibleChange: (visible) => {
3071
3083
  if (!popupOpen) setTooltipVisible(visible);
@@ -3154,7 +3166,7 @@ function DropdownWrapper(props) {
3154
3166
  })
3155
3167
  });
3156
3168
  }
3157
- function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
3169
+ function DropdownMenuLabel({ icon, value, option, preserveStrokeWidth, onOptionSelect }) {
3158
3170
  var _option$label;
3159
3171
  const onChange = (v) => {
3160
3172
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
@@ -3171,6 +3183,7 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
3171
3183
  children: /* @__PURE__ */ jsx(CustomLabel, {
3172
3184
  className: "univer-text-sm",
3173
3185
  icon,
3186
+ preserveStrokeWidth,
3174
3187
  value$: option.value$,
3175
3188
  value: option.value,
3176
3189
  label: option.label,
@@ -3178,7 +3191,10 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
3178
3191
  })
3179
3192
  }), hasCheckMark && /* @__PURE__ */ jsx("span", {
3180
3193
  className: "univer-ml-auto univer-flex univer-w-4 univer-flex-shrink-0 univer-justify-end",
3181
- children: selected && /* @__PURE__ */ jsx(CheckMarkIcon, { className: "univer-text-primary-600" })
3194
+ children: selected && /* @__PURE__ */ jsx(CheckMarkIcon, {
3195
+ className: "univer-text-primary-600",
3196
+ preserveStrokeWidth
3197
+ })
3182
3198
  })]
3183
3199
  });
3184
3200
  }
@@ -3186,7 +3202,7 @@ function getOptionKey(option) {
3186
3202
  var _option$label2;
3187
3203
  return String(option.id ?? option.commandId ?? option.value ?? (typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name));
3188
3204
  }
3189
- function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
3205
+ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, preserveStrokeWidth, onOptionSelect }) {
3190
3206
  const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
3191
3207
  useEffect(() => {
3192
3208
  if (disabled) setDropdownVisible(false);
@@ -3230,6 +3246,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3230
3246
  overlay: options.map((option) => /* @__PURE__ */ jsx(DropdownMenuLabel, {
3231
3247
  value,
3232
3248
  option,
3249
+ preserveStrokeWidth,
3233
3250
  onOptionSelect: handleOptionSelect
3234
3251
  }, getOptionKey(option))),
3235
3252
  children
@@ -3249,6 +3266,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3249
3266
  icon: option.icon,
3250
3267
  value,
3251
3268
  option,
3269
+ preserveStrokeWidth,
3252
3270
  onOptionSelect: handleOptionSelect
3253
3271
  }),
3254
3272
  disabled: option.disabled,
@@ -3268,6 +3286,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3268
3286
  children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
3269
3287
  icon,
3270
3288
  value,
3289
+ preserveStrokeWidth,
3271
3290
  option: { label: {
3272
3291
  name: title,
3273
3292
  selectable: false
@@ -3304,6 +3323,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3304
3323
  children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
3305
3324
  icon,
3306
3325
  value,
3326
+ preserveStrokeWidth,
3307
3327
  option: { label: {
3308
3328
  name: title,
3309
3329
  selectable: false
@@ -3421,7 +3441,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3421
3441
  layoutService.focus();
3422
3442
  commandService.executeCommand(commandId, params);
3423
3443
  };
3424
- const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
3444
+ const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth, preserveStrokeWidth } = props;
3425
3445
  const gridLabel = title ?? tooltip;
3426
3446
  const shortcutDisplay = useToolbarShortcutDisplay({
3427
3447
  id,
@@ -3491,6 +3511,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3491
3511
  children: /* @__PURE__ */ jsx(CustomLabel, {
3492
3512
  icon: iconToDisplay,
3493
3513
  iconSize,
3514
+ preserveStrokeWidth,
3494
3515
  title: titleToDisplay,
3495
3516
  value: iconColor ?? value,
3496
3517
  label,
@@ -3502,6 +3523,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3502
3523
  value,
3503
3524
  options,
3504
3525
  disabled,
3526
+ preserveStrokeWidth,
3505
3527
  onOptionSelect: handleSelect,
3506
3528
  children: /* @__PURE__ */ jsx("div", {
3507
3529
  className: clsx(toolbarButtonSelectorTriggerVariants({
@@ -3512,7 +3534,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3512
3534
  "univer-h-full": grid && !large
3513
3535
  }),
3514
3536
  "data-disabled": disabled,
3515
- children: /* @__PURE__ */ jsx(MoreDownIcon, {})
3537
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { preserveStrokeWidth })
3516
3538
  })
3517
3539
  })]
3518
3540
  });
@@ -3522,6 +3544,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3522
3544
  value,
3523
3545
  options,
3524
3546
  disabled,
3547
+ preserveStrokeWidth,
3525
3548
  onOptionSelect: handleSelect,
3526
3549
  children: /* @__PURE__ */ jsx("div", {
3527
3550
  "data-u-command": id,
@@ -3536,7 +3559,8 @@ const ToolbarItem = forwardRef((props, ref) => {
3536
3559
  }, grid && !large && !icon && borderClassName),
3537
3560
  children: grid && large ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
3538
3561
  icon: iconToDisplay,
3539
- iconSize
3562
+ iconSize,
3563
+ preserveStrokeWidth
3540
3564
  }), /* @__PURE__ */ jsxs("div", {
3541
3565
  className: clsx(toolbarSelectorTriggerVariants({ disabled }), "univer-h-4 univer-justify-center univer-gap-0.5"),
3542
3566
  children: [/* @__PURE__ */ jsx(CustomLabel, {
@@ -3544,17 +3568,18 @@ const ToolbarItem = forwardRef((props, ref) => {
3544
3568
  value,
3545
3569
  label,
3546
3570
  onChange: handleSelectionsValueChange
3547
- }), /* @__PURE__ */ jsx(MoreDownIcon, {})]
3571
+ }), /* @__PURE__ */ jsx(MoreDownIcon, { preserveStrokeWidth })]
3548
3572
  })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
3549
3573
  icon: iconToDisplay,
3550
3574
  iconSize,
3575
+ preserveStrokeWidth,
3551
3576
  title: titleToDisplay,
3552
3577
  value,
3553
3578
  label,
3554
3579
  onChange: handleSelectionsValueChange
3555
3580
  }), /* @__PURE__ */ jsx("div", {
3556
3581
  className: clsx(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }),
3557
- children: /* @__PURE__ */ jsx(MoreDownIcon, {})
3582
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { preserveStrokeWidth })
3558
3583
  })] })
3559
3584
  })
3560
3585
  });
@@ -3600,6 +3625,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3600
3625
  children: icon ? /* @__PURE__ */ jsx(CustomLabel, {
3601
3626
  icon,
3602
3627
  iconSize,
3628
+ preserveStrokeWidth,
3603
3629
  title: grid && (large || showLabel) ? gridLabel : void 0
3604
3630
  }) : /* @__PURE__ */ jsx(CustomLabel, { title })
3605
3631
  });
@@ -3653,7 +3679,8 @@ function RibbonGrid({ groups, title, className, ...props }) {
3653
3679
  large: placement.rowSpan > 1,
3654
3680
  showLabel: placement.showLabel,
3655
3681
  iconSize: placement.iconSize,
3656
- fullWidth: placement.width !== void 0
3682
+ fullWidth: placement.width !== void 0,
3683
+ preserveStrokeWidth: true
3657
3684
  })
3658
3685
  }, placement.item.key))
3659
3686
  }), /* @__PURE__ */ jsx("span", {
@@ -3788,6 +3815,7 @@ function Ribbon(props) {
3788
3815
  className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3789
3816
  children: groupItem.children && ((_groupItem$children2 = groupItem.children) === null || _groupItem$children2 === void 0 ? void 0 : _groupItem$children2.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, {
3790
3817
  ...child.item,
3818
+ preserveStrokeWidth: true,
3791
3819
  ref: (ref) => {
3792
3820
  if (ref === null || ref === void 0 ? void 0 : ref.el) toolbarItemRefs.current[child.key] = {
3793
3821
  el: ref.el,
@@ -3865,7 +3893,10 @@ function Ribbon(props) {
3865
3893
  var _groupItem$children3, _groupItem$children4;
3866
3894
  return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3867
3895
  className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3868
- children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
3896
+ children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, {
3897
+ ...child.item,
3898
+ preserveStrokeWidth: true
3899
+ }, child.key)))
3869
3900
  }) }, groupItem.key);
3870
3901
  }), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
3871
3902
  className: "univer-pl-2 rtl:univer-pr-2",
@@ -3883,7 +3914,13 @@ function Ribbon(props) {
3883
3914
  className: "univer-flex univer-items-center univer-gap-2",
3884
3915
  children: /* @__PURE__ */ jsx("div", {
3885
3916
  className: "univer-flex univer-flex-wrap univer-gap-2",
3886
- children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
3917
+ children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, {
3918
+ ...child.item,
3919
+ preserveStrokeWidth: true
3920
+ }, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, {
3921
+ ...groupItem.item,
3922
+ preserveStrokeWidth: true
3923
+ }, groupItem.key)
3887
3924
  })
3888
3925
  }, groupItem.key);
3889
3926
  })
@@ -3891,7 +3928,7 @@ function Ribbon(props) {
3891
3928
  children: /* @__PURE__ */ jsx("button", {
3892
3929
  type: "button",
3893
3930
  className: toolbarButtonClassName,
3894
- children: /* @__PURE__ */ jsx(MoreVerticalIcon, {})
3931
+ children: /* @__PURE__ */ jsx(MoreVerticalIcon, { preserveStrokeWidth: true })
3895
3932
  })
3896
3933
  })
3897
3934
  })] }, activatedTab)
@@ -3961,12 +3998,34 @@ var ThemeSwitcherService = class extends Disposable {
3961
3998
  //#endregion
3962
3999
  //#region src/services/workbench/workbench.service.ts
3963
4000
  const IWorkbenchService = createIdentifier("univer.ui.workbench.service");
3964
- var WorkbenchService = class extends Disposable {
3965
- constructor(..._args) {
3966
- super(..._args);
4001
+ let WorkbenchService = class WorkbenchService extends Disposable {
4002
+ constructor(univerInstanceService) {
4003
+ super();
3967
4004
  _defineProperty(this, "_tokens", /* @__PURE__ */ new Set());
4005
+ _defineProperty(this, "_subscriptions", new Subscription());
4006
+ _defineProperty(this, "_rootUnitId", null);
4007
+ _defineProperty(this, "_rootUnitType$", new BehaviorSubject(null));
3968
4008
  _defineProperty(this, "_skeletonVisible$", new BehaviorSubject(false));
4009
+ _defineProperty(this, "rootUnitType$", this._rootUnitType$.asObservable());
3969
4010
  _defineProperty(this, "skeletonVisible$", this._skeletonVisible$.asObservable());
4011
+ this._subscriptions.add(univerInstanceService.unitAdded$.subscribe(({ unit, options }) => {
4012
+ const unitId = unit.getUnitId();
4013
+ if ((options === null || options === void 0 ? void 0 : options.makeCurrent) === false || !isWorkbenchRootUnit(unitId, options)) return;
4014
+ this._setRootUnit(unitId, unit.type);
4015
+ }));
4016
+ this._subscriptions.add(univerInstanceService.focused$.subscribe((unitId) => {
4017
+ if (!unitId) return;
4018
+ const unit = univerInstanceService.getUnit(unitId);
4019
+ if (unit && isWorkbenchRootUnit(unitId, univerInstanceService.getUnitCreateOptions(unitId) ?? void 0)) this._setRootUnit(unitId, unit.type);
4020
+ }));
4021
+ this._subscriptions.add(univerInstanceService.unitDisposed$.subscribe((unit) => {
4022
+ const unitId = unit.getUnitId();
4023
+ if (this._rootUnitId === unitId) this._setRootUnit(null, null);
4024
+ }));
4025
+ }
4026
+ _setRootUnit(unitId, unitType) {
4027
+ this._rootUnitId = unitId;
4028
+ if (this._rootUnitType$.getValue() !== unitType) this._rootUnitType$.next(unitType);
3970
4029
  }
3971
4030
  acquireSkeleton() {
3972
4031
  const token = Symbol("workbench-skeleton");
@@ -3979,11 +4038,18 @@ var WorkbenchService = class extends Disposable {
3979
4038
  return this.disposeWithMe(disposable);
3980
4039
  }
3981
4040
  dispose() {
3982
- super.dispose();
4041
+ this._subscriptions.unsubscribe();
3983
4042
  this._tokens.clear();
4043
+ this._rootUnitId = null;
4044
+ this._rootUnitType$.complete();
3984
4045
  this._skeletonVisible$.complete();
4046
+ super.dispose();
3985
4047
  }
3986
4048
  };
4049
+ WorkbenchService = __decorate([__decorateParam(0, Inject(IUniverInstanceService))], WorkbenchService);
4050
+ function isWorkbenchRootUnit(unitId, options) {
4051
+ return !isInternalEditorID(unitId) && !(options === null || options === void 0 ? void 0 : options.skipAutoRender) && !(options === null || options === void 0 ? void 0 : options.embeddedRender);
4052
+ }
3987
4053
 
3988
4054
  //#endregion
3989
4055
  //#region src/services/contextmenu/contextmenu.service.ts
@@ -4273,6 +4339,7 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
4273
4339
  })
4274
4340
  }, item.key);
4275
4341
  return showTooltip ? /* @__PURE__ */ jsx(Tooltip, {
4342
+ className: "univer-fill-mode-backwards univer-delay-100",
4276
4343
  title: item.tooltip,
4277
4344
  children: ele
4278
4345
  }, item.key) : ele;
@@ -6261,7 +6328,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
6261
6328
  //#endregion
6262
6329
  //#region package.json
6263
6330
  var name = "@univerjs/ui";
6264
- var version = "1.0.0-beta.1";
6331
+ var version = "1.0.0-beta.2";
6265
6332
 
6266
6333
  //#endregion
6267
6334
  //#region src/views/color-picker/interface.ts
@@ -23607,7 +23674,10 @@ function MobileRibbon(props) {
23607
23674
  disabled: activeIndex === 0,
23608
23675
  "aria-label": localeService.t("ui.navigation.previous"),
23609
23676
  onClick: () => selectTab(activeIndex - 1),
23610
- children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-rotate-180 univer-text-sm" })
23677
+ children: /* @__PURE__ */ jsx(MoreLeftIcon, {
23678
+ className: "univer-rotate-180 univer-text-sm",
23679
+ preserveStrokeWidth: true
23680
+ })
23611
23681
  })
23612
23682
  }),
23613
23683
  /* @__PURE__ */ jsx("div", {
@@ -23644,7 +23714,10 @@ function MobileRibbon(props) {
23644
23714
  disabled: activeIndex >= ribbon.length - 1,
23645
23715
  "aria-label": localeService.t("ui.navigation.next"),
23646
23716
  onClick: () => selectTab(activeIndex + 1),
23647
- children: /* @__PURE__ */ jsx(MoreRightIcon, { className: "univer-text-sm" })
23717
+ children: /* @__PURE__ */ jsx(MoreRightIcon, {
23718
+ className: "univer-text-sm",
23719
+ preserveStrokeWidth: true
23720
+ })
23648
23721
  }), hasHeaderMenu && /* @__PURE__ */ jsx("div", {
23649
23722
  className: "univer-flex univer-items-center univer-gap-1 [&>*]:univer-m-0 [&>*]:univer-inline-flex [&>*]:univer-min-h-7 [&>*]:univer-min-w-7 [&>*]:univer-appearance-none [&>*]:univer-items-center [&>*]:univer-justify-center [&>*]:univer-rounded-md [&>*]:univer-border-0 [&>*]:univer-px-1.5 [&>*]:univer-leading-none [&>*]:univer-outline-none",
23650
23723
  children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
@@ -23664,7 +23737,10 @@ function MobileRibbon(props) {
23664
23737
  disabled: !canScrollLeft,
23665
23738
  "aria-label": localeService.t("ui.navigation.previous"),
23666
23739
  onClick: () => scrollToolbar("left"),
23667
- children: /* @__PURE__ */ jsx(MoreLeftIcon, { className: "univer-text-sm" })
23740
+ children: /* @__PURE__ */ jsx(MoreLeftIcon, {
23741
+ className: "univer-text-sm",
23742
+ preserveStrokeWidth: true
23743
+ })
23668
23744
  }),
23669
23745
  /* @__PURE__ */ jsx("div", {
23670
23746
  ref: toolbarScrollRef,
@@ -23678,7 +23754,10 @@ function MobileRibbon(props) {
23678
23754
  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 }),
23679
23755
  children: groupItems.map((child) => child.item && /* @__PURE__ */ jsx("div", {
23680
23756
  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"),
23681
- children: /* @__PURE__ */ jsx(ToolbarItem, { ...child.item })
23757
+ children: /* @__PURE__ */ jsx(ToolbarItem, {
23758
+ ...child.item,
23759
+ preserveStrokeWidth: true
23760
+ })
23682
23761
  }, child.key))
23683
23762
  }, groupItem.key);
23684
23763
  })
@@ -23693,7 +23772,10 @@ function MobileRibbon(props) {
23693
23772
  disabled: !canScrollRight,
23694
23773
  "aria-label": localeService.t("ui.navigation.next"),
23695
23774
  onClick: () => scrollToolbar("right"),
23696
- children: /* @__PURE__ */ jsx(MoreRightIcon, { className: "univer-text-sm" })
23775
+ children: /* @__PURE__ */ jsx(MoreRightIcon, {
23776
+ className: "univer-text-sm",
23777
+ preserveStrokeWidth: true
23778
+ })
23697
23779
  })
23698
23780
  ]
23699
23781
  })]
@@ -25340,6 +25422,43 @@ let DesktopNotificationService = class DesktopNotificationService extends Dispos
25340
25422
  };
25341
25423
  DesktopNotificationService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IUIPartsService)], DesktopNotificationService);
25342
25424
 
25425
+ //#endregion
25426
+ //#region src/services/presence/unit-presence-ui-adapter.service.ts
25427
+ const IUnitPresenceUIAdapterRegistry = createIdentifier("ui.unit-presence-adapter-registry");
25428
+ const EMPTY_ADAPTERS = Object.freeze([]);
25429
+ var UnitPresenceUIAdapterRegistry = class extends Disposable {
25430
+ constructor(..._args) {
25431
+ super(..._args);
25432
+ _defineProperty(this, "_adapters", /* @__PURE__ */ new Map());
25433
+ _defineProperty(this, "_adapters$", new BehaviorSubject(EMPTY_ADAPTERS));
25434
+ _defineProperty(this, "adapters$", this._adapters$.asObservable());
25435
+ }
25436
+ dispose() {
25437
+ this._adapters.clear();
25438
+ this._adapters$.complete();
25439
+ super.dispose();
25440
+ }
25441
+ register(adapter) {
25442
+ if (this._adapters.has(adapter.unitType)) throw new Error(`A unit presence adapter is already registered for UniverInstanceType "${adapter.unitType}".`);
25443
+ this._adapters.set(adapter.unitType, adapter);
25444
+ this._emitAdapters();
25445
+ return toDisposable(() => {
25446
+ if (this._adapters.get(adapter.unitType) !== adapter) return;
25447
+ this._adapters.delete(adapter.unitType);
25448
+ this._emitAdapters();
25449
+ });
25450
+ }
25451
+ get(unitType) {
25452
+ return this._adapters.get(unitType) ?? null;
25453
+ }
25454
+ getAll() {
25455
+ return this._adapters$.getValue();
25456
+ }
25457
+ _emitAdapters() {
25458
+ this._adapters$.next(Object.freeze(Array.from(this._adapters.values())));
25459
+ }
25460
+ };
25461
+
25343
25462
  //#endregion
25344
25463
  //#region src/services/sidebar/desktop-sidebar.service.ts
25345
25464
  var DesktopSidebarService = class extends Disposable {
@@ -25411,6 +25530,61 @@ var DesktopSidebarService = class extends Disposable {
25411
25530
  }
25412
25531
  };
25413
25532
 
25533
+ //#endregion
25534
+ //#region src/services/undo-redo/undo-redo-group.service.ts
25535
+ /**
25536
+ * Copyright 2023-present DreamNum Co., Ltd.
25537
+ *
25538
+ * Licensed under the Apache License, Version 2.0 (the "License");
25539
+ * you may not use this file except in compliance with the License.
25540
+ * You may obtain a copy of the License at
25541
+ *
25542
+ * http://www.apache.org/licenses/LICENSE-2.0
25543
+ *
25544
+ * Unless required by applicable law or agreed to in writing, software
25545
+ * distributed under the License is distributed on an "AS IS" BASIS,
25546
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25547
+ * See the License for the specific language governing permissions and
25548
+ * limitations under the License.
25549
+ */
25550
+ const HISTORY_GROUP_WINDOW = 1e3;
25551
+ let UndoRedoGroupService = class UndoRedoGroupService {
25552
+ constructor(_undoRedoService) {
25553
+ this._undoRedoService = _undoRedoService;
25554
+ _defineProperty(this, "_sessions", /* @__PURE__ */ new Map());
25555
+ }
25556
+ run(unitId, action, mode = "append") {
25557
+ return this._run(unitId, generateRandomId(8), mode, action);
25558
+ }
25559
+ createRunner(unitId, mode = "append") {
25560
+ const groupId = generateRandomId(8);
25561
+ return (action) => this._run(unitId, groupId, mode, action);
25562
+ }
25563
+ runTimed(unitId, scope, action, mode = "replace") {
25564
+ const now = Date.now();
25565
+ const sessionKey = `${unitId}:${scope}`;
25566
+ const current = this._sessions.get(sessionKey);
25567
+ const groupId = current && current.expiresAt >= now ? current.id : generateRandomId(8);
25568
+ this._sessions.set(sessionKey, {
25569
+ id: groupId,
25570
+ expiresAt: now + HISTORY_GROUP_WINDOW
25571
+ });
25572
+ if (this._sessions.size > 100) this._sessions.forEach((session, key) => {
25573
+ if (session.expiresAt < now) this._sessions.delete(key);
25574
+ });
25575
+ return this._run(unitId, groupId, mode, action);
25576
+ }
25577
+ _run(unitId, groupId, mode, action) {
25578
+ const group = this._undoRedoService.beginUndoRedoGroup(unitId, groupId, mode);
25579
+ try {
25580
+ return action();
25581
+ } finally {
25582
+ group.dispose();
25583
+ }
25584
+ }
25585
+ };
25586
+ UndoRedoGroupService = __decorate([__decorateParam(0, IUndoRedoService)], UndoRedoGroupService);
25587
+
25414
25588
  //#endregion
25415
25589
  //#region src/mobile-plugin.ts
25416
25590
  const DISABLE_AUTO_FOCUS_KEY$1 = "DISABLE_AUTO_FOCUS";
@@ -25432,6 +25606,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
25432
25606
  [IconManager],
25433
25607
  [ComponentsController],
25434
25608
  [ThemeSwitcherService],
25609
+ [UndoRedoGroupService],
25435
25610
  [IWorkbenchService, { useClass: WorkbenchService }],
25436
25611
  [ZIndexManager],
25437
25612
  [ShortcutPanelService],
@@ -25440,6 +25615,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
25440
25615
  [IRibbonService, { useClass: DesktopRibbonService }],
25441
25616
  [IShortcutService, { useClass: ShortcutService }],
25442
25617
  [IPlatformService, { useClass: PlatformService }],
25618
+ [IUnitPresenceUIAdapterRegistry, { useClass: UnitPresenceUIAdapterRegistry }],
25443
25619
  [IMenuManagerService, { useClass: MenuManagerService }],
25444
25620
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
25445
25621
  [IContextMenuService, { useClass: ContextMenuService }],
@@ -25514,98 +25690,6 @@ UniverMobileUIPlugin = __decorate([
25514
25690
  __decorateParam(3, IConfigService)
25515
25691
  ], UniverMobileUIPlugin);
25516
25692
 
25517
- //#endregion
25518
- //#region src/services/presence/unit-presence-ui-adapter.service.ts
25519
- const IUnitPresenceUIAdapterRegistry = createIdentifier("ui.unit-presence-adapter-registry");
25520
- const EMPTY_ADAPTERS = Object.freeze([]);
25521
- var UnitPresenceUIAdapterRegistry = class extends Disposable {
25522
- constructor(..._args) {
25523
- super(..._args);
25524
- _defineProperty(this, "_adapters", /* @__PURE__ */ new Map());
25525
- _defineProperty(this, "_adapters$", new BehaviorSubject(EMPTY_ADAPTERS));
25526
- _defineProperty(this, "adapters$", this._adapters$.asObservable());
25527
- }
25528
- dispose() {
25529
- this._adapters.clear();
25530
- this._adapters$.complete();
25531
- super.dispose();
25532
- }
25533
- register(adapter) {
25534
- if (this._adapters.has(adapter.unitType)) throw new Error(`A unit presence adapter is already registered for UniverInstanceType "${adapter.unitType}".`);
25535
- this._adapters.set(adapter.unitType, adapter);
25536
- this._emitAdapters();
25537
- return toDisposable(() => {
25538
- if (this._adapters.get(adapter.unitType) !== adapter) return;
25539
- this._adapters.delete(adapter.unitType);
25540
- this._emitAdapters();
25541
- });
25542
- }
25543
- get(unitType) {
25544
- return this._adapters.get(unitType) ?? null;
25545
- }
25546
- getAll() {
25547
- return this._adapters$.getValue();
25548
- }
25549
- _emitAdapters() {
25550
- this._adapters$.next(Object.freeze(Array.from(this._adapters.values())));
25551
- }
25552
- };
25553
-
25554
- //#endregion
25555
- //#region src/services/undo-redo/undo-redo-group.service.ts
25556
- /**
25557
- * Copyright 2023-present DreamNum Co., Ltd.
25558
- *
25559
- * Licensed under the Apache License, Version 2.0 (the "License");
25560
- * you may not use this file except in compliance with the License.
25561
- * You may obtain a copy of the License at
25562
- *
25563
- * http://www.apache.org/licenses/LICENSE-2.0
25564
- *
25565
- * Unless required by applicable law or agreed to in writing, software
25566
- * distributed under the License is distributed on an "AS IS" BASIS,
25567
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25568
- * See the License for the specific language governing permissions and
25569
- * limitations under the License.
25570
- */
25571
- const HISTORY_GROUP_WINDOW = 1e3;
25572
- let UndoRedoGroupService = class UndoRedoGroupService {
25573
- constructor(_undoRedoService) {
25574
- this._undoRedoService = _undoRedoService;
25575
- _defineProperty(this, "_sessions", /* @__PURE__ */ new Map());
25576
- }
25577
- run(unitId, action, mode = "append") {
25578
- return this._run(unitId, generateRandomId(8), mode, action);
25579
- }
25580
- createRunner(unitId, mode = "append") {
25581
- const groupId = generateRandomId(8);
25582
- return (action) => this._run(unitId, groupId, mode, action);
25583
- }
25584
- runTimed(unitId, scope, action, mode = "replace") {
25585
- const now = Date.now();
25586
- const sessionKey = `${unitId}:${scope}`;
25587
- const current = this._sessions.get(sessionKey);
25588
- const groupId = current && current.expiresAt >= now ? current.id : generateRandomId(8);
25589
- this._sessions.set(sessionKey, {
25590
- id: groupId,
25591
- expiresAt: now + HISTORY_GROUP_WINDOW
25592
- });
25593
- if (this._sessions.size > 100) this._sessions.forEach((session, key) => {
25594
- if (session.expiresAt < now) this._sessions.delete(key);
25595
- });
25596
- return this._run(unitId, groupId, mode, action);
25597
- }
25598
- _run(unitId, groupId, mode, action) {
25599
- const group = this._undoRedoService.beginUndoRedoGroup(unitId, groupId, mode);
25600
- try {
25601
- return action();
25602
- } finally {
25603
- group.dispose();
25604
- }
25605
- }
25606
- };
25607
- UndoRedoGroupService = __decorate([__decorateParam(0, IUndoRedoService)], UndoRedoGroupService);
25608
-
25609
25693
  //#endregion
25610
25694
  //#region src/plugin.ts
25611
25695
  const DISABLE_AUTO_FOCUS_KEY = "DISABLE_AUTO_FOCUS";
package/lib/index.css CHANGED
@@ -1431,6 +1431,10 @@
1431
1431
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
1432
1432
  }
1433
1433
 
1434
+ .univer-delay-100 {
1435
+ transition-delay: .1s;
1436
+ }
1437
+
1434
1438
  .univer-duration-150 {
1435
1439
  transition-duration: .15s;
1436
1440
  }
@@ -1475,6 +1479,14 @@
1475
1479
  animation-duration: .15s;
1476
1480
  }
1477
1481
 
1482
+ .univer-delay-100 {
1483
+ animation-delay: .1s;
1484
+ }
1485
+
1486
+ .univer-fill-mode-backwards {
1487
+ animation-fill-mode: backwards;
1488
+ }
1489
+
1478
1490
  .univer-context-menu-hover-suppressed button:hover:not(:focus) {
1479
1491
  background-color: #0000 !important;
1480
1492
  }