-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathinitForm.js
76 lines (69 loc) · 1.8 KB
/
initForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { generateUUID } from "~/lib/utils.js"
export const DEFAULT_COLOR = '#3B82F6'
export const initForm = (defaultValue = {}, withDefaultProperties = false) => {
return useForm({
title: "My Form",
description: null,
visibility: "public",
workspace_id: null,
properties: withDefaultProperties ? getDefaultProperties() : [],
// Customization
font_family: null,
theme: "default",
width: "centered",
dark_mode: "auto",
color: DEFAULT_COLOR,
hide_title: false,
no_branding: false,
uppercase_labels: false,
transparent_background: false,
closes_at: null,
closed_text:
"This form has now been closed by its owner and does not accept submissions anymore.",
auto_save: true,
auto_focus: true,
border_radius: 'small',
size: 'md',
// Submission
submit_button_text: "Submit",
re_fillable: false,
re_fill_button_text: "Fill Again",
submitted_text:
"Amazing, we saved your answers. Thank you for your time and have a great day!",
use_captcha: false,
max_submissions_count: null,
max_submissions_reached_text:
"This form has now reached the maximum number of allowed submissions and is now closed.",
editable_submissions_button_text: "Edit submission",
confetti_on_submission: false,
// Security & Privacy
can_be_indexed: true,
// Custom SEO
seo_meta: {},
...defaultValue,
})
}
function getDefaultProperties() {
return [
{
name: "Name",
type: "text",
hidden: false,
required: true,
id: generateUUID(),
},
{
name: "Email",
type: "email",
hidden: false,
id: generateUUID(),
},
{
name: "Message",
type: "text",
hidden: false,
multi_lines: true,
id: generateUUID(),
},
]
}