added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions

View File

@@ -30,11 +30,11 @@ export type LoginFormProps = Omit<ComponentPropsWithoutRef<"form">, "onSubmit" |
const validator = new TypeboxValidator();
const schema = Type.Object({
email: Type.String({
pattern: "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"
pattern: "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$",
}),
password: Type.String({
minLength: 8 // @todo: this should be configurable
})
minLength: 8, // @todo: this should be configurable
}),
});
export function AuthForm({
@@ -49,7 +49,7 @@ export function AuthForm({
const basepath = auth?.basepath ?? "/api/auth";
const password = {
action: `${basepath}/password/${action}`,
strategy: auth?.strategies?.password ?? ({ type: "password" } as const)
strategy: auth?.strategies?.password ?? ({ type: "password" } as const),
};
const oauth = transform(
@@ -59,7 +59,7 @@ export function AuthForm({
result[key] = value.config;
}
},
{}
{},
) as Record<string, AppAuthOAuthStrategy>;
const has_oauth = Object.keys(oauth).length > 0;

View File

@@ -15,7 +15,7 @@ export function AuthScreen({
action = "login",
logo,
intro,
formOnly
formOnly,
}: AuthScreenProps) {
const { strategies, basepath, loading } = useAuthStrategies();
const Form = <AuthForm auth={{ basepath, strategies }} method={method} action={action} />;

View File

@@ -20,7 +20,7 @@ export function SocialLink({
action,
method = "POST",
basepath = "/api/auth",
children
children,
}: SocialLinkProps) {
const url = [basepath, provider, action].join("/");

View File

@@ -6,7 +6,7 @@ import { SocialLink } from "./SocialLink";
export const Auth = {
Screen: AuthScreen,
Form: AuthForm,
SocialLink: SocialLink
SocialLink: SocialLink,
};
export { useAuthStrategies };

View File

@@ -6,7 +6,7 @@ import {
memo,
useEffect,
useRef,
useState
useState,
} from "react";
import { TbDots } from "react-icons/tb";
import { twMerge } from "tailwind-merge";
@@ -84,7 +84,7 @@ export function Dropzone({
onRejected,
onDeleted,
onUploaded,
children
children,
}: DropzoneProps) {
const [files, setFiles] = useState<FileState[]>(initialItems);
const [uploading, setUploading] = useState<boolean>(false);
@@ -116,7 +116,7 @@ export function Dropzone({
const specs = items.map((item) => ({
kind: "kind" in item ? item.kind : "file",
type: item.type,
size: "size" in item ? item.size : 0
size: "size" in item ? item.size : 0,
}));
return specs.every((spec) => {
@@ -164,7 +164,7 @@ export function Dropzone({
size: f.size,
type: f.type,
state: "pending",
progress: 0
progress: 0,
}));
return flow === "start" ? [...filteredFiles, ..._prev] : [..._prev, ...filteredFiles];
@@ -185,7 +185,7 @@ export function Dropzone({
},
onLeave: () => {
setIsOverAccepted(false);
}
},
});
useEffect(() => {
@@ -223,11 +223,11 @@ export function Dropzone({
return {
...f,
state,
progress: progress ?? f.progress
progress: progress ?? f.progress,
};
}
return f;
})
}),
);
}
@@ -237,11 +237,11 @@ export function Dropzone({
if (f.path === prevPath) {
return {
...f,
...newState
...newState,
};
}
return f;
})
}),
);
}
@@ -293,7 +293,7 @@ export function Dropzone({
console.log(`Progress: ${percentComplete.toFixed(2)}%`);
} else {
console.log(
"Unable to compute progress information since the total size is unknown"
"Unable to compute progress information since the total size is unknown",
);
}
});
@@ -311,7 +311,7 @@ export function Dropzone({
const newState = {
...response.state,
progress: 1,
state: "uploaded"
state: "uploaded",
};
replaceFileState(file.path, newState);
@@ -364,7 +364,7 @@ export function Dropzone({
const openFileInput = () => inputRef.current?.click();
const showPlaceholder = Boolean(
placeholder?.show === true || !maxItems || (maxItems && files.length < maxItems)
placeholder?.show === true || !maxItems || (maxItems && files.length < maxItems),
);
const renderProps: DropzoneRenderProps = {
@@ -373,25 +373,25 @@ export function Dropzone({
ref: inputRef,
type: "file",
multiple: !maxItems || maxItems > 1,
onChange: handleFileInputChange
onChange: handleFileInputChange,
},
state: {
files,
isOver,
isOverAccepted,
showPlaceholder
showPlaceholder,
},
actions: {
uploadFile,
deleteFile,
openFileInput
openFileInput,
},
dropzoneProps: {
maxItems,
placeholder,
autoUpload,
flow
}
flow,
},
};
return children ? children(renderProps) : <DropzoneInner {...renderProps} />;
@@ -402,7 +402,7 @@ const DropzoneInner = ({
inputProps,
state: { files, isOver, isOverAccepted, showPlaceholder },
actions: { uploadFile, deleteFile, openFileInput },
dropzoneProps: { placeholder, flow }
dropzoneProps: { placeholder, flow },
}: DropzoneRenderProps) => {
const Placeholder = showPlaceholder && (
<UploadPlaceholder onClick={openFileInput} text={placeholder?.text} />
@@ -422,7 +422,7 @@ const DropzoneInner = ({
className={twMerge(
"dropzone w-full h-full align-start flex flex-col select-none",
isOver && isOverAccepted && "bg-green-200/10",
isOver && !isOverAccepted && "bg-red-200/40 cursor-not-allowed"
isOver && !isOverAccepted && "bg-red-200/40 cursor-not-allowed",
)}
>
<div className="hidden">
@@ -478,7 +478,7 @@ const Wrapper = ({ file, fallback, ...props }: PreviewComponentProps) => {
};
export const PreviewWrapperMemoized = memo(
Wrapper,
(prev, next) => prev.file.path === next.file.path
(prev, next) => prev.file.path === next.file.path,
);
type PreviewProps = {
@@ -490,12 +490,12 @@ const Preview: React.FC<PreviewProps> = ({ file, handleUpload, handleDelete }) =
const dropdownItems = [
["initial", "uploaded"].includes(file.state) && {
label: "Delete",
onClick: () => handleDelete(file)
onClick: () => handleDelete(file),
},
["initial", "pending"].includes(file.state) && {
label: "Upload",
onClick: () => handleUpload(file)
}
onClick: () => handleUpload(file),
},
];
return (
@@ -503,7 +503,7 @@ const Preview: React.FC<PreviewProps> = ({ file, handleUpload, handleDelete }) =
className={twMerge(
"w-[49%] md:w-60 flex flex-col border border-muted relative",
file.state === "failed" && "border-red-500 bg-red-200/20",
file.state === "deleting" && "opacity-70"
file.state === "deleting" && "opacity-70",
)}
>
<div className="absolute top-2 right-2">

View File

@@ -38,7 +38,7 @@ export function DropzoneContainer({
const baseUrl = api.baseUrl;
const defaultQuery = {
limit: query?.limit ? query?.limit : props.maxItems ? props.maxItems : 50,
sort: "-id"
sort: "-id",
};
const entity_name = (media?.entity_name ?? "media") as "media";
//console.log("dropzone:baseUrl", baseUrl);
@@ -51,12 +51,12 @@ export function DropzoneContainer({
where: {
reference: `${entity.name}.${entity.field}`,
entity_id: entity.id,
...query?.where
}
...query?.where,
},
})
: api.data.readMany(entity_name, {
...defaultQuery,
...query
...query,
});
const $q = useApiQuery(selectApi, { enabled: initialItems !== false && !initialItems });
@@ -69,7 +69,7 @@ export function DropzoneContainer({
return {
url,
headers: api.media.getUploadHeaders(),
method: "POST"
method: "POST",
};
});

View File

@@ -9,7 +9,7 @@ import { guess } from "media/storage/mime-types-tiny";
const FILES_TO_IGNORE = [
// Thumbnail cache files for macOS and Windows
".DS_Store", // macOs
"Thumbs.db" // Windows
"Thumbs.db", // Windows
];
export function toFileWithPath(file: FileWithPath, path?: string): FileWithPath {
@@ -29,7 +29,7 @@ export function toFileWithPath(file: FileWithPath, path?: string): FileWithPath
: file.name,
writable: false,
configurable: false,
enumerable: true
enumerable: true,
});
}
@@ -55,7 +55,7 @@ function withMimeType(file: FileWithPath) {
value: type,
writable: false,
configurable: false,
enumerable: true
enumerable: true,
});
}
}
@@ -105,7 +105,7 @@ function isObject<T>(v: any): v is T {
function getInputFiles(evt: Event) {
return fromList<FileWithPath>((evt.target as HTMLInputElement).files).map((file) =>
toFileWithPath(file)
toFileWithPath(file),
);
}
@@ -179,9 +179,9 @@ function flatten<T>(items: any[]): T[] {
(acc, files) => [
// biome-ignore lint/performance/noAccumulatingSpread: <explanation>
...acc,
...(Array.isArray(files) ? flatten(files) : [files])
...(Array.isArray(files) ? flatten(files) : [files]),
],
[]
[],
);
}
@@ -229,7 +229,7 @@ function fromDirEntry(entry: any) {
},
(err: any) => {
reject(err);
}
},
);
}
@@ -247,7 +247,7 @@ async function fromFileEntry(entry: any) {
},
(err: any) => {
reject(err);
}
},
);
});
}

View File

@@ -6,7 +6,7 @@ export function mediaItemToFileState(
options: {
overrides?: Partial<FileState>;
baseUrl?: string;
} = { overrides: {}, baseUrl: "" }
} = { overrides: {}, baseUrl: "" },
): FileState {
return {
body: `${options.baseUrl}/api/media/file/${item.path}`,
@@ -16,7 +16,7 @@ export function mediaItemToFileState(
type: item.mime_type ?? "",
state: "uploaded",
progress: 0,
...options.overrides
...options.overrides,
};
}
@@ -25,7 +25,7 @@ export function mediaItemsToFileStates(
options: {
overrides?: Partial<FileState>;
baseUrl?: string;
} = { overrides: {}, baseUrl: "" }
} = { overrides: {}, baseUrl: "" },
): FileState[] {
return items.map((item) => mediaItemToFileState(item, options));
}

View File

@@ -4,7 +4,7 @@ import { DropzoneContainer, useDropzone } from "./DropzoneContainer";
export const Media = {
Dropzone: DropzoneContainer,
Preview: PreviewWrapperMemoized,
useDropzone: useDropzone
useDropzone: useDropzone,
};
export { useDropzone as useMediaDropzone };
@@ -14,6 +14,6 @@ export type {
FileState,
FileStateWithData,
DropzoneProps,
DropzoneRenderProps
DropzoneRenderProps,
} from "./Dropzone";
export type { DropzoneContainerProps } from "./DropzoneContainer";

View File

@@ -9,7 +9,7 @@ type DropzoneProps = {
const events = {
enter: ["dragenter", "dragover", "dragstart"] as const,
leave: ["dragleave", "drop"] as const
leave: ["dragleave", "drop"] as const,
};
const allEvents = [...events.enter, ...events.leave];
@@ -45,7 +45,7 @@ export function useDropzone({ onDropped, onOver, onLeave }: DropzoneProps) {
onDropped?.(files as any);
onOverCalled.current = false;
},
[onDropped]
[onDropped],
);
const handleFileInputChange = useCallback(
@@ -53,7 +53,7 @@ export function useDropzone({ onDropped, onOver, onLeave }: DropzoneProps) {
const files = await fromEvent(e);
onDropped?.(files as any);
},
[onDropped]
[onDropped],
);
useEffect(() => {