@samline/forms 2.3.0 → 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 +3 -3
- package/dist/browser/global.global.js +24 -10
- package/dist/browser/global.global.js.map +1 -1
- package/dist/index.cjs +24 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -10
- 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.2/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.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.
|
|
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
|
|
|
@@ -4870,6 +4870,7 @@ var Forms = (() => {
|
|
|
4870
4870
|
const formatOptions = config.options;
|
|
4871
4871
|
const fieldNames = resolveFieldNames(config);
|
|
4872
4872
|
const bucket = getRegistry(state2);
|
|
4873
|
+
const phase1Entries = [];
|
|
4873
4874
|
for (const fieldName of fieldNames) {
|
|
4874
4875
|
const displayName = config.displayField ?? `${fieldName}_displayed`;
|
|
4875
4876
|
const canonicalFields = helpers.getFieldsByName(fieldName);
|
|
@@ -4894,28 +4895,31 @@ var Forms = (() => {
|
|
|
4894
4895
|
displayName,
|
|
4895
4896
|
mirrorIsOwned
|
|
4896
4897
|
});
|
|
4898
|
+
phase1Entries.push(existing);
|
|
4897
4899
|
} else {
|
|
4898
|
-
|
|
4900
|
+
const entry = {
|
|
4899
4901
|
canonicalName: fieldName,
|
|
4900
4902
|
displayName,
|
|
4901
4903
|
visible,
|
|
4902
4904
|
mirror,
|
|
4903
4905
|
mirrorIsOwned,
|
|
4904
4906
|
handler: UNBOUND
|
|
4905
|
-
}
|
|
4907
|
+
};
|
|
4908
|
+
bucket.set(fieldName, entry);
|
|
4906
4909
|
state2.formattedFields.set(fieldName, {
|
|
4907
4910
|
config,
|
|
4908
4911
|
displayName,
|
|
4909
4912
|
mirrorIsOwned
|
|
4910
4913
|
});
|
|
4914
|
+
phase1Entries.push(entry);
|
|
4911
4915
|
}
|
|
4912
4916
|
}
|
|
4913
4917
|
const formatter = await loadFormatter();
|
|
4914
4918
|
if (!formatter) {
|
|
4915
|
-
rollbackPhase1(bucket, state2.formattedFields);
|
|
4919
|
+
rollbackPhase1(phase1Entries, bucket, state2.formattedFields);
|
|
4916
4920
|
return;
|
|
4917
4921
|
}
|
|
4918
|
-
for (const
|
|
4922
|
+
for (const entry of phase1Entries) {
|
|
4919
4923
|
if (entry.handler !== UNBOUND) {
|
|
4920
4924
|
const current = entry.visible.value;
|
|
4921
4925
|
if (current !== "") {
|
|
@@ -4942,16 +4946,16 @@ var Forms = (() => {
|
|
|
4942
4946
|
}
|
|
4943
4947
|
}
|
|
4944
4948
|
};
|
|
4945
|
-
var rollbackPhase1 = (bucket, registry2) => {
|
|
4946
|
-
for (const
|
|
4949
|
+
var rollbackPhase1 = (entries, bucket, registry2) => {
|
|
4950
|
+
for (const entry of entries) {
|
|
4947
4951
|
if (entry.visible.isConnected) {
|
|
4948
|
-
restoreVisibleName(entry.visible,
|
|
4952
|
+
restoreVisibleName(entry.visible, entry.canonicalName);
|
|
4949
4953
|
}
|
|
4950
4954
|
if (entry.mirrorIsOwned && entry.mirror.isConnected) {
|
|
4951
4955
|
entry.mirror.remove();
|
|
4952
4956
|
}
|
|
4953
|
-
bucket.delete(
|
|
4954
|
-
registry2.delete(
|
|
4957
|
+
bucket.delete(entry.canonicalName);
|
|
4958
|
+
registry2.delete(entry.canonicalName);
|
|
4955
4959
|
}
|
|
4956
4960
|
};
|
|
4957
4961
|
var createFormat = (state2, helpers) => (config) => {
|
|
@@ -4969,6 +4973,15 @@ var Forms = (() => {
|
|
|
4969
4973
|
}
|
|
4970
4974
|
return null;
|
|
4971
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
|
+
};
|
|
4972
4985
|
var cleanupFormatRegistry = (state2) => {
|
|
4973
4986
|
if (!state2.element) {
|
|
4974
4987
|
registry.delete(state2);
|
|
@@ -5558,10 +5571,11 @@ var Forms = (() => {
|
|
|
5558
5571
|
if (!name) return;
|
|
5559
5572
|
clearFieldCache();
|
|
5560
5573
|
const canonical = resolveCanonicalForName(state2, name) ?? name;
|
|
5574
|
+
const displayName = resolveDisplayNameForName(state2, name);
|
|
5561
5575
|
if (normalizedOptions.clearManualErrorsOnChange) {
|
|
5562
5576
|
delete state2.manualErrors[canonical];
|
|
5563
5577
|
}
|
|
5564
|
-
syncVisualState([
|
|
5578
|
+
syncVisualState([displayName]);
|
|
5565
5579
|
if (state2.isValidated && state2.validators[canonical]) {
|
|
5566
5580
|
validateNames([canonical]);
|
|
5567
5581
|
}
|