@strictly/react-form 0.0.9 → 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.
Files changed (60) hide show
  1. package/.out/core/mobx/field_adapter_builder.js +18 -6
  2. package/.out/core/mobx/form_presenter.d.ts +5 -5
  3. package/.out/core/mobx/form_presenter.js +232 -127
  4. package/.out/core/mobx/hooks.d.ts +24 -4
  5. package/.out/core/mobx/hooks.js +26 -5
  6. package/.out/core/mobx/merge_field_adapters_with_validators.js +1 -5
  7. package/.out/core/mobx/specs/fixtures.js +2 -1
  8. package/.out/core/mobx/specs/form_presenter.tests.js +16 -8
  9. package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +2 -1
  10. package/.out/core/mobx/sub_form_field_adapters.d.ts +2 -2
  11. package/.out/field_converters/integer_to_string_converter.js +12 -4
  12. package/.out/field_converters/maybe_identity_converter.js +12 -4
  13. package/.out/field_converters/nullable_to_boolean_converter.js +24 -7
  14. package/.out/field_converters/select_value_type_converter.js +36 -12
  15. package/.out/mantine/create_checkbox.js +8 -4
  16. package/.out/mantine/create_fields_view.d.ts +9 -1
  17. package/.out/mantine/create_fields_view.js +20 -5
  18. package/.out/mantine/create_form.js +1 -1
  19. package/.out/mantine/create_radio_group.js +8 -4
  20. package/.out/mantine/create_text_input.js +8 -4
  21. package/.out/mantine/create_value_input.js +8 -4
  22. package/.out/mantine/hooks.d.ts +2 -1
  23. package/.out/mantine/hooks.js +219 -93
  24. package/.out/mantine/specs/checkbox_hooks.stories.js +13 -1
  25. package/.out/mantine/specs/checkbox_hooks.tests.js +22 -9
  26. package/.out/mantine/specs/create_fields_view.tests.d.ts +1 -0
  27. package/.out/mantine/specs/create_fields_view.tests.js +17 -0
  28. package/.out/mantine/specs/fields_view_hooks.stories.d.ts +6 -2
  29. package/.out/mantine/specs/fields_view_hooks.stories.js +39 -7
  30. package/.out/mantine/specs/fields_view_hooks.tests.js +30 -1
  31. package/.out/mantine/specs/radio_group_hooks.stories.js +13 -1
  32. package/.out/mantine/specs/radio_group_hooks.tests.js +23 -10
  33. package/.out/mantine/specs/select_hooks.stories.js +13 -1
  34. package/.out/mantine/specs/text_input_hooks.stories.js +13 -1
  35. package/.out/mantine/specs/text_input_hooks.tests.js +18 -7
  36. package/.out/mantine/specs/value_input_hooks.stories.js +14 -2
  37. package/.out/tsconfig.tsbuildinfo +1 -1
  38. package/.out/tsup.config.js +2 -9
  39. package/.out/types/merge_validators.js +1 -4
  40. package/.out/util/partial.js +5 -5
  41. package/.out/vitest.workspace.js +2 -10
  42. package/.turbo/turbo-build.log +9 -9
  43. package/.turbo/turbo-check-types.log +1 -1
  44. package/.turbo/turbo-release$colon$exports.log +1 -1
  45. package/core/mobx/form_presenter.ts +15 -14
  46. package/core/mobx/hooks.tsx +197 -0
  47. package/core/mobx/specs/form_presenter.tests.ts +24 -5
  48. package/core/mobx/sub_form_field_adapters.ts +14 -3
  49. package/dist/index.cjs +395 -277
  50. package/dist/index.d.cts +52 -26
  51. package/dist/index.d.ts +52 -26
  52. package/dist/index.js +398 -276
  53. package/mantine/create_fields_view.tsx +66 -31
  54. package/mantine/hooks.tsx +9 -6
  55. package/mantine/specs/__snapshots__/fields_view_hooks.tests.tsx.snap +194 -197
  56. package/mantine/specs/create_fields_view.tests.ts +29 -0
  57. package/mantine/specs/fields_view_hooks.stories.tsx +58 -15
  58. package/mantine/specs/fields_view_hooks.tests.tsx +26 -0
  59. package/package.json +1 -1
  60. package/core/mobx/hooks.ts +0 -112
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 ?? accessor.value.length;
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?.set(conversion.value);
529
+ accessor == null ? void 0 : accessor.set(conversion.value);
464
530
  return true;
465
531
  default:
466
532
  throw new import_base2.UnreachableError(conversion);
@@ -485,8 +551,7 @@ var FormPresenter = class {
485
551
  convert,
486
552
  create
487
553
  } = adapter2;
488
- const accessor = model.accessors[valuePath];
489
- const value = accessor == null ? create(valuePath, model.value) : accessor.value;
554
+ const value = create(valuePath, model.value);
490
555
  const {
491
556
  value: displayValue
492
557
  } = convert(value, valuePath, model.value);
@@ -507,7 +572,7 @@ var FormPresenter = class {
507
572
  const keys = new Set(Object.keys(values));
508
573
  return keys.has(valuePath);
509
574
  }
510
- validateField(model, valuePath) {
575
+ validateField(model, valuePath, ignoreDefaultValue = false) {
511
576
  const {
512
577
  convert,
513
578
  revert,
@@ -526,6 +591,14 @@ var FormPresenter = class {
526
591
  const value = fieldOverride != null ? fieldOverride[0] : storedValue;
527
592
  const dirty = storedValue !== value;
528
593
  (0, import_base2.assertExists)(revert, "changing field directly not supported {}", valuePath);
594
+ if (ignoreDefaultValue) {
595
+ const {
596
+ value: defaultDisplayValue
597
+ } = convert(create(valuePath, model.value), valuePath, model.value);
598
+ if (defaultDisplayValue === value) {
599
+ return true;
600
+ }
601
+ }
529
602
  const conversion = revert(value, valuePath, model.value);
530
603
  return (0, import_mobx.runInAction)(function() {
531
604
  switch (conversion.type) {
@@ -596,18 +669,18 @@ var FormPresenter = class {
596
669
  );
597
670
  });
598
671
  }
599
- createModel(value) {
600
- return new FormModel(
601
- this.type,
602
- value,
603
- this.adapters
604
- );
605
- }
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,20 +802,179 @@ 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);
816
+
817
+ // core/mobx/hooks.tsx
818
+ var import_react2 = require("react");
742
819
 
743
- // core/mobx/hooks.ts
820
+ // util/partial.tsx
821
+ var import_mobx_react = require("mobx-react");
744
822
  var import_react = require("react");
823
+ var import_jsx_runtime = require("react/jsx-runtime");
824
+ function createSimplePartialComponent(Component, curriedProps) {
825
+ return (0, import_react.forwardRef)(
826
+ function(exposedProps, ref) {
827
+ const C = Component;
828
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
829
+ C,
830
+ __spreadValues(__spreadValues({
831
+ ref
832
+ }, curriedProps), exposedProps)
833
+ );
834
+ }
835
+ );
836
+ }
837
+ function createPartialComponent(Component, curriedPropsSource, additionalPropKeys = []) {
838
+ return (0, import_react.forwardRef)(
839
+ function(props, ref) {
840
+ const C = Component;
841
+ const [
842
+ additionalProps,
843
+ exposedProps
844
+ ] = additionalPropKeys.reduce(
845
+ function([
846
+ additionalProps2,
847
+ exposedProps2
848
+ ], key) {
849
+ const value = props[
850
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
851
+ key
852
+ ];
853
+ delete exposedProps2[key];
854
+ additionalProps2[key] = value;
855
+ return [
856
+ additionalProps2,
857
+ exposedProps2
858
+ ];
859
+ },
860
+ [
861
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
862
+ {},
863
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
864
+ __spreadValues({}, props)
865
+ ]
866
+ );
867
+ const curriedProps = curriedPropsSource(additionalProps);
868
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
869
+ C,
870
+ __spreadValues(__spreadValues({
871
+ ref
872
+ }, curriedProps), exposedProps)
873
+ );
874
+ }
875
+ );
876
+ }
877
+ function usePartialComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
878
+ return (0, import_react.useMemo)(
879
+ function() {
880
+ return createPartialComponent(
881
+ Component,
882
+ curriedPropsSource,
883
+ additionalPropKeys
884
+ );
885
+ },
886
+ // eslint-disable-next-line react-hooks/exhaustive-deps
887
+ [
888
+ // eslint-disable-next-line react-hooks/exhaustive-deps
889
+ ...deps,
890
+ Component,
891
+ // eslint-disable-next-line react-hooks/exhaustive-deps
892
+ ...additionalPropKeys
893
+ ]
894
+ );
895
+ }
896
+ function createPartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
897
+ return createUnsafePartialObserverComponent(
898
+ Component,
899
+ curriedPropsSource,
900
+ additionalPropKeys
901
+ );
902
+ }
903
+ function createUnsafePartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
904
+ return (0, import_mobx_react.observer)(
905
+ (0, import_react.forwardRef)(
906
+ function(props, ref) {
907
+ const C = Component;
908
+ const [
909
+ additionalProps,
910
+ exposedProps
911
+ ] = additionalPropKeys.reduce(
912
+ function([
913
+ additionalProps2,
914
+ exposedProps2
915
+ ], key) {
916
+ const value = props[
917
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
918
+ key
919
+ ];
920
+ delete exposedProps2[key];
921
+ additionalProps2[key] = value;
922
+ return [
923
+ additionalProps2,
924
+ exposedProps2
925
+ ];
926
+ },
927
+ [
928
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
929
+ {},
930
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
931
+ __spreadValues({}, props)
932
+ ]
933
+ );
934
+ const curriedProps = curriedPropsSource(additionalProps);
935
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
936
+ C,
937
+ __spreadValues(__spreadValues({
938
+ ref
939
+ }, curriedProps), exposedProps)
940
+ );
941
+ }
942
+ )
943
+ );
944
+ }
945
+ function usePartialObserverComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
946
+ return (0, import_react.useMemo)(
947
+ function() {
948
+ return createPartialObserverComponent(
949
+ Component,
950
+ curriedPropsSource,
951
+ additionalPropKeys
952
+ );
953
+ },
954
+ // eslint-disable-next-line react-hooks/exhaustive-deps
955
+ [
956
+ // eslint-disable-next-line react-hooks/exhaustive-deps
957
+ ...deps,
958
+ Component,
959
+ // eslint-disable-next-line react-hooks/exhaustive-deps
960
+ ...additionalPropKeys
961
+ ]
962
+ );
963
+ }
964
+
965
+ // core/mobx/hooks.tsx
745
966
  function useDefaultMobxFormHooks(presenter, value, {
746
967
  onValidFieldSubmit,
747
- onValidFormSubmit
968
+ onValidFormSubmit,
969
+ FormFieldsView
748
970
  } = {}) {
749
- const model = (0, import_react.useMemo)(function() {
971
+ const model = (0, import_react2.useMemo)(function() {
750
972
  return presenter.createModel(value);
751
973
  }, [
752
974
  presenter,
753
975
  value
754
976
  ]);
755
- const onFieldValueChange = (0, import_react.useCallback)(
977
+ const onFieldValueChange = (0, import_react2.useCallback)(
756
978
  function(path, value2) {
757
979
  presenter.clearFieldError(model, path);
758
980
  presenter.setFieldValue(model, path, value2);
@@ -762,10 +984,10 @@ function useDefaultMobxFormHooks(presenter, value, {
762
984
  model
763
985
  ]
764
986
  );
765
- const onFieldSubmit = (0, import_react.useCallback)(
987
+ const onFieldSubmit = (0, import_react2.useCallback)(
766
988
  function(valuePath) {
767
989
  if (presenter.validateField(model, valuePath)) {
768
- onValidFieldSubmit?.(model, valuePath);
990
+ onValidFieldSubmit == null ? void 0 : onValidFieldSubmit(model, valuePath);
769
991
  }
770
992
  return false;
771
993
  },
@@ -775,11 +997,11 @@ function useDefaultMobxFormHooks(presenter, value, {
775
997
  onValidFieldSubmit
776
998
  ]
777
999
  );
778
- const onFieldBlur = (0, import_react.useCallback)(
1000
+ const onFieldBlur = (0, import_react2.useCallback)(
779
1001
  function(path) {
780
1002
  setTimeout(function() {
781
1003
  if (presenter.isValuePathActive(model, path)) {
782
- presenter.validateField(model, path);
1004
+ presenter.validateField(model, path, true);
783
1005
  }
784
1006
  }, 100);
785
1007
  },
@@ -788,10 +1010,10 @@ function useDefaultMobxFormHooks(presenter, value, {
788
1010
  model
789
1011
  ]
790
1012
  );
791
- const onFormSubmit = (0, import_react.useCallback)(
1013
+ const onFormSubmit = (0, import_react2.useCallback)(
792
1014
  function() {
793
1015
  if (presenter.validateAll(model)) {
794
- onValidFormSubmit?.(model, model.value);
1016
+ onValidFormSubmit == null ? void 0 : onValidFormSubmit(model, model.value);
795
1017
  }
796
1018
  },
797
1019
  [
@@ -800,12 +1022,33 @@ function useDefaultMobxFormHooks(presenter, value, {
800
1022
  onValidFormSubmit
801
1023
  ]
802
1024
  );
1025
+ const FormFields = (0, import_react2.useMemo)(() => {
1026
+ if (FormFieldsView == null) {
1027
+ return void 0;
1028
+ }
1029
+ return createUnsafePartialObserverComponent(FormFieldsView, () => {
1030
+ return {
1031
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1032
+ fields: model.fields,
1033
+ onFieldBlur,
1034
+ onFieldSubmit,
1035
+ onFieldValueChange
1036
+ };
1037
+ });
1038
+ }, [
1039
+ model,
1040
+ FormFieldsView,
1041
+ onFieldBlur,
1042
+ onFieldSubmit,
1043
+ onFieldValueChange
1044
+ ]);
803
1045
  return {
804
1046
  model,
805
1047
  onFieldValueChange,
806
1048
  onFieldSubmit,
807
1049
  onFieldBlur,
808
- onFormSubmit
1050
+ onFormSubmit,
1051
+ FormFields
809
1052
  };
810
1053
  }
811
1054
 
@@ -873,11 +1116,10 @@ function mergeAdaptersWithValidators(adapters, validators) {
873
1116
  readonly: readonly1 || readonly2
874
1117
  };
875
1118
  }
876
- acc[key] = {
877
- ...adapter2,
1119
+ acc[key] = __spreadProps(__spreadValues({}, adapter2), {
878
1120
  convert,
879
1121
  revert: adapter2.revert && revert
880
- };
1122
+ });
881
1123
  return acc;
882
1124
  },
883
1125
  {}
@@ -956,9 +1198,9 @@ var NullableToBooleanConverter = class {
956
1198
  this.typeDef = typeDef;
957
1199
  this.prototype = prototype;
958
1200
  this.nullType = nullType;
1201
+ __publicField(this, "defaultValue");
959
1202
  this.defaultValue = defaultToNull ? this.nullType : prototype;
960
1203
  }
961
- defaultValue;
962
1204
  convert(from) {
963
1205
  return {
964
1206
  value: from !== this.nullType,
@@ -1117,172 +1359,25 @@ var import_base6 = require("@strictly/base");
1117
1359
  var import_mobx2 = require("mobx");
1118
1360
  var import_react4 = require("react");
1119
1361
 
1120
- // util/partial.tsx
1121
- var import_mobx_react = require("mobx-react");
1122
- var import_react2 = require("react");
1123
- var import_jsx_runtime = require("react/jsx-runtime");
1124
- function createSimplePartialComponent(Component, curriedProps) {
1125
- return (0, import_react2.forwardRef)(
1126
- function(exposedProps, ref) {
1127
- const C = Component;
1128
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1129
- C,
1130
- {
1131
- ref,
1132
- ...curriedProps,
1133
- ...exposedProps
1134
- }
1135
- );
1136
- }
1137
- );
1138
- }
1139
- function createPartialComponent(Component, curriedPropsSource, additionalPropKeys = []) {
1140
- return (0, import_react2.forwardRef)(
1141
- function(props, ref) {
1142
- const C = Component;
1143
- const [
1144
- additionalProps,
1145
- exposedProps
1146
- ] = additionalPropKeys.reduce(
1147
- function([
1148
- additionalProps2,
1149
- exposedProps2
1150
- ], key) {
1151
- const value = props[
1152
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1153
- key
1154
- ];
1155
- delete exposedProps2[key];
1156
- additionalProps2[key] = value;
1157
- return [
1158
- additionalProps2,
1159
- exposedProps2
1160
- ];
1161
- },
1162
- [
1163
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1164
- {},
1165
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1166
- { ...props }
1167
- ]
1168
- );
1169
- const curriedProps = curriedPropsSource(additionalProps);
1170
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1171
- C,
1172
- {
1173
- ref,
1174
- ...curriedProps,
1175
- ...exposedProps
1176
- }
1177
- );
1178
- }
1179
- );
1180
- }
1181
- function usePartialComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
1182
- return (0, import_react2.useMemo)(
1183
- function() {
1184
- return createPartialComponent(
1185
- Component,
1186
- curriedPropsSource,
1187
- additionalPropKeys
1188
- );
1189
- },
1190
- // eslint-disable-next-line react-hooks/exhaustive-deps
1191
- [
1192
- // eslint-disable-next-line react-hooks/exhaustive-deps
1193
- ...deps,
1194
- Component,
1195
- // eslint-disable-next-line react-hooks/exhaustive-deps
1196
- ...additionalPropKeys
1197
- ]
1198
- );
1199
- }
1200
- function createPartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
1201
- return createUnsafePartialObserverComponent(
1202
- Component,
1203
- curriedPropsSource,
1204
- additionalPropKeys
1205
- );
1206
- }
1207
- function createUnsafePartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
1208
- return (0, import_mobx_react.observer)(
1209
- (0, import_react2.forwardRef)(
1210
- function(props, ref) {
1211
- const C = Component;
1212
- const [
1213
- additionalProps,
1214
- exposedProps
1215
- ] = additionalPropKeys.reduce(
1216
- function([
1217
- additionalProps2,
1218
- exposedProps2
1219
- ], key) {
1220
- const value = props[
1221
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1222
- key
1223
- ];
1224
- delete exposedProps2[key];
1225
- additionalProps2[key] = value;
1226
- return [
1227
- additionalProps2,
1228
- exposedProps2
1229
- ];
1230
- },
1231
- [
1232
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1233
- {},
1234
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1235
- { ...props }
1236
- ]
1237
- );
1238
- const curriedProps = curriedPropsSource(additionalProps);
1239
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1240
- C,
1241
- {
1242
- ref,
1243
- ...curriedProps,
1244
- ...exposedProps
1245
- }
1246
- );
1247
- }
1248
- )
1249
- );
1250
- }
1251
- function usePartialObserverComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
1252
- return (0, import_react2.useMemo)(
1253
- function() {
1254
- return createPartialObserverComponent(
1255
- Component,
1256
- curriedPropsSource,
1257
- additionalPropKeys
1258
- );
1259
- },
1260
- // eslint-disable-next-line react-hooks/exhaustive-deps
1261
- [
1262
- // eslint-disable-next-line react-hooks/exhaustive-deps
1263
- ...deps,
1264
- Component,
1265
- // eslint-disable-next-line react-hooks/exhaustive-deps
1266
- ...additionalPropKeys
1267
- ]
1268
- );
1269
- }
1270
-
1271
1362
  // mantine/create_checkbox.tsx
1272
1363
  var import_jsx_runtime2 = require("react/jsx-runtime");
1273
1364
  function createCheckbox(valuePath, Checkbox) {
1274
1365
  const onChange = (e) => {
1275
- this.onFieldValueChange?.(valuePath, e.target.checked);
1366
+ var _a;
1367
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.checked);
1276
1368
  };
1277
1369
  const onFocus = () => {
1278
- this.onFieldFocus?.(valuePath);
1370
+ var _a;
1371
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1279
1372
  };
1280
1373
  const onBlur = () => {
1281
- this.onFieldBlur?.(valuePath);
1374
+ var _a;
1375
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1282
1376
  };
1283
1377
  const onKeyUp = (e) => {
1378
+ var _a;
1284
1379
  if (e.key === "Enter") {
1285
- if (this.onFieldSubmit?.(valuePath)) {
1380
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1286
1381
  e.preventDefault();
1287
1382
  }
1288
1383
  }
@@ -1330,42 +1425,54 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
1330
1425
  observableProps.onFieldValueChange(toKey(subKey), value);
1331
1426
  }
1332
1427
  function onFieldBlur(subKey) {
1333
- observableProps.onFieldBlur?.(toKey(subKey));
1428
+ var _a;
1429
+ (_a = observableProps.onFieldBlur) == null ? void 0 : _a.call(observableProps, toKey(subKey));
1334
1430
  }
1335
1431
  function onFieldFocus(subKey) {
1336
- observableProps.onFieldFocus?.(toKey(subKey));
1432
+ var _a;
1433
+ (_a = observableProps.onFieldFocus) == null ? void 0 : _a.call(observableProps, toKey(subKey));
1337
1434
  }
1338
1435
  function onFieldSubmit(subKey) {
1339
- observableProps.onFieldSubmit?.(toKey(subKey));
1340
- }
1341
- return (0, import_mobx_react2.observer)(function(props) {
1342
- const subFields = Object.entries(observableProps.fields).reduce(
1343
- (acc, [
1344
- fieldKey,
1345
- fieldValue
1346
- ]) => {
1347
- if (fieldKey.startsWith(valuePath)) {
1348
- acc[toSubKey(fieldKey)] = fieldValue;
1349
- }
1350
- return acc;
1351
- },
1352
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1353
- {}
1354
- );
1355
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1356
- FieldsView,
1357
- {
1358
- // maybe we can do this in a more type safe way
1359
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
1360
- ...props,
1361
- fields: subFields,
1362
- onFieldBlur,
1363
- onFieldFocus,
1364
- onFieldSubmit,
1365
- onFieldValueChange
1366
- }
1367
- );
1368
- });
1436
+ var _a;
1437
+ (_a = observableProps.onFieldSubmit) == null ? void 0 : _a.call(observableProps, toKey(subKey));
1438
+ }
1439
+ const Component = (0, import_mobx_react2.observer)(
1440
+ function(props) {
1441
+ const subFields = Object.entries(observableProps.fields).reduce(
1442
+ (acc, [
1443
+ fieldKey,
1444
+ fieldValue
1445
+ ]) => {
1446
+ if (fieldKey.startsWith(valuePath)) {
1447
+ acc[toSubKey(fieldKey)] = fieldValue;
1448
+ }
1449
+ return acc;
1450
+ },
1451
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1452
+ {}
1453
+ );
1454
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1455
+ FieldsView,
1456
+ __spreadProps(__spreadValues({}, props), {
1457
+ fields: subFields,
1458
+ onFieldBlur,
1459
+ onFieldFocus,
1460
+ onFieldSubmit,
1461
+ onFieldValueChange
1462
+ })
1463
+ );
1464
+ }
1465
+ );
1466
+ const callbackMapper = (callback) => {
1467
+ return (subFormValuePath, ...args) => {
1468
+ const valuePath2 = toKey(subFormValuePath);
1469
+ return callback(valuePath2, ...args);
1470
+ };
1471
+ };
1472
+ return {
1473
+ Component,
1474
+ callbackMapper
1475
+ };
1369
1476
  }
1370
1477
 
1371
1478
  // mantine/create_form.tsx
@@ -1380,13 +1487,10 @@ function createForm(valuePath, Form, observableProps) {
1380
1487
  }, []);
1381
1488
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1382
1489
  Form,
1383
- {
1384
- // maybe we can do this in a more type safe way
1385
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
1386
- ...props,
1490
+ __spreadProps(__spreadValues({}, props), {
1387
1491
  onValueChange,
1388
1492
  value
1389
- }
1493
+ })
1390
1494
  );
1391
1495
  });
1392
1496
  }
@@ -1450,17 +1554,21 @@ function createRadio(valuePath, value, Radio) {
1450
1554
  var import_jsx_runtime6 = require("react/jsx-runtime");
1451
1555
  function createRadioGroup(valuePath, RadioGroup) {
1452
1556
  const onChange = (value) => {
1453
- this.onFieldValueChange?.(valuePath, value);
1557
+ var _a;
1558
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
1454
1559
  };
1455
1560
  const onFocus = () => {
1456
- this.onFieldFocus?.(valuePath);
1561
+ var _a;
1562
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1457
1563
  };
1458
1564
  const onBlur = () => {
1459
- this.onFieldBlur?.(valuePath);
1565
+ var _a;
1566
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1460
1567
  };
1461
1568
  const onKeyUp = (e) => {
1569
+ var _a;
1462
1570
  if (e.key === "Enter") {
1463
- if (this.onFieldSubmit?.(valuePath)) {
1571
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1464
1572
  e.preventDefault();
1465
1573
  }
1466
1574
  }
@@ -1489,17 +1597,21 @@ function createRadioGroup(valuePath, RadioGroup) {
1489
1597
  var import_jsx_runtime7 = require("react/jsx-runtime");
1490
1598
  function createTextInput(valuePath, TextInput) {
1491
1599
  const onChange = (e) => {
1492
- this.onFieldValueChange?.(valuePath, e.target.value);
1600
+ var _a;
1601
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.value);
1493
1602
  };
1494
1603
  const onFocus = () => {
1495
- this.onFieldFocus?.(valuePath);
1604
+ var _a;
1605
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1496
1606
  };
1497
1607
  const onBlur = () => {
1498
- this.onFieldBlur?.(valuePath);
1608
+ var _a;
1609
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1499
1610
  };
1500
1611
  const onKeyUp = (e) => {
1612
+ var _a;
1501
1613
  if (e.key === "Enter") {
1502
- if (this.onFieldSubmit?.(valuePath)) {
1614
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1503
1615
  e.preventDefault();
1504
1616
  }
1505
1617
  }
@@ -1541,17 +1653,21 @@ function createTextInput(valuePath, TextInput) {
1541
1653
  var import_jsx_runtime8 = require("react/jsx-runtime");
1542
1654
  function createValueInput(valuePath, ValueInput) {
1543
1655
  const onChange = (value) => {
1544
- this.onFieldValueChange?.(valuePath, value);
1656
+ var _a;
1657
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
1545
1658
  };
1546
1659
  const onFocus = () => {
1547
- this.onFieldFocus?.(valuePath);
1660
+ var _a;
1661
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1548
1662
  };
1549
1663
  const onBlur = () => {
1550
- this.onFieldBlur?.(valuePath);
1664
+ var _a;
1665
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1551
1666
  };
1552
1667
  const onKeyUp = (e) => {
1668
+ var _a;
1553
1669
  if (e.key === "Enter") {
1554
- if (this.onFieldSubmit?.(valuePath)) {
1670
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1555
1671
  e.preventDefault();
1556
1672
  }
1557
1673
  }
@@ -1589,7 +1705,7 @@ function createValueInput(valuePath, ValueInput) {
1589
1705
  // mantine/hooks.tsx
1590
1706
  var import_jsx_runtime9 = require("react/jsx-runtime");
1591
1707
  function SimpleSelect(props) {
1592
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core.Select, { ...props });
1708
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core.Select, __spreadValues({}, props));
1593
1709
  }
1594
1710
  function useMantineFormFields({
1595
1711
  onFieldValueChange,
@@ -1640,39 +1756,40 @@ function useMantineFormFields({
1640
1756
  ]);
1641
1757
  return form;
1642
1758
  }
1759
+ var _fields_dec2, _init2, _fields;
1760
+ _fields_dec2 = [import_mobx2.observable.ref];
1643
1761
  var MantineFormImpl = class {
1644
- textInputCache = new import_base6.Cache(
1645
- createTextInput.bind(this)
1646
- );
1647
- valueInputCache = new import_base6.Cache(
1648
- createValueInput.bind(this)
1649
- );
1650
- checkboxCache = new import_base6.Cache(
1651
- createCheckbox.bind(this)
1652
- );
1653
- radioGroupCache = new import_base6.Cache(
1654
- createRadioGroup.bind(this)
1655
- );
1656
- radioCache = new import_base6.Cache(
1657
- createRadio.bind(this)
1658
- );
1659
- pillCache = new import_base6.Cache(
1660
- createPill.bind(this)
1661
- );
1662
- listCache = new import_base6.Cache(
1663
- createList.bind(this)
1664
- );
1665
- fieldsViewCache = new import_base6.Cache(
1666
- createFieldsView.bind(this)
1667
- );
1668
- formCache = new import_base6.Cache(createForm.bind(this));
1669
- @import_mobx2.observable.ref
1670
- accessor fields;
1671
- onFieldValueChange;
1672
- onFieldFocus;
1673
- onFieldBlur;
1674
- onFieldSubmit;
1675
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");
1676
1793
  this.fields = fields;
1677
1794
  }
1678
1795
  textInput(valuePath, TextInput = import_core.TextInput) {
@@ -1750,14 +1867,15 @@ var MantineFormImpl = class {
1750
1867
  );
1751
1868
  }
1752
1869
  };
1870
+ _init2 = __decoratorStart(null);
1871
+ _fields = new WeakMap();
1872
+ __decorateElement(_init2, 4, "fields", _fields_dec2, MantineFormImpl, _fields);
1873
+ __decoratorMetadata(_init2, MantineFormImpl);
1753
1874
 
1754
1875
  // types/merge_validators.ts
1755
1876
  var import_define7 = require("@strictly/define");
1756
1877
  function mergeValidators(validators1, validators2) {
1757
- const validators = {
1758
- ...validators1,
1759
- ...validators2
1760
- };
1878
+ const validators = __spreadValues(__spreadValues({}, validators1), validators2);
1761
1879
  const keys1 = new Set(Object.keys(validators1));
1762
1880
  const keys2 = new Set(Object.keys(validators2));
1763
1881
  return Array.from(keys1.intersection(keys2)).reduce(