@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.
- package/.out/core/mobx/field_adapter.d.ts +1 -0
- package/.out/core/mobx/form_model.d.ts +3 -1
- package/.out/core/mobx/form_model.js +23 -15
- package/.out/core/mobx/hooks.d.ts +2 -2
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +2 -2
- package/.out/core/mobx/specs/form_model.tests.js +26 -21
- package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +14 -21
- package/.out/core/mobx/sub_form_field_adapters.d.ts +5 -6
- package/.out/core/mobx/sub_form_field_adapters.js +6 -11
- package/.out/core/mobx/types.d.ts +3 -3
- package/.out/index.d.ts +2 -0
- package/.out/index.js +2 -0
- package/.out/mantine/field_view.d.ts +18 -0
- package/.out/mantine/field_view.js +16 -0
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/util/empty.d.ts +1 -0
- package/.out/util/empty.js +3 -0
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-check-types.log +1 -1
- package/core/mobx/field_adapter.ts +9 -0
- package/core/mobx/form_model.ts +26 -16
- package/core/mobx/hooks.tsx +2 -2
- package/core/mobx/merge_field_adapters_with_two_way_converter.ts +2 -1
- package/core/mobx/specs/form_model.tests.ts +35 -20
- package/core/mobx/specs/sub_form_field_adapters.tests.ts +14 -34
- package/core/mobx/sub_form_field_adapters.ts +11 -26
- package/core/mobx/types.ts +10 -7
- package/dist/index.cjs +99 -67
- package/dist/index.d.cts +32 -12
- package/dist/index.d.ts +32 -12
- package/dist/index.js +77 -49
- package/index.ts +2 -0
- package/mantine/field_view.tsx +39 -0
- package/package.json +1 -1
- 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
package/util/empty.tsx
ADDED