Expand props (#2948)

This PR expands the tldraw / tldraweditor component props.

### Change Type

- [x] `patch` — Bug fix
This commit is contained in:
Steve Ruiz 2024-02-25 11:16:10 +00:00 committed by GitHub
parent b2cb0d27b0
commit ad902be5e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 60 additions and 28 deletions

View file

@ -15,6 +15,7 @@ import { computed } from '@tldraw/state';
import { EmbedDefinition } from '@tldraw/tlschema'; import { EmbedDefinition } from '@tldraw/tlschema';
import { EMPTY_ARRAY } from '@tldraw/state'; import { EMPTY_ARRAY } from '@tldraw/state';
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { Expand } from '@tldraw/utils';
import { HistoryEntry } from '@tldraw/store'; import { HistoryEntry } from '@tldraw/store';
import { IndexKey } from '@tldraw/utils'; import { IndexKey } from '@tldraw/utils';
import { JsonObject } from '@tldraw/utils'; import { JsonObject } from '@tldraw/utils';
@ -2031,7 +2032,7 @@ export interface TldrawEditorBaseProps {
} }
// @public // @public
export type TldrawEditorProps = TldrawEditorBaseProps & ({ export type TldrawEditorProps = Expand<TldrawEditorBaseProps & ({
store: TLStore | TLStoreWithStatus; store: TLStore | TLStoreWithStatus;
} | { } | {
store?: undefined; store?: undefined;
@ -2040,7 +2041,7 @@ export type TldrawEditorProps = TldrawEditorBaseProps & ({
persistenceKey?: string; persistenceKey?: string;
sessionId?: string; sessionId?: string;
defaultName?: string; defaultName?: string;
}); })>;
// @public (undocumented) // @public (undocumented)
export type TLEditorComponents = Partial<{ export type TLEditorComponents = Partial<{

View file

@ -36448,6 +36448,15 @@
"kind": "Content", "kind": "Content",
"text": "export type TldrawEditorProps = " "text": "export type TldrawEditorProps = "
}, },
{
"kind": "Reference",
"text": "Expand",
"canonicalReference": "@tldraw/utils!Expand:type"
},
{
"kind": "Content",
"text": "<"
},
{ {
"kind": "Reference", "kind": "Reference",
"text": "TldrawEditorBaseProps", "text": "TldrawEditorBaseProps",
@ -36509,7 +36518,7 @@
}, },
{ {
"kind": "Content", "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", "kind": "Content",
@ -36521,7 +36530,7 @@
"name": "TldrawEditorProps", "name": "TldrawEditorProps",
"typeTokenRange": { "typeTokenRange": {
"startIndex": 1, "startIndex": 1,
"endIndex": 15 "endIndex": 17
} }
}, },
{ {

View file

@ -1,6 +1,6 @@
import { SerializedStore, Store, StoreSnapshot } from '@tldraw/store' import { SerializedStore, Store, StoreSnapshot } from '@tldraw/store'
import { TLRecord, TLStore } from '@tldraw/tlschema' import { TLRecord, TLStore } from '@tldraw/tlschema'
import { Required, annotateError } from '@tldraw/utils' import { Expand, Required, annotateError } from '@tldraw/utils'
import React, { import React, {
memo, memo,
useCallback, useCallback,
@ -41,7 +41,8 @@ import { TLStoreWithStatus } from './utils/sync/StoreWithStatus'
* *
* @public * @public
**/ **/
export type TldrawEditorProps = TldrawEditorBaseProps & export type TldrawEditorProps = Expand<
TldrawEditorBaseProps &
( (
| { | {
store: TLStore | TLStoreWithStatus store: TLStore | TLStoreWithStatus
@ -55,6 +56,7 @@ export type TldrawEditorProps = TldrawEditorBaseProps &
defaultName?: string defaultName?: string
} }
) )
>
/** /**
* Base props for the {@link @tldraw/tldraw#Tldraw} and {@link TldrawEditor} components. * Base props for the {@link @tldraw/tldraw#Tldraw} and {@link TldrawEditor} components.

View file

@ -1169,7 +1169,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
} }
// @public (undocumented) // @public (undocumented)
export type TLComponents = TLEditorComponents & TLUiComponents; export type TLComponents = Expand<TLEditorComponents & TLUiComponents>;
// @public (undocumented) // @public (undocumented)
export function Tldraw(props: TldrawProps): JSX_2.Element; export function Tldraw(props: TldrawProps): JSX_2.Element;
@ -1216,7 +1216,7 @@ export type TldrawImageProps = Expand<{
} & Partial<TLSvgOptions>>; } & Partial<TLSvgOptions>>;
// @public (undocumented) // @public (undocumented)
export type TldrawProps = (Omit<TldrawUiProps, 'components'> & Omit<TldrawEditorBaseProps, 'components'> & { export type TldrawProps = Expand<(Omit<TldrawUiProps, 'components'> & Omit<TldrawEditorBaseProps, 'components'> & {
components?: TLComponents; components?: TLComponents;
}) & Partial<TLExternalContentProps> & ({ }) & Partial<TLExternalContentProps> & ({
store: TLStore | TLStoreWithStatus; store: TLStore | TLStoreWithStatus;
@ -1226,7 +1226,7 @@ export type TldrawProps = (Omit<TldrawUiProps, 'components'> & Omit<TldrawEditor
sessionId?: string; sessionId?: string;
defaultName?: string; defaultName?: string;
snapshot?: StoreSnapshot<TLRecord>; snapshot?: StoreSnapshot<TLRecord>;
}); })>;
// @public (undocumented) // @public (undocumented)
export function TldrawScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX_2.Element | null; export function TldrawScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX_2.Element | null;

View file

@ -13626,6 +13626,15 @@
"kind": "Content", "kind": "Content",
"text": "export type TLComponents = " "text": "export type TLComponents = "
}, },
{
"kind": "Reference",
"text": "Expand",
"canonicalReference": "@tldraw/utils!Expand:type"
},
{
"kind": "Content",
"text": "<"
},
{ {
"kind": "Reference", "kind": "Reference",
"text": "TLEditorComponents", "text": "TLEditorComponents",
@ -13640,6 +13649,10 @@
"text": "TLUiComponents", "text": "TLUiComponents",
"canonicalReference": "@tldraw/tldraw!TLUiComponents:type" "canonicalReference": "@tldraw/tldraw!TLUiComponents:type"
}, },
{
"kind": "Content",
"text": ">"
},
{ {
"kind": "Content", "kind": "Content",
"text": ";" "text": ";"
@ -13650,7 +13663,7 @@
"name": "TLComponents", "name": "TLComponents",
"typeTokenRange": { "typeTokenRange": {
"startIndex": 1, "startIndex": 1,
"endIndex": 4 "endIndex": 7
} }
}, },
{ {
@ -14113,9 +14126,14 @@
"kind": "Content", "kind": "Content",
"text": "export type TldrawProps = " "text": "export type TldrawProps = "
}, },
{
"kind": "Reference",
"text": "Expand",
"canonicalReference": "@tldraw/utils!Expand:type"
},
{ {
"kind": "Content", "kind": "Content",
"text": "(" "text": "<("
}, },
{ {
"kind": "Reference", "kind": "Reference",
@ -14214,7 +14232,7 @@
}, },
{ {
"kind": "Content", "kind": "Content",
"text": ">;\n})" "text": ">;\n})>"
}, },
{ {
"kind": "Content", "kind": "Content",
@ -14226,7 +14244,7 @@
"name": "TldrawProps", "name": "TldrawProps",
"typeTokenRange": { "typeTokenRange": {
"startIndex": 1, "startIndex": 1,
"endIndex": 24 "endIndex": 25
} }
}, },
{ {

View file

@ -1,6 +1,7 @@
import { import {
Editor, Editor,
ErrorScreen, ErrorScreen,
Expand,
LoadingScreen, LoadingScreen,
StoreSnapshot, StoreSnapshot,
TLEditorComponents, TLEditorComponents,
@ -36,10 +37,10 @@ import { usePreloadAssets } from './ui/hooks/usePreloadAssets'
import { useDefaultEditorAssetsWithOverrides } from './utils/static-assets/assetUrls' import { useDefaultEditorAssetsWithOverrides } from './utils/static-assets/assetUrls'
/**@public */ /**@public */
export type TLComponents = TLEditorComponents & TLUiComponents export type TLComponents = Expand<TLEditorComponents & TLUiComponents>
/** @public */ /** @public */
export type TldrawProps = export type TldrawProps = Expand<
// combine components from base editor and ui // combine components from base editor and ui
(Omit<TldrawUiProps, 'components'> & (Omit<TldrawUiProps, 'components'> &
Omit<TldrawEditorBaseProps, 'components'> & { Omit<TldrawEditorBaseProps, 'components'> & {
@ -62,6 +63,7 @@ export type TldrawProps =
snapshot?: StoreSnapshot<TLRecord> snapshot?: StoreSnapshot<TLRecord>
} }
) )
>
/** @public */ /** @public */
export function Tldraw(props: TldrawProps) { export function Tldraw(props: TldrawProps) {