ERP-node/frontend/lib/registry/components/common/inputStyles.ts

116 lines
2.9 KiB
TypeScript
Raw Normal View History

2025-10-14 11:48:04 +09:00
/**
* Tailwind CSS Input
*/
export const INPUT_CLASSES = {
// 기본 input 스타일
base: `
2025-10-17 16:21:08 +09:00
w-full h-9 px-3 py-2 text-sm
border border-input rounded-md
bg-background text-foreground
transition-colors
focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
disabled:cursor-not-allowed disabled:opacity-50
placeholder:text-muted-foreground
2025-10-14 17:40:51 +09:00
max-w-full box-border
2025-10-14 11:48:04 +09:00
`,
// 선택된 상태
selected: `
2025-10-17 16:21:08 +09:00
ring-2 ring-primary/20
2025-10-14 11:48:04 +09:00
`,
// 라벨 스타일
label: `
2025-10-17 16:21:08 +09:00
absolute -top-6 left-0 text-xs font-medium text-foreground
2025-10-14 11:48:04 +09:00
`,
// 필수 표시
required: `
2025-10-17 16:21:08 +09:00
ml-0.5 text-destructive
2025-10-14 11:48:04 +09:00
`,
// 컨테이너
container: `
2025-10-14 17:40:51 +09:00
relative w-full h-full max-w-full box-border
2025-10-14 11:48:04 +09:00
`,
// textarea
textarea: `
2025-10-17 16:21:08 +09:00
min-h-[80px] w-full px-3 py-2 text-sm
border border-input rounded-md
bg-background text-foreground
transition-colors
focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
disabled:cursor-not-allowed disabled:opacity-50
2025-10-14 17:40:51 +09:00
resize-none
max-w-full box-border
2025-10-14 11:48:04 +09:00
`,
// select
select: `
2025-10-17 16:21:08 +09:00
h-9 w-full px-3 py-2 text-sm
border border-input rounded-md
bg-background text-foreground
transition-colors
focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
disabled:cursor-not-allowed disabled:opacity-50
2025-10-14 11:48:04 +09:00
cursor-pointer
2025-10-14 17:40:51 +09:00
max-w-full box-border
2025-10-14 11:48:04 +09:00
`,
// flex 컨테이너 (email, tel, url 등)
flexContainer: `
2025-10-14 17:40:51 +09:00
flex items-center gap-2 w-full h-full max-w-full box-border
2025-10-14 11:48:04 +09:00
`,
// 구분자 (@ , ~ 등)
separator: `
2025-10-17 16:21:08 +09:00
text-sm font-medium text-muted-foreground
2025-10-14 11:48:04 +09:00
`,
// Currency 통화 기호
currencySymbol: `
2025-10-17 16:21:08 +09:00
text-sm font-semibold text-green-600 pl-2
2025-10-14 11:48:04 +09:00
`,
// Currency input
currencyInput: `
2025-10-17 16:21:08 +09:00
flex-1 h-9 px-3 py-2 text-sm font-semibold text-right
border border-input rounded-md
bg-background text-green-600
transition-colors
focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
disabled:cursor-not-allowed disabled:opacity-50
2025-10-14 11:48:04 +09:00
`,
// Percentage 퍼센트 기호
percentageSymbol: `
2025-10-17 16:21:08 +09:00
text-sm font-semibold text-blue-600 pr-2
2025-10-14 11:48:04 +09:00
`,
// Percentage input
percentageInput: `
2025-10-17 16:21:08 +09:00
flex-1 h-9 px-3 py-2 text-sm font-semibold text-right
border border-input rounded-md
bg-background text-blue-600
transition-colors
focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
disabled:cursor-not-allowed disabled:opacity-50
2025-10-14 11:48:04 +09:00
`,
};
/**
*
*/
export function cn(...classes: (string | boolean | undefined)[]): string {
return classes.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
}
/**
* Input
*/
export function getInputClasses(isSelected?: boolean, isDisabled?: boolean): string {
return cn(INPUT_CLASSES.base, isSelected && INPUT_CLASSES.selected, isDisabled && "opacity-60");
}