@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.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 ?? accessor.value.length;
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?.set(conversion.value);
499
+ accessor == null ? void 0 : accessor.set(conversion.value);
430
500
  return true;
431
501
  default:
432
502
  throw new UnreachableError2(conversion);
@@ -451,8 +521,7 @@ var FormPresenter = class {
451
521
  convert,
452
522
  create
453
523
  } = adapter2;
454
- const accessor = model.accessors[valuePath];
455
- const value = accessor == null ? create(valuePath, model.value) : accessor.value;
524
+ const value = create(valuePath, model.value);
456
525
  const {
457
526
  value: displayValue
458
527
  } = convert(value, valuePath, model.value);
@@ -473,7 +542,7 @@ var FormPresenter = class {
473
542
  const keys = new Set(Object.keys(values));
474
543
  return keys.has(valuePath);
475
544
  }
476
- validateField(model, valuePath) {
545
+ validateField(model, valuePath, ignoreDefaultValue = false) {
477
546
  const {
478
547
  convert,
479
548
  revert,
@@ -492,6 +561,14 @@ var FormPresenter = class {
492
561
  const value = fieldOverride != null ? fieldOverride[0] : storedValue;
493
562
  const dirty = storedValue !== value;
494
563
  assertExists(revert, "changing field directly not supported {}", valuePath);
564
+ if (ignoreDefaultValue) {
565
+ const {
566
+ value: defaultDisplayValue
567
+ } = convert(create(valuePath, model.value), valuePath, model.value);
568
+ if (defaultDisplayValue === value) {
569
+ return true;
570
+ }
571
+ }
495
572
  const conversion = revert(value, valuePath, model.value);
496
573
  return runInAction(function() {
497
574
  switch (conversion.type) {
@@ -562,18 +639,18 @@ var FormPresenter = class {
562
639
  );
563
640
  });
564
641
  }
565
- createModel(value) {
566
- return new FormModel(
567
- this.type,
568
- value,
569
- this.adapters
570
- );
571
- }
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,17 +772,179 @@ 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
- // core/mobx/hooks.ts
787
+ // core/mobx/hooks.tsx
710
788
  import {
711
789
  useCallback,
790
+ useMemo as useMemo2
791
+ } from "react";
792
+
793
+ // util/partial.tsx
794
+ import { observer } from "mobx-react";
795
+ import {
796
+ forwardRef,
712
797
  useMemo
713
798
  } from "react";
799
+ import { jsx } from "react/jsx-runtime";
800
+ function createSimplePartialComponent(Component, curriedProps) {
801
+ return forwardRef(
802
+ function(exposedProps, ref) {
803
+ const C = Component;
804
+ return /* @__PURE__ */ jsx(
805
+ C,
806
+ __spreadValues(__spreadValues({
807
+ ref
808
+ }, curriedProps), exposedProps)
809
+ );
810
+ }
811
+ );
812
+ }
813
+ function createPartialComponent(Component, curriedPropsSource, additionalPropKeys = []) {
814
+ return forwardRef(
815
+ function(props, ref) {
816
+ const C = Component;
817
+ const [
818
+ additionalProps,
819
+ exposedProps
820
+ ] = additionalPropKeys.reduce(
821
+ function([
822
+ additionalProps2,
823
+ exposedProps2
824
+ ], key) {
825
+ const value = props[
826
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
827
+ key
828
+ ];
829
+ delete exposedProps2[key];
830
+ additionalProps2[key] = value;
831
+ return [
832
+ additionalProps2,
833
+ exposedProps2
834
+ ];
835
+ },
836
+ [
837
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
838
+ {},
839
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
840
+ __spreadValues({}, props)
841
+ ]
842
+ );
843
+ const curriedProps = curriedPropsSource(additionalProps);
844
+ return /* @__PURE__ */ jsx(
845
+ C,
846
+ __spreadValues(__spreadValues({
847
+ ref
848
+ }, curriedProps), exposedProps)
849
+ );
850
+ }
851
+ );
852
+ }
853
+ function usePartialComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
854
+ return useMemo(
855
+ function() {
856
+ return createPartialComponent(
857
+ Component,
858
+ curriedPropsSource,
859
+ additionalPropKeys
860
+ );
861
+ },
862
+ // eslint-disable-next-line react-hooks/exhaustive-deps
863
+ [
864
+ // eslint-disable-next-line react-hooks/exhaustive-deps
865
+ ...deps,
866
+ Component,
867
+ // eslint-disable-next-line react-hooks/exhaustive-deps
868
+ ...additionalPropKeys
869
+ ]
870
+ );
871
+ }
872
+ function createPartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
873
+ return createUnsafePartialObserverComponent(
874
+ Component,
875
+ curriedPropsSource,
876
+ additionalPropKeys
877
+ );
878
+ }
879
+ function createUnsafePartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
880
+ return observer(
881
+ forwardRef(
882
+ function(props, ref) {
883
+ const C = Component;
884
+ const [
885
+ additionalProps,
886
+ exposedProps
887
+ ] = additionalPropKeys.reduce(
888
+ function([
889
+ additionalProps2,
890
+ exposedProps2
891
+ ], key) {
892
+ const value = props[
893
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
894
+ key
895
+ ];
896
+ delete exposedProps2[key];
897
+ additionalProps2[key] = value;
898
+ return [
899
+ additionalProps2,
900
+ exposedProps2
901
+ ];
902
+ },
903
+ [
904
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
905
+ {},
906
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
907
+ __spreadValues({}, props)
908
+ ]
909
+ );
910
+ const curriedProps = curriedPropsSource(additionalProps);
911
+ return /* @__PURE__ */ jsx(
912
+ C,
913
+ __spreadValues(__spreadValues({
914
+ ref
915
+ }, curriedProps), exposedProps)
916
+ );
917
+ }
918
+ )
919
+ );
920
+ }
921
+ function usePartialObserverComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
922
+ return useMemo(
923
+ function() {
924
+ return createPartialObserverComponent(
925
+ Component,
926
+ curriedPropsSource,
927
+ additionalPropKeys
928
+ );
929
+ },
930
+ // eslint-disable-next-line react-hooks/exhaustive-deps
931
+ [
932
+ // eslint-disable-next-line react-hooks/exhaustive-deps
933
+ ...deps,
934
+ Component,
935
+ // eslint-disable-next-line react-hooks/exhaustive-deps
936
+ ...additionalPropKeys
937
+ ]
938
+ );
939
+ }
940
+
941
+ // core/mobx/hooks.tsx
714
942
  function useDefaultMobxFormHooks(presenter, value, {
715
943
  onValidFieldSubmit,
716
- onValidFormSubmit
944
+ onValidFormSubmit,
945
+ FormFieldsView
717
946
  } = {}) {
718
- const model = useMemo(function() {
947
+ const model = useMemo2(function() {
719
948
  return presenter.createModel(value);
720
949
  }, [
721
950
  presenter,
@@ -734,7 +963,7 @@ function useDefaultMobxFormHooks(presenter, value, {
734
963
  const onFieldSubmit = useCallback(
735
964
  function(valuePath) {
736
965
  if (presenter.validateField(model, valuePath)) {
737
- onValidFieldSubmit?.(model, valuePath);
966
+ onValidFieldSubmit == null ? void 0 : onValidFieldSubmit(model, valuePath);
738
967
  }
739
968
  return false;
740
969
  },
@@ -748,7 +977,7 @@ function useDefaultMobxFormHooks(presenter, value, {
748
977
  function(path) {
749
978
  setTimeout(function() {
750
979
  if (presenter.isValuePathActive(model, path)) {
751
- presenter.validateField(model, path);
980
+ presenter.validateField(model, path, true);
752
981
  }
753
982
  }, 100);
754
983
  },
@@ -760,7 +989,7 @@ function useDefaultMobxFormHooks(presenter, value, {
760
989
  const onFormSubmit = useCallback(
761
990
  function() {
762
991
  if (presenter.validateAll(model)) {
763
- onValidFormSubmit?.(model, model.value);
992
+ onValidFormSubmit == null ? void 0 : onValidFormSubmit(model, model.value);
764
993
  }
765
994
  },
766
995
  [
@@ -769,12 +998,33 @@ function useDefaultMobxFormHooks(presenter, value, {
769
998
  onValidFormSubmit
770
999
  ]
771
1000
  );
1001
+ const FormFields = useMemo2(() => {
1002
+ if (FormFieldsView == null) {
1003
+ return void 0;
1004
+ }
1005
+ return createUnsafePartialObserverComponent(FormFieldsView, () => {
1006
+ return {
1007
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1008
+ fields: model.fields,
1009
+ onFieldBlur,
1010
+ onFieldSubmit,
1011
+ onFieldValueChange
1012
+ };
1013
+ });
1014
+ }, [
1015
+ model,
1016
+ FormFieldsView,
1017
+ onFieldBlur,
1018
+ onFieldSubmit,
1019
+ onFieldValueChange
1020
+ ]);
772
1021
  return {
773
1022
  model,
774
1023
  onFieldValueChange,
775
1024
  onFieldSubmit,
776
1025
  onFieldBlur,
777
- onFormSubmit
1026
+ onFormSubmit,
1027
+ FormFields
778
1028
  };
779
1029
  }
780
1030
 
@@ -845,11 +1095,10 @@ function mergeAdaptersWithValidators(adapters, validators) {
845
1095
  readonly: readonly1 || readonly2
846
1096
  };
847
1097
  }
848
- acc[key] = {
849
- ...adapter2,
1098
+ acc[key] = __spreadProps(__spreadValues({}, adapter2), {
850
1099
  convert,
851
1100
  revert: adapter2.revert && revert
852
- };
1101
+ });
853
1102
  return acc;
854
1103
  },
855
1104
  {}
@@ -932,9 +1181,9 @@ var NullableToBooleanConverter = class {
932
1181
  this.typeDef = typeDef;
933
1182
  this.prototype = prototype;
934
1183
  this.nullType = nullType;
1184
+ __publicField(this, "defaultValue");
935
1185
  this.defaultValue = defaultToNull ? this.nullType : prototype;
936
1186
  }
937
- defaultValue;
938
1187
  convert(from) {
939
1188
  return {
940
1189
  value: from !== this.nullType,
@@ -1113,175 +1362,25 @@ import {
1113
1362
  useMemo as useMemo3
1114
1363
  } from "react";
1115
1364
 
1116
- // util/partial.tsx
1117
- import { observer } from "mobx-react";
1118
- import {
1119
- forwardRef,
1120
- useMemo as useMemo2
1121
- } from "react";
1122
- import { jsx } from "react/jsx-runtime";
1123
- function createSimplePartialComponent(Component, curriedProps) {
1124
- return forwardRef(
1125
- function(exposedProps, ref) {
1126
- const C = Component;
1127
- return /* @__PURE__ */ jsx(
1128
- C,
1129
- {
1130
- ref,
1131
- ...curriedProps,
1132
- ...exposedProps
1133
- }
1134
- );
1135
- }
1136
- );
1137
- }
1138
- function createPartialComponent(Component, curriedPropsSource, additionalPropKeys = []) {
1139
- return forwardRef(
1140
- function(props, ref) {
1141
- const C = Component;
1142
- const [
1143
- additionalProps,
1144
- exposedProps
1145
- ] = additionalPropKeys.reduce(
1146
- function([
1147
- additionalProps2,
1148
- exposedProps2
1149
- ], key) {
1150
- const value = props[
1151
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1152
- key
1153
- ];
1154
- delete exposedProps2[key];
1155
- additionalProps2[key] = value;
1156
- return [
1157
- additionalProps2,
1158
- exposedProps2
1159
- ];
1160
- },
1161
- [
1162
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1163
- {},
1164
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1165
- { ...props }
1166
- ]
1167
- );
1168
- const curriedProps = curriedPropsSource(additionalProps);
1169
- return /* @__PURE__ */ jsx(
1170
- C,
1171
- {
1172
- ref,
1173
- ...curriedProps,
1174
- ...exposedProps
1175
- }
1176
- );
1177
- }
1178
- );
1179
- }
1180
- function usePartialComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
1181
- return useMemo2(
1182
- function() {
1183
- return createPartialComponent(
1184
- Component,
1185
- curriedPropsSource,
1186
- additionalPropKeys
1187
- );
1188
- },
1189
- // eslint-disable-next-line react-hooks/exhaustive-deps
1190
- [
1191
- // eslint-disable-next-line react-hooks/exhaustive-deps
1192
- ...deps,
1193
- Component,
1194
- // eslint-disable-next-line react-hooks/exhaustive-deps
1195
- ...additionalPropKeys
1196
- ]
1197
- );
1198
- }
1199
- function createPartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
1200
- return createUnsafePartialObserverComponent(
1201
- Component,
1202
- curriedPropsSource,
1203
- additionalPropKeys
1204
- );
1205
- }
1206
- function createUnsafePartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
1207
- return observer(
1208
- forwardRef(
1209
- function(props, ref) {
1210
- const C = Component;
1211
- const [
1212
- additionalProps,
1213
- exposedProps
1214
- ] = additionalPropKeys.reduce(
1215
- function([
1216
- additionalProps2,
1217
- exposedProps2
1218
- ], key) {
1219
- const value = props[
1220
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1221
- key
1222
- ];
1223
- delete exposedProps2[key];
1224
- additionalProps2[key] = value;
1225
- return [
1226
- additionalProps2,
1227
- exposedProps2
1228
- ];
1229
- },
1230
- [
1231
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1232
- {},
1233
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1234
- { ...props }
1235
- ]
1236
- );
1237
- const curriedProps = curriedPropsSource(additionalProps);
1238
- return /* @__PURE__ */ jsx(
1239
- C,
1240
- {
1241
- ref,
1242
- ...curriedProps,
1243
- ...exposedProps
1244
- }
1245
- );
1246
- }
1247
- )
1248
- );
1249
- }
1250
- function usePartialObserverComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
1251
- return useMemo2(
1252
- function() {
1253
- return createPartialObserverComponent(
1254
- Component,
1255
- curriedPropsSource,
1256
- additionalPropKeys
1257
- );
1258
- },
1259
- // eslint-disable-next-line react-hooks/exhaustive-deps
1260
- [
1261
- // eslint-disable-next-line react-hooks/exhaustive-deps
1262
- ...deps,
1263
- Component,
1264
- // eslint-disable-next-line react-hooks/exhaustive-deps
1265
- ...additionalPropKeys
1266
- ]
1267
- );
1268
- }
1269
-
1270
1365
  // mantine/create_checkbox.tsx
1271
1366
  import { jsx as jsx2 } from "react/jsx-runtime";
1272
1367
  function createCheckbox(valuePath, Checkbox) {
1273
1368
  const onChange = (e) => {
1274
- this.onFieldValueChange?.(valuePath, e.target.checked);
1369
+ var _a;
1370
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.checked);
1275
1371
  };
1276
1372
  const onFocus = () => {
1277
- this.onFieldFocus?.(valuePath);
1373
+ var _a;
1374
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1278
1375
  };
1279
1376
  const onBlur = () => {
1280
- this.onFieldBlur?.(valuePath);
1377
+ var _a;
1378
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1281
1379
  };
1282
1380
  const onKeyUp = (e) => {
1381
+ var _a;
1283
1382
  if (e.key === "Enter") {
1284
- if (this.onFieldSubmit?.(valuePath)) {
1383
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1285
1384
  e.preventDefault();
1286
1385
  }
1287
1386
  }
@@ -1329,42 +1428,54 @@ function createFieldsView(valuePath, FieldsView, observableProps) {
1329
1428
  observableProps.onFieldValueChange(toKey(subKey), value);
1330
1429
  }
1331
1430
  function onFieldBlur(subKey) {
1332
- observableProps.onFieldBlur?.(toKey(subKey));
1431
+ var _a;
1432
+ (_a = observableProps.onFieldBlur) == null ? void 0 : _a.call(observableProps, toKey(subKey));
1333
1433
  }
1334
1434
  function onFieldFocus(subKey) {
1335
- observableProps.onFieldFocus?.(toKey(subKey));
1435
+ var _a;
1436
+ (_a = observableProps.onFieldFocus) == null ? void 0 : _a.call(observableProps, toKey(subKey));
1336
1437
  }
1337
1438
  function onFieldSubmit(subKey) {
1338
- observableProps.onFieldSubmit?.(toKey(subKey));
1339
- }
1340
- return observer2(function(props) {
1341
- const subFields = Object.entries(observableProps.fields).reduce(
1342
- (acc, [
1343
- fieldKey,
1344
- fieldValue
1345
- ]) => {
1346
- if (fieldKey.startsWith(valuePath)) {
1347
- acc[toSubKey(fieldKey)] = fieldValue;
1348
- }
1349
- return acc;
1350
- },
1351
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1352
- {}
1353
- );
1354
- return /* @__PURE__ */ jsx3(
1355
- FieldsView,
1356
- {
1357
- // maybe we can do this in a more type safe way
1358
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
1359
- ...props,
1360
- fields: subFields,
1361
- onFieldBlur,
1362
- onFieldFocus,
1363
- onFieldSubmit,
1364
- onFieldValueChange
1365
- }
1366
- );
1367
- });
1439
+ var _a;
1440
+ (_a = observableProps.onFieldSubmit) == null ? void 0 : _a.call(observableProps, toKey(subKey));
1441
+ }
1442
+ const Component = observer2(
1443
+ function(props) {
1444
+ const subFields = Object.entries(observableProps.fields).reduce(
1445
+ (acc, [
1446
+ fieldKey,
1447
+ fieldValue
1448
+ ]) => {
1449
+ if (fieldKey.startsWith(valuePath)) {
1450
+ acc[toSubKey(fieldKey)] = fieldValue;
1451
+ }
1452
+ return acc;
1453
+ },
1454
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1455
+ {}
1456
+ );
1457
+ return /* @__PURE__ */ jsx3(
1458
+ FieldsView,
1459
+ __spreadProps(__spreadValues({}, props), {
1460
+ fields: subFields,
1461
+ onFieldBlur,
1462
+ onFieldFocus,
1463
+ onFieldSubmit,
1464
+ onFieldValueChange
1465
+ })
1466
+ );
1467
+ }
1468
+ );
1469
+ const callbackMapper = (callback) => {
1470
+ return (subFormValuePath, ...args) => {
1471
+ const valuePath2 = toKey(subFormValuePath);
1472
+ return callback(valuePath2, ...args);
1473
+ };
1474
+ };
1475
+ return {
1476
+ Component,
1477
+ callbackMapper
1478
+ };
1368
1479
  }
1369
1480
 
1370
1481
  // mantine/create_form.tsx
@@ -1381,13 +1492,10 @@ function createForm(valuePath, Form, observableProps) {
1381
1492
  }, []);
1382
1493
  return /* @__PURE__ */ jsx4(
1383
1494
  Form,
1384
- {
1385
- // maybe we can do this in a more type safe way
1386
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
1387
- ...props,
1495
+ __spreadProps(__spreadValues({}, props), {
1388
1496
  onValueChange,
1389
1497
  value
1390
- }
1498
+ })
1391
1499
  );
1392
1500
  });
1393
1501
  }
@@ -1451,17 +1559,21 @@ function createRadio(valuePath, value, Radio) {
1451
1559
  import { jsx as jsx6 } from "react/jsx-runtime";
1452
1560
  function createRadioGroup(valuePath, RadioGroup) {
1453
1561
  const onChange = (value) => {
1454
- this.onFieldValueChange?.(valuePath, value);
1562
+ var _a;
1563
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
1455
1564
  };
1456
1565
  const onFocus = () => {
1457
- this.onFieldFocus?.(valuePath);
1566
+ var _a;
1567
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1458
1568
  };
1459
1569
  const onBlur = () => {
1460
- this.onFieldBlur?.(valuePath);
1570
+ var _a;
1571
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1461
1572
  };
1462
1573
  const onKeyUp = (e) => {
1574
+ var _a;
1463
1575
  if (e.key === "Enter") {
1464
- if (this.onFieldSubmit?.(valuePath)) {
1576
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1465
1577
  e.preventDefault();
1466
1578
  }
1467
1579
  }
@@ -1490,17 +1602,21 @@ function createRadioGroup(valuePath, RadioGroup) {
1490
1602
  import { jsx as jsx7 } from "react/jsx-runtime";
1491
1603
  function createTextInput(valuePath, TextInput) {
1492
1604
  const onChange = (e) => {
1493
- this.onFieldValueChange?.(valuePath, e.target.value);
1605
+ var _a;
1606
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, e.target.value);
1494
1607
  };
1495
1608
  const onFocus = () => {
1496
- this.onFieldFocus?.(valuePath);
1609
+ var _a;
1610
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1497
1611
  };
1498
1612
  const onBlur = () => {
1499
- this.onFieldBlur?.(valuePath);
1613
+ var _a;
1614
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1500
1615
  };
1501
1616
  const onKeyUp = (e) => {
1617
+ var _a;
1502
1618
  if (e.key === "Enter") {
1503
- if (this.onFieldSubmit?.(valuePath)) {
1619
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1504
1620
  e.preventDefault();
1505
1621
  }
1506
1622
  }
@@ -1542,17 +1658,21 @@ function createTextInput(valuePath, TextInput) {
1542
1658
  import { jsx as jsx8 } from "react/jsx-runtime";
1543
1659
  function createValueInput(valuePath, ValueInput) {
1544
1660
  const onChange = (value) => {
1545
- this.onFieldValueChange?.(valuePath, value);
1661
+ var _a;
1662
+ (_a = this.onFieldValueChange) == null ? void 0 : _a.call(this, valuePath, value);
1546
1663
  };
1547
1664
  const onFocus = () => {
1548
- this.onFieldFocus?.(valuePath);
1665
+ var _a;
1666
+ (_a = this.onFieldFocus) == null ? void 0 : _a.call(this, valuePath);
1549
1667
  };
1550
1668
  const onBlur = () => {
1551
- this.onFieldBlur?.(valuePath);
1669
+ var _a;
1670
+ (_a = this.onFieldBlur) == null ? void 0 : _a.call(this, valuePath);
1552
1671
  };
1553
1672
  const onKeyUp = (e) => {
1673
+ var _a;
1554
1674
  if (e.key === "Enter") {
1555
- if (this.onFieldSubmit?.(valuePath)) {
1675
+ if ((_a = this.onFieldSubmit) == null ? void 0 : _a.call(this, valuePath)) {
1556
1676
  e.preventDefault();
1557
1677
  }
1558
1678
  }
@@ -1590,7 +1710,7 @@ function createValueInput(valuePath, ValueInput) {
1590
1710
  // mantine/hooks.tsx
1591
1711
  import { jsx as jsx9 } from "react/jsx-runtime";
1592
1712
  function SimpleSelect(props) {
1593
- return /* @__PURE__ */ jsx9(Select, { ...props });
1713
+ return /* @__PURE__ */ jsx9(Select, __spreadValues({}, props));
1594
1714
  }
1595
1715
  function useMantineFormFields({
1596
1716
  onFieldValueChange,
@@ -1641,39 +1761,40 @@ function useMantineFormFields({
1641
1761
  ]);
1642
1762
  return form;
1643
1763
  }
1764
+ var _fields_dec2, _init2, _fields;
1765
+ _fields_dec2 = [observable2.ref];
1644
1766
  var MantineFormImpl = class {
1645
- textInputCache = new Cache(
1646
- createTextInput.bind(this)
1647
- );
1648
- valueInputCache = new Cache(
1649
- createValueInput.bind(this)
1650
- );
1651
- checkboxCache = new Cache(
1652
- createCheckbox.bind(this)
1653
- );
1654
- radioGroupCache = new Cache(
1655
- createRadioGroup.bind(this)
1656
- );
1657
- radioCache = new Cache(
1658
- createRadio.bind(this)
1659
- );
1660
- pillCache = new Cache(
1661
- createPill.bind(this)
1662
- );
1663
- listCache = new Cache(
1664
- createList.bind(this)
1665
- );
1666
- fieldsViewCache = new Cache(
1667
- createFieldsView.bind(this)
1668
- );
1669
- formCache = new Cache(createForm.bind(this));
1670
- @observable2.ref
1671
- accessor fields;
1672
- onFieldValueChange;
1673
- onFieldFocus;
1674
- onFieldBlur;
1675
- onFieldSubmit;
1676
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");
1677
1798
  this.fields = fields;
1678
1799
  }
1679
1800
  textInput(valuePath, TextInput = TextInputImpl) {
@@ -1751,6 +1872,10 @@ var MantineFormImpl = class {
1751
1872
  );
1752
1873
  }
1753
1874
  };
1875
+ _init2 = __decoratorStart(null);
1876
+ _fields = new WeakMap();
1877
+ __decorateElement(_init2, 4, "fields", _fields_dec2, MantineFormImpl, _fields);
1878
+ __decoratorMetadata(_init2, MantineFormImpl);
1754
1879
 
1755
1880
  // types/merge_validators.ts
1756
1881
  import {
@@ -1758,10 +1883,7 @@ import {
1758
1883
  validate as validate3
1759
1884
  } from "@strictly/define";
1760
1885
  function mergeValidators(validators1, validators2) {
1761
- const validators = {
1762
- ...validators1,
1763
- ...validators2
1764
- };
1886
+ const validators = __spreadValues(__spreadValues({}, validators1), validators2);
1765
1887
  const keys1 = new Set(Object.keys(validators1));
1766
1888
  const keys2 = new Set(Object.keys(validators2));
1767
1889
  return Array.from(keys1.intersection(keys2)).reduce(