@weirdfingers/baseboards 0.9.6 → 0.9.7
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/dist/index.js +560 -469
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
- package/templates/README.md +0 -122
- package/templates/api/.env.example +0 -65
- package/templates/api/ARTIFACT_RESOLUTION_GUIDE.md +0 -148
- package/templates/api/Dockerfile +0 -32
- package/templates/api/README.md +0 -264
- package/templates/api/alembic/env.py +0 -114
- package/templates/api/alembic/script.py.mako +0 -28
- package/templates/api/alembic/versions/20250101_000000_initial_schema.py +0 -506
- package/templates/api/alembic/versions/20251022_174729_remove_provider_name_from_generations.py +0 -75
- package/templates/api/alembic/versions/20251023_165852_switch_to_declarative_base_and_mapping.py +0 -467
- package/templates/api/alembic/versions/20251202_000000_add_artifact_lineage.py +0 -134
- package/templates/api/alembic/versions/2025925_62735_add_seed_data_for_default_tenant.py +0 -88
- package/templates/api/alembic.ini +0 -36
- package/templates/api/config/generators.yaml +0 -237
- package/templates/api/config/storage_config.yaml +0 -26
- package/templates/api/docs/ADDING_GENERATORS.md +0 -409
- package/templates/api/docs/GENERATORS_API.md +0 -502
- package/templates/api/docs/MIGRATIONS.md +0 -472
- package/templates/api/docs/TESTING_LIVE_APIS.md +0 -417
- package/templates/api/docs/storage_providers.md +0 -337
- package/templates/api/pyproject.toml +0 -205
- package/templates/api/src/boards/__init__.py +0 -10
- package/templates/api/src/boards/api/app.py +0 -172
- package/templates/api/src/boards/api/auth.py +0 -75
- package/templates/api/src/boards/api/endpoints/__init__.py +0 -3
- package/templates/api/src/boards/api/endpoints/jobs.py +0 -76
- package/templates/api/src/boards/api/endpoints/setup.py +0 -505
- package/templates/api/src/boards/api/endpoints/sse.py +0 -129
- package/templates/api/src/boards/api/endpoints/storage.py +0 -155
- package/templates/api/src/boards/api/endpoints/tenant_registration.py +0 -296
- package/templates/api/src/boards/api/endpoints/uploads.py +0 -149
- package/templates/api/src/boards/api/endpoints/webhooks.py +0 -13
- package/templates/api/src/boards/auth/__init__.py +0 -15
- package/templates/api/src/boards/auth/adapters/__init__.py +0 -27
- package/templates/api/src/boards/auth/adapters/auth0.py +0 -220
- package/templates/api/src/boards/auth/adapters/base.py +0 -73
- package/templates/api/src/boards/auth/adapters/clerk.py +0 -172
- package/templates/api/src/boards/auth/adapters/jwt.py +0 -122
- package/templates/api/src/boards/auth/adapters/none.py +0 -102
- package/templates/api/src/boards/auth/adapters/oidc.py +0 -284
- package/templates/api/src/boards/auth/adapters/supabase.py +0 -110
- package/templates/api/src/boards/auth/context.py +0 -35
- package/templates/api/src/boards/auth/factory.py +0 -129
- package/templates/api/src/boards/auth/middleware.py +0 -221
- package/templates/api/src/boards/auth/provisioning.py +0 -129
- package/templates/api/src/boards/auth/tenant_extraction.py +0 -278
- package/templates/api/src/boards/cli.py +0 -354
- package/templates/api/src/boards/config.py +0 -131
- package/templates/api/src/boards/database/__init__.py +0 -7
- package/templates/api/src/boards/database/cli.py +0 -110
- package/templates/api/src/boards/database/connection.py +0 -292
- package/templates/api/src/boards/database/models.py +0 -19
- package/templates/api/src/boards/database/seed_data.py +0 -182
- package/templates/api/src/boards/dbmodels/__init__.py +0 -441
- package/templates/api/src/boards/generators/__init__.py +0 -57
- package/templates/api/src/boards/generators/artifact_resolution.py +0 -405
- package/templates/api/src/boards/generators/artifacts.py +0 -53
- package/templates/api/src/boards/generators/base.py +0 -144
- package/templates/api/src/boards/generators/implementations/__init__.py +0 -14
- package/templates/api/src/boards/generators/implementations/fal/__init__.py +0 -25
- package/templates/api/src/boards/generators/implementations/fal/audio/__init__.py +0 -23
- package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_music_generation.py +0 -171
- package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_sound_effect_generation.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_text_to_speech.py +0 -176
- package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_tts_turbo.py +0 -195
- package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_sound_effects_v2.py +0 -194
- package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_tts_eleven_v3.py +0 -209
- package/templates/api/src/boards/generators/implementations/fal/audio/fal_elevenlabs_tts_turbo_v2_5.py +0 -206
- package/templates/api/src/boards/generators/implementations/fal/audio/fal_minimax_speech_26_hd.py +0 -237
- package/templates/api/src/boards/generators/implementations/fal/audio/minimax_music_v2.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/audio/minimax_speech_2_6_turbo.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/image/__init__.py +0 -63
- package/templates/api/src/boards/generators/implementations/fal/image/bytedance_seedream_v45_edit.py +0 -219
- package/templates/api/src/boards/generators/implementations/fal/image/clarity_upscaler.py +0 -220
- package/templates/api/src/boards/generators/implementations/fal/image/crystal_upscaler.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/image/fal_ideogram_character.py +0 -227
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2.py +0 -203
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_edit.py +0 -230
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro.py +0 -204
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro_edit.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_kontext.py +0 -216
- package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_ultra.py +0 -197
- package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image.py +0 -177
- package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image_edit.py +0 -208
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_15_edit.py +0 -216
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_5.py +0 -177
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_edit_image.py +0 -182
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_mini.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/image/ideogram_character_edit.py +0 -299
- package/templates/api/src/boards/generators/implementations/fal/image/ideogram_v2.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview.py +0 -191
- package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview_fast.py +0 -179
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana.py +0 -183
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_edit.py +0 -212
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro.py +0 -179
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro_edit.py +0 -226
- package/templates/api/src/boards/generators/implementations/fal/image/qwen_image.py +0 -249
- package/templates/api/src/boards/generators/implementations/fal/image/qwen_image_edit.py +0 -244
- package/templates/api/src/boards/generators/implementations/fal/image/reve_edit.py +0 -178
- package/templates/api/src/boards/generators/implementations/fal/image/reve_text_to_image.py +0 -155
- package/templates/api/src/boards/generators/implementations/fal/image/seedream_v45_text_to_image.py +0 -180
- package/templates/api/src/boards/generators/implementations/fal/utils.py +0 -61
- package/templates/api/src/boards/generators/implementations/fal/video/__init__.py +0 -77
- package/templates/api/src/boards/generators/implementations/fal/video/bytedance_seedance_v1_pro_text_to_video.py +0 -209
- package/templates/api/src/boards/generators/implementations/fal/video/creatify_lipsync.py +0 -161
- package/templates/api/src/boards/generators/implementations/fal/video/fal_bytedance_seedance_v1_pro_image_to_video.py +0 -222
- package/templates/api/src/boards/generators/implementations/fal/video/fal_minimax_hailuo_02_standard_text_to_video.py +0 -152
- package/templates/api/src/boards/generators/implementations/fal/video/fal_pixverse_lipsync.py +0 -197
- package/templates/api/src/boards/generators/implementations/fal/video/fal_sora_2_text_to_video.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/video/infinitalk.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_pro.py +0 -168
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_standard.py +0 -159
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_image_to_video.py +0 -175
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_text_to_video.py +0 -168
- package/templates/api/src/boards/generators/implementations/fal/video/minimax_hailuo_2_3_pro_image_to_video.py +0 -153
- package/templates/api/src/boards/generators/implementations/fal/video/sora2_image_to_video.py +0 -172
- package/templates/api/src/boards/generators/implementations/fal/video/sora_2_image_to_video_pro.py +0 -175
- package/templates/api/src/boards/generators/implementations/fal/video/sora_2_text_to_video_pro.py +0 -163
- package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2_pro.py +0 -155
- package/templates/api/src/boards/generators/implementations/fal/video/veed_fabric_1_0.py +0 -180
- package/templates/api/src/boards/generators/implementations/fal/video/veed_lipsync.py +0 -174
- package/templates/api/src/boards/generators/implementations/fal/video/veo3.py +0 -194
- package/templates/api/src/boards/generators/implementations/fal/video/veo31.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast_image_to_video.py +0 -191
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_first_last_frame_to_video.py +0 -187
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_image_to_video.py +0 -183
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_reference_to_video.py +0 -172
- package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_image_to_video.py +0 -212
- package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_text_to_video.py +0 -208
- package/templates/api/src/boards/generators/implementations/fal/video/wan_pro_image_to_video.py +0 -158
- package/templates/api/src/boards/generators/implementations/kie/__init__.py +0 -11
- package/templates/api/src/boards/generators/implementations/kie/base.py +0 -316
- package/templates/api/src/boards/generators/implementations/kie/image/__init__.py +0 -3
- package/templates/api/src/boards/generators/implementations/kie/image/nano_banana_edit.py +0 -190
- package/templates/api/src/boards/generators/implementations/kie/utils.py +0 -98
- package/templates/api/src/boards/generators/implementations/kie/video/__init__.py +0 -8
- package/templates/api/src/boards/generators/implementations/kie/video/veo3.py +0 -161
- package/templates/api/src/boards/generators/implementations/openai/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/audio/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/audio/whisper.py +0 -69
- package/templates/api/src/boards/generators/implementations/openai/image/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/image/dalle3.py +0 -96
- package/templates/api/src/boards/generators/implementations/replicate/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/image/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/image/flux_pro.py +0 -88
- package/templates/api/src/boards/generators/implementations/replicate/video/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/video/lipsync.py +0 -73
- package/templates/api/src/boards/generators/loader.py +0 -253
- package/templates/api/src/boards/generators/registry.py +0 -114
- package/templates/api/src/boards/generators/resolution.py +0 -632
- package/templates/api/src/boards/generators/testmods/class_gen.py +0 -34
- package/templates/api/src/boards/generators/testmods/import_side_effect.py +0 -35
- package/templates/api/src/boards/graphql/__init__.py +0 -7
- package/templates/api/src/boards/graphql/access_control.py +0 -136
- package/templates/api/src/boards/graphql/mutations/root.py +0 -148
- package/templates/api/src/boards/graphql/queries/root.py +0 -116
- package/templates/api/src/boards/graphql/resolvers/__init__.py +0 -8
- package/templates/api/src/boards/graphql/resolvers/auth.py +0 -12
- package/templates/api/src/boards/graphql/resolvers/board.py +0 -1053
- package/templates/api/src/boards/graphql/resolvers/generation.py +0 -666
- package/templates/api/src/boards/graphql/resolvers/generator.py +0 -50
- package/templates/api/src/boards/graphql/resolvers/lineage.py +0 -381
- package/templates/api/src/boards/graphql/resolvers/upload.py +0 -463
- package/templates/api/src/boards/graphql/resolvers/user.py +0 -25
- package/templates/api/src/boards/graphql/schema.py +0 -81
- package/templates/api/src/boards/graphql/types/board.py +0 -102
- package/templates/api/src/boards/graphql/types/generation.py +0 -166
- package/templates/api/src/boards/graphql/types/generator.py +0 -17
- package/templates/api/src/boards/graphql/types/user.py +0 -47
- package/templates/api/src/boards/jobs/repository.py +0 -153
- package/templates/api/src/boards/logging.py +0 -195
- package/templates/api/src/boards/middleware.py +0 -339
- package/templates/api/src/boards/progress/__init__.py +0 -4
- package/templates/api/src/boards/progress/models.py +0 -25
- package/templates/api/src/boards/progress/publisher.py +0 -64
- package/templates/api/src/boards/py.typed +0 -0
- package/templates/api/src/boards/redis_pool.py +0 -118
- package/templates/api/src/boards/storage/__init__.py +0 -52
- package/templates/api/src/boards/storage/base.py +0 -363
- package/templates/api/src/boards/storage/config.py +0 -187
- package/templates/api/src/boards/storage/factory.py +0 -288
- package/templates/api/src/boards/storage/implementations/__init__.py +0 -27
- package/templates/api/src/boards/storage/implementations/gcs.py +0 -340
- package/templates/api/src/boards/storage/implementations/local.py +0 -201
- package/templates/api/src/boards/storage/implementations/s3.py +0 -294
- package/templates/api/src/boards/storage/implementations/supabase.py +0 -218
- package/templates/api/src/boards/tenant_isolation.py +0 -446
- package/templates/api/src/boards/validation.py +0 -262
- package/templates/api/src/boards/workers/__init__.py +0 -1
- package/templates/api/src/boards/workers/actors.py +0 -274
- package/templates/api/src/boards/workers/cli.py +0 -125
- package/templates/api/src/boards/workers/context.py +0 -348
- package/templates/api/src/boards/workers/middleware.py +0 -58
- package/templates/api/src/py.typed +0 -0
- package/templates/compose.web.yaml +0 -35
- package/templates/compose.yaml +0 -116
- package/templates/docker/env.example +0 -23
- package/templates/web/.env.example +0 -28
- package/templates/web/Dockerfile +0 -51
- package/templates/web/components.json +0 -22
- package/templates/web/imageLoader.js +0 -18
- package/templates/web/next-env.d.ts +0 -5
- package/templates/web/next.config.js +0 -36
- package/templates/web/package.json +0 -41
- package/templates/web/postcss.config.mjs +0 -7
- package/templates/web/public/favicon.ico +0 -0
- package/templates/web/src/app/boards/[boardId]/page.tsx +0 -353
- package/templates/web/src/app/globals.css +0 -123
- package/templates/web/src/app/layout.tsx +0 -31
- package/templates/web/src/app/lineage/[generationId]/page.tsx +0 -235
- package/templates/web/src/app/page.tsx +0 -35
- package/templates/web/src/app/providers.tsx +0 -18
- package/templates/web/src/components/boards/ArtifactInputSlots.tsx +0 -206
- package/templates/web/src/components/boards/ArtifactPreview.tsx +0 -466
- package/templates/web/src/components/boards/GenerationGrid.tsx +0 -282
- package/templates/web/src/components/boards/GenerationInput.tsx +0 -370
- package/templates/web/src/components/boards/GeneratorSelector.tsx +0 -272
- package/templates/web/src/components/boards/UploadArtifact.tsx +0 -563
- package/templates/web/src/components/header.tsx +0 -32
- package/templates/web/src/components/theme-provider.tsx +0 -10
- package/templates/web/src/components/theme-toggle.tsx +0 -75
- package/templates/web/src/components/ui/alert-dialog.tsx +0 -157
- package/templates/web/src/components/ui/button.tsx +0 -58
- package/templates/web/src/components/ui/card.tsx +0 -92
- package/templates/web/src/components/ui/dropdown-menu.tsx +0 -200
- package/templates/web/src/components/ui/navigation-menu.tsx +0 -168
- package/templates/web/src/components/ui/toast.tsx +0 -128
- package/templates/web/src/components/ui/toaster.tsx +0 -35
- package/templates/web/src/components/ui/use-toast.ts +0 -187
- package/templates/web/src/hooks/useGeneratorMRU.ts +0 -57
- package/templates/web/src/lib/utils.ts +0 -6
- package/templates/web/tsconfig.json +0 -41
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
useGeneratorSelection,
|
|
4
|
-
useGeneration,
|
|
5
|
-
useMultiUpload,
|
|
6
|
-
ArtifactType,
|
|
7
|
-
} from "@weirdfingers/boards";
|
|
8
|
-
import { ArtifactPreview } from "./ArtifactPreview";
|
|
9
|
-
import { useToast } from "@/components/ui/use-toast";
|
|
10
|
-
import {
|
|
11
|
-
AlertDialog,
|
|
12
|
-
AlertDialogAction,
|
|
13
|
-
AlertDialogCancel,
|
|
14
|
-
AlertDialogContent,
|
|
15
|
-
AlertDialogDescription,
|
|
16
|
-
AlertDialogFooter,
|
|
17
|
-
AlertDialogHeader,
|
|
18
|
-
AlertDialogTitle,
|
|
19
|
-
} from "@/components/ui/alert-dialog";
|
|
20
|
-
|
|
21
|
-
interface Generation {
|
|
22
|
-
id: string;
|
|
23
|
-
artifactType: string;
|
|
24
|
-
storageUrl?: string | null;
|
|
25
|
-
thumbnailUrl?: string | null;
|
|
26
|
-
status: string;
|
|
27
|
-
errorMessage?: string | null;
|
|
28
|
-
createdAt: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface GenerationGridProps {
|
|
32
|
-
generations: Generation[];
|
|
33
|
-
boardId: string;
|
|
34
|
-
onGenerationClick?: (generation: Generation) => void;
|
|
35
|
-
onRemoveSuccess?: () => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function GenerationGrid({
|
|
39
|
-
generations,
|
|
40
|
-
boardId,
|
|
41
|
-
onGenerationClick,
|
|
42
|
-
onRemoveSuccess: onRemoveSuccess,
|
|
43
|
-
}: GenerationGridProps) {
|
|
44
|
-
const { canArtifactBeAdded, addArtifactToSlot } = useGeneratorSelection();
|
|
45
|
-
const { deleteGeneration } = useGeneration();
|
|
46
|
-
const { uploadMultiple } = useMultiUpload();
|
|
47
|
-
const { toast } = useToast();
|
|
48
|
-
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
49
|
-
const [generationToDelete, setGenerationToDelete] =
|
|
50
|
-
useState<Generation | null>(null);
|
|
51
|
-
const [isExtractingFrame, setIsExtractingFrame] = useState(false);
|
|
52
|
-
|
|
53
|
-
const handleExtractFrame = useCallback(
|
|
54
|
-
async (generation: Generation, position: "first" | "last") => {
|
|
55
|
-
if (!generation.storageUrl || isExtractingFrame) return;
|
|
56
|
-
|
|
57
|
-
setIsExtractingFrame(true);
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
// Create a video element to load the video
|
|
61
|
-
const video = document.createElement("video");
|
|
62
|
-
video.crossOrigin = "anonymous";
|
|
63
|
-
video.preload = "metadata";
|
|
64
|
-
|
|
65
|
-
// Wait for video metadata to load
|
|
66
|
-
await new Promise<void>((resolve, reject) => {
|
|
67
|
-
video.onloadedmetadata = () => resolve();
|
|
68
|
-
video.onerror = () => reject(new Error("Failed to load video"));
|
|
69
|
-
video.src = generation.storageUrl!;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Seek to the desired position
|
|
73
|
-
const targetTime = position === "first" ? 0 : video.duration - 0.1;
|
|
74
|
-
video.currentTime = Math.max(0, targetTime);
|
|
75
|
-
|
|
76
|
-
// Wait for the video to seek to the frame
|
|
77
|
-
await new Promise<void>((resolve, reject) => {
|
|
78
|
-
video.onseeked = () => resolve();
|
|
79
|
-
video.onerror = () => reject(new Error("Failed to seek video"));
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// Create a canvas and draw the video frame
|
|
83
|
-
const canvas = document.createElement("canvas");
|
|
84
|
-
canvas.width = video.videoWidth;
|
|
85
|
-
canvas.height = video.videoHeight;
|
|
86
|
-
const ctx = canvas.getContext("2d");
|
|
87
|
-
|
|
88
|
-
if (!ctx) {
|
|
89
|
-
throw new Error("Failed to get canvas context");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
93
|
-
|
|
94
|
-
// Convert canvas to blob
|
|
95
|
-
const blob = await new Promise<Blob>((resolve, reject) => {
|
|
96
|
-
canvas.toBlob(
|
|
97
|
-
(blob) => {
|
|
98
|
-
if (blob) {
|
|
99
|
-
resolve(blob);
|
|
100
|
-
} else {
|
|
101
|
-
reject(new Error("Failed to create image blob"));
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
"image/png",
|
|
105
|
-
1.0
|
|
106
|
-
);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Create a File object from the blob
|
|
110
|
-
const fileName = `${position}-frame-${generation.id}.png`;
|
|
111
|
-
const file = new File([blob], fileName, { type: "image/png" });
|
|
112
|
-
|
|
113
|
-
// Upload the extracted frame as a new image generation
|
|
114
|
-
const results = await uploadMultiple([
|
|
115
|
-
{
|
|
116
|
-
boardId,
|
|
117
|
-
artifactType: ArtifactType.IMAGE,
|
|
118
|
-
source: file,
|
|
119
|
-
userDescription: `${position === "first" ? "First" : "Last"} frame extracted from video`,
|
|
120
|
-
parentGenerationId: generation.id,
|
|
121
|
-
},
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
|
-
if (results.length > 0) {
|
|
125
|
-
toast({
|
|
126
|
-
title: "Frame extracted",
|
|
127
|
-
description: `${position === "first" ? "First" : "Last"} frame has been saved as a new image.`,
|
|
128
|
-
});
|
|
129
|
-
onRemoveSuccess?.(); // Refresh the grid to show the new generation
|
|
130
|
-
}
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error("Failed to extract frame:", error);
|
|
133
|
-
toast({
|
|
134
|
-
title: "Failed to extract frame",
|
|
135
|
-
description:
|
|
136
|
-
error instanceof Error ? error.message : "An unknown error occurred",
|
|
137
|
-
variant: "destructive",
|
|
138
|
-
});
|
|
139
|
-
} finally {
|
|
140
|
-
setIsExtractingFrame(false);
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
[boardId, uploadMultiple, toast, onRemoveSuccess, isExtractingFrame]
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
const handleDownload = async (generation: Generation) => {
|
|
147
|
-
if (!generation.storageUrl) return;
|
|
148
|
-
|
|
149
|
-
try {
|
|
150
|
-
// Add download query parameter to force download instead of inline preview
|
|
151
|
-
// Also add custom filename based on generation ID
|
|
152
|
-
const url = new URL(generation.storageUrl);
|
|
153
|
-
url.searchParams.set("download", "true");
|
|
154
|
-
url.searchParams.set("filename", `gen-${generation.id}`);
|
|
155
|
-
|
|
156
|
-
// Create temporary anchor and trigger download
|
|
157
|
-
const link = document.createElement("a");
|
|
158
|
-
link.href = url.toString();
|
|
159
|
-
link.target = "_blank";
|
|
160
|
-
document.body.appendChild(link);
|
|
161
|
-
link.click();
|
|
162
|
-
document.body.removeChild(link);
|
|
163
|
-
} catch (error) {
|
|
164
|
-
console.error("Failed to download file:", error);
|
|
165
|
-
// Fallback to opening in new tab if download fails
|
|
166
|
-
window.open(generation.storageUrl, "_blank");
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const handlePreview = (generation: Generation) => {
|
|
171
|
-
// For now, use the same handler as onClick
|
|
172
|
-
onGenerationClick?.(generation);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const handleAddToSlot = (generation: Generation) => {
|
|
176
|
-
const success = addArtifactToSlot({
|
|
177
|
-
id: generation.id,
|
|
178
|
-
artifactType: generation.artifactType,
|
|
179
|
-
storageUrl: generation.storageUrl,
|
|
180
|
-
thumbnailUrl: generation.thumbnailUrl,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
if (success) {
|
|
184
|
-
// Scroll to the generation input to show the user where the artifact was added
|
|
185
|
-
const generationInput = document.getElementById("generation-input");
|
|
186
|
-
if (generationInput) {
|
|
187
|
-
generationInput.scrollIntoView({
|
|
188
|
-
behavior: "smooth",
|
|
189
|
-
block: "nearest",
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const handleDeleteClick = (generation: Generation) => {
|
|
196
|
-
setGenerationToDelete(generation);
|
|
197
|
-
setDeleteDialogOpen(true);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const handleDeleteConfirm = async () => {
|
|
201
|
-
if (!generationToDelete) return;
|
|
202
|
-
|
|
203
|
-
try {
|
|
204
|
-
await deleteGeneration(generationToDelete.id);
|
|
205
|
-
toast({
|
|
206
|
-
title: "Generation deleted",
|
|
207
|
-
description: "The generation has been permanently removed.",
|
|
208
|
-
});
|
|
209
|
-
setDeleteDialogOpen(false);
|
|
210
|
-
setGenerationToDelete(null);
|
|
211
|
-
// Refresh the board data to update the generations list
|
|
212
|
-
onRemoveSuccess?.();
|
|
213
|
-
} catch (error) {
|
|
214
|
-
console.error("Failed to delete generation:", error);
|
|
215
|
-
toast({
|
|
216
|
-
title: "Failed to delete generation",
|
|
217
|
-
description:
|
|
218
|
-
error instanceof Error ? error.message : "An unknown error occurred",
|
|
219
|
-
variant: "destructive",
|
|
220
|
-
});
|
|
221
|
-
setDeleteDialogOpen(false);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
if (generations.length === 0) {
|
|
226
|
-
return (
|
|
227
|
-
<div className="flex items-center justify-center py-12 text-muted-foreground">
|
|
228
|
-
<p>No generations yet. Create your first one below!</p>
|
|
229
|
-
</div>
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
|
|
235
|
-
{generations.map((generation) => {
|
|
236
|
-
const canAdd =
|
|
237
|
-
generation.status === "COMPLETED" &&
|
|
238
|
-
canArtifactBeAdded(generation.artifactType);
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
<ArtifactPreview
|
|
242
|
-
key={generation.id}
|
|
243
|
-
artifactId={generation.id}
|
|
244
|
-
artifactType={generation.artifactType}
|
|
245
|
-
storageUrl={generation.storageUrl}
|
|
246
|
-
thumbnailUrl={generation.thumbnailUrl}
|
|
247
|
-
status={generation.status}
|
|
248
|
-
errorMessage={generation.errorMessage}
|
|
249
|
-
onClick={() => onGenerationClick?.(generation)}
|
|
250
|
-
onAddToSlot={() => handleAddToSlot(generation)}
|
|
251
|
-
canAddToSlot={canAdd}
|
|
252
|
-
onDownload={() => handleDownload(generation)}
|
|
253
|
-
onPreview={() => handlePreview(generation)}
|
|
254
|
-
onDelete={() => handleDeleteClick(generation)}
|
|
255
|
-
onExtractFrame={(position) => handleExtractFrame(generation, position)}
|
|
256
|
-
/>
|
|
257
|
-
);
|
|
258
|
-
})}
|
|
259
|
-
|
|
260
|
-
<AlertDialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
|
|
261
|
-
<AlertDialogContent>
|
|
262
|
-
<AlertDialogHeader>
|
|
263
|
-
<AlertDialogTitle>Delete generation?</AlertDialogTitle>
|
|
264
|
-
<AlertDialogDescription>
|
|
265
|
-
This action cannot be undone. The generation will be permanently
|
|
266
|
-
deleted.
|
|
267
|
-
</AlertDialogDescription>
|
|
268
|
-
</AlertDialogHeader>
|
|
269
|
-
<AlertDialogFooter>
|
|
270
|
-
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
271
|
-
<AlertDialogAction
|
|
272
|
-
onClick={handleDeleteConfirm}
|
|
273
|
-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
274
|
-
>
|
|
275
|
-
Delete
|
|
276
|
-
</AlertDialogAction>
|
|
277
|
-
</AlertDialogFooter>
|
|
278
|
-
</AlertDialogContent>
|
|
279
|
-
</AlertDialog>
|
|
280
|
-
</div>
|
|
281
|
-
);
|
|
282
|
-
}
|
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState, useMemo, useEffect } from "react";
|
|
4
|
-
import { Settings, ArrowUp, X } from "lucide-react";
|
|
5
|
-
import Image from "next/image";
|
|
6
|
-
import {
|
|
7
|
-
useGeneratorSelection,
|
|
8
|
-
} from "@weirdfingers/boards";
|
|
9
|
-
import { GeneratorSelector, GeneratorInfo } from "./GeneratorSelector";
|
|
10
|
-
import { useGeneratorMRU } from "@/hooks/useGeneratorMRU";
|
|
11
|
-
import { ArtifactInputSlots } from "./ArtifactInputSlots";
|
|
12
|
-
|
|
13
|
-
interface Generation {
|
|
14
|
-
id: string;
|
|
15
|
-
artifactType: string;
|
|
16
|
-
storageUrl?: string | null;
|
|
17
|
-
thumbnailUrl?: string | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface GenerationInputProps {
|
|
21
|
-
generators: GeneratorInfo[];
|
|
22
|
-
availableArtifacts: Generation[];
|
|
23
|
-
onSubmit: (params: {
|
|
24
|
-
generatorName: string;
|
|
25
|
-
prompt: string;
|
|
26
|
-
artifacts: Map<string, Generation>;
|
|
27
|
-
settings: Record<string, unknown>;
|
|
28
|
-
}) => void;
|
|
29
|
-
isGenerating?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function GenerationInput({
|
|
33
|
-
generators,
|
|
34
|
-
availableArtifacts,
|
|
35
|
-
onSubmit,
|
|
36
|
-
isGenerating = false,
|
|
37
|
-
}: GenerationInputProps) {
|
|
38
|
-
const {
|
|
39
|
-
selectedGenerator,
|
|
40
|
-
setSelectedGenerator,
|
|
41
|
-
parsedSchema,
|
|
42
|
-
selectedArtifacts,
|
|
43
|
-
setSelectedArtifacts
|
|
44
|
-
} = useGeneratorSelection();
|
|
45
|
-
|
|
46
|
-
const { lastUsedGenerator } = useGeneratorMRU();
|
|
47
|
-
|
|
48
|
-
const [prompt, setPrompt] = useState("");
|
|
49
|
-
const [attachedImage, setAttachedImage] = useState<Generation | null>(null);
|
|
50
|
-
const [showSettings, setShowSettings] = useState(false);
|
|
51
|
-
const [settings, setSettings] = useState<Record<string, unknown>>({});
|
|
52
|
-
|
|
53
|
-
// Initialize selected generator if not set
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (selectedGenerator || generators.length === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Try to load from MRU
|
|
60
|
-
if (lastUsedGenerator) {
|
|
61
|
-
const match = generators.find(g => g.name === lastUsedGenerator);
|
|
62
|
-
if (match) {
|
|
63
|
-
setSelectedGenerator(match);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
setSelectedGenerator(generators[0]);
|
|
69
|
-
}, [generators, selectedGenerator, setSelectedGenerator, lastUsedGenerator]);
|
|
70
|
-
|
|
71
|
-
const artifactSlots = useMemo(() => {
|
|
72
|
-
if (!parsedSchema) return [];
|
|
73
|
-
return parsedSchema.artifactSlots.map((slot) => ({
|
|
74
|
-
name: slot.fieldName,
|
|
75
|
-
type: slot.artifactType,
|
|
76
|
-
required: slot.required,
|
|
77
|
-
}));
|
|
78
|
-
}, [parsedSchema]);
|
|
79
|
-
|
|
80
|
-
const needsArtifactInputs = artifactSlots.length > 0;
|
|
81
|
-
|
|
82
|
-
// Initialize settings with defaults when generator changes
|
|
83
|
-
const defaultSettings = useMemo(() => {
|
|
84
|
-
const defaults: Record<string, unknown> = {};
|
|
85
|
-
if (parsedSchema) {
|
|
86
|
-
parsedSchema.settingsFields.forEach((field) => {
|
|
87
|
-
if (field.default !== undefined) {
|
|
88
|
-
defaults[field.fieldName] = field.default;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return defaults;
|
|
93
|
-
}, [parsedSchema]);
|
|
94
|
-
|
|
95
|
-
// Reset settings when generator changes or defaultSettings change
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
setSettings(defaultSettings);
|
|
98
|
-
}, [selectedGenerator, defaultSettings]);
|
|
99
|
-
|
|
100
|
-
const handleSubmit = () => {
|
|
101
|
-
if (!selectedGenerator || !prompt.trim()) return;
|
|
102
|
-
|
|
103
|
-
onSubmit({
|
|
104
|
-
generatorName: selectedGenerator.name,
|
|
105
|
-
prompt: prompt.trim(),
|
|
106
|
-
artifacts: selectedArtifacts,
|
|
107
|
-
settings,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Reset form (but keep selected artifacts and generator)
|
|
111
|
-
setPrompt("");
|
|
112
|
-
setAttachedImage(null);
|
|
113
|
-
setSettings(defaultSettings);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const handleSelectArtifact = (
|
|
117
|
-
slotName: string,
|
|
118
|
-
artifact: Generation | null
|
|
119
|
-
) => {
|
|
120
|
-
const newSelected = new Map(selectedArtifacts);
|
|
121
|
-
if (artifact) {
|
|
122
|
-
newSelected.set(slotName, artifact);
|
|
123
|
-
} else {
|
|
124
|
-
newSelected.delete(slotName);
|
|
125
|
-
}
|
|
126
|
-
setSelectedArtifacts(newSelected);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const canSubmit =
|
|
130
|
-
selectedGenerator &&
|
|
131
|
-
prompt.trim() &&
|
|
132
|
-
!isGenerating &&
|
|
133
|
-
(!needsArtifactInputs ||
|
|
134
|
-
artifactSlots
|
|
135
|
-
.filter((s) => s.required)
|
|
136
|
-
.every((s) => selectedArtifacts.has(s.name)));
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<div className="border border-border rounded-lg bg-background shadow-sm">
|
|
140
|
-
{/* Generator selector header */}
|
|
141
|
-
<div className="px-4 py-3 border-b border-border flex items-center justify-center">
|
|
142
|
-
<GeneratorSelector
|
|
143
|
-
generators={generators}
|
|
144
|
-
selectedGenerator={selectedGenerator}
|
|
145
|
-
onSelect={setSelectedGenerator}
|
|
146
|
-
/>
|
|
147
|
-
</div>
|
|
148
|
-
|
|
149
|
-
{/* Artifact input slots (for generators like lipsync) */}
|
|
150
|
-
{needsArtifactInputs && (
|
|
151
|
-
<div className="px-4 py-4 border-b border-border">
|
|
152
|
-
<ArtifactInputSlots
|
|
153
|
-
slots={artifactSlots}
|
|
154
|
-
selectedArtifacts={selectedArtifacts}
|
|
155
|
-
availableArtifacts={availableArtifacts}
|
|
156
|
-
onSelectArtifact={handleSelectArtifact}
|
|
157
|
-
/>
|
|
158
|
-
{artifactSlots.every((s) => selectedArtifacts.has(s.name)) && (
|
|
159
|
-
<div className="mt-3 flex items-center gap-2 text-sm text-success">
|
|
160
|
-
<svg
|
|
161
|
-
className="w-4 h-4"
|
|
162
|
-
fill="none"
|
|
163
|
-
strokeLinecap="round"
|
|
164
|
-
strokeLinejoin="round"
|
|
165
|
-
strokeWidth="2"
|
|
166
|
-
viewBox="0 0 24 24"
|
|
167
|
-
stroke="currentColor"
|
|
168
|
-
>
|
|
169
|
-
<path d="M5 13l4 4L19 7"></path>
|
|
170
|
-
</svg>
|
|
171
|
-
<span>
|
|
172
|
-
Both files ready for {selectedGenerator?.name} generation
|
|
173
|
-
</span>
|
|
174
|
-
</div>
|
|
175
|
-
)}
|
|
176
|
-
</div>
|
|
177
|
-
)}
|
|
178
|
-
|
|
179
|
-
{/* Attached image preview (if any) */}
|
|
180
|
-
{attachedImage && (
|
|
181
|
-
<div className="px-4 py-3 border-b border-border">
|
|
182
|
-
<div className="flex items-center gap-3">
|
|
183
|
-
<Image
|
|
184
|
-
src={attachedImage.thumbnailUrl || attachedImage.storageUrl || ""}
|
|
185
|
-
alt="Attached"
|
|
186
|
-
className="w-16 h-16 object-cover rounded"
|
|
187
|
-
width={64}
|
|
188
|
-
height={64}
|
|
189
|
-
/>
|
|
190
|
-
<div className="flex-1">
|
|
191
|
-
<p className="text-sm font-medium">Image attached</p>
|
|
192
|
-
<p className="text-xs text-muted-foreground">
|
|
193
|
-
ID: {attachedImage.id.substring(0, 8)}
|
|
194
|
-
</p>
|
|
195
|
-
</div>
|
|
196
|
-
<button
|
|
197
|
-
onClick={() => setAttachedImage(null)}
|
|
198
|
-
className="p-1 hover:bg-muted rounded"
|
|
199
|
-
>
|
|
200
|
-
<X className="w-4 h-4" />
|
|
201
|
-
</button>
|
|
202
|
-
</div>
|
|
203
|
-
</div>
|
|
204
|
-
)}
|
|
205
|
-
|
|
206
|
-
{/* Prompt input area */}
|
|
207
|
-
<div className="px-4 py-4 flex items-end gap-3">
|
|
208
|
-
<textarea
|
|
209
|
-
value={prompt}
|
|
210
|
-
onChange={(e) => setPrompt(e.target.value)}
|
|
211
|
-
placeholder={
|
|
212
|
-
needsArtifactInputs
|
|
213
|
-
? "Add optional prompt or instructions..."
|
|
214
|
-
: "Describe what you want to generate..."
|
|
215
|
-
}
|
|
216
|
-
className="flex-1 resize-none border-none outline-none text-base min-h-[60px] max-h-[200px]"
|
|
217
|
-
onKeyDown={(e) => {
|
|
218
|
-
if (e.key === "Enter" && (e.metaKey || e.ctrlKey) && canSubmit) {
|
|
219
|
-
handleSubmit();
|
|
220
|
-
}
|
|
221
|
-
}}
|
|
222
|
-
/>
|
|
223
|
-
<div className="flex items-center gap-2">
|
|
224
|
-
<button
|
|
225
|
-
onClick={() => setShowSettings(!showSettings)}
|
|
226
|
-
className="p-2 hover:bg-muted rounded-lg transition-colors"
|
|
227
|
-
title="Settings"
|
|
228
|
-
>
|
|
229
|
-
<Settings className="w-5 h-5 text-muted-foreground" />
|
|
230
|
-
</button>
|
|
231
|
-
<button
|
|
232
|
-
onClick={handleSubmit}
|
|
233
|
-
disabled={!canSubmit}
|
|
234
|
-
className={`p-3 rounded-full transition-all ${
|
|
235
|
-
canSubmit
|
|
236
|
-
? "bg-primary hover:bg-primary/90 text-primary-foreground shadow-lg"
|
|
237
|
-
: "bg-muted text-muted-foreground cursor-not-allowed"
|
|
238
|
-
}`}
|
|
239
|
-
title="Generate (⌘+Enter)"
|
|
240
|
-
>
|
|
241
|
-
<ArrowUp className="w-5 h-5" />
|
|
242
|
-
</button>
|
|
243
|
-
</div>
|
|
244
|
-
</div>
|
|
245
|
-
|
|
246
|
-
{/* Settings panel (collapsed by default) */}
|
|
247
|
-
{showSettings && (
|
|
248
|
-
<div className="px-4 py-4 border-t border-border bg-muted/50">
|
|
249
|
-
{!parsedSchema || parsedSchema.settingsFields.length === 0 ? (
|
|
250
|
-
<p className="text-sm text-muted-foreground">
|
|
251
|
-
No additional settings available for this generator
|
|
252
|
-
</p>
|
|
253
|
-
) : (
|
|
254
|
-
<div>
|
|
255
|
-
<h3 className="text-sm font-medium text-foreground mb-4">
|
|
256
|
-
Generator Settings
|
|
257
|
-
</h3>
|
|
258
|
-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
259
|
-
{parsedSchema.settingsFields.map((field) => (
|
|
260
|
-
<div key={field.fieldName} className="space-y-1.5">
|
|
261
|
-
<label
|
|
262
|
-
htmlFor={field.fieldName}
|
|
263
|
-
className="block text-sm font-medium text-foreground"
|
|
264
|
-
>
|
|
265
|
-
{field.title}
|
|
266
|
-
</label>
|
|
267
|
-
{field.description && (
|
|
268
|
-
<p className="text-xs text-muted-foreground">{field.description}</p>
|
|
269
|
-
)}
|
|
270
|
-
|
|
271
|
-
{/* Slider control */}
|
|
272
|
-
{field.type === "slider" && (
|
|
273
|
-
<div className="space-y-1">
|
|
274
|
-
<input
|
|
275
|
-
id={field.fieldName}
|
|
276
|
-
type="range"
|
|
277
|
-
min={field.min}
|
|
278
|
-
max={field.max}
|
|
279
|
-
step={field.step || (field.isInteger ? 1 : 0.01)}
|
|
280
|
-
value={
|
|
281
|
-
(settings[field.fieldName] as number) ?? field.default
|
|
282
|
-
}
|
|
283
|
-
onChange={(e) =>
|
|
284
|
-
setSettings({
|
|
285
|
-
...settings,
|
|
286
|
-
[field.fieldName]: field.isInteger
|
|
287
|
-
? parseInt(e.target.value)
|
|
288
|
-
: parseFloat(e.target.value),
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
className="w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"
|
|
292
|
-
/>
|
|
293
|
-
<div className="flex justify-between text-xs text-muted-foreground">
|
|
294
|
-
<span>{field.min}</span>
|
|
295
|
-
<span className="font-medium">
|
|
296
|
-
{String(settings[field.fieldName] ?? field.default ?? field.min)}
|
|
297
|
-
</span>
|
|
298
|
-
<span>{field.max}</span>
|
|
299
|
-
</div>
|
|
300
|
-
</div>
|
|
301
|
-
)}
|
|
302
|
-
|
|
303
|
-
{/* Dropdown control */}
|
|
304
|
-
{field.type === "dropdown" && (
|
|
305
|
-
<select
|
|
306
|
-
id={field.fieldName}
|
|
307
|
-
value={(settings[field.fieldName] as string) ?? field.default}
|
|
308
|
-
onChange={(e) =>
|
|
309
|
-
setSettings({
|
|
310
|
-
...settings,
|
|
311
|
-
[field.fieldName]: e.target.value,
|
|
312
|
-
})
|
|
313
|
-
}
|
|
314
|
-
className="block w-full px-3 py-2 text-sm border border-border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary"
|
|
315
|
-
>
|
|
316
|
-
{field.options.map((option) => (
|
|
317
|
-
<option key={option} value={option}>
|
|
318
|
-
{option}
|
|
319
|
-
</option>
|
|
320
|
-
))}
|
|
321
|
-
</select>
|
|
322
|
-
)}
|
|
323
|
-
|
|
324
|
-
{/* Number input control */}
|
|
325
|
-
{field.type === "number" && (
|
|
326
|
-
<input
|
|
327
|
-
id={field.fieldName}
|
|
328
|
-
type="number"
|
|
329
|
-
min={field.min}
|
|
330
|
-
max={field.max}
|
|
331
|
-
step={field.isInteger ? 1 : "any"}
|
|
332
|
-
value={(settings[field.fieldName] as number) ?? field.default}
|
|
333
|
-
onChange={(e) =>
|
|
334
|
-
setSettings({
|
|
335
|
-
...settings,
|
|
336
|
-
[field.fieldName]: field.isInteger
|
|
337
|
-
? parseInt(e.target.value)
|
|
338
|
-
: parseFloat(e.target.value),
|
|
339
|
-
})
|
|
340
|
-
}
|
|
341
|
-
className="block w-full px-3 py-2 text-sm border border-border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary"
|
|
342
|
-
/>
|
|
343
|
-
)}
|
|
344
|
-
|
|
345
|
-
{/* Text input control */}
|
|
346
|
-
{field.type === "text" && (
|
|
347
|
-
<input
|
|
348
|
-
id={field.fieldName}
|
|
349
|
-
type="text"
|
|
350
|
-
value={(settings[field.fieldName] as string) ?? field.default ?? ""}
|
|
351
|
-
onChange={(e) =>
|
|
352
|
-
setSettings({
|
|
353
|
-
...settings,
|
|
354
|
-
[field.fieldName]: e.target.value,
|
|
355
|
-
})
|
|
356
|
-
}
|
|
357
|
-
pattern={field.pattern}
|
|
358
|
-
className="block w-full px-3 py-2 text-sm border border-border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary"
|
|
359
|
-
/>
|
|
360
|
-
)}
|
|
361
|
-
</div>
|
|
362
|
-
))}
|
|
363
|
-
</div>
|
|
364
|
-
</div>
|
|
365
|
-
)}
|
|
366
|
-
</div>
|
|
367
|
-
)}
|
|
368
|
-
</div>
|
|
369
|
-
);
|
|
370
|
-
}
|