Skip to content

Commit

Permalink
change EditableElement type to accept class components too
Browse files Browse the repository at this point in the history
  • Loading branch information
GamerGirlandCo committed Jan 12, 2025
1 parent 5e9fb10 commit 6c4f4c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ui/fields/editable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @module ui
*/
import { Fragment, FunctionComponent, VNode } from "preact";
import { ComponentType, Fragment, VNode } from "preact";
import { Dispatch, Reducer, useContext, useEffect, useMemo, useRef } from "preact/hooks";
import { ChangeEvent, useReducer } from "preact/compat";
import Select, { ActionMeta } from "react-select";
Expand Down Expand Up @@ -50,8 +50,8 @@ export interface EditableProps<T> {
}

type EditableElementProps<T, P> = EditableState<T> & P;
export type EditableElement<T, P = any> = FunctionComponent<EditableElementProps<T, P> & P>;
export type EditableElement<T, P = any> = ComponentType<EditableElementProps<T, P> & P>;

/**
* Actions which update/change the state of an editable.
*
Expand Down Expand Up @@ -136,14 +136,14 @@ export function ControlledEditable<T, P = unknown>({
editor: Editor,
onUpdate,
content,
props,
sourcePath
props,
sourcePath,
}: Omit<EditableProps<T>, "dispatch" | "state" | "editor"> & {
onUpdate: (v: T) => unknown;
content: T;
editor: EditableElement<T, P>;
props: P;
sourcePath: string;
props: P;
sourcePath: string;
}) {
const [state, dispatch] = useEditableDispatch<T>(() => ({
updater: onUpdate,
Expand Down

0 comments on commit 6c4f4c7

Please sign in to comment.