@strictly/react-form 0.0.30 → 0.0.32
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/.storybook/preview.js +7 -0
- package/.out/core/mobx/{field_adapter.d.ts → FieldAdapter.d.ts} +1 -1
- package/.out/core/mobx/{field_adapters_of_values.d.ts → FieldAdaptersOfValues.d.ts} +1 -1
- package/.out/core/mobx/{flattened_adapters_of_fields.d.ts → FlattenedAdaptersOfFields.d.ts} +2 -2
- package/.out/core/mobx/{form_fields_of_field_adapters.d.ts → FormFieldsOfFieldAdapters.d.ts} +2 -2
- package/.out/core/mobx/{form_model.d.ts → FormModel.d.ts} +6 -5
- package/.out/core/mobx/{form_model.js → FormModel.js} +47 -35
- package/.out/core/mobx/{field_adapter_builder.d.ts → fieldAdapterBuilder.d.ts} +2 -2
- package/.out/core/mobx/{field_adapter_builder.js → fieldAdapterBuilder.js} +6 -6
- package/.out/core/mobx/hooks.d.ts +1 -1
- package/.out/core/mobx/hooks.js +15 -6
- package/.out/core/mobx/{merge_field_adapters_with_two_way_converter.d.ts → mergeFieldAdaptersWithTwoWayConverter.d.ts} +2 -2
- package/.out/core/mobx/{merge_field_adapters_with_two_way_converter.js → mergeFieldAdaptersWithTwoWayConverter.js} +1 -1
- package/.out/core/mobx/{merge_field_adapters_with_validators.d.ts → mergeFieldAdaptersWithValidators.d.ts} +1 -1
- package/.out/core/mobx/{merge_field_adapters_with_validators.js → mergeFieldAdaptersWithValidators.js} +1 -1
- package/.out/core/mobx/peek.d.ts +5 -0
- package/.out/core/mobx/peek.js +16 -0
- package/.out/core/mobx/specs/{form_model.tests.js → FormModel.tests.js} +8 -8
- package/.out/core/mobx/specs/{merge_field_adapters_with_two_way_converter.tests.js → MergeFieldAdaptersWithTwoWayConverter.tests.js} +4 -4
- package/.out/core/mobx/specs/{merge_field_adapters_with_validators.tests.js → MergeFieldAdaptersWithValidators.tests.js} +3 -3
- package/.out/core/mobx/specs/fixtures.d.ts +2 -2
- package/.out/core/mobx/specs/{sub_form_field_adapters.tests.js → subFormFieldAdapters.tests.js} +2 -2
- package/.out/core/mobx/{sub_form_field_adapters.d.ts → subFormFieldAdapters.d.ts} +1 -1
- package/.out/core/props.d.ts +1 -1
- package/.out/field_converters/{integer_to_string_converter.d.ts → IntegerToStringConverter.d.ts} +1 -1
- package/.out/field_converters/{integer_to_string_converter.js → IntegerToStringConverter.js} +1 -1
- package/.out/field_converters/{maybe_identity_converter.d.ts → MaybeIdentityConverter.d.ts} +1 -1
- package/.out/field_converters/{nullable_to_boolean_converter.d.ts → NullableToBooleanConverter.d.ts} +1 -1
- package/.out/field_converters/{nullable_to_boolean_converter.js → NullableToBooleanConverter.js} +1 -1
- package/.out/field_converters/{select_value_type_converter.d.ts → SelectValueTypeConverter.d.ts} +1 -1
- package/.out/field_converters/{select_value_type_converter.js → SelectValueTypeConverter.js} +1 -1
- package/.out/field_converters/{trimming_string_converter.d.ts → TrimmingStringConverter.d.ts} +1 -1
- package/.out/field_converters/{trimming_string_converter.js → TrimmingStringConverter.js} +1 -1
- package/.out/field_converters/{chain_field_converter.d.ts → chainFieldConverter.d.ts} +1 -1
- package/.out/field_converters/{chain_field_converter.js → chainFieldConverter.js} +1 -1
- package/.out/field_converters/{identity_converter.d.ts → identityConverter.d.ts} +1 -1
- package/.out/field_converters/{identity_converter.js → identityConverter.js} +1 -1
- package/.out/field_converters/specs/{chain_field_converter.tests.js → chainFieldConverter.tests.js} +2 -2
- package/.out/field_converters/{validating_converter.d.ts → validatingConverter.d.ts} +1 -1
- package/.out/field_converters/{validating_converter.js → validatingConverter.js} +1 -1
- package/.out/field_value_factories/{prototyping_field_value_factory.d.ts → prototypingFieldValueFactory.d.ts} +1 -1
- package/.out/index.d.ts +23 -22
- package/.out/index.js +23 -22
- package/.out/mantine/{error_renderer.d.ts → ErrorRenderer.d.ts} +2 -2
- package/.out/mantine/{create_checkbox.d.ts → createCheckbox.d.ts} +3 -3
- package/.out/mantine/{create_checkbox.js → createCheckbox.js} +2 -2
- package/.out/mantine/{create_field_view.d.ts → createFieldView.d.ts} +4 -4
- package/.out/mantine/{create_field_view.js → createFieldView.js} +1 -1
- package/.out/mantine/{create_fields_view.d.ts → createFieldsView.d.ts} +3 -3
- package/.out/mantine/{create_form.d.ts → createForm.d.ts} +3 -3
- package/.out/mantine/{create_list.d.ts → createList.d.ts} +3 -3
- package/.out/mantine/{create_list.js → createList.js} +1 -1
- package/.out/mantine/{create_pill.d.ts → createPill.d.ts} +2 -2
- package/.out/mantine/{create_pill.js → createPill.js} +1 -1
- package/.out/mantine/{create_radio.d.ts → createRadio.d.ts} +3 -3
- package/.out/mantine/{create_radio.js → createRadio.js} +1 -1
- package/.out/mantine/{create_radio_group.d.ts → createRadioGroup.d.ts} +3 -3
- package/.out/mantine/{create_radio_group.js → createRadioGroup.js} +2 -2
- package/.out/mantine/{create_text_input.d.ts → createTextInput.d.ts} +3 -3
- package/.out/mantine/{create_text_input.js → createTextInput.js} +2 -2
- package/.out/mantine/{create_value_input.d.ts → createValueInput.d.ts} +4 -4
- package/.out/mantine/{create_value_input.js → createValueInput.js} +2 -2
- package/.out/mantine/hooks.d.ts +18 -18
- package/.out/mantine/hooks.js +10 -10
- package/.out/mantine/specs/{checkbox_hooks.stories.d.ts → checkboxHooks.stories.d.ts} +1 -1
- package/.out/mantine/specs/{checkbox_hooks.stories.js → checkboxHooks.stories.js} +1 -1
- package/.out/mantine/specs/{checkbox_hooks.tests.js → checkboxHooks.tests.js} +2 -2
- package/.out/mantine/specs/{field_view_hooks.stories.d.ts → fieldViewHooks.stories.d.ts} +1 -1
- package/.out/mantine/specs/{field_view_hooks.tests.js → fieldViewHooks.tests.js} +1 -1
- package/.out/mantine/specs/{fields_view_hooks.stories.d.ts → fieldsViewHooks.stories.d.ts} +1 -1
- package/.out/mantine/specs/{fields_view_hooks.tests.js → fieldsViewHooks.tests.js} +1 -1
- package/.out/mantine/specs/{form_hooks.stories.d.ts → formHooks.stories.d.ts} +1 -1
- package/.out/mantine/specs/{form_hooks.tests.js → formHooks.tests.js} +1 -1
- package/.out/mantine/specs/{list_hooks.stories.d.ts → listHooks.stories.d.ts} +1 -1
- package/.out/mantine/specs/{list_hooks.tests.js → listHooks.tests.js} +1 -1
- package/.out/mantine/specs/{radio_group_hooks.stories.d.ts → radioGroupHooks.stories.d.ts} +2 -2
- package/.out/mantine/specs/{radio_group_hooks.stories.js → radioGroupHooks.stories.js} +1 -1
- package/.out/mantine/specs/{radio_group_hooks.tests.js → radioGroupHooks.tests.js} +2 -2
- package/.out/mantine/specs/{select_hooks.stories.d.ts → selectHooks.stories.d.ts} +1 -1
- package/.out/mantine/specs/{select_hooks.stories.js → selectHooks.stories.js} +1 -1
- package/.out/mantine/specs/{select_hooks.tests.js → selectHooks.tests.js} +1 -1
- package/.out/mantine/specs/{text_input_hooks.stories.d.ts → textInputHooks.stories.d.ts} +2 -2
- package/.out/mantine/specs/{text_input_hooks.stories.js → textInputHooks.stories.js} +1 -1
- package/.out/mantine/specs/{text_input_hooks.tests.js → textInputHooks.tests.js} +2 -2
- package/.out/mantine/specs/{value_input_hooks.stories.d.ts → valueInputHooks.stories.d.ts} +2 -2
- package/.out/mantine/specs/{value_input_hooks.stories.js → valueInputHooks.stories.js} +1 -1
- package/.out/mantine/specs/{value_input_hooks.tests.js → valueInputHooks.tests.js} +1 -1
- package/.out/mantine/types.d.ts +3 -3
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/types/{all_fields_of_fields.d.ts → AllFieldsOfFields.d.ts} +2 -2
- package/.out/types/{boolean_fields_of_fields.d.ts → BooleanFieldsOfFields.d.ts} +2 -2
- package/.out/types/{error_of_field.d.ts → ErrorOfField.d.ts} +1 -1
- package/.out/types/{flattened_validators_of_fields.d.ts → FlattenedValidatorsOfFields.d.ts} +1 -1
- package/.out/types/{list_fields_of_fields.d.ts → ListFieldsOfFields.d.ts} +2 -2
- package/.out/types/{string_fields_of_fields.d.ts → StringFieldsOfFields.d.ts} +2 -2
- package/.out/types/{sub_form_fields.d.ts → SubFormFields.d.ts} +1 -1
- package/.out/types/{value_type_of_field.d.ts → ValueTypeOfField.d.ts} +1 -1
- package/.out/types/specs/{merge_validators.tests.js → MergeValidators.tests.js} +1 -1
- package/.out/vitest.workspace.js +4 -4
- package/.storybook/preview.tsx +8 -0
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/core/mobx/{field_adapter.ts → FieldAdapter.ts} +1 -1
- package/core/mobx/{field_adapters_of_values.ts → FieldAdaptersOfValues.ts} +1 -1
- package/core/mobx/{flattened_adapters_of_fields.ts → FlattenedAdaptersOfFields.ts} +2 -2
- package/core/mobx/{form_fields_of_field_adapters.ts → FormFieldsOfFieldAdapters.ts} +2 -2
- package/core/mobx/{form_model.ts → FormModel.ts} +33 -26
- package/core/mobx/{field_adapter_builder.ts → fieldAdapterBuilder.ts} +7 -7
- package/core/mobx/hooks.tsx +19 -7
- package/core/mobx/{merge_field_adapters_with_two_way_converter.ts → mergeFieldAdaptersWithTwoWayConverter.ts} +3 -3
- package/core/mobx/{merge_field_adapters_with_validators.ts → mergeFieldAdaptersWithValidators.ts} +2 -2
- package/core/mobx/peek.ts +17 -0
- package/core/mobx/specs/{flattened_adapters_of_fields.tests.ts → FlattenedAdaptersOfFields.tests.ts} +3 -3
- package/core/mobx/specs/{flattened_list_types_of_types.tests.ts → FlattenedListTypesOfTypes.tests.ts} +1 -1
- package/core/mobx/specs/{form_model.tests.ts → FormModel.tests.ts} +10 -10
- package/core/mobx/specs/{merge_field_adapters_with_two_way_converter.tests.ts → MergeFieldAdaptersWithTwoWayConverter.tests.ts} +5 -5
- package/core/mobx/specs/{merge_field_adapters_with_validators.tests.ts → MergeFieldAdaptersWithValidators.tests.ts} +4 -4
- package/core/mobx/specs/fixtures.ts +2 -2
- package/core/mobx/specs/{sub_form_field_adapters.tests.ts → subFormFieldAdapters.tests.ts} +3 -3
- package/core/mobx/{sub_form_field_adapters.ts → subFormFieldAdapters.ts} +1 -1
- package/core/props.ts +1 -1
- package/dist/index.cjs +161 -132
- package/dist/index.d.cts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +166 -136
- package/field_converters/{integer_to_string_converter.ts → IntegerToStringConverter.ts} +1 -1
- package/field_converters/{maybe_identity_converter.ts → MaybeIdentityConverter.ts} +1 -1
- package/field_converters/{nullable_to_boolean_converter.ts → NullableToBooleanConverter.ts} +1 -1
- package/field_converters/{select_value_type_converter.ts → SelectValueTypeConverter.ts} +1 -1
- package/field_converters/{trimming_string_converter.ts → TrimmingStringConverter.ts} +1 -1
- package/field_converters/{chain_field_converter.ts → chainFieldConverter.ts} +1 -1
- package/field_converters/{identity_converter.ts → identityConverter.ts} +1 -1
- package/field_converters/specs/{chain_field_converter.tests.ts → chainFieldConverter.tests.ts} +2 -2
- package/field_converters/{validating_converter.ts → validatingConverter.ts} +1 -1
- package/field_value_factories/{prototyping_field_value_factory.ts → prototypingFieldValueFactory.ts} +1 -1
- package/index.ts +23 -22
- package/mantine/{error_renderer.ts → ErrorRenderer.ts} +2 -2
- package/mantine/{create_checkbox.tsx → createCheckbox.tsx} +5 -5
- package/mantine/{create_field_view.tsx → createFieldView.tsx} +5 -5
- package/mantine/{create_fields_view.tsx → createFieldsView.tsx} +4 -4
- package/mantine/{create_form.tsx → createForm.tsx} +3 -3
- package/mantine/{create_list.tsx → createList.tsx} +4 -4
- package/mantine/{create_pill.tsx → createPill.tsx} +3 -3
- package/mantine/{create_radio.tsx → createRadio.tsx} +4 -4
- package/mantine/{create_radio_group.tsx → createRadioGroup.tsx} +5 -5
- package/mantine/{create_text_input.tsx → createTextInput.tsx} +5 -5
- package/mantine/{create_value_input.tsx → createValueInput.tsx} +6 -6
- package/mantine/hooks.tsx +22 -22
- package/mantine/specs/{create_fields_view.tests.ts → CreateFieldsView.tests.ts} +1 -1
- package/mantine/specs/{checkbox_hooks.stories.tsx → checkboxHooks.stories.tsx} +2 -2
- package/mantine/specs/{checkbox_hooks.tests.tsx → checkboxHooks.tests.tsx} +2 -2
- package/mantine/specs/{field_view_hooks.stories.tsx → fieldViewHooks.stories.tsx} +1 -1
- package/mantine/specs/{field_view_hooks.tests.tsx → fieldViewHooks.tests.tsx} +1 -1
- package/mantine/specs/{fields_view_hooks.stories.tsx → fieldsViewHooks.stories.tsx} +1 -1
- package/mantine/specs/{fields_view_hooks.tests.tsx → fieldsViewHooks.tests.tsx} +1 -1
- package/mantine/specs/{form_hooks.stories.tsx → formHooks.stories.tsx} +1 -1
- package/mantine/specs/{form_hooks.tests.tsx → formHooks.tests.tsx} +1 -1
- package/mantine/specs/{list_hooks.stories.tsx → listHooks.stories.tsx} +1 -1
- package/mantine/specs/{list_hooks.tests.tsx → listHooks.tests.tsx} +1 -1
- package/mantine/specs/{radio_group_hooks.stories.tsx → radioGroupHooks.stories.tsx} +3 -3
- package/mantine/specs/{radio_group_hooks.tests.tsx → radioGroupHooks.tests.tsx} +2 -2
- package/mantine/specs/{select_hooks.stories.tsx → selectHooks.stories.tsx} +2 -2
- package/mantine/specs/{select_hooks.tests.tsx → selectHooks.tests.tsx} +1 -1
- package/mantine/specs/{text_input_hooks.stories.tsx → textInputHooks.stories.tsx} +3 -3
- package/mantine/specs/{text_input_hooks.tests.tsx → textInputHooks.tests.tsx} +2 -2
- package/mantine/specs/{value_input_hooks.stories.tsx → valueInputHooks.stories.tsx} +3 -3
- package/mantine/specs/{value_input_hooks.tests.tsx → valueInputHooks.tests.tsx} +1 -1
- package/mantine/types.ts +3 -3
- package/package.json +1 -1
- package/types/{all_fields_of_fields.ts → AllFieldsOfFields.ts} +2 -2
- package/types/{boolean_fields_of_fields.ts → BooleanFieldsOfFields.ts} +2 -2
- package/types/{error_of_field.ts → ErrorOfField.ts} +1 -1
- package/types/{flattened_validators_of_fields.ts → FlattenedValidatorsOfFields.ts} +1 -1
- package/types/{list_fields_of_fields.ts → ListFieldsOfFields.ts} +2 -2
- package/types/{string_fields_of_fields.ts → StringFieldsOfFields.ts} +2 -2
- package/types/{sub_form_fields.ts → SubFormFields.ts} +1 -1
- package/types/{value_type_of_field.ts → ValueTypeOfField.ts} +1 -1
- package/types/specs/{boolean_fields_of_fields.tests.ts → BooleanFieldsOfFields.tests.ts} +2 -2
- package/types/specs/{error_of_field.tests.ts → ErrorOfField.tests.ts} +2 -2
- package/types/specs/{flattened_validators_of_fields.tests.ts → FlattenedValidatorsOfFields.tests.ts} +2 -2
- package/types/specs/{list_fields_of_fields.tests.ts → ListFieldsOfFields.tests.ts} +2 -2
- package/types/specs/{merge_validators.tests.ts → MergeValidators.tests.ts} +1 -1
- package/types/specs/{string_fields_of_fields.tests.ts → StringFieldsOfFields.tests.ts} +2 -2
- package/types/specs/{sub_form_fields.tests.ts → SubFormFields.tests.ts} +2 -2
- package/types/specs/{value_type_of_field.tests.ts → ValueTypeOfField.tests.ts} +2 -2
- package/util/specs/partial.tests.tsx +1 -1
- package/vitest.workspace.ts +4 -4
- /package/.out/.vitest/{install_deterministic_random.d.ts → installDeterministicRandom.d.ts} +0 -0
- /package/.out/.vitest/{install_deterministic_random.js → installDeterministicRandom.js} +0 -0
- /package/.out/.vitest/{install_storybook_preview.d.ts → installStorybookPreview.d.ts} +0 -0
- /package/.out/.vitest/{install_storybook_preview.js → installStorybookPreview.js} +0 -0
- /package/.out/.vitest/{match_media.d.ts → matchMedia.d.ts} +0 -0
- /package/.out/.vitest/{match_media.js → matchMedia.js} +0 -0
- /package/.out/.vitest/{resize_observer.d.ts → resizeObserver.d.ts} +0 -0
- /package/.out/.vitest/{resize_observer.js → resizeObserver.js} +0 -0
- /package/.out/core/mobx/{field_adapter.js → FieldAdapter.js} +0 -0
- /package/.out/core/mobx/{field_adapters_of_values.js → FieldAdaptersOfValues.js} +0 -0
- /package/.out/core/mobx/{flattened_adapters_of_fields.js → FlattenedAdaptersOfFields.js} +0 -0
- /package/.out/core/mobx/{flattened_list_types_of_type.d.ts → FlattenedListTypesOfType.d.ts} +0 -0
- /package/.out/core/mobx/{flattened_list_types_of_type.js → FlattenedListTypesOfType.js} +0 -0
- /package/.out/core/mobx/{form_fields_of_field_adapters.js → FormFieldsOfFieldAdapters.js} +0 -0
- /package/.out/core/mobx/specs/{flattened_adapters_of_fields.tests.d.ts → FlattenedAdaptersOfFields.tests.d.ts} +0 -0
- /package/.out/core/mobx/specs/{flattened_adapters_of_fields.tests.js → FlattenedAdaptersOfFields.tests.js} +0 -0
- /package/.out/core/mobx/specs/{flattened_list_types_of_types.tests.d.ts → FlattenedListTypesOfTypes.tests.d.ts} +0 -0
- /package/.out/core/mobx/specs/{flattened_list_types_of_types.tests.js → FlattenedListTypesOfTypes.tests.js} +0 -0
- /package/.out/core/mobx/specs/{form_model.tests.d.ts → FormModel.tests.d.ts} +0 -0
- /package/.out/core/mobx/specs/{merge_field_adapters_with_two_way_converter.tests.d.ts → MergeFieldAdaptersWithTwoWayConverter.tests.d.ts} +0 -0
- /package/.out/core/mobx/specs/{merge_field_adapters_with_validators.tests.d.ts → MergeFieldAdaptersWithValidators.tests.d.ts} +0 -0
- /package/.out/core/mobx/specs/{sub_form_field_adapters.tests.d.ts → subFormFieldAdapters.tests.d.ts} +0 -0
- /package/.out/core/mobx/{sub_form_field_adapters.js → subFormFieldAdapters.js} +0 -0
- /package/.out/field_converters/{maybe_identity_converter.js → MaybeIdentityConverter.js} +0 -0
- /package/.out/field_converters/specs/{chain_field_converter.tests.d.ts → chainFieldConverter.tests.d.ts} +0 -0
- /package/.out/field_value_factories/{prototyping_field_value_factory.js → prototypingFieldValueFactory.js} +0 -0
- /package/.out/mantine/{error_renderer.js → ErrorRenderer.js} +0 -0
- /package/.out/mantine/{create_fields_view.js → createFieldsView.js} +0 -0
- /package/.out/mantine/{create_form.js → createForm.js} +0 -0
- /package/.out/mantine/specs/{checkbox_hooks.tests.d.ts → CreateFieldsView.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{create_fields_view.tests.js → CreateFieldsView.tests.js} +0 -0
- /package/.out/mantine/specs/{checkbox_constants.d.ts → checkboxConstants.d.ts} +0 -0
- /package/.out/mantine/specs/{checkbox_constants.js → checkboxConstants.js} +0 -0
- /package/.out/mantine/specs/{create_fields_view.tests.d.ts → checkboxHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{field_view_hooks.stories.js → fieldViewHooks.stories.js} +0 -0
- /package/.out/mantine/specs/{field_view_hooks.tests.d.ts → fieldViewHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{fields_view_hooks.stories.js → fieldsViewHooks.stories.js} +0 -0
- /package/.out/mantine/specs/{fields_view_hooks.tests.d.ts → fieldsViewHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{form_hooks.stories.js → formHooks.stories.js} +0 -0
- /package/.out/mantine/specs/{form_hooks.tests.d.ts → formHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{list_hooks.stories.js → listHooks.stories.js} +0 -0
- /package/.out/mantine/specs/{list_hooks.tests.d.ts → listHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{radio_group_constants.d.ts → radioGroupConstants.d.ts} +0 -0
- /package/.out/mantine/specs/{radio_group_constants.js → radioGroupConstants.js} +0 -0
- /package/.out/mantine/specs/{radio_group_hooks.tests.d.ts → radioGroupHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{select_hooks.tests.d.ts → selectHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{select_hooks_constant.d.ts → selectHooksConstant.d.ts} +0 -0
- /package/.out/mantine/specs/{select_hooks_constant.js → selectHooksConstant.js} +0 -0
- /package/.out/mantine/specs/{text_input_constants.d.ts → textInputConstants.d.ts} +0 -0
- /package/.out/mantine/specs/{text_input_constants.js → textInputConstants.js} +0 -0
- /package/.out/mantine/specs/{text_input_hooks.tests.d.ts → textInputHooks.tests.d.ts} +0 -0
- /package/.out/mantine/specs/{value_input_constants.d.ts → valueInputConstants.d.ts} +0 -0
- /package/.out/mantine/specs/{value_input_constants.js → valueInputConstants.js} +0 -0
- /package/.out/mantine/specs/{value_input_hooks.tests.d.ts → valueInputHooks.tests.d.ts} +0 -0
- /package/.out/types/{all_fields_of_fields.js → AllFieldsOfFields.js} +0 -0
- /package/.out/types/{boolean_fields_of_fields.js → BooleanFieldsOfFields.js} +0 -0
- /package/.out/types/{error_of_field.js → ErrorOfField.js} +0 -0
- /package/.out/types/{field.d.ts → Field.d.ts} +0 -0
- /package/.out/types/{field.js → Field.js} +0 -0
- /package/.out/types/{field_converters.d.ts → FieldConverters.d.ts} +0 -0
- /package/.out/types/{field_converters.js → FieldConverters.js} +0 -0
- /package/.out/types/{flattened_validators_of_fields.js → FlattenedValidatorsOfFields.js} +0 -0
- /package/.out/types/{list_fields_of_fields.js → ListFieldsOfFields.js} +0 -0
- /package/.out/types/{specs/boolean_fields_of_fields.tests.d.ts → StringFieldsOfFields.js} +0 -0
- /package/.out/types/{specs/error_of_field.tests.d.ts → SubFormFields.js} +0 -0
- /package/.out/types/{specs/flattened_validators_of_fields.tests.d.ts → ValueTypeOfField.js} +0 -0
- /package/.out/types/{merge_validators.d.ts → mergeValidators.d.ts} +0 -0
- /package/.out/types/{merge_validators.js → mergeValidators.js} +0 -0
- /package/.out/types/specs/{list_fields_of_fields.tests.d.ts → BooleanFieldsOfFields.tests.d.ts} +0 -0
- /package/.out/types/specs/{boolean_fields_of_fields.tests.js → BooleanFieldsOfFields.tests.js} +0 -0
- /package/.out/types/specs/{merge_validators.tests.d.ts → ErrorOfField.tests.d.ts} +0 -0
- /package/.out/types/specs/{error_of_field.tests.js → ErrorOfField.tests.js} +0 -0
- /package/.out/types/specs/{string_fields_of_fields.tests.d.ts → FlattenedValidatorsOfFields.tests.d.ts} +0 -0
- /package/.out/types/specs/{flattened_validators_of_fields.tests.js → FlattenedValidatorsOfFields.tests.js} +0 -0
- /package/.out/types/specs/{sub_form_fields.tests.d.ts → ListFieldsOfFields.tests.d.ts} +0 -0
- /package/.out/types/specs/{list_fields_of_fields.tests.js → ListFieldsOfFields.tests.js} +0 -0
- /package/.out/types/specs/{value_type_of_field.tests.d.ts → MergeValidators.tests.d.ts} +0 -0
- /package/.out/types/{string_fields_of_fields.js → specs/StringFieldsOfFields.tests.d.ts} +0 -0
- /package/.out/types/specs/{string_fields_of_fields.tests.js → StringFieldsOfFields.tests.js} +0 -0
- /package/.out/types/{sub_form_fields.js → specs/SubFormFields.tests.d.ts} +0 -0
- /package/.out/types/specs/{sub_form_fields.tests.js → SubFormFields.tests.js} +0 -0
- /package/.out/types/{value_type_of_field.js → specs/ValueTypeOfField.tests.d.ts} +0 -0
- /package/.out/types/specs/{value_type_of_field.tests.js → ValueTypeOfField.tests.js} +0 -0
- /package/.out/util/{empty.d.ts → Empty.d.ts} +0 -0
- /package/.out/util/{empty.js → Empty.js} +0 -0
- /package/.out/util/{partial.d.ts → Partial.d.ts} +0 -0
- /package/.out/util/{partial.js → Partial.js} +0 -0
- /package/.vitest/{install_deterministic_random.ts → installDeterministicRandom.ts} +0 -0
- /package/.vitest/{install_storybook_preview.ts → installStorybookPreview.ts} +0 -0
- /package/.vitest/{match_media.ts → matchMedia.ts} +0 -0
- /package/.vitest/{resize_observer.ts → resizeObserver.ts} +0 -0
- /package/core/mobx/{flattened_list_types_of_type.ts → FlattenedListTypesOfType.ts} +0 -0
- /package/mantine/specs/__snapshots__/{checkbox_hooks.tests.tsx.snap → checkboxHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{field_view_hooks.tests.tsx.snap → fieldViewHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{fields_view_hooks.tests.tsx.snap → fieldsViewHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{form_hooks.tests.tsx.snap → formHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{list_hooks.tests.tsx.snap → listHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{radio_group_hooks.tests.tsx.snap → radioGroupHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{select_hooks.tests.tsx.snap → selectHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{text_input_hooks.tests.tsx.snap → textInputHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/__snapshots__/{value_input_hooks.tests.tsx.snap → valueInputHooks.tests.tsx.snap} +0 -0
- /package/mantine/specs/{checkbox_constants.ts → checkboxConstants.ts} +0 -0
- /package/mantine/specs/{radio_group_constants.ts → radioGroupConstants.ts} +0 -0
- /package/mantine/specs/{select_hooks_constant.ts → selectHooksConstant.ts} +0 -0
- /package/mantine/specs/{text_input_constants.ts → textInputConstants.ts} +0 -0
- /package/mantine/specs/{value_input_constants.ts → valueInputConstants.ts} +0 -0
- /package/types/{field.ts → Field.ts} +0 -0
- /package/types/{field_converters.ts → FieldConverters.ts} +0 -0
- /package/types/{merge_validators.ts → mergeValidators.ts} +0 -0
- /package/util/{empty.tsx → Empty.tsx} +0 -0
- /package/util/{partial.tsx → Partial.tsx} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Fields } from './
|
|
2
|
-
import { type ValueTypeOfField } from './
|
|
1
|
+
import { type Fields } from './Field';
|
|
2
|
+
import { type ValueTypeOfField } from './ValueTypeOfField';
|
|
3
3
|
export type AllFieldsOfFields<F extends Fields> = {
|
|
4
4
|
[K in keyof F as ValueTypeOfField<F[K]> extends any ? K : never]: F[K];
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Fields } from './
|
|
2
|
-
import { type ValueTypeOfField } from './
|
|
1
|
+
import { type Fields } from './Field';
|
|
2
|
+
import { type ValueTypeOfField } from './ValueTypeOfField';
|
|
3
3
|
export type BooleanFieldsOfFields<F extends Fields> = {
|
|
4
4
|
[K in keyof F as ValueTypeOfField<F[K]> extends boolean ? K : never]: F[K];
|
|
5
5
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Field } from './
|
|
1
|
+
import { type Field } from './Field';
|
|
2
2
|
export type ErrorOfField<F extends Field> = F extends Field<infer _V, infer E> ? E : never;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReadonlyTypeOfType, type Type, type Validator, type ValueOfType } from '@strictly/define';
|
|
2
2
|
import { type SimplifyDeep, type ValueOf } from 'type-fest';
|
|
3
|
-
import { type Field } from 'types/
|
|
3
|
+
import { type Field } from 'types/Field';
|
|
4
4
|
export type FlattenedValidatorsOfFields<ValuePathsToTypePaths extends Readonly<Record<string, string>>, FlattenedTypeDefs extends Partial<Readonly<Record<ValueOf<ValuePathsToTypePaths>, Type>>>, FormFields extends Partial<Readonly<Record<keyof ValuePathsToTypePaths, Field>>>> = SimplifyDeep<{
|
|
5
5
|
readonly [K in keyof ValuePathsToTypePaths as FormFields[K] extends Field ? ValuePathsToTypePaths[K] : never]: ValidatorOfField<NonNullable<FormFields[K]>, FlattenedTypeDefs[ValuePathsToTypePaths[K]], K>;
|
|
6
6
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Fields } from './
|
|
2
|
-
import { type ValueTypeOfField } from './
|
|
1
|
+
import { type Fields } from './Field';
|
|
2
|
+
import { type ValueTypeOfField } from './ValueTypeOfField';
|
|
3
3
|
export type ListFieldsOfFields<F extends Fields> = {
|
|
4
4
|
[K in keyof F as ValueTypeOfField<F[K]> extends readonly any[] ? K : never]: F[K];
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Fields } from './
|
|
2
|
-
import { type ValueTypeOfField } from './
|
|
1
|
+
import { type Fields } from './Field';
|
|
2
|
+
import { type ValueTypeOfField } from './ValueTypeOfField';
|
|
3
3
|
export type StringFieldsOfFields<F extends Fields> = {
|
|
4
4
|
[K in keyof F as ValueTypeOfField<F[K]> extends string | undefined | null ? K : never]: F[K];
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StringConcatOf } from '@strictly/base';
|
|
2
|
-
import { type Fields } from './
|
|
2
|
+
import { type Fields } from './Field';
|
|
3
3
|
export type SubFormFields<F extends Fields, P extends keyof F> = P extends string ? {
|
|
4
4
|
[K in keyof F as K extends StringConcatOf<`${P}.`, infer S> ? `$.${S}` : never]: F[K];
|
|
5
5
|
} & {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Field } from './
|
|
1
|
+
import { type Field } from './Field';
|
|
2
2
|
export type ValueTypeOfField<F extends Field> = F extends Field<infer V> ? V : never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { annotations, validate, } from '@strictly/define';
|
|
2
|
-
import { mergeValidators, } from 'types/
|
|
2
|
+
import { mergeValidators, } from 'types/mergeValidators';
|
|
3
3
|
import { mock, mockReset, } from 'vitest-mock-extended';
|
|
4
4
|
describe('MergedOfValidators', function () {
|
|
5
5
|
describe('empty validators 1', function () {
|
package/.out/vitest.workspace.js
CHANGED
|
@@ -5,10 +5,10 @@ const config = createVitestUserConfig(tsconfig);
|
|
|
5
5
|
export default defineWorkspace([
|
|
6
6
|
'.',
|
|
7
7
|
Object.assign(Object.assign({}, config), { extends: './.storybook/vite.config.mts', test: Object.assign(Object.assign({}, (config.test || {})), { environment: 'jsdom', setupFiles: [
|
|
8
|
-
'./.vitest/
|
|
8
|
+
'./.vitest/installDeterministicRandom.ts',
|
|
9
9
|
// install storybook setup for unit tests that import stories directly
|
|
10
|
-
'./.vitest/
|
|
11
|
-
'./.vitest/
|
|
12
|
-
'./.vitest/
|
|
10
|
+
'./.vitest/installStorybookPreview.ts',
|
|
11
|
+
'./.vitest/matchMedia.ts',
|
|
12
|
+
'./.vitest/resizeObserver.ts',
|
|
13
13
|
] }) }),
|
|
14
14
|
]);
|
package/.storybook/preview.tsx
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import '@mantine/core/styles.css'
|
|
2
2
|
import { MantineProvider } from '@mantine/core'
|
|
3
3
|
import { type Preview } from '@storybook/react'
|
|
4
|
+
import { configure } from 'mobx'
|
|
4
5
|
import { StrictMode } from 'react'
|
|
5
6
|
|
|
7
|
+
// turn on all useful mobx warnings in storybook to try to catch bad behavior
|
|
8
|
+
configure({
|
|
9
|
+
enforceActions: 'observed',
|
|
10
|
+
observableRequiresReaction: true,
|
|
11
|
+
reactionRequiresObservable: true,
|
|
12
|
+
})
|
|
13
|
+
|
|
6
14
|
const preview: Preview = {
|
|
7
15
|
parameters: {
|
|
8
16
|
controls: {
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,12 +7,12 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Target: es6
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
11
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
10
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m64.18 KB[39m
|
|
11
|
+
[32mCJS[39m ⚡️ Build success in 121ms
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m60.02 KB[39m
|
|
13
13
|
[32mESM[39m ⚡️ Build success in 126ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m38.
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m38.
|
|
18
|
-
Done in
|
|
15
|
+
[32mDTS[39m ⚡️ Build success in 6938ms
|
|
16
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m38.43 KB[39m
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m38.43 KB[39m
|
|
18
|
+
Done in 8.16s.
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
type Type,
|
|
4
4
|
type ValueOfType,
|
|
5
5
|
} from '@strictly/define'
|
|
6
|
-
import { type FieldAdapter } from 'core/mobx/
|
|
6
|
+
import { type FieldAdapter } from 'core/mobx/FieldAdapter'
|
|
7
7
|
import {
|
|
8
8
|
type SimplifyDeep,
|
|
9
9
|
type ValueOf,
|
|
10
10
|
} from 'type-fest'
|
|
11
|
-
import { type Field } from 'types/
|
|
11
|
+
import { type Field } from 'types/Field'
|
|
12
12
|
|
|
13
13
|
export type FlattenedAdaptersOfFields<
|
|
14
14
|
ValuePathsToTypePaths extends Readonly<Record<string, string>>,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ValueOf } from 'type-fest'
|
|
2
|
-
import { type Field } from 'types/
|
|
3
|
-
import { type FieldAdapter } from './
|
|
2
|
+
import { type Field } from 'types/Field'
|
|
3
|
+
import { type FieldAdapter } from './FieldAdapter'
|
|
4
4
|
|
|
5
5
|
export type FormFieldsOfFieldAdapters<
|
|
6
6
|
ValuePathsToTypePaths extends Readonly<Record<string, string>>,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
type Accessor,
|
|
13
13
|
type AnyValueType,
|
|
14
|
+
copy,
|
|
14
15
|
equals,
|
|
15
16
|
flattenAccessorsOfType,
|
|
16
17
|
type FlattenedValuesOfType,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
valuePathToTypePath,
|
|
28
29
|
} from '@strictly/define'
|
|
29
30
|
import {
|
|
31
|
+
action,
|
|
30
32
|
computed,
|
|
31
33
|
observable,
|
|
32
34
|
runInAction,
|
|
@@ -40,20 +42,20 @@ import {
|
|
|
40
42
|
} from 'type-fest'
|
|
41
43
|
import {
|
|
42
44
|
type Field,
|
|
43
|
-
} from 'types/
|
|
45
|
+
} from 'types/Field'
|
|
44
46
|
import {
|
|
45
47
|
type AnnotatedFieldConversion,
|
|
46
48
|
UnreliableFieldConversionType,
|
|
47
|
-
} from 'types/
|
|
49
|
+
} from 'types/FieldConverters'
|
|
48
50
|
import {
|
|
49
51
|
type ContextOfFieldAdapter,
|
|
50
52
|
type ErrorOfFieldAdapter,
|
|
51
53
|
type FieldAdapter,
|
|
52
54
|
type ToOfFieldAdapter,
|
|
53
|
-
} from './
|
|
55
|
+
} from './FieldAdapter'
|
|
54
56
|
import {
|
|
55
57
|
type FlattenedListTypesOfType,
|
|
56
|
-
} from './
|
|
58
|
+
} from './FlattenedListTypesOfType'
|
|
57
59
|
|
|
58
60
|
export type FlattenedConvertedFieldsOf<
|
|
59
61
|
ValuePathsToAdapters extends Readonly<Record<string, FieldAdapter>>,
|
|
@@ -146,7 +148,7 @@ export abstract class FormModel<
|
|
|
146
148
|
>,
|
|
147
149
|
> {
|
|
148
150
|
@observable.ref
|
|
149
|
-
accessor
|
|
151
|
+
private accessor observableValue: MobxValueOfType<T>
|
|
150
152
|
@observable.shallow
|
|
151
153
|
accessor fieldOverrides: FlattenedFieldOverrides<ValuePathsToAdapters>
|
|
152
154
|
@observable.shallow
|
|
@@ -170,13 +172,13 @@ export abstract class FormModel<
|
|
|
170
172
|
protected readonly mode: FormMode,
|
|
171
173
|
) {
|
|
172
174
|
this.originalValues = flattenValuesOfType<ReadonlyTypeOfType<T>>(type, originalValue, this.listIndicesToKeys)
|
|
173
|
-
this.
|
|
175
|
+
this.observableValue = mobxCopy(type, originalValue)
|
|
174
176
|
this.flattenedTypeDefs = flattenTypesOfType(type)
|
|
175
177
|
// pre-populate field overrides for consistent behavior when default information is overwritten
|
|
176
178
|
// then returned to
|
|
177
179
|
const conversions = flattenValueTo(
|
|
178
180
|
type,
|
|
179
|
-
|
|
181
|
+
originalValue,
|
|
180
182
|
() => {},
|
|
181
183
|
(
|
|
182
184
|
_t: StrictTypeDef,
|
|
@@ -228,6 +230,12 @@ export abstract class FormModel<
|
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
|
|
233
|
+
@computed
|
|
234
|
+
get value(): ValueOfType<ReadonlyTypeOfType<T>> {
|
|
235
|
+
// copy and strip out the mobx so this computed will fire every time anything changes
|
|
236
|
+
return copy(this.type, this.observableValue)
|
|
237
|
+
}
|
|
238
|
+
|
|
231
239
|
@computed
|
|
232
240
|
get fields(): SimplifyDeep<FlattenedConvertedFieldsOf<ValuePathsToAdapters>> {
|
|
233
241
|
return new Proxy<SimplifyDeep<FlattenedConvertedFieldsOf<ValuePathsToAdapters>>>(
|
|
@@ -252,7 +260,7 @@ export abstract class FormModel<
|
|
|
252
260
|
private get knownFields(): SimplifyDeep<FlattenedConvertedFieldsOf<ValuePathsToAdapters>> {
|
|
253
261
|
return flattenValueTo(
|
|
254
262
|
this.type,
|
|
255
|
-
this.
|
|
263
|
+
this.observableValue,
|
|
256
264
|
() => {},
|
|
257
265
|
// TODO swap these to valuePath, typePath in flatten
|
|
258
266
|
(_t: StrictTypeDef, _v: AnyValueType, _setter, typePath, valuePath): Field | undefined => {
|
|
@@ -302,7 +310,7 @@ export abstract class FormModel<
|
|
|
302
310
|
const accessor = this.getAccessorForValuePath(valuePath)
|
|
303
311
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
304
312
|
const fieldTypeDef = this.flattenedTypeDefs[typePath as string]
|
|
305
|
-
const context = this.toContext(this.
|
|
313
|
+
const context = this.toContext(this.observableValue, valuePath)
|
|
306
314
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
307
315
|
const defaultValue = create(valuePath as string, context)
|
|
308
316
|
|
|
@@ -414,9 +422,9 @@ export abstract class FormModel<
|
|
|
414
422
|
get accessors(): Readonly<Record<string, Accessor>> {
|
|
415
423
|
return flattenAccessorsOfType<T, Readonly<Record<string, Accessor>>>(
|
|
416
424
|
this.type,
|
|
417
|
-
this.
|
|
425
|
+
this.observableValue,
|
|
418
426
|
(value: ValueOfType<T>): void => {
|
|
419
|
-
this.
|
|
427
|
+
this.observableValue = mobxCopy(this.type, value)
|
|
420
428
|
},
|
|
421
429
|
this.listIndicesToKeys,
|
|
422
430
|
)
|
|
@@ -448,13 +456,14 @@ export abstract class FormModel<
|
|
|
448
456
|
@computed
|
|
449
457
|
get valueChanged() {
|
|
450
458
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
451
|
-
return !equals(this.type, this.
|
|
459
|
+
return !equals(this.type, this.observableValue, this.originalValue as ValueOfType<T>)
|
|
452
460
|
}
|
|
453
461
|
|
|
454
462
|
typePath<K extends keyof ValueToTypePaths>(valuePath: K): ValueToTypePaths[K] {
|
|
455
463
|
return valuePathToTypePath<ValueToTypePaths, K>(this.type, valuePath, true)
|
|
456
464
|
}
|
|
457
465
|
|
|
466
|
+
@action
|
|
458
467
|
setFieldValue<K extends keyof ValuePathsToAdapters>(
|
|
459
468
|
valuePath: K,
|
|
460
469
|
value: ToOfFieldAdapter<ValuePathsToAdapters[K]>,
|
|
@@ -490,7 +499,7 @@ export abstract class FormModel<
|
|
|
490
499
|
elementTypePath as string,
|
|
491
500
|
// TODO what can we use for the value path here?
|
|
492
501
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
493
|
-
this.toContext(this.
|
|
502
|
+
this.toContext(this.observableValue, valuePath as unknown as keyof ValuePathsToAdapters),
|
|
494
503
|
)
|
|
495
504
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
496
505
|
const originalList: any[] = accessor.value
|
|
@@ -560,7 +569,7 @@ export abstract class FormModel<
|
|
|
560
569
|
assertExists(revert, 'setting value not supported {}', valuePath)
|
|
561
570
|
|
|
562
571
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
|
|
563
|
-
const conversion = revert(value, valuePath as any, this.toContext(this.
|
|
572
|
+
const conversion = revert(value, valuePath as any, this.toContext(this.observableValue, valuePath))
|
|
564
573
|
const accessor = this.getAccessorForValuePath(valuePath)
|
|
565
574
|
return runInAction(() => {
|
|
566
575
|
this.fieldOverrides[valuePath] = [value]
|
|
@@ -623,7 +632,7 @@ export abstract class FormModel<
|
|
|
623
632
|
create,
|
|
624
633
|
} = adapter
|
|
625
634
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
626
|
-
const context = this.toContext(this.
|
|
635
|
+
const context = this.toContext(this.observableValue, valuePath as unknown as keyof ValuePathsToAdapters)
|
|
627
636
|
const value = create(valuePath, context)
|
|
628
637
|
const {
|
|
629
638
|
value: displayValue,
|
|
@@ -643,12 +652,12 @@ export abstract class FormModel<
|
|
|
643
652
|
// TODO this isn't correct, should reload from value
|
|
644
653
|
this.fieldOverrides = {}
|
|
645
654
|
this.errorOverrides = {}
|
|
646
|
-
this.
|
|
655
|
+
this.observableValue = mobxCopy(this.type, value)
|
|
647
656
|
})
|
|
648
657
|
}
|
|
649
658
|
|
|
650
659
|
isValuePathActive<K extends keyof ValuePathsToAdapters>(valuePath: K): boolean {
|
|
651
|
-
const values = flattenValuesOfType(this.type, this.
|
|
660
|
+
const values = flattenValuesOfType(this.type, this.observableValue, this.listIndicesToKeys)
|
|
652
661
|
const keys = new Set(Object.keys(values))
|
|
653
662
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
654
663
|
return keys.has(valuePath as string)
|
|
@@ -704,25 +713,23 @@ export abstract class FormModel<
|
|
|
704
713
|
return displayedValue !== originalDisplayedValue
|
|
705
714
|
}
|
|
706
715
|
|
|
716
|
+
@action
|
|
707
717
|
validateField<K extends keyof ValuePathsToAdapters>(
|
|
708
718
|
valuePath: K,
|
|
709
719
|
validation: Validation = Validation.Always,
|
|
710
720
|
): boolean {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
delete this.errorOverrides[valuePath]
|
|
714
|
-
})
|
|
721
|
+
this.validation[valuePath] = validation
|
|
722
|
+
delete this.errorOverrides[valuePath]
|
|
715
723
|
return this.fields[valuePath].error == null
|
|
716
724
|
}
|
|
717
725
|
|
|
726
|
+
@action
|
|
718
727
|
validateAll(validation: Validation = Validation.Always): boolean {
|
|
719
728
|
const accessors = toArray(this.accessors)
|
|
720
729
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
this.validation[valuePath as keyof ValuePathsToAdapters] = validation
|
|
725
|
-
})
|
|
730
|
+
accessors.forEach(([valuePath]) => {
|
|
731
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
732
|
+
this.validation[valuePath as keyof ValuePathsToAdapters] = validation
|
|
726
733
|
})
|
|
727
734
|
return accessors.every(
|
|
728
735
|
([valuePath]): boolean => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chainAnnotatedFieldConverter,
|
|
3
3
|
chainUnreliableFieldConverter,
|
|
4
|
-
} from 'field_converters/
|
|
4
|
+
} from 'field_converters/chainFieldConverter'
|
|
5
5
|
import {
|
|
6
6
|
annotatedIdentityConverter,
|
|
7
7
|
unreliableIdentityConverter,
|
|
8
|
-
} from 'field_converters/
|
|
9
|
-
import { MaybeIdentityConverter } from 'field_converters/
|
|
10
|
-
import { TrimmingStringConverter } from 'field_converters/
|
|
11
|
-
import { prototypingFieldValueFactory } from 'field_value_factories/
|
|
8
|
+
} from 'field_converters/identityConverter'
|
|
9
|
+
import { MaybeIdentityConverter } from 'field_converters/MaybeIdentityConverter'
|
|
10
|
+
import { TrimmingStringConverter } from 'field_converters/TrimmingStringConverter'
|
|
11
|
+
import { prototypingFieldValueFactory } from 'field_value_factories/prototypingFieldValueFactory'
|
|
12
12
|
import {
|
|
13
13
|
type AnnotatedFieldConverter,
|
|
14
14
|
type FieldValueFactory,
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
type TwoWayFieldConverterWithValueFactory,
|
|
17
17
|
UnreliableFieldConversionType,
|
|
18
18
|
type UnreliableFieldConverter,
|
|
19
|
-
} from 'types/
|
|
20
|
-
import { type FieldAdapter } from './
|
|
19
|
+
} from 'types/FieldConverters'
|
|
20
|
+
import { type FieldAdapter } from './FieldAdapter'
|
|
21
21
|
|
|
22
22
|
class FieldAdapterBuilder<
|
|
23
23
|
From,
|
package/core/mobx/hooks.tsx
CHANGED
|
@@ -5,11 +5,12 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
useCallback,
|
|
7
7
|
} from 'react'
|
|
8
|
-
import type { ValueTypeOfField } from 'types/
|
|
8
|
+
import type { ValueTypeOfField } from 'types/ValueTypeOfField'
|
|
9
9
|
import {
|
|
10
10
|
type FormModel,
|
|
11
11
|
Validation,
|
|
12
|
-
} from './
|
|
12
|
+
} from './FormModel'
|
|
13
|
+
import { peek } from './peek'
|
|
13
14
|
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
16
|
type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any>
|
|
@@ -41,7 +42,8 @@ export function useDefaultMobxFormHooks<
|
|
|
41
42
|
path: Path,
|
|
42
43
|
value: ValueTypeOfField<F[Path]>,
|
|
43
44
|
) {
|
|
44
|
-
const
|
|
45
|
+
const activeValidation = peek(() => model.getValidation(path))
|
|
46
|
+
const validation = Math.min(activeValidation, Validation.Changed)
|
|
45
47
|
model.setFieldValue<Path>(path, value, validation)
|
|
46
48
|
},
|
|
47
49
|
[model],
|
|
@@ -66,10 +68,18 @@ export function useDefaultMobxFormHooks<
|
|
|
66
68
|
// (e.g. changing a discriminator)
|
|
67
69
|
// TODO debounce?
|
|
68
70
|
setTimeout(function () {
|
|
71
|
+
const [
|
|
72
|
+
validate,
|
|
73
|
+
activeValidation,
|
|
74
|
+
] = peek(() => [
|
|
75
|
+
model.isValuePathActive(path) && model.isFieldDirty(path) && model.fields[path].error == null,
|
|
76
|
+
model.getValidation(path),
|
|
77
|
+
])
|
|
69
78
|
// only start validation if the user has changed the field and there isn't already an error visible
|
|
70
|
-
if (
|
|
79
|
+
if (validate) {
|
|
80
|
+
const validation = Math.max(Validation.Changed, activeValidation)
|
|
71
81
|
// further workaround to make sure we don't downgrade the existing validation
|
|
72
|
-
model.validateField(path,
|
|
82
|
+
model.validateField(path, validation)
|
|
73
83
|
}
|
|
74
84
|
}, 100)
|
|
75
85
|
},
|
|
@@ -78,8 +88,10 @@ export function useDefaultMobxFormHooks<
|
|
|
78
88
|
|
|
79
89
|
const onFormSubmit = useCallback(
|
|
80
90
|
function () {
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
const valid = peek(() => model.validateSubmit())
|
|
92
|
+
if (valid && onValidFormSubmit) {
|
|
93
|
+
const value = peek(() => model.value)
|
|
94
|
+
onValidFormSubmit(value)
|
|
83
95
|
}
|
|
84
96
|
},
|
|
85
97
|
[
|
|
@@ -2,8 +2,8 @@ import { map } from '@strictly/base'
|
|
|
2
2
|
import {
|
|
3
3
|
chainAnnotatedFieldConverter,
|
|
4
4
|
chainUnreliableFieldConverter,
|
|
5
|
-
} from 'field_converters/
|
|
6
|
-
import { type TwoWayFieldConverter } from 'types/
|
|
5
|
+
} from 'field_converters/chainFieldConverter'
|
|
6
|
+
import { type TwoWayFieldConverter } from 'types/FieldConverters'
|
|
7
7
|
import {
|
|
8
8
|
type ContextOfFieldAdapter,
|
|
9
9
|
type ErrorOfFieldAdapter,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type FromOfFieldAdapter,
|
|
12
12
|
type ToOfFieldAdapter,
|
|
13
13
|
type ValuePathOfFieldAdapter,
|
|
14
|
-
} from './
|
|
14
|
+
} from './FieldAdapter'
|
|
15
15
|
|
|
16
16
|
export type MergedOfFieldAdaptersWithTwoWayConverter<
|
|
17
17
|
FieldAdapters extends Readonly<Record<string, FieldAdapter>>,
|
package/core/mobx/{merge_field_adapters_with_validators.ts → mergeFieldAdaptersWithValidators.ts}
RENAMED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
type AnnotatedFieldConversion,
|
|
10
10
|
type UnreliableFieldConversion,
|
|
11
11
|
UnreliableFieldConversionType,
|
|
12
|
-
} from 'types/
|
|
13
|
-
import { type FieldAdapter } from './
|
|
12
|
+
} from 'types/FieldConverters'
|
|
13
|
+
import { type FieldAdapter } from './FieldAdapter'
|
|
14
14
|
|
|
15
15
|
export type MergedOfFieldAdaptersWithValidators<
|
|
16
16
|
// must have a field adapter for every validator
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { when } from 'mobx'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Used for when you want to look at the value of an observable without observing it (or triggering
|
|
5
|
+
* the mobx runtime linter)
|
|
6
|
+
*/
|
|
7
|
+
export function peek<T>(operation: () => T): T {
|
|
8
|
+
let result: T
|
|
9
|
+
// when will make mobx think we are observing the value
|
|
10
|
+
void when(() => {
|
|
11
|
+
// trick mobx runtime linting
|
|
12
|
+
result = operation()
|
|
13
|
+
return true
|
|
14
|
+
})
|
|
15
|
+
// biome-ignore lint/style/noNonNullAssertion: the result is always there
|
|
16
|
+
return result!
|
|
17
|
+
}
|
package/core/mobx/specs/{flattened_adapters_of_fields.tests.ts → FlattenedAdaptersOfFields.tests.ts}
RENAMED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
type booleanType,
|
|
3
3
|
type numberType,
|
|
4
4
|
} from '@strictly/define'
|
|
5
|
-
import { type FieldAdapter } from 'core/mobx/
|
|
6
|
-
import { type FlattenedAdaptersOfFields } from 'core/mobx/
|
|
7
|
-
import { type Field } from 'types/
|
|
5
|
+
import { type FieldAdapter } from 'core/mobx/FieldAdapter'
|
|
6
|
+
import { type FlattenedAdaptersOfFields } from 'core/mobx/FlattenedAdaptersOfFields'
|
|
7
|
+
import { type Field } from 'types/Field'
|
|
8
8
|
|
|
9
9
|
const error = Symbol()
|
|
10
10
|
type Error = typeof error
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@strictly/define'
|
|
10
10
|
import {
|
|
11
11
|
type FlattenedListTypesOfType,
|
|
12
|
-
} from 'core/mobx/
|
|
12
|
+
} from 'core/mobx/FlattenedListTypesOfType'
|
|
13
13
|
|
|
14
14
|
describe('FlattenedListTypesOfType', function () {
|
|
15
15
|
it('filters lists types', function () {
|
|
@@ -17,29 +17,29 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
type FieldAdapter,
|
|
19
19
|
type ToOfFieldAdapter,
|
|
20
|
-
} from 'core/mobx/
|
|
20
|
+
} from 'core/mobx/FieldAdapter'
|
|
21
21
|
import {
|
|
22
22
|
adapterFromTwoWayConverter,
|
|
23
23
|
identityAdapter,
|
|
24
|
-
} from 'core/mobx/
|
|
24
|
+
} from 'core/mobx/fieldAdapterBuilder'
|
|
25
25
|
import {
|
|
26
26
|
type FlattenedTypePathsToAdaptersOf,
|
|
27
27
|
FormModel,
|
|
28
28
|
Validation,
|
|
29
29
|
type ValuePathsToAdaptersOf,
|
|
30
|
-
} from 'core/mobx/
|
|
31
|
-
import { mergeAdaptersWithValidators } from 'core/mobx/
|
|
32
|
-
import { IntegerToStringConverter } from 'field_converters/
|
|
33
|
-
import { NullableToBooleanConverter } from 'field_converters/
|
|
34
|
-
import { SelectDiscriminatedUnionConverter } from 'field_converters/
|
|
35
|
-
import { prototypingFieldValueFactory } from 'field_value_factories/
|
|
30
|
+
} from 'core/mobx/FormModel'
|
|
31
|
+
import { mergeAdaptersWithValidators } from 'core/mobx/mergeFieldAdaptersWithValidators'
|
|
32
|
+
import { IntegerToStringConverter } from 'field_converters/IntegerToStringConverter'
|
|
33
|
+
import { NullableToBooleanConverter } from 'field_converters/NullableToBooleanConverter'
|
|
34
|
+
import { SelectDiscriminatedUnionConverter } from 'field_converters/SelectValueTypeConverter'
|
|
35
|
+
import { prototypingFieldValueFactory } from 'field_value_factories/prototypingFieldValueFactory'
|
|
36
36
|
import {
|
|
37
37
|
type Simplify,
|
|
38
38
|
} from 'type-fest'
|
|
39
|
-
import { type Field } from 'types/
|
|
39
|
+
import { type Field } from 'types/Field'
|
|
40
40
|
import {
|
|
41
41
|
UnreliableFieldConversionType,
|
|
42
|
-
} from 'types/
|
|
42
|
+
} from 'types/FieldConverters'
|
|
43
43
|
import {
|
|
44
44
|
createMockedAdapter,
|
|
45
45
|
resetMockAdapter,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { type FieldAdapter } from 'core/mobx/
|
|
2
|
-
import { identityAdapter } from 'core/mobx/
|
|
1
|
+
import { type FieldAdapter } from 'core/mobx/FieldAdapter'
|
|
2
|
+
import { identityAdapter } from 'core/mobx/fieldAdapterBuilder'
|
|
3
3
|
import {
|
|
4
4
|
type MergedOfFieldAdaptersWithTwoWayConverter,
|
|
5
5
|
mergeFieldAdaptersWithTwoWayConverter,
|
|
6
|
-
} from 'core/mobx/
|
|
6
|
+
} from 'core/mobx/mergeFieldAdaptersWithTwoWayConverter'
|
|
7
7
|
import {
|
|
8
8
|
annotatedIdentityConverter,
|
|
9
9
|
unreliableIdentityConverter,
|
|
10
|
-
} from 'field_converters/
|
|
10
|
+
} from 'field_converters/identityConverter'
|
|
11
11
|
import {
|
|
12
12
|
type TwoWayFieldConverter,
|
|
13
13
|
UnreliableFieldConversionType,
|
|
14
|
-
} from 'types/
|
|
14
|
+
} from 'types/FieldConverters'
|
|
15
15
|
import {
|
|
16
16
|
createMockedAdapter,
|
|
17
17
|
createMockTwoWayFieldConverter,
|
|
@@ -7,15 +7,15 @@ import {
|
|
|
7
7
|
type FunctionalValidator,
|
|
8
8
|
type Validator,
|
|
9
9
|
} from '@strictly/define'
|
|
10
|
-
import { type FieldAdapter } from 'core/mobx/
|
|
10
|
+
import { type FieldAdapter } from 'core/mobx/FieldAdapter'
|
|
11
11
|
import {
|
|
12
12
|
identityAdapter,
|
|
13
|
-
} from 'core/mobx/
|
|
13
|
+
} from 'core/mobx/fieldAdapterBuilder'
|
|
14
14
|
import {
|
|
15
15
|
mergeAdaptersWithValidators,
|
|
16
16
|
type MergedOfFieldAdaptersWithValidators,
|
|
17
|
-
} from 'core/mobx/
|
|
18
|
-
import { UnreliableFieldConversionType } from 'types/
|
|
17
|
+
} from 'core/mobx/mergeFieldAdaptersWithValidators'
|
|
18
|
+
import { UnreliableFieldConversionType } from 'types/FieldConverters'
|
|
19
19
|
import {
|
|
20
20
|
createMockedAdapter,
|
|
21
21
|
resetMockAdapter,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type FieldAdapter } from 'core/mobx/
|
|
2
|
-
import { type TwoWayFieldConverter } from 'types/
|
|
1
|
+
import { type FieldAdapter } from 'core/mobx/FieldAdapter'
|
|
2
|
+
import { type TwoWayFieldConverter } from 'types/FieldConverters'
|
|
3
3
|
import { type Mocked } from 'vitest'
|
|
4
4
|
import {
|
|
5
5
|
mock,
|