@sharadox/form-web-library 0.4.1 → 0.5.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/README.md +2 -3
- package/distribution/contact-action/index.d.ts +6 -6
- package/distribution/contact-action/index.d.ts.map +1 -1
- package/distribution/contact-action/index.js +59 -24
- package/distribution/contact-action/index.js.map +1 -1
- package/distribution/contact-action/type.d.ts +15 -4
- package/distribution/contact-action/type.d.ts.map +1 -1
- package/llms.txt +2 -2
- package/package.json +2 -2
- package/distribution/contact-email/index.d.ts +0 -12
- package/distribution/contact-email/index.d.ts.map +0 -1
- package/distribution/contact-email/index.js +0 -47
- package/distribution/contact-email/index.js.map +0 -1
- package/distribution/contact-email/type.d.ts +0 -41
- package/distribution/contact-email/type.d.ts.map +0 -1
- package/distribution/contact-email/type.js +0 -2
- package/distribution/contact-email/type.js.map +0 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ export const sendContact = createContactAction({
|
|
|
29
29
|
site: "example.com",
|
|
30
30
|
choices: { website: "Website", logo: "Logo", other: "Others" },
|
|
31
31
|
logo: async () => ({ content: await readFile(LOGO), contentType: "image/png", filename: "logo.png" }),
|
|
32
|
-
|
|
32
|
+
design: { background: "#000000", foreground: "#ffffff", accent: "#ffffff" },
|
|
33
33
|
acknowledgement: {
|
|
34
34
|
en: {
|
|
35
35
|
subject: "Example · We received your message",
|
|
@@ -46,7 +46,7 @@ Every email has the same layout: the company's logo and name on its colors at th
|
|
|
46
46
|
(and company), every detail they gave, their message, and at the bottom the page the form was sent from, the
|
|
47
47
|
language, the time and the IP address. Replying answers the visitor. With `acknowledgement`, a visitor who left an
|
|
48
48
|
email also gets an automatic reply in their language, with their message, and replying to it reaches the company.
|
|
49
|
-
|
|
49
|
+
The emails are laid out by email-web-library's `emailLayout` in the brand's `design` (its `EmailDesign`), which a site also uses for any other email it sends.
|
|
50
50
|
|
|
51
51
|
```ts
|
|
52
52
|
|
|
@@ -75,7 +75,6 @@ The email server comes from `EMAIL_SERVER_*` and `EMAIL_SENDER_ADDRESS`.
|
|
|
75
75
|
| Import | Export |
|
|
76
76
|
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
77
|
| `…/contact-action` | `createContactAction(options)` → `(form, ip) => Promise<ContactState>`; `ENGLISH_LABELS`, `PLAIN_THEME`, `LANGUAGE_NAMES`, `formPage(value, site)`; `ContactState`, `ContactActionOptions`, `ContactLabels`, `ContactAcknowledgement` and `EmailLogo` in `…/contact-action/type` |
|
|
78
|
-
| `…/contact-email` | `brandedEmailHtml({ company, theme, logo, language, preview, eyebrow, heading, paragraphs?, rows?, quote?, footer? })`: the company's email layout (logo as `cid:logo`) |
|
|
79
78
|
| `…/parse-contact` | `parseContact(form, { choices?, choiceField?, reach?, requireMessage?, minimumMessageLength?, requireChoice?, fields?, now? })` → `bot`, `invalid` or `valid` |
|
|
80
79
|
| `…/contact-check` | `isEmail(text)`, `isPhone(text)`: the rules the action uses, safe in the browser for checks before sending |
|
|
81
80
|
| `…/bot-check` | `isLikelyBot(form, { honeypotField?, startedAtField?, minimumFillTime?, now? })` |
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EmailDesign } from "@sharadox/email-web-library";
|
|
2
2
|
import type { ContactActionOptions, ContactLabels, ContactState } from "@sharadox/form-web-library/contact-action/type";
|
|
3
3
|
/** The email's words when the site gives none. */
|
|
4
4
|
export declare const ENGLISH_LABELS: ContactLabels;
|
|
5
|
-
/** Black
|
|
6
|
-
export declare const
|
|
5
|
+
/** Black on white, plainly, when the site gives no design of its own. */
|
|
6
|
+
export declare const plainDesign: (company: string) => EmailDesign;
|
|
7
7
|
/** Common languages' names, when the site gives none. */
|
|
8
8
|
export declare const LANGUAGE_NAMES: Readonly<Record<string, string>>;
|
|
9
9
|
/**
|
|
@@ -14,8 +14,8 @@ export declare function formPage(value: ReturnType<FormData["get"]>, site: strin
|
|
|
14
14
|
/**
|
|
15
15
|
* Builds the work of a contact form's server action: checks for bots (they get a fake success), validates, limits
|
|
16
16
|
* each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then emails
|
|
17
|
-
* the company in its own
|
|
18
|
-
* page, language, time and IP at the bottom. It comes from "<company> Web Application" with the subject
|
|
17
|
+
* the company in its own design (`design`): its logo at the top, every detail the visitor gave, their message, a
|
|
18
|
+
* button to answer them, and the page, language, time and IP at the bottom. It comes from "<company> Web Application" with the subject
|
|
19
19
|
* "<company> Web Application · Contact · Name (Company)", and replying answers the visitor. When the visitor left an
|
|
20
20
|
* email and the site gives an `acknowledgement`, they get an automatic reply in their language with their message,
|
|
21
21
|
* which the company can be reached by replying to. Sites can accept a phone instead of an email (`reach`), make the
|
|
@@ -26,5 +26,5 @@ export declare function formPage(value: ReturnType<FormData["get"]>, site: strin
|
|
|
26
26
|
* // in a "use server" file:
|
|
27
27
|
* export async function sendContactAction(_: ContactState, form: FormData) { return sendContact(form, ip); }
|
|
28
28
|
*/
|
|
29
|
-
export declare function createContactAction({ to, company, senderAddress, logo,
|
|
29
|
+
export declare function createContactAction({ to, company, senderAddress, logo, design: givenDesign, languageNames, acknowledgement, choices, site, reach, requireMessage, minimumMessageLength, requireChoice, fields, labels: givenLabels, rateLimit, dailyMaximum, readConfiguration, createSender, reportError, now, }: ContactActionOptions): (form: FormData, ip: string) => Promise<ContactState>;
|
|
30
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,6BAA6B,CAAC;AAKtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAIxH,kDAAkD;AAClD,eAAO,MAAM,cAAc,EAAE,aAa5B,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,WA2B5C,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS7F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,EAAE,EACF,OAAO,EACP,aAAa,EACb,IAAI,EACJ,MAAM,EAAE,WAAW,EACnB,aAA8B,EAC9B,eAAe,EACf,OAAY,EACZ,IAAI,EACJ,KAAe,EACf,cAAqB,EACrB,oBAAwB,EACxB,aAAqB,EACrB,MAAW,EACX,MAAM,EAAE,WAAgB,EACxB,SAAkD,EAClD,YAAiB,EACjB,iBAAgD,EAChD,YAAgC,EAChC,WAA+D,EAC/D,GAAsB,GACvB,EAAE,oBAAoB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CA2I9E"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { createEmailSender, EmailError, readEmailServerConfiguration } from "@sharadox/email-web-library";
|
|
1
|
+
import { createEmailSender, EmailError, emailLayout, readEmailServerConfiguration } from "@sharadox/email-web-library";
|
|
2
2
|
import { separate } from "@sharadox/web-library/text/separate";
|
|
3
3
|
import { SEPARATOR } from "@sharadox/web-library/text/separator";
|
|
4
|
-
import { brandedEmailHtml } from "@sharadox/form-web-library/contact-email";
|
|
5
4
|
import { createRateLimiter } from "@sharadox/form-web-library/rate-limit";
|
|
6
5
|
import { parseContact } from "@sharadox/form-web-library/parse-contact";
|
|
7
6
|
const oneLine = (text) => text.replace(/[\r\n]+/g, " ");
|
|
@@ -17,9 +16,38 @@ export const ENGLISH_LABELS = {
|
|
|
17
16
|
message: "Message",
|
|
18
17
|
page: "Form",
|
|
19
18
|
sent: "Sent",
|
|
19
|
+
reply: "Reply to",
|
|
20
|
+
call: "Call",
|
|
20
21
|
};
|
|
21
|
-
/** Black
|
|
22
|
-
export const
|
|
22
|
+
/** Black on white, plainly, when the site gives no design of its own. */
|
|
23
|
+
export const plainDesign = (company) => ({
|
|
24
|
+
name: company,
|
|
25
|
+
logo: { width: 44, height: 44 },
|
|
26
|
+
wordmark: true,
|
|
27
|
+
align: "left",
|
|
28
|
+
colors: {
|
|
29
|
+
page: "#f4f4f5",
|
|
30
|
+
card: "#ffffff",
|
|
31
|
+
edge: "#e4e4e7",
|
|
32
|
+
text: "#09090b",
|
|
33
|
+
muted: "#3f3f46",
|
|
34
|
+
quiet: "#71717a",
|
|
35
|
+
rule: "#ececec",
|
|
36
|
+
accent: "#09090b",
|
|
37
|
+
box: "#f6f6f7",
|
|
38
|
+
onAccent: "#ffffff",
|
|
39
|
+
},
|
|
40
|
+
fonts: {
|
|
41
|
+
heading: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
42
|
+
body: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
43
|
+
label: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
44
|
+
},
|
|
45
|
+
heading: { size: 24, weight: 600, letterSpacing: "-0.02em", lineHeight: 1.3 },
|
|
46
|
+
label: { size: 11, letterSpacing: "0.12em" },
|
|
47
|
+
rule: "solid",
|
|
48
|
+
radius: 16,
|
|
49
|
+
button: { radius: 999, uppercase: false, letterSpacing: "0" },
|
|
50
|
+
});
|
|
23
51
|
/** Common languages' names, when the site gives none. */
|
|
24
52
|
export const LANGUAGE_NAMES = {
|
|
25
53
|
en: "English",
|
|
@@ -48,8 +76,8 @@ export function formPage(value, site) {
|
|
|
48
76
|
/**
|
|
49
77
|
* Builds the work of a contact form's server action: checks for bots (they get a fake success), validates, limits
|
|
50
78
|
* each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then emails
|
|
51
|
-
* the company in its own
|
|
52
|
-
* page, language, time and IP at the bottom. It comes from "<company> Web Application" with the subject
|
|
79
|
+
* the company in its own design (`design`): its logo at the top, every detail the visitor gave, their message, a
|
|
80
|
+
* button to answer them, and the page, language, time and IP at the bottom. It comes from "<company> Web Application" with the subject
|
|
53
81
|
* "<company> Web Application · Contact · Name (Company)", and replying answers the visitor. When the visitor left an
|
|
54
82
|
* email and the site gives an `acknowledgement`, they get an automatic reply in their language with their message,
|
|
55
83
|
* which the company can be reached by replying to. Sites can accept a phone instead of an email (`reach`), make the
|
|
@@ -60,11 +88,12 @@ export function formPage(value, site) {
|
|
|
60
88
|
* // in a "use server" file:
|
|
61
89
|
* export async function sendContactAction(_: ContactState, form: FormData) { return sendContact(form, ip); }
|
|
62
90
|
*/
|
|
63
|
-
export function createContactAction({ to, company, senderAddress, logo,
|
|
91
|
+
export function createContactAction({ to, company, senderAddress, logo, design: givenDesign, languageNames = LANGUAGE_NAMES, acknowledgement, choices = {}, site, reach = "email", requireMessage = true, minimumMessageLength = 1, requireChoice = false, fields = {}, labels: givenLabels = {}, rateLimit = { window: 60 * 60 * 1000, maximum: 5 }, dailyMaximum = 50, readConfiguration = readEmailServerConfiguration, createSender = createEmailSender, reportError = (message, error) => console.error(message, error), now = () => new Date(), }) {
|
|
64
92
|
const allow = createRateLimiter(rateLimit);
|
|
65
93
|
const allowToday = createRateLimiter({ window: 24 * 60 * 60 * 1000, maximum: dailyMaximum });
|
|
66
94
|
const labels = { ...ENGLISH_LABELS, ...givenLabels };
|
|
67
95
|
const senderName = `${company} Web Application`;
|
|
96
|
+
const design = givenDesign ?? plainDesign(company);
|
|
68
97
|
return async (form, ip) => {
|
|
69
98
|
const parsed = parseContact(form, {
|
|
70
99
|
choices: Object.keys(choices),
|
|
@@ -87,6 +116,11 @@ export function createContactAction({ to, company, senderAddress, logo, theme =
|
|
|
87
116
|
const sent = `${now().toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
88
117
|
const named = message.choices.map((choice) => choices[choice]);
|
|
89
118
|
const who = message.company ? `${message.name} (${message.company})` : message.name;
|
|
119
|
+
const firstName = message.name.split(/\s+/)[0];
|
|
120
|
+
// The one thing to do: answer by email, or call when only a phone was left.
|
|
121
|
+
const answer = message.email
|
|
122
|
+
? { label: `${labels.reply} ${firstName}`, href: `mailto:${message.email}` }
|
|
123
|
+
: { label: `${labels.call} ${firstName}`, href: `tel:${message.phone.replace(/[^\d+]/g, "")}` };
|
|
90
124
|
const rows = [
|
|
91
125
|
{ label: labels.name, value: message.name },
|
|
92
126
|
...(message.email ? [{ label: labels.email, value: message.email, href: `mailto:${message.email}` }] : []),
|
|
@@ -127,18 +161,16 @@ export function createContactAction({ to, company, senderAddress, logo, theme =
|
|
|
127
161
|
...(message.email ? { replyTo: { name: oneLine(message.name), address: message.email } } : {}),
|
|
128
162
|
subject: oneLine(separate(SEPARATOR, senderName, labels.contact, who)).slice(0, 300),
|
|
129
163
|
text,
|
|
130
|
-
html:
|
|
131
|
-
company,
|
|
132
|
-
theme,
|
|
133
|
-
logo: Boolean(image),
|
|
164
|
+
html: emailLayout({
|
|
134
165
|
language: "en",
|
|
135
166
|
preview: separate(SEPARATOR, who, named.join(", ")),
|
|
136
167
|
eyebrow: labels.contact,
|
|
137
168
|
heading: who,
|
|
138
169
|
rows,
|
|
139
170
|
...(message.message ? { quote: { label: labels.message, text: message.message } } : {}),
|
|
171
|
+
button: answer,
|
|
140
172
|
footer,
|
|
141
|
-
}),
|
|
173
|
+
}, design, Boolean(image)),
|
|
142
174
|
inlineImages,
|
|
143
175
|
});
|
|
144
176
|
// The automatic reply: never stops the message itself from counting as sent.
|
|
@@ -156,24 +188,27 @@ export function createContactAction({ to, company, senderAddress, logo, theme =
|
|
|
156
188
|
...reply.paragraphs,
|
|
157
189
|
...(message.message ? ["", `${reply.messageLabel}:`, message.message] : []),
|
|
158
190
|
].join("\n"),
|
|
159
|
-
html:
|
|
160
|
-
company,
|
|
161
|
-
theme,
|
|
162
|
-
logo: Boolean(image),
|
|
191
|
+
html: emailLayout({
|
|
163
192
|
language: message.locale,
|
|
164
193
|
preview: reply.paragraphs[0] ?? reply.subject,
|
|
165
194
|
eyebrow: reply.eyebrow,
|
|
166
195
|
heading: reply.heading(message.name),
|
|
167
196
|
paragraphs: reply.paragraphs,
|
|
168
197
|
...(message.message ? { quote: { label: reply.messageLabel, text: message.message } } : {}),
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
198
|
+
...(reply.button ? { button: reply.button } : {}),
|
|
199
|
+
// The company's own signature says where it is; without one, a line to its site does.
|
|
200
|
+
...(design.signature?.length
|
|
201
|
+
? {}
|
|
202
|
+
: {
|
|
203
|
+
footer: [
|
|
204
|
+
{
|
|
205
|
+
label: company,
|
|
206
|
+
value: page ? new URL(page).origin.replace("https://", "") : site,
|
|
207
|
+
href: page ? new URL(page).origin : `https://${site}`,
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
}),
|
|
211
|
+
}, design, Boolean(image)),
|
|
177
212
|
inlineImages,
|
|
178
213
|
});
|
|
179
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,WA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AqC,EAAE,KAAK,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;gBAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;YAClG,WAAW,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { EmailSender, EmailServerConfiguration } from "@sharadox/email-web-library";
|
|
2
|
-
import type { EmailTheme } from "@sharadox/form-web-library/contact-email/type";
|
|
1
|
+
import type { EmailDesign, EmailSender, EmailServerConfiguration } from "@sharadox/email-web-library";
|
|
3
2
|
import type { ContactReach } from "@sharadox/form-web-library/parse-contact/type";
|
|
4
3
|
/** What the form shows after a submission. */
|
|
5
4
|
export interface ContactState {
|
|
@@ -21,6 +20,10 @@ export interface ContactLabels {
|
|
|
21
20
|
page: string;
|
|
22
21
|
/** When it was sent: "Sent". */
|
|
23
22
|
sent: string;
|
|
23
|
+
/** The button that answers the visitor, before their first name: "Reply to". */
|
|
24
|
+
reply: string;
|
|
25
|
+
/** The button that calls a visitor who left only a phone, before their first name: "Call". */
|
|
26
|
+
call: string;
|
|
24
27
|
}
|
|
25
28
|
/** The automatic reply to the visitor, in one language: thanks, what happens next, and their message back. */
|
|
26
29
|
export interface ContactAcknowledgement {
|
|
@@ -34,6 +37,11 @@ export interface ContactAcknowledgement {
|
|
|
34
37
|
messageLabel: string;
|
|
35
38
|
/** The small capitals above the heading, for example "Message received". */
|
|
36
39
|
eyebrow: string;
|
|
40
|
+
/** A button under their message, for example to the site. */
|
|
41
|
+
button?: {
|
|
42
|
+
label: string;
|
|
43
|
+
href: string;
|
|
44
|
+
};
|
|
37
45
|
}
|
|
38
46
|
/** The company's logo at the top of every email: a square image (PNG), sent inside the email. */
|
|
39
47
|
export interface EmailLogo {
|
|
@@ -53,8 +61,11 @@ export interface ContactActionOptions {
|
|
|
53
61
|
senderAddress?: string;
|
|
54
62
|
/** The company's logo, at the top of every email. */
|
|
55
63
|
logo?: () => Promise<EmailLogo>;
|
|
56
|
-
/**
|
|
57
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The brand's design for its emails (email-web-library's `EmailDesign`: colors, type, rules, header, button,
|
|
66
|
+
* signature), so they look like its website; plain black on white by default.
|
|
67
|
+
*/
|
|
68
|
+
design?: EmailDesign;
|
|
58
69
|
/** Each language's name in the email, by code; English names of common languages by default. */
|
|
59
70
|
languageNames?: Readonly<Record<string, string>>;
|
|
60
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/contact-action/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/contact-action/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAElF,8CAA8C;AAC9C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,QAAQ,CAAC;CACjE;AAED,2GAA2G;AAC3G,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;I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
|
5
|
-
- /contact-action: createContactAction({ to, company (sender "<company> Web Application", subject "<company> Web Application · <labels.contact> · Name (Company)"), senderAddress?, site (domain; the form's `page` field is shown only on it or a subdomain), logo?: () => Promise<{ content, contentType, filename }> (inline cid:logo at the top),
|
|
6
|
-
- /contact-email brandedEmailHtml(options): the layout, for any email (tables, inline styles, escaped)
|
|
5
|
+
- /contact-action: createContactAction({ to, company (sender "<company> Web Application", subject "<company> Web Application · <labels.contact> · Name (Company)"), senderAddress?, site (domain; the form's `page` field is shown only on it or a subdomain), logo?: () => Promise<{ content, contentType, filename }> (inline cid:logo at the top), design? { background, foreground, accent }, languageNames?, acknowledgement?: { [locale]: { subject, eyebrow, heading(name), paragraphs, messageLabel } } (automatic reply to the visitor's email, in their language, reply-to = to; a failed reply never fails the send), choices?: { key: label }, reach? = 'email' | 'email-or-phone', requireMessage? = true, minimumMessageLength? = 1, requireChoice? = false, fields?: { name: label }, labels?: Partial<ContactLabels> (English default, ENGLISH_LABELS), rateLimit? = 5/hour per address, dailyMaximum? = 50 emails/day from everyone (per server instance; caps email cost under a flood), readConfiguration?, createSender?, reportError? }) → (form, ip) => { status: idle|sent|invalid|rate-limited|failed }. Reply-to = visitor when they gave an email; bots get fake 'sent'. The email: branded layout (logo + company on the design, accent line), every detail, the message, then Form (page), Language (name), Sent (UTC), IP.
|
|
7
6
|
- Form fields: name, email, phone (valid: + digits spaces ().- with ≥7 digits), company, message, extra fields, locale, started-at, page (location.href at sending), website (honeypot), need (checkboxes).
|
|
8
7
|
- /parse-contact: parseContact(form, { choices, choiceField='need', reach, requireMessage, minimumMessageLength, requireChoice, fields, now }) → value { name, email, phone, company, message, locale, choices, fields }
|
|
9
8
|
- /contact-check isEmail(text), isPhone(text) (browser-safe, same rules as the server); /bot-check isLikelyBot; /rate-limit createRateLimiter({ window, maximum }); /field readField(form, name, max)
|
|
10
9
|
- Env: EMAIL_SERVER_HOST/PORT/USERNAME/PASSWORD, EMAIL_SENDER_ADDRESS. License: Sharadox Open Source License 0.1.0
|
|
10
|
+
- 0.5.0: createContactAction takes `design` (email-web-library ^0.4.0 EmailDesign; plainDesign(company) by default) instead of `theme`, and lays out both emails with emailLayout; the notice has a button to answer the visitor (labels.reply "Reply to" + first name, or labels.call "Call" when only a phone was left); an acknowledgement may carry a `button`; with a design signature, the reply leaves out its line to the site; contact-email (brandedEmailHtml) is removed: use email-web-library's emailLayout
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharadox/form-web-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Forms on the server: field reading, honeypot and fill-time bot checks, rate limiting and a contact form action that emails messages with the visitor as reply-to.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "SEE LICENSE IN LICENCA.md",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"vitest": "^5.1.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@sharadox/email-web-library": "^0.
|
|
67
|
+
"@sharadox/email-web-library": "^0.4.0",
|
|
68
68
|
"@sharadox/web-library": "^0.7.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BrandedEmailOptions } from "@sharadox/form-web-library/contact-email/type";
|
|
2
|
-
/**
|
|
3
|
-
* A company's email, the same in every inbox: the logo and the company's name on its own colors at the top, a thin
|
|
4
|
-
* accent line, then the heading, any paragraphs, a table of details, a quoted text and small print at the bottom.
|
|
5
|
-
* Built from tables with inline styles, as email clients need; everything given is escaped.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* brandedEmailHtml({ company: "Sharadox", theme, logo: true, language: "en", preview: "Ana sent a message",
|
|
9
|
-
* eyebrow: "Contact", heading: "Ana (Café)", rows: [{ label: "Email", value: "ana@example.com" }] });
|
|
10
|
-
*/
|
|
11
|
-
export declare function brandedEmailHtml(options: BrandedEmailOptions): string;
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-email/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAY,MAAM,+CAA+C,CAAC;AAUnG;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA6CrE"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { escapeHtml } from "@sharadox/web-library/html/escape";
|
|
2
|
-
const FONT = "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif";
|
|
3
|
-
/** A value, as a link when it has one. */
|
|
4
|
-
const value = ({ value: text, href }, color) => href
|
|
5
|
-
? `<a href="${escapeHtml(href)}" style="color:${color};text-decoration:underline">${escapeHtml(text)}</a>`
|
|
6
|
-
: escapeHtml(text);
|
|
7
|
-
/**
|
|
8
|
-
* A company's email, the same in every inbox: the logo and the company's name on its own colors at the top, a thin
|
|
9
|
-
* accent line, then the heading, any paragraphs, a table of details, a quoted text and small print at the bottom.
|
|
10
|
-
* Built from tables with inline styles, as email clients need; everything given is escaped.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* brandedEmailHtml({ company: "Sharadox", theme, logo: true, language: "en", preview: "Ana sent a message",
|
|
14
|
-
* eyebrow: "Contact", heading: "Ana (Café)", rows: [{ label: "Email", value: "ana@example.com" }] });
|
|
15
|
-
*/
|
|
16
|
-
export function brandedEmailHtml(options) {
|
|
17
|
-
const { company, theme, logo, language, preview, eyebrow, heading, paragraphs = [], rows = [], quote, footer = [], } = options;
|
|
18
|
-
const mark = logo
|
|
19
|
-
? `<td style="padding:0 14px 0 0;vertical-align:middle"><img src="cid:logo" width="44" height="44" alt="${escapeHtml(company)}" style="display:block;width:44px;height:44px;border:0;border-radius:10px"></td>`
|
|
20
|
-
: "";
|
|
21
|
-
const table = rows.length
|
|
22
|
-
? `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="border-collapse:collapse;margin:24px 0 0">${rows
|
|
23
|
-
.map((row) => `<tr><td style="padding:12px 16px 12px 0;border-top:1px solid #ececec;width:132px;vertical-align:top;font:500 13px/1.5 ${FONT};color:#71717a">${escapeHtml(row.label)}</td><td style="padding:12px 0;border-top:1px solid #ececec;vertical-align:top;font:400 15px/1.5 ${FONT};color:#18181b;word-break:break-word">${value(row, "#18181b")}</td></tr>`)
|
|
24
|
-
.join("")}</table>`
|
|
25
|
-
: "";
|
|
26
|
-
const text = quote
|
|
27
|
-
? `<p style="margin:28px 0 8px;font:500 13px/1.5 ${FONT};color:#71717a">${escapeHtml(quote.label)}</p><div style="padding:18px 20px;background:#f6f6f7;border-radius:12px;font:400 15px/1.65 ${FONT};color:#18181b;white-space:pre-wrap;word-break:break-word">${escapeHtml(quote.text)}</div>`
|
|
28
|
-
: "";
|
|
29
|
-
const small = footer.length
|
|
30
|
-
? `<tr><td style="padding:20px 32px;background:#fafafa;border-top:1px solid #ececec;font:400 12px/1.7 ${FONT};color:#71717a">${footer
|
|
31
|
-
.map((row) => `${escapeHtml(row.label)}: ${value(row, "#52525b")}`)
|
|
32
|
-
.join("<br>")}</td></tr>`
|
|
33
|
-
: "";
|
|
34
|
-
return `<!doctype html><html lang="${escapeHtml(language)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light"><title>${escapeHtml(heading)}</title></head><body style="margin:0;padding:0;background:#f4f4f5">
|
|
35
|
-
<div style="display:none;max-height:0;overflow:hidden;opacity:0">${escapeHtml(preview)}</div>
|
|
36
|
-
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5"><tr><td align="center" style="padding:32px 12px">
|
|
37
|
-
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="width:100%;max-width:600px;background:#ffffff;border:1px solid #e4e4e7;border-radius:16px;overflow:hidden">
|
|
38
|
-
<tr><td style="background:${theme.background};padding:24px 32px"><table role="presentation" cellpadding="0" cellspacing="0"><tr>${mark}<td style="vertical-align:middle;font:600 18px/1.2 ${FONT};letter-spacing:-0.01em;color:${theme.foreground}">${escapeHtml(company)}</td></tr></table></td></tr>
|
|
39
|
-
<tr><td style="height:3px;line-height:3px;font-size:0;background:${theme.accent}"> </td></tr>
|
|
40
|
-
<tr><td style="padding:32px">
|
|
41
|
-
<p style="margin:0 0 10px;font:600 11px/1.4 ${FONT};letter-spacing:0.12em;text-transform:uppercase;color:#71717a">${escapeHtml(eyebrow)}</p>
|
|
42
|
-
<h1 style="margin:0;font:600 24px/1.3 ${FONT};letter-spacing:-0.02em;color:#09090b">${escapeHtml(heading)}</h1>
|
|
43
|
-
${paragraphs.map((paragraph) => `<p style="margin:16px 0 0;font:400 15px/1.65 ${FONT};color:#3f3f46">${escapeHtml(paragraph)}</p>`).join("")}${table}${text}
|
|
44
|
-
</td></tr>${small}
|
|
45
|
-
</table></td></tr></table></body></html>`;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-email/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAG/D,MAAM,IAAI,GAAG,+EAA+E,CAAC;AAE7F,0CAA0C;AAC1C,MAAM,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAY,EAAE,KAAa,EAAE,EAAE,CAC/D,IAAI;IACF,CAAC,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,kBAAkB,KAAK,+BAA+B,UAAU,CAAC,IAAI,CAAC,MAAM;IAC1G,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA4B;IAC3D,MAAM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;;4BAG1D,KAAK,CAAC,UAAU,sFAAsF,IAAI,sDAAsD,IAAI,iCAAiC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;mEACtM,KAAK,CAAC,MAAM;;8CAEjC,IAAI,kEAAkE,UAAU,CAAC,OAAO,CAAC;wCAC/F,IAAI,0CAA0C,UAAU,CAAC,OAAO,CAAC;EACvG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gDAAgD,IAAI,mBAAmB,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,IAAI;YAC/I,KAAK;yCACwB,CAAC;AAC1C,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** A brand's colors for its emails: the band at the top and the thin line under it. */
|
|
2
|
-
export interface EmailTheme {
|
|
3
|
-
/** The top band's color, behind the logo, for example "#000000". */
|
|
4
|
-
background: string;
|
|
5
|
-
/** The company name's color on the band, for example "#ffffff". */
|
|
6
|
-
foreground: string;
|
|
7
|
-
/** The thin line under the band, for example the brand's gold. */
|
|
8
|
-
accent: string;
|
|
9
|
-
}
|
|
10
|
-
/** One line of the details table: a label and its value (plain text, or `href` to make it a link). */
|
|
11
|
-
export interface EmailRow {
|
|
12
|
-
label: string;
|
|
13
|
-
value: string;
|
|
14
|
-
href?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface BrandedEmailOptions {
|
|
17
|
-
/** The company, beside the logo in the top band. */
|
|
18
|
-
company: string;
|
|
19
|
-
theme: EmailTheme;
|
|
20
|
-
/** True when a logo is sent with the email as the inline image "logo". */
|
|
21
|
-
logo: boolean;
|
|
22
|
-
/** The language of the email, for the html's `lang`. */
|
|
23
|
-
language: string;
|
|
24
|
-
/** The line shown in the inbox's preview, before the email is opened. */
|
|
25
|
-
preview: string;
|
|
26
|
-
/** The small capitals above the heading, for example "Contact". */
|
|
27
|
-
eyebrow: string;
|
|
28
|
-
heading: string;
|
|
29
|
-
/** Paragraphs under the heading. */
|
|
30
|
-
paragraphs?: readonly string[];
|
|
31
|
-
/** The details table. */
|
|
32
|
-
rows?: EmailRow[];
|
|
33
|
-
/** A longer text in its own box, keeping its line breaks (the visitor's message), with its label. */
|
|
34
|
-
quote?: {
|
|
35
|
-
label: string;
|
|
36
|
-
text: string;
|
|
37
|
-
};
|
|
38
|
-
/** Small print at the bottom: where it came from, when, and so on. */
|
|
39
|
-
footer?: EmailRow[];
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/contact-email/type.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sGAAsG;AACtG,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,0EAA0E;IAC1E,IAAI,EAAE,OAAO,CAAC;IACd,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,yBAAyB;IACzB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,qGAAqG;IACrG,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,sEAAsE;IACtE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;CACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/contact-email/type.ts"],"names":[],"mappings":""}
|