import type { PluginTheme } from "@getpaseo/plugin"; import { Icon, Modal, TextInput } from "@getpaseo/plugin/client/ui"; import { useEffect, useState } from "react"; import { Pressable, Text, View } from "react-native"; export interface RowIconButtonProps { icon: string; accessibilityLabel: string; theme: PluginTheme; size?: number; paddingVertical?: number; active?: boolean; disabled?: boolean; onPress(): void; } export function RowIconButton({ icon, accessibilityLabel, theme, size = 13, paddingVertical = 6, active = false, disabled = false, onPress, }: RowIconButtonProps) { return ( ({ paddingHorizontal: 5, paddingVertical, borderRadius: 6, backgroundColor: active || pressed ? theme.colors.surface1 : "transparent", opacity: disabled ? 0.5 : 1, })} > ); } export interface ActionPillProps { icon: string; label: string; theme: PluginTheme; tone?: "default" | "accent" | "danger"; disabled?: boolean; onPress(): void; } export function ActionPill({ icon, label, theme, tone = "default", disabled = false, onPress, }: ActionPillProps) { const foreground = tone === "danger" ? theme.colors.statusDanger : tone === "accent" ? theme.colors.accentForeground : theme.colors.foreground; const background = tone === "accent" ? theme.colors.accent : theme.colors.surface2; const borderColor = tone === "danger" ? theme.colors.statusDanger : tone === "accent" ? theme.colors.accent : theme.colors.border; return ( ({ flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 8, paddingVertical: 4, borderRadius: 6, borderWidth: 1, borderColor, backgroundColor: pressed ? theme.colors.surface1 : background, opacity: disabled ? 0.5 : 1, })} > {label} ); } export interface RenameWorkspaceModalProps { open: boolean; initialTitle: string; hasCustomTitle: boolean; theme: PluginTheme; saving: boolean; onClose(): void; onSave(nextTitle: string | null): void; } export function RenameWorkspaceModal({ open, initialTitle, hasCustomTitle, theme, saving, onClose, onSave, }: RenameWorkspaceModalProps) { const [draft, setDraft] = useState(initialTitle); useEffect(() => { if (open) { setDraft(initialTitle); } }, [open, initialTitle]); const trimmed = draft.trim(); const canSave = !saving && trimmed.length > 0; return ( } open={open} onOpenChange={(nextOpen) => { if (!nextOpen && !saving) onClose(); }} > Enter a title for this workspace, or reset to the default name. { if (canSave) onSave(trimmed); }} style={{ paddingHorizontal: 10, paddingVertical: 8, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, backgroundColor: theme.colors.surface1, color: theme.colors.foreground, fontSize: 14, }} /> {hasCustomTitle ? ( onSave(null)} style={({ pressed }) => ({ paddingHorizontal: 10, paddingVertical: 7, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, backgroundColor: pressed ? theme.colors.surface2 : theme.colors.surface1, opacity: saving ? 0.5 : 1, })} > Reset ) : null} ({ paddingHorizontal: 12, paddingVertical: 7, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, backgroundColor: pressed ? theme.colors.surface2 : theme.colors.surface1, opacity: saving ? 0.5 : 1, })} > Cancel { if (canSave) onSave(trimmed); }} style={({ pressed }) => ({ paddingHorizontal: 14, paddingVertical: 7, borderRadius: 8, backgroundColor: theme.colors.accent, opacity: !canSave ? 0.5 : pressed ? 0.85 : 1, })} > {saving ? "Saving..." : "Save"} ); } export interface ConfirmArchiveModalProps { open: boolean; title: string; description: string; theme: PluginTheme; archiving: boolean; onClose(): void; onConfirm(): void; } export function ConfirmArchiveModal({ open, title, description, theme, archiving, onClose, onConfirm, }: ConfirmArchiveModalProps) { return ( } open={open} onOpenChange={(nextOpen) => { if (!nextOpen && !archiving) onClose(); }} > {description} ({ paddingHorizontal: 12, paddingVertical: 7, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, backgroundColor: pressed ? theme.colors.surface2 : theme.colors.surface1, opacity: archiving ? 0.5 : 1, })} > Cancel ({ paddingHorizontal: 14, paddingVertical: 7, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.statusDanger, backgroundColor: pressed ? theme.colors.surface1 : theme.colors.surface2, opacity: archiving ? 0.5 : 1, })} > {archiving ? "Archiving..." : "Archive"} ); }