@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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @bettercms-ai/convert
2
2
 
3
+ ## 0.12.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d826cf: The trunk-zero rule is per-country data, not a regex
8
+
9
+ `bcmsPhone` stripped a leading zero from every national number with a bare
10
+ `.replace(/^0/, "")`. That is only correct for countries that actually use a trunk
11
+ prefix. Where the leading digit is part of the number, the submitted value was
12
+ silently corrupted — one digit short, and wrong in a way nobody notices until a
13
+ customer cannot be called back.
14
+
15
+ The country list now carries a `trunk` flag derived from libphonenumber's own example
16
+ numbers, rendered as `data-trunk` on each option, and the zero is dropped only when
17
+ that country says it is a trunk prefix.
18
+
19
+ The inline script exists once per vanilla lane — the Astro component, the converter and
20
+ the server renderer — because each ships as inline script text on someone else's page
21
+ and cannot import at runtime. All three carry the identical change, which
22
+ `src/__tests__/content/form-script-pin.test.ts` pins byte for byte.
23
+
3
24
  ## 0.12.0
4
25
 
5
26
  ### Minor Changes
package/dist/cli.js CHANGED
@@ -6321,6 +6321,7 @@ import MagicString4 from "magic-string";
6321
6321
  var WIRABLE = ["html", "astro", "jsx"];
6322
6322
  var CONTROLS = /* @__PURE__ */ new Set(["input", "select", "textarea"]);
6323
6323
  var FORM_SCRIPT = `<script>
6324
+ 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:'';}
6324
6325
  document.querySelectorAll('form[data-bcms-form]').forEach(function(f){
6325
6326
  f.addEventListener('submit',function(e){
6326
6327
  e.preventDefault();
@@ -6336,6 +6337,15 @@ document.querySelectorAll('form[data-bcms-form]').forEach(function(f){
6336
6337
  if(Object.prototype.hasOwnProperty.call(data,k))data[k]=(Array.isArray(data[k])?data[k]:[data[k]]).concat(v);
6337
6338
  else data[k]=v;
6338
6339
  });
6340
+ // Country-picker phone fields post ONE key. The __country select is scaffolding: it is
6341
+ // composed into the field's own value here, AFTER collection, so a showIf that points at a
6342
+ // phone key still compares the raw digits. Then it is removed from the body.
6343
+ f.querySelectorAll('select[name$="__country"]').forEach(function(sel){
6344
+ var k=sel.name.slice(0,-9);
6345
+ var o=sel.options[sel.selectedIndex];
6346
+ data[k]=bcmsPhone(o?(o.getAttribute('data-cc')||''):'',data[k],o?o.getAttribute('data-trunk')==='1':false);
6347
+ delete data[k+'__country'];
6348
+ });
6339
6349
  var body={data:data};
6340
6350
  var tok=f.querySelector('[name="cf-turnstile-response"]');
6341
6351
  if(tok&&tok.value)body['cf-turnstile-response']=tok.value;
@@ -9595,7 +9605,7 @@ function emitStubs2(dialects, slugs, contents, out) {
9595
9605
  // package.json
9596
9606
  var package_default = {
9597
9607
  name: "@bettercms-ai/convert",
9598
- version: "0.12.0",
9608
+ version: "0.12.1",
9599
9609
  type: "module",
9600
9610
  description: "Deterministic codemod that turns an imported site's text-matched bindings into declared ones \u2014 parser offsets in, one magic-string pass out, plus a receipt of everything it could not do.",
9601
9611
  bin: {
@@ -9635,7 +9645,7 @@ var package_default = {
9635
9645
  },
9636
9646
  devDependencies: {
9637
9647
  "@types/node": "^20",
9638
- esbuild: "^0.27.7",
9648
+ esbuild: "^0.28.1",
9639
9649
  tsup: "^8.5.1",
9640
9650
  typescript: "^5",
9641
9651
  vitest: "^4.1.4"