Skip to content

Commit 9e216f0

Browse files
committed
Fixed react types
1 parent 969d03d commit 9e216f0

File tree

9 files changed

+36
-24
lines changed

9 files changed

+36
-24
lines changed

src/components/Anchored.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ICommonProps, SizeUnit, Type, AnchorType, ResizeHandlePlacement } from "../core-types";
1+
import { SizeUnit, Type, AnchorType, ResizeHandlePlacement } from "../core-types";
22
import * as React from "react";
33
import { Space } from "./Space";
44
import * as PropTypes from "prop-types";
5-
import { commonProps } from "../core-react";
5+
import { commonProps, IReactSpaceProps } from "../core-react";
66

7-
interface IAnchorProps extends ICommonProps {
7+
interface IAnchorProps extends IReactSpaceProps {
88
size: SizeUnit;
99
order?: number;
1010
resizable?: boolean;

src/components/Custom.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ICommonProps, Type, SizeUnit, IPositionalProps, AnchorType, ResizeType, ResizeHandlePlacement } from "../core-types";
1+
import { Type, SizeUnit, IPositionalProps, AnchorType, ResizeType, ResizeHandlePlacement } from "../core-types";
22
import * as React from "react";
33
import { Space } from "./Space";
44
import * as PropTypes from "prop-types";
5-
import { commonProps } from "../core-react";
5+
import { commonProps, IReactSpaceProps } from "../core-react";
66

7-
interface ICustomProps extends ICommonProps {
7+
interface ICustomProps extends IReactSpaceProps {
88
left?: SizeUnit | undefined;
99
top?: SizeUnit | undefined;
1010
right?: SizeUnit | undefined;

src/components/Fill.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ICommonProps, Type } from "../core-types";
1+
import { Type } from "../core-types";
22
import * as React from "react";
33
import { Space } from "./Space";
4-
import { commonProps } from "../core-react";
4+
import { commonProps, IReactSpaceProps } from "../core-react";
55

6-
export const Fill: React.FC<ICommonProps> = (props) => (
6+
export const Fill: React.FC<IReactSpaceProps> = (props) => (
77
<Space {...props} type={Type.Fill} position={{ left: 0, top: 0, right: 0, bottom: 0 }}>
88
{props.children}
99
</Space>

src/components/Fixed.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ICommonProps, SizeUnit, Type } from "../core-types";
1+
import { SizeUnit, Type } from "../core-types";
22
import * as React from "react";
33
import { Space } from "./Space";
44
import * as PropTypes from "prop-types";
5-
import { commonProps } from "../core-react";
5+
import { commonProps, IReactSpaceProps } from "../core-react";
66

7-
interface IFixedProps extends ICommonProps {
7+
interface IFixedProps extends IReactSpaceProps {
88
width?: SizeUnit;
99
height: SizeUnit;
1010
}

src/components/Positioned.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ICommonProps, Type, SizeUnit, ResizeType } from "../core-types";
1+
import { Type, SizeUnit, ResizeType } from "../core-types";
22
import * as React from "react";
33
import { Space } from "./Space";
44
import * as PropTypes from "prop-types";
5-
import { commonProps } from "../core-react";
5+
import { commonProps, IReactSpaceProps } from "../core-react";
66

7-
interface IPositionedProps extends ICommonProps {
7+
interface IPositionedProps extends IReactSpaceProps {
88
left?: SizeUnit;
99
top?: SizeUnit;
1010
right?: SizeUnit;

src/components/Space.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CenterType, ResizeHandlePlacement, AnchorType, Type } from "../core-types";
2-
import { useSpace, ParentContext, LayerContext, DOMRectContext, IReactSpaceProps } from "../core-react";
2+
import { useSpace, ParentContext, LayerContext, DOMRectContext, IReactSpaceInnerProps } from "../core-react";
33
import * as React from "react";
44
import { Centered } from "./Centered";
55
import { CenteredVertically } from "./CenteredVertically";
@@ -15,13 +15,13 @@ function applyCentering(children: React.ReactNode, centerType: CenterType | unde
1515
return children;
1616
}
1717

18-
export class Space extends React.Component<IReactSpaceProps> {
18+
export class Space extends React.Component<IReactSpaceInnerProps> {
1919
public render() {
2020
return <SpaceInner {...this.props} wrapperInstance={this} />;
2121
}
2222
}
2323

24-
const SpaceInner: React.FC<IReactSpaceProps & { wrapperInstance: Space }> = (props) => {
24+
const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> = (props) => {
2525
if (!props.id && !props.wrapperInstance["_react_spaces_uniqueid"]) {
2626
props.wrapperInstance["_react_spaces_uniqueid"] = `s${shortuuid()}`;
2727
}

src/components/ViewPort.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ICommonProps, Type, SizeUnit } from "../core-types";
1+
import { Type, SizeUnit } from "../core-types";
22
import * as React from "react";
33
import { Space } from "./Space";
44
import * as PropTypes from "prop-types";
5-
import { commonProps } from "../core-react";
5+
import { commonProps, IReactSpaceProps } from "../core-react";
66

7-
interface IViewPortProps extends ICommonProps {
7+
interface IViewPortProps extends IReactSpaceProps {
88
left?: SizeUnit;
99
right?: SizeUnit;
1010
top?: SizeUnit;

src/components/tests/Common.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ export const commonPropsTests = (name: string, component: React.ReactNode, expec
2323
});
2424
});
2525

26+
test(`${name} with id applied`, async () => {
27+
// arrange, act
28+
const { container } = render(<ViewPort>{mutateComponent(component, { id: "test" })}</ViewPort>);
29+
30+
// assert
31+
const sut = container.querySelector("#test")!;
32+
expect(sut.id).toBe("test");
33+
});
34+
2635
test(`${name} with class applied`, async () => {
2736
// arrange, act
2837
const { container } = render(<ViewPort>{mutateComponent(component, { id: "test", className: "custom-class" })}</ViewPort>);
@@ -132,11 +141,12 @@ export const commonAnchorTests = (
132141

133142
// assert
134143
const style = window.getComputedStyle(sut);
144+
const style1 = window.getComputedStyle(sut1);
145+
135146
expect(size(style)).toBe("50px");
136147
expect(edge(style)).toBe("0px");
137148
expect(oppositeEdge(style)).toBe("");
138149

139-
const style1 = window.getComputedStyle(sut1);
140150
expect(size(style1)).toBe("100px");
141151
expect(edge(style1)).toBe("calc(0px + 50px)");
142152
expect(oppositeEdge(style1)).toBe("");

src/core-react.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ export interface IReactEvents {
4747
onTouchEnd?: (event: React.TouchEvent<HTMLElement>) => void;
4848
}
4949

50-
export interface IReactSpaceProps extends ISpaceProps, IReactEvents {
50+
export interface IReactSpaceProps extends ICommonProps, IReactEvents {
5151
style?: React.CSSProperties;
5252
as?: keyof React.ReactDOM | React.ComponentType<ICommonProps>;
5353
}
5454

55+
export interface IReactSpaceInnerProps extends IReactSpaceProps, ISpaceProps, IReactEvents {}
56+
5557
export interface IReactSpacesOptions {
5658
debug?: boolean;
5759
}
@@ -64,7 +66,7 @@ export function useForceUpdate() {
6466
return update;
6567
}
6668

67-
export function useSpace(props: IReactSpaceProps) {
69+
export function useSpace(props: IReactSpaceInnerProps) {
6870
const store = currentStore;
6971
const update = useForceUpdate();
7072
const parent = React.useContext(ParentContext);

0 commit comments

Comments
 (0)