@samline/forms 2.3.1 → 2.3.2

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 CHANGED
@@ -42,10 +42,10 @@ Requires Node 20+ when bundling. Runtime target is ES2020.
42
42
  Use the browser build when you do not have a bundler and need to run the package directly in HTML, Shopify, WordPress, or any traditional template.
43
43
 
44
44
  ```html
45
- <script src="https://unpkg.com/@samline/forms@2.3.1/dist/browser/global.global.js"></script>
45
+ <script src="https://unpkg.com/@samline/forms@2.3.2/dist/browser/global.global.js"></script>
46
46
  ```
47
47
 
48
- > Pin the version in production. Replace `2.3.1` with the version you ship.
48
+ > Pin the version in production. Replace `2.3.2` with the version you ship.
49
49
 
50
50
  The browser bundle exposes a single global: `window.Forms`.
51
51
 
@@ -55,7 +55,7 @@ The browser bundle exposes a single global: `window.Forms`.
55
55
  <button type="submit">Send</button>
56
56
  </form>
57
57
 
58
- <script src="https://unpkg.com/@samline/forms@2.3.1/dist/browser/global.global.js"></script>
58
+ <script src="https://unpkg.com/@samline/forms@2.3.2/dist/browser/global.global.js"></script>
59
59
  <script>
60
60
  const contactForm = window.Forms.newForm({ id: 'contact-form' })
61
61
 
@@ -4973,6 +4973,15 @@ var Forms = (() => {
4973
4973
  }
4974
4974
  return null;
4975
4975
  };
4976
+ var resolveDisplayNameForName = (state2, name) => {
4977
+ const bucket = registry.get(state2);
4978
+ if (!bucket) return name;
4979
+ for (const [canonical, entry] of bucket) {
4980
+ if (canonical === name) return entry.displayName;
4981
+ if (entry.displayName === name) return entry.displayName;
4982
+ }
4983
+ return name;
4984
+ };
4976
4985
  var cleanupFormatRegistry = (state2) => {
4977
4986
  if (!state2.element) {
4978
4987
  registry.delete(state2);
@@ -5562,10 +5571,11 @@ var Forms = (() => {
5562
5571
  if (!name) return;
5563
5572
  clearFieldCache();
5564
5573
  const canonical = resolveCanonicalForName(state2, name) ?? name;
5574
+ const displayName = resolveDisplayNameForName(state2, name);
5565
5575
  if (normalizedOptions.clearManualErrorsOnChange) {
5566
5576
  delete state2.manualErrors[canonical];
5567
5577
  }
5568
- syncVisualState([canonical]);
5578
+ syncVisualState([displayName]);
5569
5579
  if (state2.isValidated && state2.validators[canonical]) {
5570
5580
  validateNames([canonical]);
5571
5581
  }