@strictly/react-form 0.0.13 → 0.0.14

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 (35) hide show
  1. package/.out/core/mobx/field_adapter.d.ts +1 -0
  2. package/.out/core/mobx/form_model.d.ts +3 -1
  3. package/.out/core/mobx/form_model.js +23 -15
  4. package/.out/core/mobx/hooks.d.ts +2 -2
  5. package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +2 -2
  6. package/.out/core/mobx/specs/form_model.tests.js +26 -21
  7. package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +14 -21
  8. package/.out/core/mobx/sub_form_field_adapters.d.ts +5 -6
  9. package/.out/core/mobx/sub_form_field_adapters.js +6 -11
  10. package/.out/core/mobx/types.d.ts +3 -3
  11. package/.out/index.d.ts +2 -0
  12. package/.out/index.js +2 -0
  13. package/.out/mantine/field_view.d.ts +18 -0
  14. package/.out/mantine/field_view.js +16 -0
  15. package/.out/tsconfig.tsbuildinfo +1 -1
  16. package/.out/util/empty.d.ts +1 -0
  17. package/.out/util/empty.js +3 -0
  18. package/.turbo/turbo-build.log +8 -8
  19. package/.turbo/turbo-check-types.log +1 -1
  20. package/core/mobx/field_adapter.ts +9 -0
  21. package/core/mobx/form_model.ts +26 -16
  22. package/core/mobx/hooks.tsx +2 -2
  23. package/core/mobx/merge_field_adapters_with_two_way_converter.ts +2 -1
  24. package/core/mobx/specs/form_model.tests.ts +35 -20
  25. package/core/mobx/specs/sub_form_field_adapters.tests.ts +14 -34
  26. package/core/mobx/sub_form_field_adapters.ts +11 -26
  27. package/core/mobx/types.ts +10 -7
  28. package/dist/index.cjs +99 -67
  29. package/dist/index.d.cts +32 -12
  30. package/dist/index.d.ts +32 -12
  31. package/dist/index.js +77 -49
  32. package/index.ts +2 -0
  33. package/mantine/field_view.tsx +39 -0
  34. package/package.json +1 -1
  35. package/util/empty.tsx +3 -0
@@ -0,0 +1,39 @@
1
+ import { Observer } from 'mobx-react'
2
+ import { type ComponentType } from 'react'
3
+ import { type ErrorOfField } from 'types/error_of_field'
4
+ import { type Fields } from 'types/field'
5
+ import { type ValueTypeOfField } from 'types/value_type_of_field'
6
+ import { Empty } from 'util/empty'
7
+
8
+ /**
9
+ * Displays current value and error of a field
10
+ */
11
+ export function FieldView<F extends Fields, K extends keyof F>({
12
+ fields,
13
+ valuePath,
14
+ children,
15
+ }: {
16
+ fields: F,
17
+ valuePath: K,
18
+ children: (props: {
19
+ value: ValueTypeOfField<F[K]>,
20
+ error: ErrorOfField<F[K]> | undefined,
21
+ ErrorSink: ComponentType<{ error: ErrorOfField<F[K]> }>,
22
+ }) => JSX.Element,
23
+ }) {
24
+ return (
25
+ <Observer>
26
+ {() => {
27
+ const {
28
+ value,
29
+ error,
30
+ } = fields[valuePath]
31
+ return children({
32
+ value,
33
+ error,
34
+ ErrorSink: Empty,
35
+ })
36
+ }}
37
+ </Observer>
38
+ )
39
+ }
package/package.json CHANGED
@@ -70,7 +70,7 @@
70
70
  "test:watch": "vitest"
71
71
  },
72
72
  "type": "module",
73
- "version": "0.0.13",
73
+ "version": "0.0.14",
74
74
  "exports": {
75
75
  ".": {
76
76
  "import": {
package/util/empty.tsx ADDED
@@ -0,0 +1,3 @@
1
+ export function Empty() {
2
+ return null
3
+ }