@tansy/forms 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/admin.d.ts +2 -0
- package/admin.js +36 -0
- package/form.d.ts +15 -0
- package/form.js +101 -0
- package/forms.css +35 -0
- package/index.d.ts +12 -0
- package/index.js +233 -0
- package/logic.d.ts +59 -0
- package/logic.js +173 -0
- package/messages.d.ts +78 -0
- package/messages.js +157 -0
- package/package.json +40 -4
- package/render.d.ts +4 -0
- package/render.js +48 -0
- package/schema.d.ts +208 -0
- package/schema.js +71 -0
- package/site-messages.d.ts +91 -0
- package/site-messages.js +94 -0
- package/status.d.ts +2 -0
- package/status.js +18 -0
package/schema.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { type PluginBlock } from "tansy/plugin";
|
|
2
|
+
/** The collections Forms creates on first install. Owners can change all of it afterwards. */
|
|
3
|
+
export declare const FORMS = "forms-forms";
|
|
4
|
+
export declare const SUBMISSIONS = "forms-submissions";
|
|
5
|
+
export declare const COLLECTIONS: readonly ["forms-forms", "forms-submissions"];
|
|
6
|
+
/** The fields a form is built from, in its `fields` stream. They belong to the plugin, so the server knows how to check each one. */
|
|
7
|
+
export declare const FIELD_BLOCKS: PluginBlock[];
|
|
8
|
+
export declare const FIELD_BLOCK_NAMES: string[];
|
|
9
|
+
/** A field the plugin's code reads or writes, by collection: the contract Extensions checks. */
|
|
10
|
+
export declare const CONTRACT: {
|
|
11
|
+
"forms-forms": {
|
|
12
|
+
title: string;
|
|
13
|
+
fields: string;
|
|
14
|
+
submitLabel: string;
|
|
15
|
+
successMessage: string;
|
|
16
|
+
notify: string;
|
|
17
|
+
captcha: string;
|
|
18
|
+
};
|
|
19
|
+
"forms-submissions": {
|
|
20
|
+
form: string;
|
|
21
|
+
data: string;
|
|
22
|
+
email: string;
|
|
23
|
+
page: string;
|
|
24
|
+
state: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare function formsSchema(): {
|
|
28
|
+
version: number;
|
|
29
|
+
collections: ({
|
|
30
|
+
slug: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
urlPattern: null;
|
|
34
|
+
rules: {
|
|
35
|
+
createRule: null;
|
|
36
|
+
updateRule: null;
|
|
37
|
+
deleteRule: null;
|
|
38
|
+
listRule: null;
|
|
39
|
+
viewRule: string;
|
|
40
|
+
};
|
|
41
|
+
fields: ({
|
|
42
|
+
name: string;
|
|
43
|
+
type: string;
|
|
44
|
+
config: {
|
|
45
|
+
required: boolean;
|
|
46
|
+
maxLength: number;
|
|
47
|
+
allowedBlocks?: undefined;
|
|
48
|
+
description?: undefined;
|
|
49
|
+
multiline?: undefined;
|
|
50
|
+
hidden?: undefined;
|
|
51
|
+
defaultValue?: undefined;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
config: {
|
|
57
|
+
allowedBlocks: string[];
|
|
58
|
+
description: string;
|
|
59
|
+
required?: undefined;
|
|
60
|
+
maxLength?: undefined;
|
|
61
|
+
multiline?: undefined;
|
|
62
|
+
hidden?: undefined;
|
|
63
|
+
defaultValue?: undefined;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
name: string;
|
|
67
|
+
type: string;
|
|
68
|
+
config: {
|
|
69
|
+
maxLength: number;
|
|
70
|
+
description: string;
|
|
71
|
+
required?: undefined;
|
|
72
|
+
allowedBlocks?: undefined;
|
|
73
|
+
multiline?: undefined;
|
|
74
|
+
hidden?: undefined;
|
|
75
|
+
defaultValue?: undefined;
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
78
|
+
name: string;
|
|
79
|
+
type: string;
|
|
80
|
+
config: {
|
|
81
|
+
multiline: boolean;
|
|
82
|
+
maxLength: number;
|
|
83
|
+
description: string;
|
|
84
|
+
required?: undefined;
|
|
85
|
+
allowedBlocks?: undefined;
|
|
86
|
+
hidden?: undefined;
|
|
87
|
+
defaultValue?: undefined;
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
name: string;
|
|
91
|
+
type: string;
|
|
92
|
+
config: {
|
|
93
|
+
hidden: boolean;
|
|
94
|
+
maxLength: number;
|
|
95
|
+
description: string;
|
|
96
|
+
required?: undefined;
|
|
97
|
+
allowedBlocks?: undefined;
|
|
98
|
+
multiline?: undefined;
|
|
99
|
+
defaultValue?: undefined;
|
|
100
|
+
};
|
|
101
|
+
} | {
|
|
102
|
+
name: string;
|
|
103
|
+
type: string;
|
|
104
|
+
config: {
|
|
105
|
+
defaultValue: boolean;
|
|
106
|
+
description: string;
|
|
107
|
+
required?: undefined;
|
|
108
|
+
maxLength?: undefined;
|
|
109
|
+
allowedBlocks?: undefined;
|
|
110
|
+
multiline?: undefined;
|
|
111
|
+
hidden?: undefined;
|
|
112
|
+
};
|
|
113
|
+
})[];
|
|
114
|
+
} | {
|
|
115
|
+
slug: string;
|
|
116
|
+
name: string;
|
|
117
|
+
description: string;
|
|
118
|
+
urlPattern: null;
|
|
119
|
+
rules: {
|
|
120
|
+
createRule: null;
|
|
121
|
+
updateRule: null;
|
|
122
|
+
deleteRule: null;
|
|
123
|
+
listRule: null;
|
|
124
|
+
viewRule: null;
|
|
125
|
+
};
|
|
126
|
+
fields: ({
|
|
127
|
+
name: string;
|
|
128
|
+
type: string;
|
|
129
|
+
config: {
|
|
130
|
+
collection: string;
|
|
131
|
+
displayField: string;
|
|
132
|
+
required: boolean;
|
|
133
|
+
description?: undefined;
|
|
134
|
+
maxLength?: undefined;
|
|
135
|
+
options?: undefined;
|
|
136
|
+
defaultValue?: undefined;
|
|
137
|
+
};
|
|
138
|
+
} | {
|
|
139
|
+
name: string;
|
|
140
|
+
type: string;
|
|
141
|
+
config: {
|
|
142
|
+
description: string;
|
|
143
|
+
collection?: undefined;
|
|
144
|
+
displayField?: undefined;
|
|
145
|
+
required?: undefined;
|
|
146
|
+
maxLength?: undefined;
|
|
147
|
+
options?: undefined;
|
|
148
|
+
defaultValue?: undefined;
|
|
149
|
+
};
|
|
150
|
+
} | {
|
|
151
|
+
name: string;
|
|
152
|
+
type: string;
|
|
153
|
+
config: {
|
|
154
|
+
required: boolean;
|
|
155
|
+
description: string;
|
|
156
|
+
collection?: undefined;
|
|
157
|
+
displayField?: undefined;
|
|
158
|
+
maxLength?: undefined;
|
|
159
|
+
options?: undefined;
|
|
160
|
+
defaultValue?: undefined;
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
name: string;
|
|
164
|
+
type: string;
|
|
165
|
+
config: {
|
|
166
|
+
maxLength: number;
|
|
167
|
+
description: string;
|
|
168
|
+
collection?: undefined;
|
|
169
|
+
displayField?: undefined;
|
|
170
|
+
required?: undefined;
|
|
171
|
+
options?: undefined;
|
|
172
|
+
defaultValue?: undefined;
|
|
173
|
+
};
|
|
174
|
+
} | {
|
|
175
|
+
name: string;
|
|
176
|
+
type: string;
|
|
177
|
+
config: {
|
|
178
|
+
options: {
|
|
179
|
+
label: string;
|
|
180
|
+
value: string;
|
|
181
|
+
}[];
|
|
182
|
+
defaultValue: string;
|
|
183
|
+
collection?: undefined;
|
|
184
|
+
displayField?: undefined;
|
|
185
|
+
required?: undefined;
|
|
186
|
+
description?: undefined;
|
|
187
|
+
maxLength?: undefined;
|
|
188
|
+
};
|
|
189
|
+
})[];
|
|
190
|
+
})[];
|
|
191
|
+
blocks: {
|
|
192
|
+
name: string;
|
|
193
|
+
label: string;
|
|
194
|
+
labels: {
|
|
195
|
+
ar: string;
|
|
196
|
+
};
|
|
197
|
+
icon: null;
|
|
198
|
+
fields: {
|
|
199
|
+
name: string;
|
|
200
|
+
type: string;
|
|
201
|
+
config: {
|
|
202
|
+
collection: string;
|
|
203
|
+
displayField: string;
|
|
204
|
+
required: boolean;
|
|
205
|
+
};
|
|
206
|
+
}[];
|
|
207
|
+
}[];
|
|
208
|
+
};
|
package/schema.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defineBlock } from "tansy/plugin";
|
|
2
|
+
/** The collections Forms creates on first install. Owners can change all of it afterwards. */
|
|
3
|
+
export const FORMS = "forms-forms";
|
|
4
|
+
export const SUBMISSIONS = "forms-submissions";
|
|
5
|
+
export const COLLECTIONS = [FORMS, SUBMISSIONS];
|
|
6
|
+
/** A field's name is the key its answer is stored under, so it's kept plain. */
|
|
7
|
+
const NAME = {
|
|
8
|
+
name: "name",
|
|
9
|
+
type: "text",
|
|
10
|
+
config: { required: true, maxLength: 40, pattern: "^[a-z][a-z0-9_]*$", patternError: "Use lowercase letters, numbers and underscores, starting with a letter, such as company_name.", description: "Where the answer is stored. Each field in a form needs its own.", labels: { ar: "الاسم" }, descriptions: { ar: "المفتاح الذي تُحفظ تحته الإجابة. لكل حقل في النموذج اسمه الخاص." } },
|
|
11
|
+
};
|
|
12
|
+
const LABEL = { name: "label", type: "text", config: { required: true, maxLength: 200, labels: { ar: "التسمية" } } };
|
|
13
|
+
const HELP = { name: "help", type: "text", config: { maxLength: 300, description: "Shown under the field.", labels: { ar: "المساعدة" }, descriptions: { ar: "تظهر تحت الحقل." } } };
|
|
14
|
+
const REQUIRED = { name: "required", type: "boolean", config: { labels: { ar: "مطلوب" } } };
|
|
15
|
+
const PLACEHOLDER = { name: "placeholder", type: "text", config: { maxLength: 200, labels: { ar: "النص المؤقت" } } };
|
|
16
|
+
/** The fields a form is built from, in its `fields` stream. They belong to the plugin, so the server knows how to check each one. */
|
|
17
|
+
export const FIELD_BLOCKS = [
|
|
18
|
+
defineBlock({ name: "forms_text", label: "Short answer", labels: { ar: "إجابة قصيرة" }, category: "Form fields", defaults: { name: "name", label: "Name", required: true }, fields: [NAME, LABEL, REQUIRED, PLACEHOLDER, { name: "maxLength", type: "number", config: { min: 1, max: 1000, format: "integer", description: "200 when left empty.", labels: { ar: "أقصى طول" }, descriptions: { ar: "200 إن تُرك فارغًا." } } }, HELP] }),
|
|
19
|
+
defineBlock({ name: "forms_email", label: "Email", labels: { ar: "بريد إلكتروني" }, category: "Form fields", defaults: { name: "email", label: "Email", required: true }, fields: [NAME, LABEL, REQUIRED, PLACEHOLDER, HELP] }),
|
|
20
|
+
defineBlock({ name: "forms_textarea", label: "Long answer", labels: { ar: "إجابة طويلة" }, category: "Form fields", defaults: { name: "message", label: "Message", required: true }, fields: [NAME, LABEL, REQUIRED, PLACEHOLDER, { name: "maxLength", type: "number", config: { min: 1, max: 10000, format: "integer", description: "5,000 when left empty.", labels: { ar: "أقصى طول" }, descriptions: { ar: "5,000 إن تُرك فارغًا." } } }, HELP] }),
|
|
21
|
+
defineBlock({ name: "forms_select", label: "Choice", labels: { ar: "اختيار" }, category: "Form fields", defaults: { name: "topic", label: "Topic", options: "Sales\nSupport" }, fields: [NAME, LABEL, REQUIRED, { name: "options", type: "text", config: { required: true, multiline: true, maxLength: 5000, description: "One choice per line.", labels: { ar: "الخيارات" }, descriptions: { ar: "خيار في كل سطر." } } }, HELP] }),
|
|
22
|
+
defineBlock({ name: "forms_checkbox", label: "Checkbox", labels: { ar: "مربع اختيار" }, category: "Form fields", defaults: { name: "consent", label: "You may contact me about this message", required: true }, fields: [NAME, LABEL, { ...REQUIRED, config: { ...REQUIRED.config, description: "The box must be ticked to send, as for consent.", descriptions: { ar: "يجب تحديد المربع للإرسال، كما في الموافقة." } } }, HELP] }),
|
|
23
|
+
defineBlock({ name: "forms_number", label: "Number", labels: { ar: "رقم" }, category: "Form fields", defaults: { name: "quantity", label: "Quantity" }, fields: [NAME, LABEL, REQUIRED, { name: "min", type: "number", config: { labels: { ar: "الحد الأدنى" } } }, { name: "max", type: "number", config: { labels: { ar: "الحد الأقصى" } } }, HELP] }),
|
|
24
|
+
];
|
|
25
|
+
export const FIELD_BLOCK_NAMES = FIELD_BLOCKS.map((block) => block.name);
|
|
26
|
+
/** A field the plugin's code reads or writes, by collection: the contract Extensions checks. */
|
|
27
|
+
export const CONTRACT = {
|
|
28
|
+
[FORMS]: { title: "text", fields: "stream", submitLabel: "text", successMessage: "text", notify: "text", captcha: "boolean" },
|
|
29
|
+
[SUBMISSIONS]: { form: "reference", data: "json", email: "email", page: "text", state: "radio" },
|
|
30
|
+
};
|
|
31
|
+
const LOCKED = { createRule: null, updateRule: null, deleteRule: null };
|
|
32
|
+
export function formsSchema() {
|
|
33
|
+
return {
|
|
34
|
+
version: 1,
|
|
35
|
+
collections: [
|
|
36
|
+
{
|
|
37
|
+
slug: FORMS,
|
|
38
|
+
name: "Forms",
|
|
39
|
+
description: "Contact forms and other forms visitors fill in. Put one on a page with the Form block.",
|
|
40
|
+
urlPattern: null,
|
|
41
|
+
// Visitors can open a published form, never list them, and only the plugin's route takes answers.
|
|
42
|
+
rules: { listRule: null, viewRule: 'status = "published"', ...LOCKED },
|
|
43
|
+
fields: [
|
|
44
|
+
{ name: "title", type: "text", config: { required: true, maxLength: 200 } },
|
|
45
|
+
{ name: "fields", type: "stream", config: { allowedBlocks: FIELD_BLOCK_NAMES, description: "What the form asks, in order." } },
|
|
46
|
+
{ name: "submitLabel", type: "text", config: { maxLength: 60, description: "The button. Send when left empty." } },
|
|
47
|
+
{ name: "successMessage", type: "text", config: { multiline: true, maxLength: 1000, description: "Shown once it's sent." } },
|
|
48
|
+
// Hidden, so the addresses never reach visitors.
|
|
49
|
+
{ name: "notify", type: "text", config: { hidden: true, maxLength: 1000, description: "Who gets each submission, separated by commas. Empty uses the addresses under Forms → Settings." } },
|
|
50
|
+
{ name: "captcha", type: "boolean", config: { defaultValue: true, description: "Ask for the site's CAPTCHA, once one is set up under Extensions → CAPTCHA." } },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
slug: SUBMISSIONS,
|
|
55
|
+
name: "Submissions",
|
|
56
|
+
description: "What visitors sent through forms. Only staff with permissions on this collection see them.",
|
|
57
|
+
urlPattern: null,
|
|
58
|
+
rules: { listRule: null, viewRule: null, ...LOCKED },
|
|
59
|
+
fields: [
|
|
60
|
+
{ name: "form", type: "reference", config: { collection: FORMS, displayField: "title", required: true } },
|
|
61
|
+
{ name: "email", type: "email", config: { description: "The visitor's address, from the form's first email field. Notifications reply to it." } },
|
|
62
|
+
{ name: "data", type: "json", config: { required: true, description: "The answers, by field name." } },
|
|
63
|
+
{ name: "page", type: "text", config: { maxLength: 300, description: "The page the form was sent from." } },
|
|
64
|
+
{ name: "state", type: "radio", config: { options: [{ label: "New", value: "new" }, { label: "Done", value: "done" }, { label: "Spam", value: "spam" }], defaultValue: "new" } },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
// Here rather than in the plugin's blocks, because it links to a collection this document creates.
|
|
69
|
+
blocks: [{ name: "forms_embed", label: "Form", labels: { ar: "نموذج" }, icon: null, fields: [{ name: "form", type: "reference", config: { collection: FORMS, displayField: "title", required: true } }] }],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** What visitors read on forms, and what owners read in the email about one, as `t("forms.<key>")`. Themes and owners can word any of it differently. */
|
|
2
|
+
export declare const siteMessages: {
|
|
3
|
+
en: {
|
|
4
|
+
forms: {
|
|
5
|
+
choose: string;
|
|
6
|
+
send: string;
|
|
7
|
+
sending: string;
|
|
8
|
+
thanks: string;
|
|
9
|
+
tooMany: string;
|
|
10
|
+
failed: string;
|
|
11
|
+
offline: string;
|
|
12
|
+
trap: string;
|
|
13
|
+
namePreview: string;
|
|
14
|
+
refusals: {
|
|
15
|
+
notFound: string;
|
|
16
|
+
tooFast: string;
|
|
17
|
+
expired: string;
|
|
18
|
+
invalid: string;
|
|
19
|
+
noFields: string;
|
|
20
|
+
captchaRequired: string;
|
|
21
|
+
captchaFailed: string;
|
|
22
|
+
};
|
|
23
|
+
errors: {
|
|
24
|
+
tick: string;
|
|
25
|
+
fill: string;
|
|
26
|
+
number: string;
|
|
27
|
+
min: string;
|
|
28
|
+
max: string;
|
|
29
|
+
text: string;
|
|
30
|
+
tooLong: string;
|
|
31
|
+
email: string;
|
|
32
|
+
option: string;
|
|
33
|
+
};
|
|
34
|
+
mail: {
|
|
35
|
+
subject: string;
|
|
36
|
+
aForm: string;
|
|
37
|
+
intro: string;
|
|
38
|
+
introOn: string;
|
|
39
|
+
yes: string;
|
|
40
|
+
no: string;
|
|
41
|
+
outro: string;
|
|
42
|
+
rest: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
ar: {
|
|
47
|
+
forms: {
|
|
48
|
+
choose: string;
|
|
49
|
+
send: string;
|
|
50
|
+
sending: string;
|
|
51
|
+
thanks: string;
|
|
52
|
+
tooMany: string;
|
|
53
|
+
failed: string;
|
|
54
|
+
offline: string;
|
|
55
|
+
trap: string;
|
|
56
|
+
namePreview: string;
|
|
57
|
+
refusals: {
|
|
58
|
+
notFound: string;
|
|
59
|
+
tooFast: string;
|
|
60
|
+
expired: string;
|
|
61
|
+
invalid: string;
|
|
62
|
+
noFields: string;
|
|
63
|
+
captchaRequired: string;
|
|
64
|
+
captchaFailed: string;
|
|
65
|
+
};
|
|
66
|
+
errors: {
|
|
67
|
+
tick: string;
|
|
68
|
+
fill: string;
|
|
69
|
+
number: string;
|
|
70
|
+
min: string;
|
|
71
|
+
max: string;
|
|
72
|
+
text: string;
|
|
73
|
+
tooLong: string;
|
|
74
|
+
email: string;
|
|
75
|
+
option: string;
|
|
76
|
+
};
|
|
77
|
+
mail: {
|
|
78
|
+
subject: string;
|
|
79
|
+
aForm: string;
|
|
80
|
+
intro: string;
|
|
81
|
+
introOn: string;
|
|
82
|
+
yes: string;
|
|
83
|
+
no: string;
|
|
84
|
+
outro: string;
|
|
85
|
+
rest: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** Looks up an English word by its dotted key under `forms`, filling in `{name}` values. For code that runs without a page's words, and for API callers. */
|
|
91
|
+
export declare function english(key: string, values?: Record<string, string | number>): string;
|
package/site-messages.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** What visitors read on forms, and what owners read in the email about one, as `t("forms.<key>")`. Themes and owners can word any of it differently. */
|
|
2
|
+
export const siteMessages = {
|
|
3
|
+
en: {
|
|
4
|
+
forms: {
|
|
5
|
+
choose: "Choose…",
|
|
6
|
+
send: "Send",
|
|
7
|
+
sending: "Sending…",
|
|
8
|
+
thanks: "Thanks. Your message was sent.",
|
|
9
|
+
tooMany: "You've sent this form several times. Try again in a few minutes.",
|
|
10
|
+
failed: "It couldn't be sent. Try again.",
|
|
11
|
+
offline: "It couldn't be sent. Check your connection and try again.",
|
|
12
|
+
trap: "Leave this empty",
|
|
13
|
+
namePreview: "Give this field a name and a label.",
|
|
14
|
+
refusals: {
|
|
15
|
+
notFound: "There's no form here.",
|
|
16
|
+
tooFast: "That was quick. Wait a few seconds, then send it again.",
|
|
17
|
+
expired: "This form has expired. Reload the page and send it again.",
|
|
18
|
+
invalid: "Check the highlighted fields.",
|
|
19
|
+
noFields: "This form doesn't ask anything yet.",
|
|
20
|
+
captchaRequired: "Complete the CAPTCHA, then send it again.",
|
|
21
|
+
captchaFailed: "The CAPTCHA wasn't accepted. Try it again.",
|
|
22
|
+
},
|
|
23
|
+
errors: {
|
|
24
|
+
tick: "Tick this box to send.",
|
|
25
|
+
fill: "Fill in this field.",
|
|
26
|
+
number: "Enter a number.",
|
|
27
|
+
min: "Enter {min} or more.",
|
|
28
|
+
max: "Enter {max} or less.",
|
|
29
|
+
text: "Enter text.",
|
|
30
|
+
tooLong: "Keep it under {limit} characters.",
|
|
31
|
+
email: "Enter an email address.",
|
|
32
|
+
option: "Choose one of the options.",
|
|
33
|
+
},
|
|
34
|
+
mail: {
|
|
35
|
+
subject: "New submission: {title}",
|
|
36
|
+
aForm: "a form",
|
|
37
|
+
intro: "Someone filled in \"{title}\".",
|
|
38
|
+
introOn: "Someone filled in \"{title}\" on {page}.",
|
|
39
|
+
yes: "Yes",
|
|
40
|
+
no: "No",
|
|
41
|
+
outro: "Find it under Forms → Submissions in the dashboard. Reply to this email to answer them, when the form asked for their address.",
|
|
42
|
+
rest: "The rest is in the dashboard.",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
ar: {
|
|
47
|
+
forms: {
|
|
48
|
+
choose: "اختر…",
|
|
49
|
+
send: "إرسال",
|
|
50
|
+
sending: "جارٍ الإرسال…",
|
|
51
|
+
thanks: "شكرًا. أُرسلت رسالتك.",
|
|
52
|
+
tooMany: "أرسلت هذا النموذج عدة مرات. حاول مجددًا بعد بضع دقائق.",
|
|
53
|
+
failed: "تعذّر الإرسال. حاول مجددًا.",
|
|
54
|
+
offline: "تعذّر الإرسال. تحقق من اتصالك وحاول مجددًا.",
|
|
55
|
+
trap: "اترك هذا فارغًا",
|
|
56
|
+
namePreview: "أعطِ هذا الحقل اسمًا وتسمية.",
|
|
57
|
+
refusals: {
|
|
58
|
+
notFound: "لا يوجد نموذج هنا.",
|
|
59
|
+
tooFast: "كان ذلك سريعًا. انتظر بضع ثوانٍ ثم أرسله مجددًا.",
|
|
60
|
+
expired: "انتهت صلاحية هذا النموذج. أعد تحميل الصفحة وأرسله مجددًا.",
|
|
61
|
+
invalid: "راجع الحقول المحددة.",
|
|
62
|
+
noFields: "لا يطرح هذا النموذج أي سؤال بعد.",
|
|
63
|
+
captchaRequired: "أكمل اختبار CAPTCHA ثم أرسله مجددًا.",
|
|
64
|
+
captchaFailed: "لم يُقبل اختبار CAPTCHA. حاول مجددًا.",
|
|
65
|
+
},
|
|
66
|
+
errors: {
|
|
67
|
+
tick: "حدّد هذا المربع للإرسال.",
|
|
68
|
+
fill: "املأ هذا الحقل.",
|
|
69
|
+
number: "أدخل رقمًا.",
|
|
70
|
+
min: "أدخل {min} أو أكثر.",
|
|
71
|
+
max: "أدخل {max} أو أقل.",
|
|
72
|
+
text: "أدخل نصًا.",
|
|
73
|
+
tooLong: "اجعله أقل من {limit} حرفًا.",
|
|
74
|
+
email: "أدخل عنوان بريد إلكتروني.",
|
|
75
|
+
option: "اختر أحد الخيارات.",
|
|
76
|
+
},
|
|
77
|
+
mail: {
|
|
78
|
+
subject: "إرسال جديد: {title}",
|
|
79
|
+
aForm: "نموذج",
|
|
80
|
+
intro: "ملأ أحدهم «{title}».",
|
|
81
|
+
introOn: "ملأ أحدهم «{title}» في {page}.",
|
|
82
|
+
yes: "نعم",
|
|
83
|
+
no: "لا",
|
|
84
|
+
outro: "تجده في النماذج ← الإرسالات في لوحة التحكم. ردّ على هذه الرسالة لتجيبه، إن طلب النموذج عنوانه.",
|
|
85
|
+
rest: "البقية في لوحة التحكم.",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
/** Looks up an English word by its dotted key under `forms`, filling in `{name}` values. For code that runs without a page's words, and for API callers. */
|
|
91
|
+
export function english(key, values = {}) {
|
|
92
|
+
const found = key.replace(/^forms\./, "").split(".").reduce((node, part) => (node && typeof node === "object" ? node[part] : undefined), siteMessages.en.forms);
|
|
93
|
+
return typeof found === "string" ? found.replace(/\{(\w+)\}/g, (_, name) => String(values[name] ?? "")) : key;
|
|
94
|
+
}
|
package/status.d.ts
ADDED
package/status.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Alert, apiPath, useT } from "tansy/admin";
|
|
5
|
+
/** Says what's missing for forms to reach anyone: email to deliver notifications, and a CAPTCHA to keep scripts out. */
|
|
6
|
+
export function SetupStatus() {
|
|
7
|
+
const { t } = useT();
|
|
8
|
+
const [status, setStatus] = useState(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
let active = true;
|
|
11
|
+
fetch(apiPath("/ext/forms/status")).then((response) => (response.ok ? response.json() : null)).then((json) => { if (active)
|
|
12
|
+
setStatus(json); }).catch(() => { });
|
|
13
|
+
return () => { active = false; };
|
|
14
|
+
}, []);
|
|
15
|
+
if (!status)
|
|
16
|
+
return null;
|
|
17
|
+
return (_jsxs("div", { className: "cms-stack-2 cms-mb-6", children: [!status.mail && _jsx(Alert, { kind: "warning", children: t("ext.forms.status.noMail") }), !status.captcha && _jsx(Alert, { kind: "info", children: t("ext.forms.status.noCaptcha") })] }));
|
|
18
|
+
}
|