scalar_cms/
editor_type.rs1use chrono::{DateTime, Utc};
2use serde::Serialize;
3use ts_rs::TS;
4
5use crate::EditorField;
6
7#[derive(Serialize, TS)]
8#[serde(tag = "type", rename_all = "kebab-case")]
9pub enum EditorType {
10 Toggle {
11 component_key: Option<String>,
12 #[ts(type = "any | null")]
13 default: Option<serde_json::Value>,
14 value: Box<EditorType>,
15 },
16 Bool {
17 component_key: Option<String>,
18 default: Option<bool>,
19 },
20 Integer {
21 component_key: Option<String>,
22 default: Option<i32>,
23 },
24 Float {
25 component_key: Option<String>,
26 default: Option<f32>,
27 },
28 Struct {
29 component_key: Option<String>,
30 #[ts(type = "any | null")]
31 default: Option<serde_json::Value>,
32 fields: Vec<EditorField>,
33 },
34 Enum {
35 component_key: Option<String>,
36 #[ts(type = "any | null")]
37 default: Option<serde_json::Value>,
38 variants: Vec<EnumVariant>,
39 },
40 Array {
41 component_key: Option<String>,
42 #[ts(type = "any[] | null")]
43 default: Option<serde_json::Value>,
44 of: Box<EditorType>,
45 },
46 SingleLine {
47 component_key: Option<String>,
48 default: Option<String>,
49 },
50 MultiLine {
51 component_key: Option<String>,
52 default: Option<String>,
53 },
54 Markdown {
55 component_key: Option<String>,
56 default: Option<String>,
57 },
58 Date {
59 component_key: Option<String>,
60 default: Option<DateTime<Utc>>,
61 },
62 DateTime {
63 component_key: Option<String>,
64 default: Option<DateTime<Utc>>,
65 },
66 Null {
67 component_key: Option<String>,
68 },
69}
70
71#[derive(Serialize, TS)]
72pub struct EnumVariant {
73 pub variant_name: &'static str,
74 pub fields: Option<Vec<EditorField>>,
75}