Skip to content

Commit

Permalink
Update ts version, fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
danreeves committed Oct 10, 2023
1 parent d1ed620 commit 9051db8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion example/components/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default function Demo() {
bounds="parent"
onDrag={() => {
tether.current?.getTetherInstance() &&
tether.current?.getTetherInstance().position();
tether.current?.getTetherInstance()?.position();
}}
defaultPosition={{
x: container.clientWidth / 2 - 100 / 2,
Expand Down
6 changes: 3 additions & 3 deletions example/tests/html-class-stability/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class App extends React.Component {
}}
>
Toggle Tethered Content
</button>
</button>
<button
onClick={() => {
this.setState({
Expand All @@ -45,7 +45,7 @@ class App extends React.Component {
}}
>
Change Classes
</button>
</button>
</div>
)}
renderElement={(ref) =>
Expand All @@ -61,7 +61,7 @@ class App extends React.Component {
}}
>
Add More Content
</button>
</button>
<p>{content}</p>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"testcafe": "2.0.0",
"testcafe-browser-provider-saucelabs": "1.9.0",
"ts-jest": "^29.0.1",
"typescript": "^4.8.3"
"typescript": "^5.2"
},
"files": [
"dist",
Expand Down
87 changes: 43 additions & 44 deletions src/react-tether.d.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
import * as React from "react";
import type * as Tether from "tether";
import Tether from "tether";

export default TetherComponent;
export as namespace ReactTether;

declare class TetherComponent extends React.Component<ReactTether.TetherComponentProps> {
props: ReactTether.TetherComponentProps;
props: ReactTether.TetherComponentProps;

static propTypes: ReactTether.TetherComponentProps;
static propTypes: ReactTether.TetherComponentProps;

static defaultProps: {
renderElementTag: string;
renderElementTo: any;
};
static defaultProps: {
renderElementTag: string;
renderElementTo: any;
};

getTetherInstance(): Tether;
getTetherInstance(): Tether;

disable(): void;
disable(): void;

enable(): void;
enable(): void;

on(event: any, handler: any, ctx?: any): void;
on(event: any, handler: any, ctx?: any): void;

once(event: any, handler: any, ctx?: any): void;
once(event: any, handler: any, ctx?: any): void;

off(event: any, handler: any): void;
off(event: any, handler: any): void;

position(): void;
position(): void;
}

declare namespace ReactTether {
type TetherAttachment = { top: string; left: string };
type UpdateEventData = {
attachment: TetherAttachment;
targetAttachment: TetherAttachment;
};
type RenderProp = (ref: React.RefObject<Element>) => React.ReactNode;
type TetherAttachment = { top: string; left: string };
type UpdateEventData = {
attachment: TetherAttachment;
targetAttachment: TetherAttachment;
};
type RenderProp = (ref: React.RefObject<Element>) => React.ReactNode;

type ContraintsTo = string | "window" | "scrollParent" | HTMLElement;
type ContraintsTo = string | "window" | "scrollParent" | HTMLElement;

type Constraints = {
to?: ContraintsTo;
attachment?: string | "together";
outOfBoundsClass?: string;
pinnedClass?: string;
pin?: boolean | string[];
};
type Constraints = {
to?: ContraintsTo;
attachment?: string | "together";
outOfBoundsClass?: string;
pinnedClass?: string;
pin?: boolean | string[];
};

type TetherComponentProps = {
renderTarget?: RenderProp;
renderElement?: RenderProp;
renderElementTag?: string;
renderElementTo?: Element | string;
attachment: string;
targetAttachment?: string;
constraints?: Constraints[];
className?: string;
id?: string;
style?: React.CSSProperties;
onUpdate?: (data: UpdateEventData) => void;
onRepositioned?: () => void;
offset?: string;
} & React.Props<TetherComponent> &
Tether.ITetherOptions;
type TetherComponentProps = {
renderTarget?: RenderProp;
renderElement?: RenderProp;
renderElementTag?: string;
renderElementTo?: Element | string;
attachment: string;
targetAttachment?: string;
constraints?: Constraints[];
className?: string;
id?: string;
style?: React.CSSProperties;
onUpdate?: (data: UpdateEventData) => void;
onRepositioned?: () => void;
offset?: string;
} & Tether.ITetherOptions;
}
3 changes: 2 additions & 1 deletion src/react-tether.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, isValidElement, RefObject } from "react";
import React, { Component, isValidElement } from "react";
import type { RefObject } from "react";
import ReactDOM from "react-dom";
import Tether from "tether";

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"importsNotUsedAsValues": "error",
"verbatimModuleSyntax": true,

// TSC config
"checkJs": true, // Typecheck JS files
Expand Down

0 comments on commit 9051db8

Please sign in to comment.