@paroicms/contact-form-plugin 0.16.0 → 0.17.1
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/backend/dist/plugin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_path_1 = require("node:path");
|
|
3
4
|
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
4
5
|
const public_server_lib_1 = require("@paroicms/public-server-lib");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
6
|
const contact_form_mail_1 = require("./contact-form-mail");
|
|
7
7
|
const data_format_1 = require("./data-format");
|
|
8
8
|
const projectDir = (0, node_path_1.dirname)(__dirname);
|
|
@@ -15,7 +15,7 @@ const plugin = {
|
|
|
15
15
|
const simpleI18n = await (0, public_server_lib_1.loadSimpleTranslatorFromDirectory)({
|
|
16
16
|
l10nDir: (0, node_path_1.join)(projectDir, "locales"),
|
|
17
17
|
languages: ["en", "fr"],
|
|
18
|
-
|
|
18
|
+
logger: service.logger,
|
|
19
19
|
});
|
|
20
20
|
service.setPublicAssetsDirectory((0, node_path_1.join)(packageDir, "public-front", "dist"));
|
|
21
21
|
service.addHeadTag(`<link rel="stylesheet" href="${(0, public_server_lib_1.escapeHtml)(`${service.pluginAssetsUrl}/style.css`)}">`, `<script type="module" src="${(0, public_server_lib_1.escapeHtml)(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}"></script>`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/contact-form-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Contact form plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"@paroicms/public-server-lib": "0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@paroicms/public-anywhere-lib": "0.
|
|
36
|
-
"@paroicms/public-server-lib": "0.
|
|
35
|
+
"@paroicms/public-anywhere-lib": "0.14.0",
|
|
36
|
+
"@paroicms/public-server-lib": "0.22.1",
|
|
37
37
|
"@solid-primitives/i18n": "~2.1.1",
|
|
38
|
-
"@types/node": "~
|
|
38
|
+
"@types/node": "~22.10.7",
|
|
39
39
|
"rimraf": "~6.0.1",
|
|
40
|
-
"sass": "~1.
|
|
41
|
-
"solid-devtools": "~0.
|
|
42
|
-
"solid-js": "1.9.
|
|
43
|
-
"typescript": "~5.7.
|
|
44
|
-
"vite": "~
|
|
45
|
-
"vite-plugin-solid": "~2.
|
|
46
|
-
"terser": "~5.
|
|
40
|
+
"sass": "~1.83.4",
|
|
41
|
+
"solid-devtools": "~0.33.0",
|
|
42
|
+
"solid-js": "1.9.4",
|
|
43
|
+
"typescript": "~5.7.3",
|
|
44
|
+
"vite": "~6.0.7",
|
|
45
|
+
"vite-plugin-solid": "~2.11.0",
|
|
46
|
+
"terser": "~5.37.0"
|
|
47
47
|
},
|
|
48
48
|
"main": "backend/dist/plugin.js",
|
|
49
49
|
"files": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{insert as c,setAttribute as
|
|
1
|
+
import{insert as c,setAttribute as g,createComponent as M,effect as $,template as F,render as K}from"https://esm.sh/solid-js@1.9.4/web";import{createMemo as ee,createSignal as d,Show as D,onMount as te,onCleanup as ne}from"https://esm.sh/solid-js@1.9.4";function se(e){return e.varName?` for '${e.varName}'`:""}function ae(e,t={}){if(e==null||e===""&&!t.allowEmpty)throw new Error(`Missing string value${se(t)}`);return typeof e=="string"?e:e.toString()}var N=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function U(e,t,a){for(const[s,r]of Object.entries(t)){const m=`${a}.${s}`;e[m]=r,N(r)&&U(e,r,m)}}function re(e){const t={...e};for(const[a,s]of Object.entries(e))N(s)&&U(t,s,a);return t}var oe=(e,t)=>{if(t)for(const[a,s]of Object.entries(t))e=e.replace(new RegExp(`{{\\s*${a}\\s*}}`,"g"),s);return e},ce=e=>e;function le(e,t=ce){return(a,...s)=>{a[0]==="."&&(a=a.slice(1));const r=e()?.[a];switch(typeof r){case"function":return r(...s);case"string":return t(r,s[0]);default:return r}}}const ie="Name",de="Email",ue="Subject",me="Message",fe="Send",pe="johndoe@gmail.com",ge="John Doe",he="The subject of your message",be="Enter your message here…",ve="Unexpected error, the message could not be sent.",$e="Return Home",Fe="Your message has been sent. If there is a response, it will be sent to the address:",Ce={name:ie,email:de,subject:ue,message:me,send:fe,emailPlaceholder:pe,namePlaceholder:ge,subjectPlaceholder:he,messagePlaceholder:be,unexpectedErrorMessage:ve,returnHome:$e,successMessage:Fe},Ee="Nom",we="Courriel",ye="Sujet",Se="Message",xe="Envoyer",Me="johndoe@gmail.com",_e="John Doe",Re="Le sujet de votre message",je="Saisissez votre message…",Pe="Erreur inattendue, le message n'a pas pu être envoyé.",Le="Retourner à l'accueil",Oe="Votre message a été envoyé. S'il y a une réponse, elle sera envoyée à l'adresse :",He={name:Ee,email:we,subject:ye,message:Se,send:xe,emailPlaceholder:Me,namePlaceholder:_e,subjectPlaceholder:Re,messagePlaceholder:je,unexpectedErrorMessage:Pe,returnHome:Le,successMessage:Oe},I={en:Ce,fr:He};function Te(e){const t=ee((()=>{const s=e in I?e:"en";return re(I[s])}));return{t:le(t,oe)}}async function ke(e,t,a){a(!0);try{const s=await Ae(e);return t.reset(),s}finally{a(!1)}}async function Ae(e){const t=await fetch("/api/plugin/contact-form",{headers:{"Content-Type":"application/json"},body:JSON.stringify(e),method:"POST"});if(t.status!==200){const s=await t.text();throw new Error(`Unexpected error: ${s}`)}return await t.json()}var De=F("<div class=ContactForm-error>"),Ie=F('<div class="ContactForm-done ContactForm-ended"><div class=ContactForm-endedMessage><p></p><p></p></div><div class=ContactForm-endedActions><a class=BigBtn>'),Ne=F("<form class=ContactForm><div class=ContactForm-fieldGroup><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=text name=name required></label><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=email name=email required></label><label class=ContactFormField><span class=ContactFormField-label></span><textarea class=ContactFormField-textarea rows=5 name=message required></textarea></label></div><div class=ContactForm-action><button type=submit class=ContactForm-btn>"),Ue=F("<div class=ContactForm-captcha><div class=g-recaptcha data-callback=onRecaptchaSubmitted data-expired-callback=onRecaptchaExpired>");function qe({recaptchaKey:e,language:t,homeUrl:a}){const[s,r]=d(""),[m,q]=d(""),[_,J]=d(""),[B,G]=d(),[R,j]=d(!e),[P,C]=d(),[V,L]=d(""),[z,Y]=d(!1),{t:o}=Te(t),Q=async l=>{try{if(l.preventDefault(),!R()||!h)throw new Error("Erreur de recaptcha");const i=await ke({language:t,name:s(),message:_(),email:m(),gRecaptchaResponse:B()},h,Y);i.success?C(!0):(C(!1),L(i.message??o("unexpectedErrorMessage")))}catch{C(!1),L(o("unexpectedErrorMessage"))}},h=(()=>{var l=Ne(),i=l.firstChild,O=i.firstChild,H=O.firstChild,E=H.nextSibling,T=O.nextSibling,k=T.firstChild,w=k.nextSibling,Z=T.nextSibling,A=Z.firstChild,y=A.nextSibling,S=i.nextSibling,x=S.firstChild;return l.addEventListener("submit",Q),c(H,(()=>o("name"))),E.addEventListener("change",(n=>r(n.currentTarget.value))),c(k,(()=>o("email"))),w.addEventListener("change",(n=>{q(n.currentTarget.value)})),c(A,(()=>o("message"))),y.addEventListener("change",(n=>J(n.currentTarget.value))),c(l,e&&(()=>{var n=Ue(),u=n.firstChild;return g(u,"data-sitekey",e),n})(),S),c(l,M(D,{get when(){return P()===!1},get children(){var n=De();return c(n,V),n}}),S),c(x,(()=>o("send"))),c(l,M(D,{get when(){return P()===!0},get children(){var n=Ie(),u=n.firstChild,f=u.firstChild,b=f.nextSibling,v=u.nextSibling,p=v.firstChild;return c(f,(()=>o("successMessage"))),c(b,m),g(p,"href",a),c(p,(()=>o("returnHome"))),n}}),null),$((n=>{var u=o("namePlaceholder"),f=o("emailPlaceholder"),b=o("messagePlaceholder"),v=!!z(),p=!R();return u!==n.e&&g(E,"placeholder",n.e=u),f!==n.t&&g(w,"placeholder",n.t=f),b!==n.a&&g(y,"placeholder",n.a=b),v!==n.o&&x.classList.toggle("inProgress",n.o=v),p!==n.i&&(x.disabled=n.i=p),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),$((()=>E.value=s())),$((()=>w.value=m())),$((()=>y.value=_())),l})();return te((()=>{e&&(window.onRecaptchaSubmitted=W,window.onRecaptchaExpired=X)})),ne((()=>{e&&(window.onRecaptchaSubmitted=void 0,window.onRecaptchaExpired=void 0)})),h;function W(l){if(!l)return;j(!0);const i=h?.elements.namedItem("g-recaptcha-response");G(i.value)}function X(){j(!1)}}function Je(e,{language:t}){if(!t)throw new Error("Missing language");const a=e.dataset.recaptchaKey,s=ae(e.dataset.homeUrl),r=document.createElement("script");r.setAttribute("src","https://www.google.com/recaptcha/api.js"),document.head.appendChild(r),K((()=>M(qe,{recaptchaKey:a,language:t,homeUrl:s})),e)}document.addEventListener("DOMContentLoaded",(()=>{const e=document.documentElement.lang,t=document.querySelector("[data-effect='contactForm']");t&&Je(t,{language:e})}));
|
|
File without changes
|