40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
/**
|
|
* button-primary 컴포넌트 Zod 스키마 및 기본값
|
|
*/
|
|
import { z } from "zod";
|
|
|
|
// 버튼 액션 스키마
|
|
export const buttonActionSchema = z.object({
|
|
type: z.string().default("save"),
|
|
targetScreenId: z.number().optional(),
|
|
successMessage: z.string().optional(),
|
|
errorMessage: z.string().optional(),
|
|
modalSize: z.string().optional(),
|
|
modalTitle: z.string().optional(),
|
|
modalDescription: z.string().optional(),
|
|
modalTitleBlocks: z.array(z.any()).optional(),
|
|
});
|
|
|
|
// button-primary 설정 스키마
|
|
export const buttonPrimaryConfigSchema = z.object({
|
|
type: z.literal("button-primary").default("button-primary"),
|
|
text: z.string().default("저장"),
|
|
actionType: z.enum(["button", "submit", "reset"]).default("button"),
|
|
variant: z.enum(["primary", "secondary", "danger", "outline", "destructive"]).default("primary"),
|
|
webType: z.literal("button").default("button"),
|
|
action: buttonActionSchema.optional(),
|
|
// 추가 속성들
|
|
label: z.string().optional(),
|
|
langKey: z.string().optional(),
|
|
langKeyId: z.number().optional(),
|
|
size: z.string().optional(),
|
|
backgroundColor: z.string().optional(),
|
|
textColor: z.string().optional(),
|
|
borderRadius: z.string().optional(),
|
|
});
|
|
|
|
export type ButtonPrimaryConfig = z.infer<typeof buttonPrimaryConfigSchema>;
|
|
|
|
// 기본값 (스키마에서 자동 생성)
|
|
export const buttonPrimaryDefaults: ButtonPrimaryConfig = buttonPrimaryConfigSchema.parse({});
|