@strictly/react-form 0.0.26 → 0.0.27
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/.out/core/mobx/form_model.d.ts +1 -0
- package/.out/core/mobx/form_model.js +8 -0
- package/.out/core/mobx/hooks.js +2 -2
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-check-types.log +1 -1
- package/core/mobx/form_model.ts +9 -0
- package/core/mobx/hooks.tsx +2 -2
- package/dist/index.cjs +6 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -1
- package/package.json +1 -1
|
@@ -59,6 +59,7 @@ export declare abstract class FormModel<T extends Type, ValueToTypePaths extends
|
|
|
59
59
|
setFieldValue<K extends keyof ValuePathsToAdapters>(valuePath: K, value: ToOfFieldAdapter<ValuePathsToAdapters[K]>, validation?: Validation): boolean;
|
|
60
60
|
addListItem<K extends keyof FlattenedListTypesOfType<T>>(valuePath: K, elementValue?: Maybe<ElementOfArray<FlattenedValuesOfType<T>[K]>>, index?: number): void;
|
|
61
61
|
removeListItem<K extends keyof FlattenedListTypesOfType<T>>(...elementValuePaths: readonly `${K}.${number}`[]): void;
|
|
62
|
+
protected moveListItem<K extends keyof FlattenedListTypesOfType<T>>(fromValuePath: K, toValuePath: K): void;
|
|
62
63
|
private internalSetFieldValue;
|
|
63
64
|
/**
|
|
64
65
|
* Forces an error onto a field. Error will be removed if the field value changes
|
|
@@ -432,6 +432,8 @@ let FormModel = (() => {
|
|
|
432
432
|
const validation = this.validation[fromJsonPath];
|
|
433
433
|
delete this.validation[fromJsonPath];
|
|
434
434
|
this.validation[toJsonPath] = validation;
|
|
435
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
|
|
436
|
+
this.moveListItem(fromJsonPath, toJsonPath);
|
|
435
437
|
});
|
|
436
438
|
accessor.set(newList);
|
|
437
439
|
// delete any value overrides so the new list isn't shadowed
|
|
@@ -440,6 +442,12 @@ let FormModel = (() => {
|
|
|
440
442
|
});
|
|
441
443
|
});
|
|
442
444
|
}
|
|
445
|
+
moveListItem(fromValuePath, toValuePath) {
|
|
446
|
+
// do nothing, this is for subclasses to override
|
|
447
|
+
// put in some nonsense so TS doesn't complain about the parameters not being used
|
|
448
|
+
fromValuePath;
|
|
449
|
+
toValuePath;
|
|
450
|
+
}
|
|
443
451
|
internalSetFieldValue(valuePath, value, validation) {
|
|
444
452
|
const { revert } = this.getAdapterForValuePath(valuePath);
|
|
445
453
|
assertExists(revert, 'setting value not supported {}', valuePath);
|
package/.out/core/mobx/hooks.js
CHANGED
|
@@ -19,8 +19,8 @@ export function useDefaultMobxFormHooks(model, { onValidFieldSubmit, onValidForm
|
|
|
19
19
|
// (e.g. changing a discriminator)
|
|
20
20
|
// TODO debounce?
|
|
21
21
|
setTimeout(function () {
|
|
22
|
-
// only start validation if the user has changed the field
|
|
23
|
-
if (model.isValuePathActive(path) && model.isFieldDirty(path)) {
|
|
22
|
+
// only start validation if the user has changed the field and there isn't already an error visible
|
|
23
|
+
if (model.isValuePathActive(path) && model.isFieldDirty(path) && model.fields[path].error == null) {
|
|
24
24
|
// further workaround to make sure we don't downgrade the existing validation
|
|
25
25
|
model.validateField(path, Math.max(Validation.Changed, model.getValidation(path)));
|
|
26
26
|
}
|