@strictly/react-form 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.out/core/mobx/field_adapter.d.ts +7 -6
- package/.out/core/mobx/field_adapter_builder.d.ts +12 -13
- package/.out/core/mobx/field_adapter_builder.js +8 -12
- package/.out/core/mobx/field_adapters_of_values.d.ts +4 -0
- package/.out/core/mobx/flattened_adapters_of_fields.d.ts +2 -2
- package/.out/core/mobx/flattened_list_types_of_type.d.ts +8 -0
- package/.out/core/mobx/form_fields_of_field_adapters.d.ts +8 -0
- package/.out/core/mobx/form_presenter.d.ts +21 -24
- package/.out/core/mobx/form_presenter.js +64 -69
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +13 -0
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.js +11 -0
- package/.out/core/mobx/merge_field_adapters_with_validators.d.ts +11 -0
- package/.out/core/mobx/merge_field_adapters_with_validators.js +45 -0
- package/.out/core/mobx/specs/fixtures.d.ts +7 -0
- package/.out/core/mobx/specs/fixtures.js +20 -0
- package/.out/core/mobx/specs/flattened_adapters_of_fields.tests.js +5 -2
- package/.out/core/mobx/specs/{flattened_list_type_defs_of.tests.js → flattened_list_types_of_types.tests.js} +7 -7
- package/.out/core/mobx/specs/form_presenter.tests.js +162 -60
- package/.out/core/mobx/specs/merge_field_adapters_with_two_way_converter.js +89 -0
- package/.out/core/mobx/specs/merge_field_adapters_with_validators.tests.js +172 -0
- package/.out/core/mobx/types.d.ts +2 -2
- package/.out/field_converters/chain_field_converter.d.ts +3 -3
- package/.out/field_converters/chain_field_converter.js +17 -12
- package/.out/field_converters/identity_converter.d.ts +3 -3
- package/.out/field_converters/identity_converter.js +10 -6
- package/.out/field_converters/integer_to_string_converter.d.ts +5 -4
- package/.out/field_converters/integer_to_string_converter.js +13 -6
- package/.out/field_converters/list_converter.d.ts +2 -2
- package/.out/field_converters/list_converter.js +6 -1
- package/.out/field_converters/maybe_identity_converter.d.ts +3 -3
- package/.out/field_converters/maybe_identity_converter.js +3 -1
- package/.out/field_converters/nullable_to_boolean_converter.d.ts +9 -8
- package/.out/field_converters/nullable_to_boolean_converter.js +13 -7
- package/.out/field_converters/select_value_type_converter.d.ts +20 -15
- package/.out/field_converters/select_value_type_converter.js +29 -14
- package/.out/field_converters/specs/chain_field_converter.tests.d.ts +1 -0
- package/.out/field_converters/specs/chain_field_converter.tests.js +251 -0
- package/.out/field_converters/trimming_string_converter.d.ts +3 -3
- package/.out/field_converters/trimming_string_converter.js +7 -3
- package/.out/field_converters/validating_converter.d.ts +3 -3
- package/.out/field_converters/validating_converter.js +7 -5
- package/.out/index.d.ts +9 -2
- package/.out/index.js +9 -2
- package/.out/mantine/create_checkbox.d.ts +2 -3
- package/.out/mantine/create_checkbox.js +6 -5
- package/.out/mantine/create_pill.js +2 -2
- package/.out/mantine/create_radio.js +1 -1
- package/.out/mantine/create_radio_group.d.ts +2 -3
- package/.out/mantine/create_radio_group.js +4 -3
- package/.out/mantine/create_text_input.d.ts +2 -3
- package/.out/mantine/create_text_input.js +6 -5
- package/.out/mantine/create_value_input.d.ts +2 -3
- package/.out/mantine/create_value_input.js +6 -5
- package/.out/mantine/error_renderer.d.ts +6 -0
- package/.out/mantine/error_renderer.js +5 -0
- package/.out/mantine/hooks.d.ts +9 -13
- package/.out/mantine/hooks.js +10 -15
- package/.out/mantine/specs/checkbox_hooks.stories.d.ts +7 -2
- package/.out/mantine/specs/checkbox_hooks.stories.js +33 -6
- package/.out/mantine/specs/list_hooks.stories.js +2 -2
- package/.out/mantine/specs/radio_group_hooks.stories.d.ts +7 -2
- package/.out/mantine/specs/radio_group_hooks.stories.js +33 -6
- package/.out/mantine/specs/select_hooks.stories.d.ts +8 -2
- package/.out/mantine/specs/select_hooks.stories.js +45 -8
- package/.out/mantine/specs/text_input_hooks.stories.d.ts +5 -1
- package/.out/mantine/specs/text_input_hooks.stories.js +23 -8
- package/.out/mantine/specs/value_input_hooks.stories.d.ts +7 -2
- package/.out/mantine/specs/value_input_hooks.stories.js +49 -15
- package/.out/mantine/types.d.ts +4 -1
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/types/error_of_field.d.ts +2 -0
- package/.out/types/error_of_field.js +1 -0
- package/.out/types/field.d.ts +1 -1
- package/.out/types/field_converters.d.ts +17 -10
- package/.out/types/field_converters.js +5 -5
- package/.out/types/flattened_validators_of_fields.d.ts +8 -0
- package/.out/types/flattened_validators_of_fields.js +1 -0
- package/.out/types/merge_validators.d.ts +7 -0
- package/.out/types/merge_validators.js +38 -0
- package/.out/types/specs/flattened_validators_of_fields.tests.d.ts +1 -0
- package/.out/types/specs/flattened_validators_of_fields.tests.js +16 -0
- package/.out/types/specs/merge_validators.tests.d.ts +1 -0
- package/.out/types/specs/merge_validators.tests.js +192 -0
- package/.out/util/partial.d.ts +11 -5
- package/.out/util/partial.js +55 -15
- package/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/README.md +5 -1
- package/core/mobx/field_adapter.ts +15 -7
- package/core/mobx/field_adapter_builder.ts +39 -75
- package/core/mobx/field_adapters_of_values.ts +17 -0
- package/core/mobx/flattened_adapters_of_fields.ts +3 -3
- package/core/mobx/flattened_list_types_of_type.ts +17 -0
- package/core/mobx/form_fields_of_field_adapters.ts +16 -0
- package/core/mobx/form_presenter.ts +117 -104
- package/core/mobx/merge_field_adapters_with_two_way_converter.ts +68 -0
- package/core/mobx/merge_field_adapters_with_validators.ts +99 -0
- package/core/mobx/specs/fixtures.ts +73 -0
- package/core/mobx/specs/flattened_adapters_of_fields.tests.ts +23 -2
- package/core/mobx/specs/flattened_list_types_of_types.tests.ts +35 -0
- package/core/mobx/specs/form_presenter.tests.ts +248 -124
- package/core/mobx/specs/merge_field_adapters_with_two_way_converter.ts +140 -0
- package/core/mobx/specs/merge_field_adapters_with_validators.tests.ts +259 -0
- package/core/mobx/types.ts +3 -3
- package/dist/index.cjs +459 -211
- package/dist/index.d.cts +153 -111
- package/dist/index.d.ts +153 -111
- package/dist/index.js +453 -200
- package/field_converters/chain_field_converter.ts +37 -23
- package/field_converters/identity_converter.ts +14 -10
- package/field_converters/integer_to_string_converter.ts +15 -9
- package/field_converters/list_converter.ts +8 -3
- package/field_converters/maybe_identity_converter.ts +7 -4
- package/field_converters/nullable_to_boolean_converter.ts +23 -16
- package/field_converters/select_value_type_converter.ts +86 -26
- package/field_converters/specs/chain_field_converter.tests.ts +302 -0
- package/field_converters/trimming_string_converter.ts +11 -6
- package/field_converters/validating_converter.ts +21 -11
- package/index.ts +9 -2
- package/mantine/create_checkbox.tsx +15 -8
- package/mantine/create_list.tsx +1 -4
- package/mantine/create_pill.tsx +2 -2
- package/mantine/create_radio.tsx +1 -1
- package/mantine/create_radio_group.tsx +8 -6
- package/mantine/create_text_input.tsx +20 -8
- package/mantine/create_value_input.tsx +17 -8
- package/mantine/error_renderer.ts +15 -0
- package/mantine/hooks.tsx +25 -51
- package/mantine/specs/__snapshots__/checkbox_hooks.tests.tsx.snap +126 -0
- package/mantine/specs/__snapshots__/radio_group_hooks.tests.tsx.snap +356 -0
- package/mantine/specs/__snapshots__/select_hooks.tests.tsx.snap +208 -12
- package/mantine/specs/__snapshots__/text_input_hooks.tests.tsx.snap +45 -0
- package/mantine/specs/__snapshots__/value_input_hooks.tests.tsx.snap +194 -8
- package/mantine/specs/checkbox_hooks.stories.tsx +47 -7
- package/mantine/specs/list_hooks.stories.tsx +2 -2
- package/mantine/specs/radio_group_hooks.stories.tsx +47 -7
- package/mantine/specs/select_hooks.stories.tsx +55 -8
- package/mantine/specs/text_input_hooks.stories.tsx +32 -7
- package/mantine/specs/value_input_hooks.stories.tsx +57 -16
- package/mantine/types.ts +5 -1
- package/package.json +16 -4
- package/tsconfig.json +1 -0
- package/types/error_of_field.ts +3 -0
- package/types/field.ts +1 -1
- package/types/field_converters.ts +21 -10
- package/types/flattened_validators_of_fields.ts +34 -0
- package/types/merge_validators.ts +80 -0
- package/types/specs/error_type_of_field.tests.ts +2 -2
- package/types/specs/flattened_validators_of_fields.tests.ts +93 -0
- package/types/specs/merge_validators.tests.ts +267 -0
- package/util/partial.tsx +200 -16
- package/.out/core/mobx/flattened_list_type_defs_of.d.ts +0 -8
- package/.out/field_validators/minimum_string_length_field_validator.d.ts +0 -2
- package/.out/field_validators/minimum_string_length_field_validator.js +0 -8
- package/.out/types/error_type_of_field.d.ts +0 -2
- package/.out/types/field_validator.d.ts +0 -3
- package/.out/types/flattened_form_fields_of.d.ts +0 -9
- package/.out/types/specs/flattened_form_fields_of.tests.js +0 -13
- package/core/mobx/flattened_list_type_defs_of.ts +0 -17
- package/core/mobx/specs/flattened_list_type_defs_of.tests.ts +0 -35
- package/field_validators/minimum_string_length_field_validator.ts +0 -13
- package/mantine/specs/__snapshots__/check_box_hooks.tests.tsx.snap +0 -227
- package/types/error_type_of_field.ts +0 -3
- package/types/field_validator.ts +0 -7
- package/types/flattened_form_fields_of.ts +0 -16
- package/types/specs/flattened_form_fields_of.tests.ts +0 -43
- /package/.out/core/mobx/{flattened_list_type_defs_of.js → field_adapters_of_values.js} +0 -0
- /package/.out/core/mobx/{specs/flattened_list_type_defs_of.tests.d.ts → flattened_list_types_of_type.js} +0 -0
- /package/.out/{types/error_type_of_field.js → core/mobx/form_fields_of_field_adapters.js} +0 -0
- /package/.out/{types/field_validator.js → core/mobx/specs/flattened_list_types_of_types.tests.d.ts} +0 -0
- /package/.out/{types/flattened_form_fields_of.js → core/mobx/specs/merge_field_adapters_with_two_way_converter.d.ts} +0 -0
- /package/.out/{types/specs/flattened_form_fields_of.tests.d.ts → core/mobx/specs/merge_field_adapters_with_validators.tests.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -453,7 +453,16 @@ var require_react_dom = __commonJS({
|
|
|
453
453
|
import {
|
|
454
454
|
UnreachableError
|
|
455
455
|
} from "@strictly/base";
|
|
456
|
-
|
|
456
|
+
|
|
457
|
+
// types/field_converters.ts
|
|
458
|
+
var UnreliableFieldConversionType = /* @__PURE__ */ ((UnreliableFieldConversionType2) => {
|
|
459
|
+
UnreliableFieldConversionType2[UnreliableFieldConversionType2["Success"] = 0] = "Success";
|
|
460
|
+
UnreliableFieldConversionType2[UnreliableFieldConversionType2["Failure"] = 1] = "Failure";
|
|
461
|
+
return UnreliableFieldConversionType2;
|
|
462
|
+
})(UnreliableFieldConversionType || {});
|
|
463
|
+
|
|
464
|
+
// field_converters/chain_field_converter.ts
|
|
465
|
+
function chainUnreliableFieldConverter(from, to) {
|
|
457
466
|
return function(value, valuePath, context) {
|
|
458
467
|
const fromConversion = from(value, valuePath, context);
|
|
459
468
|
switch (fromConversion.type) {
|
|
@@ -490,20 +499,37 @@ function chainFieldConverter(from, to) {
|
|
|
490
499
|
}
|
|
491
500
|
};
|
|
492
501
|
}
|
|
493
|
-
function
|
|
502
|
+
function chainAnnotatedFieldConverter(from, to) {
|
|
494
503
|
return function(value, valuePath, context) {
|
|
495
|
-
const
|
|
496
|
-
|
|
504
|
+
const {
|
|
505
|
+
required: intermediateRequired,
|
|
506
|
+
readonly: intermediateDisabled,
|
|
507
|
+
value: intermediateValue
|
|
508
|
+
} = from(value, valuePath, context);
|
|
509
|
+
const {
|
|
510
|
+
required: finalRequired,
|
|
511
|
+
readonly: finalDisabled,
|
|
512
|
+
value: finalValue
|
|
513
|
+
} = to(intermediateValue, valuePath, context);
|
|
514
|
+
return {
|
|
515
|
+
value: finalValue,
|
|
516
|
+
required: intermediateRequired || finalRequired,
|
|
517
|
+
readonly: intermediateDisabled || finalDisabled
|
|
518
|
+
};
|
|
497
519
|
};
|
|
498
520
|
}
|
|
499
521
|
|
|
500
522
|
// field_converters/identity_converter.ts
|
|
501
|
-
function
|
|
502
|
-
return function(
|
|
503
|
-
return
|
|
523
|
+
function annotatedIdentityConverter(required = false) {
|
|
524
|
+
return function(value) {
|
|
525
|
+
return {
|
|
526
|
+
value,
|
|
527
|
+
required,
|
|
528
|
+
readonly: false
|
|
529
|
+
};
|
|
504
530
|
};
|
|
505
531
|
}
|
|
506
|
-
function
|
|
532
|
+
function unreliableIdentityConverter() {
|
|
507
533
|
return function(value) {
|
|
508
534
|
return {
|
|
509
535
|
type: 0 /* Success */,
|
|
@@ -515,9 +541,14 @@ function identityConverter() {
|
|
|
515
541
|
// field_converters/list_converter.ts
|
|
516
542
|
function listConverter() {
|
|
517
543
|
return function(from, valuePath) {
|
|
518
|
-
|
|
544
|
+
const value = from.map(function(_v, i) {
|
|
519
545
|
return `${valuePath}.${i}`;
|
|
520
546
|
});
|
|
547
|
+
return {
|
|
548
|
+
value,
|
|
549
|
+
required: false,
|
|
550
|
+
readonly: false
|
|
551
|
+
};
|
|
521
552
|
};
|
|
522
553
|
}
|
|
523
554
|
|
|
@@ -531,36 +562,11 @@ var MaybeIdentityConverter = class {
|
|
|
531
562
|
return this.converter.convert(from, valuePath, context);
|
|
532
563
|
}
|
|
533
564
|
revert(from, valuePath, context) {
|
|
534
|
-
const value = this.isFrom(from) ? this.converter.convert(from, valuePath, context) : from;
|
|
565
|
+
const value = this.isFrom(from) ? this.converter.convert(from, valuePath, context).value : from;
|
|
535
566
|
return this.converter.revert(value, valuePath, context);
|
|
536
567
|
}
|
|
537
568
|
};
|
|
538
569
|
|
|
539
|
-
// field_converters/validating_converter.ts
|
|
540
|
-
function validatingConverter(validators = []) {
|
|
541
|
-
return function(value, valuePath, context) {
|
|
542
|
-
return validators.reduce(
|
|
543
|
-
function(acc, validator) {
|
|
544
|
-
if (acc.type === 0 /* Success */) {
|
|
545
|
-
const error2 = validator(value, valuePath, context);
|
|
546
|
-
if (error2 != null) {
|
|
547
|
-
return {
|
|
548
|
-
type: 1 /* Failure */,
|
|
549
|
-
error: error2,
|
|
550
|
-
value: [value]
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return acc;
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
type: 0 /* Success */,
|
|
558
|
-
value
|
|
559
|
-
}
|
|
560
|
-
);
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
|
|
564
570
|
// field_value_factories/prototyping_field_value_factory.ts
|
|
565
571
|
function prototypingFieldValueFactory(prototype) {
|
|
566
572
|
return function() {
|
|
@@ -575,34 +581,14 @@ var FieldAdapterBuilder = class _FieldAdapterBuilder {
|
|
|
575
581
|
this.create = create;
|
|
576
582
|
this.revert = revert;
|
|
577
583
|
}
|
|
578
|
-
validateFrom(...validators) {
|
|
579
|
-
return new _FieldAdapterBuilder(
|
|
580
|
-
this.convert,
|
|
581
|
-
this.create,
|
|
582
|
-
this.revert && chainFieldConverter(
|
|
583
|
-
this.revert,
|
|
584
|
-
validatingConverter(validators)
|
|
585
|
-
)
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
validateTo(...validators) {
|
|
589
|
-
return new _FieldAdapterBuilder(
|
|
590
|
-
this.convert,
|
|
591
|
-
this.create,
|
|
592
|
-
this.revert && chainFieldConverter(
|
|
593
|
-
validatingConverter(validators),
|
|
594
|
-
this.revert
|
|
595
|
-
)
|
|
596
|
-
);
|
|
597
|
-
}
|
|
598
584
|
chain(converter, reverter) {
|
|
599
585
|
return new _FieldAdapterBuilder(
|
|
600
|
-
|
|
586
|
+
chainAnnotatedFieldConverter(
|
|
601
587
|
this.convert,
|
|
602
588
|
converter
|
|
603
589
|
),
|
|
604
590
|
this.create,
|
|
605
|
-
this.revert && reverter &&
|
|
591
|
+
this.revert && reverter && chainUnreliableFieldConverter(
|
|
606
592
|
reverter,
|
|
607
593
|
this.revert
|
|
608
594
|
)
|
|
@@ -616,17 +602,20 @@ var FieldAdapterBuilder = class _FieldAdapterBuilder {
|
|
|
616
602
|
);
|
|
617
603
|
}
|
|
618
604
|
withIdentity(isFrom) {
|
|
619
|
-
const
|
|
605
|
+
const identityConverter = new MaybeIdentityConverter({
|
|
620
606
|
convert: this.convert,
|
|
621
607
|
// should never get called if null
|
|
622
608
|
revert: this.revert
|
|
623
609
|
}, isFrom);
|
|
624
610
|
return new _FieldAdapterBuilder(
|
|
625
|
-
|
|
611
|
+
identityConverter.convert.bind(identityConverter),
|
|
626
612
|
this.create,
|
|
627
|
-
this.revert &&
|
|
613
|
+
this.revert && identityConverter.revert.bind(identityConverter)
|
|
628
614
|
);
|
|
629
615
|
}
|
|
616
|
+
get narrow() {
|
|
617
|
+
return this;
|
|
618
|
+
}
|
|
630
619
|
};
|
|
631
620
|
function adapter(converter, valueFactory, reverter) {
|
|
632
621
|
return new FieldAdapterBuilder(converter, valueFactory, reverter);
|
|
@@ -642,11 +631,11 @@ function adapterFromPrototype(converter, prototype) {
|
|
|
642
631
|
const factory2 = prototypingFieldValueFactory(prototype);
|
|
643
632
|
return typeof converter === "function" ? new FieldAdapterBuilder(converter, factory2) : new FieldAdapterBuilder(converter.convert.bind(converter), factory2, converter.revert.bind(converter));
|
|
644
633
|
}
|
|
645
|
-
function identityAdapter(prototype) {
|
|
634
|
+
function identityAdapter(prototype, required) {
|
|
646
635
|
return new FieldAdapterBuilder(
|
|
647
|
-
|
|
636
|
+
annotatedIdentityConverter(required),
|
|
648
637
|
prototypingFieldValueFactory(prototype),
|
|
649
|
-
|
|
638
|
+
unreliableIdentityConverter()
|
|
650
639
|
);
|
|
651
640
|
}
|
|
652
641
|
function listAdapter() {
|
|
@@ -662,13 +651,15 @@ import {
|
|
|
662
651
|
assertExistsAndReturn,
|
|
663
652
|
assertState,
|
|
664
653
|
checkValidNumber,
|
|
654
|
+
map,
|
|
665
655
|
toArray,
|
|
666
656
|
UnreachableError as UnreachableError2
|
|
667
657
|
} from "@strictly/base";
|
|
668
658
|
import {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
659
|
+
flattenAccessorsOfType,
|
|
660
|
+
flattenTypesOfType,
|
|
661
|
+
flattenValuesOfType,
|
|
662
|
+
flattenValueTo,
|
|
672
663
|
jsonPathPop,
|
|
673
664
|
mobxCopy,
|
|
674
665
|
valuePathToTypePath
|
|
@@ -679,12 +670,12 @@ import {
|
|
|
679
670
|
runInAction
|
|
680
671
|
} from "mobx";
|
|
681
672
|
var FormPresenter = class {
|
|
682
|
-
constructor(
|
|
683
|
-
this.
|
|
673
|
+
constructor(type, adapters) {
|
|
674
|
+
this.type = type;
|
|
684
675
|
this.adapters = adapters;
|
|
685
676
|
}
|
|
686
677
|
maybeGetAdapterForValuePath(valuePath) {
|
|
687
|
-
const typePath = valuePathToTypePath(this.
|
|
678
|
+
const typePath = valuePathToTypePath(this.type, valuePath, true);
|
|
688
679
|
return this.adapters[typePath];
|
|
689
680
|
}
|
|
690
681
|
getAdapterForValuePath(valuePath) {
|
|
@@ -695,7 +686,7 @@ var FormPresenter = class {
|
|
|
695
686
|
);
|
|
696
687
|
}
|
|
697
688
|
typePath(valuePath) {
|
|
698
|
-
return valuePathToTypePath(this.
|
|
689
|
+
return valuePathToTypePath(this.type, valuePath, true);
|
|
699
690
|
}
|
|
700
691
|
setFieldValueAndValidate(model, valuePath, value) {
|
|
701
692
|
return this.internalSetFieldValue(model, valuePath, value, true);
|
|
@@ -703,7 +694,7 @@ var FormPresenter = class {
|
|
|
703
694
|
setFieldValue(model, valuePath, value) {
|
|
704
695
|
return this.internalSetFieldValue(model, valuePath, value, false);
|
|
705
696
|
}
|
|
706
|
-
addListItem(model, valuePath, elementValue, index3) {
|
|
697
|
+
addListItem(model, valuePath, elementValue = null, index3) {
|
|
707
698
|
const listValuePath = valuePath;
|
|
708
699
|
const accessor = model.accessors[valuePath];
|
|
709
700
|
const listTypePath = this.typePath(valuePath);
|
|
@@ -836,9 +827,7 @@ var FormPresenter = class {
|
|
|
836
827
|
const conversion = revert(value, valuePath, model.value);
|
|
837
828
|
const accessor = model.getAccessorForValuePath(valuePath);
|
|
838
829
|
return runInAction(() => {
|
|
839
|
-
model.fieldOverrides[valuePath] =
|
|
840
|
-
value
|
|
841
|
-
};
|
|
830
|
+
model.fieldOverrides[valuePath] = [value];
|
|
842
831
|
switch (conversion.type) {
|
|
843
832
|
case 1 /* Failure */:
|
|
844
833
|
if (displayValidation) {
|
|
@@ -877,20 +866,26 @@ var FormPresenter = class {
|
|
|
877
866
|
} = adapter2;
|
|
878
867
|
const accessor = model.accessors[valuePath];
|
|
879
868
|
const value = accessor == null ? create(valuePath, model.value) : accessor.value;
|
|
880
|
-
const
|
|
869
|
+
const {
|
|
870
|
+
value: displayValue
|
|
871
|
+
} = convert(value, valuePath, model.value);
|
|
872
|
+
const key = valuePath;
|
|
881
873
|
runInAction(function() {
|
|
882
|
-
model.fieldOverrides[
|
|
883
|
-
value: displayValue
|
|
884
|
-
};
|
|
874
|
+
model.fieldOverrides[key] = [displayValue];
|
|
885
875
|
});
|
|
886
876
|
}
|
|
887
877
|
clearAll(model, value) {
|
|
888
878
|
runInAction(() => {
|
|
889
879
|
model.errors = {};
|
|
890
880
|
model.fieldOverrides = {};
|
|
891
|
-
model.value = mobxCopy(this.
|
|
881
|
+
model.value = mobxCopy(this.type, value);
|
|
892
882
|
});
|
|
893
883
|
}
|
|
884
|
+
isValuePathActive(model, valuePath) {
|
|
885
|
+
const values2 = flattenValuesOfType(this.type, model.value);
|
|
886
|
+
const keys2 = new Set(Object.keys(values2));
|
|
887
|
+
return keys2.has(valuePath);
|
|
888
|
+
}
|
|
894
889
|
validateField(model, valuePath) {
|
|
895
890
|
const {
|
|
896
891
|
convert,
|
|
@@ -899,13 +894,15 @@ var FormPresenter = class {
|
|
|
899
894
|
} = this.getAdapterForValuePath(valuePath);
|
|
900
895
|
const fieldOverride = model.fieldOverrides[valuePath];
|
|
901
896
|
const accessor = model.getAccessorForValuePath(valuePath);
|
|
902
|
-
const
|
|
897
|
+
const {
|
|
898
|
+
value: storedValue
|
|
899
|
+
} = convert(
|
|
903
900
|
accessor != null ? accessor.value : create(valuePath, model.value),
|
|
904
901
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
905
902
|
valuePath,
|
|
906
903
|
model.value
|
|
907
904
|
);
|
|
908
|
-
const value = fieldOverride != null ? fieldOverride
|
|
905
|
+
const value = fieldOverride != null ? fieldOverride[0] : storedValue;
|
|
909
906
|
const dirty = storedValue !== value;
|
|
910
907
|
assertExists(revert, "changing field directly not supported {}", valuePath);
|
|
911
908
|
const conversion = revert(value, valuePath, model.value);
|
|
@@ -951,9 +948,11 @@ var FormPresenter = class {
|
|
|
951
948
|
return success;
|
|
952
949
|
}
|
|
953
950
|
const fieldOverride = model.fieldOverrides[adapterPath];
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
951
|
+
const {
|
|
952
|
+
value: storedValue
|
|
953
|
+
} = convert(accessor.value, valuePath, model.value);
|
|
954
|
+
const value = fieldOverride != null ? fieldOverride[0] : storedValue;
|
|
955
|
+
const dirty = fieldOverride != null && fieldOverride[0] !== storedValue;
|
|
957
956
|
const conversion = revert(value, valuePath, model.value);
|
|
958
957
|
switch (conversion.type) {
|
|
959
958
|
case 1 /* Failure */:
|
|
@@ -978,20 +977,20 @@ var FormPresenter = class {
|
|
|
978
977
|
}
|
|
979
978
|
createModel(value) {
|
|
980
979
|
return new FormModel(
|
|
981
|
-
this.
|
|
980
|
+
this.type,
|
|
982
981
|
value,
|
|
983
982
|
this.adapters
|
|
984
983
|
);
|
|
985
984
|
}
|
|
986
985
|
};
|
|
987
986
|
var FormModel = class {
|
|
988
|
-
constructor(
|
|
989
|
-
this.
|
|
987
|
+
constructor(type, value, adapters) {
|
|
988
|
+
this.type = type;
|
|
990
989
|
this.adapters = adapters;
|
|
991
|
-
this.value = mobxCopy(
|
|
992
|
-
this.flattenedTypeDefs =
|
|
993
|
-
|
|
994
|
-
|
|
990
|
+
this.value = mobxCopy(type, value);
|
|
991
|
+
this.flattenedTypeDefs = flattenTypesOfType(type);
|
|
992
|
+
const conversions = flattenValueTo(
|
|
993
|
+
type,
|
|
995
994
|
this.value,
|
|
996
995
|
() => {
|
|
997
996
|
},
|
|
@@ -1007,12 +1006,12 @@ var FormModel = class {
|
|
|
1007
1006
|
if (revert == null) {
|
|
1008
1007
|
return;
|
|
1009
1008
|
}
|
|
1010
|
-
|
|
1011
|
-
return {
|
|
1012
|
-
value: displayValue
|
|
1013
|
-
};
|
|
1009
|
+
return convert(value2, valuePath, this.value);
|
|
1014
1010
|
}
|
|
1015
1011
|
);
|
|
1012
|
+
this.fieldOverrides = map(conversions, function(_k, v) {
|
|
1013
|
+
return v && [v.value];
|
|
1014
|
+
});
|
|
1016
1015
|
}
|
|
1017
1016
|
@observable.ref
|
|
1018
1017
|
accessor value;
|
|
@@ -1040,8 +1039,8 @@ var FormModel = class {
|
|
|
1040
1039
|
}
|
|
1041
1040
|
@computed
|
|
1042
1041
|
get knownFields() {
|
|
1043
|
-
return
|
|
1044
|
-
this.
|
|
1042
|
+
return flattenValueTo(
|
|
1043
|
+
this.type,
|
|
1045
1044
|
this.value,
|
|
1046
1045
|
() => {
|
|
1047
1046
|
},
|
|
@@ -1060,7 +1059,7 @@ var FormModel = class {
|
|
|
1060
1059
|
let typePath;
|
|
1061
1060
|
try {
|
|
1062
1061
|
typePath = valuePathToTypePath(
|
|
1063
|
-
this.
|
|
1062
|
+
this.type,
|
|
1064
1063
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1065
1064
|
valuePath,
|
|
1066
1065
|
true
|
|
@@ -1082,7 +1081,11 @@ var FormModel = class {
|
|
|
1082
1081
|
const fieldOverride = this.fieldOverrides[valuePath];
|
|
1083
1082
|
const accessor = this.getAccessorForValuePath(valuePath);
|
|
1084
1083
|
const fieldTypeDef = this.flattenedTypeDefs[typePath];
|
|
1085
|
-
const
|
|
1084
|
+
const {
|
|
1085
|
+
value,
|
|
1086
|
+
required,
|
|
1087
|
+
readonly
|
|
1088
|
+
} = convert(
|
|
1086
1089
|
accessor != null ? accessor.value : fieldTypeDef != null ? mobxCopy(
|
|
1087
1090
|
fieldTypeDef,
|
|
1088
1091
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
@@ -1094,11 +1097,10 @@ var FormModel = class {
|
|
|
1094
1097
|
);
|
|
1095
1098
|
const error2 = this.errors[valuePath];
|
|
1096
1099
|
return {
|
|
1097
|
-
value,
|
|
1100
|
+
value: fieldOverride != null ? fieldOverride[0] : value,
|
|
1098
1101
|
error: error2,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
required: this.isRequired(valuePath)
|
|
1102
|
+
readonly,
|
|
1103
|
+
required
|
|
1102
1104
|
};
|
|
1103
1105
|
}
|
|
1104
1106
|
getAccessorForValuePath(valuePath) {
|
|
@@ -1107,32 +1109,110 @@ var FormModel = class {
|
|
|
1107
1109
|
@computed
|
|
1108
1110
|
// should only be referenced internally, so loosely typed
|
|
1109
1111
|
get accessors() {
|
|
1110
|
-
return
|
|
1111
|
-
this.
|
|
1112
|
+
return flattenAccessorsOfType(
|
|
1113
|
+
this.type,
|
|
1112
1114
|
this.value,
|
|
1113
1115
|
(value) => {
|
|
1114
|
-
this.value = mobxCopy(this.
|
|
1116
|
+
this.value = mobxCopy(this.type, value);
|
|
1115
1117
|
}
|
|
1116
1118
|
);
|
|
1117
1119
|
}
|
|
1118
|
-
isDisabled(_valuePath) {
|
|
1119
|
-
return false;
|
|
1120
|
-
}
|
|
1121
|
-
isRequired(_valuePath) {
|
|
1122
|
-
return false;
|
|
1123
|
-
}
|
|
1124
1120
|
};
|
|
1125
1121
|
|
|
1122
|
+
// core/mobx/merge_field_adapters_with_two_way_converter.ts
|
|
1123
|
+
import { map as map2 } from "@strictly/base";
|
|
1124
|
+
function mergeFieldAdaptersWithTwoWayConverter(fieldAdapters, converter) {
|
|
1125
|
+
return map2(
|
|
1126
|
+
fieldAdapters,
|
|
1127
|
+
function(_key, adapter2) {
|
|
1128
|
+
return {
|
|
1129
|
+
convert: chainAnnotatedFieldConverter(
|
|
1130
|
+
adapter2.convert.bind(adapter2),
|
|
1131
|
+
converter.convert.bind(converter)
|
|
1132
|
+
),
|
|
1133
|
+
revert: adapter2.revert && chainUnreliableFieldConverter(
|
|
1134
|
+
converter.revert.bind(converter),
|
|
1135
|
+
adapter2.revert.bind(adapter2)
|
|
1136
|
+
),
|
|
1137
|
+
create: adapter2.create.bind(adapter2)
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// core/mobx/merge_field_adapters_with_validators.ts
|
|
1144
|
+
import { reduce } from "@strictly/base";
|
|
1145
|
+
import {
|
|
1146
|
+
annotations,
|
|
1147
|
+
validate
|
|
1148
|
+
} from "@strictly/define";
|
|
1149
|
+
function mergeAdaptersWithValidators(adapters, validators) {
|
|
1150
|
+
return reduce(
|
|
1151
|
+
adapters,
|
|
1152
|
+
function(acc, key, adapter2) {
|
|
1153
|
+
const validator = validators[key];
|
|
1154
|
+
if (validator == null) {
|
|
1155
|
+
acc[key] = adapter2;
|
|
1156
|
+
return acc;
|
|
1157
|
+
}
|
|
1158
|
+
function revert(to, ...params) {
|
|
1159
|
+
const result = adapter2.revert(to, ...params);
|
|
1160
|
+
if (result.type === 1 /* Failure */) {
|
|
1161
|
+
return result;
|
|
1162
|
+
}
|
|
1163
|
+
const validationError = validate(validator, result.value, ...params);
|
|
1164
|
+
if (validationError == null) {
|
|
1165
|
+
return result;
|
|
1166
|
+
}
|
|
1167
|
+
return {
|
|
1168
|
+
type: 1 /* Failure */,
|
|
1169
|
+
value: [result.value],
|
|
1170
|
+
error: validationError
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
function convert(from, ...params) {
|
|
1174
|
+
const {
|
|
1175
|
+
required: required1,
|
|
1176
|
+
readonly: readonly1,
|
|
1177
|
+
value
|
|
1178
|
+
} = adapter2.convert(from, ...params);
|
|
1179
|
+
const {
|
|
1180
|
+
required: required2,
|
|
1181
|
+
readonly: readonly2
|
|
1182
|
+
} = annotations(validator, ...params);
|
|
1183
|
+
return {
|
|
1184
|
+
value,
|
|
1185
|
+
required: required1 || required2,
|
|
1186
|
+
readonly: readonly1 || readonly2
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
acc[key] = {
|
|
1190
|
+
...adapter2,
|
|
1191
|
+
convert,
|
|
1192
|
+
revert: adapter2.revert && revert
|
|
1193
|
+
};
|
|
1194
|
+
return acc;
|
|
1195
|
+
},
|
|
1196
|
+
{}
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1126
1200
|
// field_converters/integer_to_string_converter.ts
|
|
1127
1201
|
var IntegerToStringConverter = class {
|
|
1128
|
-
constructor(isNanError) {
|
|
1202
|
+
constructor(isNanError, base = 10) {
|
|
1129
1203
|
this.isNanError = isNanError;
|
|
1204
|
+
this.base = base;
|
|
1130
1205
|
}
|
|
1131
1206
|
convert(from) {
|
|
1132
|
-
|
|
1207
|
+
const value = Math.floor(from).toString();
|
|
1208
|
+
return {
|
|
1209
|
+
value,
|
|
1210
|
+
required: false,
|
|
1211
|
+
readonly: false
|
|
1212
|
+
};
|
|
1133
1213
|
}
|
|
1134
1214
|
revert(from) {
|
|
1135
|
-
const value = parseInt(from,
|
|
1215
|
+
const value = parseInt(from, this.base);
|
|
1136
1216
|
if (Number.isNaN(value)) {
|
|
1137
1217
|
return {
|
|
1138
1218
|
type: 1 /* Failure */,
|
|
@@ -1153,14 +1233,19 @@ import {
|
|
|
1153
1233
|
copy
|
|
1154
1234
|
} from "@strictly/define";
|
|
1155
1235
|
var NullableToBooleanConverter = class {
|
|
1156
|
-
constructor(typeDef, prototype, defaultToNull = true) {
|
|
1236
|
+
constructor(typeDef, prototype, nullType, defaultToNull = true) {
|
|
1157
1237
|
this.typeDef = typeDef;
|
|
1158
1238
|
this.prototype = prototype;
|
|
1159
|
-
this.
|
|
1239
|
+
this.nullType = nullType;
|
|
1240
|
+
this.defaultValue = defaultToNull ? this.nullType : prototype;
|
|
1160
1241
|
}
|
|
1161
1242
|
defaultValue;
|
|
1162
1243
|
convert(from) {
|
|
1163
|
-
return
|
|
1244
|
+
return {
|
|
1245
|
+
value: from !== this.nullType,
|
|
1246
|
+
required: false,
|
|
1247
|
+
readonly: false
|
|
1248
|
+
};
|
|
1164
1249
|
}
|
|
1165
1250
|
revert(from) {
|
|
1166
1251
|
if (from) {
|
|
@@ -1172,7 +1257,7 @@ var NullableToBooleanConverter = class {
|
|
|
1172
1257
|
}
|
|
1173
1258
|
return {
|
|
1174
1259
|
type: 0 /* Success */,
|
|
1175
|
-
value:
|
|
1260
|
+
value: this.nullType
|
|
1176
1261
|
};
|
|
1177
1262
|
}
|
|
1178
1263
|
create() {
|
|
@@ -1188,11 +1273,12 @@ import {
|
|
|
1188
1273
|
copy as copy2
|
|
1189
1274
|
} from "@strictly/define";
|
|
1190
1275
|
var AbstractSelectValueTypeConverter = class {
|
|
1191
|
-
constructor(typeDef, values2, defaultValueKey, noSuchValueError) {
|
|
1276
|
+
constructor(typeDef, values2, defaultValueKey, noSuchValueError, required) {
|
|
1192
1277
|
this.typeDef = typeDef;
|
|
1193
1278
|
this.values = values2;
|
|
1194
1279
|
this.defaultValueKey = defaultValueKey;
|
|
1195
1280
|
this.noSuchValueError = noSuchValueError;
|
|
1281
|
+
this.required = required;
|
|
1196
1282
|
}
|
|
1197
1283
|
revert(from) {
|
|
1198
1284
|
const prototype = from == null ? null : this.values[from];
|
|
@@ -1203,29 +1289,32 @@ var AbstractSelectValueTypeConverter = class {
|
|
|
1203
1289
|
value: null
|
|
1204
1290
|
};
|
|
1205
1291
|
}
|
|
1206
|
-
const value = prototype == null ?
|
|
1292
|
+
const value = prototype == null ? prototype : copy2(this.typeDef, prototype);
|
|
1207
1293
|
return {
|
|
1208
1294
|
type: 0 /* Success */,
|
|
1209
1295
|
value
|
|
1210
1296
|
};
|
|
1211
1297
|
}
|
|
1212
1298
|
convert(from) {
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1299
|
+
const value = from == null ? from : this.doConvert(from);
|
|
1300
|
+
return {
|
|
1301
|
+
value,
|
|
1302
|
+
required: this.required,
|
|
1303
|
+
readonly: false
|
|
1304
|
+
};
|
|
1217
1305
|
}
|
|
1218
1306
|
create() {
|
|
1219
1307
|
return this.defaultValueKey != null ? this.values[this.defaultValueKey] : null;
|
|
1220
1308
|
}
|
|
1221
1309
|
};
|
|
1222
1310
|
var SelectDiscriminatedUnionConverter = class extends AbstractSelectValueTypeConverter {
|
|
1223
|
-
constructor(
|
|
1311
|
+
constructor(type, values2, defaultValueKey, required) {
|
|
1224
1312
|
super(
|
|
1225
|
-
|
|
1313
|
+
type,
|
|
1226
1314
|
values2,
|
|
1227
1315
|
defaultValueKey,
|
|
1228
|
-
null
|
|
1316
|
+
null,
|
|
1317
|
+
required
|
|
1229
1318
|
);
|
|
1230
1319
|
}
|
|
1231
1320
|
doConvert(from) {
|
|
@@ -1238,17 +1327,38 @@ var SelectDiscriminatedUnionConverter = class extends AbstractSelectValueTypeCon
|
|
|
1238
1327
|
}
|
|
1239
1328
|
};
|
|
1240
1329
|
var SelectLiteralConverter = class extends AbstractSelectValueTypeConverter {
|
|
1241
|
-
constructor(typeDef, valuesToStrings, defaultValue, noSuchValueError) {
|
|
1330
|
+
constructor(typeDef, valuesToStrings, defaultValue, noSuchValueError, required) {
|
|
1242
1331
|
super(
|
|
1243
1332
|
typeDef,
|
|
1244
1333
|
reverse(valuesToStrings),
|
|
1245
1334
|
defaultValue && valuesToStrings[defaultValue],
|
|
1246
|
-
noSuchValueError
|
|
1335
|
+
noSuchValueError,
|
|
1336
|
+
required
|
|
1247
1337
|
);
|
|
1248
1338
|
this.valuesToStrings = valuesToStrings;
|
|
1249
1339
|
}
|
|
1250
1340
|
doConvert(from) {
|
|
1251
|
-
return
|
|
1341
|
+
return this.valuesToStrings[from];
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
var SelectStringConverter = class extends AbstractSelectValueTypeConverter {
|
|
1345
|
+
constructor(typeDef, allowedValues, defaultValue, noSuchValueError, required = false) {
|
|
1346
|
+
super(
|
|
1347
|
+
typeDef,
|
|
1348
|
+
allowedValues.reduce(
|
|
1349
|
+
function(acc, value) {
|
|
1350
|
+
acc[value] = value;
|
|
1351
|
+
return acc;
|
|
1352
|
+
},
|
|
1353
|
+
{}
|
|
1354
|
+
),
|
|
1355
|
+
defaultValue,
|
|
1356
|
+
noSuchValueError,
|
|
1357
|
+
required
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
doConvert(from) {
|
|
1361
|
+
return from;
|
|
1252
1362
|
}
|
|
1253
1363
|
};
|
|
1254
1364
|
|
|
@@ -1257,7 +1367,11 @@ var TrimmingStringConverter = class {
|
|
|
1257
1367
|
constructor() {
|
|
1258
1368
|
}
|
|
1259
1369
|
convert(to) {
|
|
1260
|
-
return
|
|
1370
|
+
return {
|
|
1371
|
+
value: to.trim(),
|
|
1372
|
+
required: false,
|
|
1373
|
+
readonly: false
|
|
1374
|
+
};
|
|
1261
1375
|
}
|
|
1262
1376
|
revert(from) {
|
|
1263
1377
|
return {
|
|
@@ -1267,16 +1381,42 @@ var TrimmingStringConverter = class {
|
|
|
1267
1381
|
}
|
|
1268
1382
|
};
|
|
1269
1383
|
|
|
1270
|
-
//
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
return
|
|
1384
|
+
// field_converters/validating_converter.ts
|
|
1385
|
+
import {
|
|
1386
|
+
validate as validate2
|
|
1387
|
+
} from "@strictly/define";
|
|
1388
|
+
function validatingConverter(validators = []) {
|
|
1389
|
+
return function(value, valuePath, context) {
|
|
1390
|
+
return validators.reduce(
|
|
1391
|
+
function(acc, validator) {
|
|
1392
|
+
if (acc.type === 0 /* Success */) {
|
|
1393
|
+
const error2 = validate2(validator, value, valuePath, context);
|
|
1394
|
+
if (error2 != null) {
|
|
1395
|
+
return {
|
|
1396
|
+
type: 1 /* Failure */,
|
|
1397
|
+
error: error2,
|
|
1398
|
+
value: [value]
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
return acc;
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
type: 0 /* Success */,
|
|
1406
|
+
value
|
|
1407
|
+
}
|
|
1408
|
+
);
|
|
1277
1409
|
};
|
|
1278
1410
|
}
|
|
1279
1411
|
|
|
1412
|
+
// mantine/error_renderer.ts
|
|
1413
|
+
function DefaultErrorRenderer({
|
|
1414
|
+
error: error2
|
|
1415
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1416
|
+
}) {
|
|
1417
|
+
return error2;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1280
1420
|
// ../../node_modules/@mantine/core/esm/core/utils/keys/keys.mjs
|
|
1281
1421
|
function keys(object) {
|
|
1282
1422
|
return Object.keys(object);
|
|
@@ -6721,18 +6861,18 @@ function error() {
|
|
|
6721
6861
|
}
|
|
6722
6862
|
}
|
|
6723
6863
|
function createPubSub() {
|
|
6724
|
-
const
|
|
6864
|
+
const map3 = /* @__PURE__ */ new Map();
|
|
6725
6865
|
return {
|
|
6726
6866
|
emit(event, data) {
|
|
6727
6867
|
var _map$get;
|
|
6728
|
-
(_map$get =
|
|
6868
|
+
(_map$get = map3.get(event)) == null || _map$get.forEach((handler) => handler(data));
|
|
6729
6869
|
},
|
|
6730
6870
|
on(event, listener) {
|
|
6731
|
-
|
|
6871
|
+
map3.set(event, [...map3.get(event) || [], listener]);
|
|
6732
6872
|
},
|
|
6733
6873
|
off(event, listener) {
|
|
6734
6874
|
var _map$get2;
|
|
6735
|
-
|
|
6875
|
+
map3.set(event, ((_map$get2 = map3.get(event)) == null ? void 0 : _map$get2.filter((l) => l !== listener)) || []);
|
|
6736
6876
|
}
|
|
6737
6877
|
};
|
|
6738
6878
|
}
|
|
@@ -10990,11 +11130,37 @@ function createSimplePartialComponent(Component, curriedProps) {
|
|
|
10990
11130
|
}
|
|
10991
11131
|
);
|
|
10992
11132
|
}
|
|
10993
|
-
function createPartialComponent(Component, curriedPropsSource) {
|
|
11133
|
+
function createPartialComponent(Component, curriedPropsSource, additionalPropKeys = []) {
|
|
10994
11134
|
return forwardRef22(
|
|
10995
|
-
function(
|
|
11135
|
+
function(props, ref) {
|
|
10996
11136
|
const C = Component;
|
|
10997
|
-
const
|
|
11137
|
+
const [
|
|
11138
|
+
additionalProps,
|
|
11139
|
+
exposedProps
|
|
11140
|
+
] = additionalPropKeys.reduce(
|
|
11141
|
+
function([
|
|
11142
|
+
additionalProps2,
|
|
11143
|
+
exposedProps2
|
|
11144
|
+
], key) {
|
|
11145
|
+
const value = props[
|
|
11146
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11147
|
+
key
|
|
11148
|
+
];
|
|
11149
|
+
delete exposedProps2[key];
|
|
11150
|
+
additionalProps2[key] = value;
|
|
11151
|
+
return [
|
|
11152
|
+
additionalProps2,
|
|
11153
|
+
exposedProps2
|
|
11154
|
+
];
|
|
11155
|
+
},
|
|
11156
|
+
[
|
|
11157
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11158
|
+
{},
|
|
11159
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11160
|
+
{ ...props }
|
|
11161
|
+
]
|
|
11162
|
+
);
|
|
11163
|
+
const curriedProps = curriedPropsSource(additionalProps);
|
|
10998
11164
|
return /* @__PURE__ */ jsx71(
|
|
10999
11165
|
C,
|
|
11000
11166
|
{
|
|
@@ -11006,28 +11172,64 @@ function createPartialComponent(Component, curriedPropsSource) {
|
|
|
11006
11172
|
}
|
|
11007
11173
|
);
|
|
11008
11174
|
}
|
|
11009
|
-
function usePartialComponent(
|
|
11175
|
+
function usePartialComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
|
|
11010
11176
|
return useMemo6(
|
|
11011
11177
|
function() {
|
|
11012
|
-
return createPartialComponent(
|
|
11178
|
+
return createPartialComponent(
|
|
11179
|
+
Component,
|
|
11180
|
+
curriedPropsSource,
|
|
11181
|
+
additionalPropKeys
|
|
11182
|
+
);
|
|
11013
11183
|
},
|
|
11014
11184
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11015
11185
|
[
|
|
11016
11186
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11017
11187
|
...deps,
|
|
11018
|
-
Component
|
|
11188
|
+
Component,
|
|
11189
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11190
|
+
...additionalPropKeys
|
|
11019
11191
|
]
|
|
11020
11192
|
);
|
|
11021
11193
|
}
|
|
11022
|
-
function createPartialObserverComponent(Component, curriedPropsSource) {
|
|
11023
|
-
return createUnsafePartialObserverComponent(
|
|
11194
|
+
function createPartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
|
|
11195
|
+
return createUnsafePartialObserverComponent(
|
|
11196
|
+
Component,
|
|
11197
|
+
curriedPropsSource,
|
|
11198
|
+
additionalPropKeys
|
|
11199
|
+
);
|
|
11024
11200
|
}
|
|
11025
|
-
function createUnsafePartialObserverComponent(Component, curriedPropsSource) {
|
|
11201
|
+
function createUnsafePartialObserverComponent(Component, curriedPropsSource, additionalPropKeys = []) {
|
|
11026
11202
|
return observer(
|
|
11027
11203
|
forwardRef22(
|
|
11028
|
-
function(
|
|
11204
|
+
function(props, ref) {
|
|
11029
11205
|
const C = Component;
|
|
11030
|
-
const
|
|
11206
|
+
const [
|
|
11207
|
+
additionalProps,
|
|
11208
|
+
exposedProps
|
|
11209
|
+
] = additionalPropKeys.reduce(
|
|
11210
|
+
function([
|
|
11211
|
+
additionalProps2,
|
|
11212
|
+
exposedProps2
|
|
11213
|
+
], key) {
|
|
11214
|
+
const value = props[
|
|
11215
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11216
|
+
key
|
|
11217
|
+
];
|
|
11218
|
+
delete exposedProps2[key];
|
|
11219
|
+
additionalProps2[key] = value;
|
|
11220
|
+
return [
|
|
11221
|
+
additionalProps2,
|
|
11222
|
+
exposedProps2
|
|
11223
|
+
];
|
|
11224
|
+
},
|
|
11225
|
+
[
|
|
11226
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11227
|
+
{},
|
|
11228
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11229
|
+
{ ...props }
|
|
11230
|
+
]
|
|
11231
|
+
);
|
|
11232
|
+
const curriedProps = curriedPropsSource(additionalProps);
|
|
11031
11233
|
return /* @__PURE__ */ jsx71(
|
|
11032
11234
|
C,
|
|
11033
11235
|
{
|
|
@@ -11040,23 +11242,29 @@ function createUnsafePartialObserverComponent(Component, curriedPropsSource) {
|
|
|
11040
11242
|
)
|
|
11041
11243
|
);
|
|
11042
11244
|
}
|
|
11043
|
-
function usePartialObserverComponent(curriedPropsSource, deps, Component) {
|
|
11245
|
+
function usePartialObserverComponent(curriedPropsSource, deps, Component, additionalPropKeys = []) {
|
|
11044
11246
|
return useMemo6(
|
|
11045
11247
|
function() {
|
|
11046
|
-
return createPartialObserverComponent(
|
|
11248
|
+
return createPartialObserverComponent(
|
|
11249
|
+
Component,
|
|
11250
|
+
curriedPropsSource,
|
|
11251
|
+
additionalPropKeys
|
|
11252
|
+
);
|
|
11047
11253
|
},
|
|
11048
11254
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11049
11255
|
[
|
|
11050
11256
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11051
11257
|
...deps,
|
|
11052
|
-
Component
|
|
11258
|
+
Component,
|
|
11259
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11260
|
+
...additionalPropKeys
|
|
11053
11261
|
]
|
|
11054
11262
|
);
|
|
11055
11263
|
}
|
|
11056
11264
|
|
|
11057
11265
|
// mantine/create_checkbox.tsx
|
|
11058
11266
|
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
11059
|
-
function createCheckbox(valuePath, Checkbox2
|
|
11267
|
+
function createCheckbox(valuePath, Checkbox2) {
|
|
11060
11268
|
const onChange = (e) => {
|
|
11061
11269
|
this.onFieldValueChange?.(valuePath, e.target.checked);
|
|
11062
11270
|
};
|
|
@@ -11073,9 +11281,11 @@ function createCheckbox(valuePath, Checkbox2, ErrorRenderer) {
|
|
|
11073
11281
|
}
|
|
11074
11282
|
}
|
|
11075
11283
|
};
|
|
11076
|
-
const propSource = (
|
|
11284
|
+
const propSource = ({
|
|
11285
|
+
ErrorRenderer = DefaultErrorRenderer
|
|
11286
|
+
}) => {
|
|
11077
11287
|
const {
|
|
11078
|
-
|
|
11288
|
+
readonly,
|
|
11079
11289
|
required,
|
|
11080
11290
|
value,
|
|
11081
11291
|
error: error2
|
|
@@ -11084,7 +11294,7 @@ function createCheckbox(valuePath, Checkbox2, ErrorRenderer) {
|
|
|
11084
11294
|
return {
|
|
11085
11295
|
name: valuePath,
|
|
11086
11296
|
checked: value,
|
|
11087
|
-
disabled,
|
|
11297
|
+
disabled: readonly,
|
|
11088
11298
|
required,
|
|
11089
11299
|
error: error2 && /* @__PURE__ */ jsx72(ErrorRenderer, { error: error2 }),
|
|
11090
11300
|
onChange,
|
|
@@ -11095,7 +11305,8 @@ function createCheckbox(valuePath, Checkbox2, ErrorRenderer) {
|
|
|
11095
11305
|
};
|
|
11096
11306
|
return createUnsafePartialObserverComponent(
|
|
11097
11307
|
Checkbox2,
|
|
11098
|
-
propSource
|
|
11308
|
+
propSource,
|
|
11309
|
+
["ErrorRenderer"]
|
|
11099
11310
|
);
|
|
11100
11311
|
}
|
|
11101
11312
|
|
|
@@ -11123,7 +11334,7 @@ function DefaultList({
|
|
|
11123
11334
|
function createPill(valuePath, Pill2) {
|
|
11124
11335
|
const propSource = () => {
|
|
11125
11336
|
const {
|
|
11126
|
-
|
|
11337
|
+
readonly,
|
|
11127
11338
|
value
|
|
11128
11339
|
// note: individual pills cannot display an error!
|
|
11129
11340
|
// error,
|
|
@@ -11131,7 +11342,7 @@ function createPill(valuePath, Pill2) {
|
|
|
11131
11342
|
} = this.fields[valuePath];
|
|
11132
11343
|
return {
|
|
11133
11344
|
children: value,
|
|
11134
|
-
disabled
|
|
11345
|
+
disabled: readonly
|
|
11135
11346
|
};
|
|
11136
11347
|
};
|
|
11137
11348
|
return createUnsafePartialObserverComponent(Pill2, propSource);
|
|
@@ -11141,7 +11352,7 @@ function createPill(valuePath, Pill2) {
|
|
|
11141
11352
|
function createRadio(valuePath, value, Radio2) {
|
|
11142
11353
|
const propSource = () => {
|
|
11143
11354
|
return {
|
|
11144
|
-
disabled: this.fields[valuePath].
|
|
11355
|
+
disabled: this.fields[valuePath].readonly,
|
|
11145
11356
|
value
|
|
11146
11357
|
};
|
|
11147
11358
|
};
|
|
@@ -11153,7 +11364,7 @@ function createRadio(valuePath, value, Radio2) {
|
|
|
11153
11364
|
|
|
11154
11365
|
// mantine/create_radio_group.tsx
|
|
11155
11366
|
import { jsx as jsx74 } from "react/jsx-runtime";
|
|
11156
|
-
function createRadioGroup(valuePath, RadioGroup2
|
|
11367
|
+
function createRadioGroup(valuePath, RadioGroup2) {
|
|
11157
11368
|
const onChange = (value) => {
|
|
11158
11369
|
this.onFieldValueChange?.(valuePath, value);
|
|
11159
11370
|
};
|
|
@@ -11170,7 +11381,7 @@ function createRadioGroup(valuePath, RadioGroup2, ErrorRenderer) {
|
|
|
11170
11381
|
}
|
|
11171
11382
|
}
|
|
11172
11383
|
};
|
|
11173
|
-
const propSource = () => {
|
|
11384
|
+
const propSource = ({ ErrorRenderer = DefaultErrorRenderer }) => {
|
|
11174
11385
|
const {
|
|
11175
11386
|
required,
|
|
11176
11387
|
value,
|
|
@@ -11187,12 +11398,12 @@ function createRadioGroup(valuePath, RadioGroup2, ErrorRenderer) {
|
|
|
11187
11398
|
onKeyUp
|
|
11188
11399
|
};
|
|
11189
11400
|
};
|
|
11190
|
-
return createUnsafePartialObserverComponent(RadioGroup2, propSource);
|
|
11401
|
+
return createUnsafePartialObserverComponent(RadioGroup2, propSource, ["ErrorRenderer"]);
|
|
11191
11402
|
}
|
|
11192
11403
|
|
|
11193
11404
|
// mantine/create_text_input.tsx
|
|
11194
11405
|
import { jsx as jsx75 } from "react/jsx-runtime";
|
|
11195
|
-
function createTextInput(valuePath, TextInput2
|
|
11406
|
+
function createTextInput(valuePath, TextInput2) {
|
|
11196
11407
|
const onChange = (e) => {
|
|
11197
11408
|
this.onFieldValueChange?.(valuePath, e.target.value);
|
|
11198
11409
|
};
|
|
@@ -11209,9 +11420,11 @@ function createTextInput(valuePath, TextInput2, ErrorRenderer) {
|
|
|
11209
11420
|
}
|
|
11210
11421
|
}
|
|
11211
11422
|
};
|
|
11212
|
-
const propSource = (
|
|
11423
|
+
const propSource = ({
|
|
11424
|
+
ErrorRenderer = DefaultErrorRenderer
|
|
11425
|
+
}) => {
|
|
11213
11426
|
const {
|
|
11214
|
-
|
|
11427
|
+
readonly,
|
|
11215
11428
|
required,
|
|
11216
11429
|
value,
|
|
11217
11430
|
error: error2
|
|
@@ -11221,7 +11434,7 @@ function createTextInput(valuePath, TextInput2, ErrorRenderer) {
|
|
|
11221
11434
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11222
11435
|
name: valuePath,
|
|
11223
11436
|
value,
|
|
11224
|
-
disabled,
|
|
11437
|
+
disabled: readonly,
|
|
11225
11438
|
required,
|
|
11226
11439
|
error: error2 && /* @__PURE__ */ jsx75(ErrorRenderer, { error: error2 }),
|
|
11227
11440
|
onChange,
|
|
@@ -11232,13 +11445,14 @@ function createTextInput(valuePath, TextInput2, ErrorRenderer) {
|
|
|
11232
11445
|
};
|
|
11233
11446
|
return createUnsafePartialObserverComponent(
|
|
11234
11447
|
TextInput2,
|
|
11235
|
-
propSource
|
|
11448
|
+
propSource,
|
|
11449
|
+
["ErrorRenderer"]
|
|
11236
11450
|
);
|
|
11237
11451
|
}
|
|
11238
11452
|
|
|
11239
11453
|
// mantine/create_value_input.tsx
|
|
11240
11454
|
import { jsx as jsx76 } from "react/jsx-runtime";
|
|
11241
|
-
function createValueInput(valuePath, ValueInput
|
|
11455
|
+
function createValueInput(valuePath, ValueInput) {
|
|
11242
11456
|
const onChange = (value) => {
|
|
11243
11457
|
this.onFieldValueChange?.(valuePath, value);
|
|
11244
11458
|
};
|
|
@@ -11255,9 +11469,11 @@ function createValueInput(valuePath, ValueInput, ErrorRenderer) {
|
|
|
11255
11469
|
}
|
|
11256
11470
|
}
|
|
11257
11471
|
};
|
|
11258
|
-
const propSource = (
|
|
11472
|
+
const propSource = ({
|
|
11473
|
+
ErrorRenderer = DefaultErrorRenderer
|
|
11474
|
+
}) => {
|
|
11259
11475
|
const {
|
|
11260
|
-
|
|
11476
|
+
readonly,
|
|
11261
11477
|
required,
|
|
11262
11478
|
value,
|
|
11263
11479
|
error: error2
|
|
@@ -11267,7 +11483,7 @@ function createValueInput(valuePath, ValueInput, ErrorRenderer) {
|
|
|
11267
11483
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11268
11484
|
name: valuePath,
|
|
11269
11485
|
value,
|
|
11270
|
-
disabled,
|
|
11486
|
+
disabled: readonly,
|
|
11271
11487
|
required,
|
|
11272
11488
|
error: error2 && /* @__PURE__ */ jsx76(ErrorRenderer, { error: error2 }),
|
|
11273
11489
|
onChange,
|
|
@@ -11278,7 +11494,8 @@ function createValueInput(valuePath, ValueInput, ErrorRenderer) {
|
|
|
11278
11494
|
};
|
|
11279
11495
|
return createUnsafePartialObserverComponent(
|
|
11280
11496
|
ValueInput,
|
|
11281
|
-
propSource
|
|
11497
|
+
propSource,
|
|
11498
|
+
["ErrorRenderer"]
|
|
11282
11499
|
);
|
|
11283
11500
|
}
|
|
11284
11501
|
|
|
@@ -11287,12 +11504,6 @@ import { jsx as jsx77 } from "react/jsx-runtime";
|
|
|
11287
11504
|
function SimpleSelect(props) {
|
|
11288
11505
|
return /* @__PURE__ */ jsx77(Select, { ...props });
|
|
11289
11506
|
}
|
|
11290
|
-
function DefaultErrorRenderer({
|
|
11291
|
-
error: error2
|
|
11292
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11293
|
-
}) {
|
|
11294
|
-
return error2;
|
|
11295
|
-
}
|
|
11296
11507
|
function useMantineForm({
|
|
11297
11508
|
onFieldValueChange,
|
|
11298
11509
|
onFieldBlur,
|
|
@@ -11373,44 +11584,39 @@ var MantineFormImpl = class {
|
|
|
11373
11584
|
constructor(fields) {
|
|
11374
11585
|
this.fields = fields;
|
|
11375
11586
|
}
|
|
11376
|
-
textInput(valuePath, TextInput2 = TextInput
|
|
11587
|
+
textInput(valuePath, TextInput2 = TextInput) {
|
|
11377
11588
|
return this.textInputCache.retrieveOrCreate(
|
|
11378
11589
|
valuePath,
|
|
11379
11590
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11380
|
-
TextInput2
|
|
11381
|
-
ErrorRenderer
|
|
11591
|
+
TextInput2
|
|
11382
11592
|
);
|
|
11383
11593
|
}
|
|
11384
|
-
valueInput(valuePath, ValueInput
|
|
11594
|
+
valueInput(valuePath, ValueInput) {
|
|
11385
11595
|
return this.valueInputCache.retrieveOrCreate(
|
|
11386
11596
|
valuePath,
|
|
11387
11597
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11388
|
-
ValueInput
|
|
11389
|
-
ErrorRenderer
|
|
11598
|
+
ValueInput
|
|
11390
11599
|
);
|
|
11391
11600
|
}
|
|
11392
|
-
select(valuePath
|
|
11601
|
+
select(valuePath) {
|
|
11393
11602
|
return this.valueInputCache.retrieveOrCreate(
|
|
11394
11603
|
valuePath,
|
|
11395
11604
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11396
|
-
SimpleSelect
|
|
11397
|
-
ErrorRenderer
|
|
11605
|
+
SimpleSelect
|
|
11398
11606
|
);
|
|
11399
11607
|
}
|
|
11400
|
-
checkbox(valuePath, Checkbox2 = Checkbox
|
|
11608
|
+
checkbox(valuePath, Checkbox2 = Checkbox) {
|
|
11401
11609
|
return this.checkboxCache.retrieveOrCreate(
|
|
11402
11610
|
valuePath,
|
|
11403
11611
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11404
|
-
Checkbox2
|
|
11405
|
-
ErrorRenderer
|
|
11612
|
+
Checkbox2
|
|
11406
11613
|
);
|
|
11407
11614
|
}
|
|
11408
|
-
radioGroup(valuePath, RadioGroup2 = Radio.Group
|
|
11615
|
+
radioGroup(valuePath, RadioGroup2 = Radio.Group) {
|
|
11409
11616
|
return this.radioGroupCache.retrieveOrCreate(
|
|
11410
11617
|
valuePath,
|
|
11411
11618
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
11412
|
-
RadioGroup2
|
|
11413
|
-
ErrorRenderer
|
|
11619
|
+
RadioGroup2
|
|
11414
11620
|
);
|
|
11415
11621
|
}
|
|
11416
11622
|
radio(valuePath, value, Radio2 = Radio) {
|
|
@@ -11435,15 +11641,60 @@ var MantineFormImpl = class {
|
|
|
11435
11641
|
);
|
|
11436
11642
|
}
|
|
11437
11643
|
};
|
|
11644
|
+
|
|
11645
|
+
// types/merge_validators.ts
|
|
11646
|
+
import {
|
|
11647
|
+
annotations as annotations2,
|
|
11648
|
+
validate as validate3
|
|
11649
|
+
} from "@strictly/define";
|
|
11650
|
+
function mergeValidators(validators1, validators2) {
|
|
11651
|
+
const validators = {
|
|
11652
|
+
...validators1,
|
|
11653
|
+
...validators2
|
|
11654
|
+
};
|
|
11655
|
+
const keys1 = new Set(Object.keys(validators1));
|
|
11656
|
+
const keys2 = new Set(Object.keys(validators2));
|
|
11657
|
+
return Array.from(keys1.intersection(keys2)).reduce(
|
|
11658
|
+
function(validators3, key) {
|
|
11659
|
+
const validator1 = validators1[key];
|
|
11660
|
+
const validator2 = validators2[key];
|
|
11661
|
+
validators3[key] = {
|
|
11662
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11663
|
+
validate: function(value, valuePath, context) {
|
|
11664
|
+
const error2 = validate3(validator1, value, valuePath, context);
|
|
11665
|
+
if (error2 != null) {
|
|
11666
|
+
return error2;
|
|
11667
|
+
}
|
|
11668
|
+
return validate3(validator2, value, valuePath, context);
|
|
11669
|
+
},
|
|
11670
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11671
|
+
annotations: function(valuePath, context) {
|
|
11672
|
+
const annotations1 = annotations2(validator1, valuePath, context);
|
|
11673
|
+
const annotations22 = annotations2(validator2, valuePath, context);
|
|
11674
|
+
return {
|
|
11675
|
+
readonly: annotations1.readonly || annotations22.readonly,
|
|
11676
|
+
required: annotations1.required || annotations22.required
|
|
11677
|
+
};
|
|
11678
|
+
}
|
|
11679
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11680
|
+
};
|
|
11681
|
+
return validators3;
|
|
11682
|
+
},
|
|
11683
|
+
validators
|
|
11684
|
+
);
|
|
11685
|
+
}
|
|
11438
11686
|
export {
|
|
11439
11687
|
AbstractSelectValueTypeConverter,
|
|
11688
|
+
DefaultErrorRenderer,
|
|
11440
11689
|
FormModel,
|
|
11441
11690
|
FormPresenter,
|
|
11442
11691
|
IntegerToStringConverter,
|
|
11443
11692
|
NullableToBooleanConverter,
|
|
11444
11693
|
SelectDiscriminatedUnionConverter,
|
|
11445
11694
|
SelectLiteralConverter,
|
|
11695
|
+
SelectStringConverter,
|
|
11446
11696
|
TrimmingStringConverter,
|
|
11697
|
+
UnreliableFieldConversionType,
|
|
11447
11698
|
adapter,
|
|
11448
11699
|
adapterFromPrototype,
|
|
11449
11700
|
adapterFromTwoWayConverter,
|
|
@@ -11453,7 +11704,9 @@ export {
|
|
|
11453
11704
|
createUnsafePartialObserverComponent,
|
|
11454
11705
|
identityAdapter,
|
|
11455
11706
|
listAdapter,
|
|
11456
|
-
|
|
11707
|
+
mergeAdaptersWithValidators,
|
|
11708
|
+
mergeFieldAdaptersWithTwoWayConverter,
|
|
11709
|
+
mergeValidators,
|
|
11457
11710
|
prototypingFieldValueFactory,
|
|
11458
11711
|
useMantineForm,
|
|
11459
11712
|
usePartialComponent,
|