create-einja-app 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1041 -0
- package/dist/cli.js.map +1 -0
- package/package.json +62 -0
- package/templates/turborepo-pandacss/.biomeignore +15 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/biome-format.sh +49 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/design-doc-check.sh +61 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/detect-secrets.sh +62 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/large-file-warning.sh +42 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/playwright-resize.sh +36 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/typecheck.sh +37 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/unset-volta-recursion.sh +32 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/validate-git-commit.sh +239 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/warn-index-ts.sh +34 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/warn-relative-import.sh +48 -0
- package/templates/turborepo-pandacss/.claude/settings.json +174 -0
- package/templates/turborepo-pandacss/.claude/skills/create-einja-app-release/SKILL.md +186 -0
- package/templates/turborepo-pandacss/.claude/skills/dev-cli-release/SKILL.md +173 -0
- package/templates/turborepo-pandacss/.cursor/commands/spec-create.md +227 -0
- package/templates/turborepo-pandacss/.cursor/commands/start-dev.md +98 -0
- package/templates/turborepo-pandacss/.cursor/commands/task-exec.md +287 -0
- package/templates/turborepo-pandacss/.cursor/commands/task-vibe-kanban-loop.md +532 -0
- package/templates/turborepo-pandacss/.cursor/commands/update-docs-by-task-specs.md +448 -0
- package/templates/turborepo-pandacss/.cursor/mcp.json +45 -0
- package/templates/turborepo-pandacss/.cursor/rules/api-rules.mdc +171 -0
- package/templates/turborepo-pandacss/.cursor/rules/api-test-rules.mdc +181 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-code.mdc +70 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-commit-rules.mdc +174 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-design.mdc +12 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-rules.mdc +231 -0
- package/templates/turborepo-pandacss/.cursor/rules/error-handling-rules.mdc +188 -0
- package/templates/turborepo-pandacss/.cursor/rules/refactor-rules.mdc +93 -0
- package/templates/turborepo-pandacss/.dockerignore +126 -0
- package/templates/turborepo-pandacss/.einja-sync.json +35 -0
- package/templates/turborepo-pandacss/.env.ci +25 -0
- package/templates/turborepo-pandacss/.env.example +35 -0
- package/templates/turborepo-pandacss/.env.personal.example +27 -0
- package/templates/turborepo-pandacss/.envrc +4 -0
- package/templates/turborepo-pandacss/.gitattributes +5 -0
- package/templates/turborepo-pandacss/.husky/pre-commit +1 -0
- package/templates/turborepo-pandacss/.lintstagedrc.js +24 -0
- package/templates/turborepo-pandacss/.mcp.json +45 -0
- package/templates/turborepo-pandacss/.node-version +1 -0
- package/templates/turborepo-pandacss/.templateignore +60 -0
- package/templates/turborepo-pandacss/.vscode/extensions.json +3 -0
- package/templates/turborepo-pandacss/CLAUDE.md +415 -0
- package/templates/turborepo-pandacss/README.md +322 -0
- package/templates/turborepo-pandacss/apps/web/middleware.ts +28 -0
- package/templates/turborepo-pandacss/apps/web/next.config.ts +10 -0
- package/templates/turborepo-pandacss/apps/web/package.json +80 -0
- package/templates/turborepo-pandacss/apps/web/panda.config.ts +114 -0
- package/templates/turborepo-pandacss/apps/web/postcss.config.cjs +6 -0
- package/templates/turborepo-pandacss/apps/web/public/file.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/globe.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/next.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/vercel.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/window.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/dashboard/page.tsx +79 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/data/_components/UserTable.tsx +203 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/data/page.tsx +57 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/layout-client.tsx +31 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/layout.tsx +17 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/profile/page.tsx +59 -0
- package/templates/turborepo-pandacss/apps/web/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/turborepo-pandacss/apps/web/src/app/api/auth/signup/route.ts +70 -0
- package/templates/turborepo-pandacss/apps/web/src/app/error.tsx +106 -0
- package/templates/turborepo-pandacss/apps/web/src/app/favicon.ico +0 -0
- package/templates/turborepo-pandacss/apps/web/src/app/global-error.tsx +110 -0
- package/templates/turborepo-pandacss/apps/web/src/app/globals.css +121 -0
- package/templates/turborepo-pandacss/apps/web/src/app/layout.tsx +28 -0
- package/templates/turborepo-pandacss/apps/web/src/app/not-found.tsx +54 -0
- package/templates/turborepo-pandacss/apps/web/src/app/page.module.css +165 -0
- package/templates/turborepo-pandacss/apps/web/src/app/page.test.tsx +52 -0
- package/templates/turborepo-pandacss/apps/web/src/app/page.tsx +284 -0
- package/templates/turborepo-pandacss/apps/web/src/app/signin/page.tsx +296 -0
- package/templates/turborepo-pandacss/apps/web/src/app/signup/page.tsx +395 -0
- package/templates/turborepo-pandacss/apps/web/src/application/use-cases/UserUseCases.test.ts +229 -0
- package/templates/turborepo-pandacss/apps/web/src/application/use-cases/UserUseCases.ts +115 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/login-button.tsx +35 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/logout-button.tsx +24 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/user-avatar.test.tsx +68 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/user-avatar.tsx +43 -0
- package/templates/turborepo-pandacss/apps/web/src/components/dashboard/dashboard-stats.tsx +128 -0
- package/templates/turborepo-pandacss/apps/web/src/components/providers/query-provider.tsx +30 -0
- package/templates/turborepo-pandacss/apps/web/src/components/providers/session-provider.tsx +12 -0
- package/templates/turborepo-pandacss/apps/web/src/components/shared/Sidebar.tsx +175 -0
- package/templates/turborepo-pandacss/apps/web/src/components/shared/header.tsx +166 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/accordion.tsx +64 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/alert-dialog.tsx +135 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/alert.tsx +60 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/aspect-ratio.tsx +9 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/avatar.tsx +41 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/badge.tsx +39 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/breadcrumb.tsx +101 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/button.tsx +56 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/card.tsx +75 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/checkbox.tsx +29 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/data-table.tsx +189 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/dialog-hook.tsx +210 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/dialog.tsx +129 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/drawer.tsx +124 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/dropdown-menu.tsx +228 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/form.tsx +152 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/hover-card.tsx +38 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/input.tsx +21 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/label.tsx +21 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/pagination.tsx +105 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/popover.tsx +42 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/progress.tsx +28 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/select.tsx +170 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/separator.tsx +28 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/skeleton.tsx +13 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/sonner.tsx +25 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/table.tsx +92 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/tabs.tsx +54 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/textarea.tsx +18 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/tooltip.tsx +57 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/typography.tsx +158 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/auth/guard.ts +36 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/auth/index.ts +22 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/prisma.ts +3 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/utils.ts +6 -0
- package/templates/turborepo-pandacss/apps/web/test/globals.d.ts +1 -0
- package/templates/turborepo-pandacss/apps/web/test/matchers.d.ts +1 -0
- package/templates/turborepo-pandacss/apps/web/test/setup.ts +22 -0
- package/templates/turborepo-pandacss/apps/web/tsconfig.json +37 -0
- package/templates/turborepo-pandacss/apps/web/vitest.config.ts +20 -0
- package/templates/turborepo-pandacss/apps/web/vitest.d.ts +2 -0
- package/templates/turborepo-pandacss/biome.json +60 -0
- package/templates/turborepo-pandacss/components.json +21 -0
- package/templates/turborepo-pandacss/docker-compose.yml +27 -0
- package/templates/turborepo-pandacss/middleware.ts +32 -0
- package/templates/turborepo-pandacss/next.config.ts +10 -0
- package/templates/turborepo-pandacss/package-lock.json +9346 -0
- package/templates/turborepo-pandacss/package.json +64 -0
- package/templates/turborepo-pandacss/packages/config/package.json +41 -0
- package/templates/turborepo-pandacss/packages/config/panda.config.ts +114 -0
- package/templates/turborepo-pandacss/packages/config/src/index.ts +24 -0
- package/templates/turborepo-pandacss/packages/config/src/worktree-config-loader.ts +129 -0
- package/templates/turborepo-pandacss/packages/config/src/worktree-config.ts +75 -0
- package/templates/turborepo-pandacss/packages/config/tsconfig.build.json +19 -0
- package/templates/turborepo-pandacss/packages/config/tsconfig.json +24 -0
- package/templates/turborepo-pandacss/packages/config/typescript/base.json +19 -0
- package/templates/turborepo-pandacss/packages/front-core/package.json +24 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/config.ts +84 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/index.ts +5 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/types/next-auth.d.ts +20 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/utils.ts +29 -0
- package/templates/turborepo-pandacss/packages/front-core/src/context/index.ts +2 -0
- package/templates/turborepo-pandacss/packages/front-core/src/hooks/index.ts +2 -0
- package/templates/turborepo-pandacss/packages/front-core/src/index.ts +4 -0
- package/templates/turborepo-pandacss/packages/front-core/src/utils/index.ts +2 -0
- package/templates/turborepo-pandacss/packages/front-core/tsconfig.json +14 -0
- package/templates/turborepo-pandacss/packages/server-core/package.json +32 -0
- package/templates/turborepo-pandacss/packages/server-core/prisma/schema.prisma +102 -0
- package/templates/turborepo-pandacss/packages/server-core/prisma/seed.ts +67 -0
- package/templates/turborepo-pandacss/packages/server-core/prisma.config.ts +8 -0
- package/templates/turborepo-pandacss/packages/server-core/src/__generated__/fabbrica/index.d.ts +270 -0
- package/templates/turborepo-pandacss/packages/server-core/src/__generated__/fabbrica/index.js +484 -0
- package/templates/turborepo-pandacss/packages/server-core/src/core/result.test.ts +78 -0
- package/templates/turborepo-pandacss/packages/server-core/src/core/result.ts +53 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/.gitkeep +0 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/entities/User.test.ts +232 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/entities/User.ts +105 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/repository-interfaces/IUserRepository.ts +101 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/client.ts +15 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/mappers/UserMapper.test.ts +278 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/mappers/UserMapper.ts +103 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/repositories/UserRepository.test.ts +317 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/repositories/UserRepository.ts +169 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/factories/index.ts +22 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/factories/user.factory.ts +123 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/fixtures/users.ts +92 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/helpers/date.ts +49 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/helpers/password.ts +50 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/index.ts +26 -0
- package/templates/turborepo-pandacss/packages/server-core/tsconfig.json +14 -0
- package/templates/turborepo-pandacss/packages/server-core/vitest.config.ts +15 -0
- package/templates/turborepo-pandacss/packages/ui/package.json +37 -0
- package/templates/turborepo-pandacss/packages/ui/src/accordion.tsx +66 -0
- package/templates/turborepo-pandacss/packages/ui/src/alert-dialog.tsx +157 -0
- package/templates/turborepo-pandacss/packages/ui/src/alert.tsx +66 -0
- package/templates/turborepo-pandacss/packages/ui/src/aspect-ratio.tsx +11 -0
- package/templates/turborepo-pandacss/packages/ui/src/avatar.tsx +53 -0
- package/templates/turborepo-pandacss/packages/ui/src/badge.tsx +46 -0
- package/templates/turborepo-pandacss/packages/ui/src/breadcrumb.tsx +108 -0
- package/templates/turborepo-pandacss/packages/ui/src/button.tsx +59 -0
- package/templates/turborepo-pandacss/packages/ui/src/card.tsx +92 -0
- package/templates/turborepo-pandacss/packages/ui/src/checkbox.tsx +32 -0
- package/templates/turborepo-pandacss/packages/ui/src/data-table.tsx +216 -0
- package/templates/turborepo-pandacss/packages/ui/src/dialog-hook.tsx +226 -0
- package/templates/turborepo-pandacss/packages/ui/src/dialog.tsx +143 -0
- package/templates/turborepo-pandacss/packages/ui/src/drawer.tsx +135 -0
- package/templates/turborepo-pandacss/packages/ui/src/dropdown-menu.tsx +257 -0
- package/templates/turborepo-pandacss/packages/ui/src/form.tsx +168 -0
- package/templates/turborepo-pandacss/packages/ui/src/hover-card.tsx +44 -0
- package/templates/turborepo-pandacss/packages/ui/src/input.tsx +21 -0
- package/templates/turborepo-pandacss/packages/ui/src/label.tsx +24 -0
- package/templates/turborepo-pandacss/packages/ui/src/lib/utils.ts +6 -0
- package/templates/turborepo-pandacss/packages/ui/src/pagination.tsx +126 -0
- package/templates/turborepo-pandacss/packages/ui/src/popover.tsx +48 -0
- package/templates/turborepo-pandacss/packages/ui/src/progress.tsx +31 -0
- package/templates/turborepo-pandacss/packages/ui/src/select.tsx +185 -0
- package/templates/turborepo-pandacss/packages/ui/src/separator.tsx +28 -0
- package/templates/turborepo-pandacss/packages/ui/src/skeleton.tsx +13 -0
- package/templates/turborepo-pandacss/packages/ui/src/sonner.tsx +25 -0
- package/templates/turborepo-pandacss/packages/ui/src/table.tsx +116 -0
- package/templates/turborepo-pandacss/packages/ui/src/tabs.tsx +66 -0
- package/templates/turborepo-pandacss/packages/ui/src/textarea.tsx +18 -0
- package/templates/turborepo-pandacss/packages/ui/src/tooltip.tsx +61 -0
- package/templates/turborepo-pandacss/packages/ui/src/typography.tsx +187 -0
- package/templates/turborepo-pandacss/packages/ui/tsconfig.json +20 -0
- package/templates/turborepo-pandacss/panda.config.ts +114 -0
- package/templates/turborepo-pandacss/pnpm-lock.yaml +9032 -0
- package/templates/turborepo-pandacss/pnpm-workspace.yaml +11 -0
- package/templates/turborepo-pandacss/postcss.config.cjs +6 -0
- package/templates/turborepo-pandacss/prisma/schema.prisma +82 -0
- package/templates/turborepo-pandacss/public/file.svg +1 -0
- package/templates/turborepo-pandacss/public/globe.svg +1 -0
- package/templates/turborepo-pandacss/public/next.svg +1 -0
- package/templates/turborepo-pandacss/public/vercel.svg +1 -0
- package/templates/turborepo-pandacss/public/window.svg +1 -0
- package/templates/turborepo-pandacss/scripts/cli-template-update.ts +387 -0
- package/templates/turborepo-pandacss/scripts/env-show.ts +129 -0
- package/templates/turborepo-pandacss/scripts/env.ts +555 -0
- package/templates/turborepo-pandacss/scripts/init.sh +92 -0
- package/templates/turborepo-pandacss/scripts/setup-dev.ts +640 -0
- package/templates/turborepo-pandacss/scripts/template-update.ts +277 -0
- package/templates/turborepo-pandacss/scripts/worktree/dev.ts +872 -0
- package/templates/turborepo-pandacss/test/globals.d.ts +1 -0
- package/templates/turborepo-pandacss/test/setup.ts +22 -0
- package/templates/turborepo-pandacss/tsconfig.json +46 -0
- package/templates/turborepo-pandacss/turbo.json +57 -0
- package/templates/turborepo-pandacss/vitest.config.ts +20 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ColumnDef,
|
|
5
|
+
type ColumnFiltersState,
|
|
6
|
+
type SortingState,
|
|
7
|
+
type VisibilityState,
|
|
8
|
+
flexRender,
|
|
9
|
+
getCoreRowModel,
|
|
10
|
+
getFilteredRowModel,
|
|
11
|
+
getPaginationRowModel,
|
|
12
|
+
getSortedRowModel,
|
|
13
|
+
useReactTable,
|
|
14
|
+
} from "@tanstack/react-table";
|
|
15
|
+
|
|
16
|
+
import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
|
|
17
|
+
import { useState } from "react";
|
|
18
|
+
import { Button } from "./button";
|
|
19
|
+
import {
|
|
20
|
+
DropdownMenu,
|
|
21
|
+
DropdownMenuCheckboxItem,
|
|
22
|
+
DropdownMenuContent,
|
|
23
|
+
DropdownMenuTrigger,
|
|
24
|
+
} from "./dropdown-menu";
|
|
25
|
+
import { Input } from "./input";
|
|
26
|
+
import {
|
|
27
|
+
Table,
|
|
28
|
+
TableBody,
|
|
29
|
+
TableCell,
|
|
30
|
+
TableHead,
|
|
31
|
+
TableHeader,
|
|
32
|
+
TableRow,
|
|
33
|
+
} from "./table";
|
|
34
|
+
|
|
35
|
+
interface DataTableProps<TData, TValue> {
|
|
36
|
+
columns: ColumnDef<TData, TValue>[];
|
|
37
|
+
data: TData[];
|
|
38
|
+
searchKey?: string;
|
|
39
|
+
searchPlaceholder?: string;
|
|
40
|
+
enableColumnVisibility?: boolean;
|
|
41
|
+
enablePagination?: boolean;
|
|
42
|
+
pageSize?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function DataTable<TData, TValue>({
|
|
46
|
+
columns,
|
|
47
|
+
data,
|
|
48
|
+
searchKey,
|
|
49
|
+
searchPlaceholder = "フィルター...",
|
|
50
|
+
enableColumnVisibility = true,
|
|
51
|
+
enablePagination = true,
|
|
52
|
+
pageSize = 10,
|
|
53
|
+
}: DataTableProps<TData, TValue>) {
|
|
54
|
+
const [sorting, setSorting] = useState<SortingState>([]);
|
|
55
|
+
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
|
|
56
|
+
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
|
57
|
+
const [rowSelection, setRowSelection] = useState({});
|
|
58
|
+
|
|
59
|
+
const table = useReactTable({
|
|
60
|
+
data,
|
|
61
|
+
columns,
|
|
62
|
+
onSortingChange: setSorting,
|
|
63
|
+
onColumnFiltersChange: setColumnFilters,
|
|
64
|
+
getCoreRowModel: getCoreRowModel(),
|
|
65
|
+
getPaginationRowModel: enablePagination
|
|
66
|
+
? getPaginationRowModel()
|
|
67
|
+
: undefined,
|
|
68
|
+
getSortedRowModel: getSortedRowModel(),
|
|
69
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
70
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
71
|
+
onRowSelectionChange: setRowSelection,
|
|
72
|
+
state: {
|
|
73
|
+
sorting,
|
|
74
|
+
columnFilters,
|
|
75
|
+
columnVisibility,
|
|
76
|
+
rowSelection,
|
|
77
|
+
},
|
|
78
|
+
initialState: {
|
|
79
|
+
pagination: enablePagination
|
|
80
|
+
? {
|
|
81
|
+
pageSize: pageSize,
|
|
82
|
+
}
|
|
83
|
+
: undefined,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="w-full">
|
|
89
|
+
{/* ツールバー */}
|
|
90
|
+
<div className="flex items-center py-4">
|
|
91
|
+
{searchKey && (
|
|
92
|
+
<Input
|
|
93
|
+
placeholder={searchPlaceholder}
|
|
94
|
+
value={
|
|
95
|
+
(table.getColumn(searchKey)?.getFilterValue() as string) ?? ""
|
|
96
|
+
}
|
|
97
|
+
onChange={(event) =>
|
|
98
|
+
table.getColumn(searchKey)?.setFilterValue(event.target.value)
|
|
99
|
+
}
|
|
100
|
+
className="max-w-sm"
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
{enableColumnVisibility && (
|
|
104
|
+
<DropdownMenu>
|
|
105
|
+
<DropdownMenuTrigger asChild>
|
|
106
|
+
<Button variant="outline" className="ml-auto">
|
|
107
|
+
列 <ChevronDown className="ml-2 h-4 w-4" />
|
|
108
|
+
</Button>
|
|
109
|
+
</DropdownMenuTrigger>
|
|
110
|
+
<DropdownMenuContent align="end">
|
|
111
|
+
{table
|
|
112
|
+
.getAllColumns()
|
|
113
|
+
.filter((column) => column.getCanHide())
|
|
114
|
+
.map((column) => {
|
|
115
|
+
return (
|
|
116
|
+
<DropdownMenuCheckboxItem
|
|
117
|
+
key={column.id}
|
|
118
|
+
className="capitalize"
|
|
119
|
+
checked={column.getIsVisible()}
|
|
120
|
+
onCheckedChange={(value) =>
|
|
121
|
+
column.toggleVisibility(!!value)
|
|
122
|
+
}
|
|
123
|
+
>
|
|
124
|
+
{column.id}
|
|
125
|
+
</DropdownMenuCheckboxItem>
|
|
126
|
+
);
|
|
127
|
+
})}
|
|
128
|
+
</DropdownMenuContent>
|
|
129
|
+
</DropdownMenu>
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{/* テーブル */}
|
|
134
|
+
<div className="rounded-md border">
|
|
135
|
+
<Table>
|
|
136
|
+
<TableHeader>
|
|
137
|
+
{table.getHeaderGroups().map((headerGroup) => (
|
|
138
|
+
<TableRow key={headerGroup.id}>
|
|
139
|
+
{headerGroup.headers.map((header) => {
|
|
140
|
+
return (
|
|
141
|
+
<TableHead key={header.id}>
|
|
142
|
+
{header.isPlaceholder
|
|
143
|
+
? null
|
|
144
|
+
: flexRender(
|
|
145
|
+
header.column.columnDef.header,
|
|
146
|
+
header.getContext(),
|
|
147
|
+
)}
|
|
148
|
+
</TableHead>
|
|
149
|
+
);
|
|
150
|
+
})}
|
|
151
|
+
</TableRow>
|
|
152
|
+
))}
|
|
153
|
+
</TableHeader>
|
|
154
|
+
<TableBody>
|
|
155
|
+
{table.getRowModel().rows?.length ? (
|
|
156
|
+
table.getRowModel().rows.map((row) => (
|
|
157
|
+
<TableRow
|
|
158
|
+
key={row.id}
|
|
159
|
+
data-state={row.getIsSelected() && "selected"}
|
|
160
|
+
>
|
|
161
|
+
{row.getVisibleCells().map((cell) => (
|
|
162
|
+
<TableCell key={cell.id}>
|
|
163
|
+
{flexRender(
|
|
164
|
+
cell.column.columnDef.cell,
|
|
165
|
+
cell.getContext(),
|
|
166
|
+
)}
|
|
167
|
+
</TableCell>
|
|
168
|
+
))}
|
|
169
|
+
</TableRow>
|
|
170
|
+
))
|
|
171
|
+
) : (
|
|
172
|
+
<TableRow>
|
|
173
|
+
<TableCell
|
|
174
|
+
colSpan={columns.length}
|
|
175
|
+
className="h-24 text-center"
|
|
176
|
+
>
|
|
177
|
+
データがありません。
|
|
178
|
+
</TableCell>
|
|
179
|
+
</TableRow>
|
|
180
|
+
)}
|
|
181
|
+
</TableBody>
|
|
182
|
+
</Table>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
{/* ページネーション */}
|
|
186
|
+
{enablePagination && (
|
|
187
|
+
<div className="flex items-center justify-end space-x-2 py-4">
|
|
188
|
+
<div className="flex-1 text-sm text-muted-foreground">
|
|
189
|
+
{table.getFilteredSelectedRowModel().rows.length} of{" "}
|
|
190
|
+
{table.getFilteredRowModel().rows.length} 行が選択されています。
|
|
191
|
+
</div>
|
|
192
|
+
<div className="space-x-2">
|
|
193
|
+
<Button
|
|
194
|
+
variant="outline"
|
|
195
|
+
size="sm"
|
|
196
|
+
onClick={() => table.previousPage()}
|
|
197
|
+
disabled={!table.getCanPreviousPage()}
|
|
198
|
+
>
|
|
199
|
+
<ChevronLeft className="h-4 w-4" />
|
|
200
|
+
前へ
|
|
201
|
+
</Button>
|
|
202
|
+
<Button
|
|
203
|
+
variant="outline"
|
|
204
|
+
size="sm"
|
|
205
|
+
onClick={() => table.nextPage()}
|
|
206
|
+
disabled={!table.getCanNextPage()}
|
|
207
|
+
>
|
|
208
|
+
次へ
|
|
209
|
+
<ChevronRight className="h-4 w-4" />
|
|
210
|
+
</Button>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useCallback, useContext, useState } from "react";
|
|
4
|
+
import type React from "react";
|
|
5
|
+
import { Button } from "./button";
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogContent,
|
|
9
|
+
DialogDescription,
|
|
10
|
+
DialogFooter,
|
|
11
|
+
DialogHeader,
|
|
12
|
+
DialogTitle,
|
|
13
|
+
} from "./dialog";
|
|
14
|
+
|
|
15
|
+
interface DialogOptions {
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
confirmText?: string;
|
|
19
|
+
cancelText?: string;
|
|
20
|
+
variant?: "default" | "destructive";
|
|
21
|
+
showCloseButton?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface DialogState {
|
|
25
|
+
isOpen: boolean;
|
|
26
|
+
title?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
confirmText?: string;
|
|
29
|
+
cancelText?: string;
|
|
30
|
+
variant?: "default" | "destructive";
|
|
31
|
+
showCloseButton?: boolean;
|
|
32
|
+
onConfirm?: () => void | Promise<void>;
|
|
33
|
+
onCancel?: () => void;
|
|
34
|
+
content?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface DialogContextType {
|
|
38
|
+
openDialog: (
|
|
39
|
+
options: DialogOptions & {
|
|
40
|
+
onConfirm?: () => void | Promise<void>;
|
|
41
|
+
onCancel?: () => void;
|
|
42
|
+
},
|
|
43
|
+
) => void;
|
|
44
|
+
openCustomDialog: (content: React.ReactNode, options?: DialogOptions) => void;
|
|
45
|
+
closeDialog: () => void;
|
|
46
|
+
confirm: (
|
|
47
|
+
options: Omit<DialogOptions, "cancelText" | "confirmText"> & {
|
|
48
|
+
message: string;
|
|
49
|
+
confirmText?: string;
|
|
50
|
+
cancelText?: string;
|
|
51
|
+
},
|
|
52
|
+
) => Promise<boolean>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DialogContext = createContext<DialogContextType | undefined>(undefined);
|
|
56
|
+
|
|
57
|
+
export function DialogProvider({ children }: { children: React.ReactNode }) {
|
|
58
|
+
const [dialogState, setDialogState] = useState<DialogState>({
|
|
59
|
+
isOpen: false,
|
|
60
|
+
showCloseButton: true,
|
|
61
|
+
});
|
|
62
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
63
|
+
|
|
64
|
+
const openDialog = useCallback(
|
|
65
|
+
(
|
|
66
|
+
options: DialogOptions & {
|
|
67
|
+
onConfirm?: () => void | Promise<void>;
|
|
68
|
+
onCancel?: () => void;
|
|
69
|
+
},
|
|
70
|
+
) => {
|
|
71
|
+
setDialogState({
|
|
72
|
+
isOpen: true,
|
|
73
|
+
title: options.title,
|
|
74
|
+
description: options.description,
|
|
75
|
+
confirmText: options.confirmText || "OK",
|
|
76
|
+
cancelText: options.cancelText || "キャンセル",
|
|
77
|
+
variant: options.variant || "default",
|
|
78
|
+
showCloseButton: options.showCloseButton ?? true,
|
|
79
|
+
onConfirm: options.onConfirm,
|
|
80
|
+
onCancel: options.onCancel,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
[],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const openCustomDialog = useCallback(
|
|
87
|
+
(content: React.ReactNode, options?: DialogOptions) => {
|
|
88
|
+
setDialogState({
|
|
89
|
+
isOpen: true,
|
|
90
|
+
content,
|
|
91
|
+
showCloseButton: options?.showCloseButton ?? true,
|
|
92
|
+
variant: options?.variant || "default",
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
[],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const closeDialog = useCallback(() => {
|
|
99
|
+
setDialogState((prev) => ({ ...prev, isOpen: false }));
|
|
100
|
+
setIsLoading(false);
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
const confirm = useCallback(
|
|
104
|
+
(
|
|
105
|
+
options: Omit<DialogOptions, "cancelText" | "confirmText"> & {
|
|
106
|
+
message: string;
|
|
107
|
+
confirmText?: string;
|
|
108
|
+
cancelText?: string;
|
|
109
|
+
},
|
|
110
|
+
) => {
|
|
111
|
+
return new Promise<boolean>((resolve) => {
|
|
112
|
+
setDialogState({
|
|
113
|
+
isOpen: true,
|
|
114
|
+
title: options.title || "確認",
|
|
115
|
+
description: options.message,
|
|
116
|
+
confirmText: options.confirmText || "OK",
|
|
117
|
+
cancelText: options.cancelText || "キャンセル",
|
|
118
|
+
variant: options.variant || "default",
|
|
119
|
+
showCloseButton: options.showCloseButton ?? true,
|
|
120
|
+
onConfirm: () => {
|
|
121
|
+
resolve(true);
|
|
122
|
+
closeDialog();
|
|
123
|
+
},
|
|
124
|
+
onCancel: () => {
|
|
125
|
+
resolve(false);
|
|
126
|
+
closeDialog();
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
[closeDialog],
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const handleConfirm = async () => {
|
|
135
|
+
if (dialogState.onConfirm) {
|
|
136
|
+
setIsLoading(true);
|
|
137
|
+
try {
|
|
138
|
+
await dialogState.onConfirm();
|
|
139
|
+
closeDialog();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error("Dialog confirm error:", error);
|
|
142
|
+
setIsLoading(false);
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
closeDialog();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const handleCancel = () => {
|
|
150
|
+
if (dialogState.onCancel) {
|
|
151
|
+
dialogState.onCancel();
|
|
152
|
+
}
|
|
153
|
+
closeDialog();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const contextValue: DialogContextType = {
|
|
157
|
+
openDialog,
|
|
158
|
+
openCustomDialog,
|
|
159
|
+
closeDialog,
|
|
160
|
+
confirm,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<DialogContext.Provider value={contextValue}>
|
|
165
|
+
{children}
|
|
166
|
+
<Dialog
|
|
167
|
+
open={dialogState.isOpen}
|
|
168
|
+
onOpenChange={(open) => !open && closeDialog()}
|
|
169
|
+
>
|
|
170
|
+
<DialogContent showCloseButton={dialogState.showCloseButton}>
|
|
171
|
+
{dialogState.content ? (
|
|
172
|
+
dialogState.content
|
|
173
|
+
) : (
|
|
174
|
+
<>
|
|
175
|
+
{dialogState.title && (
|
|
176
|
+
<DialogHeader>
|
|
177
|
+
<DialogTitle>{dialogState.title}</DialogTitle>
|
|
178
|
+
{dialogState.description && (
|
|
179
|
+
<DialogDescription>
|
|
180
|
+
{dialogState.description}
|
|
181
|
+
</DialogDescription>
|
|
182
|
+
)}
|
|
183
|
+
</DialogHeader>
|
|
184
|
+
)}
|
|
185
|
+
|
|
186
|
+
{(dialogState.onConfirm || dialogState.onCancel) && (
|
|
187
|
+
<DialogFooter>
|
|
188
|
+
{dialogState.onCancel && (
|
|
189
|
+
<Button
|
|
190
|
+
variant="outline"
|
|
191
|
+
onClick={handleCancel}
|
|
192
|
+
disabled={isLoading}
|
|
193
|
+
>
|
|
194
|
+
{dialogState.cancelText}
|
|
195
|
+
</Button>
|
|
196
|
+
)}
|
|
197
|
+
{dialogState.onConfirm && (
|
|
198
|
+
<Button
|
|
199
|
+
variant={
|
|
200
|
+
dialogState.variant === "destructive"
|
|
201
|
+
? "destructive"
|
|
202
|
+
: "default"
|
|
203
|
+
}
|
|
204
|
+
onClick={handleConfirm}
|
|
205
|
+
disabled={isLoading}
|
|
206
|
+
>
|
|
207
|
+
{isLoading ? "処理中..." : dialogState.confirmText}
|
|
208
|
+
</Button>
|
|
209
|
+
)}
|
|
210
|
+
</DialogFooter>
|
|
211
|
+
)}
|
|
212
|
+
</>
|
|
213
|
+
)}
|
|
214
|
+
</DialogContent>
|
|
215
|
+
</Dialog>
|
|
216
|
+
</DialogContext.Provider>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function useDialog() {
|
|
221
|
+
const context = useContext(DialogContext);
|
|
222
|
+
if (context === undefined) {
|
|
223
|
+
throw new Error("useDialog must be used within a DialogProvider");
|
|
224
|
+
}
|
|
225
|
+
return context;
|
|
226
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
5
|
+
import type * as React from "react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
function Dialog({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DialogTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogPortal({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DialogClose({
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogOverlay({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
37
|
+
return (
|
|
38
|
+
<DialogPrimitive.Overlay
|
|
39
|
+
data-slot="dialog-overlay"
|
|
40
|
+
className={cn(
|
|
41
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function DialogContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
showCloseButton = true,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
55
|
+
showCloseButton?: boolean;
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<DialogPortal data-slot="dialog-portal">
|
|
59
|
+
<DialogOverlay />
|
|
60
|
+
<DialogPrimitive.Content
|
|
61
|
+
data-slot="dialog-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
{showCloseButton && (
|
|
70
|
+
<DialogPrimitive.Close
|
|
71
|
+
data-slot="dialog-close"
|
|
72
|
+
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
73
|
+
>
|
|
74
|
+
<XIcon />
|
|
75
|
+
<span className="sr-only">Close</span>
|
|
76
|
+
</DialogPrimitive.Close>
|
|
77
|
+
)}
|
|
78
|
+
</DialogPrimitive.Content>
|
|
79
|
+
</DialogPortal>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot="dialog-header"
|
|
87
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-slot="dialog-footer"
|
|
97
|
+
className={cn(
|
|
98
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function DialogTitle({
|
|
107
|
+
className,
|
|
108
|
+
...props
|
|
109
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
110
|
+
return (
|
|
111
|
+
<DialogPrimitive.Title
|
|
112
|
+
data-slot="dialog-title"
|
|
113
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function DialogDescription({
|
|
120
|
+
className,
|
|
121
|
+
...props
|
|
122
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
123
|
+
return (
|
|
124
|
+
<DialogPrimitive.Description
|
|
125
|
+
data-slot="dialog-description"
|
|
126
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
Dialog,
|
|
134
|
+
DialogClose,
|
|
135
|
+
DialogContent,
|
|
136
|
+
DialogDescription,
|
|
137
|
+
DialogFooter,
|
|
138
|
+
DialogHeader,
|
|
139
|
+
DialogOverlay,
|
|
140
|
+
DialogPortal,
|
|
141
|
+
DialogTitle,
|
|
142
|
+
DialogTrigger,
|
|
143
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
import { Drawer as DrawerPrimitive } from "vaul";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils";
|
|
7
|
+
|
|
8
|
+
function Drawer({
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
|
11
|
+
return <DrawerPrimitive.Root data-slot="drawer" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function DrawerTrigger({
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {
|
|
17
|
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DrawerPortal({
|
|
21
|
+
...props
|
|
22
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
|
|
23
|
+
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function DrawerClose({
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Close>) {
|
|
29
|
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function DrawerOverlay({
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {
|
|
36
|
+
return (
|
|
37
|
+
<DrawerPrimitive.Overlay
|
|
38
|
+
data-slot="drawer-overlay"
|
|
39
|
+
className={cn(
|
|
40
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function DrawerContent({
|
|
49
|
+
className,
|
|
50
|
+
children,
|
|
51
|
+
...props
|
|
52
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Content>) {
|
|
53
|
+
return (
|
|
54
|
+
<DrawerPortal data-slot="drawer-portal">
|
|
55
|
+
<DrawerOverlay />
|
|
56
|
+
<DrawerPrimitive.Content
|
|
57
|
+
data-slot="drawer-content"
|
|
58
|
+
className={cn(
|
|
59
|
+
"group/drawer-content bg-background fixed z-50 flex h-auto flex-col",
|
|
60
|
+
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b",
|
|
61
|
+
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t",
|
|
62
|
+
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
63
|
+
"data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
<div className="bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block" />
|
|
69
|
+
{children}
|
|
70
|
+
</DrawerPrimitive.Content>
|
|
71
|
+
</DrawerPortal>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
76
|
+
return (
|
|
77
|
+
<div
|
|
78
|
+
data-slot="drawer-header"
|
|
79
|
+
className={cn(
|
|
80
|
+
"flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left",
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
data-slot="drawer-footer"
|
|
92
|
+
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function DrawerTitle({
|
|
99
|
+
className,
|
|
100
|
+
...props
|
|
101
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Title>) {
|
|
102
|
+
return (
|
|
103
|
+
<DrawerPrimitive.Title
|
|
104
|
+
data-slot="drawer-title"
|
|
105
|
+
className={cn("text-foreground font-semibold", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function DrawerDescription({
|
|
112
|
+
className,
|
|
113
|
+
...props
|
|
114
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Description>) {
|
|
115
|
+
return (
|
|
116
|
+
<DrawerPrimitive.Description
|
|
117
|
+
data-slot="drawer-description"
|
|
118
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
Drawer,
|
|
126
|
+
DrawerPortal,
|
|
127
|
+
DrawerOverlay,
|
|
128
|
+
DrawerTrigger,
|
|
129
|
+
DrawerClose,
|
|
130
|
+
DrawerContent,
|
|
131
|
+
DrawerHeader,
|
|
132
|
+
DrawerFooter,
|
|
133
|
+
DrawerTitle,
|
|
134
|
+
DrawerDescription,
|
|
135
|
+
};
|