@strictly/react-form 0.0.4 → 0.0.6

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 (68) hide show
  1. package/.out/core/mobx/field_adapter_builder.d.ts +1 -1
  2. package/.out/core/mobx/field_adapter_builder.js +1 -2
  3. package/.out/core/mobx/hooks.d.ts +10 -0
  4. package/.out/core/mobx/hooks.js +47 -0
  5. package/.out/core/props.d.ts +2 -2
  6. package/.out/index.d.ts +1 -0
  7. package/.out/index.js +1 -0
  8. package/.out/mantine/create_fields_view.d.ts +7 -0
  9. package/.out/mantine/{create_sub_form.js → create_fields_view.js} +4 -5
  10. package/.out/mantine/create_form.d.ts +7 -0
  11. package/.out/mantine/create_form.js +13 -0
  12. package/.out/mantine/create_list.d.ts +5 -4
  13. package/.out/mantine/create_list.js +4 -2
  14. package/.out/mantine/hooks.d.ts +8 -5
  15. package/.out/mantine/hooks.js +17 -7
  16. package/.out/mantine/specs/checkbox_hooks.stories.d.ts +2 -2
  17. package/.out/mantine/specs/checkbox_hooks.stories.js +2 -2
  18. package/.out/mantine/specs/{sub_form_hooks.stories.d.ts → fields_view_hooks.stories.d.ts} +2 -2
  19. package/.out/mantine/specs/{sub_form_hooks.stories.js → fields_view_hooks.stories.js} +9 -8
  20. package/.out/mantine/specs/fields_view_hooks.tests.d.ts +1 -0
  21. package/.out/mantine/specs/fields_view_hooks.tests.js +12 -0
  22. package/.out/mantine/specs/form_hooks.stories.d.ts +12 -0
  23. package/.out/mantine/specs/form_hooks.stories.js +60 -0
  24. package/.out/mantine/specs/form_hooks.tests.d.ts +1 -0
  25. package/.out/mantine/specs/form_hooks.tests.js +12 -0
  26. package/.out/mantine/specs/list_hooks.stories.d.ts +2 -2
  27. package/.out/mantine/specs/list_hooks.stories.js +8 -8
  28. package/.out/mantine/specs/radio_group_hooks.stories.d.ts +2 -2
  29. package/.out/mantine/specs/radio_group_hooks.stories.js +2 -2
  30. package/.out/mantine/specs/select_hooks.stories.d.ts +2 -2
  31. package/.out/mantine/specs/select_hooks.stories.js +2 -2
  32. package/.out/mantine/specs/text_input_hooks.stories.d.ts +2 -2
  33. package/.out/mantine/specs/text_input_hooks.stories.js +2 -2
  34. package/.out/mantine/specs/value_input_hooks.stories.d.ts +2 -2
  35. package/.out/mantine/specs/value_input_hooks.stories.js +2 -2
  36. package/.out/tsconfig.tsbuildinfo +1 -1
  37. package/.turbo/turbo-build.log +7 -7
  38. package/.turbo/turbo-check-types.log +1 -1
  39. package/core/mobx/field_adapter_builder.ts +3 -4
  40. package/core/mobx/hooks.ts +94 -0
  41. package/core/props.ts +2 -2
  42. package/dist/index.cjs +175 -95
  43. package/dist/index.d.cts +48 -39
  44. package/dist/index.d.ts +48 -39
  45. package/dist/index.js +170 -86
  46. package/index.ts +1 -0
  47. package/mantine/{create_sub_form.tsx → create_fields_view.tsx} +27 -16
  48. package/mantine/create_form.tsx +43 -0
  49. package/mantine/create_list.tsx +10 -4
  50. package/mantine/hooks.tsx +51 -16
  51. package/mantine/specs/__snapshots__/fields_view_hooks.tests.tsx.snap +460 -0
  52. package/mantine/specs/__snapshots__/form_hooks.tests.tsx.snap +273 -0
  53. package/mantine/specs/__snapshots__/list_hooks.tests.tsx.snap +56 -8
  54. package/mantine/specs/checkbox_hooks.stories.tsx +4 -4
  55. package/mantine/specs/{sub_form_hooks.stories.tsx → fields_view_hooks.stories.tsx} +23 -11
  56. package/mantine/specs/fields_view_hooks.tests.tsx +15 -0
  57. package/mantine/specs/form_hooks.stories.tsx +107 -0
  58. package/mantine/specs/form_hooks.tests.tsx +15 -0
  59. package/mantine/specs/list_hooks.stories.tsx +20 -10
  60. package/mantine/specs/radio_group_hooks.stories.tsx +4 -4
  61. package/mantine/specs/select_hooks.stories.tsx +4 -4
  62. package/mantine/specs/text_input_hooks.stories.tsx +4 -4
  63. package/mantine/specs/value_input_hooks.stories.tsx +4 -4
  64. package/package.json +1 -1
  65. package/.out/field_converters/list_converter.d.ts +0 -2
  66. package/.out/field_converters/list_converter.js +0 -13
  67. package/.out/mantine/create_sub_form.d.ts +0 -6
  68. package/field_converters/list_converter.ts +0 -20
@@ -3,21 +3,21 @@ import {
3
3
  type Meta,
4
4
  type StoryObj,
5
5
  } from '@storybook/react'
6
- import { type FormProps } from 'core/props'
6
+ import { type FieldsViewProps } from 'core/props'
7
7
  import { type ErrorRenderer } from 'mantine/error_renderer'
8
- import { useMantineForm } from 'mantine/hooks'
8
+ import { useMantineFormFields } from 'mantine/hooks'
9
9
  import { type Field } from 'types/field'
10
10
  import { SELECT_LABEL } from './select_hooks_constant'
11
11
 
12
12
  function Component({
13
13
  ErrorRenderer,
14
14
  ...props
15
- }: FormProps<{
15
+ }: FieldsViewProps<{
16
16
  $: Field<string | null, string>,
17
17
  }> & {
18
18
  ErrorRenderer?: ErrorRenderer,
19
19
  }) {
20
- const form = useMantineForm(props)
20
+ const form = useMantineFormFields(props)
21
21
  const SelectComponent = form.select('$')
22
22
  return (
23
23
  <SelectComponent
@@ -8,13 +8,13 @@ import {
8
8
  type Meta,
9
9
  type StoryObj,
10
10
  } from '@storybook/react'
11
- import { type FormProps } from 'core/props'
11
+ import { type FieldsViewProps } from 'core/props'
12
12
  import {
13
13
  type SuppliedTextInputProps,
14
14
  type TextInputTarget,
15
15
  } from 'mantine/create_text_input'
16
16
  import { type ErrorRenderer } from 'mantine/error_renderer'
17
- import { useMantineForm } from 'mantine/hooks'
17
+ import { useMantineFormFields } from 'mantine/hooks'
18
18
  import { type ComponentType } from 'react'
19
19
  import { type Field } from 'types/field'
20
20
  import { TEXT_INPUT_LABEL } from './text_input_constants'
@@ -25,14 +25,14 @@ function Component<T extends TextInputTarget>({
25
25
  TextInput,
26
26
  ErrorRenderer,
27
27
  ...props
28
- }: FormProps<{
28
+ }: FieldsViewProps<{
29
29
  $: Field<string, string>,
30
30
  }> & {
31
31
  TextInput?: ComponentType<StoryTextInputProps<T>>,
32
32
  } & {
33
33
  ErrorRenderer?: ErrorRenderer,
34
34
  }) {
35
- const form = useMantineForm(props)
35
+ const form = useMantineFormFields(props)
36
36
  const TextInputComponent = form.textInput<'$', StoryTextInputProps<T>>('$', TextInput)
37
37
  return (
38
38
  <TextInputComponent
@@ -13,10 +13,10 @@ import {
13
13
  type Meta,
14
14
  type StoryObj,
15
15
  } from '@storybook/react'
16
- import { type FormProps } from 'core/props'
16
+ import { type FieldsViewProps } from 'core/props'
17
17
  import { type SuppliedValueInputProps } from 'mantine/create_value_input'
18
18
  import { type ErrorRenderer } from 'mantine/error_renderer'
19
- import { useMantineForm } from 'mantine/hooks'
19
+ import { useMantineFormFields } from 'mantine/hooks'
20
20
  import {
21
21
  type ComponentType,
22
22
  } from 'react'
@@ -37,7 +37,7 @@ function Component<
37
37
  ErrorRenderer,
38
38
  inputProps,
39
39
  ...props
40
- }: FormProps<{
40
+ }: FieldsViewProps<{
41
41
  $: Field<V, string>,
42
42
  }> & {
43
43
  ValueInput: ComponentType<P>,
@@ -46,7 +46,7 @@ function Component<
46
46
  } & {
47
47
  ErrorRenderer?: ErrorRenderer,
48
48
  }) {
49
- const form = useMantineForm(props)
49
+ const form = useMantineFormFields(props)
50
50
  const ValueInputComponent = form.valueInput<'$', P>('$', ValueInput)
51
51
  return (
52
52
  <ValueInputComponent
package/package.json CHANGED
@@ -69,7 +69,7 @@
69
69
  "test:watch": "vitest"
70
70
  },
71
71
  "type": "module",
72
- "version": "0.0.4",
72
+ "version": "0.0.6",
73
73
  "exports": {
74
74
  ".": {
75
75
  "import": {
@@ -1,2 +0,0 @@
1
- import { type AnnotatedFieldConverter } from 'types/field_converters';
2
- export declare function listConverter<E, K extends string, ValuePath extends string, Context>(): AnnotatedFieldConverter<readonly E[], K[], ValuePath, Context>;
@@ -1,13 +0,0 @@
1
- export function listConverter() {
2
- return function (from, valuePath) {
3
- const value = from.map(function (_v, i) {
4
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5
- return `${valuePath}.${i}`;
6
- });
7
- return {
8
- value,
9
- required: false,
10
- readonly: false,
11
- };
12
- };
13
- }
@@ -1,6 +0,0 @@
1
- import type { FormProps } from 'core/props';
2
- import type { ComponentType } from 'react';
3
- import type { AllFieldsOfFields } from 'types/all_fields_of_fields';
4
- import type { Fields } from 'types/field';
5
- import type { SubFormFields } from 'types/sub_form_fields';
6
- export declare function createSubForm<F extends Fields, K extends keyof AllFieldsOfFields<F>, S extends Fields = SubFormFields<F, K>>(valuePath: K, SubForm: ComponentType<FormProps<S>>, observableProps: FormProps<F>): () => import("react/jsx-runtime").JSX.Element;
@@ -1,20 +0,0 @@
1
- import { type AnnotatedFieldConverter } from 'types/field_converters'
2
-
3
- export function listConverter<
4
- E,
5
- K extends string,
6
- ValuePath extends string,
7
- Context,
8
- >(): AnnotatedFieldConverter<readonly E[], K[], ValuePath, Context> {
9
- return function (from: readonly E[], valuePath: ValuePath) {
10
- const value = from.map(function (_v, i) {
11
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
12
- return `${valuePath as string}.${i}` as K
13
- })
14
- return {
15
- value,
16
- required: false,
17
- readonly: false,
18
- }
19
- }
20
- }