Fix types for real

This commit is contained in:
Steve Ruiz 2021-10-27 17:21:49 +01:00
parent c04e4134d2
commit 02a6488f46
6 changed files with 24 additions and 6 deletions

View file

@ -1,3 +1,13 @@
## 0.0.130
### TLCore
- Major change to ShapeUtils API
### TLDraw
- Rewrite utils with new API.
## 0.0.126 ## 0.0.126
### TLDraw ### TLDraw

View file

@ -71,7 +71,7 @@ export interface TLShape {
isAspectRatioLocked?: boolean isAspectRatioLocked?: boolean
} }
export type TLComponentProps<T extends TLShape, E = any, M = any> = { export interface TLComponentProps<T extends TLShape, E = any, M = any> {
shape: T shape: T
isEditing: boolean isEditing: boolean
isBinding: boolean isBinding: boolean
@ -88,7 +88,8 @@ export type TLComponentProps<T extends TLShape, E = any, M = any> = {
onPointerMove: (e: React.PointerEvent<E>) => void onPointerMove: (e: React.PointerEvent<E>) => void
onPointerLeave: (e: React.PointerEvent<E>) => void onPointerLeave: (e: React.PointerEvent<E>) => void
} }
} & React.RefAttributes<E> ref?: React.Ref<E> | undefined
}
export interface TLShapeProps<T extends TLShape, E = any, M = any> export interface TLShapeProps<T extends TLShape, E = any, M = any>
extends TLComponentProps<T, E, M> { extends TLComponentProps<T, E, M> {

View file

@ -6,7 +6,6 @@ import {
TLBinding, TLBinding,
TLBounds, TLBounds,
TLIndicator, TLIndicator,
TLComponentProps,
TLPointerInfo, TLPointerInfo,
} from '@tldraw/core' } from '@tldraw/core'
import { Vec } from '@tldraw/vec' import { Vec } from '@tldraw/vec'
@ -20,6 +19,7 @@ import {
TLDrawShapeType, TLDrawShapeType,
TLDrawShape, TLDrawShape,
EllipseShape, EllipseShape,
TLDrawComponentProps,
} from '~types' } from '~types'
import { TLDrawShapeUtil } from '../TLDrawShapeUtil' import { TLDrawShapeUtil } from '../TLDrawShapeUtil'
import { import {
@ -86,7 +86,7 @@ export class ArrowUtil extends TLDrawShapeUtil<T, E> {
) )
} }
Component = React.forwardRef<E, TLComponentProps<T, E, M>>(({ shape, meta, events }, ref) => { Component = React.forwardRef<E, TLDrawComponentProps<T, E>>(({ shape, meta, events }, ref) => {
const { const {
handles: { start, bend, end }, handles: { start, bend, end },
decorations = {}, decorations = {},

View file

@ -2,7 +2,7 @@
import * as React from 'react' import * as React from 'react'
import { Utils, HTMLContainer, TLIndicator, TLComponentProps, TLBounds } from '@tldraw/core' import { Utils, HTMLContainer, TLIndicator, TLComponentProps, TLBounds } from '@tldraw/core'
import { defaultStyle, getShapeStyle, getFontStyle } from '../shape-styles' import { defaultStyle, getShapeStyle, getFontStyle } from '../shape-styles'
import { TextShape, TLDrawShapeType, TLDrawTransformInfo } from '~types' import { TextShape, TLDrawComponentProps, TLDrawShapeType, TLDrawTransformInfo } from '~types'
import { TextAreaUtils } from '../shared' import { TextAreaUtils } from '../shared'
import { BINDING_DISTANCE } from '~constants' import { BINDING_DISTANCE } from '~constants'
import { TLDrawShapeUtil } from '../TLDrawShapeUtil' import { TLDrawShapeUtil } from '../TLDrawShapeUtil'
@ -38,7 +38,7 @@ export class TextUtil extends TLDrawShapeUtil<T, E> {
) )
} }
Component = React.forwardRef<E, TLComponentProps<T, E>>( Component = React.forwardRef<E, TLDrawComponentProps<T, E>>(
({ shape, isBinding, isEditing, onShapeBlur, onShapeChange, meta, events }, ref) => { ({ shape, isBinding, isEditing, onShapeBlur, onShapeChange, meta, events }, ref) => {
const rInput = React.useRef<HTMLTextAreaElement>(null) const rInput = React.useRef<HTMLTextAreaElement>(null)
const { text, style } = shape const { text, style } = shape

View file

@ -9,6 +9,7 @@ import type {
TLHandle, TLHandle,
TLBounds, TLBounds,
TLSnapLine, TLSnapLine,
TLComponentProps,
} from '@tldraw/core' } from '@tldraw/core'
import type { TLPage, TLUser, TLPageState } from '@tldraw/core' import type { TLPage, TLUser, TLPageState } from '@tldraw/core'
import type { StoreApi } from 'zustand' import type { StoreApi } from 'zustand'
@ -22,6 +23,12 @@ export interface TLDrawTransformInfo<T extends TLShape> {
transformOrigin: number[] transformOrigin: number[]
} }
export type TLDrawComponentProps<T extends TLDrawShape, E extends Element = any> = TLComponentProps<
T,
E,
TLDrawMeta
>
// old // old
export type TLStore = StoreApi<Data> export type TLStore = StoreApi<Data>