This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { ActionFunctionArgs, ActionFunction } from "@remix-run/node"; | |
import type { AnyZodObject, z } from "zod" | |
export type FormActionHandler<T extends AnyZodObject> = (data: z.infer<T>, args: ActionFunctionArgs) => Promise<Response | null> | |
export type FormAction<T extends AnyZodObject> = { | |
schema: T | |
} & { | |
handler: FormActionHandler<T> | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { z } from "zod"; | |
type ParsedFormData<T extends z.AnyZodObject> = { | |
data: null; | |
errors: z.typeToFlattenedError<z.infer<T>>['fieldErrors'] | |
} | { | |
data: z.infer<T>; | |
errors: null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function base64ToBytes(base64: string): Uint8Array { | |
const binString = atob(base64); | |
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0); | |
} | |
function bytesToBase64(bytes: Uint8Array): string { | |
const binString = String.fromCodePoint(...bytes); | |
return btoa(binString); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"word": "a", | |
"level": "a1", | |
"type": "indefinite article" | |
}, | |
{ | |
"word": "abandon", | |
"level": "b2", | |
"type": "verb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CustomEventMap<T> = { | |
[key in keyof T]: CustomEvent | Event; | |
}; | |
interface CustomEventListener<M, K extends keyof M> { | |
(evt: M[K]): void; | |
} | |
interface CustomEventListenerObject< | |
M, |
OlderNewer