@samline/forms 2.3.1 → 2.3.3
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 +3 -3
- package/dist/browser/global.global.js +17 -5
- package/dist/browser/global.global.js.map +1 -1
- package/dist/index.cjs +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
45
|
+
<script src="https://unpkg.com/@samline/forms@2.3.3/dist/browser/global.global.js"></script>
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
> Pin the version in production. Replace `2.3.
|
|
48
|
+
> Pin the version in production. Replace `2.3.3` 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.
|
|
58
|
+
<script src="https://unpkg.com/@samline/forms@2.3.3/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);
|
|
@@ -5488,11 +5497,13 @@ var Forms = (() => {
|
|
|
5488
5497
|
const getMergedErrors = () => mergeErrors(state2.validationErrors, state2.manualErrors);
|
|
5489
5498
|
const syncVisualState = (names) => {
|
|
5490
5499
|
if (!state2.element) return;
|
|
5491
|
-
const
|
|
5500
|
+
const sourceNames = names ?? getTrackedFieldNames();
|
|
5492
5501
|
const errors = getMergedErrors();
|
|
5493
|
-
for (const name of
|
|
5494
|
-
const
|
|
5495
|
-
const
|
|
5502
|
+
for (const name of sourceNames) {
|
|
5503
|
+
const displayName = resolveDisplayNameForName(state2, name);
|
|
5504
|
+
const canonical = resolveCanonicalForName(state2, name) ?? name;
|
|
5505
|
+
const fields = getFieldsByName(displayName);
|
|
5506
|
+
const hasError = Boolean(errors[canonical]?.length);
|
|
5496
5507
|
for (const field of fields) {
|
|
5497
5508
|
applyBooleanAttribute(field, attributes.filled, isFieldFilled(field));
|
|
5498
5509
|
applyBooleanAttribute(field, attributes.error, hasError);
|
|
@@ -5562,10 +5573,11 @@ var Forms = (() => {
|
|
|
5562
5573
|
if (!name) return;
|
|
5563
5574
|
clearFieldCache();
|
|
5564
5575
|
const canonical = resolveCanonicalForName(state2, name) ?? name;
|
|
5576
|
+
const displayName = resolveDisplayNameForName(state2, name);
|
|
5565
5577
|
if (normalizedOptions.clearManualErrorsOnChange) {
|
|
5566
5578
|
delete state2.manualErrors[canonical];
|
|
5567
5579
|
}
|
|
5568
|
-
syncVisualState([
|
|
5580
|
+
syncVisualState([displayName]);
|
|
5569
5581
|
if (state2.isValidated && state2.validators[canonical]) {
|
|
5570
5582
|
validateNames([canonical]);
|
|
5571
5583
|
}
|