From ad902be5e64ffc771a2d9ef01b6a310f0dd5b30f Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Sun, 25 Feb 2024 11:16:10 +0000 Subject: [PATCH] Expand props (#2948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR expands the tldraw / tldraweditor component props. ### Change Type - [x] `patch` — Bug fix --- packages/editor/api-report.md | 5 ++-- packages/editor/api/api.json | 13 ++++++++-- packages/editor/src/lib/TldrawEditor.tsx | 32 +++++++++++++----------- packages/tldraw/api-report.md | 6 ++--- packages/tldraw/api/api.json | 26 ++++++++++++++++--- packages/tldraw/src/lib/Tldraw.tsx | 6 +++-- 6 files changed, 60 insertions(+), 28 deletions(-) diff --git a/packages/editor/api-report.md b/packages/editor/api-report.md index 79e28713a..b9a72fc86 100644 --- a/packages/editor/api-report.md +++ b/packages/editor/api-report.md @@ -15,6 +15,7 @@ import { computed } from '@tldraw/state'; import { EmbedDefinition } from '@tldraw/tlschema'; import { EMPTY_ARRAY } from '@tldraw/state'; import { EventEmitter } from 'eventemitter3'; +import { Expand } from '@tldraw/utils'; import { HistoryEntry } from '@tldraw/store'; import { IndexKey } from '@tldraw/utils'; import { JsonObject } from '@tldraw/utils'; @@ -2031,7 +2032,7 @@ export interface TldrawEditorBaseProps { } // @public -export type TldrawEditorProps = TldrawEditorBaseProps & ({ +export type TldrawEditorProps = Expand; // @public (undocumented) export type TLEditorComponents = Partial<{ diff --git a/packages/editor/api/api.json b/packages/editor/api/api.json index 3802abd40..32a5c40d9 100644 --- a/packages/editor/api/api.json +++ b/packages/editor/api/api.json @@ -36448,6 +36448,15 @@ "kind": "Content", "text": "export type TldrawEditorProps = " }, + { + "kind": "Reference", + "text": "Expand", + "canonicalReference": "@tldraw/utils!Expand:type" + }, + { + "kind": "Content", + "text": "<" + }, { "kind": "Reference", "text": "TldrawEditorBaseProps", @@ -36509,7 +36518,7 @@ }, { "kind": "Content", - "text": ">;\n persistenceKey?: string;\n sessionId?: string;\n defaultName?: string;\n})" + "text": ">;\n persistenceKey?: string;\n sessionId?: string;\n defaultName?: string;\n})>" }, { "kind": "Content", @@ -36521,7 +36530,7 @@ "name": "TldrawEditorProps", "typeTokenRange": { "startIndex": 1, - "endIndex": 15 + "endIndex": 17 } }, { diff --git a/packages/editor/src/lib/TldrawEditor.tsx b/packages/editor/src/lib/TldrawEditor.tsx index fff13cf47..a42db8b12 100644 --- a/packages/editor/src/lib/TldrawEditor.tsx +++ b/packages/editor/src/lib/TldrawEditor.tsx @@ -1,6 +1,6 @@ import { SerializedStore, Store, StoreSnapshot } from '@tldraw/store' import { TLRecord, TLStore } from '@tldraw/tlschema' -import { Required, annotateError } from '@tldraw/utils' +import { Expand, Required, annotateError } from '@tldraw/utils' import React, { memo, useCallback, @@ -41,20 +41,22 @@ import { TLStoreWithStatus } from './utils/sync/StoreWithStatus' * * @public **/ -export type TldrawEditorProps = TldrawEditorBaseProps & - ( - | { - store: TLStore | TLStoreWithStatus - } - | { - store?: undefined - snapshot?: StoreSnapshot - initialData?: SerializedStore - persistenceKey?: string - sessionId?: string - defaultName?: string - } - ) +export type TldrawEditorProps = Expand< + TldrawEditorBaseProps & + ( + | { + store: TLStore | TLStoreWithStatus + } + | { + store?: undefined + snapshot?: StoreSnapshot + initialData?: SerializedStore + persistenceKey?: string + sessionId?: string + defaultName?: string + } + ) +> /** * Base props for the {@link @tldraw/tldraw#Tldraw} and {@link TldrawEditor} components. diff --git a/packages/tldraw/api-report.md b/packages/tldraw/api-report.md index d13b26d2a..5e9983d92 100644 --- a/packages/tldraw/api-report.md +++ b/packages/tldraw/api-report.md @@ -1169,7 +1169,7 @@ export class TextShapeUtil extends ShapeUtil { } // @public (undocumented) -export type TLComponents = TLEditorComponents & TLUiComponents; +export type TLComponents = Expand; // @public (undocumented) export function Tldraw(props: TldrawProps): JSX_2.Element; @@ -1216,7 +1216,7 @@ export type TldrawImageProps = Expand<{ } & Partial>; // @public (undocumented) -export type TldrawProps = (Omit & Omit & { +export type TldrawProps = Expand<(Omit & Omit & { components?: TLComponents; }) & Partial & ({ store: TLStore | TLStoreWithStatus; @@ -1226,7 +1226,7 @@ export type TldrawProps = (Omit & Omit; -}); +})>; // @public (undocumented) export function TldrawScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX_2.Element | null; diff --git a/packages/tldraw/api/api.json b/packages/tldraw/api/api.json index f809ae9d3..e5c9d1f51 100644 --- a/packages/tldraw/api/api.json +++ b/packages/tldraw/api/api.json @@ -13626,6 +13626,15 @@ "kind": "Content", "text": "export type TLComponents = " }, + { + "kind": "Reference", + "text": "Expand", + "canonicalReference": "@tldraw/utils!Expand:type" + }, + { + "kind": "Content", + "text": "<" + }, { "kind": "Reference", "text": "TLEditorComponents", @@ -13640,6 +13649,10 @@ "text": "TLUiComponents", "canonicalReference": "@tldraw/tldraw!TLUiComponents:type" }, + { + "kind": "Content", + "text": ">" + }, { "kind": "Content", "text": ";" @@ -13650,7 +13663,7 @@ "name": "TLComponents", "typeTokenRange": { "startIndex": 1, - "endIndex": 4 + "endIndex": 7 } }, { @@ -14113,9 +14126,14 @@ "kind": "Content", "text": "export type TldrawProps = " }, + { + "kind": "Reference", + "text": "Expand", + "canonicalReference": "@tldraw/utils!Expand:type" + }, { "kind": "Content", - "text": "(" + "text": "<(" }, { "kind": "Reference", @@ -14214,7 +14232,7 @@ }, { "kind": "Content", - "text": ">;\n})" + "text": ">;\n})>" }, { "kind": "Content", @@ -14226,7 +14244,7 @@ "name": "TldrawProps", "typeTokenRange": { "startIndex": 1, - "endIndex": 24 + "endIndex": 25 } }, { diff --git a/packages/tldraw/src/lib/Tldraw.tsx b/packages/tldraw/src/lib/Tldraw.tsx index 752b93f4b..4ce1baca1 100644 --- a/packages/tldraw/src/lib/Tldraw.tsx +++ b/packages/tldraw/src/lib/Tldraw.tsx @@ -1,6 +1,7 @@ import { Editor, ErrorScreen, + Expand, LoadingScreen, StoreSnapshot, TLEditorComponents, @@ -36,10 +37,10 @@ import { usePreloadAssets } from './ui/hooks/usePreloadAssets' import { useDefaultEditorAssetsWithOverrides } from './utils/static-assets/assetUrls' /**@public */ -export type TLComponents = TLEditorComponents & TLUiComponents +export type TLComponents = Expand /** @public */ -export type TldrawProps = +export type TldrawProps = Expand< // combine components from base editor and ui (Omit & Omit & { @@ -62,6 +63,7 @@ export type TldrawProps = snapshot?: StoreSnapshot } ) +> /** @public */ export function Tldraw(props: TldrawProps) {