@bettercms-ai/convert 0.12.0 → 0.12.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/CHANGELOG.md +21 -0
- package/dist/cli.js +12 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -956,7 +956,7 @@ declare function isKnownHelper(content: string, dialect: Dialect): number | null
|
|
|
956
956
|
* renderer's constant occurs in it byte for byte, which is the only thing that keeps the copy a
|
|
957
957
|
* copy. Change it there first, then paste it here.
|
|
958
958
|
*/
|
|
959
|
-
declare const FORM_SCRIPT = "<script>\ndocument.querySelectorAll('form[data-bcms-form]').forEach(function(f){\n f.addEventListener('submit',function(e){\n e.preventDefault();\n var msg=f.querySelector('.bcms-form-msg');\n var data={};\n // A checkboxes group posts one entry per checked box under the SAME name; the old\n // one-at-a-time assignment kept only the last, so \"pick many\" delivered one answer.\n // One checked box still arrives as a scalar \u2014 FormData cannot tell a group from a\n // lone field \u2014 which is exactly why lib/forms/validate.ts's chosenValues() accepts\n // both an array and a comma string.\n new FormData(f).forEach(function(v,k){\n if(k==='cf-turnstile-response')return;\n if(Object.prototype.hasOwnProperty.call(data,k))data[k]=(Array.isArray(data[k])?data[k]:[data[k]]).concat(v);\n else data[k]=v;\n });\n var body={data:data};\n var tok=f.querySelector('[name=\"cf-turnstile-response\"]');\n if(tok&&tok.value)body['cf-turnstile-response']=tok.value;\n fetch(f.action,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)})\n .then(function(r){return r.ok;})\n .then(function(ok){if(msg){msg.hidden=false;msg.textContent=ok?(f.getAttribute('data-bcms-form-success')||'Thanks! Your submission was received.'):'Sorry, something went wrong.';}if(ok)f.reset();})\n .catch(function(){if(msg){msg.hidden=false;msg.textContent='Sorry, something went wrong.';}});\n });\n});\n</script>";
|
|
959
|
+
declare const FORM_SCRIPT = "<script>\nfunction bcmsPhone(cc,raw,trunk){var d=String(raw||'').trim();if(!d)return '';if(d.charAt(0)==='+'){var i=d.replace(/D/g,'');return i?'+'+i:'';}if(!cc)return d;var n=d.replace(/D/g,'');if(trunk&&n.charAt(0)==='0')n=n.slice(1);return n?'+'+cc+n:'';}\ndocument.querySelectorAll('form[data-bcms-form]').forEach(function(f){\n f.addEventListener('submit',function(e){\n e.preventDefault();\n var msg=f.querySelector('.bcms-form-msg');\n var data={};\n // A checkboxes group posts one entry per checked box under the SAME name; the old\n // one-at-a-time assignment kept only the last, so \"pick many\" delivered one answer.\n // One checked box still arrives as a scalar \u2014 FormData cannot tell a group from a\n // lone field \u2014 which is exactly why lib/forms/validate.ts's chosenValues() accepts\n // both an array and a comma string.\n new FormData(f).forEach(function(v,k){\n if(k==='cf-turnstile-response')return;\n if(Object.prototype.hasOwnProperty.call(data,k))data[k]=(Array.isArray(data[k])?data[k]:[data[k]]).concat(v);\n else data[k]=v;\n });\n // Country-picker phone fields post ONE key. The __country select is scaffolding: it is\n // composed into the field's own value here, AFTER collection, so a showIf that points at a\n // phone key still compares the raw digits. Then it is removed from the body.\n f.querySelectorAll('select[name$=\"__country\"]').forEach(function(sel){\n var k=sel.name.slice(0,-9);\n var o=sel.options[sel.selectedIndex];\n data[k]=bcmsPhone(o?(o.getAttribute('data-cc')||''):'',data[k],o?o.getAttribute('data-trunk')==='1':false);\n delete data[k+'__country'];\n });\n var body={data:data};\n var tok=f.querySelector('[name=\"cf-turnstile-response\"]');\n if(tok&&tok.value)body['cf-turnstile-response']=tok.value;\n fetch(f.action,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)})\n .then(function(r){return r.ok;})\n .then(function(ok){if(msg){msg.hidden=false;msg.textContent=ok?(f.getAttribute('data-bcms-form-success')||'Thanks! Your submission was received.'):'Sorry, something went wrong.';}if(ok)f.reset();})\n .catch(function(){if(msg){msg.hidden=false;msg.textContent='Sorry, something went wrong.';}});\n });\n});\n</script>";
|
|
960
960
|
/**
|
|
961
961
|
* Wire every form the brief lists, and say what could not be.
|
|
962
962
|
*
|
package/dist/index.js
CHANGED
|
@@ -6331,6 +6331,7 @@ import MagicString4 from "magic-string";
|
|
|
6331
6331
|
var WIRABLE = ["html", "astro", "jsx"];
|
|
6332
6332
|
var CONTROLS = /* @__PURE__ */ new Set(["input", "select", "textarea"]);
|
|
6333
6333
|
var FORM_SCRIPT = `<script>
|
|
6334
|
+
function bcmsPhone(cc,raw,trunk){var d=String(raw||'').trim();if(!d)return '';if(d.charAt(0)==='+'){var i=d.replace(/D/g,'');return i?'+'+i:'';}if(!cc)return d;var n=d.replace(/D/g,'');if(trunk&&n.charAt(0)==='0')n=n.slice(1);return n?'+'+cc+n:'';}
|
|
6334
6335
|
document.querySelectorAll('form[data-bcms-form]').forEach(function(f){
|
|
6335
6336
|
f.addEventListener('submit',function(e){
|
|
6336
6337
|
e.preventDefault();
|
|
@@ -6346,6 +6347,15 @@ document.querySelectorAll('form[data-bcms-form]').forEach(function(f){
|
|
|
6346
6347
|
if(Object.prototype.hasOwnProperty.call(data,k))data[k]=(Array.isArray(data[k])?data[k]:[data[k]]).concat(v);
|
|
6347
6348
|
else data[k]=v;
|
|
6348
6349
|
});
|
|
6350
|
+
// Country-picker phone fields post ONE key. The __country select is scaffolding: it is
|
|
6351
|
+
// composed into the field's own value here, AFTER collection, so a showIf that points at a
|
|
6352
|
+
// phone key still compares the raw digits. Then it is removed from the body.
|
|
6353
|
+
f.querySelectorAll('select[name$="__country"]').forEach(function(sel){
|
|
6354
|
+
var k=sel.name.slice(0,-9);
|
|
6355
|
+
var o=sel.options[sel.selectedIndex];
|
|
6356
|
+
data[k]=bcmsPhone(o?(o.getAttribute('data-cc')||''):'',data[k],o?o.getAttribute('data-trunk')==='1':false);
|
|
6357
|
+
delete data[k+'__country'];
|
|
6358
|
+
});
|
|
6349
6359
|
var body={data:data};
|
|
6350
6360
|
var tok=f.querySelector('[name="cf-turnstile-response"]');
|
|
6351
6361
|
if(tok&&tok.value)body['cf-turnstile-response']=tok.value;
|