261021_01_ENH: 1차 마이그레이션 완료
This commit is contained in:
10
src/app/(pages)/(main)/Management/Derived/page.tsx
Normal file
10
src/app/(pages)/(main)/Management/Derived/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import { DerivedWorkspace } from "@/components/derived/DerivedWorkspace";
|
||||
|
||||
export default function DerivedPage() {
|
||||
return (
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<DerivedWorkspace />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
10
src/app/(pages)/(main)/Management/Exim/page.tsx
Normal file
10
src/app/(pages)/(main)/Management/Exim/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import { EximWorkspace } from "@/components/exim/EximWorkspace";
|
||||
|
||||
export default function EximPage() {
|
||||
return (
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<EximWorkspace />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
10
src/app/(pages)/(main)/Report/Crosstab/page.tsx
Normal file
10
src/app/(pages)/(main)/Report/Crosstab/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import { CrosstabWorkspace } from "@/components/report/CrosstabWorkspace";
|
||||
|
||||
export default function CrosstabPage() {
|
||||
return (
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<CrosstabWorkspace />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
10
src/app/(pages)/(main)/Report/Current/page.tsx
Normal file
10
src/app/(pages)/(main)/Report/Current/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import { ProjectProgress } from "@/components/project/ProjectProgress";
|
||||
|
||||
export default function CurrentPage() {
|
||||
return (
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<ProjectProgress />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
10
src/app/(pages)/(main)/Report/Quota/page.tsx
Normal file
10
src/app/(pages)/(main)/Report/Quota/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import { QuotaWorkspace } from "@/components/report/QuotaWorkspace";
|
||||
|
||||
export default function QuotaPage() {
|
||||
return (
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<QuotaWorkspace />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
10
src/app/(pages)/(main)/Report/Tabulation/page.tsx
Normal file
10
src/app/(pages)/(main)/Report/Tabulation/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Suspense } from "react";
|
||||
import { TabulationWorkspace } from "@/components/report/TabulationWorkspace";
|
||||
|
||||
export default function TabulationPage() {
|
||||
return (
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<TabulationWorkspace />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
import { AppPageTitle } from "@/components/app-shell/AppPageTitle";
|
||||
import { Suspense } from "react";
|
||||
import { ProjectOverview } from "@/components/project/ProjectOverview";
|
||||
|
||||
export default function MainPage() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<AppPageTitle title="KART" description="프로젝트 기본 구성이 완료되었습니다." />
|
||||
<div className="rounded-lg border bg-card p-6 text-card-foreground shadow-sm">
|
||||
<p className="font-medium">다음 작업</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">메뉴와 API 경로를 프로젝트 업무에 맞게 확장하세요.</p>
|
||||
</div>
|
||||
</div>
|
||||
<Suspense fallback={<p role="status">화면을 불러오는 중입니다.</p>}>
|
||||
<ProjectOverview />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
6
src/app/(pages)/External/[urlkey]/page.tsx
vendored
Normal file
6
src/app/(pages)/External/[urlkey]/page.tsx
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ExternalEntry } from "@/components/project/ExternalEntry";
|
||||
|
||||
export default async function ExternalPage({ params }: { params: Promise<{ urlkey: string }> }) {
|
||||
const { urlkey } = await params;
|
||||
return <ExternalEntry key={urlkey} urlKey={urlkey} />;
|
||||
}
|
||||
@@ -2,34 +2,38 @@
|
||||
|
||||
import Image from "next/image";
|
||||
import type React from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { apiError, NONE_HTTP_ERROR } from "@kri/common/http";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { useLoginMutation } from "@/query/auth";
|
||||
|
||||
const inputClassName =
|
||||
"h-9 w-[280px] rounded-[4px] border-kart-line bg-white px-[14px] py-1 text-sm font-light text-[#999] shadow-none md:text-sm";
|
||||
|
||||
export default function LoginPage() {
|
||||
const router = useRouter();
|
||||
const loginMutation = useLoginMutation();
|
||||
const passwordInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const [userId, setUserId] = useState("");
|
||||
const [userPw, setUserPw] = useState("");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const tryLogin = async () => {
|
||||
if (loginMutation.isPending) return;
|
||||
if (!userId.trim()) return window.alert("아이디를 입력해 주세요.");
|
||||
if (!userPw) return window.alert("비밀번호를 입력해 주세요.");
|
||||
|
||||
setError(null);
|
||||
try {
|
||||
await loginMutation.mutateAsync({ userId: userId.trim(), userPw });
|
||||
} catch (cause: unknown) {
|
||||
const errorInfo = apiError(cause, { fallbackMessage: "로그인에 실패했습니다." });
|
||||
if (errorInfo.status === 401 || errorInfo.status === 403) setError("아이디 또는 비밀번호를 다시 확인해 주세요.");
|
||||
else if (errorInfo.code === NONE_HTTP_ERROR) setError("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해 주세요.");
|
||||
else setError(`로그인에 실패했습니다. (${errorInfo.message})`);
|
||||
const errorInfo = apiError(cause, {
|
||||
fallbackMessage: "로그인에 실패했습니다.",
|
||||
});
|
||||
if (errorInfo.status === 401 || errorInfo.status === 403)
|
||||
window.alert("사용자 정보가 없습니다.");
|
||||
else if (errorInfo.code === NONE_HTTP_ERROR)
|
||||
window.alert("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해 주세요.");
|
||||
else window.alert(`로그인에 실패했습니다. (${errorInfo.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -37,45 +41,68 @@ export default function LoginPage() {
|
||||
if (loginMutation.isSuccess) router.replace("/");
|
||||
}, [loginMutation.isSuccess, router]);
|
||||
|
||||
const handleIdKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
passwordInputRef.current?.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const handlePasswordKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
void tryLogin();
|
||||
}
|
||||
// Legacy form: Enter in either field submits.
|
||||
const handleSubmit: React.FormEventHandler<HTMLFormElement> = (event) => {
|
||||
event.preventDefault();
|
||||
void tryLogin();
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen items-center justify-center bg-muted/40 p-4">
|
||||
<Card className="w-full max-w-md shadow-xl">
|
||||
<CardHeader className="pb-8">
|
||||
<div className="flex justify-center">
|
||||
<Image src="/logo.png" alt="로고" width={240} height={120} className="h-24 w-auto object-contain" priority />
|
||||
<main className="min-h-screen bg-white bg-[url(/images/kart/bg_login_1920.svg)] bg-cover bg-center bg-no-repeat text-kart-text max-[414px]:bg-kart-bg max-[414px]:bg-none">
|
||||
<div className="flex h-[calc(100vh-64px)] items-center justify-center px-[1.0416vw] max-[414px]:min-h-screen">
|
||||
<div className="h-[446px] w-full max-w-[602px] rounded-[15px] border-2 border-kart-line bg-white max-[414px]:border-0 max-[414px]:bg-kart-bg">
|
||||
<div className="-mx-[2px] -mt-[2px] flex h-[245px] flex-col items-center justify-center rounded-[15px] border-2 border-kart-line bg-kart-soft py-[70px] max-[414px]:border-0 max-[414px]:bg-kart-bg">
|
||||
<span className="mb-[30px] text-[25px] leading-5">Welcome!</span>
|
||||
<span className="mb-[30px] flex w-full justify-center">
|
||||
<Image
|
||||
src="/images/kart/logo_kart.svg"
|
||||
alt="KART"
|
||||
width={241}
|
||||
height={58}
|
||||
className="h-auto w-[40%]"
|
||||
unoptimized
|
||||
priority
|
||||
/>
|
||||
</span>
|
||||
<span className="text-[25px] leading-5 text-[#9e9e9e]">
|
||||
Kiwi Analysis Report Tool
|
||||
</span>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="userId" className="text-sm font-medium">ID</label>
|
||||
<Input id="userId" autoComplete="username" placeholder="아이디를 입력하세요" value={userId} onChange={(event) => setUserId(event.currentTarget.value)} onKeyDown={handleIdKeyDown} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="userPw" className="text-sm font-medium">Password</label>
|
||||
<Input ref={passwordInputRef} id="userPw" type="password" autoComplete="current-password" placeholder="비밀번호를 입력하세요" value={userPw} onChange={(event) => setUserPw(event.currentTarget.value)} onKeyDown={handlePasswordKeyDown} />
|
||||
</div>
|
||||
{error ? <p className="text-sm text-destructive">{error}</p> : null}
|
||||
<Button className="mt-6 h-11 w-full" disabled={loginMutation.isPending} onClick={() => void tryLogin()}>
|
||||
{loginMutation.isPending ? "로그인 중..." : "로그인"}
|
||||
</Button>
|
||||
<div className="py-5">
|
||||
<form
|
||||
className="flex flex-col items-center justify-center"
|
||||
onSubmit={handleSubmit}
|
||||
>
|
||||
<Input
|
||||
id="login_userid"
|
||||
aria-label="User ID"
|
||||
autoComplete="username"
|
||||
placeholder="User ID"
|
||||
className={inputClassName + " mb-2"}
|
||||
value={userId}
|
||||
onChange={(event) => setUserId(event.currentTarget.value)}
|
||||
/>
|
||||
<Input
|
||||
id="login_userpw"
|
||||
type="password"
|
||||
aria-label="User Password"
|
||||
autoComplete="current-password"
|
||||
placeholder="User Password"
|
||||
className={inputClassName}
|
||||
value={userPw}
|
||||
onChange={(event) => setUserPw(event.currentTarget.value)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
className="mt-5 h-9 w-[280px] rounded-[52px] bg-kart-green text-sm font-semibold text-white hover:bg-kart-green/90"
|
||||
disabled={loginMutation.isPending}
|
||||
>
|
||||
Login
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
80
src/app/api/bookmark/[[...slug]]/route.ts
Normal file
80
src/app/api/bookmark/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import {
|
||||
bookmarkUpstreamPath,
|
||||
isBookmarkCreatePath,
|
||||
isBookmarkItemPath,
|
||||
isBookmarkListPath,
|
||||
} from "@/lib/project-proxy-policy";
|
||||
import { isBookmarkPage, readBookmarkSaveRequest } from "@/types/bookmark";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
const notFound = () =>
|
||||
NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||
const unauthorized = () =>
|
||||
NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||
const badRequest = () =>
|
||||
NextResponse.json({ message: "북마크 저장 내용을 확인해 주세요." }, { status: 400 });
|
||||
const noStore = { headers: { "Cache-Control": "no-store" } };
|
||||
const loggedIn = async () => !!(await cookies()).get(CookieKeys.AuthToken)?.value;
|
||||
|
||||
export async function GET(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
const page = request.nextUrl.searchParams.get("page");
|
||||
if (!isBookmarkListPath(slug) || !isBookmarkPage(page)) return notFound();
|
||||
if (!(await loggedIn())) return unauthorized();
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.get<unknown>(bookmarkUpstreamPath(slug), {
|
||||
query: { page },
|
||||
cache: "no-store",
|
||||
});
|
||||
return NextResponse.json(result, noStore);
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
/** Create (`{type}/{pkey}`) or update (`{type}/{pkey}/{bookmarkId}`); both answer the id as text. */
|
||||
async function save(request: NextRequest, context: RouteContext, create: boolean) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!(create ? isBookmarkCreatePath(slug) : isBookmarkItemPath(slug))) return notFound();
|
||||
if (!(await loggedIn())) return unauthorized();
|
||||
let body;
|
||||
try {
|
||||
body = readBookmarkSaveRequest(await request.json(), create);
|
||||
} catch {
|
||||
return badRequest();
|
||||
}
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const path = bookmarkUpstreamPath(slug);
|
||||
const result = create
|
||||
? await serverApi.post<unknown>(path, body, { cache: "no-store" })
|
||||
: await serverApi.put<unknown>(path, body, { cache: "no-store" });
|
||||
if (typeof result !== "string" || result === "")
|
||||
return NextResponse.json({ message: "북마크 저장 응답을 확인해 주세요." }, { status: 502 });
|
||||
return NextResponse.json({ bookmarkId: result }, noStore);
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const POST = (request: NextRequest, context: RouteContext) => save(request, context, true);
|
||||
export const PUT = (request: NextRequest, context: RouteContext) => save(request, context, false);
|
||||
|
||||
export async function DELETE(_request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isBookmarkItemPath(slug)) return notFound();
|
||||
if (!(await loggedIn())) return unauthorized();
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.del<unknown>(bookmarkUpstreamPath(slug), { cache: "no-store" });
|
||||
return NextResponse.json(result === true, noStore);
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
86
src/app/api/derived/[[...slug]]/route.ts
Normal file
86
src/app/api/derived/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import {
|
||||
derivedUpstreamPath,
|
||||
isDerivedCreatePath,
|
||||
isDerivedItemPath,
|
||||
isDerivedListPath,
|
||||
} from "@/lib/project-proxy-policy";
|
||||
import { readDerivedSaveRequest } from "@/types/derived";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
const notFound = () =>
|
||||
NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||
const unauthorized = () =>
|
||||
NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||
const noStore = { headers: { "Cache-Control": "no-store" } };
|
||||
const loggedIn = async () => !!(await cookies()).get(CookieKeys.AuthToken)?.value;
|
||||
|
||||
export async function GET(_request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isDerivedListPath(slug)) return notFound();
|
||||
if (!(await loggedIn())) return unauthorized();
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.get<unknown>(derivedUpstreamPath(slug), {
|
||||
cache: "no-store",
|
||||
});
|
||||
return NextResponse.json(result, noStore);
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
// Saving recalculates every respondent on the server, so allow a long request.
|
||||
export const maxDuration = 660;
|
||||
|
||||
/** Create (`{type}/{pkey}`) or update (`{type}/{pkey}/{variableId}`); both answer the id as text. */
|
||||
async function save(request: NextRequest, context: RouteContext, create: boolean) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!(create ? isDerivedCreatePath(slug) : isDerivedItemPath(slug))) return notFound();
|
||||
if (!(await loggedIn())) return unauthorized();
|
||||
let body;
|
||||
try {
|
||||
body = readDerivedSaveRequest(await request.json());
|
||||
} catch {
|
||||
return NextResponse.json(
|
||||
{ message: "파생변수 저장 내용을 확인해 주세요." },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const path = derivedUpstreamPath(slug);
|
||||
const options = { cache: "no-store" as const, expectText: true, timeoutMs: 600_000 };
|
||||
const result = create
|
||||
? await serverApi.post<unknown>(path, body, options)
|
||||
: await serverApi.put<unknown>(path, body, options);
|
||||
if (typeof result !== "string" || result === "")
|
||||
return NextResponse.json(
|
||||
{ message: "파생변수 저장 응답을 확인해 주세요." },
|
||||
{ status: 502 },
|
||||
);
|
||||
return NextResponse.json({ variableId: result }, noStore);
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const POST = (request: NextRequest, context: RouteContext) => save(request, context, true);
|
||||
export const PUT = (request: NextRequest, context: RouteContext) => save(request, context, false);
|
||||
|
||||
export async function DELETE(_request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isDerivedItemPath(slug)) return notFound();
|
||||
if (!(await loggedIn())) return unauthorized();
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.del<unknown>(derivedUpstreamPath(slug), { cache: "no-store" });
|
||||
return NextResponse.json(result === true, noStore);
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
const apiPath = (slug: string[]) => `/example${slug.length ? `/${slug.map(encodeURIComponent).join("/")}` : ""}`;
|
||||
const toResponse = (result: unknown) => result === undefined ? new NextResponse(null, { status: 204 }) : NextResponse.json(result);
|
||||
|
||||
export async function GET(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const query = Object.fromEntries(request.nextUrl.searchParams.entries());
|
||||
const serverApi = await createServerApi();
|
||||
return toResponse(await serverApi.get<unknown>(apiPath(slug), { query }));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const contentType = request.headers.get("content-type") ?? "";
|
||||
if (contentType.includes("multipart/form-data")) {
|
||||
return toResponse(await serverApi.postForm<unknown>(apiPath(slug), await request.formData()));
|
||||
}
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.post<unknown>(apiPath(slug), body));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const contentType = request.headers.get("content-type") ?? "";
|
||||
if (contentType.includes("multipart/form-data")) {
|
||||
return toResponse(await serverApi.putForm<unknown>(apiPath(slug), await request.formData()));
|
||||
}
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.put<unknown>(apiPath(slug), body));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PATCH(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.patch<unknown>(apiPath(slug), body));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.del<unknown>(apiPath(slug), body === undefined ? undefined : { json: body }));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
// createHttpClient의 FormData 전용 메서드는 postForm과 putForm입니다.
|
||||
// PATCH/DELETE multipart가 필요하면 공용 HTTP Client 정책을 확인한 뒤 별도 구현하세요.
|
||||
74
src/app/api/export/[[...slug]]/route.ts
Normal file
74
src/app/api/export/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { exportTarget } from "@/lib/project-proxy-policy";
|
||||
import { readExcelRequest, readRawDataRequest } from "@/types/export";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
// Workbooks for large projects take a while to build on the server.
|
||||
export const maxDuration = 660;
|
||||
const TIMEOUT_MS = 600_000;
|
||||
|
||||
/**
|
||||
* File downloads: the server workbook is streamed through unchanged with its UTF-8
|
||||
* Content-Disposition. HTTP errors become JSON errors here, so they are never saved as a file.
|
||||
*/
|
||||
async function download(request: NextRequest, context: RouteContext, method: "GET" | "POST") {
|
||||
const { slug = [] } = await context.params;
|
||||
const target = exportTarget(method, slug);
|
||||
if (!target)
|
||||
return NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||
let body: unknown;
|
||||
if (target.body !== "none") {
|
||||
try {
|
||||
const json: unknown = await request.json();
|
||||
body = target.body === "excel" ? readExcelRequest(json) : readRawDataRequest(json);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
message:
|
||||
error instanceof Error && !(error instanceof SyntaxError)
|
||||
? error.message
|
||||
: "다운로드 요청을 확인해 주세요.",
|
||||
},
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
}
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const options = {
|
||||
signal: request.signal,
|
||||
timeoutMs: TIMEOUT_MS,
|
||||
idleTimeoutMs: TIMEOUT_MS,
|
||||
cache: "no-store" as const,
|
||||
};
|
||||
const upstream =
|
||||
method === "GET"
|
||||
? await serverApi.streamGet(target.path, options)
|
||||
: await serverApi.streamPost(target.path, body, options);
|
||||
const disposition = upstream.headers.get("content-disposition");
|
||||
if (!upstream.body || !disposition) {
|
||||
await upstream.body?.cancel();
|
||||
return NextResponse.json({ message: "다운로드 응답을 확인해 주세요." }, { status: 502 });
|
||||
}
|
||||
return new Response(upstream.body, {
|
||||
headers: {
|
||||
"Content-Type": upstream.headers.get("content-type") ?? "application/octet-stream",
|
||||
"Content-Disposition": disposition,
|
||||
"Cache-Control": "no-store",
|
||||
},
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const GET = (request: NextRequest, context: RouteContext) =>
|
||||
download(request, context, "GET");
|
||||
export const POST = (request: NextRequest, context: RouteContext) =>
|
||||
download(request, context, "POST");
|
||||
40
src/app/api/external/[urlkey]/login/route.ts
vendored
Normal file
40
src/app/api/external/[urlkey]/login/route.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { AUTH_COOKIE_MAX_AGE } from "@/const/common.const";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import { isRecord } from "@/types/kart";
|
||||
import { isExternalSession, isUrlKey } from "@/types/share";
|
||||
|
||||
export async function POST(_request: NextRequest, context: { params: Promise<{ urlkey: string }> }) {
|
||||
const { urlkey } = await context.params;
|
||||
let response: NextResponse;
|
||||
let token = "";
|
||||
try {
|
||||
if (!isUrlKey(urlkey)) {
|
||||
response = NextResponse.json({ message: "공유 링크를 찾을 수 없습니다." }, { status: 404 });
|
||||
} else {
|
||||
// Link login replaces the previous identity, including an expired credential cookie.
|
||||
const api = await createServerApi(false);
|
||||
const result = await api.post<unknown>(`/external/${urlkey}/login`, null, { cache: "no-store" });
|
||||
const accessToken = isRecord(result) ? result.accessToken : null;
|
||||
if (!isExternalSession(result) || result.link.urlKey !== urlkey ||
|
||||
typeof accessToken !== "string" || !accessToken) {
|
||||
response = NextResponse.json({ message: "공유 링크 로그인 응답을 확인해 주세요." }, { status: 502 });
|
||||
} else {
|
||||
token = accessToken;
|
||||
response = NextResponse.json({ user: result.user, link: result.link });
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const failure = errorToResponse(error);
|
||||
response = new NextResponse(failure.body, { status: failure.status, headers: failure.headers });
|
||||
}
|
||||
response.headers.set("Cache-Control", "no-store");
|
||||
response.cookies.set(CookieKeys.AuthToken, token, {
|
||||
httpOnly: true, secure: ["prod", "production"].includes(serverEnv.ENV),
|
||||
sameSite: "lax", path: "/", maxAge: token ? AUTH_COOKIE_MAX_AGE : 0,
|
||||
});
|
||||
return response;
|
||||
}
|
||||
43
src/app/api/import/[[...slug]]/route.ts
Normal file
43
src/app/api/import/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { isImportPath } from "@/lib/project-proxy-policy";
|
||||
import { readImportResult } from "@/types/export";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
// Imports replace project data on the server and may run for minutes.
|
||||
export const maxDuration = 660;
|
||||
|
||||
/** Multipart upload of one `file` part, re-sent with a FormData the fetch layer encodes. */
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isImportPath(slug))
|
||||
return NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||
let file: File;
|
||||
try {
|
||||
const part = (await request.formData()).get("file");
|
||||
if (!(part instanceof File) || part.size === 0) throw new Error();
|
||||
file = part;
|
||||
} catch {
|
||||
return NextResponse.json({ message: "파일을 선택해 주세요." }, { status: 400 });
|
||||
}
|
||||
try {
|
||||
const upload = new FormData();
|
||||
upload.append("file", file, file.name);
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.postForm<unknown>(
|
||||
"/project/" + slug.slice(0, 2).map(encodeURIComponent).join("/") + "/import/" + slug[2],
|
||||
upload,
|
||||
{ timeoutMs: 600_000, cache: "no-store" },
|
||||
);
|
||||
return NextResponse.json(readImportResult(result), {
|
||||
headers: { "Cache-Control": "no-store" },
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
53
src/app/api/log/visit/route.ts
Normal file
53
src/app/api/log/visit/route.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import { isProjectRef, isRecord } from "@/types/kart";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||
return NextResponse.json(
|
||||
{ message: "로그인이 필요합니다." },
|
||||
{ status: 401 },
|
||||
);
|
||||
try {
|
||||
const body: unknown = await request.json();
|
||||
if (
|
||||
!isRecord(body) ||
|
||||
typeof body.logContent !== "string" ||
|
||||
body.logContent.length > 4000 ||
|
||||
((body.projectType !== undefined || body.pkey !== undefined) &&
|
||||
!isProjectRef(body))
|
||||
) {
|
||||
return NextResponse.json(
|
||||
{ message: "방문 기록 요청을 확인해 주세요." },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.post<string>(
|
||||
"/log/visit",
|
||||
{
|
||||
logContent: body.logContent,
|
||||
...(body.projectType === undefined
|
||||
? {}
|
||||
: { projectType: body.projectType, pkey: body.pkey }),
|
||||
},
|
||||
{ expectText: true, cache: "no-store" },
|
||||
);
|
||||
return new NextResponse(result, {
|
||||
headers: {
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
"Cache-Control": "no-store",
|
||||
},
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SyntaxError)
|
||||
return NextResponse.json(
|
||||
{ message: "방문 기록 요청을 확인해 주세요." },
|
||||
{ status: 400 },
|
||||
);
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,67 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import type { LoginRequest, LoginUser } from "@kri/common";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { AUTH_COOKIE_MAX_AGE } from "@/const/common.const";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import { isLoginUser, isRecord } from "@/types/kart";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
type LoginResponse = { accessToken: string; user: LoginUser };
|
||||
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (slug.length)
|
||||
return NextResponse.json(
|
||||
{ message: "지원하지 않는 경로입니다." },
|
||||
{ status: 404 },
|
||||
);
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const body: unknown = await request.json();
|
||||
if (
|
||||
!isRecord(body) ||
|
||||
typeof body.userId !== "string" ||
|
||||
!body.userId.trim() ||
|
||||
typeof body.userPw !== "string" ||
|
||||
!body.userPw
|
||||
) {
|
||||
return NextResponse.json(
|
||||
{ message: "아이디와 비밀번호를 입력해 주세요." },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const serverApi = await createServerApi();
|
||||
const body = (await request.json()) as LoginRequest;
|
||||
const suffix = slug.length ? `/${slug.map(encodeURIComponent).join("/")}` : "";
|
||||
const result = await serverApi.post<LoginResponse>(`/auth/login${suffix}`, body);
|
||||
|
||||
const response = NextResponse.json(result.user, { status: 200 });
|
||||
const result = await serverApi.post<unknown>(
|
||||
"/auth/login",
|
||||
{ userId: body.userId.trim(), userPw: body.userPw },
|
||||
{ cache: "no-store" },
|
||||
);
|
||||
if (
|
||||
!isRecord(result) ||
|
||||
typeof result.accessToken !== "string" ||
|
||||
!result.accessToken ||
|
||||
!isLoginUser(result.user)
|
||||
) {
|
||||
return NextResponse.json(
|
||||
{ message: "로그인 응답을 확인해 주세요." },
|
||||
{ status: 502 },
|
||||
);
|
||||
}
|
||||
const response = NextResponse.json(result.user, {
|
||||
headers: { "Cache-Control": "no-store" },
|
||||
});
|
||||
response.cookies.set(CookieKeys.AuthToken, result.accessToken, {
|
||||
httpOnly: true,
|
||||
secure: serverEnv.ENV === "prod",
|
||||
secure: ["prod", "production"].includes(serverEnv.ENV),
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: AUTH_COOKIE_MAX_AGE,
|
||||
});
|
||||
return response;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof SyntaxError)
|
||||
return NextResponse.json(
|
||||
{ message: "로그인 요청을 확인해 주세요." },
|
||||
{ status: 400 },
|
||||
);
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { NextResponse } from "next/server";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
export async function POST(_request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const suffix = slug.length ? `/${slug.map(encodeURIComponent).join("/")}` : "";
|
||||
await serverApi.post<boolean>(`/auth/logout${suffix}`);
|
||||
|
||||
const response = NextResponse.json({ ok: true });
|
||||
response.cookies.set(CookieKeys.AuthToken, "", {
|
||||
httpOnly: true,
|
||||
secure: serverEnv.ENV === "prod",
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: 0,
|
||||
});
|
||||
return response;
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
/** Stateless backend authentication has no logout API; discard the frontend session cookie. */
|
||||
export async function POST() {
|
||||
const response = NextResponse.json(
|
||||
{ ok: true },
|
||||
{ headers: { "Cache-Control": "no-store" } },
|
||||
);
|
||||
response.cookies.set(CookieKeys.AuthToken, "", {
|
||||
httpOnly: true,
|
||||
secure: ["prod", "production"].includes(serverEnv.ENV),
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: 0,
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
106
src/app/api/project/[[...slug]]/route.ts
Normal file
106
src/app/api/project/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { readReportBatch } from "@/lib/report-contract";
|
||||
import {
|
||||
isProjectReadPath,
|
||||
projectReadQuery,
|
||||
isReportStreamPath,
|
||||
} from "@/lib/project-proxy-policy";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
export async function GET(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isProjectReadPath(slug))
|
||||
return NextResponse.json(
|
||||
{ message: "지원하지 않는 경로입니다." },
|
||||
{ status: 404 },
|
||||
);
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||
return NextResponse.json(
|
||||
{ message: "로그인이 필요합니다." },
|
||||
{ status: 401 },
|
||||
);
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.get<unknown>(
|
||||
"/project/" + slug.map(encodeURIComponent).join("/"),
|
||||
{
|
||||
query: projectReadQuery(slug, request.nextUrl.searchParams),
|
||||
cache: "no-store",
|
||||
},
|
||||
);
|
||||
return NextResponse.json(result, {
|
||||
headers: { "Cache-Control": "no-store" },
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const maxDuration = 660;
|
||||
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isReportStreamPath(slug))
|
||||
return NextResponse.json(
|
||||
{ message: "지원하지 않는 경로입니다." },
|
||||
{ status: 404 },
|
||||
);
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||
return NextResponse.json(
|
||||
{ message: "로그인이 필요합니다." },
|
||||
{ status: 401 },
|
||||
);
|
||||
let body;
|
||||
try {
|
||||
body = readReportBatch(await request.json());
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
message:
|
||||
error instanceof SyntaxError
|
||||
? "집계 요청을 확인해 주세요."
|
||||
: error instanceof Error
|
||||
? error.message
|
||||
: "집계 조건을 확인해 주세요.",
|
||||
},
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const upstream = await serverApi.streamPost(
|
||||
"/project/" + slug.map(encodeURIComponent).join("/"),
|
||||
body,
|
||||
{
|
||||
signal: request.signal,
|
||||
timeoutMs: 600_000,
|
||||
idleTimeoutMs: 600_000,
|
||||
headers: { Accept: "application/x-ndjson" },
|
||||
cache: "no-store",
|
||||
},
|
||||
);
|
||||
if (
|
||||
!upstream.body ||
|
||||
!upstream.headers.get("content-type")?.includes("application/x-ndjson")
|
||||
) {
|
||||
await upstream.body?.cancel();
|
||||
return NextResponse.json(
|
||||
{ message: "집계 스트림 응답을 확인해 주세요." },
|
||||
{ status: 502 },
|
||||
);
|
||||
}
|
||||
return new Response(upstream.body, {
|
||||
headers: {
|
||||
"Content-Type": "application/x-ndjson; charset=utf-8",
|
||||
"Cache-Control": "no-store",
|
||||
"X-Accel-Buffering": "no",
|
||||
},
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
52
src/app/api/quota/[[...slug]]/route.ts
Normal file
52
src/app/api/quota/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { isQuotaListPath, isQuotaResultPath } from "@/lib/project-proxy-policy";
|
||||
import { readQuotaRequest } from "@/types/quota";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
const notFound = () =>
|
||||
NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||
const unauthorized = () =>
|
||||
NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||
|
||||
export async function GET(_request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isQuotaListPath(slug)) return notFound();
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value) return unauthorized();
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.get<unknown>(
|
||||
"/quota/" + slug.map(encodeURIComponent).join("/"),
|
||||
{ cache: "no-store" },
|
||||
);
|
||||
return NextResponse.json(result, { headers: { "Cache-Control": "no-store" } });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
const { slug = [] } = await context.params;
|
||||
if (!isQuotaResultPath(slug)) return notFound();
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value) return unauthorized();
|
||||
let body;
|
||||
try {
|
||||
body = readQuotaRequest(await request.json());
|
||||
} catch {
|
||||
return NextResponse.json({ message: "쿼터 조회 조건을 확인해 주세요." }, { status: 400 });
|
||||
}
|
||||
try {
|
||||
const serverApi = await createServerApi();
|
||||
const result = await serverApi.post<unknown>(
|
||||
"/quota/" + slug.map(encodeURIComponent).join("/"),
|
||||
body,
|
||||
{ cache: "no-store" },
|
||||
);
|
||||
return NextResponse.json(result, { headers: { "Cache-Control": "no-store" } });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
31
src/app/api/share/[projectType]/[pkey]/route.ts
Normal file
31
src/app/api/share/[projectType]/[pkey]/route.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import { isProjectRef, isRecord } from "@/types/kart";
|
||||
import { isShareLink } from "@/types/share";
|
||||
|
||||
export async function POST(request: NextRequest, context: {
|
||||
params: Promise<{ projectType: string; pkey: string }>;
|
||||
}) {
|
||||
const params = await context.params;
|
||||
const project = { projectType: params.projectType === "0" ? 0 : params.projectType === "1" ? 1 : null, pkey: params.pkey };
|
||||
if (!isProjectRef(project)) return NextResponse.json({ message: "프로젝트를 확인해 주세요." }, { status: 400 });
|
||||
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||
let body: unknown;
|
||||
try { body = await request.json(); } catch { body = null; }
|
||||
if (!isRecord(body) || typeof body.realUrl !== "string" || !body.realUrl.startsWith("/") ||
|
||||
body.realUrl.length > 4096 || (body.mode !== "P" && body.mode !== "U"))
|
||||
return NextResponse.json({ message: "공유 링크 요청을 확인해 주세요." }, { status: 400 });
|
||||
try {
|
||||
const api = await createServerApi();
|
||||
const link = await api.post<unknown>(`/project/${project.projectType}/${encodeURIComponent(project.pkey)}/share`,
|
||||
{ realUrl: body.realUrl, mode: body.mode }, { cache: "no-store" });
|
||||
if (!isShareLink(link) || link.projectType !== project.projectType || link.pkey !== project.pkey ||
|
||||
link.pageOnly !== (body.mode === "P"))
|
||||
return NextResponse.json({ message: "공유 링크 응답을 확인해 주세요." }, { status: 502 });
|
||||
return NextResponse.json(link, { headers: { "Cache-Control": "no-store" } });
|
||||
} catch (error) { return errorToResponse(error); }
|
||||
}
|
||||
995
src/app/fonts.css
Normal file
995
src/app/fonts.css
Normal file
@@ -0,0 +1,995 @@
|
||||
/* Self-hosted Noto Sans / Noto Sans KR (SIL OFL 1.1; license files under public/fonts). */
|
||||
@font-face {
|
||||
font-family: 'Noto Sans';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-stretch: 100%;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans/latin-ext.woff2") format('woff2');
|
||||
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-stretch: 100%;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans/latin.woff2") format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-000.woff2") format('woff2');
|
||||
unicode-range: U+f9ca-fa0b, U+ff03-ff05, U+ff07, U+ff0a-ff0b, U+ff0d-ff19, U+ff1b, U+ff1d, U+ff20-ff5b, U+ff5d, U+ffe0-ffe3, U+ffe5-ffe6;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-001.woff2") format('woff2');
|
||||
unicode-range: U+f92f-f980, U+f982-f9c9;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-002.woff2") format('woff2');
|
||||
unicode-range: U+d723-d728, U+d72a-d733, U+d735-d748, U+d74a-d74f, U+d752-d753, U+d755-d757, U+d75a-d75f, U+d762-d764, U+d766-d768, U+d76a-d76b, U+d76d-d76f, U+d771-d787, U+d789-d78b, U+d78d-d78f, U+d791-d797, U+d79a, U+d79c, U+d79e-d7a3, U+f900-f909, U+f90b-f92e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-003.woff2") format('woff2');
|
||||
unicode-range: U+d679-d68b, U+d68e-d69e, U+d6a0, U+d6a2-d6a7, U+d6a9-d6c3, U+d6c6-d6c7, U+d6c9-d6cb, U+d6cd-d6d3, U+d6d5-d6d6, U+d6d8-d6e3, U+d6e5-d6e7, U+d6e9-d6fb, U+d6fd-d717, U+d719-d71f, U+d721-d722;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-004.woff2") format('woff2');
|
||||
unicode-range: U+d5bc-d5c7, U+d5ca-d5cb, U+d5cd-d5cf, U+d5d1-d5d7, U+d5d9-d5da, U+d5dc, U+d5de-d5e3, U+d5e6-d5e7, U+d5e9-d5eb, U+d5ed-d5f6, U+d5f8, U+d5fa-d5ff, U+d602-d603, U+d605-d607, U+d609-d60f, U+d612-d613, U+d616-d61b, U+d61d-d637, U+d63a-d63b, U+d63d-d63f, U+d641-d647, U+d64a-d64c, U+d64e-d653, U+d656-d657, U+d659-d65b, U+d65d-d666, U+d668, U+d66a-d678;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-005.woff2") format('woff2');
|
||||
unicode-range: U+d507, U+d509-d50b, U+d50d-d513, U+d515-d53b, U+d53e-d53f, U+d541-d543, U+d545-d54c, U+d54e, U+d550, U+d552-d557, U+d55a-d55b, U+d55d-d55f, U+d561-d564, U+d566-d567, U+d56a, U+d56c, U+d56e-d573, U+d576-d577, U+d579-d583, U+d585-d586, U+d58a-d5a4, U+d5a6-d5bb;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-006.woff2") format('woff2');
|
||||
unicode-range: U+d464-d477, U+d47a-d47b, U+d47d-d47f, U+d481-d487, U+d489-d48a, U+d48c, U+d48e-d4e7, U+d4e9-d503, U+d505-d506;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-007.woff2") format('woff2');
|
||||
unicode-range: U+d3bf-d3c7, U+d3ca-d3cf, U+d3d1-d3eb, U+d3ee-d3ef, U+d3f1-d3f3, U+d3f5-d3fb, U+d3fd-d400, U+d402-d45b, U+d45d-d463;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-008.woff2") format('woff2');
|
||||
unicode-range: U+d2ff, U+d302-d304, U+d306-d30b, U+d30f, U+d311-d313, U+d315-d31b, U+d31e, U+d322-d324, U+d326-d327, U+d32a-d32b, U+d32d-d32f, U+d331-d337, U+d339-d33c, U+d33e-d37b, U+d37e-d37f, U+d381-d383, U+d385-d38b, U+d38e-d390, U+d392-d397, U+d39a-d39b, U+d39d-d39f, U+d3a1-d3a7, U+d3a9-d3aa, U+d3ac, U+d3ae-d3b3, U+d3b5-d3b7, U+d3b9-d3bb, U+d3bd-d3be;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-009.woff2") format('woff2');
|
||||
unicode-range: U+d257-d27f, U+d281-d29b, U+d29d-d29f, U+d2a1-d2ab, U+d2ad-d2b7, U+d2ba-d2bb, U+d2bd-d2bf, U+d2c1-d2c7, U+d2c9-d2ef, U+d2f2-d2f3, U+d2f5-d2f7, U+d2f9-d2fe;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-010.woff2") format('woff2');
|
||||
unicode-range: U+d1b4, U+d1b6-d1f3, U+d1f5-d22b, U+d22e-d22f, U+d231-d233, U+d235-d23b, U+d23d-d240, U+d242-d256;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-011.woff2") format('woff2');
|
||||
unicode-range: U+d105-d12f, U+d132-d133, U+d135-d137, U+d139-d13f, U+d141-d142, U+d144, U+d146-d14b, U+d14e-d14f, U+d151-d153, U+d155-d15b, U+d15e-d187, U+d189-d19f, U+d1a2-d1a3, U+d1a5-d1a7, U+d1a9-d1af, U+d1b2-d1b3;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-012.woff2") format('woff2');
|
||||
unicode-range: U+d04b-d04f, U+d051-d057, U+d059-d06b, U+d06d-d06f, U+d071-d073, U+d075-d07b, U+d07e-d0a3, U+d0a6-d0a7, U+d0a9-d0ab, U+d0ad-d0b3, U+d0b6, U+d0b8, U+d0ba-d0bf, U+d0c2-d0c3, U+d0c5-d0c7, U+d0c9-d0cf, U+d0d2, U+d0d6-d0db, U+d0de-d0df, U+d0e1-d0e3, U+d0e5-d0eb, U+d0ee-d0f0, U+d0f2-d104;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-013.woff2") format('woff2');
|
||||
unicode-range: U+cfa2-cfc3, U+cfc5-cfdf, U+cfe2-cfe3, U+cfe5-cfe7, U+cfe9-cff4, U+cff6-cffb, U+cffd-cfff, U+d001-d003, U+d005-d017, U+d019-d033, U+d036-d037, U+d039-d03b, U+d03d-d04a;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-014.woff2") format('woff2');
|
||||
unicode-range: U+cef0-cef3, U+cef6, U+cef9-ceff, U+cf01-cf03, U+cf05-cf07, U+cf09-cf0f, U+cf11-cf12, U+cf14-cf1b, U+cf1d-cf1f, U+cf21-cf2f, U+cf31-cf53, U+cf56-cf57, U+cf59-cf5b, U+cf5d-cf63, U+cf66, U+cf68, U+cf6a-cf6f, U+cf71-cf84, U+cf86-cf8b, U+cf8d-cfa1;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-015.woff2") format('woff2');
|
||||
unicode-range: U+ce3c-ce57, U+ce5a-ce5b, U+ce5d-ce5f, U+ce61-ce67, U+ce6a, U+ce6c, U+ce6e-ce73, U+ce76-ce77, U+ce79-ce7b, U+ce7d-ce83, U+ce85-ce88, U+ce8a-ce8f, U+ce91-ce93, U+ce95-ce97, U+ce99-ce9f, U+cea2, U+cea4-ceab, U+cead-cee3, U+cee6-cee7, U+cee9-ceeb, U+ceed-ceef;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-016.woff2") format('woff2');
|
||||
unicode-range: U+cd92-cd93, U+cd96-cd97, U+cd99-cd9b, U+cd9d-cda3, U+cda6-cda8, U+cdaa-cdaf, U+cdb1-cdc3, U+cdc5-cdcb, U+cdcd-cde7, U+cde9-ce03, U+ce05-ce1f, U+ce22-ce34, U+ce36-ce3b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-017.woff2") format('woff2');
|
||||
unicode-range: U+ccef-cd07, U+cd0a-cd0b, U+cd0d-cd1a, U+cd1c, U+cd1e-cd2b, U+cd2d-cd5b, U+cd5d-cd77, U+cd79-cd91;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-018.woff2") format('woff2');
|
||||
unicode-range: U+cc3f-cc43, U+cc46-cc47, U+cc49-cc4b, U+cc4d-cc53, U+cc55-cc58, U+cc5a-cc5f, U+cc61-cc97, U+cc9a-cc9b, U+cc9d-cc9f, U+cca1-cca7, U+ccaa, U+ccac, U+ccae-ccb3, U+ccb6-ccb7, U+ccb9-ccbb, U+ccbd-cccf, U+ccd1-cce3, U+cce5-ccee;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-019.woff2") format('woff2');
|
||||
unicode-range: U+cb91-cbd3, U+cbd5-cbe3, U+cbe5-cc0b, U+cc0e-cc0f, U+cc11-cc13, U+cc15-cc1b, U+cc1d-cc20, U+cc23-cc27, U+cc2a-cc2b, U+cc2d, U+cc2f, U+cc31-cc37, U+cc3a, U+cc3c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-020.woff2") format('woff2');
|
||||
unicode-range: U+caf4-cb47, U+cb4a-cb90;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-021.woff2") format('woff2');
|
||||
unicode-range: U+ca4a-ca4b, U+ca4e-ca4f, U+ca51-ca53, U+ca55-ca5b, U+ca5d-ca60, U+ca62-ca83, U+ca85-cabb, U+cabe-cabf, U+cac1-cac3, U+cac5-cacb, U+cacd-cad0, U+cad2, U+cad4-cad8, U+cada-caf3;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-022.woff2") format('woff2');
|
||||
unicode-range: U+c996-c997, U+c99a-c99c, U+c99e-c9bf, U+c9c2-c9c3, U+c9c5-c9c7, U+c9c9-c9cf, U+c9d2, U+c9d4, U+c9d7-c9d8, U+c9db, U+c9de-c9df, U+c9e1-c9e3, U+c9e5-c9e6, U+c9e8-c9eb, U+c9ee-c9f0, U+c9f2-c9f7, U+c9f9-ca0b, U+ca0d-ca28, U+ca2a-ca49;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-023.woff2") format('woff2');
|
||||
unicode-range: U+c8e9-c8f4, U+c8f6-c8fb, U+c8fe-c8ff, U+c901-c903, U+c905-c90b, U+c90e-c910, U+c912-c917, U+c919-c92b, U+c92d-c94f, U+c951-c953, U+c955-c96b, U+c96d-c973, U+c975-c987, U+c98a-c98b, U+c98d-c98f, U+c991-c995;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-024.woff2") format('woff2');
|
||||
unicode-range: U+c841-c84b, U+c84d-c86f, U+c872-c873, U+c875-c877, U+c879-c87f, U+c882-c884, U+c887-c88a, U+c88d-c8c3, U+c8c5-c8df, U+c8e1-c8e8;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-025.woff2") format('woff2');
|
||||
unicode-range: U+c779-c77b, U+c77e-c782, U+c786, U+c78b, U+c78d, U+c78f, U+c792-c793, U+c795, U+c797, U+c799-c79f, U+c7a2, U+c7a7-c7ab, U+c7ae-c7bb, U+c7bd-c7c0, U+c7c2-c7c7, U+c7c9-c7dc, U+c7de-c7ff, U+c802-c803, U+c805-c807, U+c809, U+c80b-c80f, U+c812, U+c814, U+c817-c81b, U+c81e-c81f, U+c821-c823, U+c825-c82e, U+c830-c837, U+c839-c83b, U+c83d-c840;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-026.woff2") format('woff2');
|
||||
unicode-range: U+c6bb-c6bf, U+c6c2, U+c6c4, U+c6c6-c6cb, U+c6ce-c6cf, U+c6d1-c6d3, U+c6d5-c6db, U+c6dd-c6df, U+c6e1-c6e7, U+c6e9-c6eb, U+c6ed-c6ef, U+c6f1-c6f8, U+c6fa-c703, U+c705-c707, U+c709-c70b, U+c70d-c716, U+c718, U+c71a-c71f, U+c722-c723, U+c725-c727, U+c729-c734, U+c736-c73b, U+c73e-c73f, U+c741-c743, U+c745-c74b, U+c74e-c750, U+c752-c757, U+c759-c773, U+c776-c777;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-027.woff2") format('woff2');
|
||||
unicode-range: U+c5f5-c5fb, U+c5fe, U+c602-c605, U+c607, U+c609-c60f, U+c611-c61a, U+c61c-c623, U+c626-c627, U+c629-c62b, U+c62d, U+c62f-c632, U+c636, U+c638, U+c63a-c63f, U+c642-c643, U+c645-c647, U+c649-c652, U+c656-c65b, U+c65d-c65f, U+c661-c663, U+c665-c677, U+c679-c67b, U+c67d-c693, U+c696-c697, U+c699-c69b, U+c69d-c6a3, U+c6a6, U+c6a8, U+c6aa-c6af, U+c6b2-c6b3, U+c6b5-c6b7, U+c6b9-c6ba;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-028.woff2") format('woff2');
|
||||
unicode-range: U+c517-c527, U+c52a-c52b, U+c52d-c52f, U+c531-c538, U+c53a, U+c53c, U+c53e-c543, U+c546-c547, U+c54b, U+c54d-c552, U+c556, U+c55a-c55b, U+c55d, U+c55f, U+c562-c563, U+c565-c567, U+c569-c56f, U+c572, U+c574, U+c576-c57b, U+c57e-c57f, U+c581-c583, U+c585-c586, U+c588-c58b, U+c58e, U+c590, U+c592-c596, U+c599-c5b3, U+c5b6-c5b7, U+c5ba, U+c5be-c5c3, U+c5ca-c5cb, U+c5cd, U+c5cf, U+c5d2-c5d3, U+c5d5-c5d7, U+c5d9-c5df, U+c5e1-c5e2, U+c5e4, U+c5e6-c5eb, U+c5ef, U+c5f1-c5f3;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-029.woff2") format('woff2');
|
||||
unicode-range: U+c475-c4ef, U+c4f2-c4f3, U+c4f5-c4f7, U+c4f9-c4ff, U+c502-c50b, U+c50d-c516;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-030.woff2") format('woff2');
|
||||
unicode-range: U+c3d0-c3d7, U+c3da-c3db, U+c3dd-c3de, U+c3e1-c3ec, U+c3ee-c3f3, U+c3f5-c42b, U+c42d-c463, U+c466-c474;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-031.woff2") format('woff2');
|
||||
unicode-range: U+c32b-c367, U+c36a-c36b, U+c36d-c36f, U+c371-c377, U+c37a-c37b, U+c37e-c383, U+c385-c387, U+c389-c3cf;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-032.woff2") format('woff2');
|
||||
unicode-range: U+c26a-c26b, U+c26d-c26f, U+c271-c273, U+c275-c27b, U+c27e-c287, U+c289-c28f, U+c291-c297, U+c299-c29a, U+c29c-c2a3, U+c2a5-c2a7, U+c2a9-c2ab, U+c2ad-c2b3, U+c2b6, U+c2b8, U+c2ba-c2bb, U+c2bd-c2db, U+c2de-c2df, U+c2e1-c2e2, U+c2e5-c2ea, U+c2ee, U+c2f0, U+c2f2-c2f5, U+c2f7, U+c2fa-c2fb, U+c2fd-c2ff, U+c301-c307, U+c309-c30c, U+c30e-c312, U+c315-c323, U+c325-c328, U+c32a;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-033.woff2") format('woff2');
|
||||
unicode-range: U+c1bc-c1c3, U+c1c5-c1df, U+c1e1-c1fb, U+c1fd-c203, U+c205-c20c, U+c20e, U+c210-c217, U+c21a-c21b, U+c21d-c21e, U+c221-c227, U+c229-c22a, U+c22c, U+c22e, U+c230, U+c233-c24f, U+c251-c257, U+c259-c269;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-034.woff2") format('woff2');
|
||||
unicode-range: U+c101-c11b, U+c11f, U+c121-c123, U+c125-c12b, U+c12e, U+c132-c137, U+c13a-c13b, U+c13d-c13f, U+c141-c147, U+c14a, U+c14c-c153, U+c155-c157, U+c159-c15b, U+c15d-c166, U+c169-c16f, U+c171-c177, U+c179-c18b, U+c18e-c18f, U+c191-c193, U+c195-c19b, U+c19d-c19e, U+c1a0, U+c1a2-c1a4, U+c1a6-c1bb;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-035.woff2") format('woff2');
|
||||
unicode-range: U+c049-c057, U+c059-c05b, U+c05d-c05f, U+c061-c067, U+c069-c08f, U+c091-c0ab, U+c0ae-c0af, U+c0b1-c0b3, U+c0b5, U+c0b7-c0bb, U+c0be, U+c0c2-c0c7, U+c0ca-c0cb, U+c0cd-c0cf, U+c0d1-c0d7, U+c0d9-c0da, U+c0dc, U+c0de-c0e3, U+c0e5-c0eb, U+c0ed-c0f3, U+c0f6, U+c0f8, U+c0fa-c0ff;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-036.woff2") format('woff2');
|
||||
unicode-range: U+bfa7-bfaf, U+bfb1-bfc4, U+bfc6-bfcb, U+bfce-bfcf, U+bfd1-bfd3, U+bfd5-bfdb, U+bfdd-c048;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-037.woff2") format('woff2');
|
||||
unicode-range: U+bf07, U+bf09-bf3f, U+bf41-bf4f, U+bf52-bf54, U+bf56-bfa6;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-038.woff2") format('woff2');
|
||||
unicode-range: U+be56, U+be58, U+be5c-be5f, U+be62-be63, U+be65-be67, U+be69-be74, U+be76-be7b, U+be7e-be7f, U+be81-be8e, U+be90, U+be92-bea7, U+bea9-becf, U+bed2-bed3, U+bed5-bed6, U+bed9-bee3, U+bee6-bf06;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-039.woff2") format('woff2');
|
||||
unicode-range: U+bdb0-bdd3, U+bdd5-bdef, U+bdf1-be0b, U+be0d-be0f, U+be11-be13, U+be15-be43, U+be46-be47, U+be49-be4b, U+be4d-be53;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-040.woff2") format('woff2');
|
||||
unicode-range: U+bd03, U+bd06, U+bd08, U+bd0a-bd0f, U+bd11-bd22, U+bd25-bd47, U+bd49-bd58, U+bd5a-bd7f, U+bd82-bd83, U+bd85-bd87, U+bd8a-bd8f, U+bd91-bd92, U+bd94, U+bd96-bd98, U+bd9a-bdaf;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-041.woff2") format('woff2');
|
||||
unicode-range: U+bc4e-bc83, U+bc86-bc87, U+bc89-bc8b, U+bc8d-bc93, U+bc96, U+bc98, U+bc9b-bc9f, U+bca2-bca3, U+bca5-bca7, U+bca9-bcb2, U+bcb4-bcbb, U+bcbe-bcbf, U+bcc1-bcc3, U+bcc5-bccc, U+bcce-bcd0, U+bcd2-bcd4, U+bcd6-bcf3, U+bcf7, U+bcf9-bcfb, U+bcfd-bd02;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-042.woff2") format('woff2');
|
||||
unicode-range: U+bb90-bba3, U+bba5-bbab, U+bbad-bbbf, U+bbc1-bbf7, U+bbfa-bbfb, U+bbfd-bbfe, U+bc01-bc07, U+bc09-bc0a, U+bc0e, U+bc10, U+bc12-bc13, U+bc17, U+bc19-bc1a, U+bc1e, U+bc20-bc23, U+bc26, U+bc28, U+bc2a-bc2c, U+bc2e-bc2f, U+bc32-bc33, U+bc35-bc37, U+bc39-bc3f, U+bc41-bc42, U+bc44, U+bc46-bc48, U+bc4a-bc4d;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-043.woff2") format('woff2');
|
||||
unicode-range: U+bae6-bafb, U+bafd-bb17, U+bb19-bb33, U+bb37, U+bb39-bb3a, U+bb3d-bb43, U+bb45-bb46, U+bb48, U+bb4a-bb4f, U+bb51-bb53, U+bb55-bb57, U+bb59-bb62, U+bb64-bb8f;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-044.woff2") format('woff2');
|
||||
unicode-range: U+ba30-ba37, U+ba3a-ba3b, U+ba3d-ba3f, U+ba41-ba47, U+ba49-ba4a, U+ba4c, U+ba4e-ba53, U+ba56-ba57, U+ba59-ba5b, U+ba5d-ba63, U+ba65-ba66, U+ba68-ba6f, U+ba71-ba73, U+ba75-ba77, U+ba79-ba84, U+ba86, U+ba88-baa7, U+baaa, U+baad-baaf, U+bab1-bab7, U+baba, U+babc, U+babe-bae5;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-045.woff2") format('woff2');
|
||||
unicode-range: U+b96e-b973, U+b976-b977, U+b979-b97b, U+b97d-b983, U+b986, U+b988, U+b98a-b98d, U+b98f-b9ab, U+b9ae-b9af, U+b9b1-b9b3, U+b9b5-b9bb, U+b9be, U+b9c0, U+b9c2-b9c7, U+b9ca-b9cb, U+b9cd, U+b9d2-b9d7, U+b9da, U+b9dc, U+b9df-b9e0, U+b9e2, U+b9e6-b9e7, U+b9e9-b9f3, U+b9f6, U+b9f8, U+b9fb-ba2f;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-046.woff2") format('woff2');
|
||||
unicode-range: U+b8bf-b8cb, U+b8cd-b8e0, U+b8e2-b8e7, U+b8ea-b8eb, U+b8ed-b8ef, U+b8f1-b8f7, U+b8fa, U+b8fc, U+b8fe-b903, U+b905-b917, U+b919-b91f, U+b921-b93b, U+b93d-b957, U+b95a-b95b, U+b95d-b95f, U+b961-b967, U+b969-b96c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-047.woff2") format('woff2');
|
||||
unicode-range: U+b80d-b80f, U+b811-b817, U+b81a, U+b81c-b823, U+b826-b827, U+b829-b82b, U+b82d-b833, U+b836, U+b83a-b83f, U+b841-b85b, U+b85e-b85f, U+b861-b863, U+b865-b86b, U+b86e, U+b870, U+b872-b8af, U+b8b1-b8be;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-048.woff2") format('woff2');
|
||||
unicode-range: U+b74d-b75f, U+b761-b763, U+b765-b774, U+b776-b77b, U+b77e-b77f, U+b781-b783, U+b785-b78b, U+b78e, U+b792-b796, U+b79a-b79b, U+b79d-b7a7, U+b7aa, U+b7ae-b7b3, U+b7b6-b7c8, U+b7ca-b7eb, U+b7ee-b7ef, U+b7f1-b7f3, U+b7f5-b7fb, U+b7fe, U+b802-b806, U+b80a-b80b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-049.woff2") format('woff2');
|
||||
unicode-range: U+b6a7-b6aa, U+b6ac-b6b0, U+b6b2-b6ef, U+b6f1-b727, U+b72a-b72b, U+b72d-b72e, U+b731-b737, U+b739-b73a, U+b73c-b743, U+b745-b74c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-050.woff2") format('woff2');
|
||||
unicode-range: U+b605-b60f, U+b612-b617, U+b619-b624, U+b626-b69b, U+b69e-b6a3, U+b6a5-b6a6;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-051.woff2") format('woff2');
|
||||
unicode-range: U+b55f, U+b562-b583, U+b585-b59f, U+b5a2-b5a3, U+b5a5-b5a7, U+b5a9-b5b2, U+b5b5-b5ba, U+b5bd-b604;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-052.woff2") format('woff2');
|
||||
unicode-range: U+b4a5-b4b6, U+b4b8-b4bf, U+b4c1-b4c7, U+b4c9-b4db, U+b4de-b4df, U+b4e1-b4e2, U+b4e5-b4eb, U+b4ee, U+b4f0, U+b4f2-b513, U+b516-b517, U+b519-b51a, U+b51d-b523, U+b526, U+b528, U+b52b-b52f, U+b532-b533, U+b535-b537, U+b539-b53f, U+b541-b544, U+b546-b54b, U+b54d-b54f, U+b551-b55b, U+b55d-b55e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-053.woff2") format('woff2');
|
||||
unicode-range: U+b3f8-b3fb, U+b3fd-b40f, U+b411-b417, U+b419-b41b, U+b41d-b41f, U+b421-b427, U+b42a-b42b, U+b42d-b44f, U+b452-b453, U+b455-b457, U+b459-b45f, U+b462-b464, U+b466-b46b, U+b46d-b47f, U+b481-b4a3;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-054.woff2") format('woff2');
|
||||
unicode-range: U+b342-b353, U+b356-b357, U+b359-b35b, U+b35d-b35e, U+b360-b363, U+b366, U+b368, U+b36a-b36d, U+b36f, U+b372-b373, U+b375-b377, U+b379-b37f, U+b381-b382, U+b384, U+b386-b38b, U+b38d-b3c3, U+b3c6-b3c7, U+b3c9-b3ca, U+b3cd-b3d3, U+b3d6, U+b3d8, U+b3da-b3f7;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-055.woff2") format('woff2');
|
||||
unicode-range: U+b27c-b283, U+b285-b28f, U+b292-b293, U+b295-b297, U+b29a-b29f, U+b2a1-b2a4, U+b2a7-b2a9, U+b2ab, U+b2ad-b2c7, U+b2ca-b2cb, U+b2cd-b2cf, U+b2d1-b2d7, U+b2da, U+b2dc, U+b2de-b2e3, U+b2e7, U+b2e9-b2ea, U+b2ef-b2f3, U+b2f6, U+b2f8, U+b2fa-b2fb, U+b2fd-b2fe, U+b302-b303, U+b305-b307, U+b309-b30f, U+b312, U+b316-b31b, U+b31d-b341;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-056.woff2") format('woff2');
|
||||
unicode-range: U+b1d6-b1e7, U+b1e9-b1fc, U+b1fe-b203, U+b206-b207, U+b209-b20b, U+b20d-b213, U+b216-b21f, U+b221-b257, U+b259-b273, U+b275-b27b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-057.woff2") format('woff2');
|
||||
unicode-range: U+b120-b122, U+b126-b127, U+b129-b12b, U+b12d-b133, U+b136, U+b138, U+b13a-b13f, U+b142-b143, U+b145-b14f, U+b151-b153, U+b156-b157, U+b159-b177, U+b17a-b17b, U+b17d-b17f, U+b181-b187, U+b189-b18c, U+b18e-b191, U+b195-b1a7, U+b1a9-b1cb, U+b1cd-b1d5;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-058.woff2") format('woff2');
|
||||
unicode-range: U+b05f-b07b, U+b07e-b07f, U+b081-b083, U+b085-b08b, U+b08d-b097, U+b09b, U+b09d-b09f, U+b0a2-b0a7, U+b0aa, U+b0b0, U+b0b2, U+b0b6-b0b7, U+b0b9-b0bb, U+b0bd-b0c3, U+b0c6-b0c7, U+b0ca-b0cf, U+b0d1-b0df, U+b0e1-b0e4, U+b0e6-b107, U+b10a-b10b, U+b10d-b10f, U+b111-b112, U+b114-b117, U+b119-b11a, U+b11c-b11f;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-059.woff2") format('woff2');
|
||||
unicode-range: U+afac-afb7, U+afba-afbb, U+afbd-afbf, U+afc1-afc6, U+afca-afcc, U+afce-afd3, U+afd5-afe7, U+afe9-afef, U+aff1-b00b, U+b00d-b00f, U+b011-b013, U+b015-b01b, U+b01d-b027, U+b029-b043, U+b045-b047, U+b049, U+b04b, U+b04d-b052, U+b055-b056, U+b058-b05c, U+b05e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-060.woff2") format('woff2');
|
||||
unicode-range: U+af03-af07, U+af09-af2b, U+af2e-af33, U+af35-af3b, U+af3e-af40, U+af44-af47, U+af4a-af5c, U+af5e-af63, U+af65-af7f, U+af81-afab;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-061.woff2") format('woff2');
|
||||
unicode-range: U+ae56-ae5b, U+ae5e-ae60, U+ae62-ae64, U+ae66-ae67, U+ae69-ae6b, U+ae6d-ae83, U+ae85-aebb, U+aebf, U+aec1-aec3, U+aec5-aecb, U+aece, U+aed0, U+aed2-aed7, U+aed9-aef3, U+aef5-af02;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-062.woff2") format('woff2');
|
||||
unicode-range: U+ad9c-ada3, U+ada5-adbf, U+adc1-adc3, U+adc5-adc7, U+adc9-add2, U+add4-addb, U+addd-addf, U+ade1-ade3, U+ade5-adf7, U+adfa-adfb, U+adfd-adff, U+ae02-ae07, U+ae0a, U+ae0c, U+ae0e-ae13, U+ae15-ae2f, U+ae31-ae33, U+ae35-ae37, U+ae39-ae3f, U+ae42, U+ae44, U+ae46-ae49, U+ae4b, U+ae4f, U+ae51-ae53, U+ae55;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-063.woff2") format('woff2');
|
||||
unicode-range: U+ace2-ace3, U+ace5-ace6, U+ace9-acef, U+acf2, U+acf4, U+acf7-acfb, U+acfe-acff, U+ad01-ad03, U+ad05-ad0b, U+ad0d-ad10, U+ad12-ad1b, U+ad1d-ad33, U+ad35-ad48, U+ad4a-ad4f, U+ad51-ad6b, U+ad6e-ad6f, U+ad71-ad72, U+ad77-ad7c, U+ad7e, U+ad80, U+ad82-ad87, U+ad89-ad8b, U+ad8d-ad8f, U+ad91-ad9b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-064.woff2") format('woff2');
|
||||
unicode-range: U+ac25-ac2c, U+ac2e, U+ac30, U+ac32-ac37, U+ac39-ac3f, U+ac41-ac4c, U+ac4e-ac6f, U+ac72-ac73, U+ac75-ac76, U+ac79-ac7f, U+ac82, U+ac84-ac88, U+ac8a-ac8b, U+ac8d-ac8f, U+ac91-ac93, U+ac95-ac9b, U+ac9d-ac9e, U+aca1-aca7, U+acab, U+acad-acaf, U+acb1-acb7, U+acba-acbb, U+acbe-acc0, U+acc2-acc3, U+acc5-acdf;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-065.woff2") format('woff2');
|
||||
unicode-range: U+99df, U+99ed, U+99f1, U+99ff, U+9a01, U+9a08, U+9a0e-9a0f, U+9a19, U+9a2b, U+9a30, U+9a36-9a37, U+9a40, U+9a43, U+9a45, U+9a4d, U+9a55, U+9a57, U+9a5a-9a5b, U+9a5f, U+9a62, U+9a65, U+9a69-9a6a, U+9aa8, U+9ab8, U+9ad3, U+9ae5, U+9aee, U+9b1a, U+9b27, U+9b2a, U+9b31, U+9b3c, U+9b41-9b45, U+9b4f, U+9b54, U+9b5a, U+9b6f, U+9b8e, U+9b91, U+9b9f, U+9bab, U+9bae, U+9bc9, U+9bd6, U+9be4, U+9be8, U+9c0d, U+9c10, U+9c12, U+9c15, U+9c25, U+9c32, U+9c3b, U+9c47, U+9c49, U+9c57, U+9ce5, U+9ce7, U+9ce9, U+9cf3-9cf4, U+9cf6, U+9d09, U+9d1b, U+9d26, U+9d28, U+9d3b, U+9d51, U+9d5d, U+9d60-9d61, U+9d6c, U+9d72, U+9da9, U+9daf, U+9db4, U+9dc4, U+9dd7, U+9df2, U+9df8-9dfa, U+9e1a, U+9e1e, U+9e75, U+9e79, U+9e7d, U+9e7f, U+9e92-9e93, U+9e97, U+9e9d, U+9e9f, U+9ea5, U+9eb4-9eb5, U+9ebb, U+9ebe, U+9ec3, U+9ecd-9ece, U+9ed4, U+9ed8, U+9edb-9edc, U+9ede, U+9ee8, U+9ef4, U+9f07-9f08, U+9f0e, U+9f13, U+9f20, U+9f3b, U+9f4a-9f4b, U+9f4e, U+9f52, U+9f5f, U+9f61, U+9f67, U+9f6a, U+9f6c, U+9f77, U+9f8d, U+9f90, U+9f95, U+9f9c, U+ac02-ac03, U+ac05-ac06, U+ac09-ac0f, U+ac17-ac18, U+ac1b, U+ac1e-ac1f, U+ac21-ac23;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-066.woff2") format('woff2');
|
||||
unicode-range: U+96a7-96a8, U+96aa, U+96b1, U+96b7, U+96bb, U+96c0-96c1, U+96c4-96c5, U+96c7, U+96c9, U+96cb-96ce, U+96d5-96d6, U+96d9, U+96db-96dc, U+96e2-96e3, U+96e8-96ea, U+96ef-96f0, U+96f2, U+96f6-96f7, U+96f9, U+96fb, U+9700, U+9706-9707, U+9711, U+9713, U+9716, U+9719, U+971c, U+971e, U+9727, U+9730, U+9732, U+9739, U+973d, U+9742, U+9744, U+9748, U+9756, U+975c, U+9761, U+9769, U+976d, U+9774, U+9777, U+977a, U+978b, U+978d, U+978f, U+97a0, U+97a8, U+97ab, U+97ad, U+97c6, U+97cb, U+97dc, U+97f6, U+97fb, U+97ff-9803, U+9805-9806, U+9808, U+980a, U+980c, U+9810-9813, U+9817-9818, U+982d, U+9830, U+9838-9839, U+983b, U+9846, U+984c-984e, U+9854, U+9858, U+985a, U+985e, U+9865, U+9867, U+986b, U+986f, U+98af, U+98b1, U+98c4, U+98c7, U+98db-98dc, U+98e1-98e2, U+98ed-98ef, U+98f4, U+98fc-98fe, U+9903, U+9909-990a, U+990c, U+9910, U+9913, U+9918, U+991e, U+9920, U+9928, U+9945, U+9949, U+994b-994d, U+9951-9952, U+9954, U+9957, U+9996, U+999d, U+99a5, U+99a8, U+99ac-99ae, U+99b1, U+99b3-99b4, U+99b9, U+99c1, U+99d0-99d2, U+99d5, U+99d9, U+99dd;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-067.woff2") format('woff2');
|
||||
unicode-range: U+920d, U+9210-9212, U+9217, U+921e, U+9234, U+923a, U+923f-9240, U+9245, U+9249, U+9257, U+925b, U+925e, U+9262, U+9264-9266, U+9283, U+9285, U+9291, U+9293, U+9296, U+9298, U+929c, U+92b3, U+92b6-92b7, U+92b9, U+92cc, U+92cf, U+92d2, U+92e4, U+92ea, U+92f8, U+92fc, U+9304, U+9310, U+9318, U+931a, U+931e-9322, U+9324, U+9326, U+9328, U+932b, U+932e-932f, U+9348, U+934a-934b, U+934d, U+9354, U+935b, U+936e, U+9375, U+937c, U+937e, U+938c, U+9394, U+9396, U+939a, U+93a3, U+93a7, U+93ac-93ad, U+93b0, U+93c3, U+93d1, U+93de, U+93e1, U+93e4, U+93f6, U+9404, U+9418, U+9425, U+942b, U+9435, U+9438, U+9444, U+9451-9452, U+945b, U+947d, U+947f, U+9583, U+9589, U+958f, U+9591-9592, U+9594, U+9598, U+95a3-95a5, U+95a8, U+95ad, U+95b1, U+95bb-95bc, U+95c7, U+95ca, U+95d4-95d6, U+95dc, U+95e1-95e2, U+961c, U+9621, U+962a, U+962e, U+9632, U+963b, U+963f-9640, U+9642, U+9644, U+964b-964d, U+9650, U+965b-965f, U+9662-9664, U+966a, U+9670, U+9673, U+9675-9678, U+967d, U+9685-9686, U+968a-968b, U+968d-968e, U+9694-9695, U+9698-9699, U+969b-969c, U+96a3;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-068.woff2") format('woff2');
|
||||
unicode-range: U+8fa8, U+8fad, U+8faf-8fb2, U+8fc2, U+8fc5, U+8fce, U+8fd4, U+8fe6, U+8fea-8feb, U+8fed, U+8ff0, U+8ff2, U+8ff7, U+8ff9, U+8ffd, U+9000-9003, U+9005-9006, U+9008, U+900b, U+900d, U+900f-9011, U+9014-9015, U+9017, U+9019, U+901d-9023, U+902e, U+9031-9032, U+9035, U+9038, U+903c, U+903e, U+9041-9042, U+9047, U+904a-904b, U+904d-904e, U+9050-9051, U+9054-9055, U+9059, U+905c-905e, U+9060-9061, U+9063, U+9069, U+906d-906f, U+9072, U+9075, U+9077-9078, U+907a, U+907c-907d, U+907f-9084, U+9087-9088, U+908a, U+908f, U+9091, U+9095, U+9099, U+90a2-90a3, U+90a6, U+90a8, U+90aa, U+90af-90b1, U+90b5, U+90b8, U+90c1, U+90ca, U+90de, U+90e1, U+90ed, U+90f5, U+9102, U+9112, U+9115, U+9119, U+9127, U+912d, U+9132, U+9149-914e, U+9152, U+9162, U+9169-916a, U+916c, U+9175, U+9177-9178, U+9187, U+9189, U+918b, U+918d, U+9192, U+919c, U+91ab-91ac, U+91ae-91af, U+91b1, U+91b4-91b5, U+91c0, U+91c7, U+91c9, U+91cb, U+91cf-91d0, U+91d7-91d8, U+91dc-91dd, U+91e3, U+91e7, U+91ea, U+91f5;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-069.woff2") format('woff2');
|
||||
unicode-range: U+8c6a-8c6b, U+8c79-8c7a, U+8c82, U+8c8a, U+8c8c, U+8c9d-8c9e, U+8ca0-8ca2, U+8ca7-8cac, U+8caf-8cb0, U+8cb3-8cb4, U+8cb6-8cb8, U+8cbb-8cbd, U+8cbf-8cc4, U+8cc7-8cc8, U+8cca, U+8cd1, U+8cd3, U+8cda, U+8cdc, U+8cde, U+8ce0, U+8ce2-8ce4, U+8ce6, U+8cea, U+8ced, U+8cf4, U+8cfb-8cfd, U+8d04-8d05, U+8d07-8d08, U+8d0a, U+8d0d, U+8d13, U+8d16, U+8d64, U+8d66, U+8d6b, U+8d70, U+8d73-8d74, U+8d77, U+8d85, U+8d8a, U+8d99, U+8da3, U+8da8, U+8db3, U+8dba, U+8dbe, U+8dc6, U+8dcb-8dcc, U+8dcf, U+8ddb, U+8ddd, U+8de1, U+8de3, U+8de8, U+8df3, U+8e0a, U+8e0f-8e10, U+8e1e, U+8e2a, U+8e30, U+8e35, U+8e42, U+8e44, U+8e47-8e4a, U+8e59, U+8e5f-8e60, U+8e74, U+8e76, U+8e81, U+8e87, U+8e8a, U+8e8d, U+8eaa-8eac, U+8ec0, U+8ecb-8ecc, U+8ed2, U+8edf, U+8eeb, U+8ef8, U+8efb, U+8efe, U+8f03, U+8f05, U+8f09, U+8f12-8f15, U+8f1b-8f1f, U+8f26-8f27, U+8f29-8f2a, U+8f2f, U+8f33, U+8f38-8f39, U+8f3b, U+8f3e-8f3f, U+8f44-8f45, U+8f49, U+8f4d-8f4e, U+8f5d, U+8f5f, U+8f62, U+8f9b-8f9c, U+8fa3, U+8fa6;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-070.woff2") format('woff2');
|
||||
unicode-range: U+8941, U+8944, U+895f, U+8964, U+896a, U+8972, U+8981, U+8983, U+8986-8987, U+898f, U+8993, U+8996, U+89a1, U+89a9-89aa, U+89b2, U+89ba, U+89bd, U+89c0, U+89d2, U+89e3, U+89f4, U+89f8, U+8a02-8a03, U+8a08, U+8a0a, U+8a0c, U+8a0e, U+8a13, U+8a16-8a17, U+8a1b, U+8a1d, U+8a1f, U+8a23, U+8a25, U+8a2a, U+8a2d, U+8a31, U+8a34, U+8a36, U+8a3a-8a3b, U+8a50, U+8a54-8a55, U+8a5b, U+8a5e, U+8a60, U+8a62-8a63, U+8a66, U+8a6d-8a6e, U+8a70, U+8a72-8a73, U+8a75, U+8a79, U+8a85, U+8a87, U+8a8c-8a8d, U+8a93, U+8a95, U+8a98, U+8aa0-8aa1, U+8aa3-8aa6, U+8aa8, U+8aaa, U+8ab0, U+8ab2, U+8ab9, U+8abc, U+8abe-8abf, U+8ac2, U+8ac4, U+8ac7, U+8acb, U+8acd, U+8acf, U+8ad2, U+8ad6, U+8adb-8adc, U+8ae1, U+8ae6-8ae7, U+8aea-8aeb, U+8aed-8aee, U+8af1, U+8af6-8af8, U+8afa, U+8afe, U+8b00-8b02, U+8b04, U+8b0e, U+8b10, U+8b14, U+8b16-8b17, U+8b19-8b1b, U+8b1d, U+8b20, U+8b28, U+8b2b-8b2c, U+8b33, U+8b39, U+8b41, U+8b49, U+8b4e-8b4f, U+8b58, U+8b5a, U+8b5c, U+8b66, U+8b6c, U+8b6f-8b70, U+8b74, U+8b77, U+8b7d, U+8b80, U+8b8a, U+8b90, U+8b92-8b93, U+8b96, U+8b9a, U+8c37, U+8c3f, U+8c41, U+8c46, U+8c48, U+8c4a, U+8c4c, U+8c55, U+8c5a, U+8c61;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-071.woff2") format('woff2');
|
||||
unicode-range: U+858f, U+8591, U+8594, U+859b, U+85a6, U+85a8-85aa, U+85af-85b0, U+85ba, U+85c1, U+85c9, U+85cd-85cf, U+85d5, U+85dc-85dd, U+85e4-85e5, U+85e9-85ea, U+85f7, U+85fa-85fb, U+85ff, U+8602, U+8606-8607, U+860a, U+8616-8617, U+861a, U+862d, U+863f, U+864e, U+8650, U+8654-8655, U+865b-865c, U+865e-865f, U+8667, U+8679, U+868a, U+868c, U+8693, U+86a3-86a4, U+86a9, U+86c7, U+86cb, U+86d4, U+86d9, U+86db, U+86df, U+86e4, U+86ed, U+86fe, U+8700, U+8702-8703, U+8708, U+8718, U+871a, U+871c, U+874e, U+8755, U+8757, U+875f, U+8766, U+8768, U+8774, U+8776, U+8778, U+8782, U+878d, U+879f, U+87a2, U+87b3, U+87ba, U+87c4, U+87e0, U+87ec, U+87ef, U+87f2, U+87f9, U+87fb, U+87fe, U+8805, U+881f, U+8822-8823, U+8831, U+8836, U+883b, U+8840, U+8846, U+884d, U+8852-8853, U+8857, U+8859, U+885b, U+885d, U+8861-8863, U+8868, U+886b, U+8870, U+8872, U+8877, U+887e-887f, U+8881-8882, U+8888, U+888b, U+888d, U+8892, U+8896-8897, U+889e, U+88ab, U+88b4, U+88c1-88c2, U+88cf, U+88d4-88d5, U+88d9, U+88dc-88dd, U+88df, U+88e1, U+88e8, U+88f3-88f5, U+88f8, U+88fd, U+8907, U+8910, U+8912-8913, U+8918-8919, U+8925, U+892a, U+8936, U+8938, U+893b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-072.woff2") format('woff2');
|
||||
unicode-range: U+82a6, U+82a9, U+82ac-82af, U+82b3, U+82b7-82b9, U+82bb-82bd, U+82bf, U+82d1-82d2, U+82d4-82d5, U+82d7, U+82db, U+82de-82df, U+82e1, U+82e5-82e7, U+82fd-82fe, U+8301-8305, U+8309, U+8317, U+8328, U+832b, U+832f, U+8331, U+8334-8336, U+8338-8339, U+8340, U+8347, U+8349-834a, U+834f, U+8351-8352, U+8373, U+8377, U+837b, U+8389-838a, U+838e, U+8396, U+8398, U+839e, U+83a2, U+83a9-83ab, U+83bd, U+83c1, U+83c5, U+83c9-83ca, U+83cc, U+83d3, U+83d6, U+83dc, U+83e9, U+83eb, U+83ef-83f2, U+83f4, U+83f9, U+83fd, U+8403-8404, U+840a, U+840c-840e, U+8429, U+842c, U+8431, U+8438, U+843d, U+8449, U+8457, U+845b, U+8461, U+8463, U+8466, U+846b-846c, U+846f, U+8475, U+847a, U+8490, U+8494, U+8499, U+849c, U+84a1, U+84b2, U+84b8, U+84bb-84bc, U+84bf-84c0, U+84c2, U+84c4, U+84c6, U+84c9, U+84cb, U+84cd, U+84d1, U+84da, U+84ec, U+84ee, U+84f4, U+84fc, U+8511, U+8513-8514, U+8517-8518, U+851a, U+851e, U+8521, U+8523, U+8525, U+852c-852d, U+852f, U+853d, U+853f, U+8541, U+8543, U+8549, U+854e, U+8553, U+8559, U+8563, U+8568-856a, U+856d, U+8584, U+8587;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-073.woff2") format('woff2');
|
||||
unicode-range: U+8033, U+8036, U+803d, U+803f, U+8043, U+8046, U+804a, U+8056, U+8058, U+805a, U+805e, U+806f-8070, U+8072-8073, U+8077, U+807d-807f, U+8084-8087, U+8089, U+808b-808c, U+8096, U+809b, U+809d, U+80a1-80a2, U+80a5, U+80a9-80aa, U+80af, U+80b1-80b2, U+80b4, U+80ba, U+80c3-80c4, U+80cc, U+80ce, U+80da-80db, U+80de, U+80e1, U+80e4-80e5, U+80f1, U+80f4, U+80f8, U+80fd, U+8102, U+8105-8108, U+810a, U+8118, U+811a-811b, U+8123, U+8129, U+812b, U+812f, U+8139, U+813e, U+814b, U+814e, U+8150-8151, U+8154-8155, U+8165-8166, U+816b, U+8170-8171, U+8178-817a, U+817f-8180, U+8188, U+818a, U+818f, U+819a, U+819c-819d, U+81a0, U+81a3, U+81a8, U+81b3, U+81b5, U+81ba, U+81bd-81c0, U+81c2, U+81c6, U+81cd, U+81d8, U+81df, U+81e3, U+81e5, U+81e7-81e8, U+81ed, U+81f3-81f4, U+81fa-81fc, U+81fe, U+8205, U+8208, U+820a, U+820c-820d, U+8212, U+821b-821c, U+821e-821f, U+8221, U+822a-822c, U+8235-8237, U+8239, U+8240, U+8245, U+8247, U+8259, U+8264, U+8266, U+826e-826f, U+8271, U+8276, U+8278, U+827e, U+828b, U+828d-828e, U+8292, U+8299-829a, U+829d, U+829f, U+82a5;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-074.woff2") format('woff2');
|
||||
unicode-range: U+7d2f-7d30, U+7d33, U+7d35, U+7d39-7d3a, U+7d42-7d46, U+7d50, U+7d5e, U+7d61-7d62, U+7d66, U+7d68, U+7d6a, U+7d6e, U+7d71-7d73, U+7d76, U+7d79, U+7d7f, U+7d8e-7d8f, U+7d93, U+7d9c, U+7da0, U+7da2, U+7dac-7dad, U+7db1-7db2, U+7db4-7db5, U+7db8, U+7dba-7dbb, U+7dbd-7dbf, U+7dc7, U+7dca-7dcb, U+7dd6, U+7dd8, U+7dda, U+7ddd-7dde, U+7de0-7de1, U+7de3, U+7de8-7de9, U+7dec, U+7def, U+7df4, U+7dfb, U+7e09-7e0a, U+7e15, U+7e1b, U+7e1d-7e1f, U+7e21, U+7e23, U+7e2b, U+7e2e-7e2f, U+7e31, U+7e37, U+7e3d-7e3e, U+7e43, U+7e46-7e47, U+7e52, U+7e54-7e55, U+7e5e, U+7e61, U+7e69-7e6b, U+7e6d, U+7e70, U+7e79, U+7e7c, U+7e82, U+7e8c, U+7e8f, U+7e93, U+7e96, U+7e98, U+7e9b-7e9c, U+7f36, U+7f38, U+7f3a, U+7f4c, U+7f50, U+7f54-7f55, U+7f6a-7f6b, U+7f6e, U+7f70, U+7f72, U+7f75, U+7f77, U+7f79, U+7f85, U+7f88, U+7f8a, U+7f8c, U+7f94, U+7f9a, U+7f9e, U+7fa4, U+7fa8-7fa9, U+7fb2, U+7fb8-7fb9, U+7fbd, U+7fc1, U+7fc5, U+7fca, U+7fcc, U+7fce, U+7fd2, U+7fd4-7fd5, U+7fdf-7fe1, U+7fe9, U+7feb, U+7ff0, U+7ff9, U+7ffc, U+8000-8001, U+8003, U+8006, U+8009, U+800c, U+8010, U+8015, U+8017-8018, U+802d;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-075.woff2") format('woff2');
|
||||
unicode-range: U+7a49, U+7a4d-7a4e, U+7a57, U+7a61-7a62, U+7a69, U+7a6b, U+7a70, U+7a74, U+7a76, U+7a79, U+7a7d, U+7a7f, U+7a81, U+7a84, U+7a88, U+7a92-7a93, U+7a95, U+7a98, U+7a9f, U+7aa9-7aaa, U+7aae-7aaf, U+7aba, U+7ac4-7ac5, U+7ac7, U+7aca, U+7ad7, U+7ad9, U+7add, U+7adf-7ae0, U+7ae3, U+7ae5, U+7aea, U+7aed, U+7aef, U+7af6, U+7af9-7afa, U+7aff, U+7b0f, U+7b11, U+7b19, U+7b1b, U+7b1e, U+7b20, U+7b26, U+7b2d, U+7b39, U+7b46, U+7b49, U+7b4b-7b4d, U+7b4f-7b52, U+7b54, U+7b56, U+7b60, U+7b6c, U+7b6e, U+7b75, U+7b7d, U+7b87, U+7b8b, U+7b8f, U+7b94-7b95, U+7b97, U+7b9a, U+7b9d, U+7ba1, U+7bad, U+7bb1, U+7bb4, U+7bb8, U+7bc0-7bc1, U+7bc4, U+7bc6-7bc7, U+7bc9, U+7bd2, U+7be0, U+7be4, U+7be9, U+7c07, U+7c12, U+7c1e, U+7c21, U+7c27, U+7c2a-7c2b, U+7c3d-7c3f, U+7c43, U+7c4c-7c4d, U+7c60, U+7c64, U+7c6c, U+7c73, U+7c83, U+7c89, U+7c92, U+7c95, U+7c97-7c98, U+7c9f, U+7ca5, U+7ca7, U+7cae, U+7cb1-7cb3, U+7cb9, U+7cbe, U+7cca, U+7cd6, U+7cde-7ce0, U+7ce7, U+7cfb, U+7cfe, U+7d00, U+7d02, U+7d04-7d08, U+7d0a-7d0b, U+7d0d, U+7d10, U+7d14, U+7d17-7d1b, U+7d20-7d21, U+7d2b-7d2c, U+7d2e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-076.woff2") format('woff2');
|
||||
unicode-range: U+7704, U+7708-7709, U+770b, U+771e, U+7720, U+7729, U+7737-7738, U+773a, U+773c, U+7740, U+774d, U+775b, U+7761, U+7763, U+7766, U+776b, U+7779, U+777e-777f, U+778b, U+7791, U+779e, U+77a5, U+77ac-77ad, U+77b0, U+77b3, U+77bb-77bc, U+77bf, U+77d7, U+77db-77dc, U+77e2-77e3, U+77e9, U+77ed-77ef, U+7802, U+7812, U+7825-7827, U+782c, U+7832, U+7834, U+7845, U+784f, U+785d, U+786b-786c, U+786f, U+787c, U+7881, U+7887, U+788c-788e, U+7891, U+7897, U+78a3, U+78a7, U+78a9, U+78ba-78bc, U+78c1, U+78c5, U+78ca-78cb, U+78ce, U+78d0, U+78e8, U+78ec, U+78ef, U+78f5, U+78fb, U+7901, U+790e, U+7916, U+792a-792c, U+793a, U+7940-7941, U+7947-7949, U+7950, U+7956-7957, U+795a-795d, U+7960, U+7965, U+7968, U+796d, U+797a, U+797f, U+7981, U+798d-798e, U+7991, U+79a6-79a7, U+79aa, U+79ae, U+79b1, U+79b3, U+79b9, U+79bd-79c1, U+79c9-79cb, U+79d2, U+79d5, U+79d8, U+79df, U+79e4, U+79e6-79e7, U+79e9, U+79fb, U+7a00, U+7a05, U+7a08, U+7a0b, U+7a0d, U+7a14, U+7a17, U+7a19-7a1a, U+7a1c, U+7a1f-7a20, U+7a2e, U+7a31, U+7a36-7a37, U+7a3b-7a3d, U+7a3f-7a40, U+7a46;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-077.woff2") format('woff2');
|
||||
unicode-range: U+7482-7483, U+7487, U+7489, U+748b, U+7498, U+749c, U+749e-749f, U+74a1, U+74a3, U+74a5, U+74a7-74a8, U+74aa, U+74b0, U+74b2, U+74b5, U+74b9, U+74bd, U+74bf, U+74c6, U+74ca, U+74cf, U+74d4, U+74d8, U+74da, U+74dc, U+74e0, U+74e2-74e3, U+74e6, U+74ee, U+74f7, U+7501, U+7504, U+7511, U+7515, U+7518, U+751a-751b, U+7523, U+7525-7526, U+752b-752c, U+7531, U+7533, U+7538, U+753a, U+7547, U+754c, U+754f, U+7551, U+7553-7554, U+7559, U+755b-755d, U+7562, U+7565-7566, U+756a, U+756f-7570, U+7575-7576, U+7578, U+757a, U+757f, U+7586-7587, U+758a-758b, U+758e-758f, U+7591, U+759d, U+75a5, U+75ab, U+75b1-75b3, U+75b5, U+75b8-75b9, U+75bc-75be, U+75c2, U+75c5, U+75c7, U+75cd, U+75d2, U+75d4-75d5, U+75d8-75d9, U+75db, U+75e2, U+75f0, U+75f2, U+75f4, U+75fa, U+75fc, U+7600, U+760d, U+7619, U+761f-7622, U+7624, U+7626, U+763b, U+7642, U+764c, U+764e, U+7652, U+7656, U+7661, U+7664, U+7669, U+766c, U+7670, U+7672, U+7678, U+7686-7687, U+768e, U+7690, U+7693, U+76ae, U+76ba, U+76bf, U+76c2-76c3, U+76c6, U+76c8, U+76ca, U+76d2, U+76d6, U+76db-76dc, U+76de-76df, U+76e1, U+76e3-76e4, U+76e7, U+76f2, U+76fc, U+76fe, U+7701;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-078.woff2") format('woff2');
|
||||
unicode-range: U+7230, U+7232, U+7235, U+723a-723b, U+723d-723e, U+7240, U+7246-7248, U+724c, U+7252, U+7258-7259, U+725b, U+725d, U+725f, U+7261-7262, U+7267, U+7272, U+727d, U+7280-7281, U+72a2, U+72a7, U+72ac, U+72af, U+72c0, U+72c2, U+72c4, U+72ce, U+72d0, U+72d7, U+72d9, U+72e1, U+72e9, U+72f8-72f9, U+72fc-72fd, U+730a, U+7316, U+731b-731d, U+7325, U+7329-732b, U+7336-7337, U+733e-733f, U+7344-7345, U+7350, U+7352, U+7357, U+7368, U+736a, U+7370, U+7372, U+7375, U+7378, U+737a-737b, U+7384, U+7386-7387, U+7389, U+738e, U+7394, U+7396-7398, U+739f, U+73a7, U+73a9, U+73ad, U+73b2-73b3, U+73b9, U+73c0, U+73c2, U+73c9-73ca, U+73cc-73cd, U+73cf, U+73d6, U+73d9, U+73dd-73de, U+73e0, U+73e3-73e6, U+73e9-73ea, U+73ed, U+73f7, U+73f9, U+73fd-73fe, U+7401, U+7403, U+7405, U+7407, U+7409, U+7413, U+741b, U+7420-7422, U+7425-7426, U+7428, U+742a-742c, U+742e-7430, U+7433-7436, U+7438, U+743a, U+743f-7441, U+7443-7444, U+744b, U+7455, U+7457, U+7459-745c, U+745e-7460, U+7462, U+7464-7465, U+7468-746a, U+746f, U+747e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-079.woff2") format('woff2');
|
||||
unicode-range: U+6f8d-6f8e, U+6f90, U+6f94, U+6f97, U+6fa3-6fa4, U+6fa7, U+6fae-6faf, U+6fb1, U+6fb3, U+6fb9, U+6fbe, U+6fc0-6fc3, U+6fca, U+6fd5, U+6fda, U+6fdf-6fe1, U+6fe4, U+6fe9, U+6feb-6fec, U+6fef, U+6ff1, U+6ffe, U+7001, U+7005-7006, U+7009, U+700b, U+700f, U+7011, U+7015, U+7018, U+701a-701f, U+7023, U+7027-7028, U+702f, U+7037, U+703e, U+704c, U+7050-7051, U+7058, U+705d, U+7070, U+7078, U+707c-707d, U+7085, U+708a, U+708e, U+7092, U+7098-709a, U+70a1, U+70a4, U+70ab-70ad, U+70af, U+70b3, U+70b7-70b9, U+70c8, U+70cb, U+70cf, U+70d8-70d9, U+70dd, U+70df, U+70f1, U+70f9, U+70fd, U+7104, U+7109, U+710c, U+7119-711a, U+711e, U+7126, U+7130, U+7136, U+7147, U+7149-714a, U+714c, U+714e, U+7150, U+7156, U+7159, U+715c, U+715e, U+7164-7167, U+7169, U+716c, U+716e, U+717d, U+7184, U+7189-718a, U+718f, U+7192, U+7194, U+7199, U+719f, U+71a2, U+71ac, U+71b1, U+71b9-71ba, U+71be, U+71c1, U+71c3, U+71c8-71c9, U+71ce, U+71d0, U+71d2, U+71d4-71d5, U+71df, U+71e5-71e7, U+71ed-71ee, U+71fb-71fc, U+71fe-7200, U+7206, U+7210, U+721b, U+722a, U+722c-722d;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-080.woff2") format('woff2');
|
||||
unicode-range: U+6d5a, U+6d5c, U+6d63, U+6d66, U+6d69-6d6a, U+6d6c, U+6d6e, U+6d74, U+6d78-6d79, U+6d7f, U+6d85, U+6d87-6d89, U+6d8c-6d8e, U+6d91, U+6d93, U+6d95, U+6daf, U+6db2, U+6db5, U+6dc0, U+6dc3-6dc7, U+6dcb, U+6dcf, U+6dd1, U+6dd8-6dda, U+6dde, U+6de1, U+6de8, U+6dea-6deb, U+6dee, U+6df1, U+6df3, U+6df5, U+6df7-6dfb, U+6e17, U+6e19-6e1b, U+6e1f-6e21, U+6e23-6e26, U+6e2b-6e2d, U+6e32, U+6e34, U+6e36, U+6e38, U+6e3a, U+6e3c-6e3e, U+6e43-6e44, U+6e4a, U+6e4d, U+6e56, U+6e58, U+6e5b-6e5c, U+6e5e-6e5f, U+6e67, U+6e6b, U+6e6e-6e6f, U+6e72-6e73, U+6e7a, U+6e90, U+6e96, U+6e9c-6e9d, U+6e9f, U+6ea2, U+6ea5, U+6eaa-6eab, U+6eaf, U+6eb1, U+6eb6, U+6eba, U+6ec2, U+6ec4-6ec5, U+6ec9, U+6ecb-6ecc, U+6ece, U+6ed1, U+6ed3-6ed4, U+6eef, U+6ef4, U+6ef8, U+6efe-6eff, U+6f01-6f02, U+6f06, U+6f0f, U+6f11, U+6f14-6f15, U+6f20, U+6f22-6f23, U+6f2b-6f2c, U+6f31-6f32, U+6f38, U+6f3f, U+6f41, U+6f51, U+6f54, U+6f57-6f58, U+6f5a-6f5b, U+6f5e-6f5f, U+6f62, U+6f64, U+6f6d-6f6e, U+6f70, U+6f7a, U+6f7c-6f7e, U+6f81, U+6f84, U+6f88;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-081.woff2") format('woff2');
|
||||
unicode-range: U+6ada-6adb, U+6af6, U+6afb, U+6b04, U+6b0a, U+6b0c, U+6b12, U+6b16, U+6b20-6b21, U+6b23, U+6b32, U+6b3a, U+6b3d-6b3e, U+6b46-6b47, U+6b4e, U+6b50, U+6b5f, U+6b61-6b62, U+6b64-6b66, U+6b6a, U+6b72, U+6b77-6b78, U+6b7b, U+6b7f, U+6b83-6b84, U+6b86, U+6b89-6b8a, U+6b96, U+6b98, U+6b9e, U+6bae-6baf, U+6bb2, U+6bb5, U+6bb7, U+6bba, U+6bbc, U+6bbf, U+6bc1, U+6bc5-6bc6, U+6bcb, U+6bcf, U+6bd2-6bd3, U+6bd6-6bd8, U+6bdb, U+6beb-6bec, U+6c08, U+6c0f, U+6c13, U+6c23, U+6c37-6c38, U+6c3e, U+6c40-6c42, U+6c4e, U+6c50, U+6c55, U+6c57, U+6c5a, U+6c5d-6c60, U+6c68, U+6c6a, U+6c6d, U+6c70, U+6c72, U+6c76, U+6c7a, U+6c7d-6c7e, U+6c81-6c83, U+6c85-6c88, U+6c8c, U+6c90, U+6c92-6c96, U+6c99-6c9b, U+6cab, U+6cae, U+6cb3, U+6cb8-6cb9, U+6cbb-6cbf, U+6cc1-6cc2, U+6cc4, U+6cc9-6cca, U+6ccc, U+6cd3, U+6cd7, U+6cdb, U+6ce1-6ce3, U+6ce5, U+6ce8, U+6ceb, U+6cee-6cf0, U+6cf3, U+6d0b-6d0c, U+6d11, U+6d17, U+6d19, U+6d1b, U+6d1e, U+6d25, U+6d27, U+6d29, U+6d32, U+6d35-6d36, U+6d38-6d39, U+6d3b, U+6d3d-6d3e, U+6d41, U+6d59;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-082.woff2") format('woff2');
|
||||
unicode-range: U+67f0-67f1, U+67f3-67f6, U+67fb, U+67fe, U+6812-6813, U+6816-6817, U+6821-6822, U+682f, U+6838-6839, U+683d, U+6840-6843, U+6848, U+684e, U+6850-6851, U+6853-6854, U+686d, U+6876, U+687f, U+6881, U+6885, U+688f, U+6893-6894, U+6897, U+689d, U+689f, U+68a1-68a2, U+68a7-68a8, U+68ad, U+68af-68b1, U+68b3, U+68b5-68b6, U+68c4-68c5, U+68c9, U+68cb, U+68cd, U+68d2, U+68d5, U+68d7-68d8, U+68da, U+68df-68e0, U+68e7-68e8, U+68ee, U+68f2, U+68f9-68fa, U+6900, U+6905, U+690d-690e, U+6912, U+6927, U+6930, U+693d, U+693f, U+694a, U+6953-6955, U+6957, U+6959-695a, U+695e, U+6960-6963, U+6968, U+696b, U+696d-696f, U+6975, U+6977-6979, U+6995, U+699b-699c, U+69a5, U+69a7, U+69ae, U+69b4, U+69bb, U+69c1, U+69c3, U+69cb-69cd, U+69d0, U+69e8, U+69ea, U+69fb, U+69fd, U+69ff, U+6a02, U+6a0a, U+6a11, U+6a13, U+6a17, U+6a19, U+6a1e-6a1f, U+6a21, U+6a23, U+6a35, U+6a38-6a3a, U+6a3d, U+6a44, U+6a48, U+6a4b, U+6a52-6a53, U+6a58-6a59, U+6a5f, U+6a61, U+6a6b, U+6a80, U+6a84, U+6a89, U+6a8d-6a8e, U+6a97, U+6a9c, U+6aa3, U+6ab3, U+6abb, U+6ac2-6ac3, U+6ad3;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-083.woff2") format('woff2');
|
||||
unicode-range: U+6607, U+6609-660a, U+660c, U+660f-6611, U+6613-6615, U+661e, U+6620, U+6627-6628, U+662d, U+6630-6631, U+6634, U+6636, U+663a-663b, U+6641, U+6643-6644, U+6649, U+664b, U+664f, U+6659, U+665b, U+665d-665f, U+6664-6669, U+666b, U+666e-666f, U+6673-6674, U+6676-6678, U+6684, U+6687-6689, U+668e, U+6690-6691, U+6696-6698, U+669d, U+66a0, U+66a2, U+66ab, U+66ae, U+66b2-66b4, U+66b9, U+66bb, U+66be, U+66c4, U+66c6-66c7, U+66c9, U+66d6, U+66d9, U+66dc-66dd, U+66e0, U+66e6, U+66f0, U+66f2-66f4, U+66f7, U+66f9-66fa, U+66fc, U+66fe-66ff, U+6703, U+670b, U+670d, U+6714-6715, U+6717, U+671b, U+671d-671f, U+6726-6727, U+672a-672b, U+672d-672e, U+6731, U+6736, U+673a, U+673d, U+6746, U+6749, U+674e-6751, U+6753, U+6756, U+675c, U+675e-675f, U+676d, U+676f-6770, U+6773, U+6775, U+6777, U+677b, U+677e-677f, U+6787, U+6789, U+678b, U+678f-6790, U+6793, U+6795, U+679a, U+679d, U+67af-67b0, U+67b3, U+67b6-67b8, U+67be, U+67c4, U+67cf-67d4, U+67da, U+67dd, U+67e9, U+67ec, U+67ef;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-084.woff2") format('woff2');
|
||||
unicode-range: U+6392, U+6396, U+6398, U+639b, U+63a0-63a2, U+63a5, U+63a7-63aa, U+63c0, U+63c4, U+63c6, U+63cf, U+63d6, U+63da-63db, U+63e1, U+63ed-63ee, U+63f4, U+63f6-63f7, U+640d, U+640f, U+6414, U+6416-6417, U+641c, U+6422, U+642c-642d, U+643a, U+643e, U+6458, U+6460, U+6469, U+646f, U+6478-647a, U+6488, U+6491-6493, U+649a, U+649e, U+64a4-64a5, U+64ab, U+64ad-64ae, U+64b0, U+64b2, U+64bb, U+64c1, U+64c4-64c5, U+64c7, U+64ca, U+64cd-64ce, U+64d2, U+64d4, U+64d8, U+64da, U+64e1-64e2, U+64e5-64e7, U+64ec, U+64f2, U+64f4, U+64fa, U+64fe, U+6500, U+6504, U+6518, U+651d, U+6523, U+652a-652c, U+652f, U+6536-6539, U+653b, U+653e, U+6548, U+654d-654f, U+6551, U+6556-6557, U+655e, U+6562-6563, U+6566, U+656c-656d, U+6572, U+6574-6575, U+6577-6578, U+657e, U+6582-6583, U+6585, U+658c, U+6590-6591, U+6597, U+6599, U+659b-659c, U+659f, U+65a1, U+65a4-65a5, U+65a7, U+65ab-65ac, U+65af, U+65b7, U+65bc-65bd, U+65c1, U+65c5, U+65cb-65cc, U+65cf, U+65d2, U+65d7, U+65e0, U+65e3, U+65e6, U+65e8-65e9, U+65ec-65ed, U+65f1, U+65f4, U+65fa-65fd, U+65ff, U+6606;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-085.woff2") format('woff2');
|
||||
unicode-range: U+614c, U+6153, U+6155, U+6158-6159, U+615d, U+615f, U+6162-6164, U+6167-6168, U+616b, U+616e, U+6170, U+6176-6177, U+617d-617e, U+6181-6182, U+618a, U+618e, U+6190-6191, U+6194, U+6198-619a, U+61a4, U+61a7, U+61a9, U+61ab-61ac, U+61ae, U+61b2, U+61b6, U+61ba, U+61be, U+61c3, U+61c7-61cb, U+61e6, U+61f2, U+61f6-61f8, U+61fa, U+61fc, U+61ff-6200, U+6207-6208, U+620a, U+620c-620e, U+6212, U+6216, U+621a, U+621f, U+6221, U+622a, U+622e, U+6230-6231, U+6234, U+6236, U+623e-623f, U+6241, U+6247-6249, U+624d, U+6253, U+6258, U+626e, U+6271, U+6276, U+6279, U+627c, U+627f-6280, U+6284, U+6289-628a, U+6291-6292, U+6295, U+6297-6298, U+629b, U+62ab, U+62b1, U+62b5, U+62b9, U+62bc-62bd, U+62c2, U+62c7-62c9, U+62cc-62cd, U+62cf-62d0, U+62d2-62d4, U+62d6-62d9, U+62db-62dc, U+62ec-62ef, U+62f1, U+62f3, U+62f7, U+62fe-62ff, U+6301, U+6307, U+6309, U+6311, U+632b, U+632f, U+633a-633b, U+633d-633e, U+6349, U+634c, U+634f-6350, U+6355, U+6367-6368, U+636e, U+6372, U+6377, U+637a-637b, U+637f, U+6383, U+6388-6389, U+638c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-086.woff2") format('woff2');
|
||||
unicode-range: U+5f11, U+5f13-5f15, U+5f17-5f18, U+5f1b, U+5f1f, U+5f26-5f27, U+5f29, U+5f31, U+5f35, U+5f3a, U+5f3c, U+5f48, U+5f4a, U+5f4c, U+5f4e, U+5f56-5f57, U+5f59, U+5f5b, U+5f62, U+5f66-5f67, U+5f69-5f6d, U+5f70-5f71, U+5f77, U+5f79, U+5f7c, U+5f7f-5f81, U+5f85, U+5f87, U+5f8a-5f8b, U+5f90-5f92, U+5f98-5f99, U+5f9e, U+5fa0-5fa1, U+5fa8-5faa, U+5fae, U+5fb5, U+5fb9, U+5fbd, U+5fc5, U+5fcc-5fcd, U+5fd6-5fd9, U+5fe0, U+5feb, U+5ff5, U+5ffd, U+5fff, U+600f, U+6012, U+6016, U+601c, U+6020-6021, U+6025, U+6028, U+602a, U+602f, U+6041-6043, U+604d, U+6050, U+6052, U+6055, U+6059, U+605d, U+6062-6065, U+6068-606a, U+606c-606d, U+606f-6070, U+6085, U+6089, U+608c-608d, U+6094, U+6096, U+609a-609b, U+609f-60a0, U+60a3-60a4, U+60a7, U+60b0, U+60b2-60b4, U+60b6, U+60b8, U+60bc-60bd, U+60c7, U+60d1, U+60da, U+60dc, U+60df-60e1, U+60f0-60f1, U+60f6, U+60f9-60fb, U+6101, U+6106, U+6108-6109, U+610d-610e, U+6115, U+611a, U+6127, U+6130, U+6134, U+6137, U+613c, U+613e-613f, U+6142, U+6144, U+6147-6148, U+614a-614b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-087.woff2") format('woff2');
|
||||
unicode-range: U+5c40, U+5c45-5c46, U+5c48, U+5c4b, U+5c4d-5c4e, U+5c51, U+5c5b, U+5c60, U+5c62, U+5c64-5c65, U+5c6c, U+5c6f, U+5c79, U+5c90-5c91, U+5ca1, U+5ca9, U+5cab-5cac, U+5cb1, U+5cb3, U+5cb5, U+5cb7-5cb8, U+5cba, U+5cbe, U+5cc0, U+5cd9, U+5ce0, U+5ce8, U+5cef-5cf0, U+5cf4, U+5cf6, U+5cfb, U+5cfd, U+5d07, U+5d0d-5d0e, U+5d11, U+5d14, U+5d16-5d17, U+5d19, U+5d27, U+5d29, U+5d4b-5d4c, U+5d50, U+5d69, U+5d6c, U+5d6f, U+5d87, U+5d8b, U+5d9d, U+5da0, U+5da2, U+5daa, U+5db8, U+5dba, U+5dbc-5dbd, U+5dcd, U+5dd2, U+5dd6, U+5de1-5de2, U+5de5-5de8, U+5deb, U+5dee, U+5df1-5df4, U+5df7, U+5dfd-5dfe, U+5e03, U+5e06, U+5e11, U+5e16, U+5e19, U+5e1b, U+5e1d, U+5e25, U+5e2b, U+5e2d, U+5e33, U+5e36, U+5e38, U+5e3d, U+5e3f-5e40, U+5e44-5e45, U+5e47, U+5e4c, U+5e55, U+5e5f, U+5e61-5e63, U+5e72, U+5e77-5e79, U+5e7b-5e7e, U+5e84, U+5e87, U+5e8a, U+5e8f, U+5e95, U+5e97, U+5e9a, U+5e9c, U+5ea0, U+5ea7, U+5eab, U+5ead, U+5eb5-5eb8, U+5ebe, U+5ec2, U+5ec8-5eca, U+5ed0, U+5ed3, U+5ed6, U+5eda-5edb, U+5edf-5ee0, U+5ee2-5ee3, U+5eec, U+5ef3, U+5ef6-5ef7, U+5efa-5efb, U+5f01, U+5f04, U+5f0a;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-088.woff2") format('woff2');
|
||||
unicode-range: U+59be, U+59c3, U+59c6, U+59c9, U+59cb, U+59d0-59d1, U+59d3-59d4, U+59d9-59da, U+59dc-59dd, U+59e6, U+59e8, U+59ea, U+59ec, U+59ee, U+59f8, U+59fb, U+59ff, U+5a01, U+5a03, U+5a11, U+5a18, U+5a1b-5a1c, U+5a1f-5a20, U+5a25, U+5a29, U+5a36, U+5a3c, U+5a41, U+5a46, U+5a49, U+5a5a, U+5a62, U+5a66, U+5a92, U+5a9a-5a9b, U+5aa4, U+5ac1-5ac2, U+5ac4, U+5ac9, U+5acc, U+5ae1, U+5ae6, U+5ae9, U+5b05, U+5b09, U+5b0b-5b0c, U+5b16, U+5b2a, U+5b40, U+5b43, U+5b51, U+5b54-5b55, U+5b58, U+5b5a, U+5b5c-5b5d, U+5b5f, U+5b63-5b64, U+5b69, U+5b6b, U+5b70-5b71, U+5b75, U+5b7a, U+5b7c, U+5b85, U+5b87-5b88, U+5b8b, U+5b8f, U+5b93, U+5b95-5b99, U+5b9b-5b9c, U+5ba2-5ba6, U+5bac, U+5bae, U+5bb0, U+5bb3-5bb5, U+5bb8-5bb9, U+5bbf-5bc0, U+5bc2-5bc7, U+5bcc, U+5bd0, U+5bd2-5bd4, U+5bd7, U+5bde-5bdf, U+5be1-5be2, U+5be4-5be9, U+5beb-5bec, U+5bee-5bef, U+5bf5-5bf6, U+5bf8, U+5bfa, U+5c01, U+5c04, U+5c07-5c0b, U+5c0d-5c0e, U+5c16, U+5c19, U+5c24, U+5c28, U+5c31, U+5c38-5c3c, U+5c3e-5c3f;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-089.woff2") format('woff2');
|
||||
unicode-range: U+5703-5704, U+5708, U+570d, U+5712-5713, U+5716, U+5718, U+572d, U+573b, U+5740, U+5742, U+5747, U+574a, U+574d-574e, U+5750-5751, U+5761, U+5764, U+5766, U+576a, U+576e, U+5770, U+5775, U+577c, U+5782, U+5788, U+578b, U+5793, U+57a0, U+57a2-57a3, U+57c3, U+57c7-57c8, U+57cb, U+57df-57e0, U+57f0, U+57f4, U+57f7, U+57f9-57fa, U+57fc, U+5800, U+5802, U+5805-5806, U+5808-580a, U+581e, U+5821, U+5824, U+5827, U+582a, U+582f-5831, U+5835, U+583a, U+584a-584b, U+584f, U+5851, U+5854, U+5857-5858, U+585a, U+585e, U+5861-5862, U+5864, U+5875, U+5879, U+587c, U+587e, U+5883, U+5885, U+5889, U+5893, U+589c, U+589e-589f, U+58a8-58a9, U+58ae, U+58b3, U+58ba-58bb, U+58be, U+58c1, U+58c5, U+58c7, U+58ce, U+58d1, U+58d3, U+58d5, U+58d8-58d9, U+58de-58df, U+58e4, U+58ec, U+58ef, U+58f9-58fb, U+58fd, U+590f, U+5914-5915, U+5919, U+5922, U+592d-592e, U+5931, U+5937, U+593e, U+5944, U+5947-5949, U+594e-5951, U+5954-5955, U+5957, U+595a, U+5960, U+5962, U+5967, U+596a-596e, U+5974, U+5978, U+5982-5984, U+598a, U+5993, U+5996-5997, U+5999, U+59a5, U+59a8, U+59ac, U+59b9, U+59bb;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-090.woff2") format('woff2');
|
||||
unicode-range: U+539a, U+53a0, U+53a5-53a6, U+53ad, U+53bb, U+53c3, U+53c8-53cb, U+53cd, U+53d4, U+53d6-53d7, U+53db, U+53e1-53e3, U+53e5, U+53e9-53ed, U+53f1, U+53f3, U+53f8, U+5403-5404, U+540a, U+540e-5411, U+541b, U+541d, U+541f-5420, U+5426, U+5429, U+542b, U+5433, U+5438-5439, U+543b-543c, U+543e, U+5442, U+5448, U+544a, U+5451, U+5468, U+546a, U+5471, U+5473, U+5475, U+547b-547d, U+5480, U+5486, U+548e, U+5490, U+54a4, U+54a8, U+54ab-54ac, U+54b3, U+54b8, U+54bd, U+54c0, U+54c4, U+54c8-54c9, U+54e1, U+54e5, U+54e8, U+54ed-54ee, U+54f2, U+54fa, U+5504, U+5506-5507, U+550e, U+5510, U+551c, U+552f, U+5531, U+5535, U+553e, U+5544, U+5546, U+554f, U+5553, U+5556, U+555e, U+5563, U+557c, U+5580, U+5584, U+5586-5587, U+5589-558a, U+5598-559a, U+559c-559d, U+55a7, U+55a9-55ac, U+55ae, U+55c5, U+55c7, U+55d4, U+55da, U+55dc, U+55df, U+55e3-55e4, U+55fd-55fe, U+5606, U+5609, U+5614, U+5617, U+562f, U+5632, U+5634, U+5636, U+5653, U+5668, U+566b, U+5674, U+5686, U+56a5, U+56ac, U+56ae, U+56b4, U+56bc, U+56ca, U+56cd, U+56d1, U+56da-56db, U+56de, U+56e0, U+56f0, U+56f9-56fa;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-091.woff2") format('woff2');
|
||||
unicode-range: U+516e, U+5175-5178, U+517c, U+5180, U+5186, U+518a, U+518d, U+5192, U+5195, U+5197, U+51a0, U+51a5, U+51aa, U+51ac, U+51b6-51b7, U+51bd, U+51c4, U+51c6, U+51c9, U+51cb-51cd, U+51dc-51de, U+51e1, U+51f0-51f1, U+51f6, U+51f8-51f9, U+51fd, U+5200, U+5203, U+5207-5208, U+520a, U+520e, U+5211, U+5217, U+521d, U+5224-5225, U+522a, U+522e, U+5230, U+5236-523b, U+5243, U+5247, U+524a-524c, U+5254, U+5256, U+525b, U+525d, U+5261, U+5269-526a, U+526f, U+5272, U+5275, U+527d, U+527f, U+5283, U+5287-5289, U+528d, U+5291-5292, U+529f, U+52a3-52a4, U+52a9-52ab, U+52be, U+52c1, U+52c3, U+52c5, U+52c7, U+52c9, U+52cd, U+52d2, U+52d6, U+52d8-52d9, U+52db, U+52dd-52df, U+52e2-52e4, U+52f3, U+52f5, U+52f8, U+52fa-52fb, U+52fe-52ff, U+5305, U+5308, U+530d, U+530f-5310, U+5315, U+5319, U+5320-5321, U+5323, U+532a, U+532f, U+5339, U+533f-5341, U+5343-5344, U+5347-534a, U+534d, U+5351-5354, U+535a, U+535c, U+535e, U+5360, U+5366, U+5368, U+536f-5371, U+5374-5375, U+5377, U+537d, U+537f, U+5384, U+5393, U+5398;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-092.woff2") format('woff2');
|
||||
unicode-range: U+4f43, U+4f46-4f48, U+4f4d-4f51, U+4f55, U+4f59-4f5a, U+4f69, U+4f6f-4f70, U+4f73, U+4f76, U+4f7a, U+4f7e-4f7f, U+4f81, U+4f83-4f84, U+4f86, U+4f88, U+4f8a-4f8b, U+4f8d, U+4f8f, U+4f91, U+4f96, U+4f98, U+4f9b, U+4f9d, U+4fae-4faf, U+4fb5-4fb6, U+4fbf, U+4fc2-4fc4, U+4fc9-4fca, U+4fce, U+4fd1, U+4fd3-4fd4, U+4fd7, U+4fda, U+4fdf-4fe0, U+4fee-4fef, U+4ff1, U+4ff3, U+4ff5, U+4ff8, U+4ffa, U+5002, U+5006, U+5009, U+500b, U+500d, U+5011-5012, U+5016, U+5019-501a, U+501c, U+501e-501f, U+5021, U+5023-5024, U+5026-5028, U+502a-502d, U+503b, U+5043, U+5047-5049, U+504f, U+5055, U+505a, U+505c, U+5065, U+5074-5076, U+5078, U+5080, U+5085, U+508d, U+5091, U+5098-5099, U+50ac-50ad, U+50b2-50b3, U+50b5, U+50b7, U+50be, U+50c5, U+50c9-50ca, U+50d1, U+50d5-50d6, U+50da, U+50de, U+50e5, U+50e7, U+50ed, U+50f9, U+50fb, U+50ff-5101, U+5104, U+5106, U+5109, U+5112, U+511f, U+5121, U+512a, U+5132, U+5137, U+513a, U+513c, U+5140-5141, U+5143-5148, U+514b-514e, U+5152, U+515c, U+5162, U+5169-516b, U+516d;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-093.woff2") format('woff2');
|
||||
unicode-range: U+338c-339c, U+339f-33a0, U+33a2-33cb, U+33cf-33d0, U+33d3, U+33d6, U+33d8, U+33db-33dd, U+4e01, U+4e03, U+4e07-4e08, U+4e11, U+4e14-4e15, U+4e18-4e19, U+4e1e, U+4e32, U+4e38-4e39, U+4e42-4e43, U+4e45, U+4e4d-4e4f, U+4e56, U+4e58-4e59, U+4e5d-4e5e, U+4e6b, U+4e6d, U+4e73, U+4e76-4e77, U+4e7e, U+4e82, U+4e86, U+4e88, U+4e8e, U+4e90-4e92, U+4e94-4e95, U+4e98, U+4e9b, U+4e9e, U+4ea1-4ea2, U+4ea4-4ea6, U+4ea8, U+4eab, U+4ead-4eae, U+4eb6, U+4ec0-4ec1, U+4ec4, U+4ec7, U+4ecb, U+4ecd, U+4ed4-4ed5, U+4ed7-4ed9, U+4edd, U+4edf, U+4ee4, U+4ef0, U+4ef2, U+4ef6-4ef7, U+4efb, U+4f01, U+4f09, U+4f0b, U+4f0d-4f11, U+4f2f, U+4f34, U+4f36, U+4f38, U+4f3a, U+4f3c-4f3d;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-094.woff2") format('woff2');
|
||||
unicode-range: U+3136, U+3138, U+313a-3140, U+3143-3144, U+3150, U+3152, U+3154-3156, U+3158-315b, U+315d-315f, U+3162, U+3164-318c, U+318e, U+3200-321b, U+3231, U+3239, U+3251-325a, U+3260-327b, U+327e-327f, U+328a-3290, U+3294, U+329e, U+32a5, U+3380-3384, U+3388-338b;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-095.woff2") format('woff2');
|
||||
unicode-range: U+2f7d, U+2f7f-2f8b, U+2f8e-2f90, U+2f92-2f97, U+2f99-2fa0, U+2fa2-2fa3, U+2fa5-2fa9, U+2fac-2fb1, U+2fb3-2fbc, U+2fc1-2fca, U+2fcd-2fd4, U+3003, U+3012-3019, U+301c, U+301e-3020, U+3036, U+3041, U+3043, U+3045, U+3047, U+3049, U+304e, U+3050, U+3052, U+3056, U+305a, U+305c, U+305e, U+3062, U+3065, U+306c, U+3070-307d, U+3080, U+3085, U+3087, U+308e, U+3090-3091, U+30a1, U+30a5, U+30a9, U+30ae, U+30b1-30b2, U+30b4, U+30b6, U+30bc-30be, U+30c2, U+30c5, U+30cc, U+30d2, U+30d4, U+30d8-30dd, U+30e4, U+30e6, U+30e8, U+30ee, U+30f0-30f2, U+30f4-30f6, U+3133, U+3135;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-096.woff2") format('woff2');
|
||||
unicode-range: U+2541-254b, U+25a4-25a9, U+25b1, U+25b5, U+25b9, U+25bf, U+25c1, U+25c3, U+25c9-25ca, U+25cc, U+25ce, U+25d0-25d1, U+25e6, U+25ef, U+260f, U+261d, U+261f, U+262f, U+2660, U+2664, U+2667-2669, U+266d, U+266f, U+2716, U+271a, U+273d, U+2756, U+2776-277f, U+278a-2793, U+2963, U+2965, U+2ac5-2ac6, U+2acb-2acc, U+2f00, U+2f04, U+2f06, U+2f08, U+2f0a-2f0b, U+2f11-2f12, U+2f14, U+2f17-2f18, U+2f1c-2f1d, U+2f1f-2f20, U+2f23-2f26, U+2f28-2f29, U+2f2b, U+2f2d, U+2f2f-2f32, U+2f38, U+2f3c-2f40, U+2f42-2f4c, U+2f4f-2f52, U+2f54-2f58, U+2f5a-2f66, U+2f69-2f70, U+2f72-2f76, U+2f78, U+2f7a-2f7c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-097.woff2") format('woff2');
|
||||
unicode-range: U+2479-2487, U+249c-24d1, U+24d3-24d7, U+24d9-24e9, U+24eb-24f4, U+2500-2501, U+2503, U+250c-2513, U+2515-2516, U+2518-2540;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-098.woff2") format('woff2');
|
||||
unicode-range: U+215b-215e, U+2162-2169, U+2170-2179, U+2195-2199, U+21b0-21b4, U+21bc, U+21c0, U+21c4-21c5, U+21cd, U+21cf-21d4, U+21e0-21e3, U+21e6-21e9, U+2200, U+2202-2203, U+2206-2209, U+220b-220c, U+220f, U+2211, U+2213, U+221a, U+221d-2220, U+2222, U+2225-2227, U+2229-222c, U+222e, U+2234-2237, U+223d, U+2243, U+2245, U+2248, U+2250-2253, U+225a, U+2260-2262, U+2264-2267, U+226a-226b, U+226e-2273, U+2276-2277, U+2279-227b, U+2280-2287, U+228a-228b, U+2295-2297, U+22a3-22a5, U+22bb-22bc, U+22ce-22cf, U+22da-22db, U+22ee-22ef, U+2306, U+2312, U+2314, U+2467-2478;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-099.woff2") format('woff2');
|
||||
unicode-range: U+81-82, U+84, U+a2-a5, U+a7-a8, U+aa, U+ac-ad, U+b1-b3, U+b6, U+b8-ba, U+bc-be, U+c0, U+c2, U+c6-cb, U+ce-d0, U+d4, U+d8-d9, U+db-dc, U+de-df, U+e6, U+eb, U+ee-f0, U+f4, U+f7-f9, U+fb, U+fe-ff, U+111, U+126-127, U+132-133, U+138, U+13f-142, U+149-14b, U+152-153, U+166-167, U+2bc, U+2c7, U+2d0, U+2d8-2d9, U+2db-2dd, U+391-394, U+396-3a1, U+3a3-3a9, U+3b2-3b6, U+3b8, U+3bc, U+3be-3c1, U+3c3-3c9, U+2010, U+2015-2016, U+2018-2019, U+201b, U+201f-2021, U+2025, U+2030, U+2033-2036, U+203c, U+203e, U+2042, U+2074, U+207a-207f, U+2081-2084, U+2109, U+2113, U+2116, U+2121, U+2126, U+212b, U+2153-2154;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-100.woff2") format('woff2');
|
||||
unicode-range: U+e8, U+2da, U+2160, U+2194, U+3054, U+3058, U+306d, U+3086, U+308d, U+30ac, U+30bb, U+30c4, U+30cd-30ce, U+30e2, U+3132, U+3146, U+3149, U+339d, U+4e3b, U+4f0a, U+4fdd, U+4fe1, U+5409, U+540c, U+5834, U+592a-592b, U+5b9a, U+5dde, U+5e0c, U+5e73, U+5f0f, U+60f3, U+653f, U+661f, U+662f, U+667a, U+683c, U+6b4c, U+6c11, U+767c, U+76ee, U+76f4, U+77f3, U+79d1, U+7a7a, U+7b2c, U+7d22, U+8207, U+8a00, U+8a71, U+9280, U+9580, U+958b, U+96c6, U+9762, U+98df, U+9ed1, U+ac2d, U+adc8, U+add3, U+af48, U+b014, U+b134-b135, U+b158, U+b2aa, U+b35f, U+b6a4, U+b9cf, U+bb63, U+bd23, U+be91, U+c29b, U+c3f4, U+c42c, U+c55c, U+c573, U+c58f, U+c78c, U+c7dd, U+c8f5, U+cad1, U+cc48, U+cf10, U+cf20, U+d03c, U+d07d, U+d2a0, U+d30e, U+d38d, U+d3a8, U+d3c8, U+d5e5, U+d5f9, U+d6e4, U+f90a, U+ff02, U+ff1c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-101.woff2") format('woff2');
|
||||
unicode-range: U+3b1, U+2466, U+25a1, U+25a3, U+261c, U+3008-3009, U+305b, U+305d, U+3069, U+30a7, U+30ba, U+30cf, U+30ef, U+3151, U+3157, U+4e4b, U+4e5f, U+4e8c, U+4eca, U+4ed6, U+4f5b, U+50cf, U+5149, U+5165, U+5171, U+5229, U+529b, U+5316, U+539f, U+53f2, U+571f, U+5728, U+58eb, U+591c, U+5b78, U+5c11, U+5c55, U+5ddd, U+5e02, U+5fb7, U+60c5, U+610f, U+611f, U+6625, U+66f8, U+6797, U+679c, U+682a, U+6d2a, U+706b, U+7406, U+767b, U+76f8, U+77e5, U+7acb, U+898b, U+8a69, U+8def, U+8fd1, U+901a, U+90e8, U+91cd, U+975e, U+ae14, U+ae6c, U+aec0, U+afc7, U+afc9, U+b01c, U+b028, U+b308, U+b311, U+b314, U+b31c, U+b524, U+b560, U+b764, U+b920, U+b9e3, U+bd48, U+be7d, U+c0db, U+c231, U+c270, U+c2e3, U+c37d, U+c3ed, U+c530, U+c6a5, U+c6dc, U+c7a4, U+c954, U+c974, U+d000, U+d565, U+d667, U+d6c5, U+d79d, U+ff1e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-102.woff2") format('woff2');
|
||||
unicode-range: U+131, U+2032, U+2465, U+2642, U+3048, U+3051, U+3083-3084, U+308f, U+30c0, U+30d1, U+30d3, U+30d6, U+30df, U+30e7, U+3153, U+4e16, U+4e8b, U+4ee5, U+5206, U+52a0, U+52d5, U+53e4, U+53ef, U+54c1, U+57ce, U+597d, U+5b8c, U+5ea6, U+5f8c, U+5f97, U+6210, U+6240, U+624b, U+6728, U+6bd4, U+7236, U+7269, U+7279, U+738b, U+7528, U+7530, U+767e, U+798f, U+8005, U+8a18, U+90fd, U+91cc, U+9577, U+9593, U+98a8, U+ac20, U+acf6, U+ad90, U+af5d, U+af80, U+afcd, U+aff0, U+b0a1, U+b0b5, U+b1fd, U+b2fc, U+b380, U+b51b, U+b584, U+b5b3, U+b8fd, U+b93c, U+b9f4, U+bb44, U+bc08, U+bc27, U+bc49, U+be55, U+be64, U+bfb0, U+bfc5, U+c178, U+c21f, U+c314, U+c4f1, U+c58d, U+c664, U+c698, U+c6a7, U+c6c1, U+c9ed, U+cac0, U+cacc, U+cad9, U+ccb5, U+cdcc, U+d0e4, U+d143, U+d320, U+d330, U+d54d, U+ff06, U+ff1f, U+ff5e;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-103.woff2") format('woff2');
|
||||
unicode-range: U+b4, U+20a9, U+20ac, U+2190, U+24d8, U+2502, U+2514, U+2592, U+25c7-25c8, U+2663, U+3060, U+3064, U+3081, U+3088, U+30a3, U+30a6, U+30aa, U+30b5, U+30c7, U+30ca-30cb, U+30d0, U+30e3, U+30e5, U+339e, U+4e09, U+4eac, U+4f5c, U+5167-5168, U+516c, U+51fa, U+5408, U+540d, U+591a, U+5b57, U+6211, U+65b9, U+660e, U+6642, U+6700, U+6b63, U+6e2f, U+7063, U+7532, U+793e, U+81ea, U+8272, U+82b1, U+897f, U+8eca, U+91ce, U+ac38, U+ad76, U+ae84, U+aecc, U+b07d, U+b0b1, U+b215, U+b2a0, U+b310, U+b3d7, U+b52a, U+b618, U+b775, U+b797, U+bcd5, U+bd59, U+be80, U+bea8, U+bed1, U+bee4-bee5, U+c060, U+c2ef, U+c329, U+c3dc, U+c597, U+c5bd, U+c5e5, U+c69c, U+c9d6, U+ca29, U+ca5c, U+ca84, U+cc39, U+cc3b, U+ce89, U+cee5, U+cf65, U+cf85, U+d058, U+d145, U+d22d, U+d325, U+d37d, U+d3ad, U+d769, U+ff0c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-104.woff2") format('woff2');
|
||||
unicode-range: U+2161, U+2228, U+2299, U+2464, U+2517, U+2640, U+3042, U+304a, U+3053, U+3061, U+307f, U+3082, U+308c, U+3092, U+30a8, U+30ab, U+30ad, U+30b0, U+30b3, U+30b7, U+30c1, U+30c6, U+30c9, U+30d5, U+30d7, U+30de, U+30e0-30e1, U+30ec-30ed, U+4e0b, U+4e0d, U+4ee3, U+53f0, U+548c, U+5b89, U+5bb6, U+5c0f, U+611b, U+6771, U+6aa2, U+6bcd, U+6c34, U+6cd5, U+6d77, U+767d, U+795e, U+8ecd, U+9999, U+9ad8, U+ac07, U+ac1a, U+ac40, U+ad0c, U+ad88, U+ada4, U+ae01, U+ae65, U+aebd, U+aec4, U+afe8, U+b139, U+b205, U+b383, U+b38c, U+b42c, U+b461, U+b55c, U+b78f, U+b8fb, U+b9f7, U+bafc, U+bc99, U+bed8, U+bfcd, U+c0bf, U+c0f9, U+c167, U+c204, U+c20f, U+c22f, U+c258, U+c298, U+c2bc, U+c388, U+c501, U+c50c, U+c5b9, U+c5ce, U+c641, U+c648, U+c73d, U+ca50, U+ca61, U+cc4c, U+ceac, U+d0d4, U+d5f7, U+d6d7, U+ff1a;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-105.woff2") format('woff2');
|
||||
unicode-range: U+2103, U+2463, U+25c6, U+25cb, U+266c, U+3001, U+300a, U+3046, U+304c-304d, U+304f, U+3055, U+3059, U+3063, U+3066-3068, U+306f, U+3089, U+30b8, U+30bf, U+314f, U+4e0a, U+570b, U+5730, U+5916, U+5929, U+5c71, U+5e74, U+5fc3, U+601d, U+6027, U+63d0, U+6709, U+6734, U+751f, U+7684, U+82f1, U+9053, U+91d1, U+97f3, U+ac2f, U+ac4d, U+adc4, U+ade4, U+ae41, U+ae4d-ae4e, U+aed1, U+afb9, U+b0e0, U+b299, U+b365, U+b46c, U+b480, U+b4c8, U+b7b4, U+b819, U+b918, U+baab, U+bab9, U+be8f, U+bed7, U+c0ec, U+c19f, U+c1a5, U+c3d9, U+c464, U+c53d, U+c553, U+c570, U+c5cc, U+c633, U+c6a4, U+c7a3, U+c7a6, U+c886, U+c9d9-c9da, U+c9ec, U+ca0c, U+cc21, U+cd1b, U+cd78, U+cdc4, U+cef8, U+cfe4, U+d0a5, U+d0b5, U+d0ec, U+d15d, U+d188, U+d23c, U+d2ac, U+d729, U+d79b, U+ff01, U+ff08-ff09, U+ff5c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-106.woff2") format('woff2');
|
||||
unicode-range: U+2039-203a, U+223c, U+25b3, U+25b7, U+25bd, U+25cf, U+266a, U+3002, U+300b, U+304b, U+3057, U+305f, U+306a-306b, U+307e, U+308a-308b, U+3093, U+30a2, U+30af, U+30b9, U+30c3, U+30c8, U+30e9-30eb, U+33a1, U+4e00, U+524d, U+5357, U+5b50, U+7121, U+884c, U+9751, U+ac94, U+aebe, U+aecd, U+af08, U+af41, U+af49, U+b010, U+b053, U+b109, U+b11b, U+b128, U+b154, U+b291, U+b2e6, U+b301, U+b385, U+b525, U+b5b4, U+b729, U+b72f, U+b738, U+b7ff, U+b837, U+b975, U+ba67, U+bb47, U+bc1f, U+bd90, U+bfd4, U+c27c, U+c324, U+c379, U+c3e0, U+c465, U+c53b, U+c58c, U+c610, U+c653, U+c6cd, U+c813, U+c82f, U+c999, U+c9e0, U+cac4, U+cad3, U+cbd4, U+cc10, U+cc22, U+ccb8, U+ccbc, U+cda5, U+ce84, U+cea3, U+cf67, U+cfe1, U+d241, U+d30d, U+d31c, U+d391, U+d401, U+d479, U+d5c9, U+d5db, U+d649, U+d6d4;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-107.woff2") format('woff2');
|
||||
unicode-range: U+b0, U+e9, U+2193, U+2462, U+260e, U+261e, U+300e-300f, U+3044, U+30a4, U+30fb-30fc, U+314d, U+5973, U+6545, U+6708, U+7537, U+ac89, U+ac9c, U+acc1, U+ad04, U+ad75, U+ad7d, U+ae45, U+ae61, U+af42, U+b0ab, U+b0af, U+b0b3, U+b12c, U+b194, U+b1a8, U+b220, U+b258, U+b284, U+b2ff, U+b315, U+b371, U+b3d4-b3d5, U+b460, U+b527, U+b534, U+b810, U+b818, U+b98e, U+ba55, U+bbac, U+bc0b, U+bc40, U+bca1, U+bccd, U+bd93, U+be54, U+be5a, U+bf08, U+bf50, U+bf55, U+bfdc, U+c0c0, U+c0d0, U+c0f4, U+c100, U+c11e, U+c170, U+c20d, U+c274, U+c290, U+c308, U+c369, U+c539, U+c587, U+c5ff, U+c6ec, U+c70c, U+c7ad, U+c7c8, U+c83c, U+c881, U+cb48, U+cc60, U+ce69, U+ce6b, U+ce75, U+cf04, U+cf08, U+cf55, U+cf70, U+cffc, U+d0b7, U+d1a8, U+d2c8, U+d384, U+d47c, U+d48b, U+d5dd, U+d5e8, U+d720, U+d759, U+f981;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-108.woff2") format('woff2');
|
||||
unicode-range: U+e0, U+e2, U+395, U+3b7, U+3ba, U+2460-2461, U+25a0, U+3010-3011, U+306e, U+30f3, U+314a, U+314c, U+5927, U+65b0, U+7e41, U+97d3, U+9ad4, U+ad49, U+ae0b, U+ae0d, U+ae43, U+ae5d, U+aecf, U+af3c, U+af64, U+afd4, U+b080, U+b084, U+b0c5, U+b10c, U+b1e8, U+b2ac, U+b36e, U+b451, U+b515, U+b540, U+b561, U+b6ab, U+b6b1, U+b72c, U+b730, U+b744, U+b800, U+b8ec, U+b8f0, U+b904, U+b968, U+b96d, U+b987, U+b9d9, U+bb36, U+bb49, U+bc2d, U+bc43, U+bcf6, U+bd89, U+be57, U+be61, U+bed4, U+c090, U+c130, U+c148, U+c19c, U+c2f9, U+c36c, U+c37c, U+c384, U+c3df, U+c575, U+c584, U+c660, U+c719, U+c816, U+ca4d, U+ca54, U+cabc, U+cb49, U+cc14, U+cff5, U+d004, U+d038, U+d0b4, U+d0d3, U+d0e0, U+d0ed, U+d131, U+d1b0, U+d31f, U+d33d, U+d3a0, U+d3ab, U+d514, U+d584, U+d6a1, U+d6cc, U+d749, U+d760, U+d799;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-109.woff2") format('woff2');
|
||||
unicode-range: U+24, U+60, U+3b9, U+3bb, U+3bd, U+2191, U+2606, U+300c-300d, U+3131, U+3134, U+3139, U+3141-3142, U+3148, U+3161, U+3163, U+321c, U+4eba, U+5317, U+ac31, U+ac77, U+ac9f, U+acb9, U+acf0-acf1, U+acfd, U+ad73, U+af3d, U+b00c, U+b04a, U+b057, U+b0c4, U+b188, U+b1cc, U+b214, U+b2db, U+b2ee, U+b304, U+b4ed, U+b518, U+b5bc, U+b625, U+b69c-b69d, U+b7ac, U+b801, U+b86c, U+b959, U+b95c, U+b985, U+ba48, U+bb58, U+bc0c, U+bc38, U+bc85, U+bc9a, U+bf40, U+c068, U+c0bd, U+c0cc, U+c12f, U+c149, U+c1e0, U+c22b, U+c22d, U+c250, U+c2fc, U+c300, U+c313, U+c370, U+c3d8, U+c557, U+c580, U+c5e3, U+c62e, U+c634, U+c6f0, U+c74d, U+c783, U+c78e, U+c796, U+c7bc, U+c92c, U+ca4c, U+cc1c, U+cc54, U+cc59, U+ce04, U+cf30, U+cfc4, U+d140, U+d321, U+d38c, U+d399, U+d54f, U+d587, U+d5d0, U+d6e8, U+d770;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-110.woff2") format('woff2');
|
||||
unicode-range: U+d7, U+ea, U+fc, U+2192, U+25bc, U+3000, U+3137, U+3145, U+315c, U+7f8e, U+ac13, U+ac71, U+ac90, U+acb8, U+ace7, U+ad7f, U+ae50, U+aef4, U+af34, U+afbc, U+b048, U+b09a, U+b0ad, U+b0bc, U+b113, U+b125, U+b141, U+b20c, U+b2d9, U+b2ed, U+b367, U+b369, U+b374, U+b3cb, U+b4ec, U+b611, U+b760, U+b81b, U+b834, U+b8b0, U+b8e1, U+b989, U+b9d1, U+b9e1, U+b9fa, U+ba4d, U+ba78, U+bb35, U+bb54, U+bbf9, U+bc11, U+bcb3, U+bd05, U+bd95, U+bdd4, U+be10, U+bed0, U+bf51, U+c0d8, U+c232, U+c2b7, U+c2eb, U+c378, U+c500, U+c52c, U+c549, U+c568, U+c598, U+c5c9, U+c61b, U+c639, U+c67c, U+c717, U+c78a, U+c80a, U+c90c-c90d, U+c950, U+c9e7, U+cbe4, U+cca9, U+cce4, U+cdb0, U+ce78, U+ce94, U+ce98, U+cf8c, U+d018, U+d034, U+d0f1, U+d1b1, U+d280, U+d2f8, U+d338, U+d380, U+d3b4, U+d610, U+d69f, U+d6fc, U+d758;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-111.woff2") format('woff2');
|
||||
unicode-range: U+e7, U+2022, U+203b, U+25c0, U+2605, U+2661, U+3147, U+318d, U+672c, U+8a9e, U+acaa, U+acbc, U+ad1c, U+ae4a, U+ae5c, U+b044, U+b054, U+b0c8-b0c9, U+b2a6, U+b2d0, U+b35c, U+b364, U+b428, U+b454, U+b465, U+b4b7, U+b4e3, U+b51c, U+b5a1, U+b784, U+b790, U+b7ab, U+b7f4, U+b82c, U+b835, U+b8e9, U+b8f8, U+b9d8, U+b9f9, U+ba5c, U+ba64, U+babd, U+bb18, U+bb3b, U+bbff, U+bc0d, U+bc45, U+bc97, U+bcbc, U+be45, U+be75, U+be7c, U+bfcc, U+c0b6, U+c0f7, U+c14b, U+c2b4, U+c30d, U+c4f8, U+c5bb, U+c5d1, U+c5e0, U+c5ee, U+c5fd, U+c606, U+c6c5, U+c6e0, U+c708, U+c81d, U+c820, U+c824, U+c878, U+c918, U+c96c, U+c9e4, U+c9f1, U+cc2e, U+cd09, U+cea1, U+cef5, U+cef7, U+cf64, U+cf69, U+cfe8, U+d035, U+d0ac, U+d230, U+d234, U+d2f4, U+d31d, U+d575, U+d578, U+d608, U+d614, U+d718, U+d751, U+d761, U+d78c, U+d790;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-112.woff2") format('woff2');
|
||||
unicode-range: U+2665, U+3160, U+4e2d, U+6587, U+65e5, U+ac12, U+ac14, U+ac16, U+ac81, U+ad34, U+ade0, U+ae54, U+aebc, U+af2c, U+afc0, U+afc8, U+b04c, U+b08c, U+b099, U+b0a9, U+b0ac, U+b0ae, U+b0b8, U+b123, U+b179, U+b2e5, U+b2f7, U+b4c0, U+b531, U+b538, U+b545, U+b550, U+b5a8, U+b6f0, U+b728, U+b73b, U+b7ad, U+b7ed, U+b809, U+b864, U+b86d, U+b871, U+b9bf, U+b9f5, U+ba40, U+ba4b, U+ba58, U+ba87, U+baac, U+bbc0, U+bc16, U+bc34, U+bd07, U+bd99, U+be59, U+bfd0, U+c058, U+c0e4, U+c0f5, U+c12d, U+c139, U+c228, U+c529, U+c5c7, U+c635, U+c637, U+c735, U+c77d, U+c787, U+c789, U+c8c4, U+c989, U+c98c, U+c9d0, U+c9d3, U+cc0c, U+cc99, U+cd0c, U+cd2c, U+cd98, U+cda4, U+ce59, U+ce60, U+ce6d, U+cea0, U+d0d0-d0d1, U+d0d5, U+d14d, U+d1a4, U+d29c, U+d2f1, U+d301, U+d39c, U+d3bc, U+d4e8, U+d540, U+d5ec, U+d640, U+d750;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-113.woff2") format('woff2');
|
||||
unicode-range: U+5e, U+25b2, U+25b6, U+314e, U+ac24, U+ace1, U+ace4, U+ae68, U+af2d, U+b0d0, U+b0e5, U+b150, U+b155, U+b193, U+b2c9, U+b2dd, U+b3c8, U+b3fc, U+b410, U+b458, U+b4dd, U+b5a0, U+b5a4, U+b5bb, U+b7b5, U+b838, U+b840, U+b86f, U+b8f9, U+b960, U+b9e5, U+bab8, U+bb50, U+bc1d, U+bc24-bc25, U+bca8, U+bcbd, U+bd04, U+bd10, U+bd24, U+be48, U+be5b, U+be68, U+c05c, U+c12c, U+c140, U+c15c, U+c168, U+c194, U+c219, U+c27d, U+c2a8, U+c2f1, U+c2f8, U+c368, U+c554-c555, U+c559, U+c564, U+c5d8, U+c5fc, U+c625, U+c65c, U+c6b1, U+c728, U+c794, U+c84c, U+c88c, U+c8e0, U+c8fd, U+c998, U+c9dd, U+cc0d, U+cc30, U+ceec, U+cf13, U+cf1c, U+cf5c, U+d050, U+d07c, U+d0a8, U+d134, U+d138, U+d154, U+d1f4, U+d2bc, U+d329, U+d32c, U+d3d0, U+d3f4, U+d3fc, U+d56b, U+d5cc, U+d600-d601, U+d639, U+d6c8, U+d754, U+d765;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-114.woff2") format('woff2');
|
||||
unicode-range: U+3c-3d, U+2026, U+24d2, U+314b, U+ac11, U+acf3, U+ad74, U+ad81, U+adf9, U+ae34, U+af43, U+afb8, U+b05d, U+b07c, U+b110, U+b118, U+b17c, U+b180, U+b18d, U+b192, U+b2cc, U+b355, U+b378, U+b4a4, U+b4ef, U+b78d, U+b799, U+b7a9, U+b7fd, U+b807, U+b80c, U+b839, U+b9b4, U+b9db, U+ba3c, U+bab0, U+bba4, U+bc94, U+be4c, U+c154, U+c1c4, U+c26c, U+c2ac, U+c2ed, U+c4f4, U+c55e, U+c561, U+c571, U+c5b5, U+c5c4, U+c654-c655, U+c695, U+c6e8, U+c6f9, U+c724, U+c751, U+c775, U+c7a0, U+c7c1, U+c874, U+c880, U+c9d5, U+c9f8, U+cabd, U+cc29, U+cc2c, U+cca8, U+ccab, U+ccd0, U+ce21, U+ce35, U+ce7c, U+ce90, U+cee8, U+cef4, U+cfe0, U+d070, U+d0b9, U+d0c1, U+d0c4, U+d0c8, U+d15c, U+d1a1, U+d2c0, U+d300, U+d314, U+d3ed, U+d478, U+d480, U+d48d, U+d508, U+d53d, U+d5e4, U+d611, U+d61c, U+d68d, U+d6a8, U+d798;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-115.woff2") format('woff2');
|
||||
unicode-range: U+23, U+25, U+5f, U+a9, U+ac08, U+ac78, U+aca8, U+acac, U+ace8, U+ad70, U+adc0, U+addc, U+b137, U+b140, U+b208, U+b290, U+b2f5, U+b3c5, U+b3cc, U+b420, U+b429, U+b529, U+b530, U+b77d, U+b79c, U+b7a8, U+b7c9, U+b7f0, U+b7fc, U+b828, U+b860, U+b9ad, U+b9c1, U+b9c9, U+b9dd-b9de, U+b9e8, U+ba38-ba39, U+babb, U+bc00, U+bc8c, U+bca0, U+bca4, U+bcd1, U+bcfc, U+bd09, U+bdf0, U+be60, U+c0ad, U+c0b4, U+c0bc, U+c190, U+c1fc, U+c220, U+c288, U+c2b9, U+c2f6, U+c528, U+c545, U+c558, U+c5bc, U+c5d4, U+c600, U+c644, U+c6c0, U+c6c3, U+c721, U+c798, U+c7a1, U+c811, U+c838, U+c871, U+c904, U+c990, U+c9dc, U+cc38, U+cc44, U+cca0, U+cd1d, U+cd95, U+cda9, U+ce5c, U+cf00, U+cf58, U+d150, U+d22c, U+d305, U+d328, U+d37c, U+d3f0, U+d551, U+d5a5, U+d5c8, U+d5d8, U+d63c, U+d64d, U+d669, U+d734, U+d76c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-116.woff2") format('woff2');
|
||||
unicode-range: U+26, U+2b, U+3e, U+40, U+7e, U+ac01, U+ac19, U+ac1d, U+aca0, U+aca9, U+acb0, U+ad8c, U+ae09, U+ae38, U+ae40, U+aed8, U+b09c, U+b0a0, U+b108, U+b204, U+b298, U+b2d8, U+b2eb-b2ec, U+b2f4, U+b313, U+b358, U+b450, U+b4e0, U+b54c, U+b610, U+b780, U+b78c, U+b791, U+b8e8, U+b958, U+b974, U+b984, U+b9b0, U+b9bc-b9bd, U+b9ce, U+ba70, U+bbfc, U+bc0f, U+bc15, U+bc1b, U+bc31, U+bc95, U+bcc0, U+bcc4, U+bd81, U+bd88, U+c0c8, U+c11d, U+c13c, U+c158, U+c18d, U+c1a1, U+c21c, U+c4f0, U+c54a, U+c560, U+c5b8, U+c5c8, U+c5f4, U+c628, U+c62c, U+c678, U+c6cc, U+c808, U+c810, U+c885, U+c88b, U+c900, U+c988, U+c99d, U+c9c8, U+cc3d-cc3e, U+cc45, U+cd08, U+ce20, U+cee4, U+d074, U+d0a4, U+d0dd, U+d2b9, U+d3b8, U+d3c9, U+d488, U+d544, U+d559, U+d56d, U+d588, U+d615, U+d648, U+d655, U+d658, U+d65c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-117.woff2") format('woff2');
|
||||
unicode-range: U+d, U+48, U+7c, U+ac10, U+ac15, U+ac74, U+ac80, U+ac83, U+acc4, U+ad11, U+ad50, U+ad6d, U+adfc, U+ae00, U+ae08, U+ae4c, U+b0a8, U+b124, U+b144, U+b178, U+b274, U+b2a5, U+b2e8, U+b2f9, U+b354, U+b370, U+b418, U+b41c, U+b4f1, U+b514, U+b798, U+b808, U+b824-b825, U+b8cc, U+b978, U+b9d0, U+b9e4, U+baa9, U+bb3c, U+bc18, U+bc1c, U+bc30, U+bc84, U+bcf5, U+bcf8, U+bd84, U+be0c, U+be14, U+c0b0, U+c0c9, U+c0dd, U+c124, U+c2dd, U+c2e4, U+c2ec, U+c54c, U+c57c-c57d, U+c591, U+c5c5-c5c6, U+c5ed, U+c608, U+c640, U+c6b8, U+c6d4, U+c784, U+c7ac, U+c800-c801, U+c9c1, U+c9d1, U+cc28, U+cc98, U+cc9c, U+ccad, U+cd5c, U+cd94, U+cd9c, U+cde8, U+ce68, U+cf54, U+d0dc, U+d14c, U+d1a0, U+d1b5, U+d2f0, U+d30c, U+d310, U+d398, U+d45c, U+d50c, U+d53c, U+d560, U+d568, U+d589, U+d604, U+d6c4, U+d788;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-118.woff2") format('woff2');
|
||||
unicode-range: U+39, U+49, U+4d-4e, U+a0, U+ac04, U+ac1c, U+ac70, U+ac8c, U+acbd, U+acf5, U+acfc, U+ad00, U+ad6c, U+adf8, U+b098, U+b0b4, U+b294, U+b2c8, U+b300, U+b3c4, U+b3d9, U+b4dc, U+b4e4, U+b77c, U+b7ec, U+b85d, U+b97c, U+b9c8, U+b9cc, U+ba54, U+ba74, U+ba85, U+baa8, U+bb34, U+bb38, U+bbf8, U+bc14, U+bc29, U+bc88, U+bcf4, U+bd80, U+be44, U+c0c1, U+c11c, U+c120, U+c131, U+c138, U+c18c, U+c218, U+c2b5, U+c2e0, U+c544, U+c548, U+c5b4, U+c5d0, U+c5ec, U+c5f0, U+c601, U+c624, U+c694, U+c6a9, U+c6b0, U+c6b4, U+c6d0, U+c704, U+c720, U+c73c, U+c740, U+c744, U+c74c, U+c758, U+c77c, U+c785, U+c788, U+c790-c791, U+c7a5, U+c804, U+c815, U+c81c, U+c870, U+c8fc, U+c911, U+c9c4, U+ccb4, U+ce58, U+ce74, U+d06c, U+d0c0, U+d130, U+d2b8, U+d3ec, U+d504, U+d55c, U+d569, U+d574, U+d638, U+d654, U+d68c;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/kr-119.woff2") format('woff2');
|
||||
unicode-range: U+20-22, U+27-2a, U+2c-38, U+3a-3b, U+3f, U+41-47, U+4a-4c, U+4f-5d, U+61-7b, U+7d, U+a1, U+ab, U+ae, U+b7, U+bb, U+bf, U+2013-2014, U+201c-201d, U+2122, U+ac00, U+ace0, U+ae30, U+b2e4, U+b85c, U+b9ac, U+c0ac, U+c2a4, U+c2dc, U+c774, U+c778, U+c9c0, U+d558;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/latin-ext.woff2") format('woff2');
|
||||
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Noto Sans KR';
|
||||
font-style: normal;
|
||||
font-weight: 300 800;
|
||||
font-display: swap;
|
||||
src: url("/fonts/noto-sans-kr/latin.woff2") format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
@@ -1,9 +1,18 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
@import "./fonts.css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--font-sans: "Noto Sans", "Noto Sans KR", sans-serif;
|
||||
/* legacy KART palette */
|
||||
--color-kart-green: #1cae81;
|
||||
--color-kart-bg: #f5f5f5;
|
||||
--color-kart-soft: #fafafa;
|
||||
--color-kart-line: #e1e1e1;
|
||||
--color-kart-text: #666666;
|
||||
--color-kart-title: #191919;
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
@@ -76,6 +85,12 @@
|
||||
body { @apply bg-background text-foreground; }
|
||||
}
|
||||
|
||||
/* legacy KART home special effect (SpecialEffect.tsx) */
|
||||
.kart-petal { position: fixed; top: -10px; z-index: 1000; width: 10px; height: 10px; border-radius: 50%; opacity: 0.7; animation: kart-fall linear infinite; }
|
||||
.kart-kring { position: fixed; top: -10px; z-index: 1000; height: 130px; animation: kart-fall-kring linear infinite; }
|
||||
@keyframes kart-fall { 0% { top: -10px; } 100% { top: 100vh; } }
|
||||
@keyframes kart-fall-kring { 0% { top: -10px; } 80% { top: 100vh; } }
|
||||
|
||||
.ProseMirror img { cursor: pointer; }
|
||||
.ProseMirror .ProseMirror-selectednode img { outline: 5px solid #0ea5e9; outline-offset: -5px; }
|
||||
.ProseMirror [data-resize-container] { position: relative; display: inline-block; }
|
||||
|
||||
@@ -5,8 +5,8 @@ import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "KART",
|
||||
description: "KART 보고서 시스템",
|
||||
icons: { icon: "/favicon.ico" }
|
||||
description: "KART 설문 데이터 시각화 시스템",
|
||||
icons: { icon: "/favicon_kart.png", apple: "/favicon_kart.png" }
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
|
||||
@@ -1,40 +1,237 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { KriHeader } from "@/components/layout/KriHeader";
|
||||
import { topMenus } from "@/config/menu.data";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import type { LoginUser } from "@kri/common";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { kartMenus } from "@/config/menu.data";
|
||||
import type { KartMenuItem } from "@/config/menu.type";
|
||||
import { ProjectSelector } from "@/components/project/ProjectSelector";
|
||||
import { useProjectTitle } from "@/query/project";
|
||||
import { useProjectParamsMigration, useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { projectPagePath } from "@/lib/report-navigation";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { isExternalUser, isShareLink, REPORT_MEMBER_ROLE } from "@/types/share";
|
||||
|
||||
interface AppHeaderProps {
|
||||
menuOpen: boolean;
|
||||
showMenuButton: boolean;
|
||||
activeMenuId?: string;
|
||||
user?: LoginUser | null;
|
||||
onToggleMenu: () => void;
|
||||
onNavigate: (path: string) => void;
|
||||
user: LoginUser;
|
||||
}
|
||||
|
||||
export function AppHeader({ menuOpen, showMenuButton, activeMenuId, user, onToggleMenu, onNavigate }: AppHeaderProps) {
|
||||
/** Legacy KART Header.js: fixed GNB (64px) + title bar (80px). */
|
||||
export function AppHeader({ user }: AppHeaderProps) {
|
||||
const pathname = usePathname();
|
||||
const { auth } = useAuth();
|
||||
const external = isExternalUser(user);
|
||||
const { project } = useSelectedProject();
|
||||
useProjectParamsMigration();
|
||||
const title = useProjectTitle(project);
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
const menus = project && !(external && auth.external?.pageOnly)
|
||||
? kartMenus.filter((menu) => !menu.visible || menu.visible(user))
|
||||
: [];
|
||||
const projectTitle = project ? title : "Project Overview TOP 6";
|
||||
const canCopyUrl = !!project && user.userRole < REPORT_MEMBER_ROLE;
|
||||
const copy = useMutation({
|
||||
mutationFn: async (mode: "P" | "U") => {
|
||||
if (!project) return;
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete("projectType");
|
||||
url.searchParams.delete("pkey");
|
||||
const link = await nextApi.post<unknown>(`/share/${project.projectType}/${encodeURIComponent(project.pkey)}`, {
|
||||
realUrl: pathname + url.search + url.hash, mode,
|
||||
});
|
||||
if (!isShareLink(link)) throw new Error("공유 링크 응답을 확인해 주세요.");
|
||||
await navigator.clipboard.writeText(link.url);
|
||||
},
|
||||
onSuccess: () => window.alert("주소가 복사되었습니다."),
|
||||
onError: (error) => window.alert(apiError(error, { fallbackMessage: "주소를 복사하지 못했습니다." }).message),
|
||||
});
|
||||
|
||||
return (
|
||||
<KriHeader
|
||||
logo={<Image src="/logo.png" alt="로고" width={120} height={40} className="h-10 w-auto object-contain" priority />}
|
||||
menus={topMenus}
|
||||
activeMenuId={activeMenuId}
|
||||
menuOpen={menuOpen}
|
||||
showMenuButton={showMenuButton}
|
||||
onToggleMenu={onToggleMenu}
|
||||
onNavigate={onNavigate}
|
||||
right={
|
||||
<header className="sticky top-0 z-40">
|
||||
<nav className="bg-kart-bg px-[1.0416vw]">
|
||||
<div className="flex h-16 items-center justify-between">
|
||||
{external ? <h1><KartLogo /></h1> : <Link href="/" replace><h1><KartLogo /></h1></Link>}
|
||||
<button
|
||||
type="button"
|
||||
aria-label="메뉴 열기"
|
||||
aria-expanded={mobileOpen}
|
||||
className="min-[1301px]:hidden"
|
||||
onClick={() => setMobileOpen((open) => !open)}
|
||||
>
|
||||
<Image
|
||||
src="/images/kart/bx_menu.svg"
|
||||
alt=""
|
||||
width={24}
|
||||
height={24}
|
||||
unoptimized
|
||||
/>
|
||||
</button>
|
||||
<div className="hidden h-full items-center gap-[2.604vw] min-[1301px]:flex">
|
||||
{pathname === "/" ? (
|
||||
<p className="text-[15px] font-bold">
|
||||
안녕하세요! {user.userName}님
|
||||
</p>
|
||||
) : null}
|
||||
{project ? (
|
||||
<ul className="flex h-full items-center">
|
||||
{menus.map((menu) => (
|
||||
<li key={menu.id} className="relative">
|
||||
<GnbLink menu={menu} active={pathname === menu.path} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
{!external ? <Link
|
||||
href="/logout"
|
||||
replace
|
||||
className="inline-flex h-7 w-[113px] items-center justify-center rounded-[52px] bg-kart-green text-sm leading-[17px] font-bold text-white"
|
||||
>
|
||||
Logout
|
||||
</Link> : null}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{mobileOpen ? (
|
||||
<>
|
||||
<span className="hidden text-sm text-muted-foreground sm:inline">{user?.userName ?? ""}</span>
|
||||
<Button variant="ghost" size="sm" className="gap-2" onClick={() => onNavigate("/logout")}>
|
||||
<LogOut className="size-4" />
|
||||
<span className="hidden sm:inline">로그아웃</span>
|
||||
</Button>
|
||||
<ul className="fixed top-16 right-0 z-50 w-full bg-kart-bg px-[3.076vw] py-[4.102vw] text-right min-[1301px]:hidden">
|
||||
{menus.map((menu) => (
|
||||
<li key={menu.id} className="mb-3">
|
||||
{menu.ready && project ? (
|
||||
<Link
|
||||
href={projectPagePath(menu.path)}
|
||||
className={cn(
|
||||
"text-lg font-bold text-[#9e9e9e] transition-colors hover:text-kart-green",
|
||||
pathname === menu.path && "text-kart-green",
|
||||
)}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
>
|
||||
{menu.label}
|
||||
</Link>
|
||||
) : (
|
||||
<span
|
||||
aria-disabled="true"
|
||||
title="준비 중"
|
||||
className="text-lg font-bold text-[#9e9e9e]"
|
||||
>
|
||||
{menu.label}
|
||||
</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
{!external ? <li className="mb-3">
|
||||
<Link
|
||||
href="/logout"
|
||||
replace
|
||||
className="text-lg font-bold text-[#9e9e9e] hover:text-kart-green"
|
||||
>
|
||||
Logout
|
||||
</Link>
|
||||
</li> : null}
|
||||
</ul>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="fixed inset-x-0 top-16 bottom-0 z-30 bg-black/20 min-[1301px]:hidden"
|
||||
onClick={() => setMobileOpen(false)}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
<div className="relative flex h-20 flex-col items-start border-y border-kart-line bg-white px-[1.0416vw] pt-2 max-[1300px]:h-[82px]">
|
||||
<div className="mt-[2.5px] w-[400px] max-[1300px]:w-full">
|
||||
{external ? <div className="h-8" /> : <ProjectSelector />}
|
||||
</div>
|
||||
<div className="mt-[2.5px] max-[1300px]:mt-1.5">
|
||||
<h2 className="text-xl leading-[1.28571] font-bold break-all text-kart-title max-[1300px]:text-lg">
|
||||
{projectTitle}
|
||||
</h2>
|
||||
</div>
|
||||
{canCopyUrl ? (
|
||||
<div className="absolute top-[23px] right-5 flex max-[1300px]:hidden">
|
||||
{(
|
||||
[
|
||||
["Page Copy", "ic_copy_page.svg"],
|
||||
["URL Copy", "ic_copy_url.svg"],
|
||||
] as const
|
||||
).map(([label, icon]) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
disabled={copy.isPending}
|
||||
onClick={() => copy.mutate(label === "Page Copy" ? "P" : "U")}
|
||||
className="ml-[15px] inline-block h-7 cursor-pointer rounded-[52px] bg-kart-bg bg-size-[18px_18px] bg-position-[left_12px_center] bg-no-repeat py-1.5 pr-[14px] pl-[34px] text-sm leading-[15px] font-bold text-kart-green"
|
||||
style={{ backgroundImage: `url(/images/kart/${icon})` }}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
function KartLogo() {
|
||||
return <Image src="/images/kart/logo_kart.svg" alt="KART" width={135} height={32}
|
||||
className="mt-2 h-auto w-[135px]" unoptimized priority />;
|
||||
}
|
||||
|
||||
function GnbLink({ menu, active }: { menu: KartMenuItem; active: boolean }) {
|
||||
const content = (
|
||||
<>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute top-[34%] -left-[17px] size-5 bg-contain bg-left bg-no-repeat"
|
||||
style={{
|
||||
backgroundImage: `url(/images/kart/ic_gnb${menu.icon}_20${active ? "-1" : ""}.png)`,
|
||||
}}
|
||||
/>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute top-[34%] -left-[17px] hidden size-5 bg-contain bg-left bg-no-repeat group-hover:block"
|
||||
style={{
|
||||
backgroundImage: `url(/images/kart/ic_gnb${menu.icon}_20-1.png)`,
|
||||
}}
|
||||
/>
|
||||
{menu.label}
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"absolute right-0 bottom-[14px] -left-[17px] h-1 bg-kart-green",
|
||||
active ? "block" : "hidden group-hover:block",
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
const className = cn(
|
||||
"group relative ml-[3.125vw] block h-16 pl-2 text-center text-sm leading-[64px] font-bold text-[#444] transition-colors",
|
||||
active && "text-kart-green",
|
||||
);
|
||||
if (!menu.ready)
|
||||
return (
|
||||
<span aria-disabled="true" title="준비 중" className={className}>
|
||||
{menu.label}
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute top-[34%] -left-[17px] size-5 bg-contain bg-left bg-no-repeat"
|
||||
style={{
|
||||
backgroundImage: `url(/images/kart/ic_gnb${menu.icon}_20.png)`,
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
<Link
|
||||
href={projectPagePath(menu.path)}
|
||||
aria-current={active ? "page" : undefined}
|
||||
className={cn(className, "hover:text-kart-green")}
|
||||
>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,45 +1,60 @@
|
||||
"use client";
|
||||
|
||||
import type { Route } from "next";
|
||||
import { useMemo, useState, type ReactNode } from "react";
|
||||
import { Fragment, Suspense, useEffect, useState, type ReactNode } from "react";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { KriMainLayout } from "@/components/layout/KriMainLayout";
|
||||
import { AppHeader } from "./AppHeader";
|
||||
import { AppSidebar } from "./AppSidebar";
|
||||
import { sideMenus, topMenus } from "@/config/menu.data";
|
||||
import { sideMenus } from "@/config/menu.data";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { externalPageAllowed, isExternalUser, reportUrl } from "@/types/share";
|
||||
|
||||
export function AppMainLayout({ children }: { children: ReactNode }) {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const { auth, hydrated } = useAuth();
|
||||
const [menuOpen, setMenuOpen] = useState(true);
|
||||
|
||||
const activeMenuId = useMemo(
|
||||
() => topMenus.find((item) => item.path && (pathname === item.path || pathname.startsWith(`${item.path}/`)))?.id,
|
||||
[pathname],
|
||||
);
|
||||
|
||||
const navigate = (path: string) => router.push(path as Route);
|
||||
const external = isExternalUser(auth.user);
|
||||
const externalAllowed = !external || (!!auth.external && externalPageAllowed(auth.external, pathname));
|
||||
useEffect(() => {
|
||||
if (hydrated && !auth.user) router.replace("/logout");
|
||||
else if (hydrated && !externalAllowed)
|
||||
router.replace((auth.external ? reportUrl(auth.external.realUrl) : "/logout") as Route);
|
||||
}, [hydrated, auth.user, auth.external, externalAllowed, router]);
|
||||
const hasSidebar = sideMenus.length > 0;
|
||||
|
||||
if (!hydrated || !auth.user || !externalAllowed)
|
||||
return (
|
||||
<p
|
||||
role="status"
|
||||
className="p-8 text-center text-sm text-muted-foreground"
|
||||
>
|
||||
로그인 정보를 확인하는 중입니다.
|
||||
</p>
|
||||
);
|
||||
return (
|
||||
<KriMainLayout
|
||||
className="bg-kart-bg text-kart-text"
|
||||
sidebarOpen={hasSidebar && menuOpen}
|
||||
onSidebarOpenChange={setMenuOpen}
|
||||
header={
|
||||
<AppHeader
|
||||
menuOpen={menuOpen}
|
||||
showMenuButton={hasSidebar}
|
||||
activeMenuId={activeMenuId}
|
||||
user={auth.user}
|
||||
onToggleMenu={() => setMenuOpen((current) => !current)}
|
||||
onNavigate={navigate}
|
||||
/>
|
||||
<Suspense fallback={<div className="h-[146px] bg-kart-bg" />}>
|
||||
<AppHeader user={auth.user} />
|
||||
</Suspense>
|
||||
}
|
||||
sidebar={hasSidebar ? <AppSidebar items={sideMenus} isOpen={menuOpen} pathname={pathname} onNavigate={navigate} /> : undefined}
|
||||
sidebar={
|
||||
hasSidebar ? (
|
||||
<AppSidebar
|
||||
items={sideMenus}
|
||||
isOpen={menuOpen}
|
||||
pathname={pathname}
|
||||
onNavigate={(path) => router.push(path as Route)}
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
mainClassName="bg-kart-bg px-[1.0416vw] pt-2.5 pb-6"
|
||||
>
|
||||
{children}
|
||||
<Fragment key={auth.user.userId + ":" + auth.user.userRole}>{children}</Fragment>
|
||||
</KriMainLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,23 @@
|
||||
import { useAtomValue } from "jotai";
|
||||
import { KriLoadingOverlay, type KriLoadingOverlayProps } from "@/components/common/KriLoadingOverlay";
|
||||
import { loadingAtom } from "@/store/jotai/loading";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type LoadingOverlayAdapterProps = Omit<KriLoadingOverlayProps, "open"> & { force?: boolean };
|
||||
|
||||
export function LoadingOverlayAdapter({ force = false, ...props }: LoadingOverlayAdapterProps) {
|
||||
// Legacy KART loading: blurred page with the 200px loading.gif instead of the spinner.
|
||||
const legacyOverlay = "bg-transparent backdrop-blur-[5px]";
|
||||
const legacyIndicator =
|
||||
"size-[200px] animate-none rounded-none border-0 bg-[url(/images/kart/loading.gif)] bg-contain bg-center bg-no-repeat";
|
||||
|
||||
export function LoadingOverlayAdapter({ force = false, className, spinnerClassName, ...props }: LoadingOverlayAdapterProps) {
|
||||
const open = useAtomValue(loadingAtom);
|
||||
return <KriLoadingOverlay open={force || open} {...props} />;
|
||||
return (
|
||||
<KriLoadingOverlay
|
||||
open={force || open}
|
||||
className={cn(legacyOverlay, className)}
|
||||
spinnerClassName={cn(legacyIndicator, spinnerClassName)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
147
src/components/chart/BaseEChart.tsx
Normal file
147
src/components/chart/BaseEChart.tsx
Normal file
@@ -0,0 +1,147 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import type { ComponentType, CSSProperties } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { CHART_HEIGHTS } from './chart.config'
|
||||
import { useResizeKey } from './useResizeKey'
|
||||
|
||||
type EChartsSeries = NonNullable<EChartsOption['series']>
|
||||
type ReactEChartsProps = {
|
||||
option: EChartsOption
|
||||
className?: string
|
||||
style?: CSSProperties
|
||||
notMerge?: boolean
|
||||
lazyUpdate?: boolean
|
||||
onEvents?: Record<string, (params: unknown) => void>
|
||||
}
|
||||
|
||||
export type BaseEChartProps = {
|
||||
option: EChartsOption
|
||||
height?: number | string
|
||||
className?: string
|
||||
contentClassName?: string
|
||||
chartClassName?: string
|
||||
style?: CSSProperties
|
||||
contentStyle?: CSSProperties
|
||||
chartStyle?: CSSProperties
|
||||
notMerge?: boolean
|
||||
lazyUpdate?: boolean
|
||||
onEvents?: Record<string, (params: unknown) => void>
|
||||
resizeDebounceMs?: number
|
||||
normalizeValues?: boolean
|
||||
decimalPlaces?: number
|
||||
}
|
||||
|
||||
const roundNumber = (value: number, decimalPlaces: number) => {
|
||||
const factor = 10 ** decimalPlaces
|
||||
return Math.round((value + Number.EPSILON) * factor) / factor
|
||||
}
|
||||
|
||||
const normalizeDataValue = (value: unknown, decimalPlaces: number): unknown => {
|
||||
if (typeof value === 'number') {
|
||||
return roundNumber(value, decimalPlaces)
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((item) => normalizeDataValue(item, decimalPlaces))
|
||||
}
|
||||
|
||||
if (value && typeof value === 'object' && 'value' in value) {
|
||||
const dataItem = value as Record<string, unknown>
|
||||
|
||||
return {
|
||||
...dataItem,
|
||||
value: normalizeDataValue(dataItem.value, decimalPlaces),
|
||||
}
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
const normalizeSeries = (
|
||||
series: EChartsOption['series'] | undefined,
|
||||
decimalPlaces: number,
|
||||
): EChartsOption['series'] => {
|
||||
if (!series) return series
|
||||
|
||||
const normalizeOne = (seriesOption: EChartsSeries): EChartsSeries => {
|
||||
const candidate = seriesOption as Record<string, unknown>
|
||||
const data = candidate.data
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
return seriesOption
|
||||
}
|
||||
|
||||
return {
|
||||
...candidate,
|
||||
data: data.map((value) => normalizeDataValue(value, decimalPlaces)),
|
||||
} as EChartsSeries
|
||||
}
|
||||
|
||||
return (Array.isArray(series) ? series.map((item) => normalizeOne(item as EChartsSeries)) : normalizeOne(series)) as EChartsOption['series']
|
||||
}
|
||||
|
||||
export function BaseEChart({
|
||||
option,
|
||||
height = CHART_HEIGHTS.DEFAULT,
|
||||
className,
|
||||
contentClassName,
|
||||
chartClassName,
|
||||
style,
|
||||
contentStyle,
|
||||
chartStyle,
|
||||
notMerge = true,
|
||||
lazyUpdate = false,
|
||||
onEvents,
|
||||
resizeDebounceMs = 150,
|
||||
normalizeValues = true,
|
||||
decimalPlaces = 2,
|
||||
}: BaseEChartProps) {
|
||||
const resizeKey = useResizeKey(resizeDebounceMs)
|
||||
const [ReactECharts, setReactECharts] = useState<ComponentType<ReactEChartsProps> | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
|
||||
void import('echarts-for-react').then((module) => {
|
||||
if (!cancelled) {
|
||||
setReactECharts(() => module.default as ComponentType<ReactEChartsProps>)
|
||||
}
|
||||
})
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [])
|
||||
|
||||
const normalizedOption = useMemo<EChartsOption>(() => {
|
||||
if (!normalizeValues) return option
|
||||
|
||||
return {
|
||||
...option,
|
||||
series: normalizeSeries(option.series, decimalPlaces),
|
||||
}
|
||||
}, [decimalPlaces, normalizeValues, option])
|
||||
|
||||
return (
|
||||
<div className={className} style={{ display: 'flex', flexDirection: 'column', height, ...style }}>
|
||||
<div className={contentClassName} style={{ flex: 1, minHeight: 0, ...contentStyle }}>
|
||||
{ReactECharts ? (
|
||||
<ReactECharts
|
||||
key={resizeKey}
|
||||
option={normalizedOption}
|
||||
className={chartClassName}
|
||||
style={{ width: '100%', height: '100%', ...chartStyle }}
|
||||
notMerge={notMerge}
|
||||
lazyUpdate={lazyUpdate}
|
||||
onEvents={onEvents}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BaseEChart
|
||||
59
src/components/chart/KriBarChart.tsx
Normal file
59
src/components/chart/KriBarChart.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { BaseEChart } from './BaseEChart'
|
||||
import type { KriCartesianChartProps } from './chart.types'
|
||||
import { defaultGrid, defaultLegend, mergeChartOptions, mergeObjectOption } from './chart.utils'
|
||||
|
||||
export type KriBarChartProps = KriCartesianChartProps & {
|
||||
isHorizontal?: boolean
|
||||
barWidth?: number | string
|
||||
barMaxWidth?: number | string
|
||||
}
|
||||
|
||||
export function KriBarChart({
|
||||
categories,
|
||||
series,
|
||||
isHorizontal = false,
|
||||
barWidth,
|
||||
barMaxWidth,
|
||||
title,
|
||||
legend,
|
||||
tooltip,
|
||||
grid,
|
||||
xAxis,
|
||||
yAxis,
|
||||
option,
|
||||
...baseChartProps
|
||||
}: KriBarChartProps) {
|
||||
const chartOption = useMemo<EChartsOption>(() => {
|
||||
const categoryAxis = { type: 'category', data: categories }
|
||||
const valueAxis = { type: 'value' }
|
||||
const generated: EChartsOption = {
|
||||
title,
|
||||
tooltip: tooltip ?? { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
||||
legend: legend ?? defaultLegend(series.length),
|
||||
grid: grid ?? defaultGrid(series.length),
|
||||
xAxis: mergeObjectOption(isHorizontal ? valueAxis : categoryAxis, xAxis) as EChartsOption['xAxis'],
|
||||
yAxis: mergeObjectOption(isHorizontal ? categoryAxis : valueAxis, yAxis) as EChartsOption['yAxis'],
|
||||
series: series.map((item) => ({
|
||||
type: 'bar',
|
||||
name: item.name,
|
||||
data: item.data,
|
||||
...(barWidth ? { barWidth } : {}),
|
||||
...(barMaxWidth ? { barMaxWidth } : {}),
|
||||
...(item.color ? { color: item.color } : {}),
|
||||
...item.option,
|
||||
})) as EChartsOption['series'],
|
||||
}
|
||||
|
||||
return mergeChartOptions(generated, option)
|
||||
}, [barMaxWidth, barWidth, categories, grid, isHorizontal, legend, option, series, title, tooltip, xAxis, yAxis])
|
||||
|
||||
return <BaseEChart option={chartOption} {...baseChartProps} />
|
||||
}
|
||||
|
||||
export default KriBarChart
|
||||
|
||||
58
src/components/chart/KriLineChart.tsx
Normal file
58
src/components/chart/KriLineChart.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { BaseEChart } from './BaseEChart'
|
||||
import type { KriCartesianChartProps } from './chart.types'
|
||||
import { defaultGrid, defaultLegend, mergeChartOptions, mergeObjectOption } from './chart.utils'
|
||||
|
||||
export type KriLineChartProps = KriCartesianChartProps & {
|
||||
smooth?: boolean
|
||||
area?: boolean
|
||||
showSymbol?: boolean
|
||||
}
|
||||
|
||||
export function KriLineChart({
|
||||
categories,
|
||||
series,
|
||||
smooth = false,
|
||||
area = false,
|
||||
showSymbol = true,
|
||||
title,
|
||||
legend,
|
||||
tooltip,
|
||||
grid,
|
||||
xAxis,
|
||||
yAxis,
|
||||
option,
|
||||
...baseChartProps
|
||||
}: KriLineChartProps) {
|
||||
const chartOption = useMemo<EChartsOption>(() => {
|
||||
const generated: EChartsOption = {
|
||||
title,
|
||||
tooltip: tooltip ?? { trigger: 'axis' },
|
||||
legend: legend ?? defaultLegend(series.length),
|
||||
grid: grid ?? defaultGrid(series.length),
|
||||
xAxis: mergeObjectOption({ type: 'category', data: categories, boundaryGap: false }, xAxis) as EChartsOption['xAxis'],
|
||||
yAxis: mergeObjectOption({ type: 'value' }, yAxis) as EChartsOption['yAxis'],
|
||||
series: series.map((item) => ({
|
||||
type: 'line',
|
||||
name: item.name,
|
||||
data: item.data,
|
||||
smooth,
|
||||
showSymbol,
|
||||
...(area ? { areaStyle: {} } : {}),
|
||||
...(item.color ? { color: item.color } : {}),
|
||||
...item.option,
|
||||
})) as EChartsOption['series'],
|
||||
}
|
||||
|
||||
return mergeChartOptions(generated, option)
|
||||
}, [area, categories, grid, legend, option, series, showSymbol, smooth, title, tooltip, xAxis, yAxis])
|
||||
|
||||
return <BaseEChart option={chartOption} {...baseChartProps} />
|
||||
}
|
||||
|
||||
export default KriLineChart
|
||||
|
||||
50
src/components/chart/KriPieChart.tsx
Normal file
50
src/components/chart/KriPieChart.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { BaseEChart } from './BaseEChart'
|
||||
import type { KriChartBaseProps, KriPieChartSeries } from './chart.types'
|
||||
import { defaultLegend, mergeChartOptions } from './chart.utils'
|
||||
|
||||
export type KriPieChartProps = KriChartBaseProps & {
|
||||
series: KriPieChartSeries[]
|
||||
}
|
||||
|
||||
const getPieCenter = (index: number, count: number) => {
|
||||
if (count === 1) return ['50%', '55%']
|
||||
|
||||
return [`${((index + 0.5) / count) * 100}%`, '55%']
|
||||
}
|
||||
|
||||
export function KriPieChart({
|
||||
series,
|
||||
title,
|
||||
legend,
|
||||
tooltip,
|
||||
option,
|
||||
...baseChartProps
|
||||
}: KriPieChartProps) {
|
||||
const chartOption = useMemo<EChartsOption>(() => {
|
||||
const generated: EChartsOption = {
|
||||
title,
|
||||
tooltip: tooltip ?? { trigger: 'item' },
|
||||
legend: legend ?? defaultLegend(series.length),
|
||||
series: series.map((item, index) => ({
|
||||
type: 'pie',
|
||||
name: item.name,
|
||||
data: item.data,
|
||||
radius: item.radius ?? (series.length > 1 ? ['32%', '52%'] : '65%'),
|
||||
center: item.center ?? getPieCenter(index, series.length),
|
||||
...item.option,
|
||||
})) as EChartsOption['series'],
|
||||
}
|
||||
|
||||
return mergeChartOptions(generated, option)
|
||||
}, [legend, option, series, title, tooltip])
|
||||
|
||||
return <BaseEChart option={chartOption} {...baseChartProps} />
|
||||
}
|
||||
|
||||
export default KriPieChart
|
||||
|
||||
55
src/components/chart/KriRadarChart.tsx
Normal file
55
src/components/chart/KriRadarChart.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { BaseEChart } from './BaseEChart'
|
||||
import type { KriChartBaseProps, KriRadarChartSeries, KriRadarDataItem, KriRadarIndicator } from './chart.types'
|
||||
import { defaultLegend, mergeChartOptions, mergeObjectOption } from './chart.utils'
|
||||
|
||||
export type KriRadarChartProps = KriChartBaseProps & {
|
||||
indicators: KriRadarIndicator[]
|
||||
series: KriRadarChartSeries[]
|
||||
radar?: EChartsOption['radar']
|
||||
}
|
||||
|
||||
const normalizeRadarData = (series: KriRadarChartSeries): KriRadarDataItem[] => {
|
||||
if (series.data.every((value) => typeof value === 'number')) {
|
||||
return [{ name: series.name, value: series.data as number[] }]
|
||||
}
|
||||
|
||||
return series.data as KriRadarDataItem[]
|
||||
}
|
||||
|
||||
export function KriRadarChart({
|
||||
indicators,
|
||||
series,
|
||||
radar,
|
||||
title,
|
||||
legend,
|
||||
tooltip,
|
||||
option,
|
||||
...baseChartProps
|
||||
}: KriRadarChartProps) {
|
||||
const chartOption = useMemo<EChartsOption>(() => {
|
||||
const generated: EChartsOption = {
|
||||
title,
|
||||
tooltip: tooltip ?? { trigger: 'item' },
|
||||
legend: legend ?? defaultLegend(series.length),
|
||||
radar: mergeObjectOption({ indicator: indicators }, radar) as EChartsOption['radar'],
|
||||
series: series.map((item) => ({
|
||||
type: 'radar',
|
||||
name: item.name,
|
||||
data: normalizeRadarData(item),
|
||||
...item.option,
|
||||
})) as EChartsOption['series'],
|
||||
}
|
||||
|
||||
return mergeChartOptions(generated, option)
|
||||
}, [indicators, legend, option, radar, series, title, tooltip])
|
||||
|
||||
return <BaseEChart option={chartOption} {...baseChartProps} />
|
||||
}
|
||||
|
||||
export default KriRadarChart
|
||||
|
||||
55
src/components/chart/KriScatterChart.tsx
Normal file
55
src/components/chart/KriScatterChart.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { BaseEChart } from './BaseEChart'
|
||||
import type { KriChartBaseProps, KriScatterChartSeries } from './chart.types'
|
||||
import { defaultGrid, defaultLegend, mergeChartOptions, mergeObjectOption } from './chart.utils'
|
||||
|
||||
export type KriScatterChartProps = KriChartBaseProps & {
|
||||
series: KriScatterChartSeries[]
|
||||
grid?: EChartsOption['grid']
|
||||
xAxis?: EChartsOption['xAxis']
|
||||
yAxis?: EChartsOption['yAxis']
|
||||
symbolSize?: number | ((value: unknown, params: unknown) => number)
|
||||
}
|
||||
|
||||
export function KriScatterChart({
|
||||
series,
|
||||
grid,
|
||||
xAxis,
|
||||
yAxis,
|
||||
symbolSize,
|
||||
title,
|
||||
legend,
|
||||
tooltip,
|
||||
option,
|
||||
...baseChartProps
|
||||
}: KriScatterChartProps) {
|
||||
const chartOption = useMemo<EChartsOption>(() => {
|
||||
const generated: EChartsOption = {
|
||||
title,
|
||||
tooltip: tooltip ?? { trigger: 'item' },
|
||||
legend: legend ?? defaultLegend(series.length),
|
||||
grid: grid ?? defaultGrid(series.length),
|
||||
xAxis: mergeObjectOption({ type: 'value' }, xAxis) as EChartsOption['xAxis'],
|
||||
yAxis: mergeObjectOption({ type: 'value' }, yAxis) as EChartsOption['yAxis'],
|
||||
series: series.map((item) => ({
|
||||
type: 'scatter',
|
||||
name: item.name,
|
||||
data: item.data,
|
||||
...(symbolSize ? { symbolSize } : {}),
|
||||
...(item.color ? { color: item.color } : {}),
|
||||
...item.option,
|
||||
})) as EChartsOption['series'],
|
||||
}
|
||||
|
||||
return mergeChartOptions(generated, option)
|
||||
}, [grid, legend, option, series, symbolSize, title, tooltip, xAxis, yAxis])
|
||||
|
||||
return <BaseEChart option={chartOption} {...baseChartProps} />
|
||||
}
|
||||
|
||||
export default KriScatterChart
|
||||
|
||||
62
src/components/chart/KriStackedBarChart.tsx
Normal file
62
src/components/chart/KriStackedBarChart.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import { BaseEChart } from './BaseEChart'
|
||||
import type { KriCartesianChartProps } from './chart.types'
|
||||
import { defaultGrid, defaultLegend, mergeChartOptions, mergeObjectOption } from './chart.utils'
|
||||
|
||||
export type KriStackedBarChartProps = KriCartesianChartProps & {
|
||||
isHorizontal?: boolean
|
||||
stackName?: string
|
||||
barWidth?: number | string
|
||||
barMaxWidth?: number | string
|
||||
}
|
||||
|
||||
export function KriStackedBarChart({
|
||||
categories,
|
||||
series,
|
||||
isHorizontal = false,
|
||||
stackName = 'total',
|
||||
barWidth,
|
||||
barMaxWidth,
|
||||
title,
|
||||
legend,
|
||||
tooltip,
|
||||
grid,
|
||||
xAxis,
|
||||
yAxis,
|
||||
option,
|
||||
...baseChartProps
|
||||
}: KriStackedBarChartProps) {
|
||||
const chartOption = useMemo<EChartsOption>(() => {
|
||||
const categoryAxis = { type: 'category', data: categories }
|
||||
const valueAxis = { type: 'value' }
|
||||
const generated: EChartsOption = {
|
||||
title,
|
||||
tooltip: tooltip ?? { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
||||
legend: legend ?? defaultLegend(series.length),
|
||||
grid: grid ?? defaultGrid(series.length),
|
||||
xAxis: mergeObjectOption(isHorizontal ? valueAxis : categoryAxis, xAxis) as EChartsOption['xAxis'],
|
||||
yAxis: mergeObjectOption(isHorizontal ? categoryAxis : valueAxis, yAxis) as EChartsOption['yAxis'],
|
||||
series: series.map((item) => ({
|
||||
type: 'bar',
|
||||
name: item.name,
|
||||
data: item.data,
|
||||
stack: item.stack ?? stackName,
|
||||
...(barWidth ? { barWidth } : {}),
|
||||
...(barMaxWidth ? { barMaxWidth } : {}),
|
||||
...(item.color ? { color: item.color } : {}),
|
||||
...item.option,
|
||||
})) as EChartsOption['series'],
|
||||
}
|
||||
|
||||
return mergeChartOptions(generated, option)
|
||||
}, [barMaxWidth, barWidth, categories, grid, isHorizontal, legend, option, series, stackName, title, tooltip, xAxis, yAxis])
|
||||
|
||||
return <BaseEChart option={chartOption} {...baseChartProps} />
|
||||
}
|
||||
|
||||
export default KriStackedBarChart
|
||||
|
||||
6
src/components/chart/chart.config.ts
Normal file
6
src/components/chart/chart.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const CHART_HEIGHTS = {
|
||||
DEFAULT: 320,
|
||||
SMALL: 240,
|
||||
LARGE: 420,
|
||||
} as const
|
||||
|
||||
71
src/components/chart/chart.types.ts
Normal file
71
src/components/chart/chart.types.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
import type { BaseEChartProps } from './BaseEChart'
|
||||
|
||||
export type KriChartBaseProps = Omit<BaseEChartProps, 'option'> & {
|
||||
option?: EChartsOption
|
||||
title?: EChartsOption['title']
|
||||
legend?: EChartsOption['legend']
|
||||
tooltip?: EChartsOption['tooltip']
|
||||
}
|
||||
|
||||
export type KriCategoryValue = string | number
|
||||
|
||||
export type KriCategoryChartSeries = {
|
||||
name: string
|
||||
data: unknown[]
|
||||
color?: string
|
||||
stack?: string
|
||||
option?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type KriCartesianChartProps = KriChartBaseProps & {
|
||||
categories: KriCategoryValue[]
|
||||
series: KriCategoryChartSeries[]
|
||||
grid?: EChartsOption['grid']
|
||||
xAxis?: EChartsOption['xAxis']
|
||||
yAxis?: EChartsOption['yAxis']
|
||||
}
|
||||
|
||||
export type KriNamedChartData = {
|
||||
name: string
|
||||
value: unknown
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type KriPieChartSeries = {
|
||||
name?: string
|
||||
data: KriNamedChartData[]
|
||||
radius?: string | number | Array<string | number>
|
||||
center?: Array<string | number>
|
||||
option?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type KriRadarIndicator = {
|
||||
name: string
|
||||
max?: number
|
||||
min?: number
|
||||
color?: string
|
||||
}
|
||||
|
||||
export type KriRadarDataItem = {
|
||||
name?: string
|
||||
value: number[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type KriRadarChartSeries = {
|
||||
name: string
|
||||
data: number[] | KriRadarDataItem[]
|
||||
option?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type KriScatterDataItem = [number, number] | [string, number] | KriNamedChartData
|
||||
|
||||
export type KriScatterChartSeries = {
|
||||
name: string
|
||||
data: KriScatterDataItem[]
|
||||
color?: string
|
||||
option?: Record<string, unknown>
|
||||
}
|
||||
|
||||
34
src/components/chart/chart.utils.ts
Normal file
34
src/components/chart/chart.utils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { EChartsOption } from 'echarts'
|
||||
|
||||
export const mergeChartOptions = (generated: EChartsOption, option?: EChartsOption): EChartsOption => {
|
||||
if (!option) return generated
|
||||
|
||||
return {
|
||||
...generated,
|
||||
...option,
|
||||
series: option.series ?? generated.series,
|
||||
}
|
||||
}
|
||||
|
||||
export const mergeObjectOption = <TOption>(defaults: Record<string, unknown>, option?: TOption): TOption | Record<string, unknown> => {
|
||||
if (!option) return defaults
|
||||
if (Array.isArray(option)) return option
|
||||
if (typeof option === 'object') return { ...defaults, ...(option as Record<string, unknown>) }
|
||||
|
||||
return option
|
||||
}
|
||||
|
||||
export const defaultLegend = (seriesCount: number): EChartsOption['legend'] | undefined => {
|
||||
return seriesCount > 1 ? { top: 0 } : undefined
|
||||
}
|
||||
|
||||
export const defaultGrid = (seriesCount: number): EChartsOption['grid'] => {
|
||||
return {
|
||||
top: seriesCount > 1 ? 44 : 24,
|
||||
right: 24,
|
||||
bottom: 24,
|
||||
left: 24,
|
||||
containLabel: true,
|
||||
}
|
||||
}
|
||||
|
||||
29
src/components/chart/index.ts
Normal file
29
src/components/chart/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export { BaseEChart, default } from './BaseEChart'
|
||||
export type { BaseEChartProps } from './BaseEChart'
|
||||
export { KriBarChart } from './KriBarChart'
|
||||
export type { KriBarChartProps } from './KriBarChart'
|
||||
export { KriLineChart } from './KriLineChart'
|
||||
export type { KriLineChartProps } from './KriLineChart'
|
||||
export { KriPieChart } from './KriPieChart'
|
||||
export type { KriPieChartProps } from './KriPieChart'
|
||||
export { KriRadarChart } from './KriRadarChart'
|
||||
export type { KriRadarChartProps } from './KriRadarChart'
|
||||
export { KriScatterChart } from './KriScatterChart'
|
||||
export type { KriScatterChartProps } from './KriScatterChart'
|
||||
export { KriStackedBarChart } from './KriStackedBarChart'
|
||||
export type { KriStackedBarChartProps } from './KriStackedBarChart'
|
||||
export { CHART_HEIGHTS } from './chart.config'
|
||||
export type {
|
||||
KriCartesianChartProps,
|
||||
KriCategoryChartSeries,
|
||||
KriCategoryValue,
|
||||
KriChartBaseProps,
|
||||
KriNamedChartData,
|
||||
KriPieChartSeries,
|
||||
KriRadarChartSeries,
|
||||
KriRadarDataItem,
|
||||
KriRadarIndicator,
|
||||
KriScatterChartSeries,
|
||||
KriScatterDataItem,
|
||||
} from './chart.types'
|
||||
export { useResizeKey } from './useResizeKey'
|
||||
31
src/components/chart/useResizeKey.ts
Normal file
31
src/components/chart/useResizeKey.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export function useResizeKey(delay = 150) {
|
||||
const [resizeKey, setResizeKey] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return
|
||||
|
||||
let timer: number | undefined
|
||||
|
||||
const handleResize = () => {
|
||||
if (timer) window.clearTimeout(timer)
|
||||
|
||||
timer = window.setTimeout(() => {
|
||||
setResizeKey((key) => key + 1)
|
||||
}, delay)
|
||||
}
|
||||
|
||||
window.addEventListener('resize', handleResize)
|
||||
|
||||
return () => {
|
||||
if (timer) window.clearTimeout(timer)
|
||||
window.removeEventListener('resize', handleResize)
|
||||
}
|
||||
}, [delay])
|
||||
|
||||
return resizeKey
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export interface KriAutoCompleteBaseProps<T> {
|
||||
items: T[]
|
||||
searchable?: boolean
|
||||
searchMode?: 'filter' | 'inputOnly'
|
||||
resetScrollOnSearch?: boolean
|
||||
defaultSearchValue?: string
|
||||
onSearchValueChange?: (value: string) => void
|
||||
placeholder?: string
|
||||
@@ -56,6 +57,7 @@ export function KriMultiSelect<T = unknown>({
|
||||
onChange,
|
||||
searchable = true,
|
||||
searchMode = 'filter',
|
||||
resetScrollOnSearch = false,
|
||||
defaultSearchValue = '',
|
||||
onSearchValueChange,
|
||||
maxCount = 1,
|
||||
@@ -96,6 +98,7 @@ export function KriMultiSelect<T = unknown>({
|
||||
badgeClassName={badgeClassName}
|
||||
searchable={searchable}
|
||||
searchMode={searchMode}
|
||||
resetScrollOnSearch={resetScrollOnSearch}
|
||||
defaultSearchValue={defaultSearchValue}
|
||||
onSearchValueChange={onSearchValueChange}
|
||||
maxCount={maxCount}
|
||||
@@ -131,6 +134,7 @@ function KriSingleSelectInner<T>({
|
||||
onChange,
|
||||
searchable = true,
|
||||
searchMode = 'filter',
|
||||
resetScrollOnSearch = false,
|
||||
defaultSearchValue = '',
|
||||
onSearchValueChange,
|
||||
placeholder = 'Select an option',
|
||||
@@ -208,6 +212,7 @@ function KriSingleSelectInner<T>({
|
||||
badgeClassName={badgeClassName}
|
||||
searchable={searchable}
|
||||
searchMode={searchMode}
|
||||
resetScrollOnSearch={resetScrollOnSearch}
|
||||
defaultSearchValue={defaultSearchValue}
|
||||
onSearchValueChange={onSearchValueChange}
|
||||
preventDeselect={preventDeselect}
|
||||
|
||||
@@ -30,6 +30,7 @@ function MultiSelectInner<T>(
|
||||
hideSelectAll = false,
|
||||
searchable = true,
|
||||
searchMode = 'filter',
|
||||
resetScrollOnSearch = false,
|
||||
defaultSearchValue = '',
|
||||
onSearchValueChange,
|
||||
emptyIndicator = '검색 결과가 없습니다.',
|
||||
@@ -199,6 +200,7 @@ function MultiSelectInner<T>(
|
||||
selectedValues={selectedValues}
|
||||
searchable={searchable}
|
||||
searchMode={searchMode}
|
||||
resetScrollOnSearch={resetScrollOnSearch}
|
||||
searchValue={searchValue}
|
||||
onSearchValueChange={handleSearchChange}
|
||||
hideSelectAll={hideSelectAll}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
import { CheckIcon } from 'lucide-react'
|
||||
import {
|
||||
Command,
|
||||
@@ -20,6 +21,7 @@ interface MultiSelectContentProps<T> {
|
||||
searchable: boolean
|
||||
searchMode: 'filter' | 'inputOnly'
|
||||
searchValue: string
|
||||
resetScrollOnSearch?: boolean
|
||||
onSearchValueChange: (value: string) => void
|
||||
hideSelectAll: boolean
|
||||
hideOptionCheck: boolean
|
||||
@@ -97,6 +99,7 @@ export function MultiSelectContent<T>({
|
||||
searchable,
|
||||
searchMode,
|
||||
searchValue,
|
||||
resetScrollOnSearch = false,
|
||||
onSearchValueChange,
|
||||
hideSelectAll,
|
||||
hideOptionCheck,
|
||||
@@ -105,6 +108,17 @@ export function MultiSelectContent<T>({
|
||||
onToggleOption,
|
||||
onToggleAll,
|
||||
}: MultiSelectContentProps<T>) {
|
||||
const listRef = React.useRef<HTMLDivElement>(null)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!resetScrollOnSearch) return
|
||||
|
||||
const frame = requestAnimationFrame(() => {
|
||||
if (listRef.current) listRef.current.scrollTop = 0
|
||||
})
|
||||
return () => cancelAnimationFrame(frame)
|
||||
}, [resetScrollOnSearch, searchValue])
|
||||
|
||||
const grouped = isGroupedOptions(options)
|
||||
const flatOptions = grouped ? options.flatMap((group) => group.options) : options
|
||||
const selectableOptions = flatOptions.filter((option) => !option.disabled)
|
||||
@@ -119,7 +133,7 @@ export function MultiSelectContent<T>({
|
||||
placeholder="검색..."
|
||||
/>
|
||||
) : null}
|
||||
<CommandList>
|
||||
<CommandList ref={listRef}>
|
||||
<CommandEmpty>{emptyIndicator}</CommandEmpty>
|
||||
{selectionMode === 'multiple' && !hideSelectAll && selectableOptions.length > 0 ? (
|
||||
<>
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface MultiSelectProps<T = unknown>
|
||||
hideSelectAll?: boolean
|
||||
searchable?: boolean
|
||||
searchMode?: 'filter' | 'inputOnly'
|
||||
resetScrollOnSearch?: boolean
|
||||
defaultSearchValue?: string
|
||||
onSearchValueChange?: (value: string) => void
|
||||
emptyIndicator?: React.ReactNode
|
||||
|
||||
553
src/components/derived/DerivedWorkspace.tsx
Normal file
553
src/components/derived/DerivedWorkspace.tsx
Normal file
@@ -0,0 +1,553 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import {
|
||||
DndContext,
|
||||
PointerSensor,
|
||||
closestCenter,
|
||||
useSensor,
|
||||
useSensors,
|
||||
type DragEndEvent,
|
||||
} from "@dnd-kit/core";
|
||||
import {
|
||||
SortableContext,
|
||||
arrayMove,
|
||||
useSortable,
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { QueryState } from "@/components/project/QueryState";
|
||||
import { FilterPopup } from "@/components/report/FilterPopup";
|
||||
import { PcOnlyNotice } from "@/components/report/ReportChrome";
|
||||
import { LegacyCheck, SquareButton, StatBox } from "@/components/report/ReportParts";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import { useDerivedListQuery, useDerivedMutations } from "@/query/derived";
|
||||
import { useQuestionQuery } from "@/query/report";
|
||||
import { projectKey, type ProjectRef } from "@/types/kart";
|
||||
import {
|
||||
DERIVED_TYPES,
|
||||
derivedFormError,
|
||||
newDerivedValue,
|
||||
readDerivedJson,
|
||||
writeVariableInfo,
|
||||
type DerivedElse,
|
||||
type DerivedType,
|
||||
type DerivedValue,
|
||||
type DerivedVariable,
|
||||
} from "@/types/derived";
|
||||
import {
|
||||
filterCondition,
|
||||
readFilterArray,
|
||||
realFilterCondition,
|
||||
writeFilterArray,
|
||||
type LegacyFilterLine,
|
||||
} from "@/lib/legacy-filter";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function DerivedWorkspace() {
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const { project, hydrated } = useSelectedProject();
|
||||
const missing = hydrated && !project;
|
||||
useEffect(() => {
|
||||
if (missing) router.replace("/");
|
||||
}, [missing, router]);
|
||||
if (!project) return null;
|
||||
return (
|
||||
<Workspace
|
||||
key={JSON.stringify([
|
||||
projectKey(project),
|
||||
auth.user?.userId,
|
||||
auth.user?.userRole,
|
||||
auth.user?.userTeam,
|
||||
])}
|
||||
project={project}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
type Form = {
|
||||
/** Stored id of the variable being edited; null for "New Variable". */
|
||||
originId: string | null;
|
||||
variableId: string;
|
||||
title: string;
|
||||
type: DerivedType;
|
||||
values: DerivedValue[];
|
||||
otherwise: DerivedElse;
|
||||
nextValueId: number;
|
||||
};
|
||||
|
||||
// Legacy resetSelectedVariable: Single, no values, Else shown (not Missing).
|
||||
const emptyForm = (): Form => ({
|
||||
originId: null,
|
||||
variableId: "",
|
||||
title: "",
|
||||
type: "single",
|
||||
values: [],
|
||||
otherwise: { isMissing: false, value: "", label: "" },
|
||||
nextValueId: 0,
|
||||
});
|
||||
|
||||
const errorMessage = (error: unknown, fallbackMessage: string) =>
|
||||
apiError(error, { fallbackMessage }).message;
|
||||
|
||||
/** Legacy views/Management/Derived.js: variable list, definition form, value rules and Else. */
|
||||
function Workspace({ project }: { project: ProjectRef }) {
|
||||
const variables = useDerivedListQuery(project);
|
||||
const questions = useQuestionQuery(project);
|
||||
const { save, remove } = useDerivedMutations(project);
|
||||
const [form, setForm] = useState<Form>(emptyForm);
|
||||
const [filterFor, setFilterFor] = useState<string | null>(null);
|
||||
useVisitLog("/Management/Derived", project);
|
||||
|
||||
const patch = (next: Partial<Form>) => setForm((current) => ({ ...current, ...next }));
|
||||
const updateValue = (id: string, next: Partial<DerivedValue>) =>
|
||||
setForm((current) => ({
|
||||
...current,
|
||||
values: current.values.map((row) => (row.id === id ? { ...row, ...next } : row)),
|
||||
}));
|
||||
|
||||
const selectVariable = (variable: DerivedVariable) => {
|
||||
try {
|
||||
const { values, otherwise } = readDerivedJson(variable.derivedJson);
|
||||
setForm({
|
||||
originId: variable.id,
|
||||
variableId: variable.id,
|
||||
title: variable.title,
|
||||
type: variable.type,
|
||||
values,
|
||||
otherwise,
|
||||
nextValueId: values.length,
|
||||
});
|
||||
} catch (error) {
|
||||
window.alert(errorMessage(error, "파생변수 설정을 읽을 수 없습니다."));
|
||||
}
|
||||
};
|
||||
const submit = async (asNew: boolean) => {
|
||||
const variableInfo = writeVariableInfo(form.values, form.otherwise);
|
||||
const invalid = derivedFormError({
|
||||
variableId: form.variableId,
|
||||
title: form.title,
|
||||
type: form.type,
|
||||
info: variableInfo,
|
||||
});
|
||||
if (invalid) {
|
||||
window.alert(invalid);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await save.mutateAsync({
|
||||
originId: asNew ? null : form.originId,
|
||||
request: {
|
||||
variableId: form.variableId.trim(),
|
||||
variableTitle: form.title.trim(),
|
||||
variableType: form.type,
|
||||
variableInfo,
|
||||
},
|
||||
});
|
||||
window.alert("저장되었습니다.");
|
||||
setForm(emptyForm());
|
||||
} catch (error) {
|
||||
window.alert(errorMessage(error, "파생변수를 저장하지 못했습니다."));
|
||||
}
|
||||
};
|
||||
const destroy = async (variable: DerivedVariable) => {
|
||||
if (!window.confirm("정말 삭제 하시겠습니까?")) return;
|
||||
try {
|
||||
await remove.mutateAsync(variable.id);
|
||||
window.alert("삭제되었습니다.");
|
||||
setForm(emptyForm());
|
||||
} catch (error) {
|
||||
window.alert(errorMessage(error, "파생변수를 삭제하지 못했습니다."));
|
||||
}
|
||||
};
|
||||
const editing = form.values.find((row) => row.id === filterFor);
|
||||
const editingLines = (() => {
|
||||
if (!editing) return [];
|
||||
try {
|
||||
return readFilterArray(editing.array);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
})();
|
||||
const applyFilter = (lines: LegacyFilterLine[]) => {
|
||||
if (!editing) return;
|
||||
updateValue(editing.id, {
|
||||
condition: filterCondition(lines),
|
||||
realCondition: realFilterCondition(lines),
|
||||
array: writeFilterArray(lines),
|
||||
});
|
||||
};
|
||||
|
||||
if (variables.isPending || variables.isError)
|
||||
return (
|
||||
<QueryState
|
||||
pending={variables.isPending}
|
||||
error={variables.error}
|
||||
onRetry={() => void variables.refetch()}
|
||||
/>
|
||||
);
|
||||
const numeric = form.type === "num";
|
||||
return (
|
||||
<section
|
||||
aria-label="Create Variable"
|
||||
className="-mx-[1.0416vw] -mt-2.5 -mb-6 min-h-[calc(100vh-146px)] bg-white"
|
||||
>
|
||||
<div className="hidden [@media(pointer:coarse)_and_(max-width:767px)]:block">
|
||||
<PcOnlyNotice />
|
||||
</div>
|
||||
<div className="flex items-start gap-[1.041vw] px-[1.0416vw] py-5 [@media(pointer:coarse)_and_(max-width:767px)]:hidden">
|
||||
<div className="w-[396px] shrink-0">
|
||||
<VariableList
|
||||
variables={variables.data}
|
||||
selectedId={form.originId}
|
||||
onSelect={selectVariable}
|
||||
onDelete={(variable) => void destroy(variable)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setForm(emptyForm())}
|
||||
className="ml-5 cursor-pointer bg-[url(/images/kart/ic_plus_bl.png)] bg-size-[12px_12px] bg-position-[left_top_4px] bg-no-repeat pl-4 text-sm font-bold text-kart-text"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<StatBox icon="document" title={form.originId ? "Update Variable" : "New Variable"}>
|
||||
<div className="px-4 pb-3">
|
||||
<div className="flex gap-5">
|
||||
<div>
|
||||
<FieldTitle htmlFor="derived_id">Variable Name</FieldTitle>
|
||||
<input
|
||||
id="derived_id"
|
||||
type="text"
|
||||
value={form.variableId}
|
||||
placeholder="영어, 숫자만 사용 가능"
|
||||
// Legacy: letters and digits only, never a leading digit.
|
||||
onChange={(event) =>
|
||||
patch({ variableId: event.target.value.replace(/^\d|[^\da-zA-Z]/g, "") })
|
||||
}
|
||||
className={inputClass + " w-[22.708vw] max-w-[45.8vw]"}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<FieldTitle>Type</FieldTitle>
|
||||
<div role="radiogroup" aria-label="Type" className="flex h-9 items-center gap-[1.458vw]">
|
||||
{DERIVED_TYPES.map((type) => (
|
||||
<label
|
||||
key={type.value}
|
||||
className="flex cursor-pointer items-center gap-1.5 text-sm text-kart-text"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="derived_type"
|
||||
checked={form.type === type.value}
|
||||
onChange={() => patch({ type: type.value })}
|
||||
className="size-5 shrink-0 cursor-pointer appearance-none rounded-full border-2 border-[#767676] bg-white checked:border-kart-green checked:bg-kart-green checked:shadow-[inset_0_0_0_3px_white] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kart-green"
|
||||
/>
|
||||
{type.label}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<FieldTitle htmlFor="derived_title">Title</FieldTitle>
|
||||
<input
|
||||
id="derived_title"
|
||||
type="text"
|
||||
value={form.title}
|
||||
onChange={(event) => patch({ title: event.target.value })}
|
||||
className={inputClass + " w-full max-w-[710px]"}
|
||||
/>
|
||||
</div>
|
||||
</StatBox>
|
||||
<div className="mb-4 flex h-[55px] items-center gap-2 rounded-[15px] bg-kart-green p-2.5">
|
||||
<Image
|
||||
src="/images/kart/ic_filter_36.png"
|
||||
alt=""
|
||||
width={36}
|
||||
height={36}
|
||||
className="h-[33px] w-9 object-contain"
|
||||
unoptimized
|
||||
/>
|
||||
<h3 className="text-base font-bold text-white">Value</h3>
|
||||
</div>
|
||||
<ValueRows
|
||||
values={form.values}
|
||||
numeric={numeric}
|
||||
onMove={(values) => patch({ values })}
|
||||
onChange={updateValue}
|
||||
onRemove={(id) =>
|
||||
patch({ values: form.values.filter((row) => row.id !== id) })
|
||||
}
|
||||
onSetting={setFilterFor}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
patch({
|
||||
values: [...form.values, newDerivedValue("derived_value_" + form.nextValueId)],
|
||||
nextValueId: form.nextValueId + 1,
|
||||
})
|
||||
}
|
||||
className="my-5 h-7 w-[113px] cursor-pointer rounded-[52px] bg-kart-green bg-[url(/images/kart/ic_plus_s.png)] bg-size-[12px_12px] bg-position-[left_16px_center] bg-no-repeat pl-5 text-sm font-bold text-white"
|
||||
>
|
||||
Add Value
|
||||
</button>
|
||||
<StatBox icon="document" title="Else">
|
||||
<div className="px-4 pb-3">
|
||||
<FieldTitle>Else</FieldTitle>
|
||||
<LegacyCheck
|
||||
id="chk_missing"
|
||||
label="Missing"
|
||||
checked={form.otherwise.isMissing}
|
||||
onChange={(isMissing) => patch({ otherwise: { ...form.otherwise, isMissing } })}
|
||||
/>
|
||||
{form.otherwise.isMissing ? null : (
|
||||
<div className="flex gap-2">
|
||||
<div>
|
||||
<FieldTitle htmlFor="else_value">Value</FieldTitle>
|
||||
<input
|
||||
id="else_value"
|
||||
type="text"
|
||||
value={form.otherwise.value}
|
||||
onChange={(event) =>
|
||||
patch({
|
||||
otherwise: {
|
||||
...form.otherwise,
|
||||
value: event.target.value.replace(/[^0-9]/g, ""),
|
||||
},
|
||||
})
|
||||
}
|
||||
className={inputClass + " w-[22.708vw]"}
|
||||
/>
|
||||
</div>
|
||||
{numeric ? null : (
|
||||
<div>
|
||||
<FieldTitle htmlFor="else_label">Label</FieldTitle>
|
||||
<input
|
||||
id="else_label"
|
||||
type="text"
|
||||
value={form.otherwise.label}
|
||||
onChange={(event) =>
|
||||
patch({ otherwise: { ...form.otherwise, label: event.target.value } })
|
||||
}
|
||||
className={inputClass + " w-[22.708vw]"}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</StatBox>
|
||||
<div className="flex justify-center gap-1">
|
||||
<SquareButton done disabled={save.isPending} onClick={() => void submit(false)}>
|
||||
Save
|
||||
</SquareButton>
|
||||
{form.originId ? (
|
||||
<SquareButton done={false} disabled={save.isPending} onClick={() => void submit(true)}>
|
||||
Save As
|
||||
</SquareButton>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{editing ? (
|
||||
<FilterPopup
|
||||
open
|
||||
initial={editingLines}
|
||||
questions={questions.data ?? []}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setFilterFor(null);
|
||||
}}
|
||||
onSave={applyFilter}
|
||||
/>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const inputClass =
|
||||
"h-9 rounded-[4px] border border-kart-line bg-white px-3.5 py-1 text-sm leading-[19px] font-light text-[#999] outline-none";
|
||||
|
||||
function FieldTitle({ htmlFor, children }: { htmlFor?: string; children: ReactNode }) {
|
||||
return (
|
||||
<h3 className="pt-2.5 pb-2 text-base font-bold text-kart-title">
|
||||
{htmlFor ? <label htmlFor={htmlFor}>{children}</label> : children}
|
||||
</h3>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy VariableBoxDerived: derived variables with a delete (x) after each title. */
|
||||
function VariableList({
|
||||
variables,
|
||||
selectedId,
|
||||
onSelect,
|
||||
onDelete,
|
||||
}: {
|
||||
variables: DerivedVariable[];
|
||||
selectedId: string | null;
|
||||
onSelect: (variable: DerivedVariable) => void;
|
||||
onDelete: (variable: DerivedVariable) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="mb-5 rounded-[15px] bg-white shadow-[1px_0_0_0_#e1e1e1,0_1px_0_0_#e1e1e1,1px_1px_0_0_#e1e1e1,inset_1px_0_0_0_#e1e1e1,inset_0_1px_0_0_#e1e1e1]">
|
||||
<div className="flex h-[55px] items-center gap-2 rounded-[15px] bg-kart-soft p-2.5 shadow-[1px_0_0_0_#e1e1e1,0_1px_0_0_#e1e1e1,1px_1px_0_0_#e1e1e1,inset_1px_0_0_0_#e1e1e1,inset_0_1px_0_0_#e1e1e1]">
|
||||
<Image src="/images/kart/ic_document_36-2.svg" alt="" width={36} height={36} unoptimized />
|
||||
<h3 className="text-base font-bold text-kart-title">Variable List</h3>
|
||||
</div>
|
||||
{variables.length ? (
|
||||
<ul className="px-4 pb-2">
|
||||
{variables.map((variable) => (
|
||||
<li key={variable.id} className="mt-2 flex items-center">
|
||||
<button
|
||||
type="button"
|
||||
title={variable.title}
|
||||
aria-current={variable.id === selectedId ? "true" : undefined}
|
||||
onClick={() => onSelect(variable)}
|
||||
className={cn(
|
||||
"w-[94%] cursor-pointer overflow-hidden bg-kart-bg px-3 py-2 text-left text-sm leading-5 text-ellipsis whitespace-nowrap text-kart-text",
|
||||
variable.id === selectedId && "text-kart-green",
|
||||
)}
|
||||
>
|
||||
{variable.id + ". " + variable.title}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={variable.id + " 삭제"}
|
||||
onClick={() => onDelete(variable)}
|
||||
className="ml-[7px] cursor-pointer"
|
||||
>
|
||||
<Image src="/images/kart/ic_close.png" alt="" width={12} height={12} unoptimized />
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy DerivedChild list: rows reorder by dragging (rule order decides the first match). */
|
||||
function ValueRows({
|
||||
values,
|
||||
numeric,
|
||||
onMove,
|
||||
onChange,
|
||||
onRemove,
|
||||
onSetting,
|
||||
}: {
|
||||
values: DerivedValue[];
|
||||
numeric: boolean;
|
||||
onMove: (values: DerivedValue[]) => void;
|
||||
onChange: (id: string, next: Partial<DerivedValue>) => void;
|
||||
onRemove: (id: string) => void;
|
||||
onSetting: (id: string) => void;
|
||||
}) {
|
||||
// Pointer only: the rows contain text inputs, where Space/Enter must not start a drag.
|
||||
const sensors = useSensors(
|
||||
useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
|
||||
);
|
||||
const onDragEnd = ({ active, over }: DragEndEvent) => {
|
||||
if (!over || active.id === over.id) return;
|
||||
const ids = values.map((row) => row.id);
|
||||
onMove(arrayMove(values, ids.indexOf(String(active.id)), ids.indexOf(String(over.id))));
|
||||
};
|
||||
return (
|
||||
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={onDragEnd}>
|
||||
<SortableContext items={values.map((row) => row.id)} strategy={verticalListSortingStrategy}>
|
||||
{values.map((row) => (
|
||||
<ValueRow
|
||||
key={row.id}
|
||||
row={row}
|
||||
numeric={numeric}
|
||||
onChange={(next) => onChange(row.id, next)}
|
||||
onRemove={() => onRemove(row.id)}
|
||||
onSetting={() => onSetting(row.id)}
|
||||
/>
|
||||
))}
|
||||
</SortableContext>
|
||||
</DndContext>
|
||||
);
|
||||
}
|
||||
|
||||
function ValueRow({
|
||||
row,
|
||||
numeric,
|
||||
onChange,
|
||||
onRemove,
|
||||
onSetting,
|
||||
}: {
|
||||
row: DerivedValue;
|
||||
numeric: boolean;
|
||||
onChange: (next: Partial<DerivedValue>) => void;
|
||||
onRemove: () => void;
|
||||
onSetting: () => void;
|
||||
}) {
|
||||
const { listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
||||
id: row.id,
|
||||
});
|
||||
return (
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
style={{ transform: CSS.Transform.toString(transform), transition, opacity: isDragging ? 0.4 : 1 }}
|
||||
{...listeners}
|
||||
className="mb-4 cursor-pointer rounded-[15px] border border-kart-line bg-white px-4 pb-3"
|
||||
>
|
||||
<div className="relative flex items-center pt-2.5 pb-2">
|
||||
<h3 className="text-base font-bold text-kart-title">Condition</h3>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onSetting}
|
||||
className="ml-5 h-[27px] w-[113px] cursor-pointer rounded-[52px] bg-kart-green text-sm font-bold text-white"
|
||||
>
|
||||
Setting
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="값 삭제"
|
||||
onClick={onRemove}
|
||||
className="absolute top-2 right-0 cursor-pointer"
|
||||
>
|
||||
<Image src="/images/kart/trash_icon.png" alt="" width={24} height={24} unoptimized />
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
readOnly
|
||||
aria-label="Condition"
|
||||
value={row.condition}
|
||||
className="h-9 w-full rounded-[4px] bg-kart-bg px-3.5 py-1 text-sm font-light text-[#999] outline-none"
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<div>
|
||||
<FieldTitle>Value</FieldTitle>
|
||||
<input
|
||||
type="text"
|
||||
aria-label="Value"
|
||||
value={row.value}
|
||||
onChange={(event) => onChange({ value: event.target.value.replace(/[^0-9]/g, "") })}
|
||||
className={inputClass + " w-[22.708vw]"}
|
||||
/>
|
||||
</div>
|
||||
{numeric ? null : (
|
||||
<div>
|
||||
<FieldTitle>Label</FieldTitle>
|
||||
<input
|
||||
type="text"
|
||||
aria-label="Label"
|
||||
value={row.label}
|
||||
onChange={(event) => onChange({ label: event.target.value })}
|
||||
className={inputClass + " w-[22.708vw]"}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
314
src/components/exim/EximWorkspace.tsx
Normal file
314
src/components/exim/EximWorkspace.tsx
Normal file
@@ -0,0 +1,314 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { PcOnlyNotice } from "@/components/report/ReportChrome";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import { useFileDownload, useImportFile, type Download, type ImportTarget } from "@/query/export";
|
||||
import { useProjectTitle } from "@/query/project";
|
||||
import { EXPORT_PREFIX, QUESTION_FORM_NAME } from "@/lib/download-name";
|
||||
import { projectKey, type ProjectRef } from "@/types/kart";
|
||||
import type { RawDataRequest } from "@/types/export";
|
||||
|
||||
export function EximWorkspace() {
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const { project, hydrated } = useSelectedProject();
|
||||
const missing = hydrated && !project;
|
||||
useEffect(() => {
|
||||
if (missing) router.replace("/");
|
||||
}, [missing, router]);
|
||||
if (!project) return null;
|
||||
return (
|
||||
<Workspace
|
||||
key={JSON.stringify([
|
||||
projectKey(project),
|
||||
auth.user?.userId,
|
||||
auth.user?.userRole,
|
||||
auth.user?.userTeam,
|
||||
])}
|
||||
project={project}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const failure = (error: unknown, fallbackMessage: string) =>
|
||||
window.alert(apiError(error, { fallbackMessage }).message);
|
||||
|
||||
/** Legacy views/Management/Exim.js: raw data / guide export and the three replacement imports. */
|
||||
function Workspace({ project }: { project: ProjectRef }) {
|
||||
const download = useFileDownload();
|
||||
const upload = useImportFile(project);
|
||||
const [type, setType] = useState<RawDataRequest["type"]>("COMPLETE");
|
||||
useVisitLog("/Management/Exim", project);
|
||||
const title = useProjectTitle(project);
|
||||
|
||||
const save = (target: Download, confirmText?: string) => {
|
||||
if (confirmText && !window.confirm(confirmText)) return;
|
||||
download.mutate(target, {
|
||||
onError: (error) => failure(error, "파일을 내려받지 못했습니다."),
|
||||
});
|
||||
};
|
||||
const importFile = (target: ImportTarget, file: File) =>
|
||||
upload.mutateAsync({ target, file }).then(
|
||||
(result) =>
|
||||
window.alert(
|
||||
"처리 " +
|
||||
result.processedRows +
|
||||
"건, 반영 " +
|
||||
result.affectedRows +
|
||||
"건, 삭제 " +
|
||||
result.removedRows +
|
||||
"건, 보관 " +
|
||||
result.archivedRows +
|
||||
"건",
|
||||
),
|
||||
(error: unknown) => failure(error, "파일을 올리지 못했습니다."),
|
||||
);
|
||||
|
||||
return (
|
||||
<section
|
||||
aria-label="Export/Import"
|
||||
className="-mx-[1.0416vw] -mt-2.5 -mb-6 min-h-[calc(100vh-146px)] bg-white"
|
||||
>
|
||||
<div className="hidden [@media(pointer:coarse)_and_(max-width:767px)]:block">
|
||||
<PcOnlyNotice />
|
||||
</div>
|
||||
<div className="flex items-start gap-4 px-[1.0416vw] py-5 [@media(pointer:coarse)_and_(max-width:767px)]:hidden">
|
||||
<Column icon="/images/kart/ic_export.svg" title="Export">
|
||||
<EximBox title="Data Export" info="Raw Data를 다운로드 받을 수 있습니다.">
|
||||
<div className="flex items-center gap-2">
|
||||
<h3 className="p-1 text-base font-bold text-kart-title">Type</h3>
|
||||
<div role="radiogroup" aria-label="Type" className="flex w-[180px] items-center gap-9">
|
||||
{(
|
||||
[
|
||||
["COMPLETE", "완료"],
|
||||
["INCOMPLETE", "완료 아님"],
|
||||
] as const
|
||||
).map(([value, label]) => (
|
||||
<label key={value} className="flex cursor-pointer items-center gap-1.5 text-sm text-kart-text">
|
||||
<input
|
||||
type="radio"
|
||||
name="data_type"
|
||||
checked={type === value}
|
||||
onChange={() => setType(value)}
|
||||
className="size-5 shrink-0 cursor-pointer appearance-none rounded-full border-2 border-[#767676] bg-white checked:border-kart-green checked:bg-kart-green checked:shadow-[inset_0_0_0_3px_white] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kart-green"
|
||||
/>
|
||||
{label}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<GreyButton
|
||||
icon="/images/kart/ic_exports.png"
|
||||
onClick={() =>
|
||||
save(
|
||||
{
|
||||
kind: "data",
|
||||
project,
|
||||
request: { type },
|
||||
name: {
|
||||
prefix: type === "COMPLETE" ? EXPORT_PREFIX.data : EXPORT_PREFIX.dataIncomplete,
|
||||
title,
|
||||
},
|
||||
},
|
||||
title + " 데이터를 다운로드 하시겠습니까?",
|
||||
)
|
||||
}
|
||||
>
|
||||
Export Data
|
||||
</GreyButton>
|
||||
</EximBox>
|
||||
<EximBox title="Variable Guide Export" info="변수 가이드를 다운로드 받을 수 있습니다.">
|
||||
<span />
|
||||
<GreyButton
|
||||
icon="/images/kart/ic_exports.png"
|
||||
onClick={() =>
|
||||
save(
|
||||
{ kind: "guide", project, name: { prefix: EXPORT_PREFIX.guide, title } },
|
||||
title + " 변수 가이드를 다운로드 하시겠습니까?")
|
||||
}
|
||||
>
|
||||
Export Guide
|
||||
</GreyButton>
|
||||
</EximBox>
|
||||
</Column>
|
||||
<Column icon="/images/kart/ic_import.svg" title="Import">
|
||||
<ImportBox
|
||||
id="import_data"
|
||||
title="Data Import"
|
||||
info="Data를 교체 할수 있습니다."
|
||||
formTitle="Export Header"
|
||||
onForm={() => save({ kind: "form/data", project, name: { prefix: EXPORT_PREFIX.header, title } })}
|
||||
confirmText={title + " 프로젝트의 모든 완료 데이터를 삭제 후 진행됩니다.\r\n진행 하시겠습니까?"}
|
||||
importTitle="Import Data"
|
||||
onImport={(file) => importFile("data", file)}
|
||||
/>
|
||||
<ImportBox
|
||||
id="import_question"
|
||||
title="Question Import"
|
||||
info="설문 문항을 초기화 하고 일괄 세팅할 수 있습니다."
|
||||
formTitle="Export Form"
|
||||
onForm={() => save({ kind: "form/question", name: QUESTION_FORM_NAME })}
|
||||
confirmText={
|
||||
title +
|
||||
" 프로젝트의 모든 문항을 삭제 후 진행됩니다. (단 하드 코딩은 유지 됩니다.)\r\n진행 하시겠습니까?"
|
||||
}
|
||||
importTitle="Import Question"
|
||||
onImport={(file) => importFile("question", file)}
|
||||
wide
|
||||
/>
|
||||
<ImportBox
|
||||
id="import_title"
|
||||
title="Question Title Import"
|
||||
info="Table Title을 세팅 할수 있습니다."
|
||||
formTitle="Export Form"
|
||||
onForm={() => save({ kind: "form/title", project, name: { prefix: EXPORT_PREFIX.title, title } })}
|
||||
confirmText={title + " 프로젝트의 Title을 삭제 후 진행됩니다.\r\n진행 하시겠습니까?"}
|
||||
importTitle="Import Title"
|
||||
onImport={(file) => importFile("title", file)}
|
||||
/>
|
||||
</Column>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function Column({ icon, title, children }: { icon: string; title: string; children: ReactNode }) {
|
||||
return (
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="mb-3.5 flex items-center gap-1">
|
||||
<Image src={icon} alt="" width={36} height={36} unoptimized />
|
||||
<h2 className="text-xl font-semibold text-kart-title">{title}</h2>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy ExportBox / ImportBox frame: title with the description, then one control row. */
|
||||
function EximBox({
|
||||
title,
|
||||
info,
|
||||
action,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
info: string;
|
||||
action?: ReactNode;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="mb-4 rounded-[15px] border border-kart-line bg-white">
|
||||
<div className="-m-px flex h-[55px] items-center justify-between rounded-[15px] border border-kart-line bg-kart-soft p-2.5">
|
||||
<div className="flex items-baseline gap-2">
|
||||
<h3 className="text-base font-bold text-kart-title">{title}</h3>
|
||||
<span className="text-sm text-kart-text">{info}</span>
|
||||
</div>
|
||||
{action}
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-5 px-4 py-3.5">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function GreyButton({
|
||||
icon,
|
||||
onClick,
|
||||
children,
|
||||
wide = false,
|
||||
}: {
|
||||
icon: string;
|
||||
onClick: () => void;
|
||||
children: ReactNode;
|
||||
wide?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
style={{ backgroundImage: `url(${icon})` }}
|
||||
className={
|
||||
"h-[50px] shrink-0 cursor-pointer rounded-[4px] bg-kart-bg bg-size-[15px] bg-position-[left_20px_center] bg-no-repeat pl-10 text-base font-bold text-[#9e9e9e] grayscale " +
|
||||
(wide ? "w-[190px]" : "w-[156px]")
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy ImportBox: form download (red), file picker, then a confirmed upload. */
|
||||
function ImportBox({
|
||||
id,
|
||||
title,
|
||||
info,
|
||||
formTitle,
|
||||
onForm,
|
||||
confirmText,
|
||||
importTitle,
|
||||
onImport,
|
||||
wide = false,
|
||||
}: {
|
||||
id: string;
|
||||
title: string;
|
||||
info: string;
|
||||
formTitle: string;
|
||||
onForm: () => void;
|
||||
confirmText: string;
|
||||
importTitle: string;
|
||||
onImport: (file: File) => Promise<unknown>;
|
||||
wide?: boolean;
|
||||
}) {
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const submit = () => {
|
||||
if (!window.confirm(confirmText)) return;
|
||||
if (!file) {
|
||||
window.alert("파일을 선택해 주세요.");
|
||||
return;
|
||||
}
|
||||
void onImport(file);
|
||||
// Legacy clears the picker right after sending.
|
||||
setFile(null);
|
||||
if (input.current) input.current.value = "";
|
||||
};
|
||||
return (
|
||||
<EximBox
|
||||
title={title}
|
||||
info={info}
|
||||
action={
|
||||
<button
|
||||
type="button"
|
||||
onClick={onForm}
|
||||
className="h-7 w-[156px] cursor-pointer rounded-[52px] bg-[#ff5b40] bg-[url(/images/kart/ic_exports_s.png)] bg-size-[12px] bg-position-[left_20px_center] bg-no-repeat pl-3.5 text-sm font-bold text-white"
|
||||
>
|
||||
{formTitle}
|
||||
</button>
|
||||
}
|
||||
>
|
||||
<input
|
||||
ref={input}
|
||||
id={id}
|
||||
type="file"
|
||||
className="sr-only"
|
||||
onChange={(event) => setFile(event.target.files?.[0] ?? null)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={title + " 파일 선택"}
|
||||
onClick={() => input.current?.click()}
|
||||
className="h-9 w-[70%] max-w-[700px] cursor-pointer truncate rounded-[4px] border border-kart-line bg-kart-bg bg-[url(/images/kart/ic_gnb5_20.png)] bg-size-[20px] bg-position-[left_20px_center] bg-no-repeat pr-3.5 pl-[46px] text-left text-sm font-light text-[#999]"
|
||||
>
|
||||
{file?.name ?? "파일선택"}
|
||||
</button>
|
||||
<GreyButton icon="/images/kart/ic_imports.png" onClick={submit} wide={wide}>
|
||||
{importTitle}
|
||||
</GreyButton>
|
||||
</EximBox>
|
||||
);
|
||||
}
|
||||
90
src/components/project/DailyChart.tsx
Normal file
90
src/components/project/DailyChart.tsx
Normal file
@@ -0,0 +1,90 @@
|
||||
"use client";
|
||||
|
||||
import type { EChartsOption } from "echarts";
|
||||
import { BaseEChart } from "@/components/chart";
|
||||
import { displayCount, displayDate, type ProgressDay } from "@/types/kart";
|
||||
import type { ZoomWindow } from "@/lib/progress-zoom";
|
||||
import { chartTextStyle, useChartFontReady } from "@/hooks/useChartFont";
|
||||
|
||||
// Legacy Chart.js LineBarChart: Total bar + Complete/Screen/Quota lines.
|
||||
const series = [
|
||||
{ key: "totalCount", name: "Total", type: "bar", color: "#1CAE81" },
|
||||
{ key: "completeCount", name: "Complete", type: "line", color: "#FF5B40" },
|
||||
{ key: "screenCount", name: "Screen", type: "line", color: "#FFC950" },
|
||||
{ key: "quotaCount", name: "Quota", type: "line", color: "#3789FF" },
|
||||
] as const;
|
||||
|
||||
// Legacy charts ran on ECharts 5; pin its default grid so ECharts 6 lays out the same plot area.
|
||||
export const legacyGrid = {
|
||||
left: "10%",
|
||||
right: "10%",
|
||||
top: 60,
|
||||
bottom: 70,
|
||||
outerBoundsMode: "none",
|
||||
} as const;
|
||||
|
||||
/** Glyphs drawn by axis/value labels besides the category names. */
|
||||
export const chartDigits = "0123456789,.-";
|
||||
|
||||
export const seriesLabel = {
|
||||
show: true,
|
||||
position: "top",
|
||||
fontSize: 15,
|
||||
fontWeight: "bold",
|
||||
valueAnimation: true,
|
||||
formatter: (params: { value?: unknown }) =>
|
||||
typeof params.value === "number" ? displayCount(params.value) : "",
|
||||
} as const;
|
||||
|
||||
export function DailyChart({
|
||||
rows,
|
||||
zoom,
|
||||
onZoom,
|
||||
}: {
|
||||
rows: ProgressDay[];
|
||||
zoom: ZoomWindow;
|
||||
onZoom: (event: unknown) => void;
|
||||
}) {
|
||||
const dates = rows.map((row) => displayDate(row.surveyDate));
|
||||
const fontReady = useChartFontReady(
|
||||
dates.join("") + series.map((item) => item.name).join("") + chartDigits,
|
||||
);
|
||||
const option: EChartsOption = {
|
||||
textStyle: chartTextStyle,
|
||||
grid: legacyGrid,
|
||||
tooltip: { trigger: "axis", textStyle: chartTextStyle },
|
||||
xAxis: { type: "category", data: dates },
|
||||
yAxis: { type: "value" },
|
||||
series: series.map((item, index) => ({
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
color: item.color,
|
||||
data: rows.map((row) => row[item.key]),
|
||||
...(item.type === "bar"
|
||||
? { barMaxWidth: 100 }
|
||||
: { symbolSize: 10, lineStyle: { width: 3 } }),
|
||||
...(index === 0 ? { label: seriesLabel } : {}),
|
||||
})) as EChartsOption["series"],
|
||||
dataZoom: [
|
||||
{
|
||||
type: "slider",
|
||||
height: 30,
|
||||
// ECharts 6 draws the slider ~9px lower than the legacy ECharts 5 default (bottom: 7).
|
||||
bottom: 16,
|
||||
show: true,
|
||||
xAxisIndex: [0],
|
||||
start: zoom.start,
|
||||
end: zoom.end,
|
||||
},
|
||||
],
|
||||
};
|
||||
if (!fontReady) return null;
|
||||
return (
|
||||
<BaseEChart
|
||||
option={option}
|
||||
height={370}
|
||||
normalizeValues={false}
|
||||
onEvents={{ datazoom: onZoom }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
50
src/components/project/ExternalEntry.tsx
Normal file
50
src/components/project/ExternalEntry.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import type { Route } from "next";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { isExternalSession, reportUrl, type ExternalSession } from "@/types/share";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
|
||||
export function ExternalEntry({ urlKey }: { urlKey: string }) {
|
||||
const router = useRouter();
|
||||
const { hydrated, setAuth, logout } = useAuth();
|
||||
const setProject = useSetAtom(selectedProjectAtom);
|
||||
const queryClient = useQueryClient();
|
||||
const pending = useRef<Promise<ExternalSession> | null>(null);
|
||||
const [error, setError] = useState("");
|
||||
useEffect(() => {
|
||||
if (!hydrated) return;
|
||||
let active = true;
|
||||
const enter = async () => {
|
||||
logout();
|
||||
setProject(null);
|
||||
await queryClient.cancelQueries();
|
||||
queryClient.clear();
|
||||
const result = await nextApi.post<unknown>(`/external/${encodeURIComponent(urlKey)}/login`, null, {
|
||||
skipUnauthorizedHandler: true, skipForbiddenHandler: true, skipResponseErrorHandler: true,
|
||||
});
|
||||
if (!isExternalSession(result)) throw new Error("공유 링크 로그인 응답을 확인해 주세요.");
|
||||
return result;
|
||||
};
|
||||
// Reuse the request during StrictMode effect replay; each entry records one landing.
|
||||
pending.current ??= enter();
|
||||
void pending.current.then((result) => {
|
||||
if (!active) return;
|
||||
setProject({ userId: result.user.userId, project: { projectType: result.link.projectType, pkey: result.link.pkey } });
|
||||
setAuth({ user: result.user, external: result.link });
|
||||
router.replace(reportUrl(result.link.realUrl) as Route);
|
||||
}).catch((reason: unknown) => {
|
||||
if (active) setError(apiError(reason, { fallbackMessage: "공유 링크를 확인해 주세요." }).message);
|
||||
});
|
||||
return () => { active = false; };
|
||||
}, [hydrated, logout, setAuth, setProject, queryClient, router, urlKey]);
|
||||
if (error) return <p role="alert" className="p-8 text-center text-sm">{error}</p>;
|
||||
return <LoadingOverlayAdapter force label="공유 링크를 확인하는 중입니다." />;
|
||||
}
|
||||
125
src/components/project/ProjectOverview.tsx
Normal file
125
src/components/project/ProjectOverview.tsx
Normal file
@@ -0,0 +1,125 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useEffect } from "react";
|
||||
import { KriPieChart } from "@/components/chart";
|
||||
import { useProjectSummaryQuery } from "@/query/project";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { chartTextStyle, useChartFontReady } from "@/hooks/useChartFont";
|
||||
import { projectKey } from "@/types/kart";
|
||||
import { QueryState } from "./QueryState";
|
||||
import { SpecialEffect, hasSpecialEffect } from "./SpecialEffect";
|
||||
|
||||
// Legacy Chart.js DoughnutChart palette and labels.
|
||||
const colors = ["#B3D2FF", "#DAECAF", "#FFBEB3", "#FFE9B8"];
|
||||
const labels = ["완료", "스크린", "쿼터", "진행중"];
|
||||
|
||||
export function ProjectOverview() {
|
||||
const { auth } = useAuth();
|
||||
const summary = useProjectSummaryQuery();
|
||||
const fontReady = useChartFontReady(labels.join("") + "0123456789");
|
||||
const { hydrated, select, clear } = useSelectedProject();
|
||||
useVisitLog("/");
|
||||
// Legacy Main.js resets the selected project whenever the overview opens.
|
||||
useEffect(() => {
|
||||
if (hydrated) clear();
|
||||
}, [hydrated, clear]);
|
||||
return (
|
||||
<section aria-label="Project Overview TOP 6">
|
||||
{auth.user && hasSpecialEffect(auth.user.userId) ? (
|
||||
<SpecialEffect />
|
||||
) : null}
|
||||
{summary.isPending || summary.isError || !summary.data?.length ? (
|
||||
<QueryState
|
||||
pending={summary.isPending}
|
||||
error={summary.error}
|
||||
empty="조회 가능한 최근 프로젝트가 없습니다."
|
||||
onRetry={() => void summary.refetch()}
|
||||
/>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 gap-[0.8332vw] py-[0.4166vw] min-[768px]:grid-cols-2 min-[1301px]:grid-cols-3">
|
||||
{summary.data.map((project) => (
|
||||
<div
|
||||
key={projectKey(project)}
|
||||
className="relative h-[420px] rounded-[15px] border border-kart-line bg-white"
|
||||
>
|
||||
<Link
|
||||
href="/Report/Current"
|
||||
onClick={() => select(project)}
|
||||
title={project.title ?? project.pkey}
|
||||
className="-m-px flex h-[55px] items-center justify-between rounded-[15px] border border-kart-line bg-kart-soft p-4"
|
||||
>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<Image
|
||||
src="/images/kart/icon_circle.svg"
|
||||
alt=""
|
||||
width={36}
|
||||
height={36}
|
||||
className="size-9 shrink-0"
|
||||
unoptimized
|
||||
/>
|
||||
<h3 className="line-clamp-2 text-base font-bold text-kart-title">
|
||||
{project.title || project.pkey}
|
||||
</h3>
|
||||
</div>
|
||||
<div className="flex shrink-0 gap-2">
|
||||
{[project.surveyType, project.status].map((value, index) => (
|
||||
<span
|
||||
key={index}
|
||||
className="inline-block h-[27px] min-w-[55px] rounded-[39px] border border-kart-line px-1 text-center text-sm leading-[25px] text-kart-text"
|
||||
>
|
||||
{value ?? "-"}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</Link>
|
||||
{/* Legacy chart_frame: 350px canvas whose top lands 48px below the card top. */}
|
||||
<div className="absolute top-12 left-0 h-[350px] w-full">
|
||||
{fontReady ? (
|
||||
<KriPieChart
|
||||
height={350}
|
||||
option={{ textStyle: chartTextStyle }}
|
||||
tooltip={{ trigger: "item", textStyle: chartTextStyle }}
|
||||
legend={{ bottom: "0%", left: "center" }}
|
||||
normalizeValues={false}
|
||||
series={[
|
||||
{
|
||||
name: project.title ?? project.pkey,
|
||||
radius: ["35%", "70%"],
|
||||
center: ["50%", "50%"],
|
||||
data: [
|
||||
project.completeCount,
|
||||
project.screenCount,
|
||||
project.quotaCount,
|
||||
project.ongoingCount,
|
||||
].map((value, index) => ({
|
||||
name: labels[index],
|
||||
value: value ?? "-",
|
||||
})),
|
||||
option: {
|
||||
avoidLabelOverlap: false,
|
||||
itemStyle: {
|
||||
borderRadius: 5,
|
||||
borderColor: "#fff",
|
||||
borderWidth: 2,
|
||||
},
|
||||
label: { show: false, position: "center" },
|
||||
emphasis: { label: { show: false } },
|
||||
labelLine: { show: false },
|
||||
color: colors,
|
||||
},
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
232
src/components/project/ProjectProgress.tsx
Normal file
232
src/components/project/ProjectProgress.tsx
Normal file
@@ -0,0 +1,232 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useProgressQuery } from "@/query/project";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import {
|
||||
displayCount,
|
||||
displayDate,
|
||||
projectKey,
|
||||
type ProjectRef,
|
||||
type DateRange,
|
||||
} from "@/types/kart";
|
||||
import {
|
||||
readZoomEvent,
|
||||
zoomDateRange,
|
||||
type ZoomWindow,
|
||||
} from "@/lib/progress-zoom";
|
||||
import { QueryState } from "./QueryState";
|
||||
import { DailyChart } from "./DailyChart";
|
||||
import { ScreenChart } from "./ScreenChart";
|
||||
|
||||
export function ProjectProgress() {
|
||||
const router = useRouter();
|
||||
const { project, hydrated } = useSelectedProject();
|
||||
// Legacy AuthRoute sends project pages without a selected project back home.
|
||||
const missing = hydrated && !project;
|
||||
useEffect(() => {
|
||||
if (missing) router.replace("/");
|
||||
}, [missing, router]);
|
||||
if (!project) return null;
|
||||
return <ProgressDetails key={projectKey(project)} project={project} />;
|
||||
}
|
||||
|
||||
/** Legacy Current.js layout; the daily chart's dataZoom drives the type/loi/screen date filter. */
|
||||
function ProgressDetails({ project }: { project: ProjectRef }) {
|
||||
const [range, setRange] = useState<DateRange>({ startDate: "", endDate: "" });
|
||||
const [zoom, setZoom] = useState<ZoomWindow>({ start: 0, end: 100 });
|
||||
const pendingZoom = useRef<ZoomWindow | null>(null);
|
||||
const queries = useProgressQuery(project, range);
|
||||
useVisitLog("/Report/Current", project);
|
||||
const type = queries.type.data?.[0];
|
||||
const loi = queries.loi.data?.[0];
|
||||
const dates = (queries.daily.data ?? []).map((row) =>
|
||||
displayDate(row.surveyDate),
|
||||
);
|
||||
// Legacy applies the zoomed dates on mouse release, not on every drag step.
|
||||
const applyZoom = () => {
|
||||
const next = pendingZoom.current;
|
||||
pendingZoom.current = null;
|
||||
if (!next) return;
|
||||
setZoom(next);
|
||||
const nextRange = zoomDateRange(dates, next);
|
||||
if (
|
||||
nextRange &&
|
||||
(nextRange.startDate !== range.startDate ||
|
||||
nextRange.endDate !== range.endDate)
|
||||
)
|
||||
setRange(nextRange);
|
||||
};
|
||||
return (
|
||||
<section
|
||||
aria-label="진행 현황"
|
||||
className="flex flex-col"
|
||||
onPointerUp={applyZoom}
|
||||
>
|
||||
<div className="flex w-full gap-2 max-[1024px]:flex-wrap">
|
||||
<ProgressBox title="응답자 현황" table>
|
||||
<ValueTable
|
||||
header={["Total", "Complete", "Screen", "Quota", "Ongoing"]}
|
||||
values={
|
||||
type && [
|
||||
displayCount(type.totalCount),
|
||||
displayCount(type.completeCount),
|
||||
displayCount(type.screenCount),
|
||||
displayCount(type.quotaCount),
|
||||
displayCount(type.goingCount),
|
||||
]
|
||||
}
|
||||
/>
|
||||
{queries.type.isError ? (
|
||||
<QueryState
|
||||
error={queries.type.error}
|
||||
onRetry={() => void queries.type.refetch()}
|
||||
/>
|
||||
) : null}
|
||||
</ProgressBox>
|
||||
<ProgressBox title="응답시간" table>
|
||||
<ValueTable
|
||||
header={["N", "AVG", "AVG (제외 Top/Bot 2.5%)", "Min", "Max"]}
|
||||
values={
|
||||
loi && [
|
||||
displayCount(loi.cnt),
|
||||
loi.avgLoi ?? "-",
|
||||
loi.avgLoiModify ?? "-",
|
||||
loi.minLoi ?? "-",
|
||||
loi.maxLoi ?? "-",
|
||||
]
|
||||
}
|
||||
/>
|
||||
{queries.loi.isError ? (
|
||||
<QueryState
|
||||
error={queries.loi.error}
|
||||
onRetry={() => void queries.loi.refetch()}
|
||||
/>
|
||||
) : null}
|
||||
</ProgressBox>
|
||||
</div>
|
||||
<ProgressBox title="일별 참여자 수">
|
||||
{queries.daily.isError ? (
|
||||
<QueryState
|
||||
error={queries.daily.error}
|
||||
onRetry={() => void queries.daily.refetch()}
|
||||
/>
|
||||
) : queries.daily.data && !queries.daily.data.length ? (
|
||||
<QueryState empty="일별 참여 데이터가 없습니다." />
|
||||
) : queries.daily.data ? (
|
||||
<ChartFrame>
|
||||
<DailyChart
|
||||
rows={queries.daily.data}
|
||||
zoom={zoom}
|
||||
onZoom={(event) => {
|
||||
pendingZoom.current = readZoomEvent(event);
|
||||
}}
|
||||
/>
|
||||
</ChartFrame>
|
||||
) : null}
|
||||
</ProgressBox>
|
||||
<ProgressBox title="문항별 SCREEN OUT 사례수">
|
||||
{queries.screen.isError ? (
|
||||
<QueryState
|
||||
error={queries.screen.error}
|
||||
onRetry={() => void queries.screen.refetch()}
|
||||
/>
|
||||
) : queries.screen.data ? (
|
||||
<ChartFrame>
|
||||
<ScreenChart rows={queries.screen.data} />
|
||||
</ChartFrame>
|
||||
) : null}
|
||||
</ProgressBox>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy chart_box: 420px card (chart_box2 for the tables: transparent, auto height). */
|
||||
function ProgressBox({
|
||||
title,
|
||||
table = false,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
table?: boolean;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
table
|
||||
? "mb-4 w-[calc((100%-8px)/2)] max-[1024px]:w-full"
|
||||
: "relative mb-4 h-[420px] w-full rounded-[15px] border border-kart-line bg-white"
|
||||
}
|
||||
>
|
||||
<div className="-m-px flex h-[55px] items-center gap-2 rounded-[15px] border border-kart-line bg-kart-soft p-2.5">
|
||||
<Image
|
||||
src="/images/kart/icon_circle.svg"
|
||||
alt=""
|
||||
width={36}
|
||||
height={36}
|
||||
className="size-9"
|
||||
unoptimized
|
||||
/>
|
||||
<h3 className="text-base font-bold text-kart-title">{title}</h3>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy chart_frame (width 98%): the 370px canvas starts 48px below the box top. */
|
||||
function ChartFrame({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="absolute top-12 left-1/2 h-[370px] w-[98%] -translate-x-1/2">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy CurrentTable. */
|
||||
function ValueTable({
|
||||
header,
|
||||
values,
|
||||
}: {
|
||||
header: string[];
|
||||
values?: string[];
|
||||
}) {
|
||||
return (
|
||||
<div className="mt-2 w-full overflow-hidden rounded-[4px]">
|
||||
<div className="h-[70px] w-full overflow-x-auto max-[1024px]:h-auto">
|
||||
<table className="h-full w-full table-fixed text-center text-sm whitespace-nowrap text-kart-text">
|
||||
<thead>
|
||||
<tr>
|
||||
{header.map((label) => (
|
||||
<th
|
||||
key={label}
|
||||
className="w-[150px] border border-[#d0d0d0] bg-kart-line px-2.5 py-1.5 font-bold"
|
||||
>
|
||||
{label}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{values ? (
|
||||
<tr>
|
||||
{values.map((value, index) => (
|
||||
<td
|
||||
key={header[index]}
|
||||
className="border-r border-b border-l border-[#d0d0d0] bg-white py-1.5 font-bold"
|
||||
>
|
||||
{value}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
) : null}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
58
src/components/project/ProjectSelector.tsx
Normal file
58
src/components/project/ProjectSelector.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, usePathname } from "next/navigation";
|
||||
import { KriSingleSelect } from "@/components/common/KriAutoComplete";
|
||||
import { useProjectListQuery } from "@/query/project";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { projectKey } from "@/types/kart";
|
||||
import { projectPagePath } from "@/lib/report-navigation";
|
||||
import { QueryState } from "./QueryState";
|
||||
|
||||
/** Legacy ProjectSelect: search dropdown that always reads "프로젝트 선택". */
|
||||
export function ProjectSelector() {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { project: selected, select } = useSelectedProject();
|
||||
const projects = useProjectListQuery();
|
||||
if (projects.isError)
|
||||
return (
|
||||
<QueryState
|
||||
error={projects.error}
|
||||
onRetry={() => void projects.refetch()}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<KriSingleSelect
|
||||
// Remount after each selection so the trigger returns to the legacy fixed label.
|
||||
key={selected ? projectKey(selected) : ""}
|
||||
items={projects.data ?? []}
|
||||
value=""
|
||||
getValue={projectKey}
|
||||
getLabel={(item) => "(" + item.pkey + ") " + (item.title ?? "")}
|
||||
onChange={(value) => {
|
||||
const project = projects.data?.find(
|
||||
(item) => projectKey(item) === value,
|
||||
);
|
||||
if (!project) return;
|
||||
// Same page for the new project (legacy keeps the current menu), progress from home.
|
||||
select(project);
|
||||
router.push(projectPagePath(pathname));
|
||||
}}
|
||||
placeholder={
|
||||
projects.isPending
|
||||
? "목록을 불러오는 중..."
|
||||
: projects.data?.length
|
||||
? "프로젝트 선택"
|
||||
: "조회 가능한 프로젝트가 없습니다."
|
||||
}
|
||||
widthClassName="w-full"
|
||||
className="h-8 min-h-8 rounded-[39px] border-[#d0d0d0] bg-kart-soft px-[22px] py-0 text-sm shadow-none"
|
||||
spanClassName="text-sm [&_span]:text-kart-text"
|
||||
searchable
|
||||
resetScrollOnSearch
|
||||
preventDeselect
|
||||
hideOptionCheck
|
||||
disabled={projects.isPending}
|
||||
/>
|
||||
);
|
||||
}
|
||||
51
src/components/project/QueryState.tsx
Normal file
51
src/components/project/QueryState.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export function QueryState({
|
||||
pending,
|
||||
error,
|
||||
empty,
|
||||
onRetry,
|
||||
}: {
|
||||
pending?: boolean;
|
||||
error?: Error | null;
|
||||
empty?: string;
|
||||
onRetry?: () => void;
|
||||
}) {
|
||||
if (pending)
|
||||
return (
|
||||
<p
|
||||
className="p-8 text-center text-sm text-muted-foreground"
|
||||
role="status"
|
||||
>
|
||||
데이터를 불러오는 중입니다.
|
||||
</p>
|
||||
);
|
||||
if (error)
|
||||
return (
|
||||
<div
|
||||
role="alert"
|
||||
className="space-y-3 rounded-lg border border-destructive/30 bg-destructive/5 p-5 text-sm"
|
||||
>
|
||||
<p>
|
||||
{
|
||||
apiError(error, {
|
||||
fallbackMessage: "데이터를 불러오지 못했습니다.",
|
||||
}).message
|
||||
}
|
||||
</p>
|
||||
{onRetry && (
|
||||
<Button variant="outline" size="sm" onClick={onRetry}>
|
||||
다시 시도
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<p className="p-8 text-center text-sm text-muted-foreground">
|
||||
{empty ?? "조회 결과가 없습니다."}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
52
src/components/project/ScreenChart.tsx
Normal file
52
src/components/project/ScreenChart.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
"use client";
|
||||
|
||||
import type { EChartsOption } from "echarts";
|
||||
import { BaseEChart } from "@/components/chart";
|
||||
import type { ProgressScreen } from "@/types/kart";
|
||||
import { chartTextStyle, useChartFontReady } from "@/hooks/useChartFont";
|
||||
import { chartDigits, legacyGrid, seriesLabel } from "./DailyChart";
|
||||
|
||||
const escapeHtml = (text: string) =>
|
||||
text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
|
||||
/** Legacy Current.js: VIEWTITLE with entities decoded, tags and removed. */
|
||||
export function screenTooltipText(viewTitle: string | null): string {
|
||||
return (viewTitle ?? "")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/<[^>]*>?/g, "")
|
||||
.replace(/ /gi, "");
|
||||
}
|
||||
|
||||
// Legacy Chart.js BarChart for "문항별 SCREEN OUT 사례수".
|
||||
export function ScreenChart({ rows }: { rows: ProgressScreen[] }) {
|
||||
const pages = rows.map((row) => row.pageName ?? "");
|
||||
const fontReady = useChartFontReady(pages.join("") + chartDigits);
|
||||
const option: EChartsOption = {
|
||||
textStyle: chartTextStyle,
|
||||
grid: legacyGrid,
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
textStyle: chartTextStyle,
|
||||
// ECharts renders the formatter result as HTML, so escape the stripped title.
|
||||
formatter: (params) => {
|
||||
const first = Array.isArray(params) ? params[0] : params;
|
||||
const row = rows[first?.dataIndex ?? -1];
|
||||
return "<p>" + escapeHtml(screenTooltipText(row?.viewTitle ?? null)) + "</p>";
|
||||
},
|
||||
},
|
||||
xAxis: { type: "category", data: pages },
|
||||
yAxis: { type: "value" },
|
||||
series: [
|
||||
{
|
||||
type: "bar",
|
||||
data: rows.map((row) => row.cnt),
|
||||
barMaxWidth: 100,
|
||||
color: "#1CAE81",
|
||||
label: seriesLabel,
|
||||
},
|
||||
],
|
||||
};
|
||||
if (!fontReady) return null;
|
||||
return <BaseEChart option={option} height={370} normalizeValues={false} />;
|
||||
}
|
||||
107
src/components/project/SpecialEffect.tsx
Normal file
107
src/components/project/SpecialEffect.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
// Legacy Main.js effectUser list (email local parts).
|
||||
const effectUsers = [
|
||||
"jspark",
|
||||
"joohee",
|
||||
"choins",
|
||||
"shbaek",
|
||||
"seoyun",
|
||||
"cwpark",
|
||||
"hrsim",
|
||||
];
|
||||
|
||||
export function hasSpecialEffect(userId: string): boolean {
|
||||
return effectUsers.includes(userId.toLowerCase().split("@")[0]);
|
||||
}
|
||||
|
||||
type Particle = {
|
||||
id: number;
|
||||
left: number;
|
||||
duration: number;
|
||||
/** petal color or kring image index */
|
||||
look: string;
|
||||
};
|
||||
|
||||
/** Legacy SpecialEffect.js: FlowerPetals or KringEffect for 10 seconds on the home page. */
|
||||
export function SpecialEffect() {
|
||||
const [kind, setKind] = useState<"petal" | "kring" | null>(null);
|
||||
const [particles, setParticles] = useState<Particle[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const selected = Math.random() < 0.5 ? "petal" : "kring";
|
||||
setKind(selected);
|
||||
let nextId = 0;
|
||||
const removals = new Set<ReturnType<typeof setTimeout>>();
|
||||
const spawn = setInterval(
|
||||
() => {
|
||||
const id = nextId++;
|
||||
const look =
|
||||
selected === "petal"
|
||||
? "#" +
|
||||
Math.floor(Math.random() * 0x1000000)
|
||||
.toString(16)
|
||||
.padStart(6, "0")
|
||||
: String(Math.floor(Math.random() * 11) + 1);
|
||||
setParticles((current) => [
|
||||
...current,
|
||||
{
|
||||
id,
|
||||
left: Math.random() * 100,
|
||||
duration: Math.random() * 3 + 2,
|
||||
look,
|
||||
},
|
||||
]);
|
||||
const removal = setTimeout(() => {
|
||||
removals.delete(removal);
|
||||
setParticles((current) => current.filter((item) => item.id !== id));
|
||||
}, 5000);
|
||||
removals.add(removal);
|
||||
},
|
||||
selected === "petal" ? 100 : 250,
|
||||
);
|
||||
const stop = setTimeout(() => {
|
||||
clearInterval(spawn);
|
||||
setKind(null);
|
||||
setParticles([]);
|
||||
}, 10000);
|
||||
return () => {
|
||||
clearInterval(spawn);
|
||||
clearTimeout(stop);
|
||||
removals.forEach(clearTimeout);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!kind) return null;
|
||||
return (
|
||||
<div aria-hidden="true" className="pointer-events-none">
|
||||
{particles.map((particle) =>
|
||||
kind === "petal" ? (
|
||||
<span
|
||||
key={particle.id}
|
||||
className="kart-petal"
|
||||
style={{
|
||||
left: particle.left + "vw",
|
||||
animationDuration: particle.duration + "s",
|
||||
backgroundColor: particle.look,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
// eslint-disable-next-line @next/next/no-img-element -- transient animated sprites
|
||||
<img
|
||||
key={particle.id}
|
||||
className="kart-kring"
|
||||
src={`/images/kart/kring/kring_${particle.look}.png`}
|
||||
alt=""
|
||||
style={{
|
||||
left: particle.left + "vw",
|
||||
animationDuration: particle.duration + "s",
|
||||
}}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
231
src/components/report/BannerBox.tsx
Normal file
231
src/components/report/BannerBox.tsx
Normal file
@@ -0,0 +1,231 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useDndContext, useDroppable } from "@dnd-kit/core";
|
||||
import {
|
||||
SortableContext,
|
||||
arrayMove,
|
||||
useSortable,
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import type { Question } from "@/types/report";
|
||||
import { isDerivedQuestion, questionViewTitle } from "@/lib/report-ui";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { plainText } from "./ReportResultView";
|
||||
import {
|
||||
QUESTION_COLOR,
|
||||
VARIABLE_COLOR,
|
||||
readDragData,
|
||||
type DragBannerItem,
|
||||
type DragData,
|
||||
} from "./QuestionList";
|
||||
|
||||
export const MAX_BANNER_DEPTH = 5;
|
||||
|
||||
/**
|
||||
* Legacy insertBanner / insertBannerSub / moveSelectedBanner. Returns the next banner groups for
|
||||
* a drop, or null when the drop does not concern banners. Only "all" questions become banners.
|
||||
*/
|
||||
export function dropOnBanner(
|
||||
banners: string[][],
|
||||
data: DragData,
|
||||
overId: string,
|
||||
overData: DragData | null,
|
||||
): string[][] | null {
|
||||
if (data.kind === "question") {
|
||||
if (data.loc !== "all") return null;
|
||||
if (overId === "banner-new") return [...banners, [data.qid]];
|
||||
if (!overId.startsWith("banner-sub:")) return null;
|
||||
const group = Number(overId.slice("banner-sub:".length));
|
||||
return banners.map((ids, index) =>
|
||||
index === group && !ids.includes(data.qid) && ids.length < MAX_BANNER_DEPTH
|
||||
? [...ids, data.qid]
|
||||
: ids,
|
||||
);
|
||||
}
|
||||
if (data.kind !== "banner-item") return null;
|
||||
if (overData?.kind !== "banner-item" || overData.group !== data.group) return null;
|
||||
return banners.map((ids, index) =>
|
||||
index === data.group
|
||||
? arrayMove(ids, ids.indexOf(data.qid), ids.indexOf(overData.qid))
|
||||
: ids,
|
||||
);
|
||||
}
|
||||
|
||||
/** Removes one banner question; an emptied group disappears (legacy deleteSubBanner). */
|
||||
export const removeBanner = (banners: string[][], group: number, qid: string) =>
|
||||
banners
|
||||
.map((ids, index) => (index === group ? ids.filter((id) => id !== qid) : ids))
|
||||
.filter((ids) => ids.length > 0);
|
||||
|
||||
/** True while a banner-capable question is being dragged (legacy green dashed border). */
|
||||
function useBannerDragActive(): boolean {
|
||||
const { active } = useDndContext();
|
||||
const data = readDragData(active?.data.current);
|
||||
return data?.kind === "question" && data.loc === "all";
|
||||
}
|
||||
|
||||
/** Legacy BannerBox: one column per banner group plus the trailing "Banner List" drop area. */
|
||||
export function BannerBox({
|
||||
banners,
|
||||
questions,
|
||||
onRemove,
|
||||
}: {
|
||||
banners: string[][];
|
||||
questions: Question[];
|
||||
onRemove: (group: number, qid: string) => void;
|
||||
}) {
|
||||
const find = (qid: string) => questions.find((item) => item.qid === qid);
|
||||
return (
|
||||
<div className="p-4">
|
||||
<ul className="flex min-h-[210px] flex-wrap gap-2">
|
||||
{banners.map((group, groupIndex) => (
|
||||
<li
|
||||
key={groupIndex + ":" + group.join("|")}
|
||||
className="flex h-[210px] w-[280px] cursor-pointer flex-col"
|
||||
>
|
||||
<SortableContext
|
||||
items={group.map((qid) => bannerItemId(groupIndex, qid))}
|
||||
strategy={verticalListSortingStrategy}
|
||||
>
|
||||
{group.map((qid) => (
|
||||
<BannerItem
|
||||
key={qid}
|
||||
group={groupIndex}
|
||||
qid={qid}
|
||||
question={find(qid)}
|
||||
onRemove={() => onRemove(groupIndex, qid)}
|
||||
/>
|
||||
))}
|
||||
</SortableContext>
|
||||
{group.length < MAX_BANNER_DEPTH ? (
|
||||
<SubDrop group={groupIndex} />
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
<NewBannerDrop />
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const bannerItemId = (group: number, qid: string) =>
|
||||
"banner:" + group + ":" + qid;
|
||||
|
||||
function BannerItem({
|
||||
group,
|
||||
qid,
|
||||
question,
|
||||
onRemove,
|
||||
}: {
|
||||
group: number;
|
||||
qid: string;
|
||||
question?: Question;
|
||||
onRemove: () => void;
|
||||
}) {
|
||||
const data: DragBannerItem = { kind: "banner-item", group, qid };
|
||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
||||
useSortable({ id: bannerItemId(group, qid), data });
|
||||
const view = question ? questionViewTitle(question) : qid;
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className="mb-[3px] flex h-9 shrink-0 items-center justify-center pr-2.5"
|
||||
style={{
|
||||
background:
|
||||
question && isDerivedQuestion(question)
|
||||
? VARIABLE_COLOR
|
||||
: QUESTION_COLOR,
|
||||
opacity: isDragging ? 0 : 1,
|
||||
transform: CSS.Transform.toString(transform),
|
||||
transition,
|
||||
}}
|
||||
>
|
||||
<span className="relative block min-w-0 flex-1 overflow-hidden px-3 py-2 text-sm leading-5 text-ellipsis whitespace-nowrap text-kart-text">
|
||||
{plainText(view)}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={plainText(view) + " 배너에서 삭제"}
|
||||
// Keep the delete click from starting a drag.
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onClick={onRemove}
|
||||
className="shrink-0 cursor-pointer"
|
||||
>
|
||||
<Image
|
||||
src="/images/kart/ic_close.png"
|
||||
alt=""
|
||||
width={12}
|
||||
height={12}
|
||||
unoptimized
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" className="max-w-md opacity-65">
|
||||
{plainText(view)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
function SubDrop({ group }: { group: number }) {
|
||||
const { setNodeRef, isOver } = useDroppable({ id: "banner-sub:" + group });
|
||||
const canDrop = useBannerDragActive();
|
||||
return (
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
className="flex min-h-0 flex-1 flex-col items-center justify-center rounded-b-[15px] border-2 border-dashed bg-white"
|
||||
style={{ borderColor: canDrop || isOver ? "#1cae81" : "#d0d0d0" }}
|
||||
>
|
||||
<Image
|
||||
src="/images/kart/ic_drop.svg"
|
||||
alt=""
|
||||
width={16}
|
||||
height={16}
|
||||
className="size-4 grayscale"
|
||||
unoptimized
|
||||
/>
|
||||
<p className="text-xs leading-[17px] font-bold text-[#989898]">
|
||||
Drag&Drop
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NewBannerDrop() {
|
||||
const { setNodeRef, isOver } = useDroppable({ id: "banner-new" });
|
||||
const canDrop = useBannerDragActive();
|
||||
return (
|
||||
<li className="h-[210px] min-w-[280px] flex-1">
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
className="flex h-full flex-col items-center justify-center rounded-[15px] border-2 border-dashed bg-white px-2.5"
|
||||
style={{ borderColor: canDrop || isOver ? "#1cae81" : "#d0d0d0" }}
|
||||
>
|
||||
<Image
|
||||
src="/images/kart/ic_drop.svg"
|
||||
alt=""
|
||||
width={48}
|
||||
height={48}
|
||||
unoptimized
|
||||
/>
|
||||
<p className="text-xs leading-[17px] font-bold text-[#989898]">
|
||||
Banner List
|
||||
</p>
|
||||
<span className="text-sm leading-5 text-[#989898]">
|
||||
Please, select a banner.
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
152
src/components/report/BookmarkPopup.tsx
Normal file
152
src/components/report/BookmarkPopup.tsx
Normal file
@@ -0,0 +1,152 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useState } from "react";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import type { ReportBookmarks } from "@/hooks/useReportBookmarks";
|
||||
import { LegacyCheck } from "./ReportParts";
|
||||
|
||||
/**
|
||||
* Legacy BookmarkArea popup: Title, "Just for me", Information, then Save / Save as / Delete.
|
||||
* Save updates the selected bookmark (creates one on "New"); Save as always creates.
|
||||
*/
|
||||
export function BookmarkPopup({
|
||||
state,
|
||||
buildJson,
|
||||
onSaved,
|
||||
onDeleted,
|
||||
}: {
|
||||
state: ReportBookmarks;
|
||||
/** Current page conditions in the legacy BOOKMARK_JSON format. */
|
||||
buildJson: () => string;
|
||||
onSaved: () => void;
|
||||
onDeleted: () => void;
|
||||
}) {
|
||||
const current = state.current;
|
||||
const [title, setTitle] = useState(current?.bookmarkTitle ?? "");
|
||||
const [info, setInfo] = useState(current?.bookmarkInfo ?? "");
|
||||
// Legacy: unchecked only when IS_OPEN is 1 ("New" starts open).
|
||||
const [justForMe, setJustForMe] = useState(current ? current.isOpen !== 1 : false);
|
||||
const pending = state.save.isPending || state.remove.isPending;
|
||||
|
||||
const submit = async (asNew: boolean) => {
|
||||
const request = {
|
||||
bookmarkTitle: title,
|
||||
bookmarkInfo: info,
|
||||
bookmarkJson: buildJson(),
|
||||
isOpen: justForMe ? (0 as const) : (1 as const),
|
||||
};
|
||||
try {
|
||||
const bookmarkId = await state.save.mutateAsync({
|
||||
bookmarkId: asNew || !current ? null : current.bookmarkId,
|
||||
request,
|
||||
});
|
||||
state.select({ bookmarkId, ...request, isMine: true });
|
||||
onSaved();
|
||||
state.setPopupOpen(false);
|
||||
} catch (error) {
|
||||
window.alert(apiError(error, { fallbackMessage: "북마크를 저장하지 못했습니다." }).message);
|
||||
}
|
||||
};
|
||||
const destroy = async () => {
|
||||
if (!current || !window.confirm("정말 삭제 하시겠습니까?")) return;
|
||||
try {
|
||||
await state.remove.mutateAsync(current.bookmarkId);
|
||||
onDeleted();
|
||||
state.setPopupOpen(false);
|
||||
} catch (error) {
|
||||
window.alert(apiError(error, { fallbackMessage: "북마크를 삭제하지 못했습니다." }).message);
|
||||
}
|
||||
};
|
||||
const buttonClass =
|
||||
"my-2.5 inline-block h-[30px] w-[100px] cursor-pointer rounded-[4px] font-bold disabled:cursor-default";
|
||||
return (
|
||||
<Dialog open={state.popupOpen} onOpenChange={state.setPopupOpen}>
|
||||
<DialogContent
|
||||
showCloseButton={false}
|
||||
className="h-[480px] w-[382px] max-w-[calc(100vw-2rem)] gap-0 overflow-hidden rounded-[10px] border-0 p-0 sm:max-w-[382px]"
|
||||
>
|
||||
<div className="relative flex h-[55px] items-center rounded-t-[10px] bg-kart-green p-2.5">
|
||||
<Image src="/images/kart/ic_filter_pop.png" alt="" width={36} height={36} unoptimized />
|
||||
<DialogTitle className="pl-2 text-base font-bold text-white">Bookmark</DialogTitle>
|
||||
<DialogDescription className="sr-only">
|
||||
현재 조건을 북마크로 저장하거나 삭제합니다.
|
||||
</DialogDescription>
|
||||
<DialogClose className="absolute top-5 right-5 cursor-pointer" aria-label="닫기">
|
||||
<Image src="/images/kart/ic_close_w.png" alt="" width={18} height={18} unoptimized />
|
||||
</DialogClose>
|
||||
</div>
|
||||
<div className="px-4">
|
||||
<div className="mt-5">
|
||||
<h3 className="mb-2.5 text-base font-bold text-kart-title">
|
||||
<label htmlFor="bookmark_title">Title</label>
|
||||
</h3>
|
||||
<input
|
||||
id="bookmark_title"
|
||||
type="text"
|
||||
value={title}
|
||||
onChange={(event) => setTitle(event.target.value)}
|
||||
className="mb-2.5 h-9 w-full rounded-[4px] border border-kart-line bg-white px-3.5 py-1 text-sm leading-[19px] font-light text-[#999] outline-none"
|
||||
/>
|
||||
<h3 className="mb-2.5 text-base font-bold text-kart-title">Information</h3>
|
||||
<div className="mb-5">
|
||||
<LegacyCheck
|
||||
id="chk_bookmark"
|
||||
label="Just for me"
|
||||
checked={justForMe}
|
||||
onChange={setJustForMe}
|
||||
/>
|
||||
</div>
|
||||
<textarea
|
||||
aria-label="Information"
|
||||
cols={30}
|
||||
rows={10}
|
||||
value={info}
|
||||
onChange={(event) => setInfo(event.target.value)}
|
||||
// Fixed height: rows=10 grows with the line height and pushed the buttons out of the
|
||||
// 480px legacy popup.
|
||||
className="block h-[160px] w-full resize-none border border-kart-line p-1 text-sm text-justify text-black outline-[#17BBB0] [&::-webkit-scrollbar]:w-[6px] [&::-webkit-scrollbar-thumb]:rounded-[93px] [&::-webkit-scrollbar-thumb]:bg-[#9e9e9e] [&::-webkit-scrollbar-track]:bg-kart-line"
|
||||
/>
|
||||
<div className="text-center">
|
||||
<button
|
||||
type="button"
|
||||
disabled={pending}
|
||||
onClick={() => void submit(false)}
|
||||
className={buttonClass + " bg-kart-green text-white"}
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
{current ? (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
disabled={pending}
|
||||
onClick={() => void submit(true)}
|
||||
className={buttonClass + " ml-[5px] bg-kart-green text-white"}
|
||||
>
|
||||
Save as
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={pending}
|
||||
onClick={() => void destroy()}
|
||||
className={buttonClass + " ml-[5px] bg-kart-bg text-[#9e9e9e]"}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
193
src/components/report/CrosstabPhone.tsx
Normal file
193
src/components/report/CrosstabPhone.tsx
Normal file
@@ -0,0 +1,193 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useEffectEvent, useState } from "react";
|
||||
import { useBookmarkListQuery } from "@/query/bookmark";
|
||||
import { useCrosstabResults } from "@/query/report";
|
||||
import type { ProjectRef } from "@/types/kart";
|
||||
import type { Bookmark } from "@/types/bookmark";
|
||||
import type { Question } from "@/types/report";
|
||||
import { questionHead, questionViewTitle } from "@/lib/report-ui";
|
||||
import { filterCondition } from "@/lib/legacy-filter";
|
||||
import { bookmarkAxis, bookmarkTest, readBookmarkSetting } from "@/lib/bookmark-json";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { bookmarkIndexes, crosstabBatch } from "./crosstab-conditions";
|
||||
import { ResultBlock } from "./LegacyResultTable";
|
||||
import { plainText } from "./ReportResultView";
|
||||
|
||||
/**
|
||||
* Legacy Cross Tab on phones: saved bookmarks only (no "New"), the first one selected, shown
|
||||
* read-only with its filter, banner and table lists and the re-run results.
|
||||
*/
|
||||
export function CrosstabPhone({
|
||||
project,
|
||||
questions,
|
||||
}: {
|
||||
project: ProjectRef;
|
||||
questions: Question[];
|
||||
}) {
|
||||
const list = useBookmarkListQuery(project, "CROSSTAB");
|
||||
const [selectedId, setSelectedId] = useState<string | null>(null);
|
||||
const bookmarks = list.data ?? [];
|
||||
const current =
|
||||
bookmarks.find((bookmark) => bookmark.bookmarkId === selectedId) ?? bookmarks[0];
|
||||
return (
|
||||
<div className="min-h-[calc(100vh-146px)] bg-kart-bg">
|
||||
<ul className="flex h-[60px] items-end gap-[30px] overflow-x-auto overflow-y-hidden bg-white px-4 [&::-webkit-scrollbar]:hidden">
|
||||
{bookmarks.map((bookmark) => {
|
||||
const active = bookmark.bookmarkId === current?.bookmarkId;
|
||||
return (
|
||||
<li key={bookmark.bookmarkId} className="shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
title={bookmark.bookmarkTitle}
|
||||
aria-current={active ? "page" : undefined}
|
||||
onClick={() => setSelectedId(bookmark.bookmarkId)}
|
||||
className={cn(
|
||||
"relative cursor-pointer pb-2 text-sm font-bold whitespace-nowrap",
|
||||
active
|
||||
? "text-kart-green after:absolute after:inset-x-0 after:bottom-0 after:h-1 after:bg-kart-green"
|
||||
: "text-[#9e9e9e]",
|
||||
)}
|
||||
>
|
||||
{bookmark.bookmarkTitle}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{current ? (
|
||||
<PhoneBookmarkView
|
||||
key={current.bookmarkId}
|
||||
project={project}
|
||||
bookmark={current}
|
||||
questions={questions}
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full bg-white pt-10 text-center">
|
||||
<Image
|
||||
src="/images/kart/icon_none_bookmark.svg"
|
||||
alt="저장된 북마크가 없습니다."
|
||||
width={102}
|
||||
height={140}
|
||||
className="inline-block h-[70vh] w-auto"
|
||||
unoptimized
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PhoneBookmarkView({
|
||||
project,
|
||||
bookmark,
|
||||
questions,
|
||||
}: {
|
||||
project: ProjectRef;
|
||||
bookmark: Bookmark;
|
||||
questions: Question[];
|
||||
}) {
|
||||
const results = useCrosstabResults(project);
|
||||
const setting = readBookmarkSetting(bookmark.bookmarkJson);
|
||||
const indexes = bookmarkIndexes(setting.index, questions);
|
||||
const run = () => {
|
||||
if (!indexes.length) return;
|
||||
try {
|
||||
results.runAll(
|
||||
crosstabBatch(indexes, {
|
||||
banners: setting.banners,
|
||||
filterLines: setting.filter.lines,
|
||||
isTest: bookmarkTest(setting.option),
|
||||
isAxis: bookmarkAxis(setting.option),
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
window.alert(error instanceof Error ? error.message : "북마크 조건을 확인해 주세요.");
|
||||
}
|
||||
};
|
||||
// Selecting a bookmark runs its tables, like the legacy effects.
|
||||
const start = useEffectEvent(run);
|
||||
useEffect(() => {
|
||||
start();
|
||||
}, []);
|
||||
const find = (qid: string) => questions.find((question) => question.qid === qid);
|
||||
const bannerIds = setting.banners
|
||||
.flat()
|
||||
.filter((qid, position, all) => all.indexOf(qid) === position);
|
||||
return (
|
||||
<div className="relative px-4 pt-6 pb-[100px]">
|
||||
<button
|
||||
type="button"
|
||||
aria-label="다시 집계"
|
||||
title="다시 집계"
|
||||
onClick={run}
|
||||
className="absolute top-2 right-4 size-9 cursor-pointer rounded-[4px] border border-kart-line bg-white bg-[url(/images/kart/ic_re.png)] bg-[length:18px_17px] bg-center bg-no-repeat"
|
||||
/>
|
||||
<section className="mb-2">
|
||||
<h3 className="p-2 text-base font-bold text-kart-title">Filter</h3>
|
||||
<input
|
||||
type="text"
|
||||
readOnly
|
||||
aria-label="Filter"
|
||||
value={setting.filter.condition || filterCondition(setting.filter.lines)}
|
||||
className="w-full rounded-[4px] bg-white p-2 text-sm font-light text-kart-text outline-none"
|
||||
/>
|
||||
</section>
|
||||
<PhoneList title="banner" questions={bannerIds.flatMap((qid) => find(qid) ?? [])} />
|
||||
<PhoneList title="index" questions={indexes.flatMap((qid) => find(qid) ?? [])} />
|
||||
<div className="mt-2 bg-white">
|
||||
{indexes.map((qid) => {
|
||||
const slot = results.slots[qid];
|
||||
const question = find(qid);
|
||||
return (
|
||||
<ResultBlock
|
||||
key={qid}
|
||||
title={question ? questionHead(question) : qid}
|
||||
result={slot?.result}
|
||||
error={slot?.error}
|
||||
pending={!!slot && !slot.result && !slot.error}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy MobileBox: question titles that expand to the full question text. */
|
||||
function PhoneList({ title, questions }: { title: string; questions: Question[] }) {
|
||||
return (
|
||||
<section className="mb-2">
|
||||
<h3 className="p-2 text-base font-bold text-kart-title">{title}</h3>
|
||||
{questions.map((question) => (
|
||||
<PhoneListItem key={question.qid} question={question} />
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function PhoneListItem({ question }: { question: Question }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<div className="mb-1.5 bg-white p-2 text-sm text-kart-text">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen(!open)}
|
||||
className="relative block w-full cursor-pointer pr-6 text-left font-bold"
|
||||
>
|
||||
{plainText(questionViewTitle(question))}
|
||||
<Image
|
||||
src={open ? "/images/kart/acc_arrow_close_s.png" : "/images/kart/acc_arrow_open_s.png"}
|
||||
alt=""
|
||||
width={17}
|
||||
height={open ? 10 : 12}
|
||||
className="absolute top-1 right-0"
|
||||
unoptimized
|
||||
/>
|
||||
</button>
|
||||
{open ? <p className="mt-1">{plainText(question.title ?? "")}</p> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
322
src/components/report/CrosstabWorkspace.tsx
Normal file
322
src/components/report/CrosstabWorkspace.tsx
Normal file
@@ -0,0 +1,322 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import type { DragEndEvent } from "@dnd-kit/core";
|
||||
import { arrayMove } from "@dnd-kit/sortable";
|
||||
import { QueryState } from "@/components/project/QueryState";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { usePhoneView } from "@/hooks/usePhoneView";
|
||||
import { useReportBookmarks } from "@/hooks/useReportBookmarks";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { useFileDownload } from "@/query/export";
|
||||
import { EXPORT_PREFIX } from "@/lib/download-name";
|
||||
import { useProjectTitle } from "@/query/project";
|
||||
import { useCrosstabResults, useQuestionQuery } from "@/query/report";
|
||||
import { projectKey, type ProjectRef } from "@/types/kart";
|
||||
import type { Bookmark } from "@/types/bookmark";
|
||||
import { canIndex } from "@/lib/report-contract";
|
||||
import { isDerivedQuestion, questionHead } from "@/lib/report-ui";
|
||||
import { filterCondition } from "@/lib/legacy-filter";
|
||||
import {
|
||||
bookmarkAxis,
|
||||
bookmarkFilter,
|
||||
bookmarkTest,
|
||||
emptyBookmarkFilter,
|
||||
emptyBookmarkSetting,
|
||||
readBookmarkSetting,
|
||||
writeBookmarkJson,
|
||||
} from "@/lib/bookmark-json";
|
||||
import { BannerBox, dropOnBanner, removeBanner } from "./BannerBox";
|
||||
import { BookmarkPopup } from "./BookmarkPopup";
|
||||
import { CrosstabPhone } from "./CrosstabPhone";
|
||||
import { excelTables } from "./excel-tables";
|
||||
import { bookmarkIndexes, crosstabBatch, type Conditions } from "./crosstab-conditions";
|
||||
import { IndexBox } from "./IndexBox";
|
||||
import { ReportTabs } from "./ReportChrome";
|
||||
import { ReportFrame } from "./ReportFrame";
|
||||
import { FilterStatBox, ResetButton, SquareButton, StatBox } from "./ReportParts";
|
||||
import { ResultBlock } from "./LegacyResultTable";
|
||||
import { QuestionList, readDragData } from "./QuestionList";
|
||||
import { FilterPopup } from "./FilterPopup";
|
||||
|
||||
export function CrosstabWorkspace() {
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const { project, hydrated } = useSelectedProject();
|
||||
const missing = hydrated && !project;
|
||||
useEffect(() => {
|
||||
if (missing) router.replace("/");
|
||||
}, [missing, router]);
|
||||
if (!project) return null;
|
||||
return (
|
||||
<Workspace
|
||||
key={JSON.stringify([
|
||||
projectKey(project),
|
||||
auth.user?.userId,
|
||||
auth.user?.userRole,
|
||||
auth.user?.userTeam,
|
||||
])}
|
||||
project={project}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy Crosstab.js: questions dropped on Table are aggregated one by one; changing banner,
|
||||
* filter or options re-runs every table.
|
||||
*/
|
||||
function Workspace({ project }: { project: ProjectRef }) {
|
||||
const questions = useQuestionQuery(project);
|
||||
const results = useCrosstabResults(project);
|
||||
const [indexes, setIndexes] = useState<string[]>([]);
|
||||
const [conditions, setConditions] = useState<Conditions>({
|
||||
banners: [],
|
||||
filterLines: [],
|
||||
isTest: false,
|
||||
isAxis: false,
|
||||
});
|
||||
const [filterOpen, setFilterOpen] = useState(false);
|
||||
const bookmarks = useReportBookmarks(project, "CROSSTAB");
|
||||
const download = useFileDownload();
|
||||
const projectTitle = useProjectTitle(project);
|
||||
// Stored filter strings and OPTION of the applied bookmark, kept verbatim when unchanged.
|
||||
const [loadedFilter, setLoadedFilter] = useState(emptyBookmarkFilter);
|
||||
const [option, setOption] = useState<Record<string, unknown>>({});
|
||||
const phone = usePhoneView();
|
||||
useVisitLog("/Report/Crosstab", project);
|
||||
|
||||
const all = (questions.data ?? []).filter(canIndex);
|
||||
const find = (qid: string) =>
|
||||
(questions.data ?? []).find((question) => question.qid === qid);
|
||||
const done =
|
||||
indexes.length > 0 &&
|
||||
indexes.every((qid) => results.slots[qid]?.result || results.slots[qid]?.error);
|
||||
|
||||
// Legacy selectedBookMark effect: replace every condition, then re-run every table.
|
||||
const applyBookmark = (bookmark: Bookmark | null) => {
|
||||
const setting = bookmark ? readBookmarkSetting(bookmark.bookmarkJson) : emptyBookmarkSetting;
|
||||
const ids = bookmarkIndexes(setting.index, questions.data ?? []);
|
||||
const next: Conditions = {
|
||||
banners: setting.banners,
|
||||
filterLines: setting.filter.lines,
|
||||
isTest: bookmarkTest(setting.option),
|
||||
isAxis: bookmarkAxis(setting.option),
|
||||
};
|
||||
bookmarks.select(bookmark);
|
||||
setIndexes(ids);
|
||||
setConditions(next);
|
||||
setLoadedFilter(setting.filter);
|
||||
setOption(setting.option);
|
||||
results.reset();
|
||||
if (!ids.length) return;
|
||||
try {
|
||||
results.runAll(crosstabBatch(ids, next));
|
||||
} catch (error) {
|
||||
window.alert(error instanceof Error ? error.message : "북마크 조건을 확인해 주세요.");
|
||||
}
|
||||
};
|
||||
const currentFilter = () => bookmarkFilter(conditions.filterLines, loadedFilter);
|
||||
// Legacy ExportTable: every received table in Table order, word clouds with their picture.
|
||||
const exportTable = () => {
|
||||
const tables = excelTables(
|
||||
indexes.map((qid) => ({ index: qid, result: results.slots[qid]?.result })),
|
||||
find,
|
||||
);
|
||||
if (!tables.length) return;
|
||||
download.mutate(
|
||||
{
|
||||
kind: "table",
|
||||
project,
|
||||
request: { tables, turn: conditions.isAxis },
|
||||
name: { prefix: EXPORT_PREFIX.table, title: projectTitle },
|
||||
},
|
||||
{
|
||||
onError: (error) =>
|
||||
window.alert(apiError(error, { fallbackMessage: "Excel 파일을 만들지 못했습니다." }).message),
|
||||
},
|
||||
);
|
||||
};
|
||||
const runAll = (next: Conditions = conditions) => {
|
||||
if (indexes.length) results.runAll(crosstabBatch(indexes, next));
|
||||
};
|
||||
const change = (patch: Partial<Conditions>) => {
|
||||
const next = { ...conditions, ...patch };
|
||||
setConditions(next);
|
||||
runAll(next);
|
||||
};
|
||||
const onDragEnd = (event: DragEndEvent) => {
|
||||
const data = readDragData(event.active.data.current);
|
||||
if (!data) return;
|
||||
const overId = event.over ? String(event.over.id) : "";
|
||||
const overData = readDragData(event.over?.data.current);
|
||||
if (data.kind === "question" && overId === "index-drop") {
|
||||
if (indexes.includes(data.qid)) return;
|
||||
setIndexes([...indexes, data.qid]);
|
||||
results.runOne(crosstabBatch([data.qid], conditions));
|
||||
return;
|
||||
}
|
||||
if (data.kind === "index-item") {
|
||||
if (overData?.kind === "index-item")
|
||||
setIndexes(arrayMove(indexes, indexes.indexOf(data.qid), indexes.indexOf(overData.qid)));
|
||||
return;
|
||||
}
|
||||
const banners = dropOnBanner(conditions.banners, data, overId, overData);
|
||||
if (banners) change({ banners });
|
||||
};
|
||||
|
||||
if (questions.isPending || questions.isError)
|
||||
return (
|
||||
<QueryState
|
||||
pending={questions.isPending}
|
||||
error={questions.error}
|
||||
onRetry={() => void questions.refetch()}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<ReportFrame
|
||||
label="Cross Tab"
|
||||
tabs={
|
||||
<ReportTabs
|
||||
bookmarks={bookmarks.bookmarks}
|
||||
selectedId={bookmarks.current?.bookmarkId ?? null}
|
||||
onSelect={applyBookmark}
|
||||
canSave={bookmarks.canSave}
|
||||
onBookmark={() => bookmarks.setPopupOpen(true)}
|
||||
onRefresh={() => runAll()}
|
||||
/>
|
||||
}
|
||||
isTest={conditions.isTest}
|
||||
onTestChange={(isTest) => change({ isTest })}
|
||||
isAxis={conditions.isAxis}
|
||||
onAxisChange={(isAxis) => change({ isAxis })}
|
||||
findQuestion={find}
|
||||
onDragEnd={onDragEnd}
|
||||
phone={
|
||||
// Legacy phones show saved bookmarks read-only; mounted only on phones so the hidden
|
||||
// view never requests tables on a desktop.
|
||||
phone ? <CrosstabPhone project={project} questions={questions.data ?? []} /> : null
|
||||
}
|
||||
lists={
|
||||
<>
|
||||
<QuestionList
|
||||
title="Question List"
|
||||
variant="question"
|
||||
questions={all.filter((question) => !isDerivedQuestion(question))}
|
||||
/>
|
||||
<QuestionList
|
||||
title="Variable List"
|
||||
variant="variable"
|
||||
questions={all.filter(isDerivedQuestion)}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{(collapsed) => (
|
||||
<>
|
||||
{collapsed ? null : (
|
||||
<>
|
||||
<FilterStatBox
|
||||
condition={filterCondition(conditions.filterLines)}
|
||||
onAdd={() => setFilterOpen(true)}
|
||||
onReset={() => change({ filterLines: [] })}
|
||||
/>
|
||||
<div className="mb-4 text-center">
|
||||
<SquareButton done={done} disabled={download.isPending} onClick={exportTable}>
|
||||
Export Table
|
||||
</SquareButton>
|
||||
</div>
|
||||
<StatBox
|
||||
icon="document"
|
||||
title="Banner"
|
||||
action={
|
||||
<ResetButton label="배너 초기화" onClick={() => change({ banners: [] })} />
|
||||
}
|
||||
>
|
||||
<BannerBox
|
||||
banners={conditions.banners}
|
||||
questions={questions.data ?? []}
|
||||
onRemove={(group, qid) =>
|
||||
change({ banners: removeBanner(conditions.banners, group, qid) })
|
||||
}
|
||||
/>
|
||||
</StatBox>
|
||||
</>
|
||||
)}
|
||||
<div className="flex items-start gap-5">
|
||||
{collapsed ? null : (
|
||||
<StatBox
|
||||
icon="document"
|
||||
title="Table"
|
||||
className="w-[20%] shrink-0"
|
||||
action={
|
||||
<ResetButton
|
||||
label="표 초기화"
|
||||
onClick={() => {
|
||||
setIndexes([]);
|
||||
results.reset();
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<IndexBox
|
||||
indexes={indexes}
|
||||
questions={questions.data ?? []}
|
||||
onRemove={(qid) => {
|
||||
setIndexes(indexes.filter((id) => id !== qid));
|
||||
results.remove(qid);
|
||||
}}
|
||||
/>
|
||||
</StatBox>
|
||||
)}
|
||||
<div className={collapsed ? "w-full" : "w-[79%] min-w-0"}>
|
||||
{indexes.map((qid) => {
|
||||
const slot = results.slots[qid];
|
||||
const question = find(qid);
|
||||
return (
|
||||
<ResultBlock
|
||||
key={qid}
|
||||
title={question ? questionHead(question) : qid}
|
||||
result={slot?.result}
|
||||
error={slot?.error}
|
||||
pending={!!slot && !slot.result && !slot.error}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</ReportFrame>
|
||||
{filterOpen ? (
|
||||
<FilterPopup
|
||||
open
|
||||
initial={conditions.filterLines}
|
||||
questions={questions.data ?? []}
|
||||
onOpenChange={setFilterOpen}
|
||||
onSave={(filterLines) => change({ filterLines })}
|
||||
/>
|
||||
) : null}
|
||||
{bookmarks.popupOpen ? (
|
||||
<BookmarkPopup
|
||||
state={bookmarks}
|
||||
buildJson={() =>
|
||||
writeBookmarkJson({
|
||||
index: indexes,
|
||||
banners: conditions.banners,
|
||||
filter: currentFilter(),
|
||||
option,
|
||||
isTest: conditions.isTest,
|
||||
isAxis: conditions.isAxis,
|
||||
})
|
||||
}
|
||||
onSaved={() => setLoadedFilter(currentFilter())}
|
||||
onDeleted={() => applyBookmark(null)}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
357
src/components/report/FilterPopup.tsx
Normal file
357
src/components/report/FilterPopup.tsx
Normal file
@@ -0,0 +1,357 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useState } from "react";
|
||||
import type { Question } from "@/types/report";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { KriSelect } from "@/components/common/KriSelect";
|
||||
import {
|
||||
KriMultiSelect,
|
||||
KriSingleSelect,
|
||||
} from "@/components/common/KriAutoComplete";
|
||||
import { choices } from "@/lib/report-contract";
|
||||
import { questionViewTitle } from "@/lib/report-ui";
|
||||
import {
|
||||
FILTER_OPERATORS,
|
||||
filterCondition,
|
||||
newFilterLine,
|
||||
toServerFilter,
|
||||
type AndOr,
|
||||
type LegacyFilterLine,
|
||||
} from "@/lib/legacy-filter";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { plainText } from "./ReportResultView";
|
||||
|
||||
type Update = (id: string, fn: (line: LegacyFilterLine) => LegacyFilterLine | null) => void;
|
||||
|
||||
/** Applies `fn` to the line with `id` anywhere in the tree; returning null removes it. */
|
||||
function updateTree(
|
||||
list: LegacyFilterLine[],
|
||||
id: string,
|
||||
fn: (line: LegacyFilterLine) => LegacyFilterLine | null,
|
||||
): LegacyFilterLine[] {
|
||||
return list.flatMap((line) => {
|
||||
if (line.id === id) {
|
||||
const next = fn(line);
|
||||
return next ? [next] : [];
|
||||
}
|
||||
return [{ ...line, childList: updateTree(line.childList, id, fn) }];
|
||||
});
|
||||
}
|
||||
|
||||
/** Legacy FilterPopup: nested AND/OR condition lines with the "Selected Filter" preview. */
|
||||
export function FilterPopup({
|
||||
open,
|
||||
initial,
|
||||
questions,
|
||||
onOpenChange,
|
||||
onSave,
|
||||
}: {
|
||||
open: boolean;
|
||||
initial: LegacyFilterLine[];
|
||||
questions: Question[];
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onSave: (lines: LegacyFilterLine[]) => void;
|
||||
}) {
|
||||
const [lines, setLines] = useState(initial);
|
||||
const update: Update = (id, fn) => setLines((current) => updateTree(current, id, fn));
|
||||
const options = questions.filter(
|
||||
(question) => question.qtype !== "text" && question.isDerived !== "2",
|
||||
);
|
||||
const save = () => {
|
||||
try {
|
||||
toServerFilter(lines);
|
||||
} catch (error) {
|
||||
window.alert(error instanceof Error ? error.message : "필터를 확인해 주세요.");
|
||||
return;
|
||||
}
|
||||
onSave(lines);
|
||||
onOpenChange(false);
|
||||
};
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent
|
||||
showCloseButton={false}
|
||||
className="w-[1200px] max-w-[calc(100vw-2rem)] gap-0 overflow-hidden rounded-[15px] border-0 p-0 sm:max-w-[1200px]"
|
||||
>
|
||||
<div className="flex h-[55px] items-center gap-2 bg-kart-green px-5">
|
||||
{/* Legacy reuses the green filter tile; on the green header only the white glyph shows. */}
|
||||
<Image src="/images/kart/ic_filter_36.png" alt="" width={36} height={36} className="h-[33px] w-9" unoptimized />
|
||||
<DialogTitle className="text-base leading-[20.5px] font-bold text-white">
|
||||
Filter
|
||||
</DialogTitle>
|
||||
<DialogDescription className="sr-only">
|
||||
필터 조건을 만들고 Save로 적용합니다.
|
||||
</DialogDescription>
|
||||
<DialogClose className="ml-auto cursor-pointer" aria-label="닫기">
|
||||
<Image src="/images/kart/ic_close_w.png" alt="" width={18} height={18} unoptimized />
|
||||
</DialogClose>
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<div className="h-[550px] overflow-y-auto">
|
||||
{lines.length === 0 ? (
|
||||
<div className="pt-2.5 pl-1.5">
|
||||
<PlusButton onClick={() => setLines([newFilterLine("fil_0")])} />
|
||||
</div>
|
||||
) : (
|
||||
<FilterList
|
||||
lines={lines}
|
||||
parentId=""
|
||||
questions={options}
|
||||
update={update}
|
||||
setRoot={setLines}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<h3 className="text-base leading-[20.5px] font-bold text-kart-text">
|
||||
Selected Filter
|
||||
</h3>
|
||||
<input
|
||||
type="text"
|
||||
readOnly
|
||||
aria-label="선택한 필터"
|
||||
value={filterCondition(lines)}
|
||||
className="mt-1 h-9 w-full rounded-[4px] border border-kart-line bg-kart-bg px-3.5 text-sm font-light text-kart-text outline-none"
|
||||
/>
|
||||
<div className="mt-2.5 text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={save}
|
||||
className="h-[50px] w-[156px] cursor-pointer rounded-[4px] bg-kart-green text-base font-bold text-white"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function FilterList({
|
||||
lines,
|
||||
parentId,
|
||||
questions,
|
||||
update,
|
||||
setRoot,
|
||||
}: {
|
||||
lines: LegacyFilterLine[];
|
||||
parentId: string;
|
||||
questions: Question[];
|
||||
update: Update;
|
||||
setRoot: (fn: (lines: LegacyFilterLine[]) => LegacyFilterLine[]) => void;
|
||||
}) {
|
||||
// Legacy ids: siblings share the parent prefix ("fil_" / "fil_0_") plus their index.
|
||||
const addSibling = () => {
|
||||
const prefix = parentId ? parentId + "_" : "fil_";
|
||||
const append = (list: LegacyFilterLine[]) => [
|
||||
...list,
|
||||
newFilterLine(prefix + list.length, "AND"),
|
||||
];
|
||||
if (!parentId) setRoot(append);
|
||||
else update(parentId, (line) => ({ ...line, childList: append(line.childList) }));
|
||||
};
|
||||
return (
|
||||
<ul className="border-l-2 border-kart-line pl-2.5">
|
||||
{lines.map((line, index) => (
|
||||
<li key={line.id} className="py-1">
|
||||
{index > 0 ? (
|
||||
<AndOrToggle
|
||||
value={line.preAndOr}
|
||||
onChange={(value) => update(line.id, (item) => ({ ...item, preAndOr: value }))}
|
||||
/>
|
||||
) : null}
|
||||
<FilterLineRow line={line} questions={questions} update={update} />
|
||||
{line.childList.length > 0 ? (
|
||||
<>
|
||||
<AndOrToggle
|
||||
value={line.postAndOr}
|
||||
onChange={(value) => update(line.id, (item) => ({ ...item, postAndOr: value }))}
|
||||
/>
|
||||
<div className="ml-5">
|
||||
<FilterList
|
||||
lines={line.childList}
|
||||
parentId={line.id}
|
||||
questions={questions}
|
||||
update={update}
|
||||
setRoot={setRoot}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
{index === lines.length - 1 ? (
|
||||
<div className="mt-1.5 flex gap-1">
|
||||
<PlusButton onClick={addSibling} />
|
||||
{line.childList.length === 0 ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="하위 조건 추가"
|
||||
className="cursor-pointer"
|
||||
onClick={() =>
|
||||
update(line.id, (item) => ({
|
||||
...item,
|
||||
postAndOr: "AND",
|
||||
childList: [newFilterLine(item.id + "_0")],
|
||||
}))
|
||||
}
|
||||
>
|
||||
<Image src="/images/kart/ic_return.png" alt="" width={22} height={22} unoptimized />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function FilterLineRow({
|
||||
line,
|
||||
questions,
|
||||
update,
|
||||
}: {
|
||||
line: LegacyFilterLine;
|
||||
questions: Question[];
|
||||
update: Update;
|
||||
}) {
|
||||
const question = questions.find((item) => item.qid === line.qid);
|
||||
const numeric = question?.qtype === "num";
|
||||
const multi = line.op.includes("IN");
|
||||
const values = line.value ? line.value.split(",") : [];
|
||||
const valueOptions = question
|
||||
? choices(question).map((option) => ({
|
||||
value: option.value,
|
||||
label: plainText(option.label),
|
||||
}))
|
||||
: [];
|
||||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
<KriSingleSelect
|
||||
items={questions}
|
||||
value={line.qid}
|
||||
getValue={(item) => item.qid}
|
||||
getLabel={(item) => plainText(questionViewTitle(item))}
|
||||
placeholder="문항 선택"
|
||||
widthClassName="w-[300px]"
|
||||
className="h-[38px] min-h-[38px] rounded-[4px] border-[#d0d0d0] text-sm"
|
||||
spanClassName="text-sm"
|
||||
searchable
|
||||
preventDeselect
|
||||
hideOptionCheck
|
||||
onChange={(qid) => {
|
||||
const selected = questions.find((item) => item.qid === qid);
|
||||
if (!selected) return;
|
||||
update(line.id, (item) => ({
|
||||
...item,
|
||||
qid,
|
||||
vname: selected.variable ?? selected.qid,
|
||||
op: "IN",
|
||||
value: "",
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
<KriSelect
|
||||
items={FILTER_OPERATORS}
|
||||
value={line.op}
|
||||
useAll={false}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
className="h-[38px] w-[150px] rounded-[4px] border-[#d0d0d0] text-sm"
|
||||
onChange={(value) => {
|
||||
const op = FILTER_OPERATORS.find((item) => item.value === value)?.value;
|
||||
if (!op) return;
|
||||
update(line.id, (item) => ({
|
||||
...item,
|
||||
op,
|
||||
// Legacy: NULL checks drop values; single comparisons keep the first code.
|
||||
value: op.includes("NULL") ? "" : op.includes("IN") ? item.value : item.value.split(",")[0],
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
{line.op.includes("NULL") ? null : numeric ? (
|
||||
<input
|
||||
type="text"
|
||||
value={line.value}
|
||||
placeholder="숫자, ','만 가능"
|
||||
aria-label="비교 값"
|
||||
className="h-[38px] w-[150px] rounded-[4px] border border-[#d0d0d0] px-3.5 text-sm text-kart-text outline-none"
|
||||
onChange={(event) => {
|
||||
const value = event.target.value.replace(/[^0-9.,]/g, "").replace(/(\.*)\./g, "$1");
|
||||
update(line.id, (item) => ({ ...item, value }));
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<KriMultiSelect
|
||||
// Remount when the question or operator changes so stale picks are dropped.
|
||||
key={line.qid + ":" + (multi ? "multi" : "single")}
|
||||
items={valueOptions}
|
||||
value={values}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="값 선택"
|
||||
widthClassName="w-[250px]"
|
||||
className="h-[38px] min-h-[38px] rounded-[4px] border-[#d0d0d0] text-sm"
|
||||
spanClassName="text-sm"
|
||||
badgeClassName="text-xs"
|
||||
maxSelected={multi ? undefined : 1}
|
||||
hideSelectAll={!multi}
|
||||
onChange={(next) => {
|
||||
// Legacy keeps codes sorted and comma-joined.
|
||||
const value = [...next].sort().join(",");
|
||||
update(line.id, (item) => ({ ...item, value }));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
aria-label="조건 삭제"
|
||||
className="cursor-pointer"
|
||||
onClick={() => update(line.id, () => null)}
|
||||
>
|
||||
<Image src="/images/kart/ic_minus.png" alt="" width={22} height={22} unoptimized />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AndOrToggle({
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
value: AndOr;
|
||||
onChange: (value: AndOr) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="my-1.5 inline-flex overflow-hidden rounded-full border border-kart-line text-xs font-bold">
|
||||
{(["AND", "OR"] as const).map((option) => (
|
||||
<button
|
||||
key={option}
|
||||
type="button"
|
||||
aria-pressed={value === option}
|
||||
onClick={() => onChange(option)}
|
||||
className={cn(
|
||||
"cursor-pointer px-3 py-1",
|
||||
value === option ? "bg-kart-green text-white" : "bg-white text-[#9e9e9e]",
|
||||
)}
|
||||
>
|
||||
{option}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PlusButton({ onClick }: { onClick: () => void }) {
|
||||
return (
|
||||
<button type="button" aria-label="조건 추가" className="cursor-pointer" onClick={onClick}>
|
||||
<Image src="/images/kart/ic_plus_filter.png" alt="" width={22} height={22} unoptimized />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
119
src/components/report/IndexBox.tsx
Normal file
119
src/components/report/IndexBox.tsx
Normal file
@@ -0,0 +1,119 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useDndContext, useDroppable } from "@dnd-kit/core";
|
||||
import {
|
||||
SortableContext,
|
||||
useSortable,
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import type { Question } from "@/types/report";
|
||||
import { isDerivedQuestion, questionViewTitle } from "@/lib/report-ui";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { plainText } from "./ReportResultView";
|
||||
import {
|
||||
QUESTION_COLOR,
|
||||
VARIABLE_COLOR,
|
||||
readDragData,
|
||||
type DragIndexItem,
|
||||
} from "./QuestionList";
|
||||
|
||||
export const indexItemId = (qid: string) => "index:" + qid;
|
||||
|
||||
/** Legacy Cross Tab IndexBox: ordered tables plus the "Drag&Drop" area accepting any question. */
|
||||
export function IndexBox({
|
||||
indexes,
|
||||
questions,
|
||||
onRemove,
|
||||
}: {
|
||||
indexes: string[];
|
||||
questions: Question[];
|
||||
onRemove: (qid: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="p-4">
|
||||
<SortableContext items={indexes.map(indexItemId)} strategy={verticalListSortingStrategy}>
|
||||
{indexes.map((qid) => (
|
||||
<IndexItem
|
||||
key={qid}
|
||||
qid={qid}
|
||||
question={questions.find((item) => item.qid === qid)}
|
||||
onRemove={() => onRemove(qid)}
|
||||
/>
|
||||
))}
|
||||
</SortableContext>
|
||||
<IndexDrop />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function IndexItem({
|
||||
qid,
|
||||
question,
|
||||
onRemove,
|
||||
}: {
|
||||
qid: string;
|
||||
question?: Question;
|
||||
onRemove: () => void;
|
||||
}) {
|
||||
const data: DragIndexItem = { kind: "index-item", qid };
|
||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
||||
useSortable({ id: indexItemId(qid), data });
|
||||
const view = question ? questionViewTitle(question) : qid;
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
className="mt-[3px] flex h-9 cursor-pointer items-center justify-center pr-2.5"
|
||||
style={{
|
||||
background:
|
||||
question && isDerivedQuestion(question) ? VARIABLE_COLOR : QUESTION_COLOR,
|
||||
opacity: isDragging ? 0 : 1,
|
||||
transform: CSS.Transform.toString(transform),
|
||||
transition,
|
||||
}}
|
||||
>
|
||||
<span className="block min-w-0 flex-1 overflow-hidden px-3 py-2 text-sm leading-5 text-ellipsis whitespace-nowrap text-kart-text">
|
||||
{plainText(view)}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={plainText(view) + " 표에서 삭제"}
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onClick={onRemove}
|
||||
className="shrink-0 cursor-pointer"
|
||||
>
|
||||
<Image src="/images/kart/ic_close.png" alt="" width={12} height={12} unoptimized />
|
||||
</button>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" className="max-w-md opacity-65">
|
||||
{plainText(view)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
function IndexDrop() {
|
||||
const { setNodeRef, isOver } = useDroppable({ id: "index-drop" });
|
||||
const { active } = useDndContext();
|
||||
const canDrop = readDragData(active?.data.current)?.kind === "question";
|
||||
return (
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
className="mt-[3px] flex h-14 flex-col items-center justify-center rounded-[15px] border-2 border-dashed bg-white py-1.5"
|
||||
style={{ borderColor: canDrop || isOver ? "#1cae81" : "#d0d0d0" }}
|
||||
>
|
||||
<Image src="/images/kart/ic_drop.svg" alt="" width={16} height={16} className="size-4 grayscale" unoptimized />
|
||||
<p className="text-xs leading-[17px] text-[#989898]">Drag&Drop</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
129
src/components/report/LegacyResultTable.tsx
Normal file
129
src/components/report/LegacyResultTable.tsx
Normal file
@@ -0,0 +1,129 @@
|
||||
"use client";
|
||||
|
||||
import type { ReportResult, ReportRow } from "@/types/report";
|
||||
import { isTransposed, legacyCellText } from "@/lib/report-ui";
|
||||
import { HtmlText, plainText } from "./ReportResultView";
|
||||
import { TableLoading } from "./ReportParts";
|
||||
import { WordCloud } from "./WordCloud";
|
||||
|
||||
/** Legacy Table.js ResultTable look: grey header grid, bold first column, centred values. */
|
||||
export function LegacyResultTable({ result }: { result: ReportResult }) {
|
||||
if (!result.headerRows.length && !result.rows.length)
|
||||
return <ResultMessage message="Data가 없습니다." />;
|
||||
return (
|
||||
<div className="min-w-[320px] overflow-x-auto">
|
||||
<table className="w-full border-collapse bg-kart-soft text-sm leading-5 whitespace-break-spaces text-kart-text">
|
||||
<caption className="sr-only">
|
||||
{plainText(result.title ?? result.questionId)}
|
||||
</caption>
|
||||
<thead>
|
||||
{result.headerRows.map((row, index) => (
|
||||
<Row key={row.rowIndex} row={row} result={result} header firstRow={index === 0} />
|
||||
))}
|
||||
</thead>
|
||||
<tbody className="border-b border-kart-line">
|
||||
{result.rows.map((row) => (
|
||||
<Row key={row.rowIndex} row={row} result={result} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Row({
|
||||
row,
|
||||
result,
|
||||
header = false,
|
||||
firstRow = false,
|
||||
}: {
|
||||
row: ReportRow;
|
||||
result: ReportResult;
|
||||
header?: boolean;
|
||||
firstRow?: boolean;
|
||||
}) {
|
||||
const transposed = isTransposed(result);
|
||||
return (
|
||||
<tr className="border border-b-0 border-kart-line">
|
||||
{row.cells.map((cell) => {
|
||||
const th = header || cell.columnIndex === 0;
|
||||
const Tag = th ? "th" : "td";
|
||||
return (
|
||||
<Tag
|
||||
key={cell.columnIndex}
|
||||
rowSpan={cell.rowSpan}
|
||||
colSpan={cell.colSpan}
|
||||
className={
|
||||
th
|
||||
? "max-w-[300px] border border-kart-line p-3.5 text-center font-bold" +
|
||||
(firstRow && cell.columnIndex === 0
|
||||
? " w-[300px] min-w-[300px]"
|
||||
: "")
|
||||
: "max-w-[300px] border-r border-kart-line bg-white p-3.5 text-center font-normal"
|
||||
}
|
||||
>
|
||||
{cell.kind === "TEXT" ? (
|
||||
<HtmlText text={cell.textValue} />
|
||||
) : (
|
||||
legacyCellText(
|
||||
cell,
|
||||
row.kind,
|
||||
result.columns[cell.columnIndex]?.kind,
|
||||
transposed,
|
||||
)
|
||||
)}
|
||||
</Tag>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
/** One legacy result: heading (EXPLAIN) then the table, word cloud, loading gif or message. */
|
||||
export function ResultBlock({
|
||||
title,
|
||||
result,
|
||||
error,
|
||||
pending,
|
||||
}: {
|
||||
title: string;
|
||||
result?: ReportResult;
|
||||
error?: string;
|
||||
pending: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<h3 className="py-5 text-base leading-[20.5px] font-bold text-kart-title">
|
||||
<HtmlText text={title} />
|
||||
</h3>
|
||||
{result ? (
|
||||
result.type === "TEXT_ANALYSIS" ? (
|
||||
<WordCloud result={result} />
|
||||
) : (
|
||||
<LegacyResultTable result={result} />
|
||||
)
|
||||
) : error ? (
|
||||
<ResultMessage message={error} />
|
||||
) : pending ? (
|
||||
<TableLoading />
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy non-array body: a single bordered message row. */
|
||||
export function ResultMessage({ message }: { message: string }) {
|
||||
return (
|
||||
<div className="min-w-[320px] overflow-x-auto">
|
||||
<table className="w-full bg-kart-soft text-sm text-kart-text">
|
||||
<thead>
|
||||
<tr className="border border-kart-line">
|
||||
<td className="bg-white p-3.5 text-center" role="alert">
|
||||
{message}
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
187
src/components/report/QuestionList.tsx
Normal file
187
src/components/report/QuestionList.tsx
Normal file
@@ -0,0 +1,187 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useState } from "react";
|
||||
import { useDraggable } from "@dnd-kit/core";
|
||||
import type { Question } from "@/types/report";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { dragLocation, questionViewTitle } from "@/lib/report-ui";
|
||||
import { isRecord } from "@/types/kart";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { plainText } from "./ReportResultView";
|
||||
|
||||
export type DragQuestion = { kind: "question"; qid: string; loc: "row" | "all" };
|
||||
export type DragBannerItem = { kind: "banner-item"; group: number; qid: string };
|
||||
export type DragIndexItem = { kind: "index-item"; qid: string };
|
||||
export type DragData = DragQuestion | DragBannerItem | DragIndexItem;
|
||||
|
||||
/** Narrows dnd-kit's untyped `data.current` to the payloads this page attaches. */
|
||||
export function readDragData(data: unknown): DragData | null {
|
||||
if (!isRecord(data)) return null;
|
||||
if (
|
||||
data.kind === "question" &&
|
||||
typeof data.qid === "string" &&
|
||||
(data.loc === "row" || data.loc === "all")
|
||||
)
|
||||
return { kind: "question", qid: data.qid, loc: data.loc };
|
||||
if (
|
||||
data.kind === "banner-item" &&
|
||||
typeof data.qid === "string" &&
|
||||
typeof data.group === "number"
|
||||
)
|
||||
return { kind: "banner-item", qid: data.qid, group: data.group };
|
||||
if (data.kind === "index-item" && typeof data.qid === "string")
|
||||
return { kind: "index-item", qid: data.qid };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Legacy item colours: survey questions vs derived variables.
|
||||
export const QUESTION_COLOR = "#B7E8E3";
|
||||
export const VARIABLE_COLOR = "#DAECAF";
|
||||
|
||||
/** Legacy QuestionBox / VariableBox: collapsible list whose items are drag sources. */
|
||||
export function QuestionList({
|
||||
title,
|
||||
variant,
|
||||
questions,
|
||||
selected,
|
||||
onToggle,
|
||||
onSelectAll,
|
||||
}: {
|
||||
title: string;
|
||||
variant: "question" | "variable";
|
||||
questions: Question[];
|
||||
/** Tabulation: click-to-select ids. Undefined in Cross Tab, where every item is coloured. */
|
||||
selected?: string[];
|
||||
onToggle?: (qid: string) => void;
|
||||
onSelectAll?: (all: boolean) => void;
|
||||
}) {
|
||||
const [open, setOpen] = useState(true);
|
||||
if (!questions.length) return null;
|
||||
const allSelected =
|
||||
!!selected && questions.every((question) => selected.includes(question.qid));
|
||||
return (
|
||||
<div className="mb-5 rounded-[15px] bg-white shadow-[1px_0_0_0_#e1e1e1,0_1px_0_0_#e1e1e1,1px_1px_0_0_#e1e1e1,inset_1px_0_0_0_#e1e1e1,inset_0_1px_0_0_#e1e1e1]">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen(!open)}
|
||||
className="relative mb-2 flex h-[55px] w-full cursor-pointer items-center gap-2 rounded-[15px] bg-kart-soft p-2.5 shadow-[1px_0_0_0_#e1e1e1,0_1px_0_0_#e1e1e1,1px_1px_0_0_#e1e1e1,inset_1px_0_0_0_#e1e1e1,inset_0_1px_0_0_#e1e1e1]"
|
||||
>
|
||||
<Image
|
||||
src="/images/kart/icon_circle.svg"
|
||||
alt=""
|
||||
width={36}
|
||||
height={36}
|
||||
className="size-9"
|
||||
unoptimized
|
||||
/>
|
||||
<h3 className="text-base leading-[20.5px] font-bold text-kart-title">
|
||||
{title}
|
||||
</h3>
|
||||
<Image
|
||||
src={
|
||||
open
|
||||
? "/images/kart/acc_arrow_open.png"
|
||||
: "/images/kart/acc_arrow_close.png"
|
||||
}
|
||||
alt=""
|
||||
width={24}
|
||||
height={14}
|
||||
className="absolute right-5"
|
||||
unoptimized
|
||||
/>
|
||||
</button>
|
||||
<div
|
||||
className={cn(
|
||||
"grid transition-[grid-template-rows] duration-500",
|
||||
open ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
|
||||
)}
|
||||
>
|
||||
<div className="overflow-hidden">
|
||||
{onSelectAll ? (
|
||||
<div className="flex h-5 justify-end pr-2.5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onSelectAll(!allSelected)}
|
||||
className={cn(
|
||||
"ml-2 cursor-pointer text-xs leading-5 font-bold",
|
||||
allSelected ? "text-kart-green" : "text-[#9e9e9e]",
|
||||
)}
|
||||
>
|
||||
Select All
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
<ul className="max-h-[650px] overflow-y-scroll px-4 pb-2 [&::-webkit-scrollbar]:w-[6px][&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-[#9e9e9e] [&::-webkit-scrollbar-track]:bg-kart-line">
|
||||
{questions.map((question) => (
|
||||
<QuestionItem
|
||||
key={question.qid}
|
||||
question={question}
|
||||
color={
|
||||
!selected || selected.includes(question.qid)
|
||||
? variant === "question"
|
||||
? QUESTION_COLOR
|
||||
: VARIABLE_COLOR
|
||||
: undefined
|
||||
}
|
||||
onClick={onToggle ? () => onToggle(question.qid) : undefined}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function QuestionItem({
|
||||
question,
|
||||
color,
|
||||
onClick,
|
||||
}: {
|
||||
question: Question;
|
||||
color?: string;
|
||||
onClick?: () => void;
|
||||
}) {
|
||||
const view = questionViewTitle(question);
|
||||
const data: DragQuestion = {
|
||||
kind: "question",
|
||||
qid: question.qid,
|
||||
loc: dragLocation(question),
|
||||
};
|
||||
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({
|
||||
id: "question:" + question.qid,
|
||||
data,
|
||||
});
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<li
|
||||
ref={setNodeRef}
|
||||
{...attributes}
|
||||
{...listeners}
|
||||
onClick={onClick}
|
||||
aria-current={onClick && color !== undefined ? "true" : undefined}
|
||||
className="relative mt-2 cursor-pointer list-none overflow-hidden px-3 py-2 text-sm leading-5 whitespace-nowrap text-kart-text transition-all"
|
||||
style={{
|
||||
backgroundColor: color ?? "#f5f5f5",
|
||||
opacity: isDragging ? 0.4 : 1,
|
||||
}}
|
||||
>
|
||||
{/* Legacy list rows show the title as one plain line with an ellipsis. */}
|
||||
<span className="inline-block w-full overflow-hidden text-ellipsis">
|
||||
{plainText(view)}
|
||||
</span>
|
||||
</li>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" className="max-w-md opacity-65">
|
||||
{plainText(view)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
62
src/components/report/QuotaTable.tsx
Normal file
62
src/components/report/QuotaTable.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
"use client";
|
||||
|
||||
import type { QuotaCell, QuotaResult } from "@/types/quota";
|
||||
import { quotaCellStyle } from "@/lib/quota-ui";
|
||||
import { HtmlText, plainText } from "./ReportResultView";
|
||||
|
||||
/** Legacy ResultTable with isQuota: complete (coloured) / target over an achievement gauge. */
|
||||
export function QuotaTable({ result }: { result: QuotaResult }) {
|
||||
return (
|
||||
<div className="min-w-[320px] overflow-x-auto">
|
||||
<table className="w-full border-collapse bg-kart-soft text-sm leading-5 whitespace-break-spaces text-kart-text">
|
||||
<caption className="sr-only">{plainText(result.title ?? "")}</caption>
|
||||
<thead>
|
||||
{result.headerRows.map((row, index) => (
|
||||
<tr key={row.rowIndex} className="border border-b-0 border-kart-line">
|
||||
{row.cells.map((cell) => (
|
||||
<th
|
||||
key={cell.columnIndex}
|
||||
rowSpan={cell.rowSpan}
|
||||
colSpan={cell.colSpan}
|
||||
className={
|
||||
"border border-kart-line p-3.5 text-center font-bold" +
|
||||
(index === 0 && cell.columnIndex === 0 ? " w-[200px] min-w-[200px]" : "")
|
||||
}
|
||||
>
|
||||
<HtmlText text={cell.textValue} />
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</thead>
|
||||
<tbody className="border-b border-kart-line">
|
||||
{result.rows.map((row) => (
|
||||
<tr key={row.rowIndex} className="border border-b-0 border-kart-line">
|
||||
{row.cells.map((cell) =>
|
||||
cell.kind === "QUOTA" ? (
|
||||
<QuotaValue key={cell.columnIndex} cell={cell} />
|
||||
) : (
|
||||
<th key={cell.columnIndex} className="border border-kart-line p-3.5 text-center font-bold">
|
||||
<HtmlText text={cell.textValue} />
|
||||
</th>
|
||||
),
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function QuotaValue({ cell }: { cell: QuotaCell }) {
|
||||
const style = quotaCellStyle(cell);
|
||||
return (
|
||||
<td
|
||||
className="border-r border-kart-line bg-white p-3.5 text-center font-normal"
|
||||
style={style.background ? { background: style.background } : undefined}
|
||||
>
|
||||
<span style={{ color: style.color }}>{cell.complete ?? "-"}</span>/{cell.target ?? "-"}
|
||||
</td>
|
||||
);
|
||||
}
|
||||
163
src/components/report/QuotaWorkspace.tsx
Normal file
163
src/components/report/QuotaWorkspace.tsx
Normal file
@@ -0,0 +1,163 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { QueryState } from "@/components/project/QueryState";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useFileDownload } from "@/query/export";
|
||||
import { EXPORT_PREFIX } from "@/lib/download-name";
|
||||
import { useProjectTitle } from "@/query/project";
|
||||
import { quotaResultQuery, useQuotaListQuery, useQuotaResultQuery } from "@/query/quota";
|
||||
import { projectKey, type ProjectRef } from "@/types/kart";
|
||||
import { quotaTooltip } from "@/types/quota";
|
||||
import { quotaExcelBody, type ExcelTable } from "@/lib/report-excel";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { LeftToggleBox } from "./ReportChrome";
|
||||
import { LegacyCheck, TableLoading } from "./ReportParts";
|
||||
import { ResultMessage } from "./LegacyResultTable";
|
||||
import { plainText } from "./ReportResultView";
|
||||
import { QuotaTable } from "./QuotaTable";
|
||||
|
||||
export function QuotaWorkspace() {
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const { project, hydrated } = useSelectedProject();
|
||||
const missing = hydrated && !project;
|
||||
useEffect(() => {
|
||||
if (missing) router.replace("/");
|
||||
}, [missing, router]);
|
||||
if (!project) return null;
|
||||
return (
|
||||
<Workspace
|
||||
key={JSON.stringify([
|
||||
projectKey(project),
|
||||
auth.user?.userId,
|
||||
auth.user?.userRole,
|
||||
auth.user?.userTeam,
|
||||
])}
|
||||
project={project}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy Quota.js: pick a saved quota setting (first one by default) and show complete/target. */
|
||||
function Workspace({ project }: { project: ProjectRef }) {
|
||||
const list = useQuotaListQuery(project);
|
||||
const { auth } = useAuth();
|
||||
const [chosen, setChosen] = useState<number | null>(null);
|
||||
const [isTest, setIsTest] = useState(false);
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
useVisitLog("/Report/Quota", project);
|
||||
// Legacy selects the first quota once the list arrives.
|
||||
const selected = chosen ?? list.data?.[0]?.qsOrder ?? null;
|
||||
const result = useQuotaResultQuery(project, selected, isTest ? "TEST" : "ACTUAL");
|
||||
const selectedSet = list.data?.find((set) => set.qsOrder === selected);
|
||||
const queryClient = useQueryClient();
|
||||
const download = useFileDownload();
|
||||
const projectTitle = useProjectTitle(project);
|
||||
// Legacy setExportQuota: every quota setting in list order, one sheet each.
|
||||
const exportQuota = useMutation({
|
||||
mutationFn: async () => {
|
||||
const dataScope = isTest ? "TEST" : "ACTUAL";
|
||||
const tables: ExcelTable[] = [];
|
||||
for (const set of list.data ?? []) {
|
||||
const quota = await queryClient.fetchQuery(
|
||||
quotaResultQuery(auth.user, project, set.qsOrder, dataScope),
|
||||
);
|
||||
const body = quotaExcelBody(quota);
|
||||
if (body) tables.push({ head: set.qsTitle ?? String(set.qsOrder), vname: "", qtype: "", body });
|
||||
}
|
||||
if (!tables.length) throw new Error("내보낼 쿼터 결과가 없습니다.");
|
||||
await download.mutateAsync({
|
||||
kind: "quota",
|
||||
project,
|
||||
request: { tables, turn: false },
|
||||
name: { prefix: EXPORT_PREFIX.quota, title: projectTitle },
|
||||
});
|
||||
},
|
||||
onError: (error) =>
|
||||
window.alert(apiError(error, { fallbackMessage: "Excel 파일을 만들지 못했습니다." }).message),
|
||||
});
|
||||
|
||||
return (
|
||||
<section aria-label="Quota" className="-mt-2.5">
|
||||
<div className="relative flex items-start justify-center gap-[1.041vw] py-5">
|
||||
{collapsed ? (
|
||||
<LeftToggleBox onExpand={() => setCollapsed(false)} />
|
||||
) : (
|
||||
<div className="min-h-[278px] w-[400px] shrink-0">
|
||||
<div className="relative pr-5 pb-5">
|
||||
<LegacyCheck id="chk_test" label="Use Test Data" checked={isTest} onChange={setIsTest} />
|
||||
<button
|
||||
type="button"
|
||||
aria-label="조건 영역 접기"
|
||||
onClick={() => setCollapsed(true)}
|
||||
className="absolute -top-2 right-0 cursor-pointer"
|
||||
>
|
||||
<Image src="/images/kart/btn_left.png" alt="" width={36} height={36} unoptimized />
|
||||
</button>
|
||||
</div>
|
||||
<div className="mb-5 rounded-[15px] bg-white shadow-[1px_0_0_0_#e1e1e1,0_1px_0_0_#e1e1e1,1px_1px_0_0_#e1e1e1,inset_1px_0_0_0_#e1e1e1,inset_0_1px_0_0_#e1e1e1]">
|
||||
<div className="mb-2 flex h-[55px] items-center gap-2 rounded-[15px] bg-kart-soft p-2.5 shadow-[1px_0_0_0_#e1e1e1,0_1px_0_0_#e1e1e1,1px_1px_0_0_#e1e1e1,inset_1px_0_0_0_#e1e1e1,inset_0_1px_0_0_#e1e1e1]">
|
||||
<Image src="/images/kart/icon_circle.svg" alt="" width={36} height={36} className="size-9" unoptimized />
|
||||
<h3 className="text-base leading-[20.5px] font-bold text-kart-title">Quota List</h3>
|
||||
<button
|
||||
type="button"
|
||||
disabled={exportQuota.isPending || !list.data?.length}
|
||||
onClick={() => exportQuota.mutate()}
|
||||
className="mr-2 ml-auto h-7 w-[113px] cursor-pointer rounded-[52px] bg-kart-green text-sm leading-[16px] font-bold text-white disabled:cursor-default"
|
||||
>
|
||||
Export Quota
|
||||
</button>
|
||||
</div>
|
||||
{list.isError ? (
|
||||
<div className="p-4">
|
||||
<QueryState error={list.error} onRetry={() => void list.refetch()} />
|
||||
</div>
|
||||
) : (
|
||||
<ul className="px-4 pb-2">
|
||||
{(list.data ?? []).map((set) => (
|
||||
<li key={set.qsOrder} title={quotaTooltip(set)} className="mt-2 list-none">
|
||||
<button
|
||||
type="button"
|
||||
aria-current={set.qsOrder === selected ? "true" : undefined}
|
||||
onClick={() => setChosen(set.qsOrder)}
|
||||
className={cn(
|
||||
"w-full cursor-pointer overflow-hidden px-3 py-2 text-left text-sm leading-5 text-ellipsis whitespace-nowrap transition-all",
|
||||
set.qsOrder === selected
|
||||
? "bg-kart-green text-white"
|
||||
: "bg-kart-bg text-kart-text",
|
||||
)}
|
||||
>
|
||||
{plainText(set.qsTitle ?? String(set.qsOrder))}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className={collapsed ? "ml-[75px] w-[calc(100%-100px)]" : "w-[calc(100%-400px)] min-w-0"}>
|
||||
{selectedSet ? (
|
||||
<h3 className="py-2.5 text-base leading-[20.5px] font-bold text-kart-title">
|
||||
{plainText(selectedSet.qsTitle ?? "")}
|
||||
</h3>
|
||||
) : null}
|
||||
{selected === null ? null : result.isError ? (
|
||||
<ResultMessage message={apiError(result.error, { fallbackMessage: "쿼터 결과를 불러오지 못했습니다." }).message} />
|
||||
) : result.data ? (
|
||||
<QuotaTable result={result.data} />
|
||||
) : (
|
||||
<TableLoading />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
167
src/components/report/ReportChrome.tsx
Normal file
167
src/components/report/ReportChrome.tsx
Normal file
@@ -0,0 +1,167 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Carousel, CarouselContent, CarouselItem, type CarouselApi } from "@/components/ui/carousel";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Bookmark } from "@/types/bookmark";
|
||||
|
||||
/**
|
||||
* Legacy tab_container (components/Bookmark.js): "New" plus the bookmark tabs in a slider that
|
||||
* scrolls two tabs at a time, arrows when overflowing, and the bookmark / refresh side buttons.
|
||||
*/
|
||||
export function ReportTabs({
|
||||
bookmarks,
|
||||
selectedId,
|
||||
onSelect,
|
||||
canSave,
|
||||
onBookmark,
|
||||
onRefresh,
|
||||
}: {
|
||||
bookmarks: Bookmark[];
|
||||
/** Null selects "New". */
|
||||
selectedId: string | null;
|
||||
onSelect: (bookmark: Bookmark | null) => void;
|
||||
/** Legacy shows the bookmark button only on "New" and the user's own bookmarks. */
|
||||
canSave: boolean;
|
||||
onBookmark: () => void;
|
||||
onRefresh: () => void;
|
||||
}) {
|
||||
const [api, setApi] = useState<CarouselApi>();
|
||||
const [canScroll, setCanScroll] = useState({ prev: false, next: false });
|
||||
useEffect(() => {
|
||||
if (!api) return;
|
||||
const update = () => {
|
||||
setCanScroll({ prev: api.canScrollPrev(), next: api.canScrollNext() });
|
||||
};
|
||||
update();
|
||||
api.on("select", update);
|
||||
api.on("reInit", update);
|
||||
return () => {
|
||||
api.off("select", update);
|
||||
api.off("reInit", update);
|
||||
};
|
||||
}, [api]);
|
||||
const tabs = [
|
||||
{ id: null, title: "New", bookmark: null },
|
||||
...bookmarks.map((bookmark) => ({
|
||||
id: bookmark.bookmarkId,
|
||||
title: bookmark.bookmarkTitle,
|
||||
bookmark,
|
||||
})),
|
||||
];
|
||||
const arrows = canScroll.prev || canScroll.next;
|
||||
return (
|
||||
<div className="relative top-0.5 flex h-[67px] justify-between bg-kart-bg px-4 pt-[23px]">
|
||||
{/* Bottom line drawn under the tabs so the active tab can cover it inside the slider. */}
|
||||
<div aria-hidden className="absolute inset-x-0 bottom-0 h-0.5 bg-kart-line" />
|
||||
<div className="relative w-[calc(100%-277px)] pr-[30px] pl-[38px]">
|
||||
{arrows ? (
|
||||
<TabArrow side="left" disabled={!canScroll.prev} onClick={() => api?.scrollPrev()} />
|
||||
) : null}
|
||||
<Carousel
|
||||
setApi={setApi}
|
||||
opts={{ align: "start", slidesToScroll: 2, containScroll: "trimSnaps" }}
|
||||
>
|
||||
<CarouselContent className="ml-0 gap-[0.416vw]">
|
||||
{tabs.map((tab) => {
|
||||
const active = tab.id === selectedId;
|
||||
return (
|
||||
<CarouselItem key={tab.id ?? ""} className="basis-auto pl-0">
|
||||
<button
|
||||
type="button"
|
||||
title={tab.bookmark ? tab.title : undefined}
|
||||
aria-current={active ? "page" : undefined}
|
||||
onClick={() => onSelect(tab.bookmark)}
|
||||
className={cn(
|
||||
"block h-11 w-[175px] cursor-pointer overflow-hidden rounded-t-[15px] border-2 border-b-0 border-kart-line text-center text-sm leading-[42px] font-bold text-ellipsis whitespace-nowrap",
|
||||
active ? "bg-white text-kart-green" : "bg-kart-line text-[#9e9e9e]",
|
||||
)}
|
||||
>
|
||||
{tab.title}
|
||||
</button>
|
||||
</CarouselItem>
|
||||
);
|
||||
})}
|
||||
</CarouselContent>
|
||||
</Carousel>
|
||||
{arrows ? (
|
||||
<TabArrow side="right" disabled={!canScroll.next} onClick={() => api?.scrollNext()} />
|
||||
) : null}
|
||||
</div>
|
||||
<div className="absolute top-4 right-[15px] flex items-center gap-2">
|
||||
{canSave ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="북마크"
|
||||
title="북마크"
|
||||
onClick={onBookmark}
|
||||
className="size-9 cursor-pointer rounded-[4px] border border-kart-line bg-white bg-[url(/images/kart/ic_bookmark_14.png)] bg-center bg-no-repeat"
|
||||
/>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
aria-label="다시 집계"
|
||||
title="다시 집계"
|
||||
onClick={onRefresh}
|
||||
className="size-9 cursor-pointer rounded-[4px] border border-kart-line bg-white bg-[url(/images/kart/ic_re.png)] bg-center bg-no-repeat"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy tab_arrows: 14x24 image buttons at the slider edges. */
|
||||
function TabArrow({ side, disabled, onClick }: { side: "left" | "right"; disabled: boolean; onClick: () => void }) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={side === "left" ? "이전 북마크" : "다음 북마크"}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
"absolute top-[11px] z-[1] h-6 w-3.5 cursor-pointer disabled:cursor-default disabled:opacity-30",
|
||||
side === "left" ? "left-0" : "right-0",
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
src={side === "left" ? "/images/kart/arrow_l.png" : "/images/kart/arrow_r.png"}
|
||||
alt=""
|
||||
width={14}
|
||||
height={24}
|
||||
unoptimized
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy LeftToggleBox shown while the condition panels are collapsed. */
|
||||
export function LeftToggleBox({ onExpand }: { onExpand: () => void }) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="조건 영역 펼치기"
|
||||
onClick={onExpand}
|
||||
className="absolute top-[19px] left-0 flex w-[86px] cursor-pointer flex-col items-center gap-[22px] rounded-r-[15px] border border-l-0 border-kart-line bg-white py-[18px]"
|
||||
>
|
||||
<Image src="/images/kart/btn_right.png" alt="" width={44} height={44} unoptimized />
|
||||
<Image src="/images/kart/ic_filter_36.png" alt="" width={36} height={36} unoptimized />
|
||||
<Image src="/images/kart/ic_document_36-1.svg" alt="" width={36} height={36} unoptimized />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy mobile Tabulation: the PC-only illustration. */
|
||||
export function PcOnlyNotice() {
|
||||
return (
|
||||
<div className="flex h-[80vh] items-center justify-center">
|
||||
<Image
|
||||
src="/images/kart/icon_pc.svg"
|
||||
alt="PC 화면에서 사용할 수 있습니다."
|
||||
width={233}
|
||||
height={140}
|
||||
unoptimized
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
133
src/components/report/ReportFrame.tsx
Normal file
133
src/components/report/ReportFrame.tsx
Normal file
@@ -0,0 +1,133 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import {
|
||||
DndContext,
|
||||
DragOverlay,
|
||||
KeyboardSensor,
|
||||
PointerSensor,
|
||||
pointerWithin,
|
||||
useSensor,
|
||||
useSensors,
|
||||
type DragEndEvent,
|
||||
type DragStartEvent,
|
||||
} from "@dnd-kit/core";
|
||||
import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import type { Question } from "@/types/report";
|
||||
import { questionViewTitle } from "@/lib/report-ui";
|
||||
import { LeftToggleBox } from "./ReportChrome";
|
||||
import { LegacyCheck } from "./ReportParts";
|
||||
import { readDragData } from "./QuestionList";
|
||||
import { plainText } from "./ReportResultView";
|
||||
|
||||
/**
|
||||
* Shared legacy Tabulation / Cross Tab frame: bookmark tabs, the collapsible left panel with the
|
||||
* Use Test Data / 세로 테이블 checks and question lists, drag-and-drop context, and the phone view.
|
||||
*/
|
||||
export function ReportFrame({
|
||||
label,
|
||||
tabs,
|
||||
isTest,
|
||||
onTestChange,
|
||||
isAxis,
|
||||
onAxisChange,
|
||||
lists,
|
||||
findQuestion,
|
||||
onDragEnd,
|
||||
phone,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
/** Bookmark tab bar (`ReportTabs`). */
|
||||
tabs: ReactNode;
|
||||
isTest: boolean;
|
||||
onTestChange: (value: boolean) => void;
|
||||
isAxis: boolean;
|
||||
onAxisChange: (value: boolean) => void;
|
||||
lists: ReactNode;
|
||||
findQuestion: (qid: string) => Question | undefined;
|
||||
onDragEnd: (event: DragEndEvent) => void;
|
||||
phone: ReactNode;
|
||||
children: (collapsed: boolean) => ReactNode;
|
||||
}) {
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
const [dragging, setDragging] = useState<Question | null>(null);
|
||||
const sensors = useSensors(
|
||||
// A short movement threshold keeps plain clicks as selection toggles.
|
||||
useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
|
||||
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
|
||||
);
|
||||
const onDragStart = (event: DragStartEvent) => {
|
||||
const data = readDragData(event.active.data.current);
|
||||
setDragging(data?.kind === "question" ? (findQuestion(data.qid) ?? null) : null);
|
||||
};
|
||||
return (
|
||||
<TooltipProvider delayDuration={0}>
|
||||
<section
|
||||
aria-label={label}
|
||||
className="-mx-[1.0416vw] -mt-2.5 -mb-6 min-h-[calc(100vh-146px)] bg-white"
|
||||
>
|
||||
{/* Legacy shows reduced content on phones (small touch screens). */}
|
||||
<div className="[@media(pointer:coarse)_and_(max-width:767px)]:hidden">
|
||||
{tabs}
|
||||
<DndContext
|
||||
sensors={sensors}
|
||||
collisionDetection={pointerWithin}
|
||||
onDragStart={onDragStart}
|
||||
onDragEnd={(event) => {
|
||||
setDragging(null);
|
||||
onDragEnd(event);
|
||||
}}
|
||||
onDragCancel={() => setDragging(null)}
|
||||
>
|
||||
<div className="relative px-[1.0416vw]">
|
||||
<div className="flex items-start justify-center gap-[1.041vw] py-5">
|
||||
{collapsed ? (
|
||||
<LeftToggleBox onExpand={() => setCollapsed(false)} />
|
||||
) : (
|
||||
<div className="min-h-[278px] w-[396px] shrink-0">
|
||||
<div className="relative pt-0.5 pr-5 pb-[18px]">
|
||||
<LegacyCheck id="chk_test" label="Use Test Data" checked={isTest} onChange={onTestChange} />
|
||||
<LegacyCheck id="chk_axis" label="세로 테이블" checked={isAxis} onChange={onAxisChange} />
|
||||
<button
|
||||
type="button"
|
||||
aria-label="조건 영역 접기"
|
||||
onClick={() => setCollapsed(true)}
|
||||
className="absolute -top-1.5 right-0 cursor-pointer"
|
||||
>
|
||||
<Image src="/images/kart/btn_left.png" alt="" width={36} height={36} unoptimized />
|
||||
</button>
|
||||
</div>
|
||||
{lists}
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className={
|
||||
collapsed
|
||||
? "relative ml-[75px] w-[calc(100%-100px)]"
|
||||
: "relative min-w-0 flex-1"
|
||||
}
|
||||
>
|
||||
{children(collapsed)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* Legacy react-dnd drops in place; no animation back to the source item. */}
|
||||
<DragOverlay dropAnimation={null}>
|
||||
{dragging ? (
|
||||
<div className="w-[356px] cursor-grabbing overflow-hidden bg-kart-bg px-3 py-2 text-sm leading-5 text-ellipsis whitespace-nowrap text-kart-text opacity-80 shadow">
|
||||
{plainText(questionViewTitle(dragging))}
|
||||
</div>
|
||||
) : null}
|
||||
</DragOverlay>
|
||||
</DndContext>
|
||||
</div>
|
||||
<div className="hidden [@media(pointer:coarse)_and_(max-width:767px)]:block">
|
||||
{phone}
|
||||
</div>
|
||||
</section>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
186
src/components/report/ReportParts.tsx
Normal file
186
src/components/report/ReportParts.tsx
Normal file
@@ -0,0 +1,186 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import type { ReactNode } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
|
||||
/** Legacy statistic_box: white card whose 55px title bar overlaps the border by 1px. */
|
||||
export function StatBox({
|
||||
icon,
|
||||
title,
|
||||
action,
|
||||
className,
|
||||
children,
|
||||
}: {
|
||||
icon: "filter" | "document";
|
||||
title: string;
|
||||
action?: ReactNode;
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"mb-4 rounded-[15px] border border-kart-line bg-white",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div className="-m-px flex h-[55px] items-center justify-between rounded-[15px] border border-kart-line bg-kart-soft p-2.5">
|
||||
<div className="flex items-center gap-2">
|
||||
<Image
|
||||
src={
|
||||
icon === "filter"
|
||||
? "/images/kart/ic_filter_36.png"
|
||||
: "/images/kart/ic_document_36-1.svg"
|
||||
}
|
||||
alt=""
|
||||
width={36}
|
||||
height={36}
|
||||
className="h-[33px] w-9 object-contain"
|
||||
unoptimized
|
||||
/>
|
||||
<h3 className="text-base leading-[20.5px] font-bold text-kart-title">
|
||||
{title}
|
||||
</h3>
|
||||
</div>
|
||||
{action}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy Filter box: Add Filter opens the popup; the read-only line shows the condition text. */
|
||||
export function FilterStatBox({
|
||||
condition,
|
||||
onAdd,
|
||||
onReset,
|
||||
}: {
|
||||
condition: string;
|
||||
onAdd: () => void;
|
||||
onReset: () => void;
|
||||
}) {
|
||||
return (
|
||||
<StatBox
|
||||
icon="filter"
|
||||
title="Filter"
|
||||
action={
|
||||
<button
|
||||
type="button"
|
||||
onClick={onAdd}
|
||||
className="h-7 w-[113px] cursor-pointer rounded-[52px] bg-kart-green bg-[url(/images/kart/ic_plus.png)] bg-position-[left_12px_center] bg-no-repeat pl-5 text-sm leading-[16px] font-bold text-white"
|
||||
>
|
||||
Add Filter
|
||||
</button>
|
||||
}
|
||||
>
|
||||
<div className="flex gap-2 p-4">
|
||||
<input
|
||||
type="text"
|
||||
readOnly
|
||||
aria-label="적용된 필터"
|
||||
value={condition}
|
||||
className="h-9 min-w-0 flex-1 rounded-[4px] bg-kart-bg px-3.5 py-1 text-sm leading-[19px] font-light text-kart-text outline-none"
|
||||
/>
|
||||
<ResetButton label="필터 초기화" onClick={onReset} />
|
||||
</div>
|
||||
</StatBox>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy 36px white reset square with the circular-arrow icon. */
|
||||
export function ResetButton({
|
||||
label,
|
||||
onClick,
|
||||
}: {
|
||||
label: string;
|
||||
onClick: () => void;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={label}
|
||||
title={label}
|
||||
onClick={onClick}
|
||||
className="size-9 shrink-0 cursor-pointer rounded-[4px] border border-kart-line bg-white bg-[url(/images/kart/ic_reset_16.png)] bg-size-[18px_17px] bg-center bg-no-repeat"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy 20px rounded checkbox: grey border, green fill with white check. */
|
||||
export function LegacyCheck({
|
||||
id,
|
||||
label,
|
||||
checked,
|
||||
onChange,
|
||||
}: {
|
||||
id: string;
|
||||
label: string;
|
||||
checked: boolean;
|
||||
onChange: (checked: boolean) => void;
|
||||
}) {
|
||||
return (
|
||||
<span className="inline-flex h-5 w-[150px] items-center gap-2.5 align-top text-sm leading-5 text-kart-text">
|
||||
<Checkbox
|
||||
id={id}
|
||||
checked={checked}
|
||||
onCheckedChange={(value) => onChange(value === true)}
|
||||
className="size-5 cursor-pointer rounded-[4px] border-[#ddd] bg-white shadow-none data-[state=checked]:border-kart-green data-[state=checked]:bg-kart-green data-[state=checked]:text-white"
|
||||
/>
|
||||
<label htmlFor={id} className="cursor-pointer">
|
||||
{label}
|
||||
</label>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy square_btn (156x50). Grey until every requested table has arrived, then green. */
|
||||
export function SquareButton({
|
||||
done,
|
||||
onClick,
|
||||
children,
|
||||
className,
|
||||
disabled,
|
||||
title,
|
||||
}: {
|
||||
done: boolean;
|
||||
onClick?: () => void;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
disabled?: boolean;
|
||||
title?: string;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
title={title}
|
||||
className={cn(
|
||||
"h-[50px] w-[156px] cursor-pointer rounded-[4px] text-base leading-[18.4px] font-bold text-white",
|
||||
done ? "bg-kart-green" : "bg-[#9e9e9e]",
|
||||
disabled && "cursor-default",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy TableLoading: 200px loading.gif centred in half the width. */
|
||||
export function TableLoading() {
|
||||
return (
|
||||
<div className="w-1/2 text-center" role="status" aria-label="집계 중">
|
||||
<Image
|
||||
src="/images/kart/loading.gif"
|
||||
alt=""
|
||||
width={200}
|
||||
height={200}
|
||||
className="inline-block w-[200px]"
|
||||
unoptimized
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
166
src/components/report/ReportResultView.tsx
Normal file
166
src/components/report/ReportResultView.tsx
Normal file
@@ -0,0 +1,166 @@
|
||||
"use client";
|
||||
|
||||
import DOMPurify from "dompurify";
|
||||
import type { DisplayMode, ReportCell, ReportResult } from "@/types/report";
|
||||
import { cellDisplay } from "@/lib/report-contract";
|
||||
|
||||
export function HtmlText({ text }: { text: string | null | undefined }) {
|
||||
if (!text) return null;
|
||||
if (typeof window === "undefined") return <span>{text}</span>;
|
||||
return (
|
||||
<span
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: DOMPurify.sanitize(text, {
|
||||
ALLOWED_TAGS: [
|
||||
"b",
|
||||
"strong",
|
||||
"em",
|
||||
"i",
|
||||
"u",
|
||||
"br",
|
||||
"span",
|
||||
"sub",
|
||||
"sup",
|
||||
],
|
||||
ALLOWED_ATTR: [],
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
/** Text content of a server HTML fragment (tooltips, aria labels). */
|
||||
export function plainText(html: string): string {
|
||||
if (typeof window === "undefined") return html;
|
||||
const safe = DOMPurify.sanitize(html, { ALLOWED_TAGS: [], ALLOWED_ATTR: [] });
|
||||
return new DOMParser().parseFromString(safe, "text/html").body.textContent ?? "";
|
||||
}
|
||||
export function questionLabel(question: {
|
||||
variable: string | null;
|
||||
qid: string;
|
||||
explain: string | null;
|
||||
title: string | null;
|
||||
}) {
|
||||
const text =
|
||||
(question.variable || question.qid) +
|
||||
". " +
|
||||
(question.explain || question.title || "");
|
||||
if (typeof window === "undefined") return text;
|
||||
const safe = DOMPurify.sanitize(text, { ALLOWED_TAGS: [], ALLOWED_ATTR: [] });
|
||||
return (
|
||||
new DOMParser().parseFromString(safe, "text/html").body.textContent ||
|
||||
question.qid
|
||||
);
|
||||
}
|
||||
export function ReportResultView({
|
||||
result,
|
||||
displayMode,
|
||||
}: {
|
||||
result: ReportResult;
|
||||
displayMode: DisplayMode;
|
||||
}) {
|
||||
if (result.type === "TEXT_ANALYSIS") return <TextResult result={result} />;
|
||||
const rows = [...result.headerRows, ...result.rows];
|
||||
if (!rows.length)
|
||||
return (
|
||||
<p className="p-6 text-sm text-muted-foreground">집계 결과가 없습니다.</p>
|
||||
);
|
||||
return (
|
||||
<div className="max-h-[75vh] overflow-auto rounded-lg border">
|
||||
<table className="w-full border-collapse text-sm tabular-nums">
|
||||
<caption className="sr-only">
|
||||
{result.title ?? result.questionId}
|
||||
</caption>
|
||||
<tbody>
|
||||
{rows.map((row, index) => (
|
||||
<tr
|
||||
key={row.rowIndex}
|
||||
className={
|
||||
row.kind === "TOTAL" ? "bg-[#eff8f3] font-semibold" : ""
|
||||
}
|
||||
>
|
||||
{row.cells.map((cell) => {
|
||||
const header =
|
||||
index < result.headerRows.length || cell.columnIndex === 0;
|
||||
const Tag = header ? "th" : "td";
|
||||
return (
|
||||
<Tag
|
||||
key={cell.columnIndex}
|
||||
rowSpan={cell.rowSpan}
|
||||
colSpan={cell.colSpan}
|
||||
className={
|
||||
"min-w-24 whitespace-pre-wrap border px-3 py-2.5 " +
|
||||
(header ? "bg-[#f5f6f7] font-medium " : "text-right ") +
|
||||
(cell.columnIndex === 0
|
||||
? "min-w-48 max-w-96 text-left "
|
||||
: "")
|
||||
}
|
||||
title={
|
||||
cell.base == null
|
||||
? undefined
|
||||
: "백분율 기준 사례수: " + cell.base
|
||||
}
|
||||
>
|
||||
<CellContent cell={cell} mode={displayMode} />
|
||||
</Tag>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
function CellContent({ cell, mode }: { cell: ReportCell; mode: DisplayMode }) {
|
||||
return cell.kind === "TEXT" ? (
|
||||
<HtmlText text={cell.textValue} />
|
||||
) : (
|
||||
<>{cellDisplay(cell, mode)}</>
|
||||
);
|
||||
}
|
||||
function TextResult({ result }: { result: ReportResult }) {
|
||||
if (!result.words.length)
|
||||
return (
|
||||
<p className="p-6 text-sm text-muted-foreground">
|
||||
분석할 단어가 없습니다.
|
||||
</p>
|
||||
);
|
||||
const maximum = Math.max(1, ...result.words.map((word) => word.count));
|
||||
return (
|
||||
<div className="grid gap-6 lg:grid-cols-[minmax(0,1fr)_240px]">
|
||||
<div
|
||||
className="flex min-h-64 flex-wrap content-center items-center justify-center gap-x-5 gap-y-3 rounded-lg bg-white p-6"
|
||||
aria-label="주관식 단어 빈도"
|
||||
>
|
||||
{result.words.map((word, index) => (
|
||||
<span
|
||||
key={index}
|
||||
title={word.text + ": " + word.count}
|
||||
style={{
|
||||
fontSize: 12 + Math.sqrt(word.count / maximum) * 36,
|
||||
color: ["#1CAE81", "#0066FF", "#FF7386", "#B066FA"][index % 4],
|
||||
}}
|
||||
>
|
||||
{word.text}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="mb-3 font-semibold">Top 10</h3>
|
||||
<ol className="space-y-2 text-sm">
|
||||
{result.words.slice(0, 10).map((word, index) => (
|
||||
<li
|
||||
key={index}
|
||||
className="flex justify-between gap-3 border-b pb-2"
|
||||
>
|
||||
<span>
|
||||
{index + 1}. {word.text}
|
||||
</span>
|
||||
<strong>{word.count.toLocaleString("ko-KR")}</strong>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
315
src/components/report/TabulationWorkspace.tsx
Normal file
315
src/components/report/TabulationWorkspace.tsx
Normal file
@@ -0,0 +1,315 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import type { DragEndEvent } from "@dnd-kit/core";
|
||||
import { QueryState } from "@/components/project/QueryState";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useReportBookmarks } from "@/hooks/useReportBookmarks";
|
||||
import { useVisitLog } from "@/hooks/useVisitLog";
|
||||
import { apiError } from "@kri/common/http";
|
||||
import { useFileDownload } from "@/query/export";
|
||||
import { EXPORT_PREFIX } from "@/lib/download-name";
|
||||
import { useProjectTitle } from "@/query/project";
|
||||
import { useQuestionQuery, useReportStream } from "@/query/report";
|
||||
import { projectKey, type ProjectRef } from "@/types/kart";
|
||||
import type { Bookmark } from "@/types/bookmark";
|
||||
import { canIndex, readReportBatch } from "@/lib/report-contract";
|
||||
import { isDerivedQuestion, questionHead } from "@/lib/report-ui";
|
||||
import {
|
||||
filterCondition,
|
||||
toServerFilter,
|
||||
type LegacyFilterLine,
|
||||
} from "@/lib/legacy-filter";
|
||||
import {
|
||||
bookmarkAxis,
|
||||
bookmarkFilter,
|
||||
bookmarkTest,
|
||||
emptyBookmarkFilter,
|
||||
emptyBookmarkSetting,
|
||||
readBookmarkSetting,
|
||||
writeBookmarkJson,
|
||||
} from "@/lib/bookmark-json";
|
||||
import { BannerBox, dropOnBanner, removeBanner } from "./BannerBox";
|
||||
import { BookmarkPopup } from "./BookmarkPopup";
|
||||
import { excelTables } from "./excel-tables";
|
||||
import { PcOnlyNotice, ReportTabs } from "./ReportChrome";
|
||||
import { ReportFrame } from "./ReportFrame";
|
||||
import { FilterStatBox, ResetButton, SquareButton, StatBox } from "./ReportParts";
|
||||
import { ResultBlock, ResultMessage } from "./LegacyResultTable";
|
||||
import { QuestionList, readDragData } from "./QuestionList";
|
||||
import { FilterPopup } from "./FilterPopup";
|
||||
|
||||
export function TabulationWorkspace() {
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const { project, hydrated } = useSelectedProject();
|
||||
const missing = hydrated && !project;
|
||||
useEffect(() => {
|
||||
if (missing) router.replace("/");
|
||||
}, [missing, router]);
|
||||
if (!project) return null;
|
||||
return (
|
||||
<Workspace
|
||||
key={JSON.stringify([
|
||||
projectKey(project),
|
||||
auth.user?.userId,
|
||||
auth.user?.userRole,
|
||||
auth.user?.userTeam,
|
||||
])}
|
||||
project={project}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy Tabulation.js: click-selected questions, dragged banners, Run → characteristic + tables. */
|
||||
function Workspace({ project }: { project: ProjectRef }) {
|
||||
const questions = useQuestionQuery(project);
|
||||
const { run, start, reset } = useReportStream(project);
|
||||
const [selectedQuestion, setSelectedQuestion] = useState<string[]>([]);
|
||||
const [selectedVariable, setSelectedVariable] = useState<string[]>([]);
|
||||
const [banners, setBanners] = useState<string[][]>([]);
|
||||
const [filterLines, setFilterLines] = useState<LegacyFilterLine[]>([]);
|
||||
const [filterOpen, setFilterOpen] = useState(false);
|
||||
const [isTest, setIsTest] = useState(false);
|
||||
const [isAxis, setIsAxis] = useState(false);
|
||||
const bookmarks = useReportBookmarks(project, "TABULATION");
|
||||
const download = useFileDownload();
|
||||
const projectTitle = useProjectTitle(project);
|
||||
// Stored filter strings and OPTION of the applied bookmark, kept verbatim when unchanged.
|
||||
const [loadedFilter, setLoadedFilter] = useState(emptyBookmarkFilter);
|
||||
const [option, setOption] = useState<Record<string, unknown>>({});
|
||||
useVisitLog("/Report/Tabulation", project);
|
||||
|
||||
// Tabulation never lists open-ended (text) questions.
|
||||
const all = (questions.data ?? []).filter(
|
||||
(question) => canIndex(question) && question.qtype !== "text",
|
||||
);
|
||||
const questionItems = all.filter((question) => !isDerivedQuestion(question));
|
||||
const variableItems = all.filter(isDerivedQuestion);
|
||||
const find = (qid: string) =>
|
||||
(questions.data ?? []).find((question) => question.qid === qid);
|
||||
// Legacy order: questions in list order, then variables in click order.
|
||||
const selectedIndex = [...selectedQuestion, ...selectedVariable];
|
||||
const tables = run.slots.filter((slot) => slot.index !== "");
|
||||
const done =
|
||||
run.status === "complete" &&
|
||||
tables.length > 0 &&
|
||||
tables.every((slot) => slot.result || slot.error);
|
||||
|
||||
const makeTable = () => {
|
||||
if (!selectedIndex.length) return;
|
||||
start({
|
||||
request: readReportBatch({
|
||||
indexes: selectedIndex,
|
||||
banners,
|
||||
filter: toServerFilter(filterLines),
|
||||
dataScope: isTest ? "TEST" : "ACTUAL",
|
||||
transpose: isAxis,
|
||||
// Legacy screens show percentages with 1 decimal and Mean with 2.
|
||||
percentageDecimals: 1,
|
||||
statisticDecimals: 2,
|
||||
}),
|
||||
titles: selectedIndex.map((qid) => {
|
||||
const question = find(qid);
|
||||
return question ? questionHead(question) : qid;
|
||||
}),
|
||||
// Legacy requests the hidden 표본의 특성 table for Excel export on every run.
|
||||
characteristic: true,
|
||||
});
|
||||
};
|
||||
const toggleQuestion = (qid: string) => {
|
||||
const next = selectedQuestion.includes(qid)
|
||||
? selectedQuestion.filter((id) => id !== qid)
|
||||
: [...selectedQuestion, qid];
|
||||
setSelectedQuestion(
|
||||
questionItems.map((item) => item.qid).filter((id) => next.includes(id)),
|
||||
);
|
||||
};
|
||||
const toggleVariable = (qid: string) =>
|
||||
setSelectedVariable(
|
||||
selectedVariable.includes(qid)
|
||||
? selectedVariable.filter((id) => id !== qid)
|
||||
: [...selectedVariable, qid],
|
||||
);
|
||||
// Legacy selectedBookMark effect: replace every condition and clear shown tables; no auto-run.
|
||||
const applyBookmark = (bookmark: Bookmark | null) => {
|
||||
const setting = bookmark ? readBookmarkSetting(bookmark.bookmarkJson) : emptyBookmarkSetting;
|
||||
bookmarks.select(bookmark);
|
||||
reset();
|
||||
setSelectedQuestion(
|
||||
questionItems.map((item) => item.qid).filter((qid) => setting.index.includes(qid)),
|
||||
);
|
||||
setSelectedVariable(
|
||||
variableItems.map((item) => item.qid).filter((qid) => setting.index.includes(qid)),
|
||||
);
|
||||
setBanners(setting.banners);
|
||||
setFilterLines(setting.filter.lines);
|
||||
setLoadedFilter(setting.filter);
|
||||
setOption(setting.option);
|
||||
setIsTest(bookmarkTest(setting.option));
|
||||
setIsAxis(bookmarkAxis(setting.option));
|
||||
};
|
||||
const currentFilter = () => bookmarkFilter(filterLines, loadedFilter);
|
||||
// Legacy ExportTable: the hidden 표본의 특성 table first, then every received table.
|
||||
const exportTable = () => {
|
||||
const tables = excelTables(run.slots, find);
|
||||
if (!tables.length) return;
|
||||
download.mutate(
|
||||
{
|
||||
kind: "table",
|
||||
project,
|
||||
request: { tables, turn: isAxis },
|
||||
name: { prefix: EXPORT_PREFIX.table, title: projectTitle },
|
||||
},
|
||||
{
|
||||
onError: (error) =>
|
||||
window.alert(apiError(error, { fallbackMessage: "Excel 파일을 만들지 못했습니다." }).message),
|
||||
},
|
||||
);
|
||||
};
|
||||
const onDragEnd = (event: DragEndEvent) => {
|
||||
const data = readDragData(event.active.data.current);
|
||||
if (!data) return;
|
||||
const next = dropOnBanner(
|
||||
banners,
|
||||
data,
|
||||
event.over ? String(event.over.id) : "",
|
||||
readDragData(event.over?.data.current),
|
||||
);
|
||||
if (next) setBanners(next);
|
||||
};
|
||||
|
||||
if (questions.isPending || questions.isError)
|
||||
return (
|
||||
<QueryState
|
||||
pending={questions.isPending}
|
||||
error={questions.error}
|
||||
onRetry={() => void questions.refetch()}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<ReportFrame
|
||||
label="Tabulation"
|
||||
tabs={
|
||||
<ReportTabs
|
||||
bookmarks={bookmarks.bookmarks}
|
||||
selectedId={bookmarks.current?.bookmarkId ?? null}
|
||||
onSelect={applyBookmark}
|
||||
canSave={bookmarks.canSave}
|
||||
onBookmark={() => bookmarks.setPopupOpen(true)}
|
||||
onRefresh={makeTable}
|
||||
/>
|
||||
}
|
||||
isTest={isTest}
|
||||
onTestChange={setIsTest}
|
||||
isAxis={isAxis}
|
||||
onAxisChange={(value) => {
|
||||
setIsAxis(value);
|
||||
// Legacy clears shown tables when the orientation changes.
|
||||
reset();
|
||||
}}
|
||||
findQuestion={find}
|
||||
onDragEnd={onDragEnd}
|
||||
phone={<PcOnlyNotice />}
|
||||
lists={
|
||||
<>
|
||||
<QuestionList
|
||||
title="Question List"
|
||||
variant="question"
|
||||
questions={questionItems}
|
||||
selected={selectedQuestion}
|
||||
onToggle={toggleQuestion}
|
||||
onSelectAll={(value) =>
|
||||
setSelectedQuestion(value ? questionItems.map((item) => item.qid) : [])
|
||||
}
|
||||
/>
|
||||
<QuestionList
|
||||
title="Variable List"
|
||||
variant="variable"
|
||||
questions={variableItems}
|
||||
selected={selectedVariable}
|
||||
onToggle={toggleVariable}
|
||||
onSelectAll={(value) =>
|
||||
setSelectedVariable(value ? variableItems.map((item) => item.qid) : [])
|
||||
}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{(collapsed) => (
|
||||
<>
|
||||
{collapsed ? null : (
|
||||
<>
|
||||
<FilterStatBox
|
||||
condition={filterCondition(filterLines)}
|
||||
onAdd={() => setFilterOpen(true)}
|
||||
onReset={() => setFilterLines([])}
|
||||
/>
|
||||
<div className="mb-4 text-center">
|
||||
<SquareButton done={done} disabled={download.isPending} onClick={exportTable}>
|
||||
Export Table
|
||||
</SquareButton>
|
||||
</div>
|
||||
<StatBox
|
||||
icon="document"
|
||||
title="Banner"
|
||||
action={<ResetButton label="배너 초기화" onClick={() => setBanners([])} />}
|
||||
>
|
||||
<BannerBox
|
||||
banners={banners}
|
||||
questions={questions.data ?? []}
|
||||
onRemove={(group, qid) => setBanners(removeBanner(banners, group, qid))}
|
||||
/>
|
||||
</StatBox>
|
||||
<div className="text-center">
|
||||
<SquareButton done={done} onClick={makeTable}>
|
||||
Run
|
||||
</SquareButton>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{run.error ? <ResultMessage message={run.error} /> : null}
|
||||
{tables.map((slot, index) => (
|
||||
<ResultBlock
|
||||
key={index}
|
||||
title={slot.title}
|
||||
result={slot.result}
|
||||
error={slot.error}
|
||||
pending={run.status === "running"}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</ReportFrame>
|
||||
{filterOpen ? (
|
||||
<FilterPopup
|
||||
open
|
||||
initial={filterLines}
|
||||
questions={questions.data ?? []}
|
||||
onOpenChange={setFilterOpen}
|
||||
onSave={setFilterLines}
|
||||
/>
|
||||
) : null}
|
||||
{bookmarks.popupOpen ? (
|
||||
<BookmarkPopup
|
||||
state={bookmarks}
|
||||
buildJson={() =>
|
||||
writeBookmarkJson({
|
||||
index: selectedIndex,
|
||||
banners,
|
||||
filter: currentFilter(),
|
||||
option,
|
||||
isTest,
|
||||
isAxis,
|
||||
})
|
||||
}
|
||||
onSaved={() => setLoadedFilter(currentFilter())}
|
||||
onDeleted={() => applyBookmark(null)}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
153
src/components/report/WordCloud.tsx
Normal file
153
src/components/report/WordCloud.tsx
Normal file
@@ -0,0 +1,153 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import cloud from "d3-cloud";
|
||||
import type { ReportResult } from "@/types/report";
|
||||
import { CHART_FONT_FAMILY, useChartFontReady } from "@/hooks/useChartFont";
|
||||
|
||||
// Legacy react-wordcloud options (Table.js ResultCloud).
|
||||
const COLORS = ["#FF2500", "#0066FF", "#1CAE81", "#94C81A", "#FFBF33", "#B066FA", "#FF7386"];
|
||||
const FONT_SIZES = [10, 100] as const;
|
||||
const HEIGHT = 400;
|
||||
|
||||
type Placed = { text: string; size: number; x: number; y: number; color: string };
|
||||
|
||||
// Drawn layouts by result, so Export Table can send the cloud the user is looking at.
|
||||
const drawn = new WeakMap<ReportResult, { width: number; placed: Placed[] }>();
|
||||
|
||||
/**
|
||||
* Base64 PNG of the word cloud as shown (legacy exported the on-screen SVG on a white
|
||||
* background). Drawn on a canvas so the already loaded web font is used for every glyph.
|
||||
*/
|
||||
export function wordCloudPng(result: ReportResult): string | undefined {
|
||||
const layout = drawn.get(result);
|
||||
const canvas = document.createElement("canvas");
|
||||
const context = canvas.getContext("2d");
|
||||
if (!layout || !context) return undefined;
|
||||
canvas.width = layout.width;
|
||||
canvas.height = HEIGHT;
|
||||
context.fillStyle = "#ffffff";
|
||||
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
context.textAlign = "center";
|
||||
for (const word of layout.placed) {
|
||||
context.font = `700 ${word.size}px ${CHART_FONT_FAMILY}`;
|
||||
context.fillStyle = word.color;
|
||||
context.fillText(word.text, layout.width / 2 + word.x, HEIGHT / 2 + word.y);
|
||||
}
|
||||
return canvas.toDataURL("image/png").split(",")[1];
|
||||
}
|
||||
|
||||
/** Legacy ResultCloud: d3-cloud layout (60%) beside the Top 10 table (40%). */
|
||||
export function WordCloud({ result }: { result: ReportResult }) {
|
||||
const words = result.words;
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const [width, setWidth] = useState(0);
|
||||
const [placed, setPlaced] = useState<Placed[]>([]);
|
||||
const fontReady = useChartFontReady(words.map((word) => word.text).join(""));
|
||||
|
||||
useEffect(() => {
|
||||
if (width && placed.length) drawn.set(result, { width, placed });
|
||||
}, [result, width, placed]);
|
||||
|
||||
useEffect(() => {
|
||||
const element = container.current;
|
||||
if (!element) return;
|
||||
const observer = new ResizeObserver(([entry]) =>
|
||||
setWidth(Math.floor(entry.contentRect.width)),
|
||||
);
|
||||
observer.observe(element);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!fontReady || !width || !words.length) return;
|
||||
const counts = words.map((word) => word.count);
|
||||
const low = Math.sqrt(Math.min(...counts));
|
||||
const high = Math.sqrt(Math.max(...counts));
|
||||
// scale: "sqrt" over the count domain, mapped onto fontSizes.
|
||||
const size = (count: number) =>
|
||||
high === low
|
||||
? FONT_SIZES[1]
|
||||
: FONT_SIZES[0] +
|
||||
((Math.sqrt(count) - low) / (high - low)) * (FONT_SIZES[1] - FONT_SIZES[0]);
|
||||
const layout = cloud<cloud.Word>()
|
||||
.size([width, HEIGHT])
|
||||
.words(words.map((word) => ({ text: word.text, size: size(word.count) })))
|
||||
.padding(1)
|
||||
.rotate(() => 0)
|
||||
.font(CHART_FONT_FAMILY)
|
||||
.fontWeight(700)
|
||||
.fontSize((word) => word.size ?? FONT_SIZES[0])
|
||||
.on("end", (output) =>
|
||||
setPlaced(
|
||||
output.map((word) => ({
|
||||
text: word.text ?? "",
|
||||
size: word.size ?? FONT_SIZES[0],
|
||||
x: word.x ?? 0,
|
||||
y: word.y ?? 0,
|
||||
// deterministic: false — legacy picks a random palette colour per word.
|
||||
color: COLORS[Math.floor(Math.random() * COLORS.length)],
|
||||
})),
|
||||
),
|
||||
);
|
||||
layout.start();
|
||||
return () => {
|
||||
layout.stop();
|
||||
};
|
||||
}, [fontReady, width, words]);
|
||||
|
||||
return (
|
||||
<div className="flex gap-3">
|
||||
<div ref={container} className="w-3/5">
|
||||
{width ? (
|
||||
<svg
|
||||
width={width}
|
||||
height={HEIGHT}
|
||||
role="img"
|
||||
aria-label="주관식 단어 빈도 워드클라우드"
|
||||
>
|
||||
<g transform={`translate(${width / 2},${HEIGHT / 2})`}>
|
||||
{placed.map((word, index) => (
|
||||
<text
|
||||
key={index}
|
||||
textAnchor="middle"
|
||||
transform={`translate(${word.x},${word.y})`}
|
||||
style={{
|
||||
fontFamily: CHART_FONT_FAMILY,
|
||||
fontSize: word.size,
|
||||
fontWeight: 700,
|
||||
fill: word.color,
|
||||
}}
|
||||
>
|
||||
{word.text}
|
||||
</text>
|
||||
))}
|
||||
</g>
|
||||
</svg>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="w-2/5">
|
||||
<h3 className="text-base leading-[20.5px] font-bold text-kart-title">
|
||||
Top 10
|
||||
</h3>
|
||||
<table className="mt-3 w-full border-separate border-spacing-0 text-sm text-kart-text">
|
||||
<tbody>
|
||||
{words.slice(0, 10).map((word, index) => (
|
||||
<tr key={index} className="bg-kart-bg">
|
||||
<td className="h-9 w-10 rounded-[4px] border-8 border-white px-3 py-2 text-center font-bold">
|
||||
{index + 1}
|
||||
</td>
|
||||
<td className="h-9 rounded-[4px] border-8 border-white px-3 py-2 text-left">
|
||||
{word.text}
|
||||
</td>
|
||||
<td className="h-9 w-10 rounded-[4px] border-8 border-white px-3 py-2 text-center font-bold text-kart-green">
|
||||
({word.count})
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
31
src/components/report/crosstab-conditions.ts
Normal file
31
src/components/report/crosstab-conditions.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { Question, ReportBatch } from "@/types/report";
|
||||
import { canIndex, readReportBatch } from "@/lib/report-contract";
|
||||
import { toServerFilter, type LegacyFilterLine } from "@/lib/legacy-filter";
|
||||
|
||||
/** Cross Tab conditions that re-run every table when they change. */
|
||||
export type Conditions = {
|
||||
banners: string[][];
|
||||
filterLines: LegacyFilterLine[];
|
||||
isTest: boolean;
|
||||
isAxis: boolean;
|
||||
};
|
||||
|
||||
export const crosstabBatch = (ids: string[], conditions: Conditions): ReportBatch =>
|
||||
readReportBatch({
|
||||
indexes: ids,
|
||||
banners: conditions.banners,
|
||||
filter: toServerFilter(conditions.filterLines),
|
||||
dataScope: conditions.isTest ? "TEST" : "ACTUAL",
|
||||
transpose: conditions.isAxis,
|
||||
// Legacy screens show percentages with 1 decimal and Mean with 2.
|
||||
percentageDecimals: 1,
|
||||
statisticDecimals: 2,
|
||||
});
|
||||
|
||||
/** Bookmark INDEX entries that are still indexable questions, in saved order without repeats. */
|
||||
export const bookmarkIndexes = (index: string[], questions: Question[]) =>
|
||||
index.filter(
|
||||
(qid, position) =>
|
||||
index.indexOf(qid) === position &&
|
||||
questions.some((question) => question.qid === qid && canIndex(question)),
|
||||
);
|
||||
33
src/components/report/excel-tables.ts
Normal file
33
src/components/report/excel-tables.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { Question, ReportResult } from "@/types/report";
|
||||
import { questionHead } from "@/lib/report-ui";
|
||||
import { reportExcelBody, type ExcelTable } from "@/lib/report-excel";
|
||||
import { wordCloudPng } from "./WordCloud";
|
||||
|
||||
/** Legacy Tabulation characterArray head for the hidden TABULATION_0 table. */
|
||||
export const CHARACTERISTIC_HEAD = "■ 표 본 의 특 성 ■";
|
||||
|
||||
/**
|
||||
* Legacy ExportTable list: received tables in screen order (head = EXPLAIN, vname = VARIABLE,
|
||||
* qtype = QTYPE), word clouds with their picture. Pending, failed and empty tables are skipped,
|
||||
* like the legacy writer skipping an empty body.
|
||||
*/
|
||||
export function excelTables(
|
||||
items: { index: string; result?: ReportResult }[],
|
||||
find: (qid: string) => Question | undefined,
|
||||
): ExcelTable[] {
|
||||
return items.flatMap(({ index, result }) => {
|
||||
const body = result ? reportExcelBody(result) : null;
|
||||
if (!result || !body) return [];
|
||||
const question = index ? find(index) : undefined;
|
||||
const imagePng = result.type === "TEXT_ANALYSIS" ? wordCloudPng(result) : undefined;
|
||||
return [
|
||||
{
|
||||
head: index ? (question ? questionHead(question) : index) : CHARACTERISTIC_HEAD,
|
||||
vname: question?.variable ?? "",
|
||||
qtype: question?.qtype ?? "",
|
||||
body,
|
||||
...(imagePng ? { imagePng } : {}),
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { cn } from "cn"
|
||||
import { Slot } from "radix-ui"
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
|
||||
241
src/components/ui/carousel.tsx
Normal file
241
src/components/ui/carousel.tsx
Normal file
@@ -0,0 +1,241 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cn } from "cn"
|
||||
import useEmblaCarousel, {
|
||||
type UseEmblaCarouselType,
|
||||
} from "embla-carousel-react"
|
||||
import { ArrowLeft, ArrowRight } from "lucide-react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
type CarouselApi = UseEmblaCarouselType[1]
|
||||
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
||||
type CarouselOptions = UseCarouselParameters[0]
|
||||
type CarouselPlugin = UseCarouselParameters[1]
|
||||
|
||||
type CarouselProps = {
|
||||
opts?: CarouselOptions
|
||||
plugins?: CarouselPlugin
|
||||
orientation?: "horizontal" | "vertical"
|
||||
setApi?: (api: CarouselApi) => void
|
||||
}
|
||||
|
||||
type CarouselContextProps = {
|
||||
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
||||
api: ReturnType<typeof useEmblaCarousel>[1]
|
||||
scrollPrev: () => void
|
||||
scrollNext: () => void
|
||||
canScrollPrev: boolean
|
||||
canScrollNext: boolean
|
||||
} & CarouselProps
|
||||
|
||||
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
||||
|
||||
function useCarousel() {
|
||||
const context = React.useContext(CarouselContext)
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useCarousel must be used within a <Carousel />")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
function Carousel({
|
||||
orientation = "horizontal",
|
||||
opts,
|
||||
setApi,
|
||||
plugins,
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & CarouselProps) {
|
||||
const [carouselRef, api] = useEmblaCarousel(
|
||||
{
|
||||
...opts,
|
||||
axis: orientation === "horizontal" ? "x" : "y",
|
||||
},
|
||||
plugins
|
||||
)
|
||||
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
||||
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
||||
|
||||
const onSelect = React.useCallback((api: CarouselApi) => {
|
||||
if (!api) return
|
||||
setCanScrollPrev(api.canScrollPrev())
|
||||
setCanScrollNext(api.canScrollNext())
|
||||
}, [])
|
||||
|
||||
const scrollPrev = React.useCallback(() => {
|
||||
api?.scrollPrev()
|
||||
}, [api])
|
||||
|
||||
const scrollNext = React.useCallback(() => {
|
||||
api?.scrollNext()
|
||||
}, [api])
|
||||
|
||||
const handleKeyDown = React.useCallback(
|
||||
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (event.key === "ArrowLeft") {
|
||||
event.preventDefault()
|
||||
scrollPrev()
|
||||
} else if (event.key === "ArrowRight") {
|
||||
event.preventDefault()
|
||||
scrollNext()
|
||||
}
|
||||
},
|
||||
[scrollPrev, scrollNext]
|
||||
)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!api || !setApi) return
|
||||
setApi(api)
|
||||
}, [api, setApi])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!api) return
|
||||
onSelect(api)
|
||||
api.on("reInit", onSelect)
|
||||
api.on("select", onSelect)
|
||||
|
||||
return () => {
|
||||
api?.off("select", onSelect)
|
||||
}
|
||||
}, [api, onSelect])
|
||||
|
||||
return (
|
||||
<CarouselContext.Provider
|
||||
value={{
|
||||
carouselRef,
|
||||
api: api,
|
||||
opts,
|
||||
orientation:
|
||||
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
||||
scrollPrev,
|
||||
scrollNext,
|
||||
canScrollPrev,
|
||||
canScrollNext,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
onKeyDownCapture={handleKeyDown}
|
||||
className={cn("relative", className)}
|
||||
role="region"
|
||||
aria-roledescription="carousel"
|
||||
data-slot="carousel"
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</CarouselContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
const { carouselRef, orientation } = useCarousel()
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={carouselRef}
|
||||
className="overflow-hidden"
|
||||
data-slot="carousel-content"
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex",
|
||||
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
||||
const { orientation } = useCarousel()
|
||||
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-roledescription="slide"
|
||||
data-slot="carousel-item"
|
||||
className={cn(
|
||||
"min-w-0 shrink-0 grow-0 basis-full",
|
||||
orientation === "horizontal" ? "pl-4" : "pt-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselPrevious({
|
||||
className,
|
||||
variant = "outline",
|
||||
size = "icon",
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
||||
|
||||
return (
|
||||
<Button
|
||||
data-slot="carousel-previous"
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
"absolute size-8 rounded-full",
|
||||
orientation === "horizontal"
|
||||
? "top-1/2 -left-12 -translate-y-1/2"
|
||||
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
||||
className
|
||||
)}
|
||||
disabled={!canScrollPrev}
|
||||
onClick={scrollPrev}
|
||||
{...props}
|
||||
>
|
||||
<ArrowLeft />
|
||||
<span className="sr-only">Previous slide</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselNext({
|
||||
className,
|
||||
variant = "outline",
|
||||
size = "icon",
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
||||
|
||||
return (
|
||||
<Button
|
||||
data-slot="carousel-next"
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
"absolute size-8 rounded-full",
|
||||
orientation === "horizontal"
|
||||
? "top-1/2 -right-12 -translate-y-1/2"
|
||||
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
||||
className
|
||||
)}
|
||||
disabled={!canScrollNext}
|
||||
onClick={scrollNext}
|
||||
{...props}
|
||||
>
|
||||
<ArrowRight />
|
||||
<span className="sr-only">Next slide</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
type CarouselApi,
|
||||
Carousel,
|
||||
CarouselContent,
|
||||
CarouselItem,
|
||||
CarouselPrevious,
|
||||
CarouselNext,
|
||||
}
|
||||
56
src/components/ui/tooltip.tsx
Normal file
56
src/components/ui/tooltip.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cn } from "cn"
|
||||
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
||||
|
||||
function TooltipProvider({
|
||||
delayDuration = 0,
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
||||
return (
|
||||
<TooltipPrimitive.Provider
|
||||
data-slot="tooltip-provider"
|
||||
delayDuration={delayDuration}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Tooltip({
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
||||
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
||||
}
|
||||
|
||||
function TooltipTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
||||
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
||||
}
|
||||
|
||||
function TooltipContent({
|
||||
className,
|
||||
sideOffset = 0,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
||||
return (
|
||||
<TooltipPrimitive.Portal>
|
||||
<TooltipPrimitive.Content
|
||||
data-slot="tooltip-content"
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
|
||||
</TooltipPrimitive.Content>
|
||||
</TooltipPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
||||
@@ -1,6 +1,6 @@
|
||||
export const commonConfig = {
|
||||
appName: "KART",
|
||||
description: "KART 보고서 시스템",
|
||||
description: "KART 설문 데이터 시각화 시스템",
|
||||
homePath: "/",
|
||||
loginPath: "/login",
|
||||
logoutPath: "/logout",
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
import type { SideMenuItem, TopMenuItem } from "./menu.type";
|
||||
import type { KartMenuItem, SideMenuItem } from "./menu.type";
|
||||
|
||||
export const topMenus: TopMenuItem[] = [
|
||||
{ id: "home", label: "홈", path: "/" },
|
||||
/** Legacy Header.js order and labels. Role rules map legacy isAdmin<7 / isAdmin<5 to userRole. */
|
||||
export const kartMenus: KartMenuItem[] = [
|
||||
{ id: "progress", label: "진행 현황", path: "/Report/Current", icon: 1, ready: true },
|
||||
{ id: "quota", label: "Quota", path: "/Report/Quota", icon: 2, ready: true },
|
||||
{ id: "tabulation", label: "Tabulation", path: "/Report/Tabulation", icon: 3, ready: true },
|
||||
{ id: "crosstab", label: "Cross Tab", path: "/Report/Crosstab", icon: 4, ready: true },
|
||||
{
|
||||
id: "derived",
|
||||
label: "Create Variable",
|
||||
path: "/Management/Derived",
|
||||
icon: 5,
|
||||
ready: true,
|
||||
visible: (user) => user.userRole < 9001,
|
||||
},
|
||||
{
|
||||
id: "exim",
|
||||
label: "Export/Import",
|
||||
path: "/Management/Exim",
|
||||
icon: 6,
|
||||
ready: true,
|
||||
visible: (user) => user.userRole === 1001 || user.userTeam === "R701",
|
||||
},
|
||||
];
|
||||
|
||||
export const sideMenus: SideMenuItem[] = [];
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
import type { LoginUser } from "@kri/common";
|
||||
import type { KriNavigationItem } from "@/components/layout/types";
|
||||
|
||||
export type TopMenuItem = KriNavigationItem;
|
||||
export type SideMenuItem = KriNavigationItem;
|
||||
|
||||
/** Legacy KART GNB entry. `icon` selects public/images/kart/ic_gnb{n}_20(-1).png. */
|
||||
export type KartMenuItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
path: string;
|
||||
icon: number;
|
||||
/** false until the page is migrated; rendered in place but not navigable. */
|
||||
ready: boolean;
|
||||
visible?: (user: LoginUser) => boolean;
|
||||
};
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
export const AUTH_COOKIE_MAX_AGE = 24 * 60 * 60;
|
||||
|
||||
/**
|
||||
* How long a quota result stays fresh before re-selecting it queries the server again.
|
||||
* Tune in operation: each server query writes a "QUOTA VIEW" site log.
|
||||
*/
|
||||
export const QUOTA_RESULT_STALE_TIME_MS = 10_000;
|
||||
|
||||
@@ -1,51 +1,57 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback } from "react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import type { LoginUser } from "@kri/common";
|
||||
import { isRecord, isLoginUser } from "@/types/kart";
|
||||
import type { AuthState as CommonAuthState } from "@kri/common/hooks";
|
||||
import { createPersistentAtom } from "@kri/common/jotai";
|
||||
import { getLocalStorage, removeLocalStorage, setLocalStorage } from "@/store/storage/secure-storage";
|
||||
import {
|
||||
getLocalStorage,
|
||||
removeLocalStorage,
|
||||
setLocalStorage,
|
||||
} from "@/store/storage/secure-storage";
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
import { isExternalSession, isExternalUser, type ShareLink } from "@/types/share";
|
||||
|
||||
export type AuthState = CommonAuthState<LoginUser>;
|
||||
export type AuthState = CommonAuthState<LoginUser> & { external?: ShareLink };
|
||||
const initialAuthState: AuthState = { user: null };
|
||||
|
||||
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
||||
typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
|
||||
const isLoginUser = (value: unknown): value is LoginUser => {
|
||||
if (!isRecord(value)) return false;
|
||||
|
||||
return (
|
||||
typeof value.userId === "string" &&
|
||||
typeof value.userName === "string" &&
|
||||
typeof value.userCmpn === "string" &&
|
||||
typeof value.userTeam === "string" &&
|
||||
typeof value.userRole === "number"
|
||||
);
|
||||
};
|
||||
|
||||
const isPersistedAuthState = (value: unknown): value is AuthState =>
|
||||
isRecord(value) && isLoginUser(value.user);
|
||||
isRecord(value) && isLoginUser(value.user) &&
|
||||
(isExternalUser(value.user)
|
||||
? isExternalSession({ user: value.user, link: value.external })
|
||||
: value.external === undefined);
|
||||
|
||||
/*
|
||||
* atom은 서버·클라이언트 최초 렌더 모두 initialAuthState로 시작한다.
|
||||
* 저장소 값은 onMount(마운트 이후 시점)에만 반영되므로
|
||||
* 서버 HTML과 클라이언트 최초 렌더가 항상 일치해 하이드레이션 오류가 발생하지 않는다.
|
||||
*/
|
||||
export const authStateAtom = createPersistentAtom<AuthState>(StorageKeys.AuthState, initialAuthState, {
|
||||
storage: { get: getLocalStorage, set: setLocalStorage, remove: removeLocalStorage },
|
||||
validate: isPersistedAuthState,
|
||||
shouldRemove: (value) => value.user === null,
|
||||
debugLabel: "authState",
|
||||
});
|
||||
export const authStateAtom = createPersistentAtom<AuthState>(
|
||||
StorageKeys.AuthState,
|
||||
initialAuthState,
|
||||
{
|
||||
storage: {
|
||||
get: getLocalStorage,
|
||||
set: setLocalStorage,
|
||||
remove: removeLocalStorage,
|
||||
},
|
||||
validate: isPersistedAuthState,
|
||||
shouldRemove: (value) => value.user === null,
|
||||
debugLabel: "authState",
|
||||
},
|
||||
);
|
||||
|
||||
export function useAuth() {
|
||||
const [auth, setAuth] = useAtom(authStateAtom);
|
||||
const hydrated = useAtomValue(authStateAtom.hydratedAtom);
|
||||
|
||||
const setFromLoginResponse = useCallback((user: LoginUser) => setAuth({ user }), [setAuth]);
|
||||
const setFromLoginResponse = useCallback(
|
||||
(user: LoginUser) => setAuth({ user }),
|
||||
[setAuth],
|
||||
);
|
||||
const logout = useCallback(() => setAuth(initialAuthState), [setAuth]);
|
||||
|
||||
return { auth, setAuth, setFromLoginResponse, logout } as const;
|
||||
return { auth, hydrated, setAuth, setFromLoginResponse, logout } as const;
|
||||
}
|
||||
|
||||
35
src/hooks/useChartFont.ts
Normal file
35
src/hooks/useChartFont.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
/** Same stack as the app's --font-sans; ECharts draws on canvas and needs it explicitly. */
|
||||
export const CHART_FONT_FAMILY = '"Noto Sans", "Noto Sans KR", sans-serif';
|
||||
|
||||
export const chartTextStyle = { fontFamily: CHART_FONT_FAMILY } as const;
|
||||
|
||||
/**
|
||||
* Canvas text does not re-render when a web font arrives, so load the unicode-range
|
||||
* slices for `text` first. Returns true once `text` can be drawn with the web fonts.
|
||||
*/
|
||||
export function useChartFontReady(text: string): boolean {
|
||||
const [loadedText, setLoadedText] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
const sample = text || "0";
|
||||
void Promise.all(
|
||||
["400", "700"].flatMap((weight) => [
|
||||
document.fonts.load(weight + ' 12px "Noto Sans"', sample),
|
||||
document.fonts.load(weight + ' 12px "Noto Sans KR"', sample),
|
||||
]),
|
||||
)
|
||||
// A failed font request falls back to sans-serif; the chart still renders.
|
||||
.catch(() => undefined)
|
||||
.then(() => {
|
||||
if (active) setLoadedText(text);
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [text]);
|
||||
return loadedText === text;
|
||||
}
|
||||
20
src/hooks/usePhoneView.ts
Normal file
20
src/hooks/usePhoneView.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { useSyncExternalStore } from "react";
|
||||
|
||||
/** Same "small touch screen" test as the phone-only CSS in ReportFrame. */
|
||||
const PHONE_QUERY = "(pointer: coarse) and (max-width: 767px)";
|
||||
|
||||
function subscribe(onChange: () => void) {
|
||||
const media = window.matchMedia(PHONE_QUERY);
|
||||
media.addEventListener("change", onChange);
|
||||
return () => media.removeEventListener("change", onChange);
|
||||
}
|
||||
|
||||
export function usePhoneView(): boolean {
|
||||
return useSyncExternalStore(
|
||||
subscribe,
|
||||
() => window.matchMedia(PHONE_QUERY).matches,
|
||||
() => false,
|
||||
);
|
||||
}
|
||||
34
src/hooks/useReportBookmarks.ts
Normal file
34
src/hooks/useReportBookmarks.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { isExternalUser } from "@/types/share";
|
||||
import { useBookmarkListQuery, useBookmarkMutations } from "@/query/bookmark";
|
||||
import type { ProjectRef } from "@/types/kart";
|
||||
import type { Bookmark, BookmarkPage } from "@/types/bookmark";
|
||||
|
||||
/** Tab list, selected tab ("New" = null) and the save popup of one Tabulation / Cross Tab page. */
|
||||
export function useReportBookmarks(project: ProjectRef, page: BookmarkPage) {
|
||||
const { auth } = useAuth();
|
||||
const list = useBookmarkListQuery(project, page);
|
||||
const { save, remove } = useBookmarkMutations(project, page);
|
||||
const [selected, setSelected] = useState<Bookmark | null>(null);
|
||||
const [popupOpen, setPopupOpen] = useState(false);
|
||||
const bookmarks = list.data ?? [];
|
||||
// The reloaded list wins; a just-saved bookmark shows from its local copy until then.
|
||||
const current = selected
|
||||
? (bookmarks.find((bookmark) => bookmark.bookmarkId === selected.bookmarkId) ?? selected)
|
||||
: null;
|
||||
return {
|
||||
bookmarks,
|
||||
current,
|
||||
select: setSelected,
|
||||
canSave: !isExternalUser(auth.user) && (!current || current.isMine),
|
||||
popupOpen,
|
||||
setPopupOpen,
|
||||
save,
|
||||
remove,
|
||||
};
|
||||
}
|
||||
|
||||
export type ReportBookmarks = ReturnType<typeof useReportBookmarks>;
|
||||
102
src/hooks/useSelectedProject.ts
Normal file
102
src/hooks/useSelectedProject.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect } from "react";
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import type { Route } from "next";
|
||||
import { createPersistentAtom } from "@kri/common/jotai";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { isExternalUser } from "@/types/share";
|
||||
import {
|
||||
getLocalStorage,
|
||||
removeLocalStorage,
|
||||
setLocalStorage,
|
||||
} from "@/store/storage/secure-storage";
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
import { isProjectRef, isRecord, readProjectParams, type ProjectRef } from "@/types/kart";
|
||||
|
||||
/** The project chosen for the project pages, owned by the user who chose it. */
|
||||
export type SelectedProject = { userId: string; project: ProjectRef } | null;
|
||||
|
||||
const isSelectedProject = (value: unknown): value is SelectedProject =>
|
||||
value === null ||
|
||||
(isRecord(value) &&
|
||||
typeof value.userId === "string" &&
|
||||
value.userId !== "" &&
|
||||
isProjectRef(value.project));
|
||||
|
||||
/**
|
||||
* Legacy KART kept the selected project in ptokenState (recoil-persist, localStorage) instead of
|
||||
* the URL. Like authStateAtom, the stored value is applied after mount, so server and first
|
||||
* client renders agree.
|
||||
*/
|
||||
export const selectedProjectAtom = createPersistentAtom<SelectedProject>(
|
||||
StorageKeys.SelectedProject,
|
||||
null,
|
||||
{
|
||||
storage: {
|
||||
get: getLocalStorage,
|
||||
set: setLocalStorage,
|
||||
remove: removeLocalStorage,
|
||||
},
|
||||
validate: isSelectedProject,
|
||||
shouldRemove: (value) => value === null,
|
||||
debugLabel: "selectedProject",
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Current project for the signed-in user. An old `?projectType=&pkey=` link takes precedence
|
||||
* until ProjectParamsMigration stores it and removes the parameters from the address.
|
||||
*/
|
||||
export function useSelectedProject() {
|
||||
const { auth, hydrated: authHydrated } = useAuth();
|
||||
const [selected, setSelected] = useAtom(selectedProjectAtom);
|
||||
const storeHydrated = useAtomValue(selectedProjectAtom.hydratedAtom);
|
||||
const urlProject = readProjectParams(useSearchParams());
|
||||
const external = isExternalUser(auth.user);
|
||||
const fromUrl = external ? null : urlProject;
|
||||
const userId = auth.user?.userId;
|
||||
const stored =
|
||||
selected && userId && selected.userId === userId
|
||||
? { projectType: selected.project.projectType, pkey: selected.project.pkey }
|
||||
: null;
|
||||
const select = useCallback(
|
||||
(project: ProjectRef) => {
|
||||
if (userId && !external)
|
||||
setSelected({
|
||||
userId,
|
||||
project: { projectType: project.projectType, pkey: project.pkey },
|
||||
});
|
||||
},
|
||||
[setSelected, userId, external],
|
||||
);
|
||||
const clear = useCallback(() => setSelected(null), [setSelected]);
|
||||
return {
|
||||
project: external ? auth.external ?? null : fromUrl ?? stored,
|
||||
fromUrl,
|
||||
/** False until both the login state and the stored selection have been read. */
|
||||
hydrated: authHydrated && storeHydrated,
|
||||
select,
|
||||
clear,
|
||||
} as const;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old bookmarks and shared links still carry `?projectType=&pkey=`: store that project and
|
||||
* replace the address with the bare path. Mounted once in the app header.
|
||||
*/
|
||||
export function useProjectParamsMigration() {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { auth, hydrated } = useAuth();
|
||||
const { fromUrl, select } = useSelectedProject();
|
||||
const projectType = fromUrl?.projectType;
|
||||
const pkey = fromUrl?.pkey;
|
||||
const signedIn = hydrated && !!auth.user;
|
||||
useEffect(() => {
|
||||
if (!signedIn || projectType === undefined || pkey === undefined) return;
|
||||
select({ projectType, pkey });
|
||||
router.replace(pathname as Route);
|
||||
}, [signedIn, projectType, pkey, select, router, pathname]);
|
||||
}
|
||||
41
src/hooks/useVisitLog.ts
Normal file
41
src/hooks/useVisitLog.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { projectKey, type ProjectRef } from "@/types/kart";
|
||||
|
||||
export function useVisitLog(path: string, project?: ProjectRef) {
|
||||
const { auth, hydrated } = useAuth();
|
||||
const lastVisit = useRef("");
|
||||
const projectType = project?.projectType;
|
||||
const pkey = project?.pkey;
|
||||
useEffect(() => {
|
||||
if (!hydrated || !auth.user) return;
|
||||
const key =
|
||||
auth.user.userId +
|
||||
":" +
|
||||
path +
|
||||
":" +
|
||||
(projectType === undefined || pkey === undefined
|
||||
? ""
|
||||
: projectKey({ projectType, pkey }));
|
||||
if (lastVisit.current === key) return;
|
||||
lastVisit.current = key;
|
||||
void nextApi
|
||||
.post(
|
||||
"/log/visit",
|
||||
{
|
||||
logContent: path,
|
||||
...(projectType === undefined ? {} : { projectType, pkey }),
|
||||
},
|
||||
{
|
||||
expectText: true,
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
},
|
||||
)
|
||||
.catch(() => undefined);
|
||||
}, [auth.user, hydrated, path, projectType, pkey]);
|
||||
}
|
||||
129
src/lib/bookmark-json.ts
Normal file
129
src/lib/bookmark-json.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
import { isRecord } from "@/types/kart";
|
||||
import {
|
||||
filterCondition,
|
||||
readFilterArray,
|
||||
realFilterCondition,
|
||||
writeFilterArray,
|
||||
type LegacyFilterLine,
|
||||
} from "@/lib/legacy-filter";
|
||||
|
||||
/**
|
||||
* Legacy BOOKMARK_JSON (states/Format.js bookmarkJsonFormat). The legacy KART reads and rewrites
|
||||
* the same REPORT_BOOKMARK rows, so this module is the only place that knows the stored shape:
|
||||
* `{"INDEX":"a,b","BANNER":"a|b,c","FILTER_CONDITION":"…","REAL_FILTER_CONDITION":"…",
|
||||
* "FILTER_ARRAY":"[…]","OPTION":{"TEST":"TEST","TURN":"1"}}`.
|
||||
*/
|
||||
|
||||
/** The filter edit tree with the two condition strings stored beside it. */
|
||||
export type BookmarkFilter = {
|
||||
lines: LegacyFilterLine[];
|
||||
array: string;
|
||||
condition: string;
|
||||
realCondition: string;
|
||||
};
|
||||
|
||||
export type BookmarkSetting = {
|
||||
index: string[];
|
||||
banners: string[][];
|
||||
filter: BookmarkFilter;
|
||||
/** Stored OPTION object; TEST / TURN map to the checks, other keys (legacy PRTHEAD) are kept. */
|
||||
option: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export const emptyBookmarkFilter: BookmarkFilter = {
|
||||
lines: [],
|
||||
array: "",
|
||||
condition: "",
|
||||
realCondition: "",
|
||||
};
|
||||
|
||||
export const emptyBookmarkSetting: BookmarkSetting = {
|
||||
index: [],
|
||||
banners: [],
|
||||
filter: emptyBookmarkFilter,
|
||||
option: {},
|
||||
};
|
||||
|
||||
/** Never throws: unreadable parts load as empty, like a fresh "New" tab. */
|
||||
export function readBookmarkSetting(json: string): BookmarkSetting {
|
||||
let parsed: unknown = null;
|
||||
try {
|
||||
parsed = JSON.parse(json);
|
||||
} catch {
|
||||
// Treated as an empty setting below.
|
||||
}
|
||||
const source = isRecord(parsed) ? parsed : {};
|
||||
const text = (key: string) => {
|
||||
const value = source[key];
|
||||
return typeof value === "string" ? value : "";
|
||||
};
|
||||
const array = text("FILTER_ARRAY");
|
||||
let lines: LegacyFilterLine[] = [];
|
||||
try {
|
||||
lines = readFilterArray(array);
|
||||
} catch {
|
||||
// Keep the stored strings so saving an untouched filter does not drop them.
|
||||
}
|
||||
return {
|
||||
index: text("INDEX")
|
||||
.split(",")
|
||||
.filter((qid) => qid !== ""),
|
||||
banners: text("BANNER")
|
||||
.split(",")
|
||||
.map((group) => group.split("|").filter((qid) => qid !== ""))
|
||||
.filter((group) => group.length > 0),
|
||||
filter: {
|
||||
lines,
|
||||
array,
|
||||
condition: text("FILTER_CONDITION"),
|
||||
realCondition: text("REAL_FILTER_CONDITION"),
|
||||
},
|
||||
option: isRecord(source.OPTION) ? { ...source.OPTION } : {},
|
||||
};
|
||||
}
|
||||
|
||||
export const bookmarkTest = (option: Record<string, unknown>) => option.TEST === "TEST";
|
||||
export const bookmarkAxis = (option: Record<string, unknown>) => option.TURN === "1";
|
||||
|
||||
/**
|
||||
* Filter to store for the current edit tree. An untouched loaded filter keeps its stored strings
|
||||
* verbatim; an edited one regenerates all three from the tree so they stay consistent.
|
||||
*/
|
||||
export function bookmarkFilter(lines: LegacyFilterLine[], loaded: BookmarkFilter): BookmarkFilter {
|
||||
if (lines === loaded.lines) return loaded;
|
||||
return {
|
||||
lines,
|
||||
array: writeFilterArray(lines),
|
||||
condition: filterCondition(lines),
|
||||
realCondition: realFilterCondition(lines),
|
||||
};
|
||||
}
|
||||
|
||||
export function writeBookmarkJson(setting: {
|
||||
index: string[];
|
||||
banners: string[][];
|
||||
filter: BookmarkFilter;
|
||||
option: Record<string, unknown>;
|
||||
isTest: boolean;
|
||||
isAxis: boolean;
|
||||
}): string {
|
||||
const rest = Object.fromEntries(
|
||||
Object.entries(setting.option).filter(([key]) => key !== "TEST" && key !== "TURN"),
|
||||
);
|
||||
return JSON.stringify({
|
||||
INDEX: setting.index.join(","),
|
||||
BANNER: setting.banners
|
||||
.filter((group) => group.length > 0)
|
||||
.map((group) => group.join("|"))
|
||||
.join(","),
|
||||
FILTER_CONDITION: setting.filter.condition,
|
||||
REAL_FILTER_CONDITION: setting.filter.realCondition,
|
||||
FILTER_ARRAY: setting.filter.array,
|
||||
// Legacy key order: TEST, TURN, then the rest (PRTHEAD); unchecked options are omitted.
|
||||
OPTION: {
|
||||
...(setting.isTest ? { TEST: "TEST" } : {}),
|
||||
...(setting.isAxis ? { TURN: "1" } : {}),
|
||||
...rest,
|
||||
},
|
||||
});
|
||||
}
|
||||
54
src/lib/download-name.ts
Normal file
54
src/lib/download-name.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
const pad = (value: number) => String(value).padStart(2, "0");
|
||||
|
||||
/**
|
||||
* Legacy front-made download name `"{prefix} {project title} {date}.xlsx"`, with the date as
|
||||
* `YYYY-MM-DD HHmmss` in browser time (legacy DateTimeString added year+month+day as numbers).
|
||||
* Characters a file name cannot hold become `_`, like the server's Content-Disposition names.
|
||||
*/
|
||||
export function exportFileName(prefix: string, title: string, now: Date): string {
|
||||
const date =
|
||||
now.getFullYear() +
|
||||
"-" +
|
||||
pad(now.getMonth() + 1) +
|
||||
"-" +
|
||||
pad(now.getDate()) +
|
||||
" " +
|
||||
pad(now.getHours()) +
|
||||
pad(now.getMinutes()) +
|
||||
pad(now.getSeconds());
|
||||
const safe = (prefix + " " + title + " " + date).replace(/[\u0000-\u001f\u007f\\/:*?"<>|]/g, "_");
|
||||
return safe + ".xlsx";
|
||||
}
|
||||
|
||||
/** Prefixes of the legacy download names. */
|
||||
export const EXPORT_PREFIX = {
|
||||
table: "[TABLE]",
|
||||
quota: "[QUOTA]",
|
||||
data: "(DATA)",
|
||||
dataIncomplete: "(DATA_N)",
|
||||
guide: "(GUIDE)",
|
||||
header: "(Header)",
|
||||
title: "[Explain]",
|
||||
} as const;
|
||||
/** Legacy fixed name of the question upload template. */
|
||||
export const QUESTION_FORM_NAME = "KON 문항 등록 양식.xlsx";
|
||||
|
||||
/**
|
||||
* File name from a Content-Disposition header. Prefers the RFC 5987 `filename*=UTF-8''…` form the
|
||||
* server sends for Korean names, then a plain `filename`, then the fallback.
|
||||
*/
|
||||
export function contentDispositionName(header: string | null, fallback: string): string {
|
||||
if (!header) return fallback;
|
||||
const extended = /filename\*\s*=\s*([^']*)'[^']*'([^;]+)/i.exec(header);
|
||||
if (extended) {
|
||||
try {
|
||||
const name = decodeURIComponent(extended[2].trim().replace(/^"|"$/g, ""));
|
||||
if (name) return name;
|
||||
} catch {
|
||||
// Malformed percent-encoding: try the plain form below.
|
||||
}
|
||||
}
|
||||
const plain = /filename\s*=\s*("([^"]*)"|[^;]+)/i.exec(header);
|
||||
const name = (plain?.[2] ?? plain?.[1] ?? "").trim();
|
||||
return name || fallback;
|
||||
}
|
||||
@@ -2,6 +2,11 @@ import { createHttpClient } from "@kri/common/http";
|
||||
import { clientEnv } from "@/lib/env.client";
|
||||
|
||||
const resolveBaseUrl = () =>
|
||||
typeof window === "undefined" ? clientEnv.API_BASE : new URL(clientEnv.API_BASE, window.location.origin).toString();
|
||||
typeof window === "undefined"
|
||||
? clientEnv.API_BASE
|
||||
: new URL(clientEnv.API_BASE, window.location.origin).toString();
|
||||
|
||||
export const nextApi = createHttpClient(resolveBaseUrl());
|
||||
export const nextApi = createHttpClient(resolveBaseUrl(), {
|
||||
onForbidden: false,
|
||||
onResponseError: false,
|
||||
});
|
||||
|
||||
@@ -3,11 +3,14 @@ import { createHttpClient } from "@kri/common/http";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
|
||||
export async function createServerApi() {
|
||||
export async function createServerApi(authenticated = true) {
|
||||
const cookieStore = await cookies();
|
||||
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value ?? null;
|
||||
const accessToken = authenticated ? cookieStore.get(CookieKeys.AuthToken)?.value ?? null : null;
|
||||
return createHttpClient(serverEnv.API_SERVER, {
|
||||
getToken: () => accessToken,
|
||||
defaultHeaders: { "content-type": "application/json" },
|
||||
onUnauthorized: false,
|
||||
onForbidden: false,
|
||||
onResponseError: false,
|
||||
});
|
||||
}
|
||||
|
||||
203
src/lib/legacy-filter.ts
Normal file
203
src/lib/legacy-filter.ts
Normal file
@@ -0,0 +1,203 @@
|
||||
import { isRecord } from "@/types/kart";
|
||||
import type { ReportFilter } from "@/types/report";
|
||||
|
||||
/**
|
||||
* Legacy FilterPopup line (states/Format.js filterFormat). Bookmarks persist this tree as
|
||||
* FILTER_ARRAY JSON in a database shared with the legacy system, so the shape is kept verbatim.
|
||||
*/
|
||||
export type LegacyFilterOp =
|
||||
| "IN"
|
||||
| "NOT IN"
|
||||
| "<"
|
||||
| "<="
|
||||
| ">"
|
||||
| ">="
|
||||
| "IS NOT NULL"
|
||||
| "IS NULL";
|
||||
export type AndOr = "" | "AND" | "OR";
|
||||
export type LegacyFilterLine = {
|
||||
id: string;
|
||||
qid: string;
|
||||
vname: string;
|
||||
op: LegacyFilterOp;
|
||||
/** Comma-separated codes for IN / NOT IN, a single value for comparisons. */
|
||||
value: string;
|
||||
preAndOr: AndOr;
|
||||
postAndOr: AndOr;
|
||||
childList: LegacyFilterLine[];
|
||||
};
|
||||
|
||||
export const FILTER_OPERATORS: { value: LegacyFilterOp; label: string }[] = [
|
||||
{ value: "IN", label: "=" },
|
||||
{ value: "NOT IN", label: "≠" },
|
||||
{ value: "<", label: "<" },
|
||||
{ value: "<=", label: "≤" },
|
||||
{ value: ">", label: ">" },
|
||||
{ value: ">=", label: "≥" },
|
||||
{ value: "IS NOT NULL", label: "Has Value" },
|
||||
{ value: "IS NULL", label: "Has No Value" },
|
||||
];
|
||||
|
||||
export const newFilterLine = (id: string, preAndOr: AndOr = ""): LegacyFilterLine => ({
|
||||
id,
|
||||
qid: "",
|
||||
vname: "",
|
||||
op: "IN",
|
||||
value: "",
|
||||
preAndOr,
|
||||
postAndOr: "",
|
||||
childList: [],
|
||||
});
|
||||
|
||||
const isActive = (line: LegacyFilterLine) => line.qid !== "";
|
||||
|
||||
/** Legacy FilterPopup.makeFilterString; mode "v" names variables, "r" the [UK:n] form. */
|
||||
export function makeFilterString(
|
||||
list: LegacyFilterLine[],
|
||||
mode: "v" | "r",
|
||||
): string {
|
||||
let text = "(";
|
||||
for (const line of list) {
|
||||
if (!isActive(line)) continue;
|
||||
const bracket = line.op.includes("IN");
|
||||
text += line.preAndOr !== "" ? " " + line.preAndOr : "";
|
||||
text +=
|
||||
" " +
|
||||
(mode === "r"
|
||||
? line.qid.replace(
|
||||
/(\d+)((?:\[\w+\])*)/g,
|
||||
(_match, number: string, suffix: string) =>
|
||||
"[UK:" + number + "]" + suffix,
|
||||
)
|
||||
: line.vname);
|
||||
text += " " + line.op + " ";
|
||||
if (bracket) text += "(";
|
||||
text += line.value;
|
||||
if (bracket) text += ")";
|
||||
if (line.childList.length > 0 && isActive(line.childList[0])) {
|
||||
text += line.postAndOr !== "" ? " " + line.postAndOr + " " : "";
|
||||
text += makeFilterString(line.childList, mode);
|
||||
}
|
||||
}
|
||||
return text + " )";
|
||||
}
|
||||
|
||||
/** Condition text shown in the Filter box; empty when no line has a question. */
|
||||
export const filterCondition = (list: LegacyFilterLine[]) =>
|
||||
list.length > 0 && isActive(list[0]) ? makeFilterString(list, "v") : "";
|
||||
export const realFilterCondition = (list: LegacyFilterLine[]) =>
|
||||
list.length > 0 && isActive(list[0]) ? makeFilterString(list, "r") : "";
|
||||
|
||||
/** Numeric tokens become numbers (server compares them numerically, like LegacyFilterService). */
|
||||
const filterValue = (token: string): string | number => {
|
||||
const text = token.trim();
|
||||
return /^[+-]?(\d+(\.\d*)?|\.\d+)$/.test(text) ? Number(text) : text;
|
||||
};
|
||||
|
||||
function condition(line: LegacyFilterLine): ReportFilter {
|
||||
const base = { dimensionId: line.qid, reference: "QID" as const };
|
||||
if (line.op === "IS NOT NULL")
|
||||
return { ...base, operator: "IS_ANSWERED", values: [] };
|
||||
if (line.op === "IS NULL")
|
||||
return { ...base, operator: "IS_UNANSWERED", values: [] };
|
||||
const values = line.value
|
||||
.split(",")
|
||||
.map((token) => token.trim())
|
||||
.filter((token) => token !== "");
|
||||
if (!values.length) throw new Error("필터 값을 선택해 주세요.");
|
||||
if (line.op === "IN" || line.op === "NOT IN")
|
||||
return {
|
||||
...base,
|
||||
operator: line.op === "IN" ? "IN" : "NOT_IN",
|
||||
values: values.map(filterValue),
|
||||
};
|
||||
const operator = ({ "<": "LT", "<=": "LE", ">": "GT", ">=": "GE" } as const)[
|
||||
line.op
|
||||
];
|
||||
return { ...base, operator, values: [filterValue(values[0])] };
|
||||
}
|
||||
|
||||
const group = (operator: "AND" | "OR", children: ReportFilter[]): ReportFilter =>
|
||||
children.length === 1 ? children[0] : { operator, children };
|
||||
|
||||
/**
|
||||
* Converts the legacy tree into the statistics filter AST with the same meaning as the legacy
|
||||
* condition string: siblings are joined by their preAndOr, a child list follows its line with
|
||||
* postAndOr as a parenthesised operand, and AND binds tighter than OR.
|
||||
*/
|
||||
export function toServerFilter(list: LegacyFilterLine[]): ReportFilter | null {
|
||||
const operands: ReportFilter[] = [];
|
||||
const operators: ("AND" | "OR")[] = [];
|
||||
const push = (operator: AndOr, operand: ReportFilter) => {
|
||||
if (operands.length) operators.push(operator === "OR" ? "OR" : "AND");
|
||||
operands.push(operand);
|
||||
};
|
||||
for (const line of list) {
|
||||
if (!isActive(line)) continue;
|
||||
push(line.preAndOr, condition(line));
|
||||
if (line.childList.length > 0 && isActive(line.childList[0])) {
|
||||
const child = toServerFilter(line.childList);
|
||||
if (child) push(line.postAndOr, child);
|
||||
}
|
||||
}
|
||||
if (!operands.length) return null;
|
||||
const orGroups: ReportFilter[][] = [[operands[0]]];
|
||||
operators.forEach((operator, index) => {
|
||||
if (operator === "OR") orGroups.push([operands[index + 1]]);
|
||||
else orGroups[orGroups.length - 1].push(operands[index + 1]);
|
||||
});
|
||||
return group(
|
||||
"OR",
|
||||
orGroups.map((children) => group("AND", children)),
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy filterFormat key order; `postAndOr` is appended only once a child list exists. */
|
||||
function legacyLine(line: LegacyFilterLine): Record<string, unknown> {
|
||||
return {
|
||||
id: line.id,
|
||||
qid: line.qid,
|
||||
vname: line.vname,
|
||||
op: line.op,
|
||||
value: line.value,
|
||||
preAndOr: line.preAndOr,
|
||||
PostAndOr: "",
|
||||
childList: line.childList.map(legacyLine),
|
||||
...(line.postAndOr ? { postAndOr: line.postAndOr } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/** FILTER_ARRAY text as the legacy FilterPopup stores it (bookmarks, derived variable rules). */
|
||||
export const writeFilterArray = (list: LegacyFilterLine[]) =>
|
||||
list.length ? JSON.stringify(list.map(legacyLine)) : "";
|
||||
|
||||
/** Reads a saved FILTER_ARRAY (legacy JSON, may use the PostAndOr spelling). */
|
||||
export function readFilterArray(json: string): LegacyFilterLine[] {
|
||||
if (!json) return [];
|
||||
const parsed: unknown = JSON.parse(json);
|
||||
if (!Array.isArray(parsed)) throw new Error("저장된 필터 형식을 확인해 주세요.");
|
||||
return parsed.map(readLine);
|
||||
}
|
||||
function readLine(line: unknown): LegacyFilterLine {
|
||||
if (!isRecord(line)) throw new Error("저장된 필터 형식을 확인해 주세요.");
|
||||
const text = (key: string) => {
|
||||
const raw = line[key];
|
||||
return typeof raw === "string" ? raw : "";
|
||||
};
|
||||
const andOr = (key: string): AndOr => {
|
||||
const raw = text(key);
|
||||
return raw === "AND" || raw === "OR" ? raw : "";
|
||||
};
|
||||
const op = FILTER_OPERATORS.find((item) => item.value === line.op)?.value;
|
||||
if (!op) throw new Error("저장된 필터 연산자를 확인해 주세요.");
|
||||
return {
|
||||
id: text("id"),
|
||||
qid: text("qid"),
|
||||
vname: text("vname"),
|
||||
op,
|
||||
value: text("value"),
|
||||
preAndOr: andOr("preAndOr"),
|
||||
postAndOr: andOr("postAndOr") || andOr("PostAndOr"),
|
||||
childList: Array.isArray(line.childList) ? line.childList.map(readLine) : [],
|
||||
};
|
||||
}
|
||||
37
src/lib/progress-zoom.ts
Normal file
37
src/lib/progress-zoom.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { isRecord, validDateRange, type DateRange } from "@/types/kart";
|
||||
|
||||
export type ZoomWindow = { start: number; end: number };
|
||||
|
||||
/** Reads start/end percentages from an ECharts `datazoom` event (direct or batched). */
|
||||
export function readZoomEvent(event: unknown): ZoomWindow | null {
|
||||
if (!isRecord(event)) return null;
|
||||
const item = Array.isArray(event.batch) ? event.batch[0] : event;
|
||||
if (!isRecord(item)) return null;
|
||||
const { start, end } = item;
|
||||
return typeof start === "number" &&
|
||||
typeof end === "number" &&
|
||||
Number.isFinite(start) &&
|
||||
Number.isFinite(end)
|
||||
? { start, end }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy Current.js onDataZoom: label index = round((n - 1) * percent / 100).
|
||||
* `labels` are display dates (yyyy-mm-dd); returns null when they are not valid dates.
|
||||
*/
|
||||
export function zoomDateRange(
|
||||
labels: string[],
|
||||
zoom: ZoomWindow,
|
||||
): DateRange | null {
|
||||
if (!labels.length) return null;
|
||||
const at = (percent: number) =>
|
||||
labels[
|
||||
Math.min(
|
||||
labels.length - 1,
|
||||
Math.max(0, Math.round(((labels.length - 1) * percent) / 100)),
|
||||
)
|
||||
];
|
||||
const range = { startDate: at(zoom.start), endDate: at(zoom.end) };
|
||||
return range.startDate && validDateRange(range) ? range : null;
|
||||
}
|
||||
155
src/lib/project-proxy-policy.ts
Normal file
155
src/lib/project-proxy-policy.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
const progress = new Set(["day", "type", "loi", "screen"]);
|
||||
/** Browser inputs select only these implemented read operations, never an arbitrary upstream URL. */
|
||||
export function isProjectReadPath(slug: string[]): boolean {
|
||||
if (slug.length === 1) return slug[0] === "list" || slug[0] === "summary";
|
||||
return (
|
||||
slug.length === 4 &&
|
||||
(slug[0] === "0" || slug[0] === "1") &&
|
||||
slug[1] !== "." &&
|
||||
slug[1] !== ".." &&
|
||||
slug[1].length > 0 &&
|
||||
slug[1].length <= 20 &&
|
||||
!/[|/\\]/.test(slug[1]) &&
|
||||
((slug[2] === "progress" && progress.has(slug[3])) ||
|
||||
(slug[2] === "question" && slug[3] === "list"))
|
||||
);
|
||||
}
|
||||
export function projectReadQuery(
|
||||
slug: string[],
|
||||
input: URLSearchParams,
|
||||
): Record<string, string> {
|
||||
const allowed =
|
||||
slug[0] === "list"
|
||||
? ["projectType", "intranetCode", "userTeam", "keyword"]
|
||||
: slug.length === 4 && slug[2] === "progress" && slug[3] !== "day"
|
||||
? ["startDate", "endDate"]
|
||||
: [];
|
||||
const result: Record<string, string> = {};
|
||||
for (const key of allowed) {
|
||||
const value = input.get(key);
|
||||
if (value !== null) result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Quota BFF: `{type}/{pkey}/list` (GET) and `{type}/{pkey}/{quotaOrder}/result` (POST) only. */
|
||||
export function isQuotaListPath(slug: string[]): boolean {
|
||||
return (
|
||||
slug.length === 3 &&
|
||||
slug[2] === "list" &&
|
||||
isProjectReadPath([slug[0], slug[1], "question", "list"])
|
||||
);
|
||||
}
|
||||
export function isQuotaResultPath(slug: string[]): boolean {
|
||||
return (
|
||||
slug.length === 4 &&
|
||||
/^\d{1,4}$/.test(slug[2]) &&
|
||||
slug[3] === "result" &&
|
||||
isProjectReadPath([slug[0], slug[1], "question", "list"])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookmark BFF: `{type}/{pkey}/list?page=` (GET), `{type}/{pkey}` (POST) and
|
||||
* `{type}/{pkey}/{bookmarkId}` (PUT/DELETE), forwarded under `/project/{type}/{pkey}/bookmark`.
|
||||
*/
|
||||
const isProjectSlug = (slug: string[]) =>
|
||||
isProjectReadPath([slug[0], slug[1], "question", "list"]);
|
||||
export function isBookmarkListPath(slug: string[]): boolean {
|
||||
return slug.length === 3 && slug[2] === "list" && isProjectSlug(slug);
|
||||
}
|
||||
export function isBookmarkCreatePath(slug: string[]): boolean {
|
||||
return slug.length === 2 && isProjectSlug(slug);
|
||||
}
|
||||
export function isBookmarkItemPath(slug: string[]): boolean {
|
||||
const id = slug[2] ?? "";
|
||||
return (
|
||||
slug.length === 3 &&
|
||||
id !== "list" &&
|
||||
id !== "." &&
|
||||
id !== ".." &&
|
||||
id.length > 0 &&
|
||||
id.length <= 100 &&
|
||||
!/[\s|/\\]/.test(id) &&
|
||||
isProjectSlug(slug)
|
||||
);
|
||||
}
|
||||
export function bookmarkUpstreamPath(slug: string[]): string {
|
||||
return (
|
||||
"/project/" +
|
||||
slug.slice(0, 2).map(encodeURIComponent).join("/") +
|
||||
"/bookmark" +
|
||||
slug.slice(2).map((part) => "/" + encodeURIComponent(part)).join("")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived variable BFF: `{type}/{pkey}/list` (GET), `{type}/{pkey}` (POST) and
|
||||
* `{type}/{pkey}/{variableId}` (PUT/DELETE) under `/project/{type}/{pkey}/derived`.
|
||||
* Recalculation endpoints stay closed (the legacy screen never calls them).
|
||||
*/
|
||||
export function isDerivedListPath(slug: string[]): boolean {
|
||||
return slug.length === 3 && slug[2] === "list" && isProjectSlug(slug);
|
||||
}
|
||||
export function isDerivedCreatePath(slug: string[]): boolean {
|
||||
return slug.length === 2 && isProjectSlug(slug);
|
||||
}
|
||||
export function isDerivedItemPath(slug: string[]): boolean {
|
||||
return (
|
||||
slug.length === 3 &&
|
||||
slug[2] !== "list" &&
|
||||
slug[2] !== "recalculate" &&
|
||||
/^[A-Za-z][A-Za-z0-9_]{0,127}$/.test(slug[2]) &&
|
||||
isProjectSlug(slug)
|
||||
);
|
||||
}
|
||||
export function derivedUpstreamPath(slug: string[]): string {
|
||||
return (
|
||||
"/project/" +
|
||||
slug.slice(0, 2).map(encodeURIComponent).join("/") +
|
||||
"/derived" +
|
||||
slug.slice(2).map((part) => "/" + encodeURIComponent(part)).join("")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download BFF (`/api/export/...`): fixed file endpoints only. Returns the upstream path and the
|
||||
* request body kind, or null when the method/path is not an implemented download.
|
||||
*/
|
||||
export type ExportTarget = { path: string; body: "none" | "excel" | "data" };
|
||||
export function exportTarget(method: "GET" | "POST", slug: string[]): ExportTarget | null {
|
||||
if (method === "GET" && slug.join("/") === "form/question")
|
||||
return { path: "/export/form/question", body: "none" };
|
||||
if (slug.length !== 3 && slug.length !== 4) return null;
|
||||
if (!isProjectSlug(slug)) return null;
|
||||
const project = slug.slice(0, 2).map(encodeURIComponent).join("/");
|
||||
const action = slug.slice(2).join("/");
|
||||
if (method === "GET") {
|
||||
if (action === "form/data" || action === "form/title" || action === "guide")
|
||||
return { path: "/project/" + project + "/export/" + action, body: "none" };
|
||||
return null;
|
||||
}
|
||||
if (action === "table")
|
||||
return { path: "/project/" + project + "/export/excel/table", body: "excel" };
|
||||
if (action === "quota") return { path: "/quota/" + project + "/export/excel", body: "excel" };
|
||||
if (action === "data") return { path: "/project/" + project + "/export/data", body: "data" };
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Import BFF: `{type}/{pkey}/{title|question|data}` multipart uploads. */
|
||||
export function isImportPath(slug: string[]): boolean {
|
||||
return (
|
||||
slug.length === 3 &&
|
||||
(slug[2] === "title" || slug[2] === "question" || slug[2] === "data") &&
|
||||
isProjectSlug(slug)
|
||||
);
|
||||
}
|
||||
|
||||
export function isReportStreamPath(slug: string[]): boolean {
|
||||
return (
|
||||
slug.length === 4 &&
|
||||
slug[2] === "statistics" &&
|
||||
slug[3] === "result" &&
|
||||
isProjectReadPath([slug[0], slug[1], "question", "list"])
|
||||
);
|
||||
}
|
||||
22
src/lib/quota-ui.ts
Normal file
22
src/lib/quota-ui.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { QuotaCell } from "@/types/quota";
|
||||
|
||||
// Legacy QuotaThTd colours: under target, over target, exactly met.
|
||||
const UNDER = { text: "#1cae81", gauge: "#F0F7DF" };
|
||||
const OVER = { text: "#ff2500", gauge: "#FFE5E1" };
|
||||
const MET = { text: "#0066ff", gauge: "#E1EDFF" };
|
||||
|
||||
/**
|
||||
* Picks the legacy colour and gauge from the server's achievement fields. A target of 0 has no
|
||||
* percentage: UNDEFINED (nothing completed) reads as met, POSITIVE_INFINITY as over, both without
|
||||
* a gauge bar.
|
||||
*/
|
||||
export function quotaCellStyle(cell: QuotaCell): { color: string; background?: string } {
|
||||
if (cell.achievementState === "UNDEFINED") return { color: MET.text };
|
||||
if (cell.achievementState === "POSITIVE_INFINITY") return { color: OVER.text };
|
||||
const percent = cell.achievementPercent ?? 0;
|
||||
const tone = percent < 100 ? UNDER : percent > 100 ? OVER : MET;
|
||||
return {
|
||||
color: tone.text,
|
||||
background: `linear-gradient(to right, ${tone.gauge} ${percent}%, #FAFAFA 0%)`,
|
||||
};
|
||||
}
|
||||
368
src/lib/report-contract.ts
Normal file
368
src/lib/report-contract.ts
Normal file
@@ -0,0 +1,368 @@
|
||||
import { isRecord, validDateRange } from "@/types/kart";
|
||||
import type {
|
||||
Question,
|
||||
ReportBatch,
|
||||
ReportCell,
|
||||
ReportFilter,
|
||||
ReportResult,
|
||||
ReportRow,
|
||||
ReportEvent,
|
||||
FilterDraft,
|
||||
DisplayMode,
|
||||
} from "@/types/report";
|
||||
|
||||
const optionalText = (v: unknown) => v == null || typeof v === "string";
|
||||
const optionalNumber = (v: unknown) =>
|
||||
v == null || (typeof v === "number" && Number.isFinite(v));
|
||||
const integer = (v: unknown): v is number =>
|
||||
typeof v === "number" && Number.isSafeInteger(v);
|
||||
const strings = (v: unknown): v is string[] =>
|
||||
Array.isArray(v) && v.every((s) => typeof s === "string");
|
||||
const conditions = new Set([
|
||||
"EQ",
|
||||
"NE",
|
||||
"GT",
|
||||
"GE",
|
||||
"LT",
|
||||
"LE",
|
||||
"IN",
|
||||
"NOT_IN",
|
||||
"BETWEEN",
|
||||
"IS_ANSWERED",
|
||||
"IS_UNANSWERED",
|
||||
]);
|
||||
export const isQuestion = (v: unknown): v is Question =>
|
||||
isRecord(v) &&
|
||||
typeof v.qid === "string" &&
|
||||
v.qid.length > 0 &&
|
||||
(v.qOrder == null || integer(v.qOrder)) &&
|
||||
[
|
||||
"variable",
|
||||
"title",
|
||||
"explain",
|
||||
"qtype",
|
||||
"vtype",
|
||||
"labelInfo",
|
||||
"attrInfo",
|
||||
"isDerived",
|
||||
].every((key) => optionalText(v[key]));
|
||||
function isCell(v: unknown): v is ReportCell {
|
||||
return (
|
||||
isRecord(v) &&
|
||||
integer(v.columnIndex) &&
|
||||
v.columnIndex >= 0 &&
|
||||
integer(v.rowSpan) &&
|
||||
v.rowSpan > 0 &&
|
||||
integer(v.colSpan) &&
|
||||
v.colSpan > 0 &&
|
||||
typeof v.kind === "string" &&
|
||||
[
|
||||
"textValue",
|
||||
"measurement",
|
||||
"countDisplayText",
|
||||
"percentDisplayText",
|
||||
"statisticDisplayText",
|
||||
].every((key) => optionalText(v[key])) &&
|
||||
["count", "base"].every((key) => v[key] == null || integer(v[key])) &&
|
||||
["percent", "statisticValue", "percentExact", "statisticExact"].every((key) =>
|
||||
optionalNumber(v[key]),
|
||||
)
|
||||
);
|
||||
}
|
||||
export function isRow(v: unknown): v is ReportRow {
|
||||
return (
|
||||
isRecord(v) &&
|
||||
integer(v.rowIndex) &&
|
||||
v.rowIndex >= 0 &&
|
||||
typeof v.rowId === "string" &&
|
||||
typeof v.kind === "string" &&
|
||||
Array.isArray(v.cells) &&
|
||||
v.cells.every(isCell)
|
||||
);
|
||||
}
|
||||
export function isReportResult(v: unknown): v is ReportResult {
|
||||
return (
|
||||
isRecord(v) &&
|
||||
(v.type === "TABLE" || v.type === "TEXT_ANALYSIS") &&
|
||||
typeof v.questionId === "string" &&
|
||||
optionalText(v.title) &&
|
||||
Array.isArray(v.columns) &&
|
||||
v.columns.every(
|
||||
(c) =>
|
||||
isRecord(c) &&
|
||||
typeof c.columnId === "string" &&
|
||||
typeof c.kind === "string" &&
|
||||
strings(c.labels),
|
||||
) &&
|
||||
Array.isArray(v.headerRows) &&
|
||||
v.headerRows.every(isRow) &&
|
||||
Array.isArray(v.rows) &&
|
||||
v.rows.every(isRow) &&
|
||||
Array.isArray(v.words) &&
|
||||
v.words.every(
|
||||
(w) =>
|
||||
isRecord(w) &&
|
||||
typeof w.text === "string" &&
|
||||
typeof w.tag === "string" &&
|
||||
integer(w.count) &&
|
||||
w.count >= 0,
|
||||
)
|
||||
);
|
||||
}
|
||||
export function readReportEvent(v: unknown): ReportEvent {
|
||||
if (isRecord(v)) {
|
||||
if (
|
||||
v.type === "complete" &&
|
||||
integer(v.total) &&
|
||||
v.total >= 0 &&
|
||||
integer(v.succeeded) &&
|
||||
v.succeeded >= 0 &&
|
||||
integer(v.failed) &&
|
||||
v.failed >= 0 &&
|
||||
v.succeeded + v.failed === v.total
|
||||
)
|
||||
return {
|
||||
type: "complete",
|
||||
total: v.total,
|
||||
succeeded: v.succeeded,
|
||||
failed: v.failed,
|
||||
};
|
||||
if (integer(v.position) && v.position >= 0 && typeof v.index === "string") {
|
||||
if (v.type === "result" && isReportResult(v.result))
|
||||
return {
|
||||
type: "result",
|
||||
position: v.position,
|
||||
index: v.index,
|
||||
result: v.result,
|
||||
};
|
||||
if (
|
||||
v.type === "error" &&
|
||||
integer(v.status) &&
|
||||
v.status >= 400 &&
|
||||
v.status <= 599 &&
|
||||
typeof v.code === "string" &&
|
||||
typeof v.message === "string"
|
||||
) {
|
||||
return {
|
||||
type: "error",
|
||||
position: v.position,
|
||||
index: v.index,
|
||||
status: v.status,
|
||||
code: v.code,
|
||||
message: v.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error("집계 스트림의 응답 형식이 올바르지 않습니다.");
|
||||
}
|
||||
export function readFilter(v: unknown, depth = 0): ReportFilter {
|
||||
if (!isRecord(v) || depth > 32) throw new Error("필터 구조를 확인해 주세요.");
|
||||
const { operator } = v;
|
||||
if (operator === "AND" || operator === "OR" || operator === "NOT") {
|
||||
if (
|
||||
!Array.isArray(v.children) ||
|
||||
!v.children.length ||
|
||||
v.children.length > 128 ||
|
||||
(operator === "NOT" && v.children.length !== 1) ||
|
||||
(v.values != null && (!Array.isArray(v.values) || v.values.length)) ||
|
||||
v.dimensionId
|
||||
)
|
||||
throw new Error("필터 그룹의 조건을 확인해 주세요.");
|
||||
return {
|
||||
operator,
|
||||
children: v.children.map((child) => readFilter(child, depth + 1)),
|
||||
};
|
||||
}
|
||||
if (
|
||||
typeof operator !== "string" ||
|
||||
!conditions.has(operator) ||
|
||||
typeof v.dimensionId !== "string" ||
|
||||
!v.dimensionId.trim() ||
|
||||
v.dimensionId.includes("#") ||
|
||||
(v.reference != null &&
|
||||
v.reference !== "QID" &&
|
||||
v.reference !== "VARIABLE") ||
|
||||
(v.children != null && (!Array.isArray(v.children) || v.children.length))
|
||||
)
|
||||
throw new Error("필터 문항과 비교 방식을 확인해 주세요.");
|
||||
const values = v.values ?? [];
|
||||
if (
|
||||
!Array.isArray(values) ||
|
||||
!values.every(
|
||||
(value) =>
|
||||
typeof value === "string" ||
|
||||
(typeof value === "number" && Number.isFinite(value)),
|
||||
)
|
||||
)
|
||||
throw new Error("필터 비교 값을 확인해 주세요.");
|
||||
const expected =
|
||||
operator === "IS_ANSWERED" || operator === "IS_UNANSWERED"
|
||||
? 0
|
||||
: operator === "BETWEEN"
|
||||
? 2
|
||||
: operator === "IN" || operator === "NOT_IN"
|
||||
? -1
|
||||
: 1;
|
||||
if (expected === -1 ? values.length < 1 : values.length !== expected)
|
||||
throw new Error("필터 값의 개수를 확인해 주세요.");
|
||||
return {
|
||||
operator: operator as ReportFilter["operator"],
|
||||
dimensionId: v.dimensionId,
|
||||
reference: v.reference ?? "QID",
|
||||
values,
|
||||
};
|
||||
}
|
||||
export function readReportBatch(v: unknown): ReportBatch {
|
||||
if (!isRecord(v) || !strings(v.indexes) || !v.indexes.length)
|
||||
throw new Error("집계할 문항을 선택해 주세요.");
|
||||
const mode = v.mode ?? "STANDARD";
|
||||
if (
|
||||
!["STANDARD", "TABULATION_0", "TABULATION_1"].includes(String(mode)) ||
|
||||
(mode === "STANDARD"
|
||||
? v.indexes.some((id) => !id.trim())
|
||||
: v.indexes.some((id) => id !== ""))
|
||||
)
|
||||
throw new Error("집계 모드와 문항을 확인해 주세요.");
|
||||
const banners = v.banners ?? [];
|
||||
if (
|
||||
!Array.isArray(banners) ||
|
||||
!banners.every(
|
||||
(group) =>
|
||||
strings(group) &&
|
||||
group.length > 0 &&
|
||||
group.length <= 5 &&
|
||||
group.every((id) => id.trim()),
|
||||
)
|
||||
)
|
||||
throw new Error("배너 묶음은 문항 1~5개를 선택해 주세요.");
|
||||
const startDate = v.startDate ?? "",
|
||||
endDate = v.endDate ?? "";
|
||||
if (
|
||||
typeof startDate !== "string" ||
|
||||
typeof endDate !== "string" ||
|
||||
!validDateRange({ startDate, endDate })
|
||||
)
|
||||
throw new Error("조회 날짜 범위를 확인해 주세요.");
|
||||
const dataScope = v.dataScope ?? "ACTUAL",
|
||||
headerMode = v.headerMode ?? "MERGED";
|
||||
const percentageDecimals = v.percentageDecimals ?? 14,
|
||||
statisticDecimals = v.statisticDecimals ?? 14;
|
||||
if (
|
||||
!["ACTUAL", "TEST", "ALL"].includes(String(dataScope)) ||
|
||||
!["NONE", "FLAT", "MERGED"].includes(String(headerMode)) ||
|
||||
!integer(percentageDecimals) ||
|
||||
percentageDecimals < 0 ||
|
||||
percentageDecimals > 14 ||
|
||||
!integer(statisticDecimals) ||
|
||||
statisticDecimals < 0 ||
|
||||
statisticDecimals > 14
|
||||
)
|
||||
throw new Error("집계 표시 옵션을 확인해 주세요.");
|
||||
for (const key of [
|
||||
"transpose",
|
||||
"showSubtotals",
|
||||
"showValueCodes",
|
||||
"showNumericSum",
|
||||
])
|
||||
if (v[key] != null && typeof v[key] !== "boolean")
|
||||
throw new Error("집계 옵션을 확인해 주세요.");
|
||||
const groups = v.valueGroups ?? [];
|
||||
if (
|
||||
!Array.isArray(groups) ||
|
||||
!groups.every(
|
||||
(g) =>
|
||||
isRecord(g) &&
|
||||
typeof g.label === "string" &&
|
||||
g.label.trim() &&
|
||||
strings(g.values) &&
|
||||
g.values.length &&
|
||||
g.values.every((value) => value.trim()),
|
||||
)
|
||||
)
|
||||
throw new Error("보기 묶음의 이름과 값을 확인해 주세요.");
|
||||
return {
|
||||
indexes: [...v.indexes],
|
||||
mode: mode as ReportBatch["mode"],
|
||||
banners: banners.map((group) => [...group]),
|
||||
filter: v.filter == null ? null : readFilter(v.filter),
|
||||
dataScope: dataScope as ReportBatch["dataScope"],
|
||||
headerMode: headerMode as ReportBatch["headerMode"],
|
||||
...(startDate ? { startDate, endDate } : {}),
|
||||
percentageDecimals,
|
||||
statisticDecimals,
|
||||
transpose: v.transpose === true,
|
||||
showSubtotals: v.showSubtotals !== false,
|
||||
showValueCodes: v.showValueCodes === true,
|
||||
showNumericSum: v.showNumericSum === true,
|
||||
valueGroups: groups.map((g) => ({ label: g.label, values: [...g.values] })),
|
||||
};
|
||||
}
|
||||
export function compileFilter(draft: FilterDraft | null): ReportFilter | null {
|
||||
if (!draft) return null;
|
||||
if (draft.kind === "group")
|
||||
return readFilter({
|
||||
operator: draft.operator,
|
||||
children: draft.children.map(compileFilter),
|
||||
});
|
||||
const noValues =
|
||||
draft.operator === "IS_ANSWERED" || draft.operator === "IS_UNANSWERED";
|
||||
const values = noValues
|
||||
? []
|
||||
: draft.values.map((value) => {
|
||||
if (!draft.numeric) return value;
|
||||
if (!value.trim() || !Number.isFinite(Number(value)))
|
||||
throw new Error("숫자 필터 값을 확인해 주세요.");
|
||||
return Number(value);
|
||||
});
|
||||
return readFilter({
|
||||
operator: draft.operator,
|
||||
dimensionId: draft.dimensionId,
|
||||
reference: "QID",
|
||||
values,
|
||||
});
|
||||
}
|
||||
export function cellDisplay(cell: ReportCell, mode: DisplayMode): string {
|
||||
if (cell.kind === "TEXT" || cell.kind === "EMPTY")
|
||||
return cell.textValue ?? "";
|
||||
if (cell.kind === "STATISTIC" || cell.kind === "MISSING")
|
||||
return cell.statisticDisplayText ?? "-";
|
||||
const n =
|
||||
cell.countDisplayText ?? (cell.count == null ? "-" : String(cell.count));
|
||||
const raw =
|
||||
cell.percentDisplayText ??
|
||||
(cell.percent == null ? "-" : String(cell.percent));
|
||||
const percent = raw === "-" || !raw ? "-" : raw + "%";
|
||||
return mode === "N"
|
||||
? n
|
||||
: mode === "PERCENT"
|
||||
? percent
|
||||
: n + " (" + percent + ")";
|
||||
}
|
||||
export function choices(
|
||||
question: Question,
|
||||
): { value: string; label: string }[] {
|
||||
if (!question.labelInfo) return [];
|
||||
const parsed: unknown = JSON.parse(question.labelInfo);
|
||||
if (!isRecord(parsed)) throw new Error("문항 보기 정보를 확인해 주세요.");
|
||||
return Object.entries(parsed).flatMap(([key, value]) =>
|
||||
isRecord(value)
|
||||
? [
|
||||
{
|
||||
value:
|
||||
typeof value.value === "string"
|
||||
? value.value
|
||||
: typeof value.value === "number" &&
|
||||
Number.isFinite(value.value)
|
||||
? String(value.value)
|
||||
: key,
|
||||
label: typeof value.label === "string" ? value.label : key,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
export const canIndex = (q: Question) =>
|
||||
q.qtype !== "com" && q.qtype !== "come";
|
||||
export const canBanner = (q: Question) =>
|
||||
canIndex(q) && q.qtype !== "num" && q.qtype !== "text";
|
||||
121
src/lib/report-excel.ts
Normal file
121
src/lib/report-excel.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import type { ReportCell, ReportResult, ReportRow } from "@/types/report";
|
||||
import type { QuotaCell, QuotaResult } from "@/types/quota";
|
||||
import { isTransposed, legacyCellText } from "@/lib/report-ui";
|
||||
|
||||
/**
|
||||
* Excel export input (`AggregateExcelTableDto`). The server writes the legacy MakeExcel layout
|
||||
* from the legacy report body: one object per row with the same keys, header and merged cells as
|
||||
* `"text|rowSpan|colSpan"` (empty span = 1), cells covered by a merge as `""`, and the remaining
|
||||
* cells as their value: N as count text (written "(n)"), percentages and statistics as unrounded
|
||||
* numbers with a dot (numeric cells formatted 0.0, Mean 0.00), labels as text.
|
||||
*/
|
||||
export type ExcelTable = {
|
||||
head: string;
|
||||
vname: string;
|
||||
qtype: string;
|
||||
body: Record<string, string>[];
|
||||
imagePng?: string;
|
||||
};
|
||||
export type ExcelRow = Record<string, string>;
|
||||
|
||||
/** Legacy Report.cs span text: 1 is written as an empty span. */
|
||||
const span = (value: number | undefined) => (value && value > 1 ? String(value) : "");
|
||||
const anchor = (text: string, rowSpan?: number, colSpan?: number) =>
|
||||
text + "|" + span(rowSpan) + "|" + span(colSpan);
|
||||
|
||||
const columnKey = (index: number) => "c" + index;
|
||||
|
||||
/** Places cells on a full grid so every row has the same keys; merged-over cells stay "". */
|
||||
function grid(rows: { cells: { columnIndex: number }[] }[], width: number, text: (row: number, cell: number) => string): ExcelRow[] {
|
||||
return rows.map((row, rowIndex) => {
|
||||
const values: ExcelRow = {};
|
||||
for (let column = 0; column < width; column++) values[columnKey(column)] = "";
|
||||
row.cells.forEach((cell, cellIndex) => {
|
||||
values[columnKey(cell.columnIndex)] = text(rowIndex, cellIndex);
|
||||
});
|
||||
return values;
|
||||
});
|
||||
}
|
||||
|
||||
const tableWidth = (rows: { cells: { columnIndex: number; colSpan?: number }[] }[]) =>
|
||||
Math.max(
|
||||
0,
|
||||
...rows.flatMap((row) => row.cells.map((cell) => cell.columnIndex + (cell.colSpan ?? 1))),
|
||||
);
|
||||
|
||||
/**
|
||||
* Number text that always has a decimal point, so the server writes a numeric cell (formatted
|
||||
* 0.0, Mean 0.00) instead of the "(n)" count text; legacy sent "100.0" for whole percentages.
|
||||
*/
|
||||
export function pointedNumber(value: number): string {
|
||||
let text = String(value);
|
||||
if (/e/i.test(text)) text = value.toFixed(14).replace(/0+$/, "");
|
||||
if (text.endsWith(".")) text += "0";
|
||||
return text.includes(".") ? text : text + ".0";
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel value of one result cell. The base (N) line keeps the count text; percentages and
|
||||
* statistics use the unrounded server values (legacy kept full precision and only formatted the
|
||||
* cell), falling back to the screen text when an older server omits them.
|
||||
*/
|
||||
function excelText(cell: ReportCell, row: ReportRow, result: ReportResult): string {
|
||||
if (cell.kind === "TEXT") return cell.textValue ?? "";
|
||||
const columnKind = result.columns[cell.columnIndex]?.kind;
|
||||
const transposed = isTransposed(result);
|
||||
const shown = legacyCellText(cell, row.kind, columnKind, transposed);
|
||||
if (cell.kind === "EMPTY") return shown;
|
||||
if (cell.kind === "STATISTIC" || cell.kind === "MISSING")
|
||||
return cell.statisticExact == null ? shown : pointedNumber(cell.statisticExact);
|
||||
if ((transposed ? columnKind : row.kind) === "TOTAL") return shown;
|
||||
return cell.percentExact == null ? shown : pointedNumber(cell.percentExact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy table body for an ordinary result. Header rows are all anchors (like setHeader); body
|
||||
* cells are anchors only when they merge, otherwise the plain displayed text (labels included).
|
||||
* Null when the result has no rows to export.
|
||||
*/
|
||||
export function reportExcelBody(result: ReportResult): ExcelRow[] | null {
|
||||
if (result.type === "TEXT_ANALYSIS") return wordExcelBody(result);
|
||||
const rows = [...result.headerRows, ...result.rows];
|
||||
const width = tableWidth(rows);
|
||||
if (rows.length < 2 || width < 2) return null;
|
||||
const headerCount = result.headerRows.length;
|
||||
return grid(rows, width, (rowIndex, cellIndex) => {
|
||||
const row = rows[rowIndex];
|
||||
const cell = row.cells[cellIndex];
|
||||
const text = excelText(cell, row, result);
|
||||
return rowIndex < headerCount || (cell.rowSpan ?? 1) > 1 || (cell.colSpan ?? 1) > 1
|
||||
? anchor(text, cell.rowSpan, cell.colSpan)
|
||||
: text;
|
||||
});
|
||||
}
|
||||
|
||||
/** Legacy NLP getWordTag: a "Text / Count" row, then the top 100 words. */
|
||||
export function wordExcelBody(result: ReportResult): ExcelRow[] | null {
|
||||
if (!result.words.length) return null;
|
||||
return [
|
||||
{ Text: "Text", Count: "Count" },
|
||||
...result.words.slice(0, 100).map((word) => ({ Text: word.text, Count: String(word.count) })),
|
||||
];
|
||||
}
|
||||
|
||||
/** Legacy quota cell "complete/target/percent"; the server keeps "complete/target". */
|
||||
const quotaText = (cell: QuotaCell) =>
|
||||
(cell.complete ?? 0) + "/" + (cell.target ?? 0) + "/" + (cell.achievementDisplayText ?? "-");
|
||||
|
||||
export function quotaExcelBody(result: QuotaResult): ExcelRow[] | null {
|
||||
const rows = [...result.headerRows, ...result.rows];
|
||||
const width = tableWidth(rows);
|
||||
if (rows.length < 2 || width < 2) return null;
|
||||
const headerCount = result.headerRows.length;
|
||||
return grid(rows, width, (rowIndex, cellIndex) => {
|
||||
if (rowIndex < headerCount) {
|
||||
const cell = result.headerRows[rowIndex].cells[cellIndex];
|
||||
return anchor(cell.textValue ?? "", cell.rowSpan, cell.colSpan);
|
||||
}
|
||||
const cell = result.rows[rowIndex - headerCount].cells[cellIndex];
|
||||
return cell.kind === "QUOTA" ? quotaText(cell) : (cell.textValue ?? "");
|
||||
});
|
||||
}
|
||||
20
src/lib/report-navigation.ts
Normal file
20
src/lib/report-navigation.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { Route } from "next";
|
||||
|
||||
export function isProjectPage(path: string): boolean {
|
||||
return [
|
||||
"/Report/Current",
|
||||
"/Report/Quota",
|
||||
"/Report/Tabulation",
|
||||
"/Report/Crosstab",
|
||||
"/Management/Derived",
|
||||
"/Management/Exim",
|
||||
].includes(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Project pages carry no project in the address (legacy KART kept it in client state); the
|
||||
* selected project lives in useSelectedProject. Other paths open the progress page.
|
||||
*/
|
||||
export function projectPagePath(path: string): Route {
|
||||
return (isProjectPage(path) ? path : "/Report/Current") as Route;
|
||||
}
|
||||
80
src/lib/report-stream.ts
Normal file
80
src/lib/report-stream.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { readReportEvent } from "@/lib/report-contract";
|
||||
import type { ReportEvent } from "@/types/report";
|
||||
|
||||
/** Domain NDJSON framing; shared @kri/common owns HTTP, abort and transport timeouts. */
|
||||
export async function consumeReportStream(
|
||||
body: ReadableStream<Uint8Array> | null,
|
||||
indexes: string[],
|
||||
onEvent: (event: ReportEvent) => void,
|
||||
signal?: AbortSignal,
|
||||
): Promise<void> {
|
||||
if (!body) throw new Error("집계 스트림이 비어 있습니다.");
|
||||
const reader = body.getReader();
|
||||
const decoder = new TextDecoder("utf-8", { fatal: true });
|
||||
let pending = "",
|
||||
position = 0,
|
||||
succeeded = 0,
|
||||
failed = 0,
|
||||
complete = false,
|
||||
ended = false;
|
||||
const abort = () => {
|
||||
void reader.cancel().catch(() => undefined);
|
||||
};
|
||||
signal?.addEventListener("abort", abort, { once: true });
|
||||
const checkAbort = () => {
|
||||
if (signal?.aborted)
|
||||
throw new DOMException("집계를 중단했습니다.", "AbortError");
|
||||
};
|
||||
const line = (text: string) => {
|
||||
if (!text.trim()) return;
|
||||
if (complete)
|
||||
throw new Error("완료 이벤트 뒤에 추가 집계 결과가 있습니다.");
|
||||
const event = readReportEvent(JSON.parse(text));
|
||||
if (event.type === "complete") {
|
||||
if (
|
||||
position !== indexes.length ||
|
||||
event.total !== indexes.length ||
|
||||
event.succeeded !== succeeded ||
|
||||
event.failed !== failed
|
||||
)
|
||||
throw new Error("집계 완료 건수가 일치하지 않습니다.");
|
||||
complete = true;
|
||||
} else {
|
||||
if (event.position !== position || event.index !== indexes[position])
|
||||
throw new Error("집계 결과의 문항 순서가 일치하지 않습니다.");
|
||||
position++;
|
||||
if (event.type === "result") succeeded++;
|
||||
else failed++;
|
||||
}
|
||||
onEvent(event);
|
||||
};
|
||||
try {
|
||||
for (;;) {
|
||||
checkAbort();
|
||||
const chunk = await reader.read();
|
||||
checkAbort();
|
||||
if (chunk.done) {
|
||||
ended = true;
|
||||
pending += decoder.decode();
|
||||
break;
|
||||
}
|
||||
pending += decoder.decode(chunk.value, { stream: true });
|
||||
let boundary;
|
||||
while ((boundary = pending.indexOf("\n")) >= 0) {
|
||||
line(pending.slice(0, boundary));
|
||||
pending = pending.slice(boundary + 1);
|
||||
}
|
||||
if (pending.length > 64 * 1024 * 1024)
|
||||
throw new Error(
|
||||
"한 문항의 집계 결과가 너무 큽니다. 배너 수를 줄여 주세요.",
|
||||
);
|
||||
}
|
||||
if (pending.trim()) line(pending);
|
||||
if (!complete)
|
||||
throw new Error("집계가 완료되기 전에 연결이 종료되었습니다.");
|
||||
} finally {
|
||||
signal?.removeEventListener("abort", abort);
|
||||
if (!ended) await reader.cancel().catch(() => undefined);
|
||||
reader.releaseLock();
|
||||
}
|
||||
}
|
||||
59
src/lib/report-ui.ts
Normal file
59
src/lib/report-ui.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { isRecord } from "@/types/kart";
|
||||
import type { Question, ReportCell, ReportResult } from "@/types/report";
|
||||
|
||||
/** Legacy VIEWTITLE: "VARIABLE. EXPLAIN" (falls back to QID / TITLE). May contain HTML. */
|
||||
export function questionViewTitle(question: Question): string {
|
||||
return (
|
||||
(question.variable || question.qid) +
|
||||
". " +
|
||||
(question.explain || question.title || "")
|
||||
);
|
||||
}
|
||||
|
||||
/** Legacy result heading (EXPLAIN). May contain HTML. */
|
||||
export function questionHead(question: Question): string {
|
||||
return question.explain || question.title || question.variable || question.qid;
|
||||
}
|
||||
|
||||
export const isDerivedQuestion = (question: Question) =>
|
||||
question.isDerived !== "0";
|
||||
|
||||
/**
|
||||
* Legacy ChildBox checkLoc: text/numeric questions, attribute roots and vtype 2/3 can be
|
||||
* aggregated as a table ("row") but never used as a banner ("all" allows both).
|
||||
*/
|
||||
export function dragLocation(question: Question): "row" | "all" {
|
||||
const vtype = question.vtype ?? "";
|
||||
return question.qtype === "text" ||
|
||||
question.qtype === "num" ||
|
||||
(vtype === "attr" && !question.qid.includes("_")) ||
|
||||
vtype === "2" ||
|
||||
vtype === "3"
|
||||
? "row"
|
||||
: "all";
|
||||
}
|
||||
|
||||
/** True when the server applied 세로 테이블 (transpose) to this result. */
|
||||
export const isTransposed = (result: ReportResult) =>
|
||||
isRecord(result.appliedOptions) && result.appliedOptions.transpose === true;
|
||||
|
||||
/**
|
||||
* Legacy default PRTMODE: ordinary cells show the server percent text, the 사례수 (base) line
|
||||
* shows N. The base line is the TOTAL row, or the TOTAL column when the table is transposed.
|
||||
* Values are the server's display strings; nothing is re-rounded here.
|
||||
*/
|
||||
export function legacyCellText(
|
||||
cell: ReportCell,
|
||||
rowKind: string,
|
||||
columnKind = "",
|
||||
transposed = false,
|
||||
): string {
|
||||
if (cell.kind === "TEXT" || cell.kind === "EMPTY") return cell.textValue ?? "";
|
||||
if (cell.kind === "STATISTIC" || cell.kind === "MISSING")
|
||||
return cell.statisticDisplayText ?? "";
|
||||
if ((transposed ? columnKind : rowKind) === "TOTAL")
|
||||
return cell.countDisplayText ?? (cell.count == null ? "" : String(cell.count));
|
||||
return (
|
||||
cell.percentDisplayText ?? (cell.percent == null ? "" : String(cell.percent))
|
||||
);
|
||||
}
|
||||
@@ -1,40 +1,49 @@
|
||||
"use client";
|
||||
|
||||
import type { LoginRequest, LoginUser } from "@kri/common";
|
||||
import type { LoginRequest } from "@kri/common";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { isLoginUser } from "@/types/kart";
|
||||
|
||||
export function useLoginMutation() {
|
||||
const { setFromLoginResponse } = useAuth();
|
||||
const setSelectedProject = useSetAtom(selectedProjectAtom);
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (request: LoginRequest) => nextApi.post<LoginUser>("/login", request, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
}),
|
||||
onSuccess: setFromLoginResponse,
|
||||
mutationFn: async (request: LoginRequest) => {
|
||||
const user = await nextApi.post<unknown>("/login", request, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
});
|
||||
if (!isLoginUser(user)) throw new Error("로그인 응답을 확인해 주세요.");
|
||||
return user;
|
||||
},
|
||||
onSuccess: (user) => {
|
||||
queryClient.clear();
|
||||
// Legacy Login.js starts every session without a selected project.
|
||||
setSelectedProject(null);
|
||||
setFromLoginResponse(user);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useLogoutMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
const { auth, logout } = useAuth();
|
||||
const { logout } = useAuth();
|
||||
const setSelectedProject = useSetAtom(selectedProjectAtom);
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
const suffix = auth.user?.userId ? `/${encodeURIComponent(auth.user.userId)}` : "";
|
||||
try {
|
||||
await nextApi.post(`/logout${suffix}`, null, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
mutationFn: () =>
|
||||
nextApi.post("/logout", null, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
}),
|
||||
onSettled: () => {
|
||||
logout();
|
||||
setSelectedProject(null);
|
||||
queryClient.clear();
|
||||
},
|
||||
});
|
||||
|
||||
71
src/query/bookmark.ts
Normal file
71
src/query/bookmark.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { queryKeys } from "@/query/key/keys";
|
||||
import { isRecord, type ProjectRef } from "@/types/kart";
|
||||
import {
|
||||
readBookmarks,
|
||||
type BookmarkPage,
|
||||
type BookmarkSaveRequest,
|
||||
} from "@/types/bookmark";
|
||||
|
||||
const bookmarkPath = (project: ProjectRef) =>
|
||||
"/bookmark/" + project.projectType + "/" + encodeURIComponent(project.pkey);
|
||||
|
||||
export function useBookmarkListQuery(project: ProjectRef, page: BookmarkPage) {
|
||||
const { auth, hydrated } = useAuth();
|
||||
return useQuery({
|
||||
queryKey: queryKeys.bookmark.list(auth.user, project, page),
|
||||
queryFn: async () =>
|
||||
readBookmarks(
|
||||
await nextApi.get<unknown>(bookmarkPath(project) + "/list", { query: { page } }),
|
||||
),
|
||||
enabled: hydrated && !!auth.user,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export type BookmarkSave = {
|
||||
/** Null creates a new bookmark (Save on "New" and Save as). */
|
||||
bookmarkId: string | null;
|
||||
request: Omit<BookmarkSaveRequest, "bookmarkPage">;
|
||||
};
|
||||
|
||||
/** Save / Save as / Delete; every change reloads the tab list like the legacy popup close. */
|
||||
export function useBookmarkMutations(project: ProjectRef, page: BookmarkPage) {
|
||||
const { auth } = useAuth();
|
||||
const queryClient = useQueryClient();
|
||||
const onSuccess = () =>
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.bookmark.list(auth.user, project, page),
|
||||
});
|
||||
const save = useMutation({
|
||||
mutationFn: async ({ bookmarkId, request }: BookmarkSave) => {
|
||||
const result = bookmarkId
|
||||
? await nextApi.put<unknown>(
|
||||
bookmarkPath(project) + "/" + encodeURIComponent(bookmarkId),
|
||||
request,
|
||||
)
|
||||
: await nextApi.post<unknown>(bookmarkPath(project), {
|
||||
...request,
|
||||
bookmarkPage: page,
|
||||
} satisfies BookmarkSaveRequest);
|
||||
if (!isRecord(result) || typeof result.bookmarkId !== "string" || !result.bookmarkId)
|
||||
throw new Error("북마크 저장 응답을 확인해 주세요.");
|
||||
return result.bookmarkId;
|
||||
},
|
||||
onSuccess,
|
||||
});
|
||||
const remove = useMutation({
|
||||
mutationFn: async (bookmarkId: string) => {
|
||||
const result = await nextApi.del<unknown>(
|
||||
bookmarkPath(project) + "/" + encodeURIComponent(bookmarkId),
|
||||
);
|
||||
if (result !== true) throw new Error("북마크를 삭제하지 못했습니다.");
|
||||
},
|
||||
onSuccess,
|
||||
});
|
||||
return { save, remove };
|
||||
}
|
||||
68
src/query/derived.ts
Normal file
68
src/query/derived.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { queryKeys } from "@/query/key/keys";
|
||||
import { isRecord, type ProjectRef } from "@/types/kart";
|
||||
import { readDerivedVariables, type DerivedSaveRequest } from "@/types/derived";
|
||||
|
||||
const derivedPath = (project: ProjectRef) =>
|
||||
"/derived/" + project.projectType + "/" + encodeURIComponent(project.pkey);
|
||||
|
||||
// Saving recalculates the variable for every respondent; allow the server time to finish.
|
||||
const SAVE_TIMEOUT_MS = 600_000;
|
||||
|
||||
export function useDerivedListQuery(project: ProjectRef) {
|
||||
const { auth, hydrated } = useAuth();
|
||||
return useQuery({
|
||||
queryKey: queryKeys.derived.list(auth.user, project),
|
||||
queryFn: async () =>
|
||||
readDerivedVariables(await nextApi.get<unknown>(derivedPath(project) + "/list")),
|
||||
enabled: hydrated && !!auth.user,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export type DerivedSave = {
|
||||
/** Stored id being edited; null creates (Save on a new variable and Save As). */
|
||||
originId: string | null;
|
||||
request: DerivedSaveRequest;
|
||||
};
|
||||
|
||||
/** Save / Save As / Delete; each change reloads the variable list and the report question list. */
|
||||
export function useDerivedMutations(project: ProjectRef) {
|
||||
const { auth } = useAuth();
|
||||
const queryClient = useQueryClient();
|
||||
const onSuccess = () =>
|
||||
Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.derived.list(auth.user, project) }),
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.report.question(auth.user, project) }),
|
||||
]);
|
||||
const save = useMutation({
|
||||
mutationFn: async ({ originId, request }: DerivedSave) => {
|
||||
const options = { timeoutMs: SAVE_TIMEOUT_MS };
|
||||
const result = originId
|
||||
? await nextApi.put<unknown>(
|
||||
derivedPath(project) + "/" + encodeURIComponent(originId),
|
||||
request,
|
||||
options,
|
||||
)
|
||||
: await nextApi.post<unknown>(derivedPath(project), request, options);
|
||||
if (!isRecord(result) || typeof result.variableId !== "string" || !result.variableId)
|
||||
throw new Error("파생변수 저장 응답을 확인해 주세요.");
|
||||
return result.variableId;
|
||||
},
|
||||
onSuccess,
|
||||
});
|
||||
const remove = useMutation({
|
||||
mutationFn: async (variableId: string) => {
|
||||
const result = await nextApi.del<unknown>(
|
||||
derivedPath(project) + "/" + encodeURIComponent(variableId),
|
||||
);
|
||||
if (result !== true) throw new Error("파생변수를 삭제하지 못했습니다.");
|
||||
},
|
||||
onSuccess,
|
||||
});
|
||||
return { save, remove };
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user