@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
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,12 +7,12 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Target: es6
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
10
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m63.79 KB[39m
|
|
11
|
+
[32mCJS[39m ⚡️ Build success in 126ms
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m59.70 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 132ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m38.
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m38.
|
|
18
|
-
Done in
|
|
15
|
+
[32mDTS[39m ⚡️ Build success in 32334ms
|
|
16
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m38.14 KB[39m
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m38.14 KB[39m
|
|
18
|
+
Done in 33.47s.
|
package/core/mobx/form_model.ts
CHANGED
|
@@ -599,6 +599,8 @@ export abstract class FormModel<
|
|
|
599
599
|
const validation = this.validation[fromJsonPath]
|
|
600
600
|
delete this.validation[fromJsonPath]
|
|
601
601
|
this.validation[toJsonPath] = validation
|
|
602
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
|
|
603
|
+
this.moveListItem(fromJsonPath as any, toJsonPath as any)
|
|
602
604
|
})
|
|
603
605
|
accessor.set(newList)
|
|
604
606
|
// delete any value overrides so the new list isn't shadowed
|
|
@@ -608,6 +610,13 @@ export abstract class FormModel<
|
|
|
608
610
|
})
|
|
609
611
|
}
|
|
610
612
|
|
|
613
|
+
protected moveListItem<K extends keyof FlattenedListTypesOfType<T>>(fromValuePath: K, toValuePath: K) {
|
|
614
|
+
// do nothing, this is for subclasses to override
|
|
615
|
+
// put in some nonsense so TS doesn't complain about the parameters not being used
|
|
616
|
+
fromValuePath satisfies K
|
|
617
|
+
toValuePath satisfies K
|
|
618
|
+
}
|
|
619
|
+
|
|
611
620
|
private internalSetFieldValue<K extends keyof ValuePathsToAdapters>(
|
|
612
621
|
valuePath: K,
|
|
613
622
|
value: ToOfFieldAdapter<ValuePathsToAdapters[K]>,
|
package/core/mobx/hooks.tsx
CHANGED
|
@@ -66,8 +66,8 @@ export function useDefaultMobxFormHooks<
|
|
|
66
66
|
// (e.g. changing a discriminator)
|
|
67
67
|
// TODO debounce?
|
|
68
68
|
setTimeout(function () {
|
|
69
|
-
// only start validation if the user has changed the field
|
|
70
|
-
if (model.isValuePathActive(path) && model.isFieldDirty(path)) {
|
|
69
|
+
// only start validation if the user has changed the field and there isn't already an error visible
|
|
70
|
+
if (model.isValuePathActive(path) && model.isFieldDirty(path) && model.fields[path].error == null) {
|
|
71
71
|
// further workaround to make sure we don't downgrade the existing validation
|
|
72
72
|
model.validateField(path, Math.max(Validation.Changed, model.getValidation(path)))
|
|
73
73
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -720,12 +720,17 @@ var FormModel = class {
|
|
|
720
720
|
const validation = this.validation[fromJsonPath];
|
|
721
721
|
delete this.validation[fromJsonPath];
|
|
722
722
|
this.validation[toJsonPath] = validation;
|
|
723
|
+
this.moveListItem(fromJsonPath, toJsonPath);
|
|
723
724
|
});
|
|
724
725
|
accessor.set(newList);
|
|
725
726
|
delete this.fieldOverrides[listValuePath];
|
|
726
727
|
});
|
|
727
728
|
});
|
|
728
729
|
}
|
|
730
|
+
moveListItem(fromValuePath, toValuePath) {
|
|
731
|
+
fromValuePath;
|
|
732
|
+
toValuePath;
|
|
733
|
+
}
|
|
729
734
|
internalSetFieldValue(valuePath, value, validation) {
|
|
730
735
|
const { revert } = this.getAdapterForValuePath(valuePath);
|
|
731
736
|
(0, import_base2.assertExists)(revert, "setting value not supported {}", valuePath);
|
|
@@ -915,7 +920,7 @@ function useDefaultMobxFormHooks(model, {
|
|
|
915
920
|
const onFieldBlur = (0, import_react.useCallback)(
|
|
916
921
|
function(path) {
|
|
917
922
|
setTimeout(function() {
|
|
918
|
-
if (model.isValuePathActive(path) && model.isFieldDirty(path)) {
|
|
923
|
+
if (model.isValuePathActive(path) && model.isFieldDirty(path) && model.fields[path].error == null) {
|
|
919
924
|
model.validateField(path, Math.max(1 /* Changed */, model.getValidation(path)));
|
|
920
925
|
}
|
|
921
926
|
}, 100);
|
package/dist/index.d.cts
CHANGED
|
@@ -157,6 +157,7 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
|
|
|
157
157
|
setFieldValue<K extends keyof ValuePathsToAdapters>(valuePath: K, value: ToOfFieldAdapter<ValuePathsToAdapters[K]>, validation?: Validation): boolean;
|
|
158
158
|
addListItem<K extends keyof FlattenedListTypesOfType<T>>(valuePath: K, elementValue?: Maybe<ElementOfArray<FlattenedValuesOfType<T>[K]>>, index?: number): void;
|
|
159
159
|
removeListItem<K extends keyof FlattenedListTypesOfType<T>>(...elementValuePaths: readonly `${K}.${number}`[]): void;
|
|
160
|
+
protected moveListItem<K extends keyof FlattenedListTypesOfType<T>>(fromValuePath: K, toValuePath: K): void;
|
|
160
161
|
private internalSetFieldValue;
|
|
161
162
|
/**
|
|
162
163
|
* Forces an error onto a field. Error will be removed if the field value changes
|
package/dist/index.d.ts
CHANGED
|
@@ -157,6 +157,7 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
|
|
|
157
157
|
setFieldValue<K extends keyof ValuePathsToAdapters>(valuePath: K, value: ToOfFieldAdapter<ValuePathsToAdapters[K]>, validation?: Validation): boolean;
|
|
158
158
|
addListItem<K extends keyof FlattenedListTypesOfType<T>>(valuePath: K, elementValue?: Maybe<ElementOfArray<FlattenedValuesOfType<T>[K]>>, index?: number): void;
|
|
159
159
|
removeListItem<K extends keyof FlattenedListTypesOfType<T>>(...elementValuePaths: readonly `${K}.${number}`[]): void;
|
|
160
|
+
protected moveListItem<K extends keyof FlattenedListTypesOfType<T>>(fromValuePath: K, toValuePath: K): void;
|
|
160
161
|
private internalSetFieldValue;
|
|
161
162
|
/**
|
|
162
163
|
* Forces an error onto a field. Error will be removed if the field value changes
|
package/dist/index.js
CHANGED
|
@@ -690,12 +690,17 @@ var FormModel = class {
|
|
|
690
690
|
const validation = this.validation[fromJsonPath];
|
|
691
691
|
delete this.validation[fromJsonPath];
|
|
692
692
|
this.validation[toJsonPath] = validation;
|
|
693
|
+
this.moveListItem(fromJsonPath, toJsonPath);
|
|
693
694
|
});
|
|
694
695
|
accessor.set(newList);
|
|
695
696
|
delete this.fieldOverrides[listValuePath];
|
|
696
697
|
});
|
|
697
698
|
});
|
|
698
699
|
}
|
|
700
|
+
moveListItem(fromValuePath, toValuePath) {
|
|
701
|
+
fromValuePath;
|
|
702
|
+
toValuePath;
|
|
703
|
+
}
|
|
699
704
|
internalSetFieldValue(valuePath, value, validation) {
|
|
700
705
|
const { revert } = this.getAdapterForValuePath(valuePath);
|
|
701
706
|
assertExists(revert, "setting value not supported {}", valuePath);
|
|
@@ -887,7 +892,7 @@ function useDefaultMobxFormHooks(model, {
|
|
|
887
892
|
const onFieldBlur = useCallback(
|
|
888
893
|
function(path) {
|
|
889
894
|
setTimeout(function() {
|
|
890
|
-
if (model.isValuePathActive(path) && model.isFieldDirty(path)) {
|
|
895
|
+
if (model.isValuePathActive(path) && model.isFieldDirty(path) && model.fields[path].error == null) {
|
|
891
896
|
model.validateField(path, Math.max(1 /* Changed */, model.getValidation(path)));
|
|
892
897
|
}
|
|
893
898
|
}, 100);
|