@univerjs/ui 0.4.2 → 0.5.0-beta.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.
Files changed (49) hide show
  1. package/lib/cjs/facade.js +1 -0
  2. package/lib/cjs/index.js +22 -22
  3. package/lib/cjs/locale/en-US.js +1 -0
  4. package/lib/cjs/locale/fa-IR.js +1 -0
  5. package/lib/cjs/locale/ru-RU.js +1 -0
  6. package/lib/cjs/locale/vi-VN.js +1 -0
  7. package/lib/cjs/locale/zh-CN.js +1 -0
  8. package/lib/cjs/locale/zh-TW.js +1 -0
  9. package/lib/es/facade.js +46 -0
  10. package/lib/es/index.js +5941 -6313
  11. package/lib/es/locale/en-US.js +64 -0
  12. package/lib/es/locale/fa-IR.js +64 -0
  13. package/lib/es/locale/ru-RU.js +64 -0
  14. package/lib/es/locale/vi-VN.js +64 -0
  15. package/lib/es/locale/zh-CN.js +64 -0
  16. package/lib/es/locale/zh-TW.js +64 -0
  17. package/lib/index.css +1 -1
  18. package/lib/types/common/menu-hidden-observable.d.ts +1 -1
  19. package/lib/types/components/hooks/observable.d.ts +2 -0
  20. package/lib/types/components/progress-bar/ProgressBar.d.ts +1 -0
  21. package/lib/types/facade/f-hooks.d.ts +38 -0
  22. package/lib/types/facade/f-univer.d.ts +23 -0
  23. package/lib/types/facade/index.d.ts +17 -0
  24. package/lib/types/index.d.ts +5 -5
  25. package/lib/types/services/menu/menu.d.ts +0 -32
  26. package/lib/types/services/popup/canvas-popup.service.d.ts +5 -2
  27. package/lib/types/services/shortcut/shortcut.service.d.ts +2 -2
  28. package/lib/types/services/sidebar/desktop-sidebar.service.d.ts +4 -1
  29. package/lib/types/services/sidebar/hooks/useSidebarClick.d.ts +19 -0
  30. package/lib/types/services/sidebar/sidebar.service.d.ts +2 -0
  31. package/lib/types/views/components/popup/RectPopup.d.ts +41 -0
  32. package/lib/types/views/components/ribbon/hook.d.ts +1 -24
  33. package/lib/umd/facade.js +1 -0
  34. package/lib/umd/index.js +22 -22
  35. package/lib/umd/locale/en-US.js +1 -0
  36. package/lib/umd/locale/fa-IR.js +1 -0
  37. package/lib/umd/locale/ru-RU.js +1 -0
  38. package/lib/umd/locale/vi-VN.js +1 -0
  39. package/lib/umd/locale/zh-CN.js +1 -0
  40. package/lib/umd/locale/zh-TW.js +1 -0
  41. package/package.json +37 -21
  42. package/lib/locale/en-US.json +0 -61
  43. package/lib/locale/fa-IR.json +0 -61
  44. package/lib/locale/ru-RU.json +0 -61
  45. package/lib/locale/vi-VN.json +0 -61
  46. package/lib/locale/zh-CN.json +0 -61
  47. package/lib/locale/zh-TW.json +0 -61
  48. package/lib/types/commands/operations/editor/set-editor-resize.operation.d.ts +0 -2
  49. package/lib/types/services/menu/menu.service.d.ts +0 -57
@@ -1,10 +1,12 @@
1
1
  import { Nullable, Disposable } from '@univerjs/core';
2
- import { IRectPopupProps } from '@univerjs/design';
3
2
  import { IBoundRectNoAngle } from '@univerjs/engine-render';
4
3
  import { Observable } from 'rxjs';
5
- export interface IPopup extends Omit<IRectPopupProps, 'children' | 'hidden'> {
4
+ import { IRectPopupProps } from '../../views/components/popup/RectPopup';
5
+ export interface IPopup extends Omit<IRectPopupProps, 'children' | 'hidden' | 'excludeRects' | 'anchorRect$'> {
6
6
  anchorRect$: Observable<IBoundRectNoAngle>;
7
+ anchorRect?: IBoundRectNoAngle;
7
8
  excludeRects$?: Observable<IBoundRectNoAngle[]>;
9
+ excludeRects?: Nullable<IBoundRectNoAngle[]>;
8
10
  componentKey: string;
9
11
  unitId: string;
10
12
  subUnitId: string;
@@ -12,6 +14,7 @@ export interface IPopup extends Omit<IRectPopupProps, 'children' | 'hidden'> {
12
14
  canvasElement: HTMLCanvasElement;
13
15
  hideOnInvisible?: boolean;
14
16
  hiddenType?: 'hide' | 'destroy';
17
+ hiddenRects$?: Observable<IBoundRectNoAngle[]>;
15
18
  }
16
19
  export interface ICanvasPopupService {
17
20
  addPopup(item: IPopup): string;
@@ -1,8 +1,8 @@
1
- import { Disposable, ICommandService, IContextService, IDisposable } from '@univerjs/core';
1
+ import { IDisposable, Disposable, ICommandService, IContextService } from '@univerjs/core';
2
2
  import { Observable } from 'rxjs';
3
+ import { KeyCode } from './keycode';
3
4
  import { ILayoutService } from '../layout/layout.service';
4
5
  import { IPlatformService } from '../platform/platform.service';
5
- import { KeyCode } from './keycode';
6
6
  /**
7
7
  * A shortcut item that could be registered to the {@link IShortcutService}.
8
8
  */
@@ -1,13 +1,16 @@
1
1
  import { IDisposable } from '@univerjs/core';
2
- import { Subject } from 'rxjs';
3
2
  import { ISidebarMethodOptions } from '../../views/components/sidebar/interface';
4
3
  import { ISidebarService } from './sidebar.service';
4
+ import { Subject } from 'rxjs';
5
5
  export declare class DesktopSidebarService implements ISidebarService {
6
6
  private _sidebarOptions;
7
7
  readonly sidebarOptions$: Subject<ISidebarMethodOptions>;
8
8
  readonly scrollEvent$: Subject<Event>;
9
+ private container?;
9
10
  get visible(): boolean;
10
11
  get options(): ISidebarMethodOptions;
11
12
  open(params: ISidebarMethodOptions): IDisposable;
12
13
  close(id?: string): void;
14
+ getContainer(): HTMLElement | undefined;
15
+ setContainer(element: HTMLElement): void;
13
16
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Response panel to a click event.
18
+ */
19
+ export declare const useSidebarClick: (cb: (event: MouseEvent) => void) => void;
@@ -8,6 +8,8 @@ export interface ISidebarService {
8
8
  close(id?: string): void;
9
9
  get visible(): boolean;
10
10
  get options(): ISidebarMethodOptions;
11
+ getContainer(): HTMLElement | undefined;
12
+ setContainer(element?: HTMLElement): void;
11
13
  }
12
14
  export declare const ILeftSidebarService: import('@wendellhu/redi').IdentifierDecorator<ISidebarService>;
13
15
  export declare const ISidebarService: import('@wendellhu/redi').IdentifierDecorator<ISidebarService>;
@@ -0,0 +1,41 @@
1
+ import { Nullable } from '@univerjs/core';
2
+ import { RefObject, default as React } from 'react';
3
+ import { Observable } from 'rxjs';
4
+ interface IAbsolutePosition {
5
+ left: number;
6
+ right: number;
7
+ top: number;
8
+ bottom: number;
9
+ }
10
+ export interface IRectPopupProps {
11
+ children?: React.ReactNode;
12
+ /**
13
+ * the anchor element bounding rect
14
+ */
15
+ anchorRect$: Observable<IAbsolutePosition>;
16
+ excludeRects?: RefObject<Nullable<IAbsolutePosition[]>>;
17
+ direction?: 'vertical' | 'horizontal' | 'left' | 'top' | 'right' | 'left' | 'bottom' | 'bottom-center' | 'top-center';
18
+ hidden?: boolean;
19
+ onClickOutside?: (e: MouseEvent) => void;
20
+ excludeOutside?: HTMLElement[];
21
+ onContextMenu?: () => void;
22
+ onPointerEnter?: (e: React.PointerEvent<HTMLElement>) => void;
23
+ onPointerLeave?: (e: React.PointerEvent<HTMLElement>) => void;
24
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
25
+ }
26
+ export interface IPopupLayoutInfo extends Pick<IRectPopupProps, 'direction'> {
27
+ position: IAbsolutePosition;
28
+ width: number;
29
+ height: number;
30
+ containerWidth: number;
31
+ containerHeight: number;
32
+ }
33
+ declare function RectPopup(props: IRectPopupProps): React.JSX.Element;
34
+ declare namespace RectPopup {
35
+ var calcPopupPosition: (layout: IPopupLayoutInfo) => {
36
+ top: number;
37
+ left: number;
38
+ };
39
+ var useContext: () => RefObject<IAbsolutePosition | undefined>;
40
+ }
41
+ export { RectPopup };
@@ -1,26 +1,4 @@
1
- import { IDisplayMenuItem, IMenuItem, MenuGroup, MenuPosition } from '../../../services/menu/menu';
2
- type MenuPositionWithCustom = MenuPosition | string;
3
- export interface IMenuGroup {
4
- name: MenuPositionWithCustom;
5
- menuItems: Array<IDisplayMenuItem<IMenuItem>>;
6
- }
7
- export interface IToolbarRenderHookHandler {
8
- /** The activated category. */
9
- category: MenuPositionWithCustom;
10
- /** Update current activate category. */
11
- setCategory: (position: MenuPositionWithCustom) => void;
12
- visibleItems: IDisplayMenuItem<IMenuItem>[];
13
- /** Menu grouped in this category. */
14
- groups: IMenuGroup[];
15
- groupsByKey: Record<MenuGroup, Array<IDisplayMenuItem<IMenuItem>>>;
16
- }
17
- export declare function useSimpleToolbarGroups(category: MenuPositionWithCustom): IDisplayMenuItem<IMenuItem>[];
18
- /**
19
- * If your custom toolbar component need to render menu items by their category,
20
- * you can use this hook to get the toolbar status.
21
- * @returns toolbar status
22
- */
23
- export declare function useToolbarGroups(categories: MenuPositionWithCustom[], initCategory?: string): IToolbarRenderHookHandler;
1
+ import { IDisplayMenuItem, IMenuItem } from '../../../services/menu/menu';
24
2
  export interface IToolbarItemStatus {
25
3
  disabled: boolean;
26
4
  value: any;
@@ -33,4 +11,3 @@ export interface IToolbarItemStatus {
33
11
  * @returns The menu item's status
34
12
  */
35
13
  export declare function useToolbarItemStatus(menuItem: IDisplayMenuItem<IMenuItem>): IToolbarItemStatus;
36
- export {};
@@ -0,0 +1 @@
1
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?n(require("@univerjs/core"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/ui"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.UniverCore,e.UniverUi))})(this,function(e,n){"use strict";class d extends e.FUniver{copy(){return this._commandService.executeCommand(n.CopyCommand.id)}paste(){return this._commandService.executeCommand(n.PasteCommand.id)}openSiderbar(i){return this._injector.get(n.ISidebarService).open(i)}openDialog(i){const o=this._injector.get(n.IDialogService).open({...i,onClose:()=>{o.dispose()}});return o}}e.FUniver.extend(d);class r extends e.FHooks{onBeforeCopy(i){return this._injector.get(e.ICommandService).beforeCommandExecuted(o=>{o.id===n.CopyCommand.id&&i()})}onCopy(i){return this._injector.get(e.ICommandService).onCommandExecuted(o=>{o.id===n.CopyCommand.id&&i()})}onBeforePaste(i){return this._injector.get(e.ICommandService).beforeCommandExecuted(o=>{o.id===n.PasteCommand.id&&i()})}onPaste(i){return this._injector.get(e.ICommandService).onCommandExecuted(o=>{o.id===n.PasteCommand.id&&i()})}}e.FHooks.extend(r)});