Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";

import SectionControlButton from "../section-control-button";

type StoryArgs = Record<any, any>;
type StoryArgs = Record<string, unknown>;

type Story = {
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({markings: "grid"}),
undefined,
);
});

Expand All @@ -192,7 +191,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({rulerLabel: "cm"}),
undefined,
);
});

Expand All @@ -214,7 +212,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({rulerTicks: 4}),
undefined,
);
});

Expand Down Expand Up @@ -245,7 +242,6 @@ describe("GraphSettings", () => {
url: "https://example.com/image.png",
}),
}),
undefined,
),
);
});
Expand Down Expand Up @@ -276,7 +272,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
valid: "Image must be smaller than 450px x 450px.",
}),
undefined,
),
);
});
Expand Down Expand Up @@ -306,7 +301,6 @@ describe("GraphSettings", () => {
url: null,
}),
}),
undefined,
),
);
});
Expand Down Expand Up @@ -353,7 +347,6 @@ describe("GraphSettings", () => {
// Assert
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({showProtractor: false}),
undefined,
);
});

Expand Down Expand Up @@ -381,7 +374,6 @@ describe("GraphSettings", () => {
],
valid: true,
}),
undefined,
),
);
});
Expand Down Expand Up @@ -410,7 +402,6 @@ describe("GraphSettings", () => {
],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -433,13 +424,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
range: [
[-10, 10],
[-10, 10],
],
valid: "Range must have a higher number on the right",
}),
undefined,
),
);
});
Expand All @@ -465,7 +451,6 @@ describe("GraphSettings", () => {
step: [2, 1],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -488,10 +473,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
step: [1, 1],
valid: "Step is too large, there must be at least 3 ticks.",
}),
undefined,
),
);
});
Expand Down Expand Up @@ -521,10 +504,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
step: [1, 1],
valid: "Step is too small, there can be at most 20 ticks.",
}),
undefined,
),
);
});
Expand Down Expand Up @@ -554,7 +535,6 @@ describe("GraphSettings", () => {
snapStep: [2, 1],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -581,10 +561,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
snapStep: [1, 1],
valid: "Snap step is too large, there must be at least 5 ticks.",
}),
undefined,
),
);
});
Expand All @@ -611,7 +589,6 @@ describe("GraphSettings", () => {
gridStep: [2, 1],
valid: true,
}),
undefined,
),
);
});
Expand All @@ -635,10 +612,8 @@ describe("GraphSettings", () => {
await waitFor(() =>
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
gridStep: [1, 1],
valid: "Grid step is too large, there must be at least 3 ticks.",
}),
undefined,
),
);
});
Expand All @@ -664,7 +639,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
labels: ["time", "y"],
}),
undefined,
),
);
});
Expand All @@ -690,7 +664,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
labels: ["x", "count"],
}),
undefined,
),
);
});
Expand Down Expand Up @@ -719,7 +692,6 @@ describe("GraphSettings", () => {
expect.objectContaining({
box: [300, 288],
}),
undefined,
),
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus-editor/src/components/blur-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class BlurInput extends React.Component<Props, State> {
this.setState({value: nextProps.value});
}

handleChange: (e: any) => void = (e) => {
handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({value: e.target.value});
};

handleBlur: (e: any) => void = (e) => {
handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
this.props.onChange(e.target.value);
};

Expand Down
23 changes: 10 additions & 13 deletions packages/perseus-editor/src/components/drag-target.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
import * as React from "react";

type Props = {
onDrop: (e: DragEvent) => void;
component?: any;
shouldDragHighlight: (any) => boolean;
style?: any;
children?: any;
onDrop: (e: React.DragEvent<HTMLDivElement>) => void;
shouldDragHighlight: (e: React.DragEvent) => boolean;
style?: React.CSSProperties;
children?: React.ReactNode;
className?: string;
};

type DefaultProps = {
component: Props["component"];
shouldDragHighlight: Props["shouldDragHighlight"];
};

Expand All @@ -34,11 +32,10 @@ type State = {
};
class DragTarget extends React.Component<Props, State> {
static defaultProps: DefaultProps = {
component: "div",
shouldDragHighlight: () => true,
};

constructor(props) {
constructor(props: Props) {
super(props);
this.state = {
dragHover: false,
Expand All @@ -51,7 +48,7 @@ class DragTarget extends React.Component<Props, State> {
this.handleDragEnter = this.handleDragEnter.bind(this);
}

handleDrop(e: DragEvent) {
handleDrop(e: React.DragEvent<HTMLDivElement>) {
e.stopPropagation();
e.preventDefault();
this.setState({dragHover: false});
Expand All @@ -62,29 +59,29 @@ class DragTarget extends React.Component<Props, State> {
this.setState({dragHover: false});
}

handleDragOver(e) {
handleDragOver(e: React.DragEvent) {
e.preventDefault();
}

handleDragLeave() {
this.setState({dragHover: false});
}

handleDragEnter(e) {
handleDragEnter(e: React.DragEvent) {
this.setState({dragHover: this.props.shouldDragHighlight(e)});
}

render() {
const opacity = this.state.dragHover ? {opacity: 0.3} : {};
const {
component: Component,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
shouldDragHighlight,
...forwardProps
} = this.props;

return (
<Component
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div
{...forwardProps}
style={Object.assign({}, this.props.style, opacity)}
onDrop={this.handleDrop}
Expand Down
14 changes: 7 additions & 7 deletions packages/perseus-editor/src/components/dropdown-option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ class Option extends React.Component<Props> {
// @ts-expect-error - TS2564 - Property 'node' has no initializer and is not definitely assigned in the constructor.
node: HTMLDivElement;

handleKeyDown(event: any): void {
handleKeyDown(event: React.KeyboardEvent<HTMLButtonElement>): void {
const {onDropdownClose} = this.props;
const pressedKey = event.key;
const focusedElement = event.target;
const focusedElement = event.currentTarget;

if (pressedKey === "ArrowDown" && focusedElement.nextSibling) {
if (pressedKey === "ArrowDown" && focusedElement.nextElementSibling) {
event.preventDefault();
focusedElement.nextSibling.focus();
(focusedElement.nextElementSibling as HTMLElement).focus();
}
if (pressedKey === "ArrowUp" && focusedElement.previousSibling) {
if (pressedKey === "ArrowUp" && focusedElement.previousElementSibling) {
event.preventDefault();
focusedElement.previousSibling.focus();
(focusedElement.previousElementSibling as HTMLElement).focus();
}
if (
pressedKey === "ArrowUp" &&
!focusedElement.previousSibling &&
!focusedElement.previousElementSibling &&
onDropdownClose
) {
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class FormWrappedTextField extends React.Component<PropsWithForwardRef, State> {
} = this.props;
const {focused} = this.state;

const extraStyles: any = {};
const extraStyles: React.CSSProperties = {};
const spanStyle = [styles.input, styles.container];

// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
Expand Down
Loading
Loading