@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/dist/index.js
CHANGED
|
@@ -255,6 +255,7 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
255
255
|
const formatOptions = config.options;
|
|
256
256
|
const fieldNames = resolveFieldNames(config);
|
|
257
257
|
const bucket = getRegistry(state2);
|
|
258
|
+
const phase1Entries = [];
|
|
258
259
|
for (const fieldName of fieldNames) {
|
|
259
260
|
const displayName = config.displayField ?? `${fieldName}_displayed`;
|
|
260
261
|
const canonicalFields = helpers.getFieldsByName(fieldName);
|
|
@@ -279,28 +280,31 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
279
280
|
displayName,
|
|
280
281
|
mirrorIsOwned
|
|
281
282
|
});
|
|
283
|
+
phase1Entries.push(existing);
|
|
282
284
|
} else {
|
|
283
|
-
|
|
285
|
+
const entry = {
|
|
284
286
|
canonicalName: fieldName,
|
|
285
287
|
displayName,
|
|
286
288
|
visible,
|
|
287
289
|
mirror,
|
|
288
290
|
mirrorIsOwned,
|
|
289
291
|
handler: UNBOUND
|
|
290
|
-
}
|
|
292
|
+
};
|
|
293
|
+
bucket.set(fieldName, entry);
|
|
291
294
|
state2.formattedFields.set(fieldName, {
|
|
292
295
|
config,
|
|
293
296
|
displayName,
|
|
294
297
|
mirrorIsOwned
|
|
295
298
|
});
|
|
299
|
+
phase1Entries.push(entry);
|
|
296
300
|
}
|
|
297
301
|
}
|
|
298
302
|
const formatter = await loadFormatter();
|
|
299
303
|
if (!formatter) {
|
|
300
|
-
rollbackPhase1(bucket, state2.formattedFields);
|
|
304
|
+
rollbackPhase1(phase1Entries, bucket, state2.formattedFields);
|
|
301
305
|
return;
|
|
302
306
|
}
|
|
303
|
-
for (const
|
|
307
|
+
for (const entry of phase1Entries) {
|
|
304
308
|
if (entry.handler !== UNBOUND) {
|
|
305
309
|
const current = entry.visible.value;
|
|
306
310
|
if (current !== "") {
|
|
@@ -327,16 +331,16 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
327
331
|
}
|
|
328
332
|
}
|
|
329
333
|
};
|
|
330
|
-
var rollbackPhase1 = (bucket, registry2) => {
|
|
331
|
-
for (const
|
|
334
|
+
var rollbackPhase1 = (entries, bucket, registry2) => {
|
|
335
|
+
for (const entry of entries) {
|
|
332
336
|
if (entry.visible.isConnected) {
|
|
333
|
-
restoreVisibleName(entry.visible,
|
|
337
|
+
restoreVisibleName(entry.visible, entry.canonicalName);
|
|
334
338
|
}
|
|
335
339
|
if (entry.mirrorIsOwned && entry.mirror.isConnected) {
|
|
336
340
|
entry.mirror.remove();
|
|
337
341
|
}
|
|
338
|
-
bucket.delete(
|
|
339
|
-
registry2.delete(
|
|
342
|
+
bucket.delete(entry.canonicalName);
|
|
343
|
+
registry2.delete(entry.canonicalName);
|
|
340
344
|
}
|
|
341
345
|
};
|
|
342
346
|
var createFormat = (state2, helpers) => (config) => {
|
|
@@ -354,6 +358,15 @@ var resolveCanonicalForName = (state2, name) => {
|
|
|
354
358
|
}
|
|
355
359
|
return null;
|
|
356
360
|
};
|
|
361
|
+
var resolveDisplayNameForName = (state2, name) => {
|
|
362
|
+
const bucket = registry.get(state2);
|
|
363
|
+
if (!bucket) return name;
|
|
364
|
+
for (const [canonical, entry] of bucket) {
|
|
365
|
+
if (canonical === name) return entry.displayName;
|
|
366
|
+
if (entry.displayName === name) return entry.displayName;
|
|
367
|
+
}
|
|
368
|
+
return name;
|
|
369
|
+
};
|
|
357
370
|
var cleanupFormatRegistry = (state2) => {
|
|
358
371
|
if (!state2.element) {
|
|
359
372
|
registry.delete(state2);
|
|
@@ -954,10 +967,11 @@ var createFormController = (target, options = {}) => {
|
|
|
954
967
|
if (!name) return;
|
|
955
968
|
clearFieldCache();
|
|
956
969
|
const canonical = resolveCanonicalForName(state2, name) ?? name;
|
|
970
|
+
const displayName = resolveDisplayNameForName(state2, name);
|
|
957
971
|
if (normalizedOptions.clearManualErrorsOnChange) {
|
|
958
972
|
delete state2.manualErrors[canonical];
|
|
959
973
|
}
|
|
960
|
-
syncVisualState([
|
|
974
|
+
syncVisualState([displayName]);
|
|
961
975
|
if (state2.isValidated && state2.validators[canonical]) {
|
|
962
976
|
validateNames([canonical]);
|
|
963
977
|
}
|