mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
fix dead code with knip upgrade TS to v6 and fix linting errors auto apply oxfmt rules fix linting errors - unused deps etc ignore file remove all ignored files in knip add knip - dead code analysis tool swap prettier and eslint of oxfmt and oxlint fix: fix map rendering in react strict mode fix: headlessUI float replace fix: disable Matomo if not URL and SITE ID exist upgrade: 1st pass upgrade to Next.js v16 deps: upgrade react to v19
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import React from "react";
|
|
|
|
import { FeatureCollection } from "geojson";
|
|
import dynamic from "next/dynamic";
|
|
import { Controller, FieldPath, FieldValues } from "react-hook-form";
|
|
|
|
import { Prettify } from "@/types";
|
|
|
|
import LoadingMap from "../LoadingMap";
|
|
|
|
import { Field, GenericFieldProps } from "./Field";
|
|
import type { ZoneEditorProps } from "./ZoneEditor";
|
|
|
|
const ZoneEditor = dynamic(() => import("./ZoneEditor"), {
|
|
ssr: false,
|
|
loading: LoadingMap,
|
|
});
|
|
|
|
type ZoneEditorFieldProps<
|
|
TFieldValues extends FieldValues = FieldValues,
|
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
> = Prettify<
|
|
GenericFieldProps<TFieldValues, TFieldName> & Omit<ZoneEditorProps, "value" | "onChange">
|
|
>;
|
|
|
|
export const ZoneEditorField = <
|
|
TFieldValues extends FieldValues = FieldValues,
|
|
TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
>(
|
|
props: ZoneEditorFieldProps<TFieldValues, TFieldName>,
|
|
) => {
|
|
const { name, control, label, className, labelClassName } = props;
|
|
|
|
return (
|
|
<Field
|
|
{...{
|
|
name,
|
|
control,
|
|
label,
|
|
className,
|
|
labelClassName,
|
|
}}
|
|
>
|
|
<div className="flex w-full flex-col">
|
|
<Controller
|
|
control={control}
|
|
name={name}
|
|
render={({ field: { onChange, value } }) => (
|
|
<ZoneEditor
|
|
value={value ?? { type: "FeatureCollection", features: [] }}
|
|
onChange={(geoJson: FeatureCollection) => onChange(geoJson)}
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
</Field>
|
|
);
|
|
};
|