@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.cjs
CHANGED
|
@@ -296,6 +296,7 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
296
296
|
const formatOptions = config.options;
|
|
297
297
|
const fieldNames = resolveFieldNames(config);
|
|
298
298
|
const bucket = getRegistry(state2);
|
|
299
|
+
const phase1Entries = [];
|
|
299
300
|
for (const fieldName of fieldNames) {
|
|
300
301
|
const displayName = config.displayField ?? `${fieldName}_displayed`;
|
|
301
302
|
const canonicalFields = helpers.getFieldsByName(fieldName);
|
|
@@ -320,28 +321,31 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
320
321
|
displayName,
|
|
321
322
|
mirrorIsOwned
|
|
322
323
|
});
|
|
324
|
+
phase1Entries.push(existing);
|
|
323
325
|
} else {
|
|
324
|
-
|
|
326
|
+
const entry = {
|
|
325
327
|
canonicalName: fieldName,
|
|
326
328
|
displayName,
|
|
327
329
|
visible,
|
|
328
330
|
mirror,
|
|
329
331
|
mirrorIsOwned,
|
|
330
332
|
handler: UNBOUND
|
|
331
|
-
}
|
|
333
|
+
};
|
|
334
|
+
bucket.set(fieldName, entry);
|
|
332
335
|
state2.formattedFields.set(fieldName, {
|
|
333
336
|
config,
|
|
334
337
|
displayName,
|
|
335
338
|
mirrorIsOwned
|
|
336
339
|
});
|
|
340
|
+
phase1Entries.push(entry);
|
|
337
341
|
}
|
|
338
342
|
}
|
|
339
343
|
const formatter = await loadFormatter();
|
|
340
344
|
if (!formatter) {
|
|
341
|
-
rollbackPhase1(bucket, state2.formattedFields);
|
|
345
|
+
rollbackPhase1(phase1Entries, bucket, state2.formattedFields);
|
|
342
346
|
return;
|
|
343
347
|
}
|
|
344
|
-
for (const
|
|
348
|
+
for (const entry of phase1Entries) {
|
|
345
349
|
if (entry.handler !== UNBOUND) {
|
|
346
350
|
const current = entry.visible.value;
|
|
347
351
|
if (current !== "") {
|
|
@@ -368,16 +372,16 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
368
372
|
}
|
|
369
373
|
}
|
|
370
374
|
};
|
|
371
|
-
var rollbackPhase1 = (bucket, registry2) => {
|
|
372
|
-
for (const
|
|
375
|
+
var rollbackPhase1 = (entries, bucket, registry2) => {
|
|
376
|
+
for (const entry of entries) {
|
|
373
377
|
if (entry.visible.isConnected) {
|
|
374
|
-
restoreVisibleName(entry.visible,
|
|
378
|
+
restoreVisibleName(entry.visible, entry.canonicalName);
|
|
375
379
|
}
|
|
376
380
|
if (entry.mirrorIsOwned && entry.mirror.isConnected) {
|
|
377
381
|
entry.mirror.remove();
|
|
378
382
|
}
|
|
379
|
-
bucket.delete(
|
|
380
|
-
registry2.delete(
|
|
383
|
+
bucket.delete(entry.canonicalName);
|
|
384
|
+
registry2.delete(entry.canonicalName);
|
|
381
385
|
}
|
|
382
386
|
};
|
|
383
387
|
var createFormat = (state2, helpers) => (config) => {
|
|
@@ -395,6 +399,15 @@ var resolveCanonicalForName = (state2, name) => {
|
|
|
395
399
|
}
|
|
396
400
|
return null;
|
|
397
401
|
};
|
|
402
|
+
var resolveDisplayNameForName = (state2, name) => {
|
|
403
|
+
const bucket = registry.get(state2);
|
|
404
|
+
if (!bucket) return name;
|
|
405
|
+
for (const [canonical, entry] of bucket) {
|
|
406
|
+
if (canonical === name) return entry.displayName;
|
|
407
|
+
if (entry.displayName === name) return entry.displayName;
|
|
408
|
+
}
|
|
409
|
+
return name;
|
|
410
|
+
};
|
|
398
411
|
var cleanupFormatRegistry = (state2) => {
|
|
399
412
|
if (!state2.element) {
|
|
400
413
|
registry.delete(state2);
|
|
@@ -995,10 +1008,11 @@ var createFormController = (target, options = {}) => {
|
|
|
995
1008
|
if (!name) return;
|
|
996
1009
|
clearFieldCache();
|
|
997
1010
|
const canonical = resolveCanonicalForName(state2, name) ?? name;
|
|
1011
|
+
const displayName = resolveDisplayNameForName(state2, name);
|
|
998
1012
|
if (normalizedOptions.clearManualErrorsOnChange) {
|
|
999
1013
|
delete state2.manualErrors[canonical];
|
|
1000
1014
|
}
|
|
1001
|
-
syncVisualState([
|
|
1015
|
+
syncVisualState([displayName]);
|
|
1002
1016
|
if (state2.isValidated && state2.validators[canonical]) {
|
|
1003
1017
|
validateNames([canonical]);
|
|
1004
1018
|
}
|