@@ -0,0 +1,151 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* InlineComboboxField — Pane 4 編集 UI の「検索 + 選択 + 新規追加」プリミティブ。
|
||||
*
|
||||
* shadcn 公式 Combobox パターン:
|
||||
* - `<Popover>` + `<Command>` の組み合わせ
|
||||
* - 各オプションに `value`(ラベル)と `description`(説明)を持つ
|
||||
* - CommandInput で検索(`shouldFilter` ON)
|
||||
* - 検索クエリにマッチがない場合は「+ 「X」を追加」ボタンで新規オプション作成可
|
||||
* - トリガーの chrome は他フィールドと統一(border-input + bg-card)
|
||||
* - 選択中アイテムは `data-checked` で shadcn 標準の CheckIcon を表示
|
||||
*
|
||||
* 雛形では「応募経路」(Wantedly / LinkedIn / 社員リファラル / 直接応募 / etc.)で再利用。
|
||||
* オプション集合は外部 state で管理し、`onCreate` を経由して追加する。
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { ChevronDown, Plus } from "lucide-react";
|
||||
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
CommandGroup,
|
||||
CommandInput,
|
||||
CommandItem,
|
||||
CommandList,
|
||||
} from "@/components/ui/command";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
|
||||
/** Combobox の選択肢。`value` は ID 兼ラベル、`description` は補助説明。 */
|
||||
export type ComboOption = {
|
||||
value: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export type InlineComboboxFieldProps = {
|
||||
/** 現在選択中の値(`options[].value` のいずれか、または空文字) */
|
||||
value: string;
|
||||
/** 選択肢リスト(順序が表示順) */
|
||||
options: ComboOption[];
|
||||
/** 選択時に呼ばれる */
|
||||
onSave: (v: string) => void;
|
||||
/** 「+ 追加」が押されたときに呼ばれる。新オプション追加 + 選択は呼び出し側の責務 */
|
||||
onCreate: (newOpt: ComboOption) => void;
|
||||
/** スクリーンリーダー向けラベル */
|
||||
ariaLabel: string;
|
||||
/** トリガーの空表示 placeholder。デフォルト "選択..." */
|
||||
placeholder?: string;
|
||||
/** Command 検索 input の placeholder。デフォルト "検索または追加..." */
|
||||
searchPlaceholder?: string;
|
||||
};
|
||||
|
||||
export function InlineComboboxField({
|
||||
value,
|
||||
options,
|
||||
onSave,
|
||||
onCreate,
|
||||
ariaLabel,
|
||||
placeholder = "選択...",
|
||||
searchPlaceholder = "検索または追加...",
|
||||
}: InlineComboboxFieldProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [query, setQuery] = useState("");
|
||||
|
||||
const trimmed = query.trim();
|
||||
const exactMatch = options.find((o) => o.value === trimmed);
|
||||
const showCreate = trimmed !== "" && !exactMatch;
|
||||
|
||||
const handleCreate = () => {
|
||||
const newOpt: ComboOption = {
|
||||
value: trimmed,
|
||||
description: "(新規追加)",
|
||||
};
|
||||
onCreate(newOpt);
|
||||
onSave(newOpt.value);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
open={open}
|
||||
onOpenChange={(o) => {
|
||||
setOpen(o);
|
||||
if (!o) setQuery("");
|
||||
}}
|
||||
>
|
||||
<PopoverTrigger
|
||||
aria-label={ariaLabel}
|
||||
className="flex h-8 w-full items-center justify-between gap-2 rounded-lg border border-input bg-card px-2.5 py-1 text-left text-sm text-foreground transition-colors outline-none hover:bg-accent/40 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-popup-open:border-ring data-popup-open:ring-3 data-popup-open:ring-ring/50"
|
||||
>
|
||||
<span className="truncate">
|
||||
{value || (
|
||||
<span className="text-muted-foreground">{placeholder}</span>
|
||||
)}
|
||||
</span>
|
||||
<ChevronDown className="size-4 shrink-0 text-muted-foreground" />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="w-72 p-0">
|
||||
<Command shouldFilter>
|
||||
<CommandInput
|
||||
value={query}
|
||||
onValueChange={setQuery}
|
||||
placeholder={searchPlaceholder}
|
||||
/>
|
||||
<CommandList>
|
||||
<CommandEmpty className="p-1">
|
||||
{showCreate ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleCreate}
|
||||
className="flex w-full items-center gap-2 rounded-sm px-2 py-2 text-left text-sm text-primary hover:bg-muted"
|
||||
>
|
||||
<Plus className="size-4" />「{trimmed}」を追加
|
||||
</button>
|
||||
) : (
|
||||
<span className="block py-3 text-center text-sm text-muted-foreground">
|
||||
候補なし
|
||||
</span>
|
||||
)}
|
||||
</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{options.map((opt) => (
|
||||
<CommandItem
|
||||
key={opt.value}
|
||||
value={opt.value}
|
||||
data-checked={value === opt.value || undefined}
|
||||
onSelect={() => {
|
||||
onSave(opt.value);
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||||
<span className="truncate font-medium">{opt.value}</span>
|
||||
<span className="truncate text-xs text-muted-foreground group-data-selected/command-item:text-foreground/70">
|
||||
{opt.description}
|
||||
</span>
|
||||
</div>
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* InlineDateField — Pane 4 編集 UI の「日付 input」プリミティブ。
|
||||
*
|
||||
* shadcn 公式 Date Picker パターンに完全準拠:
|
||||
* - `<Popover>` + `<Calendar>` の組み合わせ
|
||||
* - 📅 アイコンを **左** に配置(shadcn 公式サンプルと同じ)
|
||||
* - トリガーの chrome は `<Input>` フィールドに揃える(border-input + bg-card)
|
||||
* ※ Button variant ではなく Input 風にする理由:
|
||||
* Pane 4 内の他フィールドと「箱」の濃淡を揃え、視覚的に浮かないようにする
|
||||
* - 値が空のときは「日付を選択」(shadcn "Pick a date" の翻訳)
|
||||
* - 日付の保存形式は ANSI / ISO 8601(YYYY-MM-DD)
|
||||
* - 月・年はドロップダウン(captionLayout="dropdown")。1925〜2050 の範囲で
|
||||
* 生年月日(過去)から入社可能日(未来)まで網羅する
|
||||
*
|
||||
* ADR-0014 で chromeless inline edit から shadcn 標準フォームへ転換した結果として
|
||||
* `components/primitives/` に切り出された再利用可能なプリミティブ。
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { Calendar as CalendarIcon } from "lucide-react";
|
||||
|
||||
import { Calendar } from "@/components/ui/calendar";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { formatISODate, parseISODate } from "@/lib/computed/profile";
|
||||
|
||||
export type InlineDateFieldProps = {
|
||||
/** ISO 8601 (YYYY-MM-DD) 形式の文字列。空で「日付を選択」placeholder */
|
||||
value: string;
|
||||
/** 値が変わったとき呼ばれる(ISO 8601 文字列を渡す) */
|
||||
onSave: (v: string) => void;
|
||||
/** スクリーンリーダー向けラベル */
|
||||
ariaLabel: string;
|
||||
};
|
||||
|
||||
export function InlineDateField({
|
||||
value,
|
||||
onSave,
|
||||
ariaLabel,
|
||||
}: InlineDateFieldProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const selected = parseISODate(value);
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger
|
||||
aria-label={ariaLabel}
|
||||
className="flex h-8 w-full items-center justify-start gap-2 rounded-lg border border-input bg-card px-2.5 py-1 text-left text-sm text-foreground transition-colors outline-none hover:bg-accent/40 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-popup-open:border-ring data-popup-open:ring-3 data-popup-open:ring-ring/50"
|
||||
>
|
||||
<CalendarIcon className="size-4 shrink-0 text-muted-foreground" />
|
||||
<span
|
||||
className={
|
||||
value
|
||||
? "truncate text-foreground"
|
||||
: "truncate text-muted-foreground"
|
||||
}
|
||||
>
|
||||
{value || "日付を選択"}
|
||||
</span>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="w-auto p-0">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={selected}
|
||||
onSelect={(d) => {
|
||||
const next = formatISODate(d);
|
||||
if (next !== value) onSave(next);
|
||||
setOpen(false);
|
||||
}}
|
||||
captionLayout="dropdown"
|
||||
startMonth={new Date(1925, 0)}
|
||||
endMonth={new Date(2050, 11)}
|
||||
defaultMonth={selected ?? new Date()}
|
||||
autoFocus
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* InlineFieldRow — ラベル + 値の縦積み行プリミティブ。
|
||||
*
|
||||
* Pane 3 / Pane 4 のフォーム系セクションで「ラベル + Inline*Field」を
|
||||
* 並べる用途で再利用する MUST。dl/dt/dd セマンティクスで a11y を確保。
|
||||
*
|
||||
* 利用例:
|
||||
* <dl className="flex flex-col gap-2.5 text-sm">
|
||||
* <InlineFieldRow label="名前">
|
||||
* <InlineTextField value={name} onSave={...} ariaLabel="名前" />
|
||||
* </InlineFieldRow>
|
||||
* <InlineFieldRow label="生年月日">
|
||||
* <InlineDateField value={birthday} onSave={...} ariaLabel="生年月日" />
|
||||
* </InlineFieldRow>
|
||||
* </dl>
|
||||
*
|
||||
* 雛形では Pane 3 ヘッダー帯トグル内の「応募情報」/「連絡先」、
|
||||
* 採用条件カード、Pane 4 モード 2「基本情報」で使う。
|
||||
*/
|
||||
|
||||
export type InlineFieldRowProps = {
|
||||
/** ラベルテキスト */
|
||||
label: string;
|
||||
/** 値(Inline*Field など) */
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export function InlineFieldRow({ label, children }: InlineFieldRowProps) {
|
||||
return (
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<dt className="text-sm text-muted-foreground">{label}</dt>
|
||||
<dd className="min-w-0">{children}</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* InlineSelectField — Pane 4 編集 UI の「固定リスト Select」プリミティブ。
|
||||
*
|
||||
* shadcn `<Select>` をラップし、ComboOption ベースの `<InlineComboboxField>` よりも
|
||||
* 軽量な「固定 N 択」の場面で使う:
|
||||
* - `string[]` だけ渡せば良い(`{ value, description }` 構造は不要)
|
||||
* - 新規追加機能は持たない(候補者個別に増やす想定がない場合に使う)
|
||||
* - SelectTrigger 素体(`border-input` + `h-8`)に `bg-card` + `w-full` +
|
||||
* `hover:bg-accent/40` を加えて他の InlineXxxField と完全に揃える
|
||||
*
|
||||
* 雛形では「形式(書類 / オンライン / オフライン)」「判定(通過 / 保留 / 不合格)」
|
||||
* のような選考ステージのメタ情報フィールドで再利用される。
|
||||
*/
|
||||
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
export type InlineSelectFieldProps = {
|
||||
/** 現在の値(空文字で placeholder 表示) */
|
||||
value: string;
|
||||
/** 選択肢(順序が表示順、`readonly` 配列も受け取る) */
|
||||
options: readonly string[];
|
||||
/** 選択時に呼ばれる */
|
||||
onSave: (v: string) => void;
|
||||
/** スクリーンリーダー向けラベル */
|
||||
ariaLabel: string;
|
||||
/** 空のときの placeholder。デフォルト "選択..." */
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
export function InlineSelectField({
|
||||
value,
|
||||
options,
|
||||
onSave,
|
||||
ariaLabel,
|
||||
placeholder = "選択...",
|
||||
}: InlineSelectFieldProps) {
|
||||
return (
|
||||
<Select
|
||||
value={value === "" ? undefined : value}
|
||||
onValueChange={(v) => onSave(v ?? "")}
|
||||
>
|
||||
<SelectTrigger
|
||||
aria-label={ariaLabel}
|
||||
className="h-8 w-full bg-card hover:bg-accent/40"
|
||||
>
|
||||
<SelectValue placeholder={placeholder} />
|
||||
</SelectTrigger>
|
||||
<SelectContent align="start">
|
||||
{options.map((opt) => (
|
||||
<SelectItem key={opt} value={opt}>
|
||||
{opt}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* InlineTextField — Pane 4 編集 UI の「1 行 input」プリミティブ。
|
||||
*
|
||||
* shadcn `<Input>` をラップし、Lab v3 で確定した規律で編集体験を統一する:
|
||||
* - 常に `<Input>` 表示(Type-direct、ADR-0014)
|
||||
* - `border-input` + `bg-card` で「手前」感を出し、編集可能と一目で分かる
|
||||
* - 保存: blur / Enter(値が変わっていれば onSave)
|
||||
* - キャンセル: Esc で defaultValue に戻して blur
|
||||
*
|
||||
* ADR-0014 で旧 ADR-0010 §6 D R5「shadcn Input MUST 禁止」を撤回。
|
||||
* 雛形では候補者の「氏名・採用担当・連絡先・希望年収(min/max)」等で再利用。
|
||||
*/
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type InlineTextFieldProps = {
|
||||
/** 現在の値(空文字で「未設定」placeholder 表示) */
|
||||
value: string;
|
||||
/** 値が変わって blur した時に呼ばれる */
|
||||
onSave: (v: string) => void;
|
||||
/** スクリーンリーダー向けラベル */
|
||||
ariaLabel: string;
|
||||
/** input の type 属性(`text` / `email` / `tel` / `number`) */
|
||||
inputType?: "text" | "email" | "tel" | "number";
|
||||
/** 空のときの placeholder。デフォルト "未設定" */
|
||||
placeholder?: string;
|
||||
/** className override(width 制限などに使う) */
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function InlineTextField({
|
||||
value,
|
||||
onSave,
|
||||
ariaLabel,
|
||||
inputType = "text",
|
||||
placeholder,
|
||||
className,
|
||||
}: InlineTextFieldProps) {
|
||||
return (
|
||||
<Input
|
||||
type={inputType}
|
||||
defaultValue={value}
|
||||
placeholder={placeholder ?? "未設定"}
|
||||
aria-label={ariaLabel}
|
||||
onBlur={(e) => {
|
||||
if (e.target.value !== value) onSave(e.target.value);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
(e.target as HTMLInputElement).blur();
|
||||
} else if (e.key === "Escape") {
|
||||
(e.target as HTMLInputElement).value = value;
|
||||
(e.target as HTMLInputElement).blur();
|
||||
}
|
||||
}}
|
||||
className={cn("h-8 bg-card", className)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* InlineTextareaField — Pane 4 編集 UI の「複数行 textarea」プリミティブ。
|
||||
*
|
||||
* shadcn `<Textarea>` をラップし、Lab v3 で確定した規律で編集体験を統一する:
|
||||
* - 常に `<Textarea>` 表示(Type-direct、ADR-0014)
|
||||
* - `bg-card` で周囲(bg-background)より明るく「手前」感を出す
|
||||
* - `field-sizing: content`(Tailwind v4 / shadcn v4 の textarea デフォルト)で内容に応じて自動リサイズ
|
||||
* - 保存: blur で onSave 発火(値が変わっていれば)。Cmd+Enter で blur
|
||||
* - キャンセル: Esc で defaultValue に戻して blur
|
||||
*
|
||||
* 雛形では「職務経歴」「志望動機」のような長文項目で再利用。
|
||||
*/
|
||||
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
|
||||
export type InlineTextareaFieldProps = {
|
||||
/** 現在の値(空文字で「未設定」placeholder 表示) */
|
||||
value: string;
|
||||
/** 値が変わって blur した時に呼ばれる */
|
||||
onSave: (v: string) => void;
|
||||
/** スクリーンリーダー向けラベル */
|
||||
ariaLabel: string;
|
||||
/** 空のときの placeholder。デフォルト "未設定" */
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
export function InlineTextareaField({
|
||||
value,
|
||||
onSave,
|
||||
ariaLabel,
|
||||
placeholder,
|
||||
}: InlineTextareaFieldProps) {
|
||||
return (
|
||||
<Textarea
|
||||
defaultValue={value}
|
||||
placeholder={placeholder ?? "未設定"}
|
||||
aria-label={ariaLabel}
|
||||
onBlur={(e) => {
|
||||
if (e.target.value !== value) onSave(e.target.value);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
||||
(e.target as HTMLTextAreaElement).blur();
|
||||
} else if (e.key === "Escape") {
|
||||
(e.target as HTMLTextAreaElement).value = value;
|
||||
(e.target as HTMLTextAreaElement).blur();
|
||||
}
|
||||
}}
|
||||
className="min-h-24 bg-card leading-relaxed whitespace-pre-line"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* ScoreLabel — 候補者の代表平均スコアを「★ 4.3」形式で表示する読み取り専用ラベル。
|
||||
*
|
||||
* Pane 3 ヘッダー帯(閉時)で名前の隣にサブテキストとして配置し、
|
||||
* 採用担当者が「この候補者は採る価値があるか」を 5 秒で判断する材料となる。
|
||||
*
|
||||
* 計算は `getCandidateAverageScore()` の派生値(最新 done scorecard の axisScores 平均)。
|
||||
* null(未評価)のときは `★ —` を表示する。
|
||||
*
|
||||
* クリック動作は持たない(ADR-0015 §19 大決定 L: スコアは読み取り専用ラベル)。
|
||||
* 4 軸の内訳が見たければ、選考フローカードから Pane 4 モード 2 へジャンプする。
|
||||
*/
|
||||
|
||||
import { Star } from "lucide-react";
|
||||
|
||||
export type ScoreLabelProps = {
|
||||
/** 平均スコア(null = 未評価) */
|
||||
value: number | null;
|
||||
};
|
||||
|
||||
export function ScoreLabel({ value }: ScoreLabelProps) {
|
||||
const displayValue = value !== null ? value.toFixed(1) : "—";
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center gap-1 text-sm text-muted-foreground tabular-nums"
|
||||
aria-label={
|
||||
value !== null ? `評価平均 ${displayValue} 点` : "評価平均 未評価"
|
||||
}
|
||||
>
|
||||
<Star className="size-3 fill-primary text-primary" aria-hidden="true" />
|
||||
{displayValue}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import React from "react";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const sectionLabelVariants = cva(
|
||||
"text-sm font-semibold uppercase tracking-wide text-muted-foreground",
|
||||
{
|
||||
variants: {
|
||||
tone: {
|
||||
default: "",
|
||||
sidebar: "text-sidebar-foreground/70",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
tone: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
function SectionLabel({
|
||||
className,
|
||||
tone = "default",
|
||||
...props
|
||||
}: React.ComponentProps<"h2"> & VariantProps<typeof sectionLabelVariants>) {
|
||||
return (
|
||||
<h2 className={cn(sectionLabelVariants({ tone }), className)} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export { SectionLabel, sectionLabelVariants };
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Pane 4 編集 UI 用の inline 編集プリミティブ群(shadcn 標準フォームベース)。
|
||||
*
|
||||
* ADR-0014「shadcn 標準フォームによる Pane 4 編集 UI」で確定:
|
||||
* - 旧 ADR-0010 §6 D R5「shadcn Input/Textarea MUST 禁止」を撤回
|
||||
* - 鉛筆アイコン式・編集ボタン式は引き続き禁止(ADR-0014 で明文化)
|
||||
* - 全フィールドが常に shadcn の Input / Textarea / Calendar / Combobox で表示される
|
||||
*
|
||||
* 利用例:
|
||||
* import { InlineTextField } from "@/components/primitives";
|
||||
* <InlineTextField value={...} onSave={...} ariaLabel="..." />
|
||||
*/
|
||||
|
||||
export { InlineTextField } from "./InlineTextField";
|
||||
export type { InlineTextFieldProps } from "./InlineTextField";
|
||||
|
||||
export { InlineDateField } from "./InlineDateField";
|
||||
export type { InlineDateFieldProps } from "./InlineDateField";
|
||||
|
||||
export { InlineComboboxField } from "./InlineComboboxField";
|
||||
export type {
|
||||
ComboOption,
|
||||
InlineComboboxFieldProps,
|
||||
} from "./InlineComboboxField";
|
||||
|
||||
export { InlineSelectField } from "./InlineSelectField";
|
||||
export type { InlineSelectFieldProps } from "./InlineSelectField";
|
||||
|
||||
export { InlineTextareaField } from "./InlineTextareaField";
|
||||
export type { InlineTextareaFieldProps } from "./InlineTextareaField";
|
||||
|
||||
export { SectionLabel, sectionLabelVariants } from "./SectionLabel";
|
||||
|
||||
export { InlineFieldRow } from "./InlineFieldRow";
|
||||
export type { InlineFieldRowProps } from "./InlineFieldRow";
|
||||
|
||||
export { ScoreLabel } from "./ScoreLabel";
|
||||
export type { ScoreLabelProps } from "./ScoreLabel";
|
||||
@@ -0,0 +1,187 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
|
||||
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
|
||||
}
|
||||
|
||||
function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
|
||||
return (
|
||||
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {
|
||||
return (
|
||||
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogOverlay({
|
||||
className,
|
||||
...props
|
||||
}: AlertDialogPrimitive.Backdrop.Props) {
|
||||
return (
|
||||
<AlertDialogPrimitive.Backdrop
|
||||
data-slot="alert-dialog-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogContent({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: AlertDialogPrimitive.Popup.Props & {
|
||||
size?: "default" | "sm"
|
||||
}) {
|
||||
return (
|
||||
<AlertDialogPortal>
|
||||
<AlertDialogOverlay />
|
||||
<AlertDialogPrimitive.Popup
|
||||
data-slot="alert-dialog-content"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</AlertDialogPortal>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogHeader({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="alert-dialog-header"
|
||||
className={cn(
|
||||
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogFooter({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="alert-dialog-footer"
|
||||
className={cn(
|
||||
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogMedia({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="alert-dialog-media"
|
||||
className={cn(
|
||||
"mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogTitle({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
||||
return (
|
||||
<AlertDialogPrimitive.Title
|
||||
data-slot="alert-dialog-title"
|
||||
className={cn(
|
||||
"font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogDescription({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
||||
return (
|
||||
<AlertDialogPrimitive.Description
|
||||
data-slot="alert-dialog-description"
|
||||
className={cn(
|
||||
"text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogAction({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
return (
|
||||
<Button
|
||||
data-slot="alert-dialog-action"
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDialogCancel({
|
||||
className,
|
||||
variant = "outline",
|
||||
size = "default",
|
||||
...props
|
||||
}: AlertDialogPrimitive.Close.Props &
|
||||
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
||||
return (
|
||||
<AlertDialogPrimitive.Close
|
||||
data-slot="alert-dialog-cancel"
|
||||
className={cn(className)}
|
||||
render={<Button variant={variant} size={size} />}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogMedia,
|
||||
AlertDialogOverlay,
|
||||
AlertDialogPortal,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Avatar({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: AvatarPrimitive.Root.Props & {
|
||||
size?: "default" | "sm" | "lg"
|
||||
}) {
|
||||
return (
|
||||
<AvatarPrimitive.Root
|
||||
data-slot="avatar"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {
|
||||
return (
|
||||
<AvatarPrimitive.Image
|
||||
data-slot="avatar-image"
|
||||
className={cn(
|
||||
"aspect-square size-full rounded-full object-cover",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarFallback({
|
||||
className,
|
||||
...props
|
||||
}: AvatarPrimitive.Fallback.Props) {
|
||||
return (
|
||||
<AvatarPrimitive.Fallback
|
||||
data-slot="avatar-fallback"
|
||||
className={cn(
|
||||
"flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="avatar-badge"
|
||||
className={cn(
|
||||
"absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
|
||||
"group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
|
||||
"group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
|
||||
"group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="avatar-group"
|
||||
className={cn(
|
||||
"group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarGroupCount({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="avatar-group-count"
|
||||
className={cn(
|
||||
"relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarBadge,
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const badgeVariants = cva(
|
||||
"group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent py-0.5 font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
||||
outline:
|
||||
"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-5 px-2 text-xs",
|
||||
xs: "h-4 px-1.5 text-[10px]",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
|
||||
return useRender({
|
||||
defaultTagName: "span",
|
||||
props: mergeProps<"span">(
|
||||
{
|
||||
className: cn(badgeVariants({ variant, size }), className),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "badge",
|
||||
variant,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
@@ -0,0 +1,125 @@
|
||||
import * as React from "react"
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
|
||||
|
||||
function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
|
||||
return (
|
||||
<nav
|
||||
aria-label="breadcrumb"
|
||||
data-slot="breadcrumb"
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
|
||||
return (
|
||||
<ol
|
||||
data-slot="breadcrumb-list"
|
||||
className={cn(
|
||||
"flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="breadcrumb-item"
|
||||
className={cn("inline-flex items-center gap-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbLink({
|
||||
className,
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"a">) {
|
||||
return useRender({
|
||||
defaultTagName: "a",
|
||||
props: mergeProps<"a">(
|
||||
{
|
||||
className: cn("transition-colors hover:text-foreground", className),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "breadcrumb-link",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="breadcrumb-page"
|
||||
role="link"
|
||||
aria-disabled="true"
|
||||
aria-current="page"
|
||||
className={cn("font-normal text-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbSeparator({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="breadcrumb-separator"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn("[&>svg]:size-3.5", className)}
|
||||
{...props}
|
||||
>
|
||||
{children ?? (
|
||||
<ChevronRightIcon />
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbEllipsis({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="breadcrumb-ellipsis"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"flex size-5 items-center justify-center [&>svg]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontalIcon
|
||||
/>
|
||||
<span className="sr-only">More</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Breadcrumb,
|
||||
BreadcrumbList,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbLink,
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
BreadcrumbEllipsis,
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { Button as ButtonPrimitive } from "@base-ui/react/button"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const buttonVariants = cva(
|
||||
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
outline:
|
||||
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default:
|
||||
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
||||
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
||||
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
icon: "size-8",
|
||||
"icon-xs":
|
||||
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
||||
"icon-sm":
|
||||
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
||||
"icon-lg": "size-9",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Button({
|
||||
className,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
...props
|
||||
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
|
||||
return (
|
||||
<ButtonPrimitive
|
||||
data-slot="button"
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Button, buttonVariants }
|
||||
@@ -0,0 +1,221 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
DayPicker,
|
||||
getDefaultClassNames,
|
||||
type DayButton,
|
||||
type Locale,
|
||||
} from "react-day-picker"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button, buttonVariants } from "@/components/ui/button"
|
||||
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
|
||||
|
||||
function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
showOutsideDays = true,
|
||||
captionLayout = "label",
|
||||
buttonVariant = "ghost",
|
||||
locale,
|
||||
formatters,
|
||||
components,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayPicker> & {
|
||||
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
||||
}) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn(
|
||||
"group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
|
||||
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
||||
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
||||
className
|
||||
)}
|
||||
captionLayout={captionLayout}
|
||||
locale={locale}
|
||||
formatters={{
|
||||
formatMonthDropdown: (date) =>
|
||||
date.toLocaleString(locale?.code, { month: "short" }),
|
||||
...formatters,
|
||||
}}
|
||||
classNames={{
|
||||
root: cn("w-fit", defaultClassNames.root),
|
||||
months: cn(
|
||||
"relative flex flex-col gap-4 md:flex-row",
|
||||
defaultClassNames.months
|
||||
),
|
||||
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
||||
nav: cn(
|
||||
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
||||
defaultClassNames.nav
|
||||
),
|
||||
button_previous: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
||||
defaultClassNames.button_previous
|
||||
),
|
||||
button_next: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
||||
defaultClassNames.button_next
|
||||
),
|
||||
month_caption: cn(
|
||||
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
||||
defaultClassNames.month_caption
|
||||
),
|
||||
dropdowns: cn(
|
||||
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
||||
defaultClassNames.dropdowns
|
||||
),
|
||||
dropdown_root: cn(
|
||||
"relative rounded-(--cell-radius)",
|
||||
defaultClassNames.dropdown_root
|
||||
),
|
||||
dropdown: cn(
|
||||
"absolute inset-0 bg-popover opacity-0",
|
||||
defaultClassNames.dropdown
|
||||
),
|
||||
caption_label: cn(
|
||||
"font-medium select-none",
|
||||
captionLayout === "label"
|
||||
? "text-sm"
|
||||
: "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
||||
defaultClassNames.caption_label
|
||||
),
|
||||
table: "w-full border-collapse",
|
||||
weekdays: cn("flex", defaultClassNames.weekdays),
|
||||
weekday: cn(
|
||||
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
||||
defaultClassNames.weekday
|
||||
),
|
||||
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
||||
week_number_header: cn(
|
||||
"w-(--cell-size) select-none",
|
||||
defaultClassNames.week_number_header
|
||||
),
|
||||
week_number: cn(
|
||||
"text-[0.8rem] text-muted-foreground select-none",
|
||||
defaultClassNames.week_number
|
||||
),
|
||||
day: cn(
|
||||
"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
|
||||
props.showWeekNumber
|
||||
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
|
||||
: "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
|
||||
defaultClassNames.day
|
||||
),
|
||||
range_start: cn(
|
||||
"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
|
||||
defaultClassNames.range_start
|
||||
),
|
||||
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
||||
range_end: cn(
|
||||
"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
|
||||
defaultClassNames.range_end
|
||||
),
|
||||
today: cn(
|
||||
"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
|
||||
defaultClassNames.today
|
||||
),
|
||||
outside: cn(
|
||||
"text-muted-foreground aria-selected:text-muted-foreground",
|
||||
defaultClassNames.outside
|
||||
),
|
||||
disabled: cn(
|
||||
"text-muted-foreground opacity-50",
|
||||
defaultClassNames.disabled
|
||||
),
|
||||
hidden: cn("invisible", defaultClassNames.hidden),
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
Root: ({ className, rootRef, ...props }) => {
|
||||
return (
|
||||
<div
|
||||
data-slot="calendar"
|
||||
ref={rootRef}
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
},
|
||||
Chevron: ({ className, orientation, ...props }) => {
|
||||
if (orientation === "left") {
|
||||
return (
|
||||
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
if (orientation === "right") {
|
||||
return (
|
||||
<ChevronRightIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
},
|
||||
DayButton: ({ ...props }) => (
|
||||
<CalendarDayButton locale={locale} {...props} />
|
||||
),
|
||||
WeekNumber: ({ children, ...props }) => {
|
||||
return (
|
||||
<td {...props}>
|
||||
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
||||
{children}
|
||||
</div>
|
||||
</td>
|
||||
)
|
||||
},
|
||||
...components,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CalendarDayButton({
|
||||
className,
|
||||
day,
|
||||
modifiers,
|
||||
locale,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
const ref = React.useRef<HTMLButtonElement>(null)
|
||||
React.useEffect(() => {
|
||||
if (modifiers.focused) ref.current?.focus()
|
||||
}, [modifiers.focused])
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
data-day={day.date.toLocaleDateString(locale?.code)}
|
||||
data-selected-single={
|
||||
modifiers.selected &&
|
||||
!modifiers.range_start &&
|
||||
!modifiers.range_end &&
|
||||
!modifiers.range_middle
|
||||
}
|
||||
data-range-start={modifiers.range_start}
|
||||
data-range-end={modifiers.range_end}
|
||||
data-range-middle={modifiers.range_middle}
|
||||
className={cn(
|
||||
"relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
|
||||
defaultClassNames.day,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Calendar, CalendarDayButton }
|
||||
@@ -0,0 +1,121 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Card({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-6 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const cardTitleVariants = cva(
|
||||
"font-heading leading-snug group-data-[size=sm]/card:text-sm",
|
||||
{
|
||||
variants: {
|
||||
emphasis: {
|
||||
default: "text-base font-medium",
|
||||
prominent: "text-sm font-semibold text-foreground",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
emphasis: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function CardTitle({
|
||||
className,
|
||||
emphasis,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & VariantProps<typeof cardTitleVariants>) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-title"
|
||||
className={cn(cardTitleVariants({ emphasis }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-action"
|
||||
className={cn(
|
||||
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn(
|
||||
"flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle,
|
||||
cardTitleVariants,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
"use client"
|
||||
|
||||
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible"
|
||||
|
||||
function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
|
||||
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
|
||||
}
|
||||
|
||||
function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
|
||||
return (
|
||||
<CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
|
||||
return (
|
||||
<CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
||||
@@ -0,0 +1,193 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Command as CommandPrimitive } from "cmdk"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog"
|
||||
import {
|
||||
InputGroup,
|
||||
InputGroupAddon,
|
||||
} from "@/components/ui/input-group"
|
||||
import { SearchIcon, CheckIcon } from "lucide-react"
|
||||
|
||||
function Command({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive>) {
|
||||
return (
|
||||
<CommandPrimitive
|
||||
data-slot="command"
|
||||
className={cn(
|
||||
"flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandDialog({
|
||||
title = "Command Palette",
|
||||
description = "Search for a command to run...",
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: Omit<React.ComponentProps<typeof Dialog>, "children"> & {
|
||||
title?: string
|
||||
description?: string
|
||||
className?: string
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogHeader className="sr-only">
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
<DialogDescription>{description}</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogContent
|
||||
className={cn(
|
||||
"top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandInput({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
||||
return (
|
||||
<div data-slot="command-input-wrapper" className="p-1 pb-0">
|
||||
<InputGroup className="h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!">
|
||||
<CommandPrimitive.Input
|
||||
data-slot="command-input"
|
||||
className={cn(
|
||||
"w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
<InputGroupAddon>
|
||||
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
||||
</InputGroupAddon>
|
||||
</InputGroup>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandList({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
||||
return (
|
||||
<CommandPrimitive.List
|
||||
data-slot="command-list"
|
||||
className={cn(
|
||||
"no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandEmpty({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
||||
return (
|
||||
<CommandPrimitive.Empty
|
||||
data-slot="command-empty"
|
||||
className={cn("py-6 text-center text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandGroup({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
||||
return (
|
||||
<CommandPrimitive.Group
|
||||
data-slot="command-group"
|
||||
className={cn(
|
||||
"overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandSeparator({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
||||
return (
|
||||
<CommandPrimitive.Separator
|
||||
data-slot="command-separator"
|
||||
className={cn("-mx-1 h-px bg-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandItem({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
||||
return (
|
||||
<CommandPrimitive.Item
|
||||
data-slot="command-item"
|
||||
className={cn(
|
||||
"group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<CheckIcon className="ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
|
||||
</CommandPrimitive.Item>
|
||||
)
|
||||
}
|
||||
|
||||
function CommandShortcut({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="command-shortcut"
|
||||
className={cn(
|
||||
"ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Command,
|
||||
CommandDialog,
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandEmpty,
|
||||
CommandGroup,
|
||||
CommandItem,
|
||||
CommandShortcut,
|
||||
CommandSeparator,
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
|
||||
import { XIcon } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Dialog({ ...props }: DialogPrimitive.Root.Props) {
|
||||
return <DialogPrimitive.Root {...props} />
|
||||
}
|
||||
|
||||
function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
|
||||
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
||||
}
|
||||
|
||||
function DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {
|
||||
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
||||
}
|
||||
|
||||
function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
|
||||
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
||||
}
|
||||
|
||||
function DialogOverlay({
|
||||
className,
|
||||
...props
|
||||
}: DialogPrimitive.Backdrop.Props) {
|
||||
return (
|
||||
<DialogPrimitive.Backdrop
|
||||
data-slot="dialog-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/50 transition-opacity duration-200 data-starting-style:opacity-0 data-ending-style:opacity-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogContent({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: DialogPrimitive.Popup.Props) {
|
||||
return (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Popup
|
||||
data-slot="dialog-content"
|
||||
className={cn(
|
||||
"fixed top-1/2 left-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-background p-6 shadow-lg outline-none duration-200 data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 transition-[transform,opacity]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close
|
||||
data-slot="dialog-close-button"
|
||||
className="absolute top-3 right-3 rounded-sm text-muted-foreground transition-opacity hover:opacity-100 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none opacity-70"
|
||||
aria-label="閉じる"
|
||||
>
|
||||
<XIcon className="size-4" />
|
||||
</DialogPrimitive.Close>
|
||||
</DialogPrimitive.Popup>
|
||||
</DialogPortal>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="dialog-header"
|
||||
className={cn("flex flex-col gap-2 text-left", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="dialog-footer"
|
||||
className={cn(
|
||||
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogTitle({
|
||||
className,
|
||||
...props
|
||||
}: DialogPrimitive.Title.Props) {
|
||||
return (
|
||||
<DialogPrimitive.Title
|
||||
data-slot="dialog-title"
|
||||
className={cn(
|
||||
"text-base font-semibold leading-none text-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogDescription({
|
||||
className,
|
||||
...props
|
||||
}: DialogPrimitive.Description.Props) {
|
||||
return (
|
||||
<DialogPrimitive.Description
|
||||
data-slot="dialog-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogOverlay,
|
||||
DialogPortal,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Menu as MenuPrimitive } from "@base-ui/react/menu"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ChevronRightIcon, CheckIcon } from "lucide-react"
|
||||
|
||||
function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
|
||||
return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {
|
||||
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {
|
||||
return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuContent({
|
||||
align = "start",
|
||||
alignOffset = 0,
|
||||
side = "bottom",
|
||||
sideOffset = 4,
|
||||
className,
|
||||
...props
|
||||
}: MenuPrimitive.Popup.Props &
|
||||
Pick<
|
||||
MenuPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset"
|
||||
>) {
|
||||
return (
|
||||
<MenuPrimitive.Portal>
|
||||
<MenuPrimitive.Positioner
|
||||
className="isolate z-50 outline-none"
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
>
|
||||
<MenuPrimitive.Popup
|
||||
data-slot="dropdown-menu-content"
|
||||
className={cn("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
||||
{...props}
|
||||
/>
|
||||
</MenuPrimitive.Positioner>
|
||||
</MenuPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {
|
||||
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuLabel({
|
||||
className,
|
||||
inset,
|
||||
...props
|
||||
}: MenuPrimitive.GroupLabel.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.GroupLabel
|
||||
data-slot="dropdown-menu-label"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuItem({
|
||||
className,
|
||||
inset,
|
||||
variant = "default",
|
||||
...props
|
||||
}: MenuPrimitive.Item.Props & {
|
||||
inset?: boolean
|
||||
variant?: "default" | "destructive"
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.Item
|
||||
data-slot="dropdown-menu-item"
|
||||
data-inset={inset}
|
||||
data-variant={variant}
|
||||
className={cn(
|
||||
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {
|
||||
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuSubTrigger({
|
||||
className,
|
||||
inset,
|
||||
children,
|
||||
...props
|
||||
}: MenuPrimitive.SubmenuTrigger.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.SubmenuTrigger
|
||||
data-slot="dropdown-menu-sub-trigger"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRightIcon className="ml-auto" />
|
||||
</MenuPrimitive.SubmenuTrigger>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuSubContent({
|
||||
align = "start",
|
||||
alignOffset = -3,
|
||||
side = "right",
|
||||
sideOffset = 0,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuContent>) {
|
||||
return (
|
||||
<DropdownMenuContent
|
||||
data-slot="dropdown-menu-sub-content"
|
||||
className={cn("w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuCheckboxItem({
|
||||
className,
|
||||
children,
|
||||
checked,
|
||||
inset,
|
||||
...props
|
||||
}: MenuPrimitive.CheckboxItem.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.CheckboxItem
|
||||
data-slot="dropdown-menu-checkbox-item"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span
|
||||
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
||||
data-slot="dropdown-menu-checkbox-item-indicator"
|
||||
>
|
||||
<MenuPrimitive.CheckboxItemIndicator>
|
||||
<CheckIcon
|
||||
/>
|
||||
</MenuPrimitive.CheckboxItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</MenuPrimitive.CheckboxItem>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {
|
||||
return (
|
||||
<MenuPrimitive.RadioGroup
|
||||
data-slot="dropdown-menu-radio-group"
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuRadioItem({
|
||||
className,
|
||||
children,
|
||||
inset,
|
||||
...props
|
||||
}: MenuPrimitive.RadioItem.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.RadioItem
|
||||
data-slot="dropdown-menu-radio-item"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span
|
||||
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
||||
data-slot="dropdown-menu-radio-item-indicator"
|
||||
>
|
||||
<MenuPrimitive.RadioItemIndicator>
|
||||
<CheckIcon
|
||||
/>
|
||||
</MenuPrimitive.RadioItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</MenuPrimitive.RadioItem>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuSeparator({
|
||||
className,
|
||||
...props
|
||||
}: MenuPrimitive.Separator.Props) {
|
||||
return (
|
||||
<MenuPrimitive.Separator
|
||||
data-slot="dropdown-menu-separator"
|
||||
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuShortcut({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="dropdown-menu-shortcut"
|
||||
className={cn(
|
||||
"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuRadioGroup,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuSubContent,
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
"use client"
|
||||
|
||||
import { useMemo } from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
|
||||
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
||||
return (
|
||||
<fieldset
|
||||
data-slot="field-set"
|
||||
className={cn(
|
||||
"flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldLegend({
|
||||
className,
|
||||
variant = "legend",
|
||||
...props
|
||||
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
|
||||
return (
|
||||
<legend
|
||||
data-slot="field-legend"
|
||||
data-variant={variant}
|
||||
className={cn(
|
||||
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="field-group"
|
||||
className={cn(
|
||||
"group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const fieldVariants = cva(
|
||||
"group/field flex w-full gap-2 data-[invalid=true]:text-destructive",
|
||||
{
|
||||
variants: {
|
||||
orientation: {
|
||||
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
|
||||
horizontal:
|
||||
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
||||
responsive:
|
||||
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
orientation: "vertical",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Field({
|
||||
className,
|
||||
orientation = "vertical",
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
data-slot="field"
|
||||
data-orientation={orientation}
|
||||
className={cn(fieldVariants({ orientation }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="field-content"
|
||||
className={cn(
|
||||
"group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldLabel({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Label>) {
|
||||
return (
|
||||
<Label
|
||||
data-slot="field-label"
|
||||
className={cn(
|
||||
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10",
|
||||
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="field-label"
|
||||
className={cn(
|
||||
"flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
||||
return (
|
||||
<p
|
||||
data-slot="field-description"
|
||||
className={cn(
|
||||
"text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
|
||||
"last:mt-0 nth-last-2:-mt-1",
|
||||
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldSeparator({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
children?: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
data-slot="field-separator"
|
||||
data-content={!!children}
|
||||
className={cn(
|
||||
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<Separator className="absolute inset-0 top-1/2" />
|
||||
{children && (
|
||||
<span
|
||||
className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
|
||||
data-slot="field-separator-content"
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function FieldError({
|
||||
className,
|
||||
children,
|
||||
errors,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
errors?: Array<{ message?: string } | undefined>
|
||||
}) {
|
||||
const content = useMemo(() => {
|
||||
if (children) {
|
||||
return children
|
||||
}
|
||||
|
||||
if (!errors?.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
const uniqueErrors = [
|
||||
...new Map(errors.map((error) => [error?.message, error])).values(),
|
||||
]
|
||||
|
||||
if (uniqueErrors?.length == 1) {
|
||||
return uniqueErrors[0]?.message
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="ml-4 flex list-disc flex-col gap-1">
|
||||
{uniqueErrors.map(
|
||||
(error, index) =>
|
||||
error?.message && <li key={index}>{error.message}</li>
|
||||
)}
|
||||
</ul>
|
||||
)
|
||||
}, [children, errors])
|
||||
|
||||
if (!content) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
role="alert"
|
||||
data-slot="field-error"
|
||||
className={cn("text-sm font-normal text-destructive", className)}
|
||||
{...props}
|
||||
>
|
||||
{content}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Field,
|
||||
FieldLabel,
|
||||
FieldDescription,
|
||||
FieldError,
|
||||
FieldGroup,
|
||||
FieldLegend,
|
||||
FieldSeparator,
|
||||
FieldSet,
|
||||
FieldContent,
|
||||
FieldTitle,
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
|
||||
function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="input-group"
|
||||
role="group"
|
||||
className={cn(
|
||||
"group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const inputGroupAddonVariants = cva(
|
||||
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
align: {
|
||||
"inline-start":
|
||||
"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]",
|
||||
"inline-end":
|
||||
"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]",
|
||||
"block-start":
|
||||
"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
||||
"block-end":
|
||||
"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
align: "inline-start",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function InputGroupAddon({
|
||||
className,
|
||||
align = "inline-start",
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
data-slot="input-group-addon"
|
||||
data-align={align}
|
||||
className={cn(inputGroupAddonVariants({ align }), className)}
|
||||
onClick={(e) => {
|
||||
if ((e.target as HTMLElement).closest("button")) {
|
||||
return
|
||||
}
|
||||
e.currentTarget.parentElement?.querySelector("input")?.focus()
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const inputGroupButtonVariants = cva(
|
||||
"flex items-center gap-2 text-sm shadow-none",
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
||||
sm: "",
|
||||
"icon-xs":
|
||||
"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
|
||||
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
size: "xs",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function InputGroupButton({
|
||||
className,
|
||||
type = "button",
|
||||
variant = "ghost",
|
||||
size = "xs",
|
||||
...props
|
||||
}: Omit<React.ComponentProps<typeof Button>, "size" | "type"> &
|
||||
VariantProps<typeof inputGroupButtonVariants> & {
|
||||
type?: "button" | "submit" | "reset"
|
||||
}) {
|
||||
return (
|
||||
<Button
|
||||
type={type}
|
||||
data-size={size}
|
||||
variant={variant}
|
||||
className={cn(inputGroupButtonVariants({ size }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function InputGroupInput({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"input">) {
|
||||
return (
|
||||
<Input
|
||||
data-slot="input-group-control"
|
||||
className={cn(
|
||||
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function InputGroupTextarea({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"textarea">) {
|
||||
return (
|
||||
<Textarea
|
||||
data-slot="input-group-control"
|
||||
className={cn(
|
||||
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
InputGroup,
|
||||
InputGroupAddon,
|
||||
InputGroupButton,
|
||||
InputGroupText,
|
||||
InputGroupInput,
|
||||
InputGroupTextarea,
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as React from "react"
|
||||
import { Input as InputPrimitive } from "@base-ui/react/input"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
return (
|
||||
<InputPrimitive
|
||||
type={type}
|
||||
data-slot="input"
|
||||
className={cn(
|
||||
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Input }
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Label({ className, ...props }: React.ComponentProps<"label">) {
|
||||
return (
|
||||
<label
|
||||
data-slot="label"
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Label }
|
||||
@@ -0,0 +1,90 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Popover({ ...props }: PopoverPrimitive.Root.Props) {
|
||||
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
||||
}
|
||||
|
||||
function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
|
||||
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
||||
}
|
||||
|
||||
function PopoverContent({
|
||||
className,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
side = "bottom",
|
||||
sideOffset = 4,
|
||||
...props
|
||||
}: PopoverPrimitive.Popup.Props &
|
||||
Pick<
|
||||
PopoverPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset"
|
||||
>) {
|
||||
return (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
className="isolate z-50"
|
||||
>
|
||||
<PopoverPrimitive.Popup
|
||||
data-slot="popover-content"
|
||||
className={cn(
|
||||
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</PopoverPrimitive.Positioner>
|
||||
</PopoverPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="popover-header"
|
||||
className={cn("flex flex-col gap-0.5 text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {
|
||||
return (
|
||||
<PopoverPrimitive.Title
|
||||
data-slot="popover-title"
|
||||
className={cn("font-medium", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function PopoverDescription({
|
||||
className,
|
||||
...props
|
||||
}: PopoverPrimitive.Description.Props) {
|
||||
return (
|
||||
<PopoverPrimitive.Description
|
||||
data-slot="popover-description"
|
||||
className={cn("text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDescription,
|
||||
PopoverHeader,
|
||||
PopoverTitle,
|
||||
PopoverTrigger,
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function ScrollArea({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: ScrollAreaPrimitive.Root.Props) {
|
||||
return (
|
||||
<ScrollAreaPrimitive.Root
|
||||
data-slot="scroll-area"
|
||||
className={cn("relative", className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport
|
||||
data-slot="scroll-area-viewport"
|
||||
className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
|
||||
>
|
||||
{children}
|
||||
</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
function ScrollBar({
|
||||
className,
|
||||
orientation = "vertical",
|
||||
...props
|
||||
}: ScrollAreaPrimitive.Scrollbar.Props) {
|
||||
return (
|
||||
<ScrollAreaPrimitive.Scrollbar
|
||||
data-slot="scroll-area-scrollbar"
|
||||
data-orientation={orientation}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Thumb
|
||||
data-slot="scroll-area-thumb"
|
||||
className="relative flex-1 rounded-full bg-border"
|
||||
/>
|
||||
</ScrollAreaPrimitive.Scrollbar>
|
||||
)
|
||||
}
|
||||
|
||||
export { ScrollArea, ScrollBar }
|
||||
@@ -0,0 +1,201 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Select as SelectPrimitive } from "@base-ui/react/select"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
|
||||
|
||||
const Select = SelectPrimitive.Root
|
||||
|
||||
function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Group
|
||||
data-slot="select-group"
|
||||
className={cn("scroll-my-1 p-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Value
|
||||
data-slot="select-value"
|
||||
className={cn("flex flex-1 text-left", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectTrigger({
|
||||
className,
|
||||
size = "default",
|
||||
children,
|
||||
...props
|
||||
}: SelectPrimitive.Trigger.Props & {
|
||||
size?: "sm" | "default"
|
||||
}) {
|
||||
return (
|
||||
<SelectPrimitive.Trigger
|
||||
data-slot="select-trigger"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon
|
||||
render={
|
||||
<ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
|
||||
}
|
||||
/>
|
||||
</SelectPrimitive.Trigger>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectContent({
|
||||
className,
|
||||
children,
|
||||
side = "bottom",
|
||||
sideOffset = 4,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
alignItemWithTrigger = true,
|
||||
...props
|
||||
}: SelectPrimitive.Popup.Props &
|
||||
Pick<
|
||||
SelectPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
|
||||
>) {
|
||||
return (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Positioner
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
alignItemWithTrigger={alignItemWithTrigger}
|
||||
className="isolate z-50"
|
||||
>
|
||||
<SelectPrimitive.Popup
|
||||
data-slot="select-content"
|
||||
data-align-trigger={alignItemWithTrigger}
|
||||
className={cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
||||
{...props}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.List>{children}</SelectPrimitive.List>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Popup>
|
||||
</SelectPrimitive.Positioner>
|
||||
</SelectPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectLabel({
|
||||
className,
|
||||
...props
|
||||
}: SelectPrimitive.GroupLabel.Props) {
|
||||
return (
|
||||
<SelectPrimitive.GroupLabel
|
||||
data-slot="select-label"
|
||||
className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectItem({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: SelectPrimitive.Item.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Item
|
||||
data-slot="select-item"
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
|
||||
{children}
|
||||
</SelectPrimitive.ItemText>
|
||||
<SelectPrimitive.ItemIndicator
|
||||
render={
|
||||
<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
|
||||
}
|
||||
>
|
||||
<CheckIcon className="pointer-events-none" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</SelectPrimitive.Item>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectSeparator({
|
||||
className,
|
||||
...props
|
||||
}: SelectPrimitive.Separator.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Separator
|
||||
data-slot="select-separator"
|
||||
className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectScrollUpButton({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollUpArrow
|
||||
data-slot="select-scroll-up-button"
|
||||
className={cn(
|
||||
"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUpIcon
|
||||
/>
|
||||
</SelectPrimitive.ScrollUpArrow>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectScrollDownButton({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollDownArrow
|
||||
data-slot="select-scroll-down-button"
|
||||
className={cn(
|
||||
"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDownIcon
|
||||
/>
|
||||
</SelectPrimitive.ScrollDownArrow>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectLabel,
|
||||
SelectScrollDownButton,
|
||||
SelectScrollUpButton,
|
||||
SelectSeparator,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
"use client"
|
||||
|
||||
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Separator({
|
||||
className,
|
||||
orientation = "horizontal",
|
||||
...props
|
||||
}: SeparatorPrimitive.Props) {
|
||||
return (
|
||||
<SeparatorPrimitive
|
||||
data-slot="separator"
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Separator }
|
||||
@@ -0,0 +1,138 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { XIcon } from "lucide-react"
|
||||
|
||||
function Sheet({ ...props }: SheetPrimitive.Root.Props) {
|
||||
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
||||
}
|
||||
|
||||
function SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {
|
||||
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
||||
}
|
||||
|
||||
function SheetClose({ ...props }: SheetPrimitive.Close.Props) {
|
||||
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
|
||||
}
|
||||
|
||||
function SheetPortal({ ...props }: SheetPrimitive.Portal.Props) {
|
||||
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
|
||||
}
|
||||
|
||||
function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
|
||||
return (
|
||||
<SheetPrimitive.Backdrop
|
||||
data-slot="sheet-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetContent({
|
||||
className,
|
||||
children,
|
||||
side = "right",
|
||||
showCloseButton = true,
|
||||
...props
|
||||
}: SheetPrimitive.Popup.Props & {
|
||||
side?: "top" | "right" | "bottom" | "left"
|
||||
showCloseButton?: boolean
|
||||
}) {
|
||||
return (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Popup
|
||||
data-slot="sheet-content"
|
||||
data-side={side}
|
||||
className={cn(
|
||||
"fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{showCloseButton && (
|
||||
<SheetPrimitive.Close
|
||||
data-slot="sheet-close"
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="absolute top-3 right-3"
|
||||
size="icon-sm"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<XIcon
|
||||
/>
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
)}
|
||||
</SheetPrimitive.Popup>
|
||||
</SheetPortal>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-header"
|
||||
className={cn("flex flex-col gap-0.5 p-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-footer"
|
||||
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {
|
||||
return (
|
||||
<SheetPrimitive.Title
|
||||
data-slot="sheet-title"
|
||||
className={cn(
|
||||
"font-heading text-base font-medium text-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetDescription({
|
||||
className,
|
||||
...props
|
||||
}: SheetPrimitive.Description.Props) {
|
||||
return (
|
||||
<SheetPrimitive.Description
|
||||
data-slot="sheet-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Sheet,
|
||||
SheetTrigger,
|
||||
SheetClose,
|
||||
SheetContent,
|
||||
SheetHeader,
|
||||
SheetFooter,
|
||||
SheetTitle,
|
||||
SheetDescription,
|
||||
}
|
||||
@@ -0,0 +1,723 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { useIsMobile } from "@/hooks/use-mobile"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import {
|
||||
Sheet,
|
||||
SheetContent,
|
||||
SheetDescription,
|
||||
SheetHeader,
|
||||
SheetTitle,
|
||||
} from "@/components/ui/sheet"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip"
|
||||
import { PanelLeftIcon } from "lucide-react"
|
||||
|
||||
const SIDEBAR_COOKIE_NAME = "sidebar_state"
|
||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
||||
const SIDEBAR_WIDTH = "16rem"
|
||||
const SIDEBAR_WIDTH_MOBILE = "18rem"
|
||||
const SIDEBAR_WIDTH_ICON = "3rem"
|
||||
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
|
||||
|
||||
type SidebarContextProps = {
|
||||
state: "expanded" | "collapsed"
|
||||
open: boolean
|
||||
setOpen: (open: boolean) => void
|
||||
openMobile: boolean
|
||||
setOpenMobile: (open: boolean) => void
|
||||
isMobile: boolean
|
||||
toggleSidebar: () => void
|
||||
}
|
||||
|
||||
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
|
||||
|
||||
function useSidebar() {
|
||||
const context = React.useContext(SidebarContext)
|
||||
if (!context) {
|
||||
throw new Error("useSidebar must be used within a SidebarProvider.")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
function SidebarProvider({
|
||||
defaultOpen = true,
|
||||
open: openProp,
|
||||
onOpenChange: setOpenProp,
|
||||
className,
|
||||
style,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
defaultOpen?: boolean
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}) {
|
||||
const isMobile = useIsMobile()
|
||||
const [openMobile, setOpenMobile] = React.useState(false)
|
||||
|
||||
// This is the internal state of the sidebar.
|
||||
// We use openProp and setOpenProp for control from outside the component.
|
||||
const [_open, _setOpen] = React.useState(defaultOpen)
|
||||
const open = openProp ?? _open
|
||||
const setOpen = React.useCallback(
|
||||
(value: boolean | ((value: boolean) => boolean)) => {
|
||||
const openState = typeof value === "function" ? value(open) : value
|
||||
if (setOpenProp) {
|
||||
setOpenProp(openState)
|
||||
} else {
|
||||
_setOpen(openState)
|
||||
}
|
||||
|
||||
// This sets the cookie to keep the sidebar state.
|
||||
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
|
||||
},
|
||||
[setOpenProp, open]
|
||||
)
|
||||
|
||||
// Helper to toggle the sidebar.
|
||||
const toggleSidebar = React.useCallback(() => {
|
||||
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
|
||||
}, [isMobile, setOpen, setOpenMobile])
|
||||
|
||||
// Adds a keyboard shortcut to toggle the sidebar.
|
||||
React.useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
||||
(event.metaKey || event.ctrlKey)
|
||||
) {
|
||||
event.preventDefault()
|
||||
toggleSidebar()
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown)
|
||||
return () => window.removeEventListener("keydown", handleKeyDown)
|
||||
}, [toggleSidebar])
|
||||
|
||||
// We add a state so that we can do data-state="expanded" or "collapsed".
|
||||
// This makes it easier to style the sidebar with Tailwind classes.
|
||||
const state = open ? "expanded" : "collapsed"
|
||||
|
||||
const contextValue = React.useMemo<SidebarContextProps>(
|
||||
() => ({
|
||||
state,
|
||||
open,
|
||||
setOpen,
|
||||
isMobile,
|
||||
openMobile,
|
||||
setOpenMobile,
|
||||
toggleSidebar,
|
||||
}),
|
||||
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
||||
)
|
||||
|
||||
return (
|
||||
<SidebarContext.Provider value={contextValue}>
|
||||
<div
|
||||
data-slot="sidebar-wrapper"
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": SIDEBAR_WIDTH,
|
||||
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
||||
...style,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
className={cn(
|
||||
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</SidebarContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
function Sidebar({
|
||||
side = "left",
|
||||
variant = "sidebar",
|
||||
collapsible = "offcanvas",
|
||||
className,
|
||||
children,
|
||||
dir,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
side?: "left" | "right"
|
||||
variant?: "sidebar" | "floating" | "inset"
|
||||
collapsible?: "offcanvas" | "icon" | "none"
|
||||
}) {
|
||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
||||
|
||||
if (collapsible === "none") {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar"
|
||||
className={cn(
|
||||
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
||||
<SheetContent
|
||||
dir={dir}
|
||||
data-sidebar="sidebar"
|
||||
data-slot="sidebar"
|
||||
data-mobile="true"
|
||||
className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
side={side}
|
||||
>
|
||||
<SheetHeader className="sr-only">
|
||||
<SheetTitle>Sidebar</SheetTitle>
|
||||
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
||||
</SheetHeader>
|
||||
<div className="flex h-full w-full flex-col">{children}</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="group peer hidden text-sidebar-foreground md:block"
|
||||
data-state={state}
|
||||
data-collapsible={state === "collapsed" ? collapsible : ""}
|
||||
data-variant={variant}
|
||||
data-side={side}
|
||||
data-slot="sidebar"
|
||||
>
|
||||
{/* This is what handles the sidebar gap on desktop */}
|
||||
<div
|
||||
data-slot="sidebar-gap"
|
||||
className={cn(
|
||||
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
||||
"group-data-[collapsible=offcanvas]:w-0",
|
||||
"group-data-[side=right]:rotate-180",
|
||||
variant === "floating" || variant === "inset"
|
||||
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
||||
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
data-slot="sidebar-container"
|
||||
data-side={side}
|
||||
className={cn(
|
||||
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
|
||||
// Adjust the padding for floating and inset variants.
|
||||
variant === "floating" || variant === "inset"
|
||||
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
||||
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
data-sidebar="sidebar"
|
||||
data-slot="sidebar-inner"
|
||||
className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarTrigger({
|
||||
className,
|
||||
onClick,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const { toggleSidebar } = useSidebar()
|
||||
|
||||
return (
|
||||
<Button
|
||||
data-sidebar="trigger"
|
||||
data-slot="sidebar-trigger"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
className={cn(className)}
|
||||
onClick={(event) => {
|
||||
onClick?.(event)
|
||||
toggleSidebar()
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
<PanelLeftIcon />
|
||||
<span className="sr-only">Toggle Sidebar</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
||||
const { toggleSidebar } = useSidebar()
|
||||
|
||||
return (
|
||||
<button
|
||||
data-sidebar="rail"
|
||||
data-slot="sidebar-rail"
|
||||
aria-label="Toggle Sidebar"
|
||||
tabIndex={-1}
|
||||
onClick={toggleSidebar}
|
||||
title="Toggle Sidebar"
|
||||
className={cn(
|
||||
"absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
|
||||
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
||||
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
||||
"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
|
||||
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
||||
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
||||
return (
|
||||
<main
|
||||
data-slot="sidebar-inset"
|
||||
className={cn(
|
||||
"relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarInput({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Input>) {
|
||||
return (
|
||||
<Input
|
||||
data-slot="sidebar-input"
|
||||
data-sidebar="input"
|
||||
className={cn("h-8 w-full bg-background shadow-none", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-header"
|
||||
data-sidebar="header"
|
||||
className={cn("flex flex-col gap-2 p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-footer"
|
||||
data-sidebar="footer"
|
||||
className={cn("flex flex-col gap-2 p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarSeparator({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Separator>) {
|
||||
return (
|
||||
<Separator
|
||||
data-slot="sidebar-separator"
|
||||
data-sidebar="separator"
|
||||
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-content"
|
||||
data-sidebar="content"
|
||||
className={cn(
|
||||
"no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-group"
|
||||
data-sidebar="group"
|
||||
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarGroupLabel({
|
||||
className,
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
|
||||
return useRender({
|
||||
defaultTagName: "div",
|
||||
props: mergeProps<"div">(
|
||||
{
|
||||
className: cn(
|
||||
"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-group-label",
|
||||
sidebar: "group-label",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function SidebarGroupAction({
|
||||
className,
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
|
||||
return useRender({
|
||||
defaultTagName: "button",
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: cn(
|
||||
"absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-group-action",
|
||||
sidebar: "group-action",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function SidebarGroupContent({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-group-content"
|
||||
data-sidebar="group-content"
|
||||
className={cn("w-full text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
||||
return (
|
||||
<ul
|
||||
data-slot="sidebar-menu"
|
||||
data-sidebar="menu"
|
||||
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="sidebar-menu-item"
|
||||
data-sidebar="menu-item"
|
||||
className={cn("group/menu-item relative", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const sidebarMenuButtonVariants = cva(
|
||||
"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
outline:
|
||||
"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
|
||||
},
|
||||
size: {
|
||||
default: "h-8 text-sm",
|
||||
sm: "h-7 text-xs",
|
||||
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function SidebarMenuButton({
|
||||
render,
|
||||
isActive = false,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
tooltip,
|
||||
className,
|
||||
...props
|
||||
}: useRender.ComponentProps<"button"> &
|
||||
React.ComponentProps<"button"> & {
|
||||
isActive?: boolean
|
||||
tooltip?: string | React.ComponentProps<typeof TooltipContent>
|
||||
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
||||
const { isMobile, state } = useSidebar()
|
||||
const comp = useRender({
|
||||
defaultTagName: "button",
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
||||
},
|
||||
props
|
||||
),
|
||||
render: !tooltip ? render : <TooltipTrigger render={render} />,
|
||||
state: {
|
||||
slot: "sidebar-menu-button",
|
||||
sidebar: "menu-button",
|
||||
size,
|
||||
active: isActive,
|
||||
},
|
||||
})
|
||||
|
||||
if (!tooltip) {
|
||||
return comp
|
||||
}
|
||||
|
||||
if (typeof tooltip === "string") {
|
||||
tooltip = {
|
||||
children: tooltip,
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
{comp}
|
||||
<TooltipContent
|
||||
side="right"
|
||||
align="center"
|
||||
hidden={state !== "collapsed" || isMobile}
|
||||
{...tooltip}
|
||||
/>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuAction({
|
||||
className,
|
||||
render,
|
||||
showOnHover = false,
|
||||
...props
|
||||
}: useRender.ComponentProps<"button"> &
|
||||
React.ComponentProps<"button"> & {
|
||||
showOnHover?: boolean
|
||||
}) {
|
||||
return useRender({
|
||||
defaultTagName: "button",
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: cn(
|
||||
"absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
showOnHover &&
|
||||
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-menu-action",
|
||||
sidebar: "menu-action",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function SidebarMenuBadge({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-menu-badge"
|
||||
data-sidebar="menu-badge"
|
||||
className={cn(
|
||||
"pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSkeleton({
|
||||
className,
|
||||
showIcon = false,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
showIcon?: boolean
|
||||
}) {
|
||||
// Random width between 50 to 90%.
|
||||
const [width] = React.useState(() => {
|
||||
return `${Math.floor(Math.random() * 40) + 50}%`
|
||||
})
|
||||
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-menu-skeleton"
|
||||
data-sidebar="menu-skeleton"
|
||||
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
||||
{...props}
|
||||
>
|
||||
{showIcon && (
|
||||
<Skeleton
|
||||
className="size-4 rounded-md"
|
||||
data-sidebar="menu-skeleton-icon"
|
||||
/>
|
||||
)}
|
||||
<Skeleton
|
||||
className="h-4 max-w-(--skeleton-width) flex-1"
|
||||
data-sidebar="menu-skeleton-text"
|
||||
style={
|
||||
{
|
||||
"--skeleton-width": width,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
||||
return (
|
||||
<ul
|
||||
data-slot="sidebar-menu-sub"
|
||||
data-sidebar="menu-sub"
|
||||
className={cn(
|
||||
"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSubItem({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="sidebar-menu-sub-item"
|
||||
data-sidebar="menu-sub-item"
|
||||
className={cn("group/menu-sub-item relative", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSubButton({
|
||||
render,
|
||||
size = "md",
|
||||
isActive = false,
|
||||
className,
|
||||
...props
|
||||
}: useRender.ComponentProps<"a"> &
|
||||
React.ComponentProps<"a"> & {
|
||||
size?: "sm" | "md"
|
||||
isActive?: boolean
|
||||
}) {
|
||||
return useRender({
|
||||
defaultTagName: "a",
|
||||
props: mergeProps<"a">(
|
||||
{
|
||||
className: cn(
|
||||
"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-menu-sub-button",
|
||||
sidebar: "menu-sub-button",
|
||||
size,
|
||||
active: isActive,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupAction,
|
||||
SidebarGroupContent,
|
||||
SidebarGroupLabel,
|
||||
SidebarHeader,
|
||||
SidebarInput,
|
||||
SidebarInset,
|
||||
SidebarMenu,
|
||||
SidebarMenuAction,
|
||||
SidebarMenuBadge,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
SidebarMenuSkeleton,
|
||||
SidebarMenuSub,
|
||||
SidebarMenuSubButton,
|
||||
SidebarMenuSubItem,
|
||||
SidebarProvider,
|
||||
SidebarRail,
|
||||
SidebarSeparator,
|
||||
SidebarTrigger,
|
||||
useSidebar,
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="skeleton"
|
||||
className={cn("animate-pulse rounded-md bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Skeleton }
|
||||
@@ -0,0 +1,18 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
return (
|
||||
<textarea
|
||||
data-slot="textarea"
|
||||
className={cn(
|
||||
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Textarea }
|
||||
@@ -0,0 +1,89 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
|
||||
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group"
|
||||
import { type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { toggleVariants } from "@/components/ui/toggle"
|
||||
|
||||
const ToggleGroupContext = React.createContext<
|
||||
VariantProps<typeof toggleVariants> & {
|
||||
spacing?: number
|
||||
orientation?: "horizontal" | "vertical"
|
||||
}
|
||||
>({
|
||||
size: "default",
|
||||
variant: "default",
|
||||
spacing: 0,
|
||||
orientation: "horizontal",
|
||||
})
|
||||
|
||||
function ToggleGroup({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
spacing = 0,
|
||||
orientation = "horizontal",
|
||||
children,
|
||||
...props
|
||||
}: ToggleGroupPrimitive.Props &
|
||||
VariantProps<typeof toggleVariants> & {
|
||||
spacing?: number
|
||||
orientation?: "horizontal" | "vertical"
|
||||
}) {
|
||||
return (
|
||||
<ToggleGroupPrimitive
|
||||
data-slot="toggle-group"
|
||||
data-variant={variant}
|
||||
data-size={size}
|
||||
data-spacing={spacing}
|
||||
data-orientation={orientation}
|
||||
style={{ "--gap": spacing } as React.CSSProperties}
|
||||
className={cn(
|
||||
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ToggleGroupContext.Provider
|
||||
value={{ variant, size, spacing, orientation }}
|
||||
>
|
||||
{children}
|
||||
</ToggleGroupContext.Provider>
|
||||
</ToggleGroupPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
function ToggleGroupItem({
|
||||
className,
|
||||
children,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
...props
|
||||
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
||||
const context = React.useContext(ToggleGroupContext)
|
||||
|
||||
return (
|
||||
<TogglePrimitive
|
||||
data-slot="toggle-group-item"
|
||||
data-variant={context.variant || variant}
|
||||
data-size={context.size || size}
|
||||
data-spacing={context.spacing}
|
||||
className={cn(
|
||||
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
||||
toggleVariants({
|
||||
variant: context.variant || variant,
|
||||
size: context.size || size,
|
||||
}),
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</TogglePrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export { ToggleGroup, ToggleGroupItem }
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client"
|
||||
|
||||
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const toggleVariants = cva(
|
||||
"group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground 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 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-transparent",
|
||||
outline: "border border-input bg-transparent hover:bg-muted",
|
||||
},
|
||||
size: {
|
||||
default:
|
||||
"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
||||
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Toggle({
|
||||
className,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
...props
|
||||
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
||||
return (
|
||||
<TogglePrimitive
|
||||
data-slot="toggle"
|
||||
className={cn(toggleVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Toggle, toggleVariants }
|
||||
@@ -0,0 +1,66 @@
|
||||
"use client"
|
||||
|
||||
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function TooltipProvider({
|
||||
delay = 0,
|
||||
...props
|
||||
}: TooltipPrimitive.Provider.Props) {
|
||||
return (
|
||||
<TooltipPrimitive.Provider
|
||||
data-slot="tooltip-provider"
|
||||
delay={delay}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
|
||||
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
||||
}
|
||||
|
||||
function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
|
||||
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
||||
}
|
||||
|
||||
function TooltipContent({
|
||||
className,
|
||||
side = "top",
|
||||
sideOffset = 4,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
children,
|
||||
...props
|
||||
}: TooltipPrimitive.Popup.Props &
|
||||
Pick<
|
||||
TooltipPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset"
|
||||
>) {
|
||||
return (
|
||||
<TooltipPrimitive.Portal>
|
||||
<TooltipPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
className="isolate z-50"
|
||||
>
|
||||
<TooltipPrimitive.Popup
|
||||
data-slot="tooltip-content"
|
||||
className={cn(
|
||||
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-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 data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" />
|
||||
</TooltipPrimitive.Popup>
|
||||
</TooltipPrimitive.Positioner>
|
||||
</TooltipPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { FieldGroup, Field, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
type AddItemDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title: string;
|
||||
description: string;
|
||||
fieldLabel: string;
|
||||
fieldId: string;
|
||||
placeholder: string;
|
||||
onAdd: (name: string) => void;
|
||||
};
|
||||
|
||||
export function AddItemDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
description,
|
||||
fieldLabel,
|
||||
fieldId,
|
||||
placeholder,
|
||||
onAdd,
|
||||
}: AddItemDialogProps) {
|
||||
const [name, setName] = useState("");
|
||||
|
||||
const handleSubmit = () => {
|
||||
const trimmed = name.trim();
|
||||
if (!trimmed) return;
|
||||
onAdd(trimmed);
|
||||
setName("");
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={(v) => {
|
||||
onOpenChange(v);
|
||||
if (!v) setName("");
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
<DialogDescription>{description}</DialogDescription>
|
||||
</DialogHeader>
|
||||
<FieldGroup>
|
||||
<Field>
|
||||
<FieldLabel htmlFor={fieldId}>{fieldLabel}</FieldLabel>
|
||||
<Input
|
||||
id={fieldId}
|
||||
autoFocus
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") handleSubmit();
|
||||
}}
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
</Field>
|
||||
</FieldGroup>
|
||||
<DialogFooter>
|
||||
<DialogClose render={<Button variant="outline">キャンセル</Button>} />
|
||||
<Button onClick={handleSubmit} disabled={!name.trim()}>
|
||||
追加
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* 添付ファイル一覧(Pane 4 モード 2 の「提出書類 / 文字起こし」共通リスト)。
|
||||
*
|
||||
* ADR-0010 §13 D75 で「添付セクションは Attachment 統一型のファイル一覧」に統合。
|
||||
* 旧「提出書類は PDF リスト / 文字起こしはテキスト塊」の二分岐を廃止し、
|
||||
* 両ステージで同じ AttachmentList を使う。
|
||||
*
|
||||
* 行のマークアップ規律(レビュー反映):
|
||||
* - `<li>` 自体には role / onClick を持たせない(ネスト button を回避、WAI-ARIA APG 準拠)
|
||||
* - `<li>` 内に **兄弟関係の native `<button>` 2 つ** を配置:
|
||||
* 1. プレビュー用ワイドボタン(kind: "txt" のときのみ有効、kind: "pdf" は disabled)
|
||||
* 2. ダウンロード用アイコンボタン(常に有効、stopPropagation 不要)
|
||||
* - `focus-within:ring-2` で行全体の focus 可視化
|
||||
* - PDF 行は `disabled` + 「プレビュー不可」バッジで「クリックしても開かない」を明示
|
||||
*
|
||||
* 状態管理規律(ADR-0010 §6/§7/§8 準拠):
|
||||
* - `openItem` state は本コンポーネント内 useState で持つ
|
||||
* - 候補者・ステージ切替は親 (CandidateDetailPane) 側の
|
||||
* `key={selectedCandidateId}-${stage}` でツリー再マウントされ、モーダルも自然に閉じる
|
||||
* - useEffect 内で setOpenItem(null) するパターンは MUST 禁止
|
||||
*
|
||||
* ダミー DL は `console.info("[stub] download:", file.id)` の observable stub
|
||||
* (noop 禁止、雛形教材として「動いている」ことを受講生に示す)。
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { Download, FileText } from "lucide-react";
|
||||
|
||||
import { type Attachment } from "@/lib/schema";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { AttachmentPreviewDialog } from "@/components/workspace/AttachmentPreviewDialog";
|
||||
|
||||
export function AttachmentList({ items }: { items: Attachment[] }) {
|
||||
const [openItem, setOpenItem] = useState<Attachment | null>(null);
|
||||
|
||||
if (items.length === 0) {
|
||||
return (
|
||||
<p className="px-1 py-2 text-sm text-muted-foreground">
|
||||
添付はまだありません。ヘッダーの「アップロード」から追加できます。
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ul className="flex flex-col gap-1.5">
|
||||
{items.map((file) => {
|
||||
const isTxt = file.kind === "txt";
|
||||
return (
|
||||
<li
|
||||
key={file.id}
|
||||
className="flex items-stretch overflow-hidden rounded-lg border border-border bg-card transition"
|
||||
>
|
||||
{/* 兄弟 button 1: プレビュー(PDF は disabled) */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (isTxt) {
|
||||
setOpenItem(file);
|
||||
}
|
||||
}}
|
||||
disabled={!isTxt}
|
||||
aria-label={
|
||||
isTxt
|
||||
? `${file.name} のプレビューを開く`
|
||||
: `${file.name}(プレビュー不可)`
|
||||
}
|
||||
className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-3 py-2.5 text-left transition outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-default disabled:hover:bg-transparent"
|
||||
>
|
||||
<FileText className="size-4 shrink-0 text-muted-foreground" />
|
||||
<span className="truncate text-sm text-foreground">
|
||||
{file.name}
|
||||
</span>
|
||||
{!isTxt && (
|
||||
<span className="ml-1 shrink-0 rounded border border-border px-1 text-[10px] text-muted-foreground">
|
||||
プレビュー不可
|
||||
</span>
|
||||
)}
|
||||
<span className="ml-auto shrink-0 text-xs text-muted-foreground tabular-nums">
|
||||
{file.size}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<Separator orientation="vertical" aria-hidden />
|
||||
|
||||
{/* 兄弟 button 2: ダウンロード(独立コントロール、stopPropagation 不要) */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => console.info("[stub] download:", file.id)}
|
||||
aria-label={`${file.name} をダウンロード`}
|
||||
className="flex shrink-0 items-center px-2.5 transition outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"
|
||||
>
|
||||
<Download className="size-3.5 text-muted-foreground" />
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<AttachmentPreviewDialog
|
||||
item={openItem}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
setOpenItem(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* 添付ファイル中身プレビューモーダル(Pane 4 モード 2 / AttachmentList から開く)。
|
||||
*
|
||||
* - shadcn Dialog 公式構造(Title / Description / Header / ScrollArea)に揃える
|
||||
* - WAI-ARIA Modal Dialog Pattern: aria-labelledby(Title 自動接続)+ aria-describedby
|
||||
* (Description 自動接続)+ Esc 閉じ + focus 戻し(Base UI Dialog で標準提供)
|
||||
* - txt は本文を whitespace-pre-wrap で表示。font-mono は使わず、日本語長文の
|
||||
* 可読性を優先(ADR-0010 §13 D75 / レビュー反映)
|
||||
* - PDF はそもそも `AttachmentList` 側で `disabled` のためモーダルが開かない。
|
||||
* この Dialog では PDF 分岐を持たない(YAGNI、PDF プレビューは雛形外)
|
||||
*
|
||||
* ADR 出典: ADR-0010 §13 / design.md D75
|
||||
*/
|
||||
|
||||
import { Download } from "lucide-react";
|
||||
|
||||
import { type Attachment } from "@/lib/schema";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
|
||||
export function AttachmentPreviewDialog({
|
||||
item,
|
||||
onOpenChange,
|
||||
}: {
|
||||
item: Attachment | null;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}) {
|
||||
// モーダルは「txt の Attachment」専用。PDF は親側で disabled されているため
|
||||
// ここに到達しない前提だが、型安全のため item?.kind === "txt" でガードする。
|
||||
return (
|
||||
<Dialog open={item !== null} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[80vh] max-w-2xl flex-col gap-3">
|
||||
<DialogHeader>
|
||||
<div className="flex items-center justify-between gap-2 pr-8">
|
||||
<DialogTitle className="truncate">{item?.name ?? ""}</DialogTitle>
|
||||
{item && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
aria-label={`${item.name} をダウンロード`}
|
||||
onClick={() => console.info("[stub] download:", item.id)}
|
||||
className="shrink-0"
|
||||
>
|
||||
<Download data-icon="inline-start" />
|
||||
ダウンロード
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<DialogDescription>
|
||||
Esc キーまたは右上 × で閉じます。
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<ScrollArea className="-mx-1 min-h-0 flex-1 px-1">
|
||||
{item?.kind === "txt" ? (
|
||||
<div className="py-1 text-sm leading-relaxed whitespace-pre-wrap text-foreground">
|
||||
{item.previewText}
|
||||
</div>
|
||||
) : null}
|
||||
</ScrollArea>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,682 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* Pane 3: 候補者ダッシュボード(ADR-0015 §19 で再設計)。
|
||||
*
|
||||
* 「人物軸の編集」として、ヘッダー帯(Collapsible)+ 採用条件カード + 選考フローカード
|
||||
* の 3 要素で構成。判断の 3 問い(Q1: 採る価値 / Q2: 採れるか / Q3: 手遅れか)に
|
||||
* スクロールなしで即答できることが目標。
|
||||
*
|
||||
* セクション順序: ヘッダー帯 → 採用条件 → 選考フロー
|
||||
*
|
||||
* `AxisScoreRow` は Pane 4 モード 2 評価セクションでも使うため引き続き export する。
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import {
|
||||
ArrowUpRight,
|
||||
Check,
|
||||
Circle,
|
||||
CircleDot,
|
||||
ChevronDown,
|
||||
Mail,
|
||||
Phone,
|
||||
MapPin,
|
||||
X,
|
||||
Star,
|
||||
StarHalf,
|
||||
} from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
type Profile,
|
||||
type StageStatus,
|
||||
type Scorecard,
|
||||
type SelectedDetail,
|
||||
STAGE_ORDER,
|
||||
} from "@/lib/schema";
|
||||
import { STAGE_LABELS, PANE3_SECTION, PANE4_SECTION_IDS } from "@/lib/labels";
|
||||
import {
|
||||
getScorecardsAverageScore,
|
||||
deriveStageStatus,
|
||||
} from "@/lib/computed/scorecards";
|
||||
import { calculateAge } from "@/lib/computed/profile";
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Card,
|
||||
CardAction,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
} from "@/components/ui/card";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleTrigger,
|
||||
CollapsibleContent,
|
||||
} from "@/components/ui/collapsible";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
InlineTextField,
|
||||
InlineDateField,
|
||||
InlineComboboxField,
|
||||
InlineTextareaField,
|
||||
InlineFieldRow,
|
||||
ScoreLabel,
|
||||
SectionLabel,
|
||||
type ComboOption,
|
||||
} from "@/components/primitives";
|
||||
|
||||
// ===== AxisScoreRow(Pane 4 モード 2 でも使う、export) =====
|
||||
|
||||
export function AxisScoreRow({
|
||||
label,
|
||||
value,
|
||||
bold = false,
|
||||
editable = false,
|
||||
onChange,
|
||||
onReset,
|
||||
}: {
|
||||
label: string;
|
||||
value: number | null;
|
||||
bold?: boolean;
|
||||
editable?: boolean;
|
||||
onChange?: (value: number) => void;
|
||||
onReset?: () => void;
|
||||
}) {
|
||||
if (value === null && !editable) {
|
||||
return (
|
||||
<div className="flex items-center justify-between gap-2 text-sm">
|
||||
<span
|
||||
className={cn(
|
||||
"text-muted-foreground",
|
||||
bold && "font-medium text-foreground",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
<span className="flex items-center gap-2 text-muted-foreground">
|
||||
<span className="tabular-nums">—</span>
|
||||
<span className="text-[11px]">未評価</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const v = value ?? 0;
|
||||
const floor = Math.floor(v);
|
||||
const hasHalf = !editable && v - floor >= 0.5;
|
||||
return (
|
||||
<div className="flex items-center justify-between gap-2 text-sm">
|
||||
<span
|
||||
className={cn(
|
||||
"text-muted-foreground",
|
||||
bold && "font-medium text-foreground",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
<span className="flex items-center gap-2">
|
||||
<span className="flex items-center gap-0.5">
|
||||
{[1, 2, 3, 4, 5].map((n) => {
|
||||
const isFull = n <= floor;
|
||||
const isHalf = hasHalf && n === floor + 1;
|
||||
const StarComp = isHalf ? StarHalf : Star;
|
||||
const filled = isFull || isHalf;
|
||||
const starEl = (
|
||||
<StarComp
|
||||
className={cn(
|
||||
"size-3",
|
||||
filled
|
||||
? "fill-primary text-primary"
|
||||
: "fill-muted-foreground/20 text-muted-foreground/30",
|
||||
)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
);
|
||||
if (editable && onChange) {
|
||||
return (
|
||||
<button
|
||||
key={n}
|
||||
type="button"
|
||||
onClick={() => onChange(n)}
|
||||
className="rounded-sm transition-opacity outline-none hover:opacity-70 focus-visible:ring-3 focus-visible:ring-ring/50"
|
||||
aria-label={`${label} を ${n} に設定`}
|
||||
>
|
||||
{starEl}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
return <span key={n}>{starEl}</span>;
|
||||
})}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-[2.25rem] text-right text-foreground tabular-nums",
|
||||
bold && "font-medium",
|
||||
value === null && "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{value !== null ? value.toFixed(1) : "—"}
|
||||
</span>
|
||||
{editable && onReset && value !== null && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onReset}
|
||||
className="ml-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50"
|
||||
aria-label={`${label} の評価をリセット`}
|
||||
>
|
||||
<X className="size-3" />
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== ↗ ジャンプアイコン(ADR-0014 §4、常時表示) =====
|
||||
|
||||
function JumpIcon({
|
||||
selected,
|
||||
className,
|
||||
}: {
|
||||
selected: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<ArrowUpRight
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"size-4 shrink-0",
|
||||
selected ? "text-primary" : "text-muted-foreground",
|
||||
className,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== ステージアイコン(状態軸、ADR-0014 §7) =====
|
||||
|
||||
function StageIcon({ status }: { status: StageStatus }) {
|
||||
if (status === "done") {
|
||||
return (
|
||||
<span
|
||||
className="mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary"
|
||||
aria-label="完了"
|
||||
>
|
||||
<Check className="size-3" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (status === "planned") {
|
||||
return (
|
||||
<span
|
||||
className="mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground"
|
||||
aria-label="予定"
|
||||
>
|
||||
<CircleDot className="size-4" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span
|
||||
className="mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground"
|
||||
aria-label="未着手"
|
||||
>
|
||||
<Circle className="size-4" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== Card: 採用条件(ADR-0015 §19.4 追加決定 M) =====
|
||||
|
||||
function RecruitingConditionsCard({
|
||||
profile,
|
||||
setProfile,
|
||||
}: {
|
||||
profile: Profile;
|
||||
setProfile: React.Dispatch<React.SetStateAction<Profile>>;
|
||||
}) {
|
||||
const updateField = <K extends keyof Profile>(key: K, value: Profile[K]) =>
|
||||
setProfile((p) => ({ ...p, [key]: value }));
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle emphasis="prominent">
|
||||
{PANE3_SECTION.recruitingConditions}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<dl className="flex flex-col gap-2.5 text-sm">
|
||||
<InlineFieldRow label="希望年収">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="w-20">
|
||||
<InlineTextField
|
||||
value={profile.desiredSalaryMin}
|
||||
onSave={(v) => updateField("desiredSalaryMin", v)}
|
||||
ariaLabel="希望年収(下限)"
|
||||
placeholder="—"
|
||||
/>
|
||||
</div>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">〜</span>
|
||||
<div className="w-20">
|
||||
<InlineTextField
|
||||
value={profile.desiredSalaryMax}
|
||||
onSave={(v) => updateField("desiredSalaryMax", v)}
|
||||
ariaLabel="希望年収(上限)"
|
||||
placeholder="—"
|
||||
/>
|
||||
</div>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
万円
|
||||
</span>
|
||||
</div>
|
||||
</InlineFieldRow>
|
||||
<InlineFieldRow label="入社可能日">
|
||||
<InlineDateField
|
||||
value={profile.availableStartDate}
|
||||
onSave={(v) => updateField("availableStartDate", v)}
|
||||
ariaLabel="入社可能日"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
</dl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== Card: 選考フロー(ADR-0015 §19.5 担当者コメント統合版) =====
|
||||
|
||||
function ScreeningFlowListCard({
|
||||
scorecards,
|
||||
selectedDetail,
|
||||
onOpenDetail,
|
||||
}: {
|
||||
scorecards: Scorecard[];
|
||||
selectedDetail: SelectedDetail;
|
||||
onOpenDetail: (next: SelectedDetail, scrollAnchor?: string) => void;
|
||||
}) {
|
||||
const allStages: Scorecard[] = STAGE_ORDER.map(
|
||||
(stage) =>
|
||||
scorecards.find((s) => s.stage === stage) ?? {
|
||||
stage,
|
||||
label: STAGE_LABELS[stage],
|
||||
date: "",
|
||||
format: "",
|
||||
interviewer: "",
|
||||
axisScores: {
|
||||
achievements: null,
|
||||
thinkingAbility: null,
|
||||
communication: null,
|
||||
cultureFit: null,
|
||||
},
|
||||
attachments: [],
|
||||
},
|
||||
);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle emphasis="prominent">
|
||||
{PANE3_SECTION.screeningFlow}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{PANE3_SECTION.screeningFlowDescription}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex flex-col gap-1">
|
||||
{allStages.map((s, idx) => {
|
||||
const selected =
|
||||
selectedDetail?.type === "stage" &&
|
||||
selectedDetail.stage === s.stage;
|
||||
const status = deriveStageStatus(s.date, s.decision);
|
||||
const showComment = status === "done" && !!s.comment;
|
||||
|
||||
return (
|
||||
<div key={s.stage}>
|
||||
{idx > 0 && <Separator className="my-1" />}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
onOpenDetail(
|
||||
{ type: "stage", stage: s.stage },
|
||||
PANE4_SECTION_IDS.m2.info,
|
||||
)
|
||||
}
|
||||
aria-label={`Pane 4 で ${s.label} を開く`}
|
||||
className={cn(
|
||||
"flex w-full items-start gap-3 rounded-md px-2 py-2 text-left transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",
|
||||
selected
|
||||
? "bg-accent text-accent-foreground"
|
||||
: "hover:bg-muted/40",
|
||||
)}
|
||||
>
|
||||
<StageIcon status={status} />
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="text-sm font-medium text-foreground">
|
||||
{s.label}
|
||||
</span>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
{s.date && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{s.date}
|
||||
</span>
|
||||
)}
|
||||
{s.decision && (
|
||||
<Badge variant="outline" size="xs">
|
||||
{s.decision}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{s.interviewer || "未予定"}
|
||||
</p>
|
||||
{showComment && (
|
||||
<p className="mt-0.5 line-clamp-2 border-l-2 border-primary/20 pl-2 text-xs leading-relaxed text-foreground/80">
|
||||
"{s.comment}"
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<JumpIcon selected={selected} className="mt-0.5" />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 応募経路の選択肢(Pane 3 ヘッダー帯トグル内で使用) =====
|
||||
|
||||
const INITIAL_SOURCE_OPTIONS: ComboOption[] = [
|
||||
{ value: "社員リファラル", description: "既存社員からの紹介で応募" },
|
||||
{ value: "Wantedly", description: "Wantedly 経由の応募" },
|
||||
{ value: "LinkedIn", description: "LinkedIn 経由の応募" },
|
||||
{ value: "直接応募", description: "自社採用ページから直接応募" },
|
||||
{ value: "エージェント経由", description: "採用エージェントを介した応募" },
|
||||
];
|
||||
|
||||
// ===== ヘッダー帯トグル内の連絡先行 =====
|
||||
|
||||
function ContactRow({
|
||||
icon,
|
||||
label,
|
||||
children,
|
||||
}: {
|
||||
icon: React.ReactNode;
|
||||
label: string;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<li className="flex items-center gap-3">
|
||||
<span
|
||||
className="flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{icon}
|
||||
</span>
|
||||
<span className="sr-only">{label}</span>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== Card: 応募情報(折りたたみ可能) =====
|
||||
|
||||
function ApplicationInfoCardContent({
|
||||
profile,
|
||||
setProfile,
|
||||
}: {
|
||||
profile: Profile;
|
||||
setProfile: React.Dispatch<React.SetStateAction<Profile>>;
|
||||
}) {
|
||||
const [sourceOptions, setSourceOptions] = useState<ComboOption[]>(
|
||||
INITIAL_SOURCE_OPTIONS,
|
||||
);
|
||||
|
||||
const updateField = <K extends keyof Profile>(key: K, value: Profile[K]) =>
|
||||
setProfile((p) => ({ ...p, [key]: value }));
|
||||
|
||||
const handleAddSource = (newOpt: ComboOption) =>
|
||||
setSourceOptions((prev) =>
|
||||
prev.find((o) => o.value === newOpt.value) ? prev : [...prev, newOpt],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
{/* 基本(名前 / 生年月日 / 応募経路 / 採用担当) — Card タイトル「応募情報」が見出しを兼ねる */}
|
||||
<section className="flex flex-col gap-3 pb-4">
|
||||
<dl className="flex flex-col gap-2.5 text-sm">
|
||||
<InlineFieldRow label="名前">
|
||||
<InlineTextField
|
||||
value={profile.name}
|
||||
onSave={(v) => updateField("name", v)}
|
||||
ariaLabel="名前"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
<InlineFieldRow label="生年月日">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<InlineDateField
|
||||
value={profile.birthday}
|
||||
onSave={(v) => updateField("birthday", v)}
|
||||
ariaLabel="生年月日"
|
||||
/>
|
||||
</div>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
{calculateAge(profile.birthday)}
|
||||
</span>
|
||||
</div>
|
||||
</InlineFieldRow>
|
||||
<InlineFieldRow label="応募経路">
|
||||
<InlineComboboxField
|
||||
value={profile.source}
|
||||
options={sourceOptions}
|
||||
onSave={(v) => updateField("source", v)}
|
||||
onCreate={handleAddSource}
|
||||
ariaLabel="応募経路"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
<InlineFieldRow label="採用担当">
|
||||
<InlineTextField
|
||||
value={profile.recruiter}
|
||||
onSave={(v) => updateField("recruiter", v)}
|
||||
ariaLabel="採用担当"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 連絡先 */}
|
||||
<section className="flex flex-col gap-3 py-4">
|
||||
<SectionLabel>連絡先</SectionLabel>
|
||||
<ul className="flex flex-col gap-2.5">
|
||||
<ContactRow
|
||||
icon={<Mail className="size-3.5" />}
|
||||
label="メールアドレス"
|
||||
>
|
||||
<InlineTextField
|
||||
value={profile.email}
|
||||
onSave={(v) => updateField("email", v)}
|
||||
ariaLabel="メールアドレス"
|
||||
inputType="email"
|
||||
/>
|
||||
</ContactRow>
|
||||
<ContactRow icon={<Phone className="size-3.5" />} label="電話番号">
|
||||
<InlineTextField
|
||||
value={profile.phone}
|
||||
onSave={(v) => updateField("phone", v)}
|
||||
ariaLabel="電話番号"
|
||||
inputType="tel"
|
||||
/>
|
||||
</ContactRow>
|
||||
<ContactRow icon={<MapPin className="size-3.5" />} label="住所">
|
||||
<InlineTextField
|
||||
value={profile.address}
|
||||
onSave={(v) => updateField("address", v)}
|
||||
ariaLabel="住所"
|
||||
/>
|
||||
</ContactRow>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 職務経歴 */}
|
||||
<section className="flex flex-col gap-2 py-4">
|
||||
<SectionLabel>職務経歴</SectionLabel>
|
||||
<InlineTextareaField
|
||||
value={profile.careerText}
|
||||
onSave={(v) => updateField("careerText", v)}
|
||||
ariaLabel="職務経歴"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 志望動機 */}
|
||||
<section className="flex flex-col gap-2 pt-4">
|
||||
<SectionLabel>志望動機</SectionLabel>
|
||||
<InlineTextareaField
|
||||
value={profile.motivationFull}
|
||||
onSave={(v) => updateField("motivationFull", v)}
|
||||
ariaLabel="志望動機"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ApplicationInfoCard({
|
||||
profile,
|
||||
setProfile,
|
||||
open,
|
||||
onOpenChange,
|
||||
candidateKey,
|
||||
}: {
|
||||
profile: Profile;
|
||||
setProfile: React.Dispatch<React.SetStateAction<Profile>>;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
candidateKey: string;
|
||||
}) {
|
||||
return (
|
||||
<Card>
|
||||
<Collapsible open={open} onOpenChange={onOpenChange}>
|
||||
<CollapsibleTrigger
|
||||
nativeButton={false}
|
||||
render={
|
||||
<CardHeader className="group/trigger cursor-pointer rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/50" />
|
||||
}
|
||||
>
|
||||
<CardTitle emphasis="prominent">
|
||||
{PANE3_SECTION.applicationInfo}
|
||||
</CardTitle>
|
||||
<CardAction>
|
||||
<ChevronDown
|
||||
aria-hidden="true"
|
||||
className="size-4 text-muted-foreground transition-[color,transform] group-hover/trigger:text-foreground in-data-[panel-open]:rotate-180"
|
||||
/>
|
||||
<span className="sr-only">{`${PANE3_SECTION.applicationInfo}を開く`}</span>
|
||||
</CardAction>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent>
|
||||
<CardContent>
|
||||
<ApplicationInfoCardContent
|
||||
key={candidateKey}
|
||||
profile={profile}
|
||||
setProfile={setProfile}
|
||||
/>
|
||||
</CardContent>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 候補者ヘッダー(固定。Avatar + 名前 + 年齢 / スコア) =====
|
||||
|
||||
function CandidateHeader({
|
||||
profile,
|
||||
scorecards,
|
||||
}: {
|
||||
profile: Profile;
|
||||
scorecards: Scorecard[];
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-5">
|
||||
<Avatar className="size-16">
|
||||
<AvatarFallback className="bg-primary/10 text-xl text-primary">
|
||||
{profile.name[0] ?? "?"}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
||||
<h2 className="font-heading truncate text-xl font-semibold text-foreground">
|
||||
{profile.name || "名前未設定"}
|
||||
</h2>
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
{profile.birthday && <span>{calculateAge(profile.birthday)}</span>}
|
||||
{profile.birthday && <span aria-hidden="true">·</span>}
|
||||
<ScoreLabel value={getScorecardsAverageScore(scorecards)} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== Pane 3 メイン =====
|
||||
|
||||
export function CandidateDashboardPane({
|
||||
profile,
|
||||
scorecards,
|
||||
selectedDetail,
|
||||
onOpenDetail,
|
||||
setProfile,
|
||||
applicationInfoOpen,
|
||||
onApplicationInfoOpenChange,
|
||||
selectedCandidateId,
|
||||
}: {
|
||||
profile: Profile;
|
||||
scorecards: Scorecard[];
|
||||
selectedDetail: SelectedDetail;
|
||||
onOpenDetail: (next: SelectedDetail, scrollAnchor?: string) => void;
|
||||
setProfile: React.Dispatch<React.SetStateAction<Profile>>;
|
||||
applicationInfoOpen: boolean;
|
||||
onApplicationInfoOpenChange: (open: boolean) => void;
|
||||
selectedCandidateId: string;
|
||||
}) {
|
||||
return (
|
||||
<section className="min-w-0 flex-1 bg-canvas">
|
||||
<ScrollArea className="h-full">
|
||||
<div className="mx-auto flex max-w-3xl flex-col gap-4 px-8 py-8">
|
||||
<CandidateHeader profile={profile} scorecards={scorecards} />
|
||||
|
||||
<ApplicationInfoCard
|
||||
profile={profile}
|
||||
setProfile={setProfile}
|
||||
open={applicationInfoOpen}
|
||||
onOpenChange={onApplicationInfoOpenChange}
|
||||
candidateKey={selectedCandidateId}
|
||||
/>
|
||||
|
||||
<RecruitingConditionsCard profile={profile} setProfile={setProfile} />
|
||||
|
||||
<ScreeningFlowListCard
|
||||
scorecards={scorecards}
|
||||
selectedDetail={selectedDetail}
|
||||
onOpenDetail={onOpenDetail}
|
||||
/>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* Pane 4: 選考ステージ詳細パネル(ADR-0015 §19 でモード 1 を廃止)。
|
||||
*
|
||||
* ステージ詳細のみ表示する。候補者詳細(旧モード 1)は Pane 3 のヘッダー帯
|
||||
* トグル内に移管済み。起動時は畳まれた 48px 帯で、Pane 3 のステージカード
|
||||
* クリックで自動展開する。
|
||||
*
|
||||
* 規律:
|
||||
* - components/primitives/ の Inline* primitive を使う(shadcn 標準フォーム)
|
||||
* - AttachmentList を再利用(添付セクション)
|
||||
* - AxisScoreRow を CandidateDashboardPane から import
|
||||
* - ステージ切替時の state リセットは `key` 再マウントで
|
||||
*
|
||||
* `SelectedDetail` 型は `lib/schema.ts` に集約(Phase 3A)。
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Pane4Toggle } from "@/components/workspace/Pane4Toggle";
|
||||
|
||||
import {
|
||||
type AxisKey,
|
||||
type StageKey,
|
||||
type Scorecard,
|
||||
type SelectedDetail,
|
||||
AXIS_ORDER,
|
||||
} from "@/lib/schema";
|
||||
import { EVALUATION_AXIS, PANE4_SECTION_IDS } from "@/lib/labels";
|
||||
import { createMinimalScorecard } from "@/lib/data/factories";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
InlineDateField,
|
||||
InlineSelectField,
|
||||
InlineComboboxField,
|
||||
InlineTextareaField,
|
||||
InlineFieldRow,
|
||||
type ComboOption,
|
||||
} from "@/components/primitives";
|
||||
import { Pane4Section } from "@/components/workspace/Pane4Section";
|
||||
import { AxisScoreRow } from "@/components/workspace/CandidateDashboardPane";
|
||||
import { AttachmentList } from "@/components/workspace/AttachmentList";
|
||||
|
||||
// ===== Pane 4 内部型(ファイル外には出さない) =====
|
||||
|
||||
/**
|
||||
* Pane 4 モード 2 で inline 編集できる Scorecard のキー集合。
|
||||
* `onUpdateScorecardField` の `field` 引数の型として親 (Workspace.tsx) と整合させる。
|
||||
*
|
||||
* 旧実装は `date / format / interviewer / decision` の 4 フィールドのみだったが、
|
||||
* ADR-0014 でコメント / 要約も `InlineTextareaField` で編集対象にしたため
|
||||
* `comment` / `summary` を追加した。Workspace.tsx 側の `EditableScorecardKey`
|
||||
* 再宣言も同形に揃える必要がある(型を export しない設計のため両側で宣言する規律)。
|
||||
*/
|
||||
type EditableScorecardKey =
|
||||
| "date"
|
||||
| "format"
|
||||
| "interviewer"
|
||||
| "decision"
|
||||
| "comment"
|
||||
| "summary";
|
||||
|
||||
// ===== 定数(screening-lab / profile-card-lab から移植) =====
|
||||
|
||||
const FORMAT_OPTIONS = [
|
||||
"書類",
|
||||
"オンライン (Google Meet)",
|
||||
"オフライン",
|
||||
] as const;
|
||||
|
||||
const DECISION_OPTIONS = ["通過", "保留", "不合格"] as const;
|
||||
|
||||
const INITIAL_INTERVIEWER_OPTIONS: ComboOption[] = [
|
||||
{ value: "田中 花子", description: "採用担当チーム" },
|
||||
{ value: "佐藤 太郎", description: "エンジニアリングマネージャー" },
|
||||
{ value: "鈴木 一郎", description: "シニアエンジニア" },
|
||||
{ value: "山田 美咲", description: "プロダクトマネージャー" },
|
||||
];
|
||||
|
||||
// ===== 選考ステージ詳細(旧モード 2、ADR-0015 で唯一のモードに) =====
|
||||
|
||||
/**
|
||||
* モード 2(選考ステージ詳細、書類選考 / 面接 共通テンプレート)。
|
||||
* 基本情報 / 評価 / コメント / 要約 / 添付 の 5 ブロック構成(screening-lab と一致)。
|
||||
*
|
||||
* ステージ別ラベル分岐(ADR-0010 §9 G):
|
||||
* - 「面接官」フィールド: 書類選考のみ「審査担当」、それ以外は「面接官」
|
||||
* - 「要約」見出し: 書類選考のみ「書類の要約」、それ以外は「面接の要約」
|
||||
* - 「添付」見出し: 書類選考のみ「提出書類」、それ以外は「添付」
|
||||
*
|
||||
* 各フィールドは `components/primitives/` の Inline* primitive で常時表示される
|
||||
* (Type-direct)。`interviewerOptions` は候補者+ステージ単位でメモリ保持し、
|
||||
* 親側 `key` でステージ・候補者切替時に自然リセット(Effect 内同期 setState 禁止)。
|
||||
*/
|
||||
function Mode2StageDetail({
|
||||
scorecard,
|
||||
onUpdateAxis,
|
||||
onUpdateScorecardField,
|
||||
}: {
|
||||
scorecard: Scorecard;
|
||||
onUpdateAxis: (stage: StageKey, axis: AxisKey, value: number | null) => void;
|
||||
onUpdateScorecardField: (
|
||||
stage: StageKey,
|
||||
field: EditableScorecardKey,
|
||||
value: string,
|
||||
) => void;
|
||||
}) {
|
||||
const isScreening = scorecard.stage === "screening";
|
||||
const interviewerLabel = isScreening ? "審査担当" : "面接官";
|
||||
const summaryHeading = isScreening ? "書類の要約" : "面接の要約";
|
||||
const attachmentHeading = isScreening ? "提出書類" : "添付";
|
||||
|
||||
const [interviewerOptions, setInterviewerOptions] = useState<ComboOption[]>(
|
||||
INITIAL_INTERVIEWER_OPTIONS,
|
||||
);
|
||||
|
||||
const handleAddInterviewer = (newOpt: ComboOption) =>
|
||||
setInterviewerOptions((prev) =>
|
||||
prev.find((o) => o.value === newOpt.value) ? prev : [...prev, newOpt],
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* 基本情報(日時 / 形式 / 面接官 / 判定) */}
|
||||
<Pane4Section id={PANE4_SECTION_IDS.m2.info} title="基本情報">
|
||||
<dl className="flex flex-col gap-2.5 text-sm">
|
||||
<InlineFieldRow label="日時">
|
||||
<InlineDateField
|
||||
value={scorecard.date}
|
||||
onSave={(v) => onUpdateScorecardField(scorecard.stage, "date", v)}
|
||||
ariaLabel="日時"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
|
||||
<InlineFieldRow label="形式">
|
||||
<InlineSelectField
|
||||
value={scorecard.format}
|
||||
options={FORMAT_OPTIONS}
|
||||
onSave={(v) =>
|
||||
onUpdateScorecardField(scorecard.stage, "format", v)
|
||||
}
|
||||
ariaLabel="形式"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
|
||||
<InlineFieldRow label={interviewerLabel}>
|
||||
<InlineComboboxField
|
||||
value={scorecard.interviewer}
|
||||
options={interviewerOptions}
|
||||
onSave={(v) =>
|
||||
onUpdateScorecardField(scorecard.stage, "interviewer", v)
|
||||
}
|
||||
onCreate={handleAddInterviewer}
|
||||
ariaLabel={interviewerLabel}
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
|
||||
<InlineFieldRow label="判定">
|
||||
<InlineSelectField
|
||||
value={scorecard.decision ?? ""}
|
||||
options={DECISION_OPTIONS}
|
||||
onSave={(v) =>
|
||||
onUpdateScorecardField(scorecard.stage, "decision", v)
|
||||
}
|
||||
ariaLabel="判定"
|
||||
/>
|
||||
</InlineFieldRow>
|
||||
</dl>
|
||||
</Pane4Section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 評価(4 観点 ★、編集可能。★ クリックで値設定 / × でリセット) */}
|
||||
<Pane4Section id={PANE4_SECTION_IDS.m2.evaluation} title="評価">
|
||||
<div className="flex flex-col gap-2 rounded-lg border border-border bg-card px-3 py-3">
|
||||
{AXIS_ORDER.map((key) => (
|
||||
<AxisScoreRow
|
||||
key={key}
|
||||
label={EVALUATION_AXIS[key]}
|
||||
value={scorecard.axisScores[key]}
|
||||
editable
|
||||
onChange={(v) => onUpdateAxis(scorecard.stage, key, v)}
|
||||
onReset={() => onUpdateAxis(scorecard.stage, key, null)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Pane4Section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 担当者のコメント(textarea) */}
|
||||
<Pane4Section
|
||||
id={PANE4_SECTION_IDS.m2.comment}
|
||||
title="担当者のコメント"
|
||||
className="gap-2"
|
||||
>
|
||||
<InlineTextareaField
|
||||
value={scorecard.comment ?? ""}
|
||||
onSave={(v) => onUpdateScorecardField(scorecard.stage, "comment", v)}
|
||||
ariaLabel="担当者のコメント"
|
||||
/>
|
||||
</Pane4Section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 要約(書類選考: 書類の要約 / 面接: 面接の要約) */}
|
||||
<Pane4Section
|
||||
id={PANE4_SECTION_IDS.m2.summary}
|
||||
title={summaryHeading}
|
||||
className="gap-2"
|
||||
>
|
||||
<InlineTextareaField
|
||||
value={scorecard.summary ?? ""}
|
||||
onSave={(v) => onUpdateScorecardField(scorecard.stage, "summary", v)}
|
||||
ariaLabel={summaryHeading}
|
||||
/>
|
||||
</Pane4Section>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* 添付(書類選考: 提出書類 / 面接: 添付)— `AttachmentList` を再利用 */}
|
||||
<Pane4Section
|
||||
id={PANE4_SECTION_IDS.m2.attachments}
|
||||
title={attachmentHeading}
|
||||
>
|
||||
<AttachmentList items={scorecard.attachments} />
|
||||
</Pane4Section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ===== Pane 4 メイン =====
|
||||
|
||||
/**
|
||||
* Pane 4: 選考ステージ詳細パネル(ADR-0015 §19 で候補者詳細を Pane 3 に移管)。
|
||||
*
|
||||
* - ヘッダー: ステージ名 + Pane4Toggle の 2 要素(◀ は撤廃)
|
||||
* - ステージ切替: `<Mode2StageDetail key={...}>` で再マウント
|
||||
* - ステージ未選択時(selectedDetail === null 想定、Phase 3C 暫定で type=profile も
|
||||
* ステージなしとして扱う): コンテンツなし、ヘッダーのみ
|
||||
*/
|
||||
export function CandidateDetailPane({
|
||||
selectedCandidateId,
|
||||
scorecards,
|
||||
selectedDetail,
|
||||
scrollAnchor,
|
||||
onScrollAnchorConsumed,
|
||||
onUpdateAxis,
|
||||
onUpdateScorecardField,
|
||||
pane4Open,
|
||||
onTogglePane4,
|
||||
}: {
|
||||
selectedCandidateId: string;
|
||||
scorecards: Scorecard[];
|
||||
selectedDetail: SelectedDetail;
|
||||
scrollAnchor: string | null;
|
||||
onScrollAnchorConsumed: () => void;
|
||||
onUpdateAxis: (stage: StageKey, axis: AxisKey, value: number | null) => void;
|
||||
onUpdateScorecardField: (
|
||||
stage: StageKey,
|
||||
field: EditableScorecardKey,
|
||||
value: string,
|
||||
) => void;
|
||||
pane4Open: boolean;
|
||||
onTogglePane4: () => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
if (!scrollAnchor) return;
|
||||
// 1 フレーム待つのは、Pane 4 が閉状態 → 開状態へ切り替わった直後に
|
||||
// 対象セクションの DOM がレイアウトされるのを待つため。
|
||||
// unmount された場合や anchor が変わった場合は cancel して、後続の
|
||||
// `scrollIntoView` と `onScrollAnchorConsumed`(state setter)が走らないようにする。
|
||||
const id = requestAnimationFrame(() => {
|
||||
document
|
||||
.getElementById(scrollAnchor)
|
||||
?.scrollIntoView({ block: "start", behavior: "smooth" });
|
||||
onScrollAnchorConsumed();
|
||||
});
|
||||
return () => cancelAnimationFrame(id);
|
||||
}, [scrollAnchor, onScrollAnchorConsumed]);
|
||||
|
||||
const heading =
|
||||
selectedDetail?.type === "stage"
|
||||
? (scorecards.find((s) => s.stage === selectedDetail.stage)?.label ??
|
||||
"詳細")
|
||||
: "ステージ詳細";
|
||||
|
||||
return (
|
||||
<aside
|
||||
className={cn(
|
||||
"flex shrink-0 flex-col border-l border-border bg-background",
|
||||
"overflow-hidden transition-[width] duration-200 ease-linear",
|
||||
pane4Open ? "w-[400px]" : "w-12",
|
||||
)}
|
||||
>
|
||||
{pane4Open ? (
|
||||
<>
|
||||
<header className="flex h-12 shrink-0 items-center gap-2 border-b border-border px-3">
|
||||
<h2 className="flex-1 truncate text-sm font-semibold text-foreground">
|
||||
{heading}
|
||||
</h2>
|
||||
<Pane4Toggle open={pane4Open} onToggle={onTogglePane4} />
|
||||
</header>
|
||||
|
||||
<ScrollArea className="min-h-0 flex-1">
|
||||
{selectedDetail?.type === "stage" && (
|
||||
<Mode2StageDetail
|
||||
key={`${selectedCandidateId}-${selectedDetail.stage}`}
|
||||
scorecard={
|
||||
scorecards.find((s) => s.stage === selectedDetail.stage) ??
|
||||
createMinimalScorecard(selectedDetail.stage)
|
||||
}
|
||||
onUpdateAxis={onUpdateAxis}
|
||||
onUpdateScorecardField={onUpdateScorecardField}
|
||||
/>
|
||||
)}
|
||||
</ScrollArea>
|
||||
</>
|
||||
) : (
|
||||
<div className="flex h-12 shrink-0 items-center justify-center border-b border-border">
|
||||
<Pane4Toggle open={pane4Open} onToggle={onTogglePane4} />
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { MoreHorizontal, Plus, Star, Trash2 } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { type Group, type StageKey } from "@/lib/schema";
|
||||
import { DeleteConfirmDialog } from "@/components/workspace/DeleteConfirmDialog";
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { AddItemDialog } from "@/components/workspace/AddItemDialog";
|
||||
|
||||
type CandidateListPaneProps = {
|
||||
groups: Group[];
|
||||
selectedCandidateId: string;
|
||||
onSelectCandidate: (id: string) => void;
|
||||
onAddCandidate: (stage: StageKey, name: string) => void;
|
||||
onDeleteCandidate: (id: string) => void;
|
||||
};
|
||||
|
||||
export function CandidateListPane({
|
||||
groups,
|
||||
selectedCandidateId,
|
||||
onSelectCandidate,
|
||||
onAddCandidate,
|
||||
onDeleteCandidate,
|
||||
}: CandidateListPaneProps) {
|
||||
const [addDialogStage, setAddDialogStage] = useState<{
|
||||
stage: StageKey;
|
||||
label: string;
|
||||
} | null>(null);
|
||||
const [deleteTarget, setDeleteTarget] = useState<{
|
||||
id: string;
|
||||
name: string;
|
||||
} | null>(null);
|
||||
|
||||
return (
|
||||
<section className="flex w-[280px] shrink-0 flex-col border-r border-border bg-background">
|
||||
<header className="flex h-12 shrink-0 items-center border-b border-border px-3">
|
||||
<h2 className="truncate text-sm font-semibold text-foreground">
|
||||
フロントエンドエンジニア
|
||||
</h2>
|
||||
</header>
|
||||
<ScrollArea className="min-h-0 flex-1">
|
||||
<div className="flex flex-col gap-5 px-3 py-4">
|
||||
{groups.map((group) => (
|
||||
<div key={group.stage}>
|
||||
<div className="sticky top-0 z-10 -mx-3 mb-2 flex items-center justify-between gap-2 bg-background px-5 py-1.5">
|
||||
<div className="flex min-w-0 items-center gap-1.5">
|
||||
<h3 className="truncate text-xs font-medium text-muted-foreground">
|
||||
{group.label}
|
||||
</h3>
|
||||
<Badge variant="secondary" size="xs">
|
||||
{group.items.length}
|
||||
</Badge>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
onClick={() =>
|
||||
setAddDialogStage({
|
||||
stage: group.stage,
|
||||
label: group.label,
|
||||
})
|
||||
}
|
||||
aria-label={`${group.label} に候補者を追加`}
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Plus aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
<ul className="flex flex-col gap-1">
|
||||
{group.items.map((cand) => {
|
||||
const selected = cand.id === selectedCandidateId;
|
||||
return (
|
||||
<li key={cand.id} className="group/candidate relative">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onSelectCandidate(cand.id)}
|
||||
className={cn(
|
||||
"flex w-full items-center gap-3 rounded-md px-2.5 py-2.5 text-left transition-colors",
|
||||
"outline-none focus-visible:ring-3 focus-visible:ring-ring/50",
|
||||
selected
|
||||
? "bg-accent text-accent-foreground"
|
||||
: "text-foreground hover:bg-muted",
|
||||
)}
|
||||
>
|
||||
<Avatar className="size-8 shrink-0">
|
||||
<AvatarFallback className="bg-primary/10 text-xs text-primary">
|
||||
{cand.name[0] ?? "?"}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm">{cand.name}</p>
|
||||
</div>
|
||||
<span className="transition-opacity group-focus-within/candidate:opacity-0 group-hover/candidate:opacity-0">
|
||||
<ScoreBadge
|
||||
avg={cand.averageScore}
|
||||
selected={selected}
|
||||
/>
|
||||
</span>
|
||||
</button>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className={cn(
|
||||
"absolute top-1/2 right-1 -translate-y-1/2",
|
||||
"opacity-0 group-focus-within/candidate:opacity-100 group-hover/candidate:opacity-100",
|
||||
"transition-opacity",
|
||||
"text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
aria-label={`${cand.name} の操作`}
|
||||
>
|
||||
<MoreHorizontal />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<DropdownMenuContent side="right" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
variant="destructive"
|
||||
onSelect={() =>
|
||||
setDeleteTarget({
|
||||
id: cand.id,
|
||||
name: cand.name,
|
||||
})
|
||||
}
|
||||
>
|
||||
<Trash2 />
|
||||
削除
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
|
||||
{addDialogStage && (
|
||||
<AddItemDialog
|
||||
open={addDialogStage !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setAddDialogStage(null);
|
||||
}}
|
||||
title="候補者を追加"
|
||||
description={`「${addDialogStage.label}」ステージに候補者を追加します`}
|
||||
fieldLabel="氏名"
|
||||
fieldId="candidate-name"
|
||||
placeholder="例: 山田 太郎"
|
||||
onAdd={(name) => onAddCandidate(addDialogStage.stage, name)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<DeleteConfirmDialog
|
||||
open={deleteTarget !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeleteTarget(null);
|
||||
}}
|
||||
title="候補者を削除しますか?"
|
||||
itemName={deleteTarget?.name ?? ""}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
onDeleteCandidate(deleteTarget.id);
|
||||
setDeleteTarget(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function ScoreBadge({
|
||||
avg,
|
||||
selected,
|
||||
}: {
|
||||
avg: number | null;
|
||||
selected: boolean;
|
||||
}) {
|
||||
if (avg === null) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0 text-xs",
|
||||
selected ? "text-accent-foreground/80" : "text-muted-foreground",
|
||||
)}
|
||||
aria-label="未評価"
|
||||
>
|
||||
—
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex shrink-0 items-center gap-0.5 text-xs tabular-nums",
|
||||
selected ? "text-accent-foreground" : "text-foreground/80",
|
||||
)}
|
||||
aria-label={`平均スコア ${avg.toFixed(1)} / 5`}
|
||||
>
|
||||
<Star aria-hidden className="size-3 fill-current" />
|
||||
{avg.toFixed(1)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
|
||||
type DeleteConfirmDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title: string;
|
||||
itemName: string;
|
||||
onConfirm: () => void;
|
||||
};
|
||||
|
||||
export function DeleteConfirmDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
itemName,
|
||||
onConfirm,
|
||||
}: DeleteConfirmDialogProps) {
|
||||
return (
|
||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{title}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
「{itemName}」を削除します。この操作は取り消せません。
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>キャンセル</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={onConfirm}>削除</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
"use client";
|
||||
|
||||
import { Settings } from "lucide-react";
|
||||
|
||||
import { type Department } from "@/lib/schema";
|
||||
import {
|
||||
Breadcrumb,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbLink,
|
||||
BreadcrumbList,
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
} from "@/components/ui/breadcrumb";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogTrigger } from "@/components/ui/dialog";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { SettingsDialogContent } from "@/components/workspace/SettingsDialog";
|
||||
|
||||
type GlobalHeaderProps = {
|
||||
departmentTitle: string;
|
||||
positionTitle: string;
|
||||
candidateName: string;
|
||||
departments: Department[];
|
||||
onAddDepartment: (name: string) => void;
|
||||
onDeleteDepartment: (deptId: string) => void;
|
||||
};
|
||||
|
||||
export function GlobalHeader({
|
||||
departmentTitle,
|
||||
positionTitle,
|
||||
candidateName,
|
||||
departments,
|
||||
onAddDepartment,
|
||||
onDeleteDepartment,
|
||||
}: GlobalHeaderProps) {
|
||||
return (
|
||||
<header className="flex h-12 shrink-0 items-center gap-2 border-b border-border bg-background px-3">
|
||||
<Breadcrumb
|
||||
className="min-w-0 flex-1 overflow-hidden"
|
||||
aria-label="パンくず"
|
||||
>
|
||||
<BreadcrumbList className="flex-nowrap text-[11px]">
|
||||
<BreadcrumbItem className="shrink-0">
|
||||
<BreadcrumbLink>{departmentTitle}</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem className="shrink-0">
|
||||
<BreadcrumbLink>{positionTitle}</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem className="min-w-0">
|
||||
<BreadcrumbPage className="truncate font-medium">
|
||||
{candidateName}
|
||||
</BreadcrumbPage>
|
||||
</BreadcrumbItem>
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
|
||||
<Dialog>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<DialogTrigger
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
className="shrink-0 text-muted-foreground hover:text-foreground"
|
||||
aria-label="ワークスペース設定"
|
||||
>
|
||||
<Settings />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<TooltipContent side="bottom">ワークスペース設定</TooltipContent>
|
||||
</Tooltip>
|
||||
<SettingsDialogContent
|
||||
departments={departments}
|
||||
onAddDepartment={onAddDepartment}
|
||||
onDeleteDepartment={onDeleteDepartment}
|
||||
/>
|
||||
</Dialog>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* Pane 1 折りたたみトグル。shadcn/ui の SidebarTrigger は単一の `PanelLeft`
|
||||
* アイコンを使うが、本プロジェクトでは「畳むのか / 開くのか」を一目で伝える
|
||||
* ために `PanelLeftClose` / `PanelLeftOpen` を `state` で切り替えている。
|
||||
*
|
||||
* - 表示位置: Pane 1 ヘッダー右端(展開時) / Pane 1 ヘッダー中央(畳時 = rail 上部)
|
||||
* - キーボード: Cmd+B / Ctrl+B(shadcn 標準、`SidebarProvider` 側で実装)
|
||||
* - shadcn 素体(`components/ui/sidebar.tsx`)は触らず、独自トグルとしてラップする
|
||||
*
|
||||
* 仕様の出典:
|
||||
* - openspec/decision/0006-... §5「Pane 1 折りたたみトグルは
|
||||
* `PanelLeftClose` / `PanelLeftOpen` を state で切替」(本実装で追記)
|
||||
*/
|
||||
|
||||
import { PanelLeftClose, PanelLeftOpen } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useSidebar } from "@/components/ui/sidebar";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type Pane1ToggleProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function Pane1Toggle({ className }: Pane1ToggleProps) {
|
||||
const { state, toggleSidebar } = useSidebar();
|
||||
const isExpanded = state === "expanded";
|
||||
const Icon = isExpanded ? PanelLeftClose : PanelLeftOpen;
|
||||
const label = isExpanded ? "Pane 1 を閉じる" : "Pane 1 を開く";
|
||||
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
onClick={toggleSidebar}
|
||||
aria-label={label}
|
||||
title={`${label}(⌘B)`}
|
||||
className={cn("size-7 text-sidebar-foreground", className)}
|
||||
>
|
||||
<Icon />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { type ReactNode } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { SectionLabel } from "@/components/primitives";
|
||||
|
||||
type Pane4SectionProps = {
|
||||
id?: string;
|
||||
title: string;
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export function Pane4Section({
|
||||
id,
|
||||
title,
|
||||
className,
|
||||
children,
|
||||
}: Pane4SectionProps) {
|
||||
return (
|
||||
<section id={id} className={cn("flex flex-col gap-3 px-5 py-4", className)}>
|
||||
<SectionLabel>{title}</SectionLabel>
|
||||
{children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import { PanelRightClose, PanelRightOpen } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type Pane4ToggleProps = {
|
||||
open: boolean;
|
||||
onToggle: () => void;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function Pane4Toggle({ open, onToggle, className }: Pane4ToggleProps) {
|
||||
const Icon = open ? PanelRightClose : PanelRightOpen;
|
||||
const label = open ? "Pane 4 を閉じる" : "Pane 4 を開く";
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
onClick={onToggle}
|
||||
aria-label={label}
|
||||
className={cn("size-7 text-foreground", className)}
|
||||
>
|
||||
<Icon />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<TooltipContent side="left">{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { MoreHorizontal, Plus, Trash2 } from "lucide-react";
|
||||
|
||||
import { type Department } from "@/lib/schema";
|
||||
import { DeleteConfirmDialog } from "@/components/workspace/DeleteConfirmDialog";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarGroup,
|
||||
SidebarGroupAction,
|
||||
SidebarGroupContent,
|
||||
SidebarGroupLabel,
|
||||
SidebarHeader,
|
||||
SidebarMenu,
|
||||
SidebarMenuAction,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
} from "@/components/ui/sidebar";
|
||||
import { Pane1Toggle } from "@/components/workspace/Pane1Toggle";
|
||||
import { AddItemDialog } from "@/components/workspace/AddItemDialog";
|
||||
|
||||
type PositionPaneProps = {
|
||||
workspaceName: string;
|
||||
departments: Department[];
|
||||
selectedPositionName?: string;
|
||||
onAddPosition: (deptId: string, posName: string) => void;
|
||||
onDeletePosition: (deptId: string, posId: string) => void;
|
||||
};
|
||||
|
||||
export function PositionPane({
|
||||
workspaceName,
|
||||
departments,
|
||||
selectedPositionName,
|
||||
onAddPosition,
|
||||
onDeletePosition,
|
||||
}: PositionPaneProps) {
|
||||
const [addDialogDeptId, setAddDialogDeptId] = useState<string | null>(null);
|
||||
const [deleteTarget, setDeleteTarget] = useState<{
|
||||
deptId: string;
|
||||
posId: string;
|
||||
posName: string;
|
||||
} | null>(null);
|
||||
|
||||
const addDialogDept = departments.find((d) => d.id === addDialogDeptId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Sidebar
|
||||
collapsible="icon"
|
||||
className="border-r border-sidebar-border [&_[data-slot=sidebar-container]]:bg-sidebar"
|
||||
>
|
||||
<SidebarHeader className="border-b border-sidebar-border p-0">
|
||||
<div className="flex h-12 items-center justify-between gap-2 px-3 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0 group-data-[state=expanded]:px-5">
|
||||
<h2 className="truncate text-sm font-semibold text-sidebar-foreground group-data-[collapsible=icon]:hidden">
|
||||
{workspaceName}
|
||||
</h2>
|
||||
<Pane1Toggle />
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
|
||||
<SidebarContent className="px-1 py-3 group-data-[collapsible=icon]:hidden">
|
||||
{departments.map((dept) => (
|
||||
<SidebarGroup key={dept.id} className="px-1">
|
||||
<SidebarGroupLabel className="px-2 text-xs font-semibold tracking-wide text-sidebar-foreground/70 uppercase">
|
||||
{dept.name}
|
||||
</SidebarGroupLabel>
|
||||
<SidebarGroupAction
|
||||
title={`${dept.name} にポジションを追加`}
|
||||
onClick={() => setAddDialogDeptId(dept.id)}
|
||||
className="w-6 rounded-[min(var(--radius-md),10px)] text-muted-foreground hover:bg-muted hover:text-foreground [&>svg]:size-3"
|
||||
>
|
||||
<Plus />
|
||||
<span className="sr-only">{dept.name} にポジションを追加</span>
|
||||
</SidebarGroupAction>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{dept.positions.map((pos) => {
|
||||
const active = pos.name === selectedPositionName;
|
||||
return (
|
||||
<SidebarMenuItem key={pos.id}>
|
||||
<SidebarMenuButton
|
||||
tooltip={pos.name}
|
||||
isActive={active}
|
||||
aria-current={active ? "page" : undefined}
|
||||
>
|
||||
<span className="truncate">{pos.name}</span>
|
||||
<span className="ml-auto text-xs text-muted-foreground tabular-nums">
|
||||
{pos.count}
|
||||
</span>
|
||||
</SidebarMenuButton>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
render={
|
||||
<SidebarMenuAction showOnHover>
|
||||
<MoreHorizontal />
|
||||
<span className="sr-only">操作</span>
|
||||
</SidebarMenuAction>
|
||||
}
|
||||
/>
|
||||
<DropdownMenuContent side="right" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
variant="destructive"
|
||||
onSelect={() =>
|
||||
setDeleteTarget({
|
||||
deptId: dept.id,
|
||||
posId: pos.id,
|
||||
posName: pos.name,
|
||||
})
|
||||
}
|
||||
>
|
||||
<Trash2 />
|
||||
削除
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</SidebarMenuItem>
|
||||
);
|
||||
})}
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
))}
|
||||
</SidebarContent>
|
||||
</Sidebar>
|
||||
|
||||
{addDialogDept && (
|
||||
<AddItemDialog
|
||||
open={addDialogDeptId !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setAddDialogDeptId(null);
|
||||
}}
|
||||
title="ポジションを追加"
|
||||
description={`${addDialogDept.name} に新しいポジションを追加します`}
|
||||
fieldLabel="ポジション名"
|
||||
fieldId="pos-name"
|
||||
placeholder="例: データエンジニア"
|
||||
onAdd={(name) => onAddPosition(addDialogDept.id, name)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<DeleteConfirmDialog
|
||||
open={deleteTarget !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeleteTarget(null);
|
||||
}}
|
||||
title="ポジションを削除しますか?"
|
||||
itemName={deleteTarget?.posName ?? ""}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
onDeletePosition(deleteTarget.deptId, deleteTarget.posId);
|
||||
setDeleteTarget(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Plus, Trash2 } from "lucide-react";
|
||||
|
||||
import { type Department } from "@/lib/schema";
|
||||
import { DeleteConfirmDialog } from "@/components/workspace/DeleteConfirmDialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogClose,
|
||||
} from "@/components/ui/dialog";
|
||||
import { FieldGroup, Field, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
InputGroup,
|
||||
InputGroupInput,
|
||||
InputGroupAddon,
|
||||
} from "@/components/ui/input-group";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
|
||||
type SettingsDialogContentProps = {
|
||||
departments: Department[];
|
||||
onAddDepartment: (name: string) => void;
|
||||
onDeleteDepartment: (deptId: string) => void;
|
||||
};
|
||||
|
||||
export function SettingsDialogContent({
|
||||
departments,
|
||||
onAddDepartment,
|
||||
onDeleteDepartment,
|
||||
}: SettingsDialogContentProps) {
|
||||
const [newDeptName, setNewDeptName] = useState("");
|
||||
const [deleteDeptTarget, setDeleteDeptTarget] = useState<{
|
||||
id: string;
|
||||
name: string;
|
||||
} | null>(null);
|
||||
|
||||
const handleAddDept = () => {
|
||||
const trimmed = newDeptName.trim();
|
||||
if (!trimmed) return;
|
||||
onAddDepartment(trimmed);
|
||||
setNewDeptName("");
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>ワークスペース設定</DialogTitle>
|
||||
<DialogDescription>
|
||||
事業部やワークスペース名を管理します
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<FieldGroup>
|
||||
<Field>
|
||||
<FieldLabel htmlFor="settings-new-dept">事業部</FieldLabel>
|
||||
<ScrollArea className="max-h-48">
|
||||
<div className="divide-y divide-border rounded-lg border border-border">
|
||||
{departments.map((dept) => (
|
||||
<div
|
||||
key={dept.id}
|
||||
className="flex items-center justify-between px-3 py-2"
|
||||
>
|
||||
<span className="text-sm">{dept.name}</span>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
onClick={() =>
|
||||
setDeleteDeptTarget({ id: dept.id, name: dept.name })
|
||||
}
|
||||
aria-label={`${dept.name} を削除`}
|
||||
className="text-muted-foreground hover:text-destructive"
|
||||
>
|
||||
<Trash2 />
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
{departments.length === 0 && (
|
||||
<div className="px-3 py-4 text-center text-sm text-muted-foreground">
|
||||
事業部がありません
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
<InputGroup>
|
||||
<InputGroupInput
|
||||
id="settings-new-dept"
|
||||
placeholder="新しい事業部名"
|
||||
value={newDeptName}
|
||||
onChange={(e) => setNewDeptName(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") handleAddDept();
|
||||
}}
|
||||
/>
|
||||
<InputGroupAddon align="inline-end">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleAddDept}
|
||||
disabled={!newDeptName.trim()}
|
||||
>
|
||||
<Plus data-icon="inline-start" />
|
||||
追加
|
||||
</Button>
|
||||
</InputGroupAddon>
|
||||
</InputGroup>
|
||||
</Field>
|
||||
|
||||
<Separator />
|
||||
|
||||
<Field>
|
||||
<FieldLabel htmlFor="settings-workspace-name">
|
||||
ワークスペース名
|
||||
</FieldLabel>
|
||||
<Input id="settings-workspace-name" defaultValue="採用管理" />
|
||||
</Field>
|
||||
</FieldGroup>
|
||||
|
||||
<DialogFooter>
|
||||
<DialogClose render={<Button variant="outline">閉じる</Button>} />
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
open={deleteDeptTarget !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeleteDeptTarget(null);
|
||||
}}
|
||||
title="事業部を削除しますか?"
|
||||
itemName={deleteDeptTarget?.name ?? ""}
|
||||
onConfirm={() => {
|
||||
if (deleteDeptTarget) {
|
||||
onDeleteDepartment(deleteDeptTarget.id);
|
||||
setDeleteDeptTarget(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* Workspace: 4 ペインの親コンポーネント。
|
||||
*
|
||||
* - Pane 1〜4 の state(candidates / selectedCandidateId / selectedDetail)を
|
||||
* 保持し、各ペインに props として渡す。
|
||||
* `previousDetail` state は ADR-0011 §6 大決定 D で削除した(戻り先が候詳に固定
|
||||
* されたため、直前の詳細を 1 段階覚える概念が不要になった)。
|
||||
* - Pane 3 = 候補者ダッシュボード(人物軸の編集: ヘッダー帯 + 採用条件 + 選考フロー)
|
||||
* - Pane 4 = ステージ軸の編集(選考ステージ詳細のみ)
|
||||
* ADR-0015 §9 大決定 G により、Pane 4 のデフォルト state は `null`
|
||||
* (ステージ未選択 = 畳み状態)。◀ ボタンは撤廃。
|
||||
*
|
||||
* レイアウト構造(shadcn/ui Sidebar を採用、ADR-0006 §3/§5 を本実装で改訂):
|
||||
*
|
||||
* ```
|
||||
* <SidebarProvider> (h-screen, defaultOpen, Cmd+B でトグル)
|
||||
* ┌─ Sidebar (Pane 1) ─┬─ SidebarInset ─────────────────────┐
|
||||
* │ (画面最上端 │ ┌─ GlobalHeader (h-12) ─────────┐ │
|
||||
* │ 〜最下端) │ └─────────────────────────────────┘ │
|
||||
* │ collapsible="icon" │ ┌─ Pane 2 ─┬─ Pane 3 ─┬─ Pane 4 ─┐ │
|
||||
* │ 240px ↔ 48px │ │ │ │ │ │
|
||||
* └────────────────────┴─┴──────────┴──────────┴──────────┘
|
||||
* ```
|
||||
*
|
||||
* - Pane 1 のみ画面最上端〜最下端まで届く chrome(折りたたみ可)
|
||||
* - GlobalHeader は Pane 1 を除く右側全幅(Pane 2 / Pane 3 / Pane 4 の上)に渡る
|
||||
* - Pane 4 はヘッダー直下から最下端まで
|
||||
* - Pane 1 折りたたみトグルは Pane 1 ヘッダー右端の `Pane1Toggle` 1 箇所
|
||||
* (ADR-0006 §5 で計画していた GlobalHeader 側の SidebarTrigger は本実装で撤回)
|
||||
*
|
||||
* 仕様の出典:
|
||||
* - openspec/decision/0006-pane-background-hierarchy-and-shadcn-inset-header.md
|
||||
* §2(4 段階背景色階層)/ §4(保存ステータス削除)はそのまま採用
|
||||
* §3(Pane 4 = 画面最上端〜最下端 / ヘッダーは中央エリアのみ)は本実装で再改訂
|
||||
* §5(SidebarTrigger は GlobalHeader)も本実装で再改訂(Pane 1 ヘッダー側に集約)
|
||||
* - openspec/decision/0009-drilldown-card-affordance.md(Pane 3 ドリルダウンカードの ▶ 規律)
|
||||
* - openspec/changes/add-4pane-workspace-template/specs/workspace-template/spec.md
|
||||
* - openspec/changes/add-4pane-workspace-template/design.md D51〜D56 / D65
|
||||
*/
|
||||
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
|
||||
import {
|
||||
type Profile,
|
||||
type AxisKey,
|
||||
type StageKey,
|
||||
type Department,
|
||||
type Candidate,
|
||||
type Group,
|
||||
type SelectedDetail,
|
||||
STAGE_ORDER,
|
||||
} from "@/lib/schema";
|
||||
import {
|
||||
createMinimalProfile,
|
||||
createMinimalScorecard,
|
||||
} from "@/lib/data/factories";
|
||||
import { getCandidateAverageScore } from "@/lib/computed/scorecards";
|
||||
import { STAGE_LABELS } from "@/lib/labels";
|
||||
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
|
||||
import { GlobalHeader } from "@/components/workspace/GlobalHeader";
|
||||
import { PositionPane } from "@/components/workspace/PositionPane";
|
||||
import { CandidateListPane } from "@/components/workspace/CandidateListPane";
|
||||
import { CandidateDashboardPane } from "@/components/workspace/CandidateDashboardPane";
|
||||
import { CandidateDetailPane } from "@/components/workspace/CandidateDetailPane";
|
||||
|
||||
// ========== UI 内部型 ==========
|
||||
//
|
||||
// 種データは `data/*.json` → Server Component(app/page.tsx)で Zod parse → props で受け取る。
|
||||
// ヘルパー関数(createMinimalProfile / createMinimalScorecard)は `lib/data/factories.ts`。
|
||||
// Pane 2 の表示用派生型 (CandidateRow / Group) と `SelectedDetail` 型は
|
||||
// `lib/schema.ts` に集約(複数ペインで共有するため)。
|
||||
// Pane 4 モード 2 用の `EditableScorecardKey` は
|
||||
// `components/workspace/CandidateDetailPane.tsx` 内部の閉じた型。
|
||||
|
||||
// `updateScorecardField` の field 引数で使う key の union 型。Pane 4 内部の
|
||||
// `EditableScorecardKey` と同形。CandidateDetailPane 内部に閉じた型として扱い
|
||||
// たいため export せず、親側で同じ形を再宣言して持つ。
|
||||
//
|
||||
// ADR-0014「shadcn 標準フォームによる Pane 4 編集 UI」で `comment` / `summary`
|
||||
// を `InlineTextareaField` で編集対象に追加したため、旧 4 フィールドから 6 フィールド
|
||||
// に拡張。CandidateDetailPane.tsx 側の同型宣言(line 70-76)と同期させる。
|
||||
// `onUpdateScorecardField` 実装本体は `[field]: value` のスプレッドで
|
||||
// 動作するため、ロジックの追加修正は不要。
|
||||
type EditableScorecardKey =
|
||||
| "date"
|
||||
| "format"
|
||||
| "interviewer"
|
||||
| "decision"
|
||||
| "comment"
|
||||
| "summary";
|
||||
|
||||
type WorkspaceProps = {
|
||||
initialDepartments: Department[];
|
||||
initialCandidates: Candidate[];
|
||||
workspace: { name: string; icon: string };
|
||||
};
|
||||
|
||||
export function Workspace({
|
||||
initialDepartments,
|
||||
initialCandidates,
|
||||
workspace,
|
||||
}: WorkspaceProps) {
|
||||
const [departments, setDepartments] =
|
||||
useState<Department[]>(initialDepartments);
|
||||
const [candidates, setCandidates] = useState<Candidate[]>(initialCandidates);
|
||||
const [selectedCandidateId, setSelectedCandidateId] = useState<string>("c2");
|
||||
const [selectedDetail, setSelectedDetail] = useState<SelectedDetail>(null);
|
||||
const [scrollAnchor, setScrollAnchor] = useState<string | null>(null);
|
||||
// ユーザーが手動で Pane 4 を畳んだか。ステージ選択は保持しつつ畳む用途。
|
||||
const [pane4ManuallyClosed, setPane4ManuallyClosed] = useState(false);
|
||||
// Pane 3 ヘッダー帯(Collapsible)の開閉。候補者切替で閉じ、新規追加で開く。
|
||||
const [applicationInfoOpen, setApplicationInfoOpen] = useState(false);
|
||||
|
||||
// Pane 4 の展開状態を派生計算(ADR-0015 §9 大決定 G)。
|
||||
// selectedDetail !== null かつ手動で畳んでいない → 開いている。
|
||||
const pane4Open = selectedDetail !== null && !pane4ManuallyClosed;
|
||||
|
||||
// アクティブ候補者を取得。`INITIAL_CANDIDATES` が常に最低 1 名持つ前提だが、
|
||||
// 万一 find が undefined を返す(未来に candidates の削除機能が入った場合等)
|
||||
// ケースに備えて先頭候補者にフォールバックする。
|
||||
const activeCandidate =
|
||||
candidates.find((c) => c.id === selectedCandidateId) ?? candidates[0];
|
||||
const profile = activeCandidate.profile;
|
||||
const scorecards = activeCandidate.scorecards;
|
||||
|
||||
// Mode1ProfileDetail は `setProfile: React.Dispatch<React.SetStateAction<Profile>>`
|
||||
// を期待している(採用案 X)。子コンポーネント側の signature を変えないために、
|
||||
// candidates 配列を更新するアダプタをここで作る。
|
||||
// 関数形 (p => next) と値形 (next) の両方に対応する。
|
||||
const setProfile = useCallback<React.Dispatch<React.SetStateAction<Profile>>>(
|
||||
(action) => {
|
||||
setCandidates((prev) =>
|
||||
prev.map((c) => {
|
||||
if (c.id !== selectedCandidateId) return c;
|
||||
const next =
|
||||
typeof action === "function" ? action(c.profile) : action;
|
||||
return { ...c, profile: next };
|
||||
}),
|
||||
);
|
||||
},
|
||||
[selectedCandidateId],
|
||||
);
|
||||
|
||||
const openDetail = useCallback(
|
||||
(next: SelectedDetail, anchor?: string) => {
|
||||
if (next?.type === "stage") {
|
||||
setCandidates((prev) =>
|
||||
prev.map((c) => {
|
||||
if (c.id !== selectedCandidateId) return c;
|
||||
if (c.scorecards.some((s) => s.stage === next.stage)) return c;
|
||||
return {
|
||||
...c,
|
||||
scorecards: [...c.scorecards, createMinimalScorecard(next.stage)],
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
setSelectedDetail(next);
|
||||
setScrollAnchor(anchor ?? null);
|
||||
setPane4ManuallyClosed(false);
|
||||
},
|
||||
[selectedCandidateId],
|
||||
);
|
||||
|
||||
// Pane 2 の候補者行クリックでアクティブ候補者を切り替える。
|
||||
// - selectedDetail が「ステージ詳細」だった場合、新候補者にそのステージの
|
||||
// scorecard が無ければ Pane 4 を **候補者詳細にフォールバック**する
|
||||
// (ADR-0011 §7 大決定 E、旧 null フォールバックを撤回)。c2 以外は
|
||||
// scorecards: [] のため、c2 → 別候補者の切替時はほぼ常に候詳へフォールバック。
|
||||
// - selectedDetail が「候補者詳細」のときは維持してよい(profile はどの候補者にも
|
||||
// 必ず存在する)。
|
||||
// - previousDetail state は ADR-0011 §6 大決定 D で削除済みのため、リセット不要。
|
||||
const selectCandidate = useCallback((id: string) => {
|
||||
setSelectedCandidateId(id);
|
||||
setSelectedDetail(null);
|
||||
setApplicationInfoOpen(false);
|
||||
setPane4ManuallyClosed(false);
|
||||
}, []);
|
||||
|
||||
const addCandidate = useCallback((stage: StageKey, name: string) => {
|
||||
const newId = `c-${Date.now()}`;
|
||||
const newCandidate: Candidate = {
|
||||
id: newId,
|
||||
profile: createMinimalProfile(name),
|
||||
scorecards: [],
|
||||
stage,
|
||||
};
|
||||
setCandidates((prev) => [...prev, newCandidate]);
|
||||
setSelectedCandidateId(newId);
|
||||
setSelectedDetail(null);
|
||||
setApplicationInfoOpen(true);
|
||||
setPane4ManuallyClosed(false);
|
||||
}, []);
|
||||
|
||||
const deleteCandidate = useCallback((id: string) => {
|
||||
setCandidates((prev) => {
|
||||
const next = prev.filter((c) => c.id !== id);
|
||||
setSelectedCandidateId((prevId) => {
|
||||
if (prevId !== id) return prevId;
|
||||
return next.length > 0 ? next[0].id : "";
|
||||
});
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const addDepartment = useCallback((name: string) => {
|
||||
setDepartments((prev) => [
|
||||
...prev,
|
||||
{ id: `d-${Date.now()}`, name, positions: [] },
|
||||
]);
|
||||
}, []);
|
||||
|
||||
const deleteDepartment = useCallback((deptId: string) => {
|
||||
setDepartments((prev) => prev.filter((d) => d.id !== deptId));
|
||||
}, []);
|
||||
|
||||
const addPosition = useCallback((deptId: string, posName: string) => {
|
||||
setDepartments((prev) =>
|
||||
prev.map((d) =>
|
||||
d.id === deptId
|
||||
? {
|
||||
...d,
|
||||
positions: [
|
||||
...d.positions,
|
||||
{ id: `p-${Date.now()}`, name: posName, count: 0 },
|
||||
],
|
||||
}
|
||||
: d,
|
||||
),
|
||||
);
|
||||
}, []);
|
||||
|
||||
const deletePosition = useCallback((deptId: string, posId: string) => {
|
||||
setDepartments((prev) =>
|
||||
prev.map((d) =>
|
||||
d.id === deptId
|
||||
? { ...d, positions: d.positions.filter((p) => p.id !== posId) }
|
||||
: d,
|
||||
),
|
||||
);
|
||||
}, []);
|
||||
|
||||
// 評価観点 ★ の編集ハンドラ。フェーズ 3A から「アクティブ候補者」の
|
||||
// scorecards を更新する形に変更(candidates 配列の中の該当候補者だけを差し替え)。
|
||||
const updateAxisScore = useCallback(
|
||||
(stage: StageKey, axis: AxisKey, value: number | null) => {
|
||||
setCandidates((prev) =>
|
||||
prev.map((c) =>
|
||||
c.id === selectedCandidateId
|
||||
? {
|
||||
...c,
|
||||
scorecards: c.scorecards.map((s) =>
|
||||
s.stage === stage
|
||||
? { ...s, axisScores: { ...s.axisScores, [axis]: value } }
|
||||
: s,
|
||||
),
|
||||
}
|
||||
: c,
|
||||
),
|
||||
);
|
||||
},
|
||||
[selectedCandidateId],
|
||||
);
|
||||
|
||||
// Pane 4 モード 2「メタ情報」の inline edit から呼ばれる。
|
||||
// `decision` だけ undefined を許すため、空文字は undefined として扱う
|
||||
// (`MetaRow` 廃止前の "未判定" 表示の代替: `EditableFieldRow` 側で空 = "未設定")。
|
||||
// フェーズ 3A: アクティブ候補者の scorecards を更新する形に変更。
|
||||
const updateScorecardField = useCallback(
|
||||
(stage: StageKey, field: EditableScorecardKey, value: string) => {
|
||||
setCandidates((prev) =>
|
||||
prev.map((c) =>
|
||||
c.id === selectedCandidateId
|
||||
? {
|
||||
...c,
|
||||
scorecards: c.scorecards.map((s) => {
|
||||
if (s.stage !== stage) return s;
|
||||
if (field === "decision") {
|
||||
const trimmed = value.trim();
|
||||
return {
|
||||
...s,
|
||||
decision: trimmed === "" ? undefined : trimmed,
|
||||
};
|
||||
}
|
||||
return { ...s, [field]: value };
|
||||
}),
|
||||
}
|
||||
: c,
|
||||
),
|
||||
);
|
||||
},
|
||||
[selectedCandidateId],
|
||||
);
|
||||
|
||||
// Pane 4 内の `useEffect` 依存安定化のため、Workspace 側でメモ化して props で渡す。
|
||||
const consumeScrollAnchor = useCallback(() => setScrollAnchor(null), []);
|
||||
const togglePane4 = useCallback(() => setPane4ManuallyClosed((v) => !v), []);
|
||||
|
||||
const positionTitle = "フロントエンドエンジニア";
|
||||
const departmentTitle = "プロダクト開発";
|
||||
|
||||
const candidateGroups: Group[] = useMemo(
|
||||
() =>
|
||||
STAGE_ORDER.map((stage) => ({
|
||||
stage,
|
||||
label: STAGE_LABELS[stage],
|
||||
items: candidates
|
||||
.filter((c) => c.stage === stage)
|
||||
.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.profile.name,
|
||||
averageScore: getCandidateAverageScore(c),
|
||||
})),
|
||||
})).filter((g) => g.items.length > 0),
|
||||
[candidates],
|
||||
);
|
||||
|
||||
return (
|
||||
// shadcn/ui の SidebarProvider が外側を取り、Pane 1 (`<Sidebar>`) を全高で固定
|
||||
// 表示する。SidebarInset が右側ブロック(GlobalHeader + Pane 2/3/4)を担う。
|
||||
// Cmd+B のキーバインドは SidebarProvider 側で標準実装されている。
|
||||
// SidebarProvider のラッパー div は既定 `min-h-svh w-full`。雛形では
|
||||
// ビューポート高に固定したいので h-screen を併記し、ペイン内で min-h-0 が
|
||||
// 効くようにする(既存 ScrollArea の挙動と整合)。
|
||||
<SidebarProvider
|
||||
defaultOpen
|
||||
className="h-screen w-full overflow-hidden bg-background text-foreground"
|
||||
>
|
||||
<PositionPane
|
||||
workspaceName={workspace.name}
|
||||
departments={departments}
|
||||
selectedPositionName={positionTitle}
|
||||
onAddPosition={addPosition}
|
||||
onDeletePosition={deletePosition}
|
||||
/>
|
||||
<SidebarInset className="flex min-w-0 flex-col bg-background">
|
||||
<GlobalHeader
|
||||
departmentTitle={departmentTitle}
|
||||
positionTitle={positionTitle}
|
||||
candidateName={profile.name}
|
||||
departments={departments}
|
||||
onAddDepartment={addDepartment}
|
||||
onDeleteDepartment={deleteDepartment}
|
||||
/>
|
||||
{/* SidebarInset 自体が <main> を出すので、内側は <div> で組み、
|
||||
Pane 2 / Pane 3 / Pane 4 を横並びにする。 */}
|
||||
<div className="flex min-h-0 flex-1">
|
||||
<CandidateListPane
|
||||
groups={candidateGroups}
|
||||
selectedCandidateId={selectedCandidateId}
|
||||
onSelectCandidate={selectCandidate}
|
||||
onAddCandidate={addCandidate}
|
||||
onDeleteCandidate={deleteCandidate}
|
||||
/>
|
||||
<CandidateDashboardPane
|
||||
profile={profile}
|
||||
scorecards={scorecards}
|
||||
selectedDetail={selectedDetail}
|
||||
onOpenDetail={openDetail}
|
||||
setProfile={setProfile}
|
||||
applicationInfoOpen={applicationInfoOpen}
|
||||
onApplicationInfoOpenChange={setApplicationInfoOpen}
|
||||
selectedCandidateId={selectedCandidateId}
|
||||
/>
|
||||
<CandidateDetailPane
|
||||
selectedCandidateId={selectedCandidateId}
|
||||
scorecards={scorecards}
|
||||
selectedDetail={selectedDetail}
|
||||
scrollAnchor={scrollAnchor}
|
||||
onScrollAnchorConsumed={consumeScrollAnchor}
|
||||
onUpdateAxis={updateAxisScore}
|
||||
onUpdateScorecardField={updateScorecardField}
|
||||
pane4Open={pane4Open}
|
||||
onTogglePane4={togglePane4}
|
||||
/>
|
||||
</div>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user