Upgrade eslint-plugin-matrix-org to 1.2.1
This upgrade came with a number of new lints that needed to be fixed across the code base. Primarily: explicit return types on functions, and explicit visibility modifiers on class members.
This commit is contained in:
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentType, useCallback, useMemo, useRef } from "react";
|
||||
import { ComponentType, ReactNode, useCallback, useMemo, useRef } from "react";
|
||||
|
||||
import type { RectReadOnly } from "react-use-measure";
|
||||
import { useReactiveState } from "../useReactiveState";
|
||||
@@ -98,16 +98,33 @@ export const useLayoutStates = (): LayoutStatesMap => {
|
||||
return layoutStates.current as LayoutStatesMap;
|
||||
};
|
||||
|
||||
interface UseLayout<State, T> {
|
||||
state: State;
|
||||
orderedItems: TileDescriptor<T>[];
|
||||
generation: number;
|
||||
canDragTile: (tile: TileDescriptor<T>) => boolean;
|
||||
dragTile: (
|
||||
from: TileDescriptor<T>,
|
||||
to: TileDescriptor<T>,
|
||||
xPositionOnFrom: number,
|
||||
yPositionOnFrom: number,
|
||||
xPositionOnTo: number,
|
||||
yPositionOnTo: number
|
||||
) => void;
|
||||
toggleFocus: ((tile: TileDescriptor<T>) => void) | undefined;
|
||||
slots: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook which uses the provided layout system to arrange a set of items into a
|
||||
* concrete layout state, and provides callbacks for user interaction.
|
||||
*/
|
||||
export const useLayout = <State, T>(
|
||||
export function useLayout<State, T>(
|
||||
layout: Layout<State>,
|
||||
items: TileDescriptor<T>[],
|
||||
bounds: RectReadOnly,
|
||||
layoutStates: LayoutStatesMap
|
||||
) => {
|
||||
): UseLayout<State, T> {
|
||||
const prevLayout = useRef<Layout<unknown>>();
|
||||
const prevState = layoutStates.get(layout);
|
||||
|
||||
@@ -169,10 +186,10 @@ export const useLayout = <State, T>(
|
||||
toggleFocus: useMemo(
|
||||
() =>
|
||||
layout.toggleFocus &&
|
||||
((tile: TileDescriptor<T>) =>
|
||||
((tile: TileDescriptor<T>): void =>
|
||||
setState((s) => layout.toggleFocus!(s, tile))),
|
||||
[layout, setState]
|
||||
),
|
||||
slots: <layout.Slots s={state} />,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user