@strictly/react-form 0.0.10 → 0.0.11
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_builder.js +18 -6
- package/.out/core/mobx/form_presenter.js +224 -121
- package/.out/core/mobx/hooks.js +2 -2
- package/.out/core/mobx/merge_field_adapters_with_validators.js +1 -5
- package/.out/core/mobx/specs/fixtures.js +2 -1
- package/.out/core/mobx/specs/form_presenter.tests.js +6 -3
- package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +2 -1
- package/.out/field_converters/integer_to_string_converter.js +12 -4
- package/.out/field_converters/maybe_identity_converter.js +12 -4
- package/.out/field_converters/nullable_to_boolean_converter.js +24 -7
- package/.out/field_converters/select_value_type_converter.js +36 -12
- package/.out/mantine/create_checkbox.js +8 -4
- package/.out/mantine/create_fields_view.js +7 -4
- package/.out/mantine/create_form.js +1 -1
- package/.out/mantine/create_radio_group.js +8 -4
- package/.out/mantine/create_text_input.js +8 -4
- package/.out/mantine/create_value_input.js +8 -4
- package/.out/mantine/hooks.js +218 -92
- package/.out/mantine/specs/checkbox_hooks.stories.js +13 -1
- package/.out/mantine/specs/checkbox_hooks.tests.js +22 -9
- package/.out/mantine/specs/fields_view_hooks.stories.js +15 -2
- package/.out/mantine/specs/fields_view_hooks.tests.js +12 -3
- package/.out/mantine/specs/radio_group_hooks.stories.js +13 -1
- package/.out/mantine/specs/radio_group_hooks.tests.js +23 -10
- package/.out/mantine/specs/select_hooks.stories.js +13 -1
- package/.out/mantine/specs/text_input_hooks.stories.js +13 -1
- package/.out/mantine/specs/text_input_hooks.tests.js +18 -7
- package/.out/mantine/specs/value_input_hooks.stories.js +14 -2
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/tsup.config.js +2 -9
- package/.out/types/merge_validators.js +1 -4
- package/.out/util/partial.js +5 -5
- package/.out/vitest.workspace.js +2 -10
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/core/mobx/hooks.tsx +1 -0
- package/dist/index.cjs +182 -100
- package/dist/index.js +186 -100
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
10
|
+
var __typeError = (msg) => {
|
|
11
|
+
throw TypeError(msg);
|
|
12
|
+
};
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
27
|
+
var __decoratorStart = (base) => {
|
|
28
|
+
var _a;
|
|
29
|
+
return [, , , __create((_a = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a : null)];
|
|
30
|
+
};
|
|
31
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
32
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
33
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
34
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
35
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
36
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
39
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
40
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
41
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
42
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
43
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
44
|
+
return __privateGet(this, extra);
|
|
45
|
+
}, set [name](x) {
|
|
46
|
+
return __privateSet(this, extra, x);
|
|
47
|
+
} }, name));
|
|
48
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
49
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
50
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
51
|
+
if (k) {
|
|
52
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
53
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
54
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
55
|
+
}
|
|
56
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
57
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
58
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
59
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
60
|
+
}
|
|
61
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
62
|
+
};
|
|
63
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
64
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
65
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
66
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
67
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
68
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
69
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
70
|
+
|
|
1
71
|
// field_converters/chain_field_converter.ts
|
|
2
72
|
import {
|
|
3
73
|
UnreachableError
|
|
@@ -285,7 +355,7 @@ var FormPresenter = class {
|
|
|
285
355
|
const listValuePath = valuePath;
|
|
286
356
|
const accessor = model.accessors[valuePath];
|
|
287
357
|
const listTypePath = this.typePath(valuePath);
|
|
288
|
-
const definedIndex = index
|
|
358
|
+
const definedIndex = index != null ? index : accessor.value.length;
|
|
289
359
|
const elementTypePath = `${listTypePath}.*`;
|
|
290
360
|
const elementAdapter = assertExistsAndReturn(
|
|
291
361
|
this.adapters[elementTypePath],
|
|
@@ -426,7 +496,7 @@ var FormPresenter = class {
|
|
|
426
496
|
return false;
|
|
427
497
|
case 0 /* Success */:
|
|
428
498
|
delete model.errors[valuePath];
|
|
429
|
-
accessor
|
|
499
|
+
accessor == null ? void 0 : accessor.set(conversion.value);
|
|
430
500
|
return true;
|
|
431
501
|
default:
|
|
432
502
|
throw new UnreachableError2(conversion);
|
|
@@ -570,10 +640,17 @@ var FormPresenter = class {
|
|
|
570
640
|
});
|
|
571
641
|
}
|
|
572
642
|
};
|
|
643
|
+
var _accessors_dec, _knownFields_dec, _fields_dec, _errors_dec, _fieldOverrides_dec, _value_dec, _init, _value, _fieldOverrides, _errors;
|
|
644
|
+
_value_dec = [observable.ref], _fieldOverrides_dec = [observable.shallow], _errors_dec = [observable.shallow], _fields_dec = [computed], _knownFields_dec = [computed], _accessors_dec = [computed];
|
|
573
645
|
var FormModel = class {
|
|
574
646
|
constructor(type, value, adapters) {
|
|
575
647
|
this.type = type;
|
|
576
648
|
this.adapters = adapters;
|
|
649
|
+
__runInitializers(_init, 5, this);
|
|
650
|
+
__privateAdd(this, _value, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
651
|
+
__privateAdd(this, _fieldOverrides, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
652
|
+
__privateAdd(this, _errors, __runInitializers(_init, 16, this, {})), __runInitializers(_init, 19, this);
|
|
653
|
+
__publicField(this, "flattenedTypeDefs");
|
|
577
654
|
this.value = mobxCopy(type, value);
|
|
578
655
|
this.flattenedTypeDefs = flattenTypesOfType(type);
|
|
579
656
|
const conversions = flattenValueTo(
|
|
@@ -600,14 +677,6 @@ var FormModel = class {
|
|
|
600
677
|
return v && [v.value];
|
|
601
678
|
});
|
|
602
679
|
}
|
|
603
|
-
@observable.ref
|
|
604
|
-
accessor value;
|
|
605
|
-
@observable.shallow
|
|
606
|
-
accessor fieldOverrides;
|
|
607
|
-
@observable.shallow
|
|
608
|
-
accessor errors = {};
|
|
609
|
-
flattenedTypeDefs;
|
|
610
|
-
@computed
|
|
611
680
|
get fields() {
|
|
612
681
|
return new Proxy(
|
|
613
682
|
this.knownFields,
|
|
@@ -624,7 +693,6 @@ var FormModel = class {
|
|
|
624
693
|
}
|
|
625
694
|
);
|
|
626
695
|
}
|
|
627
|
-
@computed
|
|
628
696
|
get knownFields() {
|
|
629
697
|
return flattenValueTo(
|
|
630
698
|
this.type,
|
|
@@ -693,7 +761,6 @@ var FormModel = class {
|
|
|
693
761
|
getAccessorForValuePath(valuePath) {
|
|
694
762
|
return this.accessors[valuePath];
|
|
695
763
|
}
|
|
696
|
-
@computed
|
|
697
764
|
// should only be referenced internally, so loosely typed
|
|
698
765
|
get accessors() {
|
|
699
766
|
return flattenAccessorsOfType(
|
|
@@ -705,6 +772,17 @@ var FormModel = class {
|
|
|
705
772
|
);
|
|
706
773
|
}
|
|
707
774
|
};
|
|
775
|
+
_init = __decoratorStart(null);
|
|
776
|
+
_value = new WeakMap();
|
|
777
|
+
_fieldOverrides = new WeakMap();
|
|
778
|
+
_errors = new WeakMap();
|
|
779
|
+
__decorateElement(_init, 4, "value", _value_dec, FormModel, _value);
|
|
780
|
+
__decorateElement(_init, 4, "fieldOverrides", _fieldOverrides_dec, FormModel, _fieldOverrides);
|
|
781
|
+
__decorateElement(_init, 4, "errors", _errors_dec, FormModel, _errors);
|
|
782
|
+
__decorateElement(_init, 2, "fields", _fields_dec, FormModel);
|
|
783
|
+
__decorateElement(_init, 2, "knownFields", _knownFields_dec, FormModel);
|
|
784
|
+
__decorateElement(_init, 2, "accessors", _accessors_dec, FormModel);
|
|
785
|
+
__decoratorMetadata(_init, FormModel);
|
|
708
786
|
|
|
709
787
|
// core/mobx/hooks.tsx
|
|
710
788
|
import {
|
|
@@ -725,11 +803,9 @@ function createSimplePartialComponent(Component, curriedProps) {
|
|
|
725
803
|
const C = Component;
|
|
726
804
|
return /* @__PURE__ */ jsx(
|
|
727
805
|
C,
|
|
728
|
-
{
|
|
729
|
-
ref
|
|
730
|
-
|
|
731
|
-
...exposedProps
|
|
732
|
-
}
|
|
806
|
+
__spreadValues(__spreadValues({
|
|
807
|
+
ref
|
|
808
|
+
}, curriedProps), exposedProps)
|
|
733
809
|
);
|
|
734
810
|
}
|
|
735
811
|
);
|
|
@@ -761,17 +837,15 @@ function createPartialComponent(Component, curriedPropsSource, additionalPropKey
|
|
|
761
837
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
762
838
|
{},
|
|
763
839
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
764
|
-
{
|
|
840
|
+
__spreadValues({}, props)
|
|
765
841
|
]
|
|
766
842
|
);
|
|
767
843
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
768
844
|
return /* @__PURE__ */ jsx(
|
|
769
845
|
C,
|
|
770
|
-
{
|
|
771
|
-
ref
|
|
772
|
-
|
|
773
|
-
...exposedProps
|
|
774
|
-
}
|
|
846
|
+
__spreadValues(__spreadValues({
|
|
847
|
+
ref
|
|
848
|
+
}, curriedProps), exposedProps)
|
|
775
849
|
);
|
|
776
850
|
}
|
|
777
851
|
);
|
|
@@ -830,17 +904,15 @@ function createUnsafePartialObserverComponent(Component, curriedPropsSource, add
|
|
|
830
904
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
831
905
|
{},
|
|
832
906
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
833
|
-
{
|
|
907
|
+
__spreadValues({}, props)
|
|
834
908
|
]
|
|
835
909
|
);
|
|
836
910
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
837
911
|
return /* @__PURE__ */ jsx(
|
|
838
912
|
C,
|
|
839
|
-
{
|
|
840
|
-
ref
|
|
841
|
-
|
|
842
|
-
...exposedProps
|
|
843
|
-
}
|
|
913
|
+
__spreadValues(__spreadValues({
|
|
914
|
+
ref
|
|
915
|
+
}, curriedProps), exposedProps)
|
|
844
916
|
);
|
|
845
917
|
}
|
|
846
918
|
)
|
|
@@ -891,7 +963,7 @@ function useDefaultMobxFormHooks(presenter, value, {
|
|
|
891
963
|
const onFieldSubmit = useCallback(
|
|
892
964
|
function(valuePath) {
|
|
893
965
|
if (presenter.validateField(model, valuePath)) {
|
|
894
|
-
onValidFieldSubmit
|
|
966
|
+
onValidFieldSubmit == null ? void 0 : onValidFieldSubmit(model, valuePath);
|
|
895
967
|
}
|
|
896
968
|
return false;
|
|
897
969
|
},
|
|
@@ -917,7 +989,7 @@ function useDefaultMobxFormHooks(presenter, value, {
|
|
|
917
989
|
const onFormSubmit = useCallback(
|
|
918
990
|
function() {
|
|
919
991
|
if (presenter.validateAll(model)) {
|
|
920
|
-
onValidFormSubmit
|
|
992
|
+
onValidFormSubmit == null ? void 0 : onValidFormSubmit(model, model.value);
|
|
921
993
|
}
|
|
922
994
|
},
|
|
923
995
|
[
|
|
@@ -1023,11 +1095,10 @@ function mergeAdaptersWithValidators(adapters, validators) {
|
|
|
1023
1095
|
readonly: readonly1 || readonly2
|
|
1024
1096
|
};
|
|
1025
1097
|
}
|
|
1026
|
-
acc[key] = {
|
|
1027
|
-
...adapter2,
|
|
1098
|
+
acc[key] = __spreadProps(__spreadValues({}, adapter2), {
|
|
1028
1099
|
convert,
|
|
1029
1100
|
revert: adapter2.revert && revert
|
|
1030
|
-
};
|
|
1101
|
+
});
|
|
1031
1102
|
return acc;
|
|
1032
1103
|
},
|
|
1033
1104
|
{}
|
|
@@ -1110,9 +1181,9 @@ var NullableToBooleanConverter = class {
|
|
|
1110
1181
|
this.typeDef = typeDef;
|
|
1111
1182
|
this.prototype = prototype;
|
|
1112
1183
|
this.nullType = nullType;
|
|
1184
|
+
__publicField(this, "defaultValue");
|
|
1113
1185
|
this.defaultValue = defaultToNull ? this.nullType : prototype;
|
|
1114
1186
|
}
|
|
1115
|
-
defaultValue;
|
|
1116
1187
|
convert(from) {
|
|
1117
1188
|
return {
|
|
1118
1189
|
value: from !== this.nullType,
|
|
@@ -1295,17 +1366,21 @@ import {
|
|
|
1295
1366
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1296
1367
|
function createCheckbox(valuePath, Checkbox) {
|
|
1297
1368
|
const onChange = (e) => {
|
|
1298
|
-
|
|
1369
|
+
var _a;
|
|
1370
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.checked);
|
|
1299
1371
|
};
|
|
1300
1372
|
const onFocus = () => {
|
|
1301
|
-
|
|
1373
|
+
var _a;
|
|
1374
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1302
1375
|
};
|
|
1303
1376
|
const onBlur = () => {
|
|
1304
|
-
|
|
1377
|
+
var _a;
|
|
1378
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1305
1379
|
};
|
|
1306
1380
|
const onKeyUp = (e) => {
|
|
1381
|
+
var _a;
|
|
1307
1382
|
if (e.key === "Enter") {
|
|
1308
|
-
if (this.onFieldSubmit
|
|
1383
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1309
1384
|
e.preventDefault();
|
|
1310
1385
|
}
|
|
1311
1386
|
}
|
|
@@ -1353,13 +1428,16 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1353
1428
|
observableProps.onFieldValueChange(toKey(subKey), value);
|
|
1354
1429
|
}
|
|
1355
1430
|
function onFieldBlur(subKey) {
|
|
1356
|
-
|
|
1431
|
+
var _a;
|
|
1432
|
+
(_a = observableProps.onFieldBlur) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1357
1433
|
}
|
|
1358
1434
|
function onFieldFocus(subKey) {
|
|
1359
|
-
|
|
1435
|
+
var _a;
|
|
1436
|
+
(_a = observableProps.onFieldFocus) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1360
1437
|
}
|
|
1361
1438
|
function onFieldSubmit(subKey) {
|
|
1362
|
-
|
|
1439
|
+
var _a;
|
|
1440
|
+
(_a = observableProps.onFieldSubmit) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1363
1441
|
}
|
|
1364
1442
|
const Component = observer2(
|
|
1365
1443
|
function(props) {
|
|
@@ -1378,16 +1456,13 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1378
1456
|
);
|
|
1379
1457
|
return /* @__PURE__ */ jsx3(
|
|
1380
1458
|
FieldsView,
|
|
1381
|
-
{
|
|
1382
|
-
// maybe we can do this in a more type safe way
|
|
1383
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
1384
|
-
...props,
|
|
1459
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1385
1460
|
fields: subFields,
|
|
1386
1461
|
onFieldBlur,
|
|
1387
1462
|
onFieldFocus,
|
|
1388
1463
|
onFieldSubmit,
|
|
1389
1464
|
onFieldValueChange
|
|
1390
|
-
}
|
|
1465
|
+
})
|
|
1391
1466
|
);
|
|
1392
1467
|
}
|
|
1393
1468
|
);
|
|
@@ -1417,13 +1492,10 @@ function createForm(valuePath, Form, observableProps) {
|
|
|
1417
1492
|
}, []);
|
|
1418
1493
|
return /* @__PURE__ */ jsx4(
|
|
1419
1494
|
Form,
|
|
1420
|
-
{
|
|
1421
|
-
// maybe we can do this in a more type safe way
|
|
1422
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
1423
|
-
...props,
|
|
1495
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1424
1496
|
onValueChange,
|
|
1425
1497
|
value
|
|
1426
|
-
}
|
|
1498
|
+
})
|
|
1427
1499
|
);
|
|
1428
1500
|
});
|
|
1429
1501
|
}
|
|
@@ -1487,17 +1559,21 @@ function createRadio(valuePath, value, Radio) {
|
|
|
1487
1559
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1488
1560
|
function createRadioGroup(valuePath, RadioGroup) {
|
|
1489
1561
|
const onChange = (value) => {
|
|
1490
|
-
|
|
1562
|
+
var _a;
|
|
1563
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
|
|
1491
1564
|
};
|
|
1492
1565
|
const onFocus = () => {
|
|
1493
|
-
|
|
1566
|
+
var _a;
|
|
1567
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1494
1568
|
};
|
|
1495
1569
|
const onBlur = () => {
|
|
1496
|
-
|
|
1570
|
+
var _a;
|
|
1571
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1497
1572
|
};
|
|
1498
1573
|
const onKeyUp = (e) => {
|
|
1574
|
+
var _a;
|
|
1499
1575
|
if (e.key === "Enter") {
|
|
1500
|
-
if (this.onFieldSubmit
|
|
1576
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1501
1577
|
e.preventDefault();
|
|
1502
1578
|
}
|
|
1503
1579
|
}
|
|
@@ -1526,17 +1602,21 @@ function createRadioGroup(valuePath, RadioGroup) {
|
|
|
1526
1602
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1527
1603
|
function createTextInput(valuePath, TextInput) {
|
|
1528
1604
|
const onChange = (e) => {
|
|
1529
|
-
|
|
1605
|
+
var _a;
|
|
1606
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.value);
|
|
1530
1607
|
};
|
|
1531
1608
|
const onFocus = () => {
|
|
1532
|
-
|
|
1609
|
+
var _a;
|
|
1610
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1533
1611
|
};
|
|
1534
1612
|
const onBlur = () => {
|
|
1535
|
-
|
|
1613
|
+
var _a;
|
|
1614
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1536
1615
|
};
|
|
1537
1616
|
const onKeyUp = (e) => {
|
|
1617
|
+
var _a;
|
|
1538
1618
|
if (e.key === "Enter") {
|
|
1539
|
-
if (this.onFieldSubmit
|
|
1619
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1540
1620
|
e.preventDefault();
|
|
1541
1621
|
}
|
|
1542
1622
|
}
|
|
@@ -1578,17 +1658,21 @@ function createTextInput(valuePath, TextInput) {
|
|
|
1578
1658
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1579
1659
|
function createValueInput(valuePath, ValueInput) {
|
|
1580
1660
|
const onChange = (value) => {
|
|
1581
|
-
|
|
1661
|
+
var _a;
|
|
1662
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
|
|
1582
1663
|
};
|
|
1583
1664
|
const onFocus = () => {
|
|
1584
|
-
|
|
1665
|
+
var _a;
|
|
1666
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1585
1667
|
};
|
|
1586
1668
|
const onBlur = () => {
|
|
1587
|
-
|
|
1669
|
+
var _a;
|
|
1670
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1588
1671
|
};
|
|
1589
1672
|
const onKeyUp = (e) => {
|
|
1673
|
+
var _a;
|
|
1590
1674
|
if (e.key === "Enter") {
|
|
1591
|
-
if (this.onFieldSubmit
|
|
1675
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1592
1676
|
e.preventDefault();
|
|
1593
1677
|
}
|
|
1594
1678
|
}
|
|
@@ -1626,7 +1710,7 @@ function createValueInput(valuePath, ValueInput) {
|
|
|
1626
1710
|
// mantine/hooks.tsx
|
|
1627
1711
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1628
1712
|
function SimpleSelect(props) {
|
|
1629
|
-
return /* @__PURE__ */ jsx9(Select, {
|
|
1713
|
+
return /* @__PURE__ */ jsx9(Select, __spreadValues({}, props));
|
|
1630
1714
|
}
|
|
1631
1715
|
function useMantineFormFields({
|
|
1632
1716
|
onFieldValueChange,
|
|
@@ -1677,39 +1761,40 @@ function useMantineFormFields({
|
|
|
1677
1761
|
]);
|
|
1678
1762
|
return form;
|
|
1679
1763
|
}
|
|
1764
|
+
var _fields_dec2, _init2, _fields;
|
|
1765
|
+
_fields_dec2 = [observable2.ref];
|
|
1680
1766
|
var MantineFormImpl = class {
|
|
1681
|
-
textInputCache = new Cache(
|
|
1682
|
-
createTextInput.bind(this)
|
|
1683
|
-
);
|
|
1684
|
-
valueInputCache = new Cache(
|
|
1685
|
-
createValueInput.bind(this)
|
|
1686
|
-
);
|
|
1687
|
-
checkboxCache = new Cache(
|
|
1688
|
-
createCheckbox.bind(this)
|
|
1689
|
-
);
|
|
1690
|
-
radioGroupCache = new Cache(
|
|
1691
|
-
createRadioGroup.bind(this)
|
|
1692
|
-
);
|
|
1693
|
-
radioCache = new Cache(
|
|
1694
|
-
createRadio.bind(this)
|
|
1695
|
-
);
|
|
1696
|
-
pillCache = new Cache(
|
|
1697
|
-
createPill.bind(this)
|
|
1698
|
-
);
|
|
1699
|
-
listCache = new Cache(
|
|
1700
|
-
createList.bind(this)
|
|
1701
|
-
);
|
|
1702
|
-
fieldsViewCache = new Cache(
|
|
1703
|
-
createFieldsView.bind(this)
|
|
1704
|
-
);
|
|
1705
|
-
formCache = new Cache(createForm.bind(this));
|
|
1706
|
-
@observable2.ref
|
|
1707
|
-
accessor fields;
|
|
1708
|
-
onFieldValueChange;
|
|
1709
|
-
onFieldFocus;
|
|
1710
|
-
onFieldBlur;
|
|
1711
|
-
onFieldSubmit;
|
|
1712
1767
|
constructor(fields) {
|
|
1768
|
+
__publicField(this, "textInputCache", new Cache(
|
|
1769
|
+
createTextInput.bind(this)
|
|
1770
|
+
));
|
|
1771
|
+
__publicField(this, "valueInputCache", new Cache(
|
|
1772
|
+
createValueInput.bind(this)
|
|
1773
|
+
));
|
|
1774
|
+
__publicField(this, "checkboxCache", new Cache(
|
|
1775
|
+
createCheckbox.bind(this)
|
|
1776
|
+
));
|
|
1777
|
+
__publicField(this, "radioGroupCache", new Cache(
|
|
1778
|
+
createRadioGroup.bind(this)
|
|
1779
|
+
));
|
|
1780
|
+
__publicField(this, "radioCache", new Cache(
|
|
1781
|
+
createRadio.bind(this)
|
|
1782
|
+
));
|
|
1783
|
+
__publicField(this, "pillCache", new Cache(
|
|
1784
|
+
createPill.bind(this)
|
|
1785
|
+
));
|
|
1786
|
+
__publicField(this, "listCache", new Cache(
|
|
1787
|
+
createList.bind(this)
|
|
1788
|
+
));
|
|
1789
|
+
__publicField(this, "fieldsViewCache", new Cache(
|
|
1790
|
+
createFieldsView.bind(this)
|
|
1791
|
+
));
|
|
1792
|
+
__publicField(this, "formCache", new Cache(createForm.bind(this)));
|
|
1793
|
+
__privateAdd(this, _fields, __runInitializers(_init2, 8, this)), __runInitializers(_init2, 11, this);
|
|
1794
|
+
__publicField(this, "onFieldValueChange");
|
|
1795
|
+
__publicField(this, "onFieldFocus");
|
|
1796
|
+
__publicField(this, "onFieldBlur");
|
|
1797
|
+
__publicField(this, "onFieldSubmit");
|
|
1713
1798
|
this.fields = fields;
|
|
1714
1799
|
}
|
|
1715
1800
|
textInput(valuePath, TextInput = TextInputImpl) {
|
|
@@ -1787,6 +1872,10 @@ var MantineFormImpl = class {
|
|
|
1787
1872
|
);
|
|
1788
1873
|
}
|
|
1789
1874
|
};
|
|
1875
|
+
_init2 = __decoratorStart(null);
|
|
1876
|
+
_fields = new WeakMap();
|
|
1877
|
+
__decorateElement(_init2, 4, "fields", _fields_dec2, MantineFormImpl, _fields);
|
|
1878
|
+
__decoratorMetadata(_init2, MantineFormImpl);
|
|
1790
1879
|
|
|
1791
1880
|
// types/merge_validators.ts
|
|
1792
1881
|
import {
|
|
@@ -1794,10 +1883,7 @@ import {
|
|
|
1794
1883
|
validate as validate3
|
|
1795
1884
|
} from "@strictly/define";
|
|
1796
1885
|
function mergeValidators(validators1, validators2) {
|
|
1797
|
-
const validators = {
|
|
1798
|
-
...validators1,
|
|
1799
|
-
...validators2
|
|
1800
|
-
};
|
|
1886
|
+
const validators = __spreadValues(__spreadValues({}, validators1), validators2);
|
|
1801
1887
|
const keys1 = new Set(Object.keys(validators1));
|
|
1802
1888
|
const keys2 = new Set(Object.keys(validators2));
|
|
1803
1889
|
return Array.from(keys1.intersection(keys2)).reduce(
|