@univerjs/drawing-ui 1.0.0-rc.0 → 1.0.1

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 (105) hide show
  1. package/lib/cjs/index.js +3939 -2385
  2. package/lib/cjs/locale/ar-SA.js +6 -1
  3. package/lib/cjs/locale/ca-ES.js +6 -1
  4. package/lib/cjs/locale/de-DE.js +6 -1
  5. package/lib/cjs/locale/en-US.js +6 -1
  6. package/lib/cjs/locale/es-ES.js +6 -1
  7. package/lib/cjs/locale/fa-IR.js +6 -1
  8. package/lib/cjs/locale/fr-FR.js +6 -1
  9. package/lib/cjs/locale/id-ID.js +6 -1
  10. package/lib/cjs/locale/it-IT.js +6 -1
  11. package/lib/cjs/locale/ja-JP.js +6 -1
  12. package/lib/cjs/locale/ko-KR.js +6 -1
  13. package/lib/cjs/locale/pl-PL.js +6 -1
  14. package/lib/cjs/locale/pt-BR.js +6 -1
  15. package/lib/cjs/locale/ru-RU.js +6 -1
  16. package/lib/cjs/locale/sk-SK.js +6 -1
  17. package/lib/cjs/locale/vi-VN.js +6 -1
  18. package/lib/cjs/locale/zh-CN.js +6 -1
  19. package/lib/cjs/locale/zh-HK.js +6 -1
  20. package/lib/cjs/locale/zh-TW.js +6 -1
  21. package/lib/es/index.js +3944 -2390
  22. package/lib/es/locale/ar-SA.js +6 -0
  23. package/lib/es/locale/ca-ES.js +6 -0
  24. package/lib/es/locale/de-DE.js +6 -0
  25. package/lib/es/locale/en-US.js +6 -0
  26. package/lib/es/locale/es-ES.js +6 -0
  27. package/lib/es/locale/fa-IR.js +6 -0
  28. package/lib/es/locale/fr-FR.js +6 -0
  29. package/lib/es/locale/id-ID.js +6 -0
  30. package/lib/es/locale/it-IT.js +6 -0
  31. package/lib/es/locale/ja-JP.js +6 -0
  32. package/lib/es/locale/ko-KR.js +6 -0
  33. package/lib/es/locale/pl-PL.js +6 -0
  34. package/lib/es/locale/pt-BR.js +6 -0
  35. package/lib/es/locale/ru-RU.js +6 -0
  36. package/lib/es/locale/sk-SK.js +6 -0
  37. package/lib/es/locale/vi-VN.js +6 -0
  38. package/lib/es/locale/zh-CN.js +6 -0
  39. package/lib/es/locale/zh-HK.js +6 -0
  40. package/lib/es/locale/zh-TW.js +6 -0
  41. package/lib/index.css +135 -0
  42. package/lib/index.js +3944 -2390
  43. package/lib/locale/ar-SA.js +6 -0
  44. package/lib/locale/ca-ES.js +6 -0
  45. package/lib/locale/de-DE.js +6 -0
  46. package/lib/locale/en-US.js +6 -0
  47. package/lib/locale/es-ES.js +6 -0
  48. package/lib/locale/fa-IR.js +6 -0
  49. package/lib/locale/fr-FR.js +6 -0
  50. package/lib/locale/id-ID.js +6 -0
  51. package/lib/locale/it-IT.js +6 -0
  52. package/lib/locale/ja-JP.js +6 -0
  53. package/lib/locale/ko-KR.js +6 -0
  54. package/lib/locale/pl-PL.js +6 -0
  55. package/lib/locale/pt-BR.js +6 -0
  56. package/lib/locale/ru-RU.js +6 -0
  57. package/lib/locale/sk-SK.js +6 -0
  58. package/lib/locale/vi-VN.js +6 -0
  59. package/lib/locale/zh-CN.js +6 -0
  60. package/lib/locale/zh-HK.js +6 -0
  61. package/lib/locale/zh-TW.js +6 -0
  62. package/lib/types/commands/operations/drawing-group.operation.d.ts +1 -1
  63. package/lib/types/controllers/image-cropper.controller.d.ts +2 -1
  64. package/lib/types/controllers/image-update.controller.d.ts +2 -5
  65. package/lib/types/controllers/mobile/image-cropper.controller.d.ts +51 -0
  66. package/lib/types/controllers/mobile/image-update.controller.d.ts +39 -0
  67. package/lib/types/controllers/mobile/ui.controller.d.ts +27 -0
  68. package/lib/types/controllers/utils.d.ts +5 -3
  69. package/lib/types/index.d.ts +4 -1
  70. package/lib/types/locale/en-US.d.ts +6 -0
  71. package/lib/types/utils/image-crop-transform.d.ts +31 -0
  72. package/lib/types/views/crop/MobileCropActions.d.ts +16 -0
  73. package/lib/types/views/image-popup-menu/ImagePopupMenu.d.ts +2 -1
  74. package/lib/types/views/image-popup-menu/MobileImagePopupMenu.d.ts +2 -1
  75. package/lib/types/views/image-preview/mobile-image-preview-button.d.ts +37 -0
  76. package/lib/types/views/object-list-panel/MobileObjectListPanel.d.ts +17 -0
  77. package/lib/types/views/object-list-panel/ObjectListPanelBase.d.ts +71 -6
  78. package/lib/types/views/panel/DrawingCommonPanel.d.ts +1 -0
  79. package/lib/types/views/panel/ImageCropper.d.ts +1 -0
  80. package/lib/types/views/panel/MobileDrawingArrange.d.ts +22 -0
  81. package/lib/types/views/panel/MobileDrawingControls.d.ts +32 -0
  82. package/lib/types/views/panel/MobileImageCropper.d.ts +17 -0
  83. package/lib/types/views/panel/component-name.d.ts +20 -0
  84. package/lib/types/views/panel/use-image-cropper.d.ts +31 -0
  85. package/lib/umd/index.js +8 -2
  86. package/lib/umd/locale/ar-SA.js +1 -1
  87. package/lib/umd/locale/ca-ES.js +1 -1
  88. package/lib/umd/locale/de-DE.js +1 -1
  89. package/lib/umd/locale/en-US.js +1 -1
  90. package/lib/umd/locale/es-ES.js +1 -1
  91. package/lib/umd/locale/fa-IR.js +1 -1
  92. package/lib/umd/locale/fr-FR.js +1 -1
  93. package/lib/umd/locale/id-ID.js +1 -1
  94. package/lib/umd/locale/it-IT.js +1 -1
  95. package/lib/umd/locale/ja-JP.js +1 -1
  96. package/lib/umd/locale/ko-KR.js +1 -1
  97. package/lib/umd/locale/pl-PL.js +1 -1
  98. package/lib/umd/locale/pt-BR.js +1 -1
  99. package/lib/umd/locale/ru-RU.js +1 -1
  100. package/lib/umd/locale/sk-SK.js +1 -1
  101. package/lib/umd/locale/vi-VN.js +1 -1
  102. package/lib/umd/locale/zh-CN.js +1 -1
  103. package/lib/umd/locale/zh-HK.js +1 -1
  104. package/lib/umd/locale/zh-TW.js +1 -1
  105. package/package.json +10 -10
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import type { IValueOption } from '@univerjs/ui';
16
17
  export interface IImagePopupMenuItem {
17
18
  label: string;
18
19
  index: number;
@@ -23,7 +24,7 @@ export interface IImagePopupMenuItem {
23
24
  value?: string;
24
25
  options?: Array<{
25
26
  icon?: string;
26
- label: unknown;
27
+ label: IValueOption['label'];
27
28
  value: string;
28
29
  }>;
29
30
  commandParamsFactory?: (value: string) => object;
@@ -16,8 +16,9 @@
16
16
  import type { IImagePopupMenuExtraProps } from './ImagePopupMenu';
17
17
  interface IMobileImagePopupMenuProps {
18
18
  popup: {
19
- extraProps?: Pick<IImagePopupMenuExtraProps, 'menuItems'> & {
19
+ extraProps?: Pick<IImagePopupMenuExtraProps, 'menuItems' | 'variant'> & {
20
20
  dialogId?: string;
21
+ onClose?: () => void;
21
22
  };
22
23
  };
23
24
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { ThemeService } from '@univerjs/core';
17
+ import type { Image, Scene, UniverRenderingContext } from '@univerjs/engine-render';
18
+ import { Rect } from '@univerjs/engine-render';
19
+ /** Transient canvas chrome: never part of the image model or its transformer. */
20
+ export declare class MobileImagePreviewButton extends Rect {
21
+ private readonly _image;
22
+ private readonly _scene;
23
+ private _enabled;
24
+ private readonly _icon;
25
+ private readonly _iconContainer;
26
+ private readonly _gesture;
27
+ private _pressed;
28
+ private _background;
29
+ private _border;
30
+ private _pressedBackground;
31
+ constructor(_image: Image, _scene: Scene, themeService: ThemeService, preview: () => void);
32
+ setPreviewEnabled(enabled: boolean): void;
33
+ dispose(): void;
34
+ private _setPressed;
35
+ private _syncPosition;
36
+ protected _draw(ctx: UniverRenderingContext): void;
37
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IObjectListPanelBaseProps } from './ObjectListPanelBase';
17
+ export declare function MobileObjectListPanel(props: IObjectListPanelBaseProps): import("react").JSX.Element;
@@ -13,7 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { ReactNode } from 'react';
16
+ import type { ComponentProps, ComponentType, FocusEvent, KeyboardEvent, ReactNode } from 'react';
17
+ import { Input } from '@univerjs/design';
17
18
  export interface IObjectListPanelCapabilities {
18
19
  arrange?: boolean;
19
20
  description?: boolean;
@@ -23,6 +24,7 @@ export interface IObjectListPanelCapabilities {
23
24
  selectable?: boolean;
24
25
  visible?: boolean;
25
26
  }
27
+ type ObjectListFilterMode = 'all' | 'hidden' | 'locked';
26
28
  export interface IObjectListPanelItem {
27
29
  id: string;
28
30
  name: string;
@@ -75,11 +77,6 @@ export interface IObjectListPanelLabels {
75
77
  sectionFloating: string;
76
78
  }
77
79
  export type ObjectListPanelTypeNameKey = 'chart' | 'connector' | 'container' | 'dom' | 'group' | 'image' | 'object' | 'placeholder' | 'shape' | 'smartArt' | 'table' | 'text' | 'unit' | 'video';
78
- interface IObjectListPanelLocaleService {
79
- t: (key: string) => string;
80
- }
81
- export declare function getObjectListPanelLabels(localeService: IObjectListPanelLocaleService): IObjectListPanelLabels;
82
- export declare function getObjectListPanelTypeName(localeService: IObjectListPanelLocaleService, typeName: ObjectListPanelTypeNameKey): string;
83
80
  export interface IObjectListPanelBaseProps {
84
81
  items: IObjectListPanelItem[];
85
82
  selectedIds: string[];
@@ -102,8 +99,76 @@ export interface IObjectListPanelBaseProps {
102
99
  onLocate?: (objectId: string) => void;
103
100
  onReorder?: (sourceObjectId: string, targetObjectId: string) => void;
104
101
  }
102
+ export declare function hasCapability(panelCapabilities: IObjectListPanelCapabilities | undefined, item: Pick<IObjectListPanelItem, 'capabilities'> | null | undefined, key: keyof IObjectListPanelCapabilities, fallback?: boolean): boolean;
103
+ export declare function useObjectListPanel(props: IObjectListPanelBaseProps): {
104
+ selectedIdSet: Set<string>;
105
+ draggingId: string | null;
106
+ setDraggingId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
107
+ searchQuery: string;
108
+ setSearchQuery: import("react").Dispatch<import("react").SetStateAction<string>>;
109
+ filterMode: ObjectListFilterMode;
110
+ setFilterMode: import("react").Dispatch<import("react").SetStateAction<ObjectListFilterMode>>;
111
+ collapsedSectionIds: Set<string>;
112
+ selectedItem: IObjectListPanelItem | null;
113
+ visibleItems: IObjectListPanelItem[];
114
+ visibleItemSections: {
115
+ id: string;
116
+ title: string;
117
+ items: IObjectListPanelItem[];
118
+ }[];
119
+ showSectionHeaders: boolean;
120
+ visibilityItems: Pick<IObjectListPanelItem, "id" | "disabled" | "selectable" | "visible" | "capabilities">[];
121
+ selectableItems: Pick<IObjectListPanelItem, "id" | "disabled" | "selectable" | "visible" | "capabilities">[];
122
+ allVisible: boolean;
123
+ allLocked: boolean;
124
+ canMoveForward: boolean;
125
+ canMoveBackward: boolean;
126
+ showArrangeControls: boolean;
127
+ showLocateControl: boolean;
128
+ canReorder: boolean;
129
+ handleDrop: (targetId: string) => void;
130
+ toggleSectionCollapsed: (sectionId: string) => void;
131
+ };
105
132
  export declare function ObjectListPanelBase(props: IObjectListPanelBaseProps): import("react").JSX.Element;
133
+ export interface IObjectListRowProps {
134
+ permissionAction?: ReactNode;
135
+ item: IObjectListPanelItem;
136
+ selected: boolean;
137
+ labels: IObjectListPanelLabels;
138
+ showLock: boolean;
139
+ showName: boolean;
140
+ showVisible: boolean;
141
+ draggable: boolean;
142
+ dragging: boolean;
143
+ onSelect: (multiSelect: boolean) => void;
144
+ onToggleExpanded: () => void;
145
+ onToggleVisible: () => void;
146
+ onToggleSelectable: () => void;
147
+ onCommitName: (value: string) => void;
148
+ onDragStart: () => void;
149
+ onDragEnd: () => void;
150
+ onDrop: () => void;
151
+ }
152
+ export declare function ObjectDetailsEditor(props: {
153
+ item: IObjectListPanelItem | null;
154
+ InputComponent?: ComponentType<ComponentProps<typeof Input>>;
155
+ descriptionClassName?: string;
156
+ labels: IObjectListPanelLabels;
157
+ showName: boolean;
158
+ showDescription: boolean;
159
+ onCommitName: (value: string) => void;
160
+ onCommitDescription: (value: string) => void;
161
+ }): import("react").JSX.Element;
106
162
  export type IDrawingObjectListItem = IObjectListPanelItem;
107
163
  export type IDrawingObjectListPanelLabels = IObjectListPanelLabels;
108
164
  export type IDrawingObjectListPanelProps = IObjectListPanelBaseProps;
165
+ export declare function useObjectListRow({ item, onCommitName }: Pick<IObjectListRowProps, 'item' | 'onCommitName'>): {
166
+ draftName: string;
167
+ setDraftName: import("react").Dispatch<import("react").SetStateAction<string>>;
168
+ disabled: boolean;
169
+ level: number;
170
+ locked: boolean;
171
+ handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
172
+ handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
173
+ };
109
174
  export {};
@@ -21,5 +21,6 @@ export interface IDrawingCommonPanelProps {
21
21
  hasAlign?: boolean;
22
22
  hasCropper?: boolean;
23
23
  hasGroup?: boolean;
24
+ onCropStart?: () => void;
24
25
  }
25
26
  export declare const DrawingCommonPanel: (props: IDrawingCommonPanelProps) => import("react").JSX.Element | null;
@@ -17,5 +17,6 @@ import type { IDrawingParam } from '@univerjs/core';
17
17
  export interface IImageCropperProps {
18
18
  drawings: IDrawingParam[];
19
19
  cropperShow: boolean;
20
+ onCropStart?: () => void;
20
21
  }
21
22
  export declare const ImageCropper: (props: IImageCropperProps) => import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IDrawingParam } from '@univerjs/core';
17
+ interface IMobileDrawingArrangeProps {
18
+ arrangeShow: boolean;
19
+ drawings: IDrawingParam[];
20
+ }
21
+ export declare function MobileDrawingArrange(props: IMobileDrawingArrangeProps): import("react").JSX.Element;
22
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IDrawingParam } from '@univerjs/core';
17
+ interface IMobileDrawingTransformProps {
18
+ transformShow: boolean;
19
+ drawings: IDrawingParam[];
20
+ }
21
+ interface IMobileDrawingAlignProps {
22
+ drawings: IDrawingParam[];
23
+ alignShow: boolean;
24
+ }
25
+ interface IMobileDrawingGroupProps {
26
+ drawings: IDrawingParam[];
27
+ hasGroup: boolean;
28
+ }
29
+ export declare function MobileDrawingTransform(props: IMobileDrawingTransformProps): import("react").JSX.Element | null;
30
+ export declare function MobileDrawingAlign(props: IMobileDrawingAlignProps): import("react").JSX.Element;
31
+ export declare function MobileDrawingGroup(props: IMobileDrawingGroupProps): import("react").JSX.Element;
32
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IImageCropperProps } from './ImageCropper';
17
+ export declare function MobileImageCropper(props: IImageCropperProps): import("react").JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ export declare const DRAWING_ARRANGE_COMPONENT = "drawing-ui.arrange";
17
+ export declare const IMAGE_CROPPER_COMPONENT = "drawing-ui.cropper";
18
+ export declare const DRAWING_TRANSFORM_COMPONENT = "drawing-ui.transform";
19
+ export declare const DRAWING_ALIGN_COMPONENT = "drawing-ui.align";
20
+ export declare const DRAWING_GROUP_COMPONENT = "drawing-ui.group";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IImageCropperProps } from './ImageCropper';
17
+ import { LocaleService } from '@univerjs/core';
18
+ import { CropType } from '../../commands/operations/image-crop.operation';
19
+ export declare function useImageCropper(props: IImageCropperProps): {
20
+ drawingParam: import("@univerjs/core").IDrawingParam;
21
+ cropperShow: boolean;
22
+ localeService: LocaleService;
23
+ cropValue: CropType;
24
+ cropOptions: {
25
+ label: string;
26
+ value: CropType;
27
+ }[];
28
+ handleCropChange: (value: string | number | boolean) => void;
29
+ onCropperBtnClick: (val: CropType) => Promise<void>;
30
+ ShapeClipPicker: any;
31
+ };