feat: 기능 추가 과정중
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { useId, type FormHTMLAttributes, type ReactNode } from "react";
|
||||
|
||||
import { TextField } from "../components/ui/text-field.jsx";
|
||||
import { useLocale } from "../i18n/index.js";
|
||||
import { TextField } from "../components/ui/text-field.ts";
|
||||
import { useLocale } from "../i18n/index.ts";
|
||||
import type {
|
||||
FieldErrors,
|
||||
FieldName,
|
||||
FormValues,
|
||||
} from "./form-contracts.js";
|
||||
} from "./form-contracts.ts";
|
||||
|
||||
export function Form(
|
||||
props: FormHTMLAttributes<HTMLFormElement> & Readonly<{ pending?: boolean }>,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { ApiFailure } from "../../contracts/errors.js";
|
||||
import type { Result } from "../../application/result.ts";
|
||||
import type { AppFailure } from "../../contracts/errors.ts";
|
||||
import {
|
||||
formatMessage,
|
||||
type ParameterlessMessageKey,
|
||||
} from "../i18n/index.js";
|
||||
} from "../i18n/index.ts";
|
||||
|
||||
export type FormValues = Readonly<Record<string, unknown>>;
|
||||
export type FieldName<Values extends FormValues> = Extract<keyof Values, string>;
|
||||
@@ -10,9 +11,7 @@ export type FieldErrors<Values extends FormValues> = Readonly<
|
||||
Partial<Record<FieldName<Values>, string>>
|
||||
>;
|
||||
|
||||
export type FormResult<Value> =
|
||||
| Readonly<{ ok: true; value: Value }>
|
||||
| Readonly<{ ok: false; error: ApiFailure }>;
|
||||
export type FormResult<Value> = Result<Value>;
|
||||
|
||||
export type FormResultState =
|
||||
| "idle"
|
||||
@@ -50,7 +49,7 @@ export function validationMessage(
|
||||
}
|
||||
|
||||
export function mapValidationFailureToFields<Values extends FormValues>(
|
||||
failure: ApiFailure,
|
||||
failure: AppFailure,
|
||||
allowedFields: readonly FieldName<Values>[],
|
||||
message: MessageResolver = defaultMessage,
|
||||
): MappedValidationFailure<Values> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from "./form-components.js";
|
||||
export * from "./form-contracts.js";
|
||||
export * from "./use-app-form.js";
|
||||
export * from "./use-dirty-navigation-guard.js";
|
||||
export * from "./form-components.tsx";
|
||||
export * from "./form-contracts.ts";
|
||||
export * from "./use-app-form.ts";
|
||||
export * from "./use-dirty-navigation-guard.tsx";
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { ZodType, ZodIssue } from "zod";
|
||||
import {
|
||||
useLocale,
|
||||
type ParameterlessMessageKey,
|
||||
} from "../i18n/index.js";
|
||||
} from "../i18n/index.ts";
|
||||
|
||||
import {
|
||||
mapValidationFailureToFields,
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
type FormResult,
|
||||
type FormResultState,
|
||||
type FormValues,
|
||||
} from "./form-contracts.js";
|
||||
} from "./form-contracts.ts";
|
||||
|
||||
type AppFormOptions<
|
||||
Values extends FormValues,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useCallback } from "react";
|
||||
import { useBeforeUnload, useBlocker } from "react-router-dom";
|
||||
|
||||
import { Button } from "../components/ui/button.jsx";
|
||||
import { Dialog } from "../components/ui/dialog.jsx";
|
||||
import { useLocale } from "../i18n/index.js";
|
||||
import { Button } from "../components/ui/button.ts";
|
||||
import { Dialog } from "../components/ui/dialog.ts";
|
||||
import { useLocale } from "../i18n/index.ts";
|
||||
|
||||
export function useDirtyNavigationGuard(when: boolean) {
|
||||
const blocker = useBlocker(when);
|
||||
|
||||
Reference in New Issue
Block a user