@zsviczian/excalidraw 0.14.0-obsidian → 0.14.2-1-obsidian

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 (60) hide show
  1. package/README.md +16 -1823
  2. package/dist/excalidraw.development.js +282 -139
  3. package/dist/excalidraw.production.min.js +1 -1
  4. package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
  5. package/package.json +1 -1
  6. package/types/actions/actionAddToLibrary.d.ts +33 -15
  7. package/types/actions/actionBoundText.d.ts +11 -5
  8. package/types/actions/actionCanvas.d.ts +225 -47
  9. package/types/actions/actionClipboard.d.ts +55 -25
  10. package/types/actions/actionDeleteSelected.d.ts +35 -17
  11. package/types/actions/actionExport.d.ts +99 -45
  12. package/types/actions/actionFinalize.d.ts +22 -10
  13. package/types/actions/actionLinearEditor.d.ts +11 -5
  14. package/types/actions/actionMenu.d.ts +33 -15
  15. package/types/actions/actionProperties.d.ts +143 -65
  16. package/types/actions/actionStyles.d.ts +11 -5
  17. package/types/actions/actionToggleGridMode.d.ts +11 -5
  18. package/types/actions/actionToggleLock.d.ts +11 -5
  19. package/types/actions/actionToggleStats.d.ts +11 -5
  20. package/types/actions/actionToggleViewMode.d.ts +11 -5
  21. package/types/actions/actionToggleZenMode.d.ts +11 -5
  22. package/types/actions/shortcuts.d.ts +1 -1
  23. package/types/actions/types.d.ts +1 -1
  24. package/types/appState.d.ts +8 -6
  25. package/types/components/ActiveConfirmDialog.d.ts +24 -0
  26. package/types/components/App.d.ts +3 -1
  27. package/types/components/HandButton.d.ts +10 -0
  28. package/types/components/LayerUI.d.ts +2 -2
  29. package/types/components/LockButton.d.ts +0 -1
  30. package/types/components/MobileMenu.d.ts +4 -4
  31. package/types/components/ToolButton.d.ts +1 -1
  32. package/types/components/context/tunnels.d.ts +16 -0
  33. package/types/components/dropdownMenu/DropdownMenu.d.ts +7 -5
  34. package/types/components/dropdownMenu/DropdownMenuContent.d.ts +7 -3
  35. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +2 -3
  36. package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +3 -2
  37. package/types/components/dropdownMenu/common.d.ts +6 -0
  38. package/types/components/footer/Footer.d.ts +3 -4
  39. package/types/components/hoc/withInternalFallback.d.ts +4 -0
  40. package/types/components/icons.d.ts +1 -0
  41. package/types/components/main-menu/MainMenu.d.ts +14 -9
  42. package/types/components/welcome-screen/WelcomeScreen.d.ts +2 -2
  43. package/types/constants.d.ts +11 -1
  44. package/types/data/restore.d.ts +8 -2
  45. package/types/element/Hyperlink.d.ts +11 -5
  46. package/types/element/linearElementEditor.d.ts +12 -5
  47. package/types/element/newElement.d.ts +0 -3
  48. package/types/element/sortElements.d.ts +2 -0
  49. package/types/element/textElement.d.ts +9 -8
  50. package/types/element/typeChecks.d.ts +1 -1
  51. package/types/element/types.d.ts +0 -1
  52. package/types/i18n.d.ts +6 -0
  53. package/types/jotai.d.ts +5 -5
  54. package/types/keys.d.ts +0 -3
  55. package/types/math.d.ts +1 -0
  56. package/types/packages/excalidraw/example/App.d.ts +7 -1
  57. package/types/packages/excalidraw/index.d.ts +1 -1
  58. package/types/packages/utils.d.ts +1 -1
  59. package/types/types.d.ts +21 -24
  60. package/types/utils.d.ts +9 -19
@@ -140,16 +140,15 @@ export declare class LinearElementEditor {
140
140
  suggestedBindings: import("./binding").SuggestedBinding[];
141
141
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
142
142
  activeTool: {
143
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
144
- lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
143
+ lastActiveTool: import("../types").LastActiveTool;
145
144
  locked: boolean;
145
+ } & ({
146
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | "hand";
146
147
  customType: null;
147
148
  } | {
148
149
  type: "custom";
149
150
  customType: string;
150
- lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
151
- locked: boolean;
152
- };
151
+ });
153
152
  penMode: boolean;
154
153
  penDetected: boolean;
155
154
  exportBackground: boolean;
@@ -192,6 +191,7 @@ export declare class LinearElementEditor {
192
191
  previousSelectedElementIds: {
193
192
  [id: string]: boolean;
194
193
  };
194
+ /** @returns whether point was dragged */
195
195
  shouldCacheIgnoreZoom: boolean;
196
196
  toast: {
197
197
  message: string;
@@ -201,6 +201,7 @@ export declare class LinearElementEditor {
201
201
  zenModeEnabled: boolean;
202
202
  theme: string;
203
203
  gridSize: number | null;
204
+ previousGridSize: number | null;
204
205
  viewModeEnabled: boolean;
205
206
  selectedGroupIds: {
206
207
  [groupId: string]: boolean;
@@ -230,6 +231,12 @@ export declare class LinearElementEditor {
230
231
  elementBackground?: string[] | undefined;
231
232
  elementStroke?: string[] | undefined;
232
233
  };
234
+ allowWheelZoom?: boolean | undefined;
235
+ allowPinchZoom?: boolean | undefined;
236
+ pinnedScripts?: string[] | undefined;
237
+ customPens?: any[] | undefined;
238
+ currentStrokeOptions?: any;
239
+ resetCustomPen?: any;
233
240
  selectedLinearElement: LinearElementEditor | null;
234
241
  };
235
242
  };
@@ -18,11 +18,8 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
18
18
  y: number;
19
19
  width: number;
20
20
  height: number;
21
- baseline: number;
22
21
  text: string;
23
22
  };
24
- export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
25
- export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
26
23
  export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, rawText, link, }: {
27
24
  text: string;
28
25
  isDeleted?: boolean | undefined;
@@ -0,0 +1,2 @@
1
+ import { ExcalidrawElement } from "./types";
2
+ export declare const normalizeElementOrder: (elements: readonly ExcalidrawElement[]) => readonly ExcalidrawElement[];
@@ -5,19 +5,13 @@ export declare const normalizeText: (text: string) => string;
5
5
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
6
6
  export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
7
7
  export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
8
- export declare const measureText: (text: string, font: FontString, maxWidth?: number | null) => {
8
+ export declare const measureText: (text: string, font: FontString) => {
9
9
  width: number;
10
10
  height: number;
11
- baseline: number;
12
- container: HTMLDivElement;
13
- } | {
14
- width: number;
15
- height: number;
16
- baseline: number;
17
- container?: undefined;
18
11
  };
19
12
  export declare const getApproxLineHeight: (font: FontString) => number;
20
13
  export declare const getTextWidth: (text: string, font: FontString) => number;
14
+ export declare const getTextHeight: (text: string, font: FontString) => number;
21
15
  export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
22
16
  export declare const charWidth: {
23
17
  calculate: (char: string, font: FontString) => number;
@@ -41,6 +35,10 @@ export declare const getContainerCenter: (container: ExcalidrawElement, appState
41
35
  x: number;
42
36
  y: number;
43
37
  };
38
+ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement) => {
39
+ x: number;
40
+ y: number;
41
+ };
44
42
  export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
45
43
  export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
46
44
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
@@ -50,3 +48,6 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
50
48
  export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
51
49
  export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
52
50
  export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
51
+ export declare const computeContainerHeightForBoundText: (container: NonDeletedExcalidrawElement, boundTextElementHeight: number) => number;
52
+ export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
53
+ export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
@@ -14,7 +14,7 @@ export declare const isBindingElementType: (elementType: AppState["activeTool"][
14
14
  export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
15
15
  export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
16
16
  export declare const isExcalidrawElement: (element: any) => boolean;
17
- export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
17
+ export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
18
18
  export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
19
19
  export declare const isUsingAdaptiveRadius: (type: string) => boolean;
20
20
  export declare const isUsingProportionalRadius: (type: string) => boolean;
@@ -100,7 +100,6 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
100
100
  fontFamily: FontFamilyValues;
101
101
  text: string;
102
102
  rawText: string;
103
- baseline: number;
104
103
  textAlign: TextAlign;
105
104
  verticalAlign: VerticalAlign;
106
105
  containerId: ExcalidrawGenericElement["id"] | null;
package/types/i18n.d.ts CHANGED
@@ -13,3 +13,9 @@ export declare const getLanguage: () => Language;
13
13
  export declare const t: (path: string, replacement?: {
14
14
  [key: string]: string | number;
15
15
  } | undefined) => string;
16
+ export declare const useI18n: () => {
17
+ t: (path: string, replacement?: {
18
+ [key: string]: string | number;
19
+ } | undefined) => string;
20
+ langCode: string;
21
+ };
package/types/jotai.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { WritableAtom } from "jotai";
1
+ import { PrimitiveAtom } from "jotai";
2
2
  export declare const jotaiScope: unique symbol;
3
3
  export declare const jotaiStore: {
4
4
  get: <Value>(atom: import("jotai").Atom<Value>) => (Value extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value) | undefined;
5
5
  asyncGet: <Value_1>(atom: import("jotai").Atom<Value_1>) => Promise<Value_1 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_1>;
6
- set: <Value_2, Update, Result extends void | Promise<void>>(atom: WritableAtom<Value_2, Update, Result>, update: Update) => Result;
6
+ set: <Value_2, Update, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_2, Update, Result>, update: Update) => Result;
7
7
  sub: (atom: {
8
8
  toString: () => string;
9
9
  debugLabel?: string | undefined;
@@ -15,7 +15,7 @@ export declare const jotaiStore: {
15
15
  }, callback: () => void) => () => void;
16
16
  SECRET_INTERNAL_store: {
17
17
  r: <Value_6>(readingAtom: import("jotai").Atom<Value_6>, version?: import("jotai/core/store").VersionObject | undefined) => import("jotai/core/store").AtomState<Value_6>;
18
- w: <Value_1_1, Update_1, Result_1 extends void | Promise<void>>(writingAtom: WritableAtom<Value_1_1, Update_1, Result_1>, update: Update_1, version?: import("jotai/core/store").VersionObject | undefined) => Result_1;
18
+ w: <Value_1_1, Update_1, Result_1 extends void | Promise<void>>(writingAtom: import("jotai").WritableAtom<Value_1_1, Update_1, Result_1>, update: Update_1, version?: import("jotai/core/store").VersionObject | undefined) => Result_1;
19
19
  c: (_atom: {
20
20
  toString: () => string;
21
21
  debugLabel?: string | undefined;
@@ -85,7 +85,7 @@ export declare const jotaiStore: {
85
85
  } | undefined;
86
86
  } | {
87
87
  r: <Value_7>(readingAtom: import("jotai").Atom<Value_7>, version?: import("jotai/core/store").VersionObject | undefined) => import("jotai/core/store").AtomState<Value_7>;
88
- w: <Value_1_2, Update_2, Result_2 extends void | Promise<void>>(writingAtom: WritableAtom<Value_1_2, Update_2, Result_2>, update: Update_2, version?: import("jotai/core/store").VersionObject | undefined) => Result_2;
88
+ w: <Value_1_2, Update_2, Result_2 extends void | Promise<void>>(writingAtom: import("jotai").WritableAtom<Value_1_2, Update_2, Result_2>, update: Update_2, version?: import("jotai/core/store").VersionObject | undefined) => Result_2;
89
89
  c: (_atom: {
90
90
  toString: () => string;
91
91
  debugLabel?: string | undefined;
@@ -119,4 +119,4 @@ export declare const jotaiStore: {
119
119
  m?: undefined;
120
120
  };
121
121
  };
122
- export declare const useAtomWithInitialValue: <T extends unknown, A extends WritableAtom<T, T, void>>(atom: A, initialValue: T | (() => T)) => readonly [T extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : T, import("jotai/core/atom").SetAtom<T, void>];
122
+ export declare const useAtomWithInitialValue: <T extends unknown, A extends PrimitiveAtom<T>>(atom: A, initialValue: T | (() => T)) => readonly [T extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : T, import("jotai/core/atom").SetAtom<T | ((prev: T) => T), void>];
package/types/keys.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- export declare const isDarwin: boolean;
2
- export declare const isWindows: boolean;
3
- export declare const isAndroid: boolean;
4
1
  export declare const CODES: {
5
2
  readonly EQUAL: "Equal";
6
3
  readonly MINUS: "Minus";
package/types/math.d.ts CHANGED
@@ -26,3 +26,4 @@ export declare const getBezierCurveArcLengths: (element: NonDeleted<ExcalidrawLi
26
26
  export declare const getBezierCurveLength: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number]) => number;
27
27
  export declare const mapIntervalToBezierT: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number], interval: number) => number;
28
28
  export declare const arePointsEqual: (p1: readonly [number, number], p2: readonly [number, number]) => boolean;
29
+ export declare const isRightAngle: (angle: number) => boolean;
@@ -1,8 +1,14 @@
1
1
  import type * as TExcalidraw from "../index";
2
2
  import "./App.scss";
3
+ import { ExcalidrawImperativeAPI } from "../../../types";
3
4
  declare global {
4
5
  interface Window {
5
6
  ExcalidrawLib: typeof TExcalidraw;
6
7
  }
7
8
  }
8
- export default function App(): JSX.Element;
9
+ export interface AppProps {
10
+ appTitle: string;
11
+ useCustom: (api: ExcalidrawImperativeAPI | null, customArgs?: any[]) => void;
12
+ customArgs?: any[];
13
+ }
14
+ export default function App({ appTitle, useCustom, customArgs }: AppProps): JSX.Element;
@@ -9,7 +9,7 @@ import LiveCollaborationTrigger from "../../components/live-collaboration/LiveCo
9
9
  declare type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
10
10
  export declare const Excalidraw: React.MemoExoticComponent<React.ForwardRefExoticComponent<PublicExcalidrawProps & React.RefAttributes<ExcalidrawAPIRefValue>>>;
11
11
  export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
12
- export { defaultLang, languages } from "../../i18n";
12
+ export { defaultLang, useI18n, languages } from "../../i18n";
13
13
  export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "../../data/restore";
14
14
  export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, serializeLibraryAsJSON, loadLibraryFromBlob, loadFromBlob, loadSceneOrLibraryFromBlob, getFreeDrawSvgPath, getCommonBoundingBox, //zsviczian
15
15
  getMaximumGroups, //zsviczian
@@ -38,5 +38,5 @@ export { intersectElementWithLine } from "../element/collision";
38
38
  export { determineFocusDistance } from "../element/collision";
39
39
  export { measureText, wrapText } from "../element/textElement";
40
40
  export { getFontString } from "../utils";
41
- export { getMaxContainerWidth } from "../element/newElement";
41
+ export { getMaxContainerWidth } from "../element/textElement";
42
42
  export { mergeLibraryItems } from "../data/library";
package/types/types.d.ts CHANGED
@@ -55,8 +55,8 @@ export declare type BinaryFileData = {
55
55
  };
56
56
  export declare type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
57
57
  export declare type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
58
- export declare type LastActiveToolBeforeEraser = {
59
- type: typeof SHAPES[number]["value"] | "eraser";
58
+ export declare type LastActiveTool = {
59
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand";
60
60
  customType: null;
61
61
  } | {
62
62
  type: "custom";
@@ -81,16 +81,19 @@ export declare type AppState = {
81
81
  editingElement: NonDeletedExcalidrawElement | null;
82
82
  editingLinearElement: LinearElementEditor | null;
83
83
  activeTool: {
84
- type: typeof SHAPES[number]["value"] | "eraser";
85
- lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
84
+ /**
85
+ * indicates a previous tool we should revert back to if we deselect the
86
+ * currently active tool. At the moment applies to `eraser` and `hand` tool.
87
+ */
88
+ lastActiveTool: LastActiveTool;
86
89
  locked: boolean;
90
+ } & ({
91
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand";
87
92
  customType: null;
88
93
  } | {
89
94
  type: "custom";
90
95
  customType: string;
91
- lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
92
- locked: boolean;
93
- };
96
+ });
94
97
  penMode: boolean;
95
98
  penDetected: boolean;
96
99
  exportBackground: boolean;
@@ -140,6 +143,7 @@ export declare type AppState = {
140
143
  zenModeEnabled: boolean;
141
144
  theme: Theme;
142
145
  gridSize: number | null;
146
+ previousGridSize: number | null;
143
147
  viewModeEnabled: boolean;
144
148
  /** top-most selected groups (i.e. does not include nested groups) */
145
149
  selectedGroupIds: {
@@ -173,6 +177,12 @@ export declare type AppState = {
173
177
  elementBackground?: string[];
174
178
  elementStroke?: string[];
175
179
  };
180
+ allowWheelZoom?: boolean;
181
+ allowPinchZoom?: boolean;
182
+ pinnedScripts?: string[];
183
+ customPens?: any[];
184
+ currentStrokeOptions?: any;
185
+ resetCustomPen?: any;
176
186
  selectedLinearElement: LinearElementEditor | null;
177
187
  };
178
188
  export declare type NormalizedZoomValue = number & {
@@ -296,11 +306,12 @@ declare type CanvasActions = Partial<{
296
306
  }>;
297
307
  declare type UIOptions = Partial<{
298
308
  dockedSidebarBreakpoint: number;
299
- welcomeScreen: boolean;
300
309
  canvasActions: CanvasActions;
310
+ /** @deprecated does nothing. Will be removed in 0.15 */
311
+ welcomeScreen?: boolean;
301
312
  }>;
302
313
  export declare type AppProps = Merge<ExcalidrawProps, {
303
- UIOptions: Merge<MarkRequired<UIOptions, "welcomeScreen">, {
314
+ UIOptions: Merge<UIOptions, {
304
315
  canvasActions: Required<CanvasActions> & {
305
316
  export: ExportOpts;
306
317
  };
@@ -395,6 +406,7 @@ export declare type ExcalidrawImperativeAPI = {
395
406
  };
396
407
  scrollToContent: InstanceType<typeof App>["scrollToContent"];
397
408
  zoomToFit: InstanceType<typeof App>["zoomToFit"];
409
+ startLineEditor: InstanceType<typeof App>["startLineEditor"];
398
410
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
399
411
  getAppState: () => InstanceType<typeof App>["state"];
400
412
  getFiles: () => InstanceType<typeof App>["files"];
@@ -424,19 +436,4 @@ export declare type Device = Readonly<{
424
436
  isTouchScreen: boolean;
425
437
  canDeviceFitSidebar: boolean;
426
438
  }>;
427
- export declare type UIChildrenComponents = {
428
- [k in "FooterCenter" | "Menu" | "WelcomeScreen"]?: React.ReactElement<{
429
- children?: React.ReactNode;
430
- }, React.JSXElementConstructor<any>>;
431
- };
432
- export declare type UIWelcomeScreenComponents = {
433
- [k in "Center" | "MenuHint" | "ToolbarHint" | "HelpHint"]?: React.ReactElement<{
434
- children?: React.ReactNode;
435
- }, React.JSXElementConstructor<any>>;
436
- };
437
- export declare type UIWelcomeScreenCenterComponents = {
438
- [k in "Logo" | "Heading" | "Menu" | "MenuItemLoadScene" | "MenuItemHelp"]?: React.ReactElement<{
439
- children?: React.ReactNode;
440
- }, React.JSXElementConstructor<any>>;
441
- };
442
439
  export {};
package/types/utils.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { EVENT } from "./constants";
2
2
  import { FontFamilyValues, FontString } from "./element/types";
3
- import { AppState, LastActiveToolBeforeEraser, Zoom } from "./types";
3
+ import { AppState, LastActiveTool, Zoom } from "./types";
4
4
  import { SHAPES } from "./shapes";
5
- import React from "react";
6
5
  export declare const setDateTimeForTests: (dateTime: string) => void;
7
6
  export declare const getDateTime: () => string;
8
7
  export declare const capitalizeString: (str: string) => string;
@@ -34,12 +33,12 @@ export declare const selectNode: (node: Element) => void;
34
33
  export declare const removeSelection: () => void;
35
34
  export declare const distance: (x: number, y: number) => number;
36
35
  export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
37
- type: (typeof SHAPES)[number]["value"] | "eraser";
36
+ type: (typeof SHAPES)[number]["value"] | "eraser" | "hand";
38
37
  } | {
39
38
  type: "custom";
40
39
  customType: string;
41
40
  }) & {
42
- lastActiveToolBeforeEraser?: LastActiveToolBeforeEraser;
41
+ lastActiveToolBeforeEraser?: LastActiveTool;
43
42
  }) => AppState["activeTool"];
44
43
  export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
45
44
  export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
@@ -125,6 +124,9 @@ export declare const getUpdatedTimestamp: () => number;
125
124
  export declare const arrayToMap: <T extends string | {
126
125
  id: string;
127
126
  }>(items: readonly T[]) => Map<string, T>;
127
+ export declare const arrayToMapWithIndex: <T extends {
128
+ id: string;
129
+ }>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
128
130
  export declare const isTestEnv: () => boolean;
129
131
  export declare const isProdEnv: () => boolean;
130
132
  export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
@@ -135,19 +137,7 @@ export declare const isPrimitive: (val: any) => boolean;
135
137
  export declare const getFrame: () => "top" | "iframe";
136
138
  export declare const isPromiseLike: (value: any) => value is Promise<any>;
137
139
  export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
138
- /**
139
- * Partitions React children into named components and the rest of children.
140
- *
141
- * Returns known children as a dictionary of react children keyed by their
142
- * displayName, and the rest children as an array.
143
- *
144
- * NOTE all named react components are included in the dictionary, irrespective
145
- * of the supplied type parameter. This means you may be throwing away
146
- * children that you aren't expecting, but should nonetheless be rendered.
147
- * To guard against this (provided you care about the rest children at all),
148
- * supply a second parameter with an object with keys of the expected children.
149
- */
150
- export declare const getReactChildren: <KnownChildren extends {
151
- [x: string]: React.ReactNode;
152
- }>(children: React.ReactNode, expectedComponents?: Record<keyof KnownChildren, any> | undefined) => readonly [Partial<KnownChildren>, React.ReactNode[]];
153
140
  export declare const isShallowEqual: <T extends Record<string, any>>(objA: T, objB: T) => boolean;
141
+ export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
142
+ checkForDefaultPrevented?: boolean | undefined;
143
+ }) => (event: E) => void;