@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/.out/tsup.config.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { defineConfig, } from 'tsup';
|
|
2
|
-
export default defineConfig((options) => ({
|
|
3
|
-
entry: ['index.ts'],
|
|
4
|
-
tsconfig: './tsconfig.build.json',
|
|
5
|
-
clean: false,
|
|
6
|
-
dts: true,
|
|
7
|
-
format: [
|
|
2
|
+
export default defineConfig((options) => (Object.assign({ entry: ['index.ts'], tsconfig: './tsconfig.build.json', clean: false, dts: true, format: [
|
|
8
3
|
'cjs',
|
|
9
4
|
'esm',
|
|
10
|
-
],
|
|
11
|
-
...options,
|
|
12
|
-
}));
|
|
5
|
+
] }, options)));
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { annotations, validate, } from '@strictly/define';
|
|
2
2
|
export function mergeValidators(validators1, validators2) {
|
|
3
|
-
const validators = {
|
|
4
|
-
...validators1,
|
|
5
|
-
...validators2,
|
|
6
|
-
};
|
|
3
|
+
const validators = Object.assign(Object.assign({}, validators1), validators2);
|
|
7
4
|
const keys1 = new Set(Object.keys(validators1));
|
|
8
5
|
const keys2 = new Set(Object.keys(validators2));
|
|
9
6
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
package/.out/util/partial.js
CHANGED
|
@@ -8,7 +8,7 @@ export function createSimplePartialComponent(Component, curriedProps) {
|
|
|
8
8
|
// still needs a cast as `extends ComponentType<any>` != `ComponentType<any>`
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unnecessary-type-assertion
|
|
10
10
|
const C = Component;
|
|
11
|
-
return (_jsx(C, { ref: ref,
|
|
11
|
+
return (_jsx(C, Object.assign({ ref: ref }, curriedProps, exposedProps)));
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
export function createPartialComponent(Component, curriedPropsSource, additionalPropKeys = []) {
|
|
@@ -34,11 +34,11 @@ export function createPartialComponent(Component, curriedPropsSource, additional
|
|
|
34
34
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
35
35
|
{},
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
37
|
-
{
|
|
37
|
+
Object.assign({}, props),
|
|
38
38
|
]);
|
|
39
39
|
// TODO is there any way we can memoize this transformation?
|
|
40
40
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
41
|
-
return (_jsx(C, { ref: ref,
|
|
41
|
+
return (_jsx(C, Object.assign({ ref: ref }, curriedProps, exposedProps)));
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
export function usePartialComponent(
|
|
@@ -88,11 +88,11 @@ export function createUnsafePartialObserverComponent(Component, curriedPropsSour
|
|
|
88
88
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
89
89
|
{},
|
|
90
90
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
91
|
-
{
|
|
91
|
+
Object.assign({}, props),
|
|
92
92
|
]);
|
|
93
93
|
// TODO is there any way we can memoize this transformation?
|
|
94
94
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
95
|
-
return (_jsx(C, { ref: ref,
|
|
95
|
+
return (_jsx(C, Object.assign({ ref: ref }, curriedProps, exposedProps)));
|
|
96
96
|
}));
|
|
97
97
|
}
|
|
98
98
|
export function usePartialObserverComponent(
|
package/.out/vitest.workspace.js
CHANGED
|
@@ -4,19 +4,11 @@ import tsconfig from './tsconfig.json';
|
|
|
4
4
|
const config = createVitestUserConfig(tsconfig);
|
|
5
5
|
export default defineWorkspace([
|
|
6
6
|
'.',
|
|
7
|
-
{
|
|
8
|
-
...config,
|
|
9
|
-
extends: './.storybook/vite.config.mts',
|
|
10
|
-
test: {
|
|
11
|
-
...(config.test || {}),
|
|
12
|
-
environment: 'jsdom',
|
|
13
|
-
setupFiles: [
|
|
7
|
+
Object.assign(Object.assign({}, config), { extends: './.storybook/vite.config.mts', test: Object.assign(Object.assign({}, (config.test || {})), { environment: 'jsdom', setupFiles: [
|
|
14
8
|
'./.vitest/install_deterministic_random.ts',
|
|
15
9
|
// install storybook setup for unit tests that import stories directly
|
|
16
10
|
'./.vitest/install_storybook_preview.ts',
|
|
17
11
|
'./.vitest/match_media.ts',
|
|
18
12
|
'./.vitest/resize_observer.ts',
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
13
|
+
] }) }),
|
|
22
14
|
]);
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,15 +4,15 @@ $ tsup
|
|
|
4
4
|
[34mCLI[39m Using tsconfig: tsconfig.build.json
|
|
5
5
|
[34mCLI[39m tsup v8.3.5
|
|
6
6
|
[34mCLI[39m Using tsup config: /home/runner/work/strictly/strictly/packages/react-form/tsup.config.ts
|
|
7
|
-
[34mCLI[39m Target:
|
|
7
|
+
[34mCLI[39m Target: es6
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m56.04 KB[39m
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 111ms
|
|
12
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m59.85 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 113ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
15
|
+
[32mDTS[39m ⚡️ Build success in 9897ms
|
|
16
16
|
[32mDTS[39m [1mdist/index.d.cts [22m[32m39.16 KB[39m
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m39.16 KB[39m
|
|
18
|
-
Done in
|
|
18
|
+
Done in 10.95s.
|
package/core/mobx/hooks.tsx
CHANGED
|
@@ -61,6 +61,7 @@ export function useDefaultMobxFormHooks<
|
|
|
61
61
|
options: {
|
|
62
62
|
onValidFieldSubmit?: <Path extends ValuePathsOfPresenter<P>>(model: ModelOfPresenter<P>, valuePath: Path) => void,
|
|
63
63
|
onValidFormSubmit?: (model: ModelOfPresenter<P>, value: ValueOfPresenter<P>) => void,
|
|
64
|
+
// TODO the types of C are not working, needs a local implementation to test
|
|
64
65
|
FormFieldsView: C,
|
|
65
66
|
},
|
|
66
67
|
): {
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
12
|
+
var __typeError = (msg) => {
|
|
13
|
+
throw TypeError(msg);
|
|
14
|
+
};
|
|
15
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
29
|
var __export = (target, all) => {
|
|
7
30
|
for (var name in all)
|
|
8
31
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,6 +39,49 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
39
|
return to;
|
|
17
40
|
};
|
|
18
41
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
|
+
var __decoratorStart = (base) => {
|
|
43
|
+
var _a;
|
|
44
|
+
return [, , , __create((_a = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a : null)];
|
|
45
|
+
};
|
|
46
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
47
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
48
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
49
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
50
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
51
|
+
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);
|
|
52
|
+
return value;
|
|
53
|
+
};
|
|
54
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
55
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
56
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
57
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
58
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
59
|
+
return __privateGet(this, extra);
|
|
60
|
+
}, set [name](x) {
|
|
61
|
+
return __privateSet(this, extra, x);
|
|
62
|
+
} }, name));
|
|
63
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
64
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
65
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
66
|
+
if (k) {
|
|
67
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
68
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
69
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
70
|
+
}
|
|
71
|
+
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;
|
|
72
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
73
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
74
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
75
|
+
}
|
|
76
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
77
|
+
};
|
|
78
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
79
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
80
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
81
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
82
|
+
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);
|
|
83
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
84
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
19
85
|
|
|
20
86
|
// index.ts
|
|
21
87
|
var index_exports = {};
|
|
@@ -319,7 +385,7 @@ var FormPresenter = class {
|
|
|
319
385
|
const listValuePath = valuePath;
|
|
320
386
|
const accessor = model.accessors[valuePath];
|
|
321
387
|
const listTypePath = this.typePath(valuePath);
|
|
322
|
-
const definedIndex = index
|
|
388
|
+
const definedIndex = index != null ? index : accessor.value.length;
|
|
323
389
|
const elementTypePath = `${listTypePath}.*`;
|
|
324
390
|
const elementAdapter = (0, import_base2.assertExistsAndReturn)(
|
|
325
391
|
this.adapters[elementTypePath],
|
|
@@ -460,7 +526,7 @@ var FormPresenter = class {
|
|
|
460
526
|
return false;
|
|
461
527
|
case 0 /* Success */:
|
|
462
528
|
delete model.errors[valuePath];
|
|
463
|
-
accessor
|
|
529
|
+
accessor == null ? void 0 : accessor.set(conversion.value);
|
|
464
530
|
return true;
|
|
465
531
|
default:
|
|
466
532
|
throw new import_base2.UnreachableError(conversion);
|
|
@@ -604,10 +670,17 @@ var FormPresenter = class {
|
|
|
604
670
|
});
|
|
605
671
|
}
|
|
606
672
|
};
|
|
673
|
+
var _accessors_dec, _knownFields_dec, _fields_dec, _errors_dec, _fieldOverrides_dec, _value_dec, _init, _value, _fieldOverrides, _errors;
|
|
674
|
+
_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];
|
|
607
675
|
var FormModel = class {
|
|
608
676
|
constructor(type, value, adapters) {
|
|
609
677
|
this.type = type;
|
|
610
678
|
this.adapters = adapters;
|
|
679
|
+
__runInitializers(_init, 5, this);
|
|
680
|
+
__privateAdd(this, _value, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
681
|
+
__privateAdd(this, _fieldOverrides, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
682
|
+
__privateAdd(this, _errors, __runInitializers(_init, 16, this, {})), __runInitializers(_init, 19, this);
|
|
683
|
+
__publicField(this, "flattenedTypeDefs");
|
|
611
684
|
this.value = (0, import_define.mobxCopy)(type, value);
|
|
612
685
|
this.flattenedTypeDefs = (0, import_define.flattenTypesOfType)(type);
|
|
613
686
|
const conversions = (0, import_define.flattenValueTo)(
|
|
@@ -634,14 +707,6 @@ var FormModel = class {
|
|
|
634
707
|
return v && [v.value];
|
|
635
708
|
});
|
|
636
709
|
}
|
|
637
|
-
@import_mobx.observable.ref
|
|
638
|
-
accessor value;
|
|
639
|
-
@import_mobx.observable.shallow
|
|
640
|
-
accessor fieldOverrides;
|
|
641
|
-
@import_mobx.observable.shallow
|
|
642
|
-
accessor errors = {};
|
|
643
|
-
flattenedTypeDefs;
|
|
644
|
-
@import_mobx.computed
|
|
645
710
|
get fields() {
|
|
646
711
|
return new Proxy(
|
|
647
712
|
this.knownFields,
|
|
@@ -658,7 +723,6 @@ var FormModel = class {
|
|
|
658
723
|
}
|
|
659
724
|
);
|
|
660
725
|
}
|
|
661
|
-
@import_mobx.computed
|
|
662
726
|
get knownFields() {
|
|
663
727
|
return (0, import_define.flattenValueTo)(
|
|
664
728
|
this.type,
|
|
@@ -727,7 +791,6 @@ var FormModel = class {
|
|
|
727
791
|
getAccessorForValuePath(valuePath) {
|
|
728
792
|
return this.accessors[valuePath];
|
|
729
793
|
}
|
|
730
|
-
@import_mobx.computed
|
|
731
794
|
// should only be referenced internally, so loosely typed
|
|
732
795
|
get accessors() {
|
|
733
796
|
return (0, import_define.flattenAccessorsOfType)(
|
|
@@ -739,6 +802,17 @@ var FormModel = class {
|
|
|
739
802
|
);
|
|
740
803
|
}
|
|
741
804
|
};
|
|
805
|
+
_init = __decoratorStart(null);
|
|
806
|
+
_value = new WeakMap();
|
|
807
|
+
_fieldOverrides = new WeakMap();
|
|
808
|
+
_errors = new WeakMap();
|
|
809
|
+
__decorateElement(_init, 4, "value", _value_dec, FormModel, _value);
|
|
810
|
+
__decorateElement(_init, 4, "fieldOverrides", _fieldOverrides_dec, FormModel, _fieldOverrides);
|
|
811
|
+
__decorateElement(_init, 4, "errors", _errors_dec, FormModel, _errors);
|
|
812
|
+
__decorateElement(_init, 2, "fields", _fields_dec, FormModel);
|
|
813
|
+
__decorateElement(_init, 2, "knownFields", _knownFields_dec, FormModel);
|
|
814
|
+
__decorateElement(_init, 2, "accessors", _accessors_dec, FormModel);
|
|
815
|
+
__decoratorMetadata(_init, FormModel);
|
|
742
816
|
|
|
743
817
|
// core/mobx/hooks.tsx
|
|
744
818
|
var import_react2 = require("react");
|
|
@@ -753,11 +827,9 @@ function createSimplePartialComponent(Component, curriedProps) {
|
|
|
753
827
|
const C = Component;
|
|
754
828
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
755
829
|
C,
|
|
756
|
-
{
|
|
757
|
-
ref
|
|
758
|
-
|
|
759
|
-
...exposedProps
|
|
760
|
-
}
|
|
830
|
+
__spreadValues(__spreadValues({
|
|
831
|
+
ref
|
|
832
|
+
}, curriedProps), exposedProps)
|
|
761
833
|
);
|
|
762
834
|
}
|
|
763
835
|
);
|
|
@@ -789,17 +861,15 @@ function createPartialComponent(Component, curriedPropsSource, additionalPropKey
|
|
|
789
861
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
790
862
|
{},
|
|
791
863
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
792
|
-
{
|
|
864
|
+
__spreadValues({}, props)
|
|
793
865
|
]
|
|
794
866
|
);
|
|
795
867
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
796
868
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
797
869
|
C,
|
|
798
|
-
{
|
|
799
|
-
ref
|
|
800
|
-
|
|
801
|
-
...exposedProps
|
|
802
|
-
}
|
|
870
|
+
__spreadValues(__spreadValues({
|
|
871
|
+
ref
|
|
872
|
+
}, curriedProps), exposedProps)
|
|
803
873
|
);
|
|
804
874
|
}
|
|
805
875
|
);
|
|
@@ -858,17 +928,15 @@ function createUnsafePartialObserverComponent(Component, curriedPropsSource, add
|
|
|
858
928
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
859
929
|
{},
|
|
860
930
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
861
|
-
{
|
|
931
|
+
__spreadValues({}, props)
|
|
862
932
|
]
|
|
863
933
|
);
|
|
864
934
|
const curriedProps = curriedPropsSource(additionalProps);
|
|
865
935
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
866
936
|
C,
|
|
867
|
-
{
|
|
868
|
-
ref
|
|
869
|
-
|
|
870
|
-
...exposedProps
|
|
871
|
-
}
|
|
937
|
+
__spreadValues(__spreadValues({
|
|
938
|
+
ref
|
|
939
|
+
}, curriedProps), exposedProps)
|
|
872
940
|
);
|
|
873
941
|
}
|
|
874
942
|
)
|
|
@@ -919,7 +987,7 @@ function useDefaultMobxFormHooks(presenter, value, {
|
|
|
919
987
|
const onFieldSubmit = (0, import_react2.useCallback)(
|
|
920
988
|
function(valuePath) {
|
|
921
989
|
if (presenter.validateField(model, valuePath)) {
|
|
922
|
-
onValidFieldSubmit
|
|
990
|
+
onValidFieldSubmit == null ? void 0 : onValidFieldSubmit(model, valuePath);
|
|
923
991
|
}
|
|
924
992
|
return false;
|
|
925
993
|
},
|
|
@@ -945,7 +1013,7 @@ function useDefaultMobxFormHooks(presenter, value, {
|
|
|
945
1013
|
const onFormSubmit = (0, import_react2.useCallback)(
|
|
946
1014
|
function() {
|
|
947
1015
|
if (presenter.validateAll(model)) {
|
|
948
|
-
onValidFormSubmit
|
|
1016
|
+
onValidFormSubmit == null ? void 0 : onValidFormSubmit(model, model.value);
|
|
949
1017
|
}
|
|
950
1018
|
},
|
|
951
1019
|
[
|
|
@@ -1048,11 +1116,10 @@ function mergeAdaptersWithValidators(adapters, validators) {
|
|
|
1048
1116
|
readonly: readonly1 || readonly2
|
|
1049
1117
|
};
|
|
1050
1118
|
}
|
|
1051
|
-
acc[key] = {
|
|
1052
|
-
...adapter2,
|
|
1119
|
+
acc[key] = __spreadProps(__spreadValues({}, adapter2), {
|
|
1053
1120
|
convert,
|
|
1054
1121
|
revert: adapter2.revert && revert
|
|
1055
|
-
};
|
|
1122
|
+
});
|
|
1056
1123
|
return acc;
|
|
1057
1124
|
},
|
|
1058
1125
|
{}
|
|
@@ -1131,9 +1198,9 @@ var NullableToBooleanConverter = class {
|
|
|
1131
1198
|
this.typeDef = typeDef;
|
|
1132
1199
|
this.prototype = prototype;
|
|
1133
1200
|
this.nullType = nullType;
|
|
1201
|
+
__publicField(this, "defaultValue");
|
|
1134
1202
|
this.defaultValue = defaultToNull ? this.nullType : prototype;
|
|
1135
1203
|
}
|
|
1136
|
-
defaultValue;
|
|
1137
1204
|
convert(from) {
|
|
1138
1205
|
return {
|
|
1139
1206
|
value: from !== this.nullType,
|
|
@@ -1296,17 +1363,21 @@ var import_react4 = require("react");
|
|
|
1296
1363
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1297
1364
|
function createCheckbox(valuePath, Checkbox) {
|
|
1298
1365
|
const onChange = (e) => {
|
|
1299
|
-
|
|
1366
|
+
var _a;
|
|
1367
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.checked);
|
|
1300
1368
|
};
|
|
1301
1369
|
const onFocus = () => {
|
|
1302
|
-
|
|
1370
|
+
var _a;
|
|
1371
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1303
1372
|
};
|
|
1304
1373
|
const onBlur = () => {
|
|
1305
|
-
|
|
1374
|
+
var _a;
|
|
1375
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1306
1376
|
};
|
|
1307
1377
|
const onKeyUp = (e) => {
|
|
1378
|
+
var _a;
|
|
1308
1379
|
if (e.key === "Enter") {
|
|
1309
|
-
if (this.onFieldSubmit
|
|
1380
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1310
1381
|
e.preventDefault();
|
|
1311
1382
|
}
|
|
1312
1383
|
}
|
|
@@ -1354,13 +1425,16 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1354
1425
|
observableProps.onFieldValueChange(toKey(subKey), value);
|
|
1355
1426
|
}
|
|
1356
1427
|
function onFieldBlur(subKey) {
|
|
1357
|
-
|
|
1428
|
+
var _a;
|
|
1429
|
+
(_a = observableProps.onFieldBlur) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1358
1430
|
}
|
|
1359
1431
|
function onFieldFocus(subKey) {
|
|
1360
|
-
|
|
1432
|
+
var _a;
|
|
1433
|
+
(_a = observableProps.onFieldFocus) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1361
1434
|
}
|
|
1362
1435
|
function onFieldSubmit(subKey) {
|
|
1363
|
-
|
|
1436
|
+
var _a;
|
|
1437
|
+
(_a = observableProps.onFieldSubmit) == null ? void 0 : _a.call(observableProps, toKey(subKey));
|
|
1364
1438
|
}
|
|
1365
1439
|
const Component = (0, import_mobx_react2.observer)(
|
|
1366
1440
|
function(props) {
|
|
@@ -1379,16 +1453,13 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
|
|
|
1379
1453
|
);
|
|
1380
1454
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1381
1455
|
FieldsView,
|
|
1382
|
-
{
|
|
1383
|
-
// maybe we can do this in a more type safe way
|
|
1384
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
1385
|
-
...props,
|
|
1456
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1386
1457
|
fields: subFields,
|
|
1387
1458
|
onFieldBlur,
|
|
1388
1459
|
onFieldFocus,
|
|
1389
1460
|
onFieldSubmit,
|
|
1390
1461
|
onFieldValueChange
|
|
1391
|
-
}
|
|
1462
|
+
})
|
|
1392
1463
|
);
|
|
1393
1464
|
}
|
|
1394
1465
|
);
|
|
@@ -1416,13 +1487,10 @@ function createForm(valuePath, Form, observableProps) {
|
|
|
1416
1487
|
}, []);
|
|
1417
1488
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1418
1489
|
Form,
|
|
1419
|
-
{
|
|
1420
|
-
// maybe we can do this in a more type safe way
|
|
1421
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
1422
|
-
...props,
|
|
1490
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1423
1491
|
onValueChange,
|
|
1424
1492
|
value
|
|
1425
|
-
}
|
|
1493
|
+
})
|
|
1426
1494
|
);
|
|
1427
1495
|
});
|
|
1428
1496
|
}
|
|
@@ -1486,17 +1554,21 @@ function createRadio(valuePath, value, Radio) {
|
|
|
1486
1554
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1487
1555
|
function createRadioGroup(valuePath, RadioGroup) {
|
|
1488
1556
|
const onChange = (value) => {
|
|
1489
|
-
|
|
1557
|
+
var _a;
|
|
1558
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
|
|
1490
1559
|
};
|
|
1491
1560
|
const onFocus = () => {
|
|
1492
|
-
|
|
1561
|
+
var _a;
|
|
1562
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1493
1563
|
};
|
|
1494
1564
|
const onBlur = () => {
|
|
1495
|
-
|
|
1565
|
+
var _a;
|
|
1566
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1496
1567
|
};
|
|
1497
1568
|
const onKeyUp = (e) => {
|
|
1569
|
+
var _a;
|
|
1498
1570
|
if (e.key === "Enter") {
|
|
1499
|
-
if (this.onFieldSubmit
|
|
1571
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1500
1572
|
e.preventDefault();
|
|
1501
1573
|
}
|
|
1502
1574
|
}
|
|
@@ -1525,17 +1597,21 @@ function createRadioGroup(valuePath, RadioGroup) {
|
|
|
1525
1597
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1526
1598
|
function createTextInput(valuePath, TextInput) {
|
|
1527
1599
|
const onChange = (e) => {
|
|
1528
|
-
|
|
1600
|
+
var _a;
|
|
1601
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.value);
|
|
1529
1602
|
};
|
|
1530
1603
|
const onFocus = () => {
|
|
1531
|
-
|
|
1604
|
+
var _a;
|
|
1605
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1532
1606
|
};
|
|
1533
1607
|
const onBlur = () => {
|
|
1534
|
-
|
|
1608
|
+
var _a;
|
|
1609
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1535
1610
|
};
|
|
1536
1611
|
const onKeyUp = (e) => {
|
|
1612
|
+
var _a;
|
|
1537
1613
|
if (e.key === "Enter") {
|
|
1538
|
-
if (this.onFieldSubmit
|
|
1614
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1539
1615
|
e.preventDefault();
|
|
1540
1616
|
}
|
|
1541
1617
|
}
|
|
@@ -1577,17 +1653,21 @@ function createTextInput(valuePath, TextInput) {
|
|
|
1577
1653
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1578
1654
|
function createValueInput(valuePath, ValueInput) {
|
|
1579
1655
|
const onChange = (value) => {
|
|
1580
|
-
|
|
1656
|
+
var _a;
|
|
1657
|
+
(_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
|
|
1581
1658
|
};
|
|
1582
1659
|
const onFocus = () => {
|
|
1583
|
-
|
|
1660
|
+
var _a;
|
|
1661
|
+
(_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
|
|
1584
1662
|
};
|
|
1585
1663
|
const onBlur = () => {
|
|
1586
|
-
|
|
1664
|
+
var _a;
|
|
1665
|
+
(_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
|
|
1587
1666
|
};
|
|
1588
1667
|
const onKeyUp = (e) => {
|
|
1668
|
+
var _a;
|
|
1589
1669
|
if (e.key === "Enter") {
|
|
1590
|
-
if (this.onFieldSubmit
|
|
1670
|
+
if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
|
|
1591
1671
|
e.preventDefault();
|
|
1592
1672
|
}
|
|
1593
1673
|
}
|
|
@@ -1625,7 +1705,7 @@ function createValueInput(valuePath, ValueInput) {
|
|
|
1625
1705
|
// mantine/hooks.tsx
|
|
1626
1706
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1627
1707
|
function SimpleSelect(props) {
|
|
1628
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core.Select, {
|
|
1708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core.Select, __spreadValues({}, props));
|
|
1629
1709
|
}
|
|
1630
1710
|
function useMantineFormFields({
|
|
1631
1711
|
onFieldValueChange,
|
|
@@ -1676,39 +1756,40 @@ function useMantineFormFields({
|
|
|
1676
1756
|
]);
|
|
1677
1757
|
return form;
|
|
1678
1758
|
}
|
|
1759
|
+
var _fields_dec2, _init2, _fields;
|
|
1760
|
+
_fields_dec2 = [import_mobx2.observable.ref];
|
|
1679
1761
|
var MantineFormImpl = class {
|
|
1680
|
-
textInputCache = new import_base6.Cache(
|
|
1681
|
-
createTextInput.bind(this)
|
|
1682
|
-
);
|
|
1683
|
-
valueInputCache = new import_base6.Cache(
|
|
1684
|
-
createValueInput.bind(this)
|
|
1685
|
-
);
|
|
1686
|
-
checkboxCache = new import_base6.Cache(
|
|
1687
|
-
createCheckbox.bind(this)
|
|
1688
|
-
);
|
|
1689
|
-
radioGroupCache = new import_base6.Cache(
|
|
1690
|
-
createRadioGroup.bind(this)
|
|
1691
|
-
);
|
|
1692
|
-
radioCache = new import_base6.Cache(
|
|
1693
|
-
createRadio.bind(this)
|
|
1694
|
-
);
|
|
1695
|
-
pillCache = new import_base6.Cache(
|
|
1696
|
-
createPill.bind(this)
|
|
1697
|
-
);
|
|
1698
|
-
listCache = new import_base6.Cache(
|
|
1699
|
-
createList.bind(this)
|
|
1700
|
-
);
|
|
1701
|
-
fieldsViewCache = new import_base6.Cache(
|
|
1702
|
-
createFieldsView.bind(this)
|
|
1703
|
-
);
|
|
1704
|
-
formCache = new import_base6.Cache(createForm.bind(this));
|
|
1705
|
-
@import_mobx2.observable.ref
|
|
1706
|
-
accessor fields;
|
|
1707
|
-
onFieldValueChange;
|
|
1708
|
-
onFieldFocus;
|
|
1709
|
-
onFieldBlur;
|
|
1710
|
-
onFieldSubmit;
|
|
1711
1762
|
constructor(fields) {
|
|
1763
|
+
__publicField(this, "textInputCache", new import_base6.Cache(
|
|
1764
|
+
createTextInput.bind(this)
|
|
1765
|
+
));
|
|
1766
|
+
__publicField(this, "valueInputCache", new import_base6.Cache(
|
|
1767
|
+
createValueInput.bind(this)
|
|
1768
|
+
));
|
|
1769
|
+
__publicField(this, "checkboxCache", new import_base6.Cache(
|
|
1770
|
+
createCheckbox.bind(this)
|
|
1771
|
+
));
|
|
1772
|
+
__publicField(this, "radioGroupCache", new import_base6.Cache(
|
|
1773
|
+
createRadioGroup.bind(this)
|
|
1774
|
+
));
|
|
1775
|
+
__publicField(this, "radioCache", new import_base6.Cache(
|
|
1776
|
+
createRadio.bind(this)
|
|
1777
|
+
));
|
|
1778
|
+
__publicField(this, "pillCache", new import_base6.Cache(
|
|
1779
|
+
createPill.bind(this)
|
|
1780
|
+
));
|
|
1781
|
+
__publicField(this, "listCache", new import_base6.Cache(
|
|
1782
|
+
createList.bind(this)
|
|
1783
|
+
));
|
|
1784
|
+
__publicField(this, "fieldsViewCache", new import_base6.Cache(
|
|
1785
|
+
createFieldsView.bind(this)
|
|
1786
|
+
));
|
|
1787
|
+
__publicField(this, "formCache", new import_base6.Cache(createForm.bind(this)));
|
|
1788
|
+
__privateAdd(this, _fields, __runInitializers(_init2, 8, this)), __runInitializers(_init2, 11, this);
|
|
1789
|
+
__publicField(this, "onFieldValueChange");
|
|
1790
|
+
__publicField(this, "onFieldFocus");
|
|
1791
|
+
__publicField(this, "onFieldBlur");
|
|
1792
|
+
__publicField(this, "onFieldSubmit");
|
|
1712
1793
|
this.fields = fields;
|
|
1713
1794
|
}
|
|
1714
1795
|
textInput(valuePath, TextInput = import_core.TextInput) {
|
|
@@ -1786,14 +1867,15 @@ var MantineFormImpl = class {
|
|
|
1786
1867
|
);
|
|
1787
1868
|
}
|
|
1788
1869
|
};
|
|
1870
|
+
_init2 = __decoratorStart(null);
|
|
1871
|
+
_fields = new WeakMap();
|
|
1872
|
+
__decorateElement(_init2, 4, "fields", _fields_dec2, MantineFormImpl, _fields);
|
|
1873
|
+
__decoratorMetadata(_init2, MantineFormImpl);
|
|
1789
1874
|
|
|
1790
1875
|
// types/merge_validators.ts
|
|
1791
1876
|
var import_define7 = require("@strictly/define");
|
|
1792
1877
|
function mergeValidators(validators1, validators2) {
|
|
1793
|
-
const validators = {
|
|
1794
|
-
...validators1,
|
|
1795
|
-
...validators2
|
|
1796
|
-
};
|
|
1878
|
+
const validators = __spreadValues(__spreadValues({}, validators1), validators2);
|
|
1797
1879
|
const keys1 = new Set(Object.keys(validators1));
|
|
1798
1880
|
const keys2 = new Set(Object.keys(validators2));
|
|
1799
1881
|
return Array.from(keys1.intersection(keys2)).reduce(
|