@strictly/react-form 0.0.13 → 0.0.14
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/field_adapter.d.ts +1 -0
- package/.out/core/mobx/form_model.d.ts +3 -1
- package/.out/core/mobx/form_model.js +23 -15
- package/.out/core/mobx/hooks.d.ts +2 -2
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +2 -2
- package/.out/core/mobx/specs/form_model.tests.js +26 -21
- package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +14 -21
- package/.out/core/mobx/sub_form_field_adapters.d.ts +5 -6
- package/.out/core/mobx/sub_form_field_adapters.js +6 -11
- package/.out/core/mobx/types.d.ts +3 -3
- package/.out/index.d.ts +2 -0
- package/.out/index.js +2 -0
- package/.out/mantine/field_view.d.ts +18 -0
- package/.out/mantine/field_view.js +16 -0
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/util/empty.d.ts +1 -0
- package/.out/util/empty.js +3 -0
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-check-types.log +1 -1
- package/core/mobx/field_adapter.ts +9 -0
- package/core/mobx/form_model.ts +26 -16
- package/core/mobx/hooks.tsx +2 -2
- package/core/mobx/merge_field_adapters_with_two_way_converter.ts +2 -1
- package/core/mobx/specs/form_model.tests.ts +35 -20
- package/core/mobx/specs/sub_form_field_adapters.tests.ts +14 -34
- package/core/mobx/sub_form_field_adapters.ts +11 -26
- package/core/mobx/types.ts +10 -7
- package/dist/index.cjs +99 -67
- package/dist/index.d.cts +32 -12
- package/dist/index.d.ts +32 -12
- package/dist/index.js +77 -49
- package/index.ts +2 -0
- package/mantine/field_view.tsx +39 -0
- package/package.json +1 -1
- package/util/empty.tsx +3 -0
package/core/mobx/types.ts
CHANGED
|
@@ -10,11 +10,12 @@ import {
|
|
|
10
10
|
*/
|
|
11
11
|
export type ValuePathsOfModel<
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
|
|
14
|
-
> =
|
|
13
|
+
Model extends FormModel<any, any, any, any, any>,
|
|
14
|
+
> = Model extends FormModel<
|
|
15
15
|
infer _1,
|
|
16
16
|
infer _2,
|
|
17
17
|
infer _3,
|
|
18
|
+
infer _4,
|
|
18
19
|
infer ValuePathsToAdapters
|
|
19
20
|
> ? keyof ValuePathsToAdapters
|
|
20
21
|
: never
|
|
@@ -25,12 +26,13 @@ export type ValuePathsOfModel<
|
|
|
25
26
|
*/
|
|
26
27
|
export type ToValueOfModelValuePath<
|
|
27
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
|
|
29
|
-
K extends ValuePathsOfModel<
|
|
30
|
-
> =
|
|
29
|
+
Model extends FormModel<any, any, any, any, any>,
|
|
30
|
+
K extends ValuePathsOfModel<Model>,
|
|
31
|
+
> = Model extends FormModel<
|
|
31
32
|
infer _1,
|
|
32
33
|
infer _2,
|
|
33
34
|
infer _3,
|
|
35
|
+
infer _4,
|
|
34
36
|
infer ValuePathsToAdapters
|
|
35
37
|
> ? ToOfFieldAdapter<ValuePathsToAdapters[K]>
|
|
36
38
|
: never
|
|
@@ -44,11 +46,12 @@ export type ToValueOfModelValuePath<
|
|
|
44
46
|
*/
|
|
45
47
|
export type FormFieldsOfModel<
|
|
46
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
|
|
48
|
-
> =
|
|
49
|
+
Model extends FormModel<any, any, any, any, any>,
|
|
50
|
+
> = Model extends FormModel<
|
|
49
51
|
infer _1,
|
|
50
52
|
infer _2,
|
|
51
53
|
infer _3,
|
|
54
|
+
infer _4,
|
|
52
55
|
infer ValuePathsToAdapters
|
|
53
56
|
> ? FlattenedConvertedFieldsOf<ValuePathsToAdapters>
|
|
54
57
|
: never
|
package/dist/index.cjs
CHANGED
|
@@ -88,6 +88,8 @@ var index_exports = {};
|
|
|
88
88
|
__export(index_exports, {
|
|
89
89
|
AbstractSelectValueTypeConverter: () => AbstractSelectValueTypeConverter,
|
|
90
90
|
DefaultErrorRenderer: () => DefaultErrorRenderer,
|
|
91
|
+
Empty: () => Empty,
|
|
92
|
+
FieldView: () => FieldView,
|
|
91
93
|
FormModel: () => FormModel,
|
|
92
94
|
IntegerToStringConverter: () => IntegerToStringConverter,
|
|
93
95
|
NullableToBooleanConverter: () => NullableToBooleanConverter,
|
|
@@ -355,8 +357,8 @@ function listAdapter() {
|
|
|
355
357
|
var import_base2 = require("@strictly/base");
|
|
356
358
|
var import_define = require("@strictly/define");
|
|
357
359
|
var import_mobx = require("mobx");
|
|
358
|
-
var _accessors_dec, _knownFields_dec, _fields_dec, _errors_dec, _fieldOverrides_dec, _value_dec, _init, _value, _fieldOverrides, _errors;
|
|
359
|
-
_value_dec = [import_mobx.observable.ref], _fieldOverrides_dec = [import_mobx.observable.shallow], _errors_dec = [import_mobx.observable.shallow], _fields_dec = [import_mobx.computed], _knownFields_dec = [import_mobx.computed], _accessors_dec = [import_mobx.computed];
|
|
360
|
+
var _accessors_dec, _knownFields_dec, _fields_dec, _context_dec, _errors_dec, _fieldOverrides_dec, _value_dec, _init, _value, _fieldOverrides, _errors;
|
|
361
|
+
_value_dec = [import_mobx.observable.ref], _fieldOverrides_dec = [import_mobx.observable.shallow], _errors_dec = [import_mobx.observable.shallow], _context_dec = [import_mobx.computed.struct], _fields_dec = [import_mobx.computed], _knownFields_dec = [import_mobx.computed], _accessors_dec = [import_mobx.computed];
|
|
360
362
|
var FormModel = class {
|
|
361
363
|
constructor(type, value, adapters) {
|
|
362
364
|
this.type = type;
|
|
@@ -368,6 +370,7 @@ var FormModel = class {
|
|
|
368
370
|
__publicField(this, "flattenedTypeDefs");
|
|
369
371
|
this.value = (0, import_define.mobxCopy)(type, value);
|
|
370
372
|
this.flattenedTypeDefs = (0, import_define.flattenTypesOfType)(type);
|
|
373
|
+
const contextValue = this.toContext(value);
|
|
371
374
|
const conversions = (0, import_define.flattenValueTo)(
|
|
372
375
|
type,
|
|
373
376
|
this.value,
|
|
@@ -385,13 +388,16 @@ var FormModel = class {
|
|
|
385
388
|
if (revert == null) {
|
|
386
389
|
return;
|
|
387
390
|
}
|
|
388
|
-
return convert(value2, valuePath,
|
|
391
|
+
return convert(value2, valuePath, contextValue);
|
|
389
392
|
}
|
|
390
393
|
);
|
|
391
394
|
this.fieldOverrides = (0, import_base2.map)(conversions, function(_k, v) {
|
|
392
395
|
return v && [v.value];
|
|
393
396
|
});
|
|
394
397
|
}
|
|
398
|
+
get context() {
|
|
399
|
+
return this.toContext(this.value);
|
|
400
|
+
}
|
|
395
401
|
get fields() {
|
|
396
402
|
return new Proxy(
|
|
397
403
|
this.knownFields,
|
|
@@ -459,11 +465,11 @@ var FormModel = class {
|
|
|
459
465
|
accessor != null ? accessor.value : fieldTypeDef != null ? (0, import_define.mobxCopy)(
|
|
460
466
|
fieldTypeDef,
|
|
461
467
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
462
|
-
create(valuePath, this.
|
|
463
|
-
) : create(valuePath, this.
|
|
468
|
+
create(valuePath, this.context)
|
|
469
|
+
) : create(valuePath, this.context),
|
|
464
470
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
465
471
|
valuePath,
|
|
466
|
-
this.
|
|
472
|
+
this.context
|
|
467
473
|
);
|
|
468
474
|
const error = this.errors[valuePath];
|
|
469
475
|
return {
|
|
@@ -521,7 +527,7 @@ var FormModel = class {
|
|
|
521
527
|
const element = elementValue != null ? elementValue[0] : elementAdapter.create(
|
|
522
528
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
523
529
|
elementTypePath,
|
|
524
|
-
this.
|
|
530
|
+
this.context
|
|
525
531
|
);
|
|
526
532
|
const originalList = accessor.value;
|
|
527
533
|
const newList = [
|
|
@@ -639,7 +645,7 @@ var FormModel = class {
|
|
|
639
645
|
internalSetFieldValue(valuePath, value, displayValidation) {
|
|
640
646
|
const { revert } = this.getAdapterForValuePath(valuePath);
|
|
641
647
|
(0, import_base2.assertExists)(revert, "setting value not supported {}", valuePath);
|
|
642
|
-
const conversion = revert(value, valuePath, this.
|
|
648
|
+
const conversion = revert(value, valuePath, this.context);
|
|
643
649
|
const accessor = this.getAccessorForValuePath(valuePath);
|
|
644
650
|
return (0, import_mobx.runInAction)(() => {
|
|
645
651
|
this.fieldOverrides[valuePath] = [value];
|
|
@@ -679,10 +685,10 @@ var FormModel = class {
|
|
|
679
685
|
convert,
|
|
680
686
|
create
|
|
681
687
|
} = adapter2;
|
|
682
|
-
const value = create(valuePath, this.
|
|
688
|
+
const value = create(valuePath, this.context);
|
|
683
689
|
const {
|
|
684
690
|
value: displayValue
|
|
685
|
-
} = convert(value, valuePath, this.
|
|
691
|
+
} = convert(value, valuePath, this.context);
|
|
686
692
|
const key = valuePath;
|
|
687
693
|
(0, import_mobx.runInAction)(() => {
|
|
688
694
|
this.fieldOverrides[key] = [displayValue];
|
|
@@ -711,10 +717,10 @@ var FormModel = class {
|
|
|
711
717
|
const {
|
|
712
718
|
value: storedValue
|
|
713
719
|
} = convert(
|
|
714
|
-
accessor != null ? accessor.value : create(valuePath, this.
|
|
720
|
+
accessor != null ? accessor.value : create(valuePath, this.context),
|
|
715
721
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
716
722
|
valuePath,
|
|
717
|
-
this.
|
|
723
|
+
this.context
|
|
718
724
|
);
|
|
719
725
|
const value = fieldOverride != null ? fieldOverride[0] : storedValue;
|
|
720
726
|
const dirty = storedValue !== value;
|
|
@@ -722,12 +728,12 @@ var FormModel = class {
|
|
|
722
728
|
if (ignoreDefaultValue) {
|
|
723
729
|
const {
|
|
724
730
|
value: defaultDisplayValue
|
|
725
|
-
} = convert(create(valuePath, this.
|
|
731
|
+
} = convert(create(valuePath, this.context), valuePath, this.context);
|
|
726
732
|
if (defaultDisplayValue === value) {
|
|
727
733
|
return true;
|
|
728
734
|
}
|
|
729
735
|
}
|
|
730
|
-
const conversion = revert(value, valuePath, this.
|
|
736
|
+
const conversion = revert(value, valuePath, this.context);
|
|
731
737
|
return (0, import_mobx.runInAction)(() => {
|
|
732
738
|
switch (conversion.type) {
|
|
733
739
|
case 1 /* Failure */:
|
|
@@ -772,10 +778,10 @@ var FormModel = class {
|
|
|
772
778
|
const fieldOverride = this.fieldOverrides[adapterPath];
|
|
773
779
|
const {
|
|
774
780
|
value: storedValue
|
|
775
|
-
} = convert(accessor.value, valuePath, this.
|
|
781
|
+
} = convert(accessor.value, valuePath, this.context);
|
|
776
782
|
const value = fieldOverride != null ? fieldOverride[0] : storedValue;
|
|
777
783
|
const dirty = fieldOverride != null && fieldOverride[0] !== storedValue;
|
|
778
|
-
const conversion = revert(value, valuePath, this.
|
|
784
|
+
const conversion = revert(value, valuePath, this.context);
|
|
779
785
|
switch (conversion.type) {
|
|
780
786
|
case 1 /* Failure */:
|
|
781
787
|
this.errors[adapterPath] = conversion.error;
|
|
@@ -805,6 +811,7 @@ _errors = new WeakMap();
|
|
|
805
811
|
__decorateElement(_init, 4, "value", _value_dec, FormModel, _value);
|
|
806
812
|
__decorateElement(_init, 4, "fieldOverrides", _fieldOverrides_dec, FormModel, _fieldOverrides);
|
|
807
813
|
__decorateElement(_init, 4, "errors", _errors_dec, FormModel, _errors);
|
|
814
|
+
__decorateElement(_init, 2, "context", _context_dec, FormModel);
|
|
808
815
|
__decorateElement(_init, 2, "fields", _fields_dec, FormModel);
|
|
809
816
|
__decorateElement(_init, 2, "knownFields", _knownFields_dec, FormModel);
|
|
810
817
|
__decorateElement(_init, 2, "accessors", _accessors_dec, FormModel);
|
|
@@ -939,17 +946,12 @@ function mergeAdaptersWithValidators(adapters, validators) {
|
|
|
939
946
|
}
|
|
940
947
|
|
|
941
948
|
// core/mobx/sub_form_field_adapters.ts
|
|
942
|
-
|
|
943
|
-
function subFormFieldAdapters(subAdapters, parentTypePath, contextType) {
|
|
949
|
+
function subFormFieldAdapters(subAdapters, parentTypePath) {
|
|
944
950
|
const dotCount = parentTypePath.split(".").length;
|
|
945
|
-
function
|
|
951
|
+
function getSubValuePath(valuePath) {
|
|
946
952
|
const parentValuePath = valuePath.split(".").slice(0, dotCount).join(".");
|
|
947
953
|
const subValuePath = valuePath.replace(parentValuePath, "$");
|
|
948
|
-
|
|
949
|
-
return [
|
|
950
|
-
subValuePath,
|
|
951
|
-
subContext
|
|
952
|
-
];
|
|
954
|
+
return subValuePath;
|
|
953
955
|
}
|
|
954
956
|
return Object.entries(subAdapters).reduce((acc, [
|
|
955
957
|
subTypePath,
|
|
@@ -958,13 +960,13 @@ function subFormFieldAdapters(subAdapters, parentTypePath, contextType) {
|
|
|
958
960
|
const typePath = subTypePath.replace("$", parentTypePath);
|
|
959
961
|
const adaptedAdapter = {
|
|
960
962
|
convert: (from, valuePath, context) => {
|
|
961
|
-
return subAdapter.convert(from,
|
|
963
|
+
return subAdapter.convert(from, getSubValuePath(valuePath), context);
|
|
962
964
|
},
|
|
963
965
|
create: (valuePath, context) => {
|
|
964
|
-
return subAdapter.create(
|
|
966
|
+
return subAdapter.create(getSubValuePath(valuePath), context);
|
|
965
967
|
},
|
|
966
968
|
revert: subAdapter.revert && ((from, valuePath, context) => {
|
|
967
|
-
return subAdapter.revert(from,
|
|
969
|
+
return subAdapter.revert(from, getSubValuePath(valuePath), context);
|
|
968
970
|
})
|
|
969
971
|
};
|
|
970
972
|
acc[typePath] = adaptedAdapter;
|
|
@@ -1004,7 +1006,7 @@ var IntegerToStringConverter = class {
|
|
|
1004
1006
|
};
|
|
1005
1007
|
|
|
1006
1008
|
// field_converters/nullable_to_boolean_converter.ts
|
|
1007
|
-
var
|
|
1009
|
+
var import_define3 = require("@strictly/define");
|
|
1008
1010
|
var NullableToBooleanConverter = class {
|
|
1009
1011
|
constructor(typeDef, prototype, nullType, defaultToNull = true) {
|
|
1010
1012
|
this.typeDef = typeDef;
|
|
@@ -1022,7 +1024,7 @@ var NullableToBooleanConverter = class {
|
|
|
1022
1024
|
}
|
|
1023
1025
|
revert(from) {
|
|
1024
1026
|
if (from) {
|
|
1025
|
-
const value = (0,
|
|
1027
|
+
const value = (0, import_define3.copy)(this.typeDef, this.prototype);
|
|
1026
1028
|
return {
|
|
1027
1029
|
type: 0 /* Success */,
|
|
1028
1030
|
value
|
|
@@ -1040,7 +1042,7 @@ var NullableToBooleanConverter = class {
|
|
|
1040
1042
|
|
|
1041
1043
|
// field_converters/select_value_type_converter.ts
|
|
1042
1044
|
var import_base5 = require("@strictly/base");
|
|
1043
|
-
var
|
|
1045
|
+
var import_define4 = require("@strictly/define");
|
|
1044
1046
|
var AbstractSelectValueTypeConverter = class {
|
|
1045
1047
|
constructor(typeDef, values, defaultValueKey, noSuchValueError, required) {
|
|
1046
1048
|
this.typeDef = typeDef;
|
|
@@ -1058,7 +1060,7 @@ var AbstractSelectValueTypeConverter = class {
|
|
|
1058
1060
|
value: null
|
|
1059
1061
|
};
|
|
1060
1062
|
}
|
|
1061
|
-
const value = prototype == null ? prototype : (0,
|
|
1063
|
+
const value = prototype == null ? prototype : (0, import_define4.copy)(this.typeDef, prototype);
|
|
1062
1064
|
return {
|
|
1063
1065
|
type: 0 /* Success */,
|
|
1064
1066
|
value
|
|
@@ -1132,13 +1134,13 @@ var SelectStringConverter = class extends AbstractSelectValueTypeConverter {
|
|
|
1132
1134
|
};
|
|
1133
1135
|
|
|
1134
1136
|
// field_converters/validating_converter.ts
|
|
1135
|
-
var
|
|
1137
|
+
var import_define5 = require("@strictly/define");
|
|
1136
1138
|
function validatingConverter(validators = []) {
|
|
1137
1139
|
return function(value, valuePath, context) {
|
|
1138
1140
|
return validators.reduce(
|
|
1139
1141
|
function(acc, validator) {
|
|
1140
1142
|
if (acc.type === 0 /* Success */) {
|
|
1141
|
-
const error = (0,
|
|
1143
|
+
const error = (0, import_define5.validate)(validator, value, valuePath, context);
|
|
1142
1144
|
if (error != null) {
|
|
1143
1145
|
return {
|
|
1144
1146
|
type: 1 /* Failure */,
|
|
@@ -1165,6 +1167,34 @@ function DefaultErrorRenderer({
|
|
|
1165
1167
|
return JSON.stringify(error);
|
|
1166
1168
|
}
|
|
1167
1169
|
|
|
1170
|
+
// mantine/field_view.tsx
|
|
1171
|
+
var import_mobx_react = require("mobx-react");
|
|
1172
|
+
|
|
1173
|
+
// util/empty.tsx
|
|
1174
|
+
function Empty() {
|
|
1175
|
+
return null;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// mantine/field_view.tsx
|
|
1179
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1180
|
+
function FieldView({
|
|
1181
|
+
fields,
|
|
1182
|
+
valuePath,
|
|
1183
|
+
children
|
|
1184
|
+
}) {
|
|
1185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mobx_react.Observer, { children: () => {
|
|
1186
|
+
const {
|
|
1187
|
+
value,
|
|
1188
|
+
error
|
|
1189
|
+
} = fields[valuePath];
|
|
1190
|
+
return children({
|
|
1191
|
+
value,
|
|
1192
|
+
error,
|
|
1193
|
+
ErrorSink: Empty
|
|
1194
|
+
});
|
|
1195
|
+
} });
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1168
1198
|
// mantine/hooks.tsx
|
|
1169
1199
|
var import_core = require("@mantine/core");
|
|
1170
1200
|
var import_base6 = require("@strictly/base");
|
|
@@ -1172,14 +1202,14 @@ var import_mobx2 = require("mobx");
|
|
|
1172
1202
|
var import_react4 = require("react");
|
|
1173
1203
|
|
|
1174
1204
|
// util/partial.tsx
|
|
1175
|
-
var
|
|
1205
|
+
var import_mobx_react2 = require("mobx-react");
|
|
1176
1206
|
var import_react2 = require("react");
|
|
1177
|
-
var
|
|
1207
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1178
1208
|
function createSimplePartialComponent(Component, curriedProps) {
|
|
1179
1209
|
return (0, import_react2.forwardRef)(
|
|
1180
1210
|
function(exposedProps, ref) {
|
|
1181
1211
|
const C = Component;
|
|
1182
|
-
return /* @__PURE__ */ (0,
|
|
1212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1183
1213
|
C,
|
|
1184
1214
|
__spreadValues(__spreadValues({
|
|
1185
1215
|
ref
|
|
@@ -1219,7 +1249,7 @@ function createPartialComponent(Component, curriedPropsSource, additionalPropKey
|
|
|
1219
1249
|
]
|
|
1220
1250
|
);
|
|
1221
1251
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
1222
|
-
return /* @__PURE__ */ (0,
|
|
1252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1223
1253
|
C,
|
|
1224
1254
|
__spreadValues(__spreadValues({
|
|
1225
1255
|
ref
|
|
@@ -1255,7 +1285,7 @@ function createPartialObserverComponent(Component, curriedPropsSource, additiona
|
|
|
1255
1285
|
);
|
|
1256
1286
|
}
|
|
1257
1287
|
function createUnsafePartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
|
|
1258
|
-
return (0,
|
|
1288
|
+
return (0, import_mobx_react2.observer)(
|
|
1259
1289
|
(0, import_react2.forwardRef)(
|
|
1260
1290
|
function(props, ref) {
|
|
1261
1291
|
const C = Component;
|
|
@@ -1286,7 +1316,7 @@ function createUnsafePartialObserverComponent(Component, curriedPropsSource, add
|
|
|
1286
1316
|
]
|
|
1287
1317
|
);
|
|
1288
1318
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
1289
|
-
return /* @__PURE__ */ (0,
|
|
1319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1290
1320
|
C,
|
|
1291
1321
|
__spreadValues(__spreadValues({
|
|
1292
1322
|
ref
|
|
@@ -1317,7 +1347,7 @@ function usePartialObserverComponent(curriedPropsSource, deps, Component, additi
|
|
|
1317
1347
|
}
|
|
1318
1348
|
|
|
1319
1349
|
// mantine/create_checkbox.tsx
|
|
1320
|
-
var
|
|
1350
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1321
1351
|
function createCheckbox(valuePath, Checkbox) {
|
|
1322
1352
|
const onChange = (e) => {
|
|
1323
1353
|
var _a;
|
|
@@ -1354,7 +1384,7 @@ function createCheckbox(valuePath, Checkbox) {
|
|
|
1354
1384
|
checked: value,
|
|
1355
1385
|
disabled: readonly,
|
|
1356
1386
|
required,
|
|
1357
|
-
error: error && /* @__PURE__ */ (0,
|
|
1387
|
+
error: error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorRenderer, { error }),
|
|
1358
1388
|
onChange,
|
|
1359
1389
|
onFocus,
|
|
1360
1390
|
onBlur,
|
|
@@ -1369,15 +1399,15 @@ function createCheckbox(valuePath, Checkbox) {
|
|
|
1369
1399
|
}
|
|
1370
1400
|
|
|
1371
1401
|
// mantine/create_fields_view.tsx
|
|
1372
|
-
var
|
|
1373
|
-
var
|
|
1374
|
-
var
|
|
1402
|
+
var import_define6 = require("@strictly/define");
|
|
1403
|
+
var import_mobx_react3 = require("mobx-react");
|
|
1404
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1375
1405
|
function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
1376
1406
|
function toKey(subKey) {
|
|
1377
|
-
return (0,
|
|
1407
|
+
return (0, import_define6.jsonPathPrefix)(valuePath, subKey);
|
|
1378
1408
|
}
|
|
1379
1409
|
function toSubKey(key) {
|
|
1380
|
-
return (0,
|
|
1410
|
+
return (0, import_define6.jsonPathUnprefix)(valuePath, key);
|
|
1381
1411
|
}
|
|
1382
1412
|
function onFieldValueChange(subKey, value) {
|
|
1383
1413
|
observableProps.onFieldValueChange(toKey(subKey), value);
|
|
@@ -1394,7 +1424,7 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1394
1424
|
var _a;
|
|
1395
1425
|
(_a = observableProps.onFieldSubmit) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1396
1426
|
}
|
|
1397
|
-
const Component = (0,
|
|
1427
|
+
const Component = (0, import_mobx_react3.observer)(
|
|
1398
1428
|
function(props) {
|
|
1399
1429
|
const subFields = Object.entries(observableProps.fields).reduce(
|
|
1400
1430
|
(acc, [
|
|
@@ -1409,7 +1439,7 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1409
1439
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1410
1440
|
{}
|
|
1411
1441
|
);
|
|
1412
|
-
return /* @__PURE__ */ (0,
|
|
1442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1413
1443
|
FieldsView,
|
|
1414
1444
|
__spreadProps(__spreadValues({}, props), {
|
|
1415
1445
|
fields: subFields,
|
|
@@ -1434,16 +1464,16 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1434
1464
|
}
|
|
1435
1465
|
|
|
1436
1466
|
// mantine/create_form.tsx
|
|
1437
|
-
var
|
|
1467
|
+
var import_mobx_react4 = require("mobx-react");
|
|
1438
1468
|
var import_react3 = require("react");
|
|
1439
|
-
var
|
|
1469
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1440
1470
|
function createForm(valuePath, Form, observableProps) {
|
|
1441
|
-
return (0,
|
|
1471
|
+
return (0, import_mobx_react4.observer)((props) => {
|
|
1442
1472
|
const { value } = observableProps.fields[valuePath];
|
|
1443
1473
|
const onValueChange = (0, import_react3.useCallback)((value2) => {
|
|
1444
1474
|
observableProps.onFieldValueChange(valuePath, value2);
|
|
1445
1475
|
}, []);
|
|
1446
|
-
return /* @__PURE__ */ (0,
|
|
1476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1447
1477
|
Form,
|
|
1448
1478
|
__spreadProps(__spreadValues({}, props), {
|
|
1449
1479
|
onValueChange,
|
|
@@ -1454,7 +1484,7 @@ function createForm(valuePath, Form, observableProps) {
|
|
|
1454
1484
|
}
|
|
1455
1485
|
|
|
1456
1486
|
// mantine/create_list.tsx
|
|
1457
|
-
var
|
|
1487
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1458
1488
|
function createList(valuePath, List) {
|
|
1459
1489
|
const propSource = () => {
|
|
1460
1490
|
const values = [...this.fields[valuePath].value];
|
|
@@ -1470,7 +1500,7 @@ function DefaultList({
|
|
|
1470
1500
|
listPath,
|
|
1471
1501
|
children
|
|
1472
1502
|
}) {
|
|
1473
|
-
return /* @__PURE__ */ (0,
|
|
1503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: values.map(function(value, index) {
|
|
1474
1504
|
const valuePath = `${listPath}.${index}`;
|
|
1475
1505
|
return children(valuePath, value, index);
|
|
1476
1506
|
}) });
|
|
@@ -1509,7 +1539,7 @@ function createRadio(valuePath, value, Radio) {
|
|
|
1509
1539
|
}
|
|
1510
1540
|
|
|
1511
1541
|
// mantine/create_radio_group.tsx
|
|
1512
|
-
var
|
|
1542
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1513
1543
|
function createRadioGroup(valuePath, RadioGroup) {
|
|
1514
1544
|
const onChange = (value) => {
|
|
1515
1545
|
var _a;
|
|
@@ -1541,7 +1571,7 @@ function createRadioGroup(valuePath, RadioGroup) {
|
|
|
1541
1571
|
name: valuePath,
|
|
1542
1572
|
value,
|
|
1543
1573
|
required,
|
|
1544
|
-
error: error && /* @__PURE__ */ (0,
|
|
1574
|
+
error: error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ErrorRenderer, { error }),
|
|
1545
1575
|
onChange,
|
|
1546
1576
|
onFocus,
|
|
1547
1577
|
onBlur,
|
|
@@ -1552,7 +1582,7 @@ function createRadioGroup(valuePath, RadioGroup) {
|
|
|
1552
1582
|
}
|
|
1553
1583
|
|
|
1554
1584
|
// mantine/create_text_input.tsx
|
|
1555
|
-
var
|
|
1585
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1556
1586
|
function createTextInput(valuePath, TextInput) {
|
|
1557
1587
|
const onChange = (e) => {
|
|
1558
1588
|
var _a;
|
|
@@ -1593,7 +1623,7 @@ function createTextInput(valuePath, TextInput) {
|
|
|
1593
1623
|
value,
|
|
1594
1624
|
disabled: readonly,
|
|
1595
1625
|
required,
|
|
1596
|
-
error: error && /* @__PURE__ */ (0,
|
|
1626
|
+
error: error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorRenderer, { error }),
|
|
1597
1627
|
onChange,
|
|
1598
1628
|
onFocus,
|
|
1599
1629
|
onBlur,
|
|
@@ -1608,7 +1638,7 @@ function createTextInput(valuePath, TextInput) {
|
|
|
1608
1638
|
}
|
|
1609
1639
|
|
|
1610
1640
|
// mantine/create_value_input.tsx
|
|
1611
|
-
var
|
|
1641
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1612
1642
|
function createValueInput(valuePath, ValueInput) {
|
|
1613
1643
|
const onChange = (value) => {
|
|
1614
1644
|
var _a;
|
|
@@ -1646,7 +1676,7 @@ function createValueInput(valuePath, ValueInput) {
|
|
|
1646
1676
|
value,
|
|
1647
1677
|
disabled: readonly,
|
|
1648
1678
|
required,
|
|
1649
|
-
error: error && /* @__PURE__ */ (0,
|
|
1679
|
+
error: error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ErrorRenderer, { error }),
|
|
1650
1680
|
onChange,
|
|
1651
1681
|
onFocus,
|
|
1652
1682
|
onBlur,
|
|
@@ -1661,9 +1691,9 @@ function createValueInput(valuePath, ValueInput) {
|
|
|
1661
1691
|
}
|
|
1662
1692
|
|
|
1663
1693
|
// mantine/hooks.tsx
|
|
1664
|
-
var
|
|
1694
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1665
1695
|
function SimpleSelect(props) {
|
|
1666
|
-
return /* @__PURE__ */ (0,
|
|
1696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core.Select, __spreadValues({}, props));
|
|
1667
1697
|
}
|
|
1668
1698
|
function useMantineFormFields({
|
|
1669
1699
|
onFieldValueChange,
|
|
@@ -1832,7 +1862,7 @@ __decorateElement(_init2, 4, "fields", _fields_dec2, MantineFormImpl, _fields);
|
|
|
1832
1862
|
__decoratorMetadata(_init2, MantineFormImpl);
|
|
1833
1863
|
|
|
1834
1864
|
// types/merge_validators.ts
|
|
1835
|
-
var
|
|
1865
|
+
var import_define7 = require("@strictly/define");
|
|
1836
1866
|
function mergeValidators(validators1, validators2) {
|
|
1837
1867
|
const validators = __spreadValues(__spreadValues({}, validators1), validators2);
|
|
1838
1868
|
const keys1 = new Set(Object.keys(validators1));
|
|
@@ -1844,16 +1874,16 @@ function mergeValidators(validators1, validators2) {
|
|
|
1844
1874
|
validators3[key] = {
|
|
1845
1875
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1846
1876
|
validate: function(value, valuePath, context) {
|
|
1847
|
-
const error = (0,
|
|
1877
|
+
const error = (0, import_define7.validate)(validator1, value, valuePath, context);
|
|
1848
1878
|
if (error != null) {
|
|
1849
1879
|
return error;
|
|
1850
1880
|
}
|
|
1851
|
-
return (0,
|
|
1881
|
+
return (0, import_define7.validate)(validator2, value, valuePath, context);
|
|
1852
1882
|
},
|
|
1853
1883
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1854
1884
|
annotations: function(valuePath, context) {
|
|
1855
|
-
const annotations1 = (0,
|
|
1856
|
-
const annotations22 = (0,
|
|
1885
|
+
const annotations1 = (0, import_define7.annotations)(validator1, valuePath, context);
|
|
1886
|
+
const annotations22 = (0, import_define7.annotations)(validator2, valuePath, context);
|
|
1857
1887
|
return {
|
|
1858
1888
|
readonly: annotations1.readonly || annotations22.readonly,
|
|
1859
1889
|
required: annotations1.required || annotations22.required
|
|
@@ -1870,6 +1900,8 @@ function mergeValidators(validators1, validators2) {
|
|
|
1870
1900
|
0 && (module.exports = {
|
|
1871
1901
|
AbstractSelectValueTypeConverter,
|
|
1872
1902
|
DefaultErrorRenderer,
|
|
1903
|
+
Empty,
|
|
1904
|
+
FieldView,
|
|
1873
1905
|
FormModel,
|
|
1874
1906
|
IntegerToStringConverter,
|
|
1875
1907
|
NullableToBooleanConverter,
|