@strictly/react-form 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.out/core/mobx/hooks.d.ts +5 -1
  2. package/.out/core/mobx/hooks.js +13 -3
  3. package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +56 -9
  4. package/.out/core/mobx/sub_form_field_adapters.d.ts +5 -5
  5. package/.out/core/mobx/sub_form_field_adapters.js +13 -10
  6. package/.out/field_converters/nullable_to_boolean_converter.d.ts +2 -2
  7. package/.out/mantine/create_checkbox.js +1 -0
  8. package/.out/mantine/create_fields_view.d.ts +1 -1
  9. package/.out/mantine/create_fields_view.js +4 -4
  10. package/.out/mantine/create_form.d.ts +1 -1
  11. package/.out/mantine/create_list.d.ts +1 -1
  12. package/.out/mantine/create_pill.d.ts +1 -1
  13. package/.out/mantine/create_radio.d.ts +1 -1
  14. package/.out/mantine/create_radio_group.js +1 -0
  15. package/.out/mantine/create_text_input.js +7 -2
  16. package/.out/mantine/create_value_input.js +1 -0
  17. package/.out/mantine/error_renderer.d.ts +1 -1
  18. package/.out/mantine/error_renderer.js +1 -1
  19. package/.out/mantine/hooks.d.ts +9 -9
  20. package/.out/mantine/specs/checkbox_hooks.stories.d.ts +2 -6
  21. package/.out/mantine/specs/checkbox_hooks.stories.js +4 -16
  22. package/.out/mantine/specs/fields_view_hooks.stories.d.ts +1 -1
  23. package/.out/mantine/specs/fields_view_hooks.stories.js +6 -3
  24. package/.out/mantine/specs/form_hooks.stories.d.ts +2 -2
  25. package/.out/mantine/specs/form_hooks.stories.js +4 -1
  26. package/.out/mantine/specs/radio_group_hooks.stories.d.ts +2 -6
  27. package/.out/mantine/specs/radio_group_hooks.stories.js +5 -17
  28. package/.out/mantine/specs/select_hooks.stories.d.ts +2 -6
  29. package/.out/mantine/specs/select_hooks.stories.js +4 -16
  30. package/.out/mantine/specs/text_input_hooks.stories.d.ts +2 -5
  31. package/.out/mantine/specs/text_input_hooks.stories.js +5 -5
  32. package/.out/mantine/specs/value_input_hooks.stories.d.ts +2 -5
  33. package/.out/mantine/specs/value_input_hooks.stories.js +5 -5
  34. package/.out/mantine/types.d.ts +4 -2
  35. package/.out/tsconfig.tsbuildinfo +1 -1
  36. package/.turbo/turbo-build.log +8 -8
  37. package/.turbo/turbo-check-types.log +1 -1
  38. package/.turbo/turbo-release$colon$exports.log +1 -1
  39. package/core/mobx/hooks.ts +24 -6
  40. package/core/mobx/specs/sub_form_field_adapters.tests.ts +108 -15
  41. package/core/mobx/sub_form_field_adapters.ts +41 -25
  42. package/dist/index.cjs +52 -27
  43. package/dist/index.d.cts +25 -19
  44. package/dist/index.d.ts +25 -19
  45. package/dist/index.js +52 -27
  46. package/field_converters/nullable_to_boolean_converter.ts +2 -3
  47. package/mantine/create_checkbox.tsx +2 -1
  48. package/mantine/create_fields_view.tsx +17 -14
  49. package/mantine/create_form.tsx +2 -2
  50. package/mantine/create_list.tsx +1 -1
  51. package/mantine/create_pill.tsx +1 -1
  52. package/mantine/create_radio.tsx +1 -1
  53. package/mantine/create_radio_group.tsx +6 -2
  54. package/mantine/create_text_input.tsx +9 -3
  55. package/mantine/create_value_input.tsx +2 -1
  56. package/mantine/error_renderer.ts +1 -1
  57. package/mantine/hooks.tsx +19 -14
  58. package/mantine/specs/__snapshots__/checkbox_hooks.tests.tsx.snap +1 -64
  59. package/mantine/specs/__snapshots__/fields_view_hooks.tests.tsx.snap +52 -52
  60. package/mantine/specs/__snapshots__/radio_group_hooks.tests.tsx.snap +1 -179
  61. package/mantine/specs/__snapshots__/select_hooks.tests.tsx.snap +1 -83
  62. package/mantine/specs/__snapshots__/text_input_hooks.tests.tsx.snap +27 -27
  63. package/mantine/specs/__snapshots__/value_input_hooks.tests.tsx.snap +31 -31
  64. package/mantine/specs/checkbox_hooks.stories.tsx +5 -21
  65. package/mantine/specs/fields_view_hooks.stories.tsx +16 -4
  66. package/mantine/specs/form_hooks.stories.tsx +10 -3
  67. package/mantine/specs/radio_group_hooks.stories.tsx +6 -20
  68. package/mantine/specs/select_hooks.stories.tsx +5 -21
  69. package/mantine/specs/text_input_hooks.stories.tsx +5 -8
  70. package/mantine/specs/value_input_hooks.stories.tsx +5 -8
  71. package/mantine/types.ts +7 -3
  72. package/package.json +2 -1
@@ -2,16 +2,13 @@ import { type TextInputProps } from '@mantine/core';
2
2
  import { type Meta, type StoryObj } from '@storybook/react';
3
3
  import { type FieldsViewProps } from 'core/props';
4
4
  import { type SuppliedTextInputProps, type TextInputTarget } from 'mantine/create_text_input';
5
- import { type ErrorRenderer } from 'mantine/error_renderer';
6
5
  import { type ComponentType } from 'react';
7
6
  import { type Field } from 'types/field';
8
7
  type StoryTextInputProps<T extends TextInputTarget> = SuppliedTextInputProps<T> & Pick<TextInputProps, 'label'>;
9
- declare function Component<T extends TextInputTarget>({ TextInput, ErrorRenderer, ...props }: FieldsViewProps<{
8
+ declare function Component<T extends TextInputTarget>({ TextInput, ...props }: FieldsViewProps<{
10
9
  $: Field<string, string>;
11
10
  }> & {
12
11
  TextInput?: ComponentType<StoryTextInputProps<T>>;
13
- } & {
14
- ErrorRenderer?: ErrorRenderer;
15
12
  }): import("react/jsx-runtime").JSX.Element;
16
13
  declare const meta: Meta<typeof Component>;
17
14
  export default meta;
@@ -20,6 +17,6 @@ export declare const Empty: Story;
20
17
  export declare const Populated: Story;
21
18
  export declare const Required: Story;
22
19
  export declare const Disabled: Story;
23
- export declare const CustomError: Story;
20
+ export declare const Error: Story;
24
21
  export declare const OverriddenTextarea: Story<HTMLTextAreaElement>;
25
22
  export declare const OverriddenPillsInputField: Story;
@@ -3,7 +3,10 @@ import { PillsInputField, Textarea, } from '@mantine/core';
3
3
  import { action } from '@storybook/addon-actions';
4
4
  import { useMantineFormFields } from 'mantine/hooks';
5
5
  import { TEXT_INPUT_LABEL } from './text_input_constants';
6
- function Component({ TextInput, ErrorRenderer, ...props }) {
6
+ function ErrorRenderer({ error }) {
7
+ return `error ${error}`;
8
+ }
9
+ function Component({ TextInput, ...props }) {
7
10
  const form = useMantineFormFields(props);
8
11
  const TextInputComponent = form.textInput('$', TextInput);
9
12
  return (_jsx(TextInputComponent, { ErrorRenderer: ErrorRenderer, label: TEXT_INPUT_LABEL }));
@@ -62,7 +65,7 @@ export const Disabled = {
62
65
  },
63
66
  },
64
67
  };
65
- export const CustomError = {
68
+ export const Error = {
66
69
  args: {
67
70
  fields: {
68
71
  $: {
@@ -72,9 +75,6 @@ export const CustomError = {
72
75
  error: 'error',
73
76
  },
74
77
  },
75
- ErrorRenderer: function () {
76
- return 'custom error';
77
- },
78
78
  },
79
79
  };
80
80
  export const OverriddenTextarea = {
@@ -2,18 +2,15 @@ import { type JsonInputProps, type NumberInputProps, type RatingProps, type Slid
2
2
  import { type Meta, type StoryObj } from '@storybook/react';
3
3
  import { type FieldsViewProps } from 'core/props';
4
4
  import { type SuppliedValueInputProps } from 'mantine/create_value_input';
5
- import { type ErrorRenderer } from 'mantine/error_renderer';
6
5
  import { type ComponentType } from 'react';
7
6
  import { type Field } from 'types/field';
8
7
  type StoryValueInputProps<V> = SuppliedValueInputProps<V, any>;
9
- declare function Component<V, P extends StoryValueInputProps<V>>({ ValueInput, ErrorRenderer, inputProps, ...props }: FieldsViewProps<{
8
+ declare function Component<V, P extends StoryValueInputProps<V>>({ ValueInput, inputProps, ...props }: FieldsViewProps<{
10
9
  $: Field<V, string>;
11
10
  }> & {
12
11
  ValueInput: ComponentType<P>;
13
12
  } & {
14
13
  inputProps: P;
15
- } & {
16
- ErrorRenderer?: ErrorRenderer;
17
14
  }): import("react/jsx-runtime").JSX.Element;
18
15
  declare const meta: Meta<typeof Component>;
19
16
  export default meta;
@@ -21,7 +18,7 @@ type Story<V, P extends StoryValueInputProps<V>> = StoryObj<typeof Component<V,
21
18
  export declare const EmptyNumberInput: Story<number | string, NumberInputProps>;
22
19
  export declare const PopulatedNumberInput: Story<number | string, NumberInputProps>;
23
20
  export declare const RequiredNumberInput: Story<number | string, NumberInputProps>;
24
- export declare const CustomErrorNumberInput: Story<number | string, NumberInputProps>;
21
+ export declare const ErrorNumberInput: Story<number | string, NumberInputProps>;
25
22
  export declare const DisabledNumberInput: Story<number | string, NumberInputProps>;
26
23
  export declare const AnSlider: Story<number, SliderProps>;
27
24
  export declare const AnRating: Story<number, RatingProps>;
@@ -3,7 +3,10 @@ import { JsonInput, NumberInput, Rating, Slider, } from '@mantine/core';
3
3
  import { action } from '@storybook/addon-actions';
4
4
  import { useMantineFormFields } from 'mantine/hooks';
5
5
  import { NUMBER_INPUT_LABEL, SLIDER_LABEL, } from './value_input_constants';
6
- function Component({ ValueInput, ErrorRenderer, inputProps, ...props }) {
6
+ function ErrorRenderer({ error }) {
7
+ return `error ${error}`;
8
+ }
9
+ function Component({ ValueInput, inputProps, ...props }) {
7
10
  const form = useMantineFormFields(props);
8
11
  const ValueInputComponent = form.valueInput('$', ValueInput);
9
12
  return (_jsx(ValueInputComponent, { ...inputProps, ErrorRenderer: ErrorRenderer }));
@@ -63,7 +66,7 @@ export const RequiredNumberInput = {
63
66
  },
64
67
  },
65
68
  };
66
- export const CustomErrorNumberInput = {
69
+ export const ErrorNumberInput = {
67
70
  args: {
68
71
  fields: {
69
72
  $: {
@@ -74,9 +77,6 @@ export const CustomErrorNumberInput = {
74
77
  },
75
78
  },
76
79
  ValueInput: NumberInput,
77
- ErrorRenderer: function () {
78
- return 'a custom error';
79
- },
80
80
  inputProps: {
81
81
  label: NUMBER_INPUT_LABEL,
82
82
  },
@@ -9,6 +9,8 @@ export type MantineForm<F extends Fields> = {
9
9
  onFieldBlur: ((this: void, key: keyof F) => void) | undefined;
10
10
  onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
11
11
  };
12
- export type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<ComponentType<P>, T, {
13
- ErrorRenderer?: ErrorRenderer<E>;
12
+ export type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<ComponentType<P>, T, [
13
+ E
14
+ ] extends [never] ? {} : {
15
+ ErrorRenderer: ErrorRenderer<E>;
14
16
  }>;