@kaspernj/api-maker 1.0.407 → 1.0.408

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/form.jsx +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaspernj/api-maker",
3
- "version": "1.0.407",
3
+ "version": "1.0.408",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
package/src/form.jsx CHANGED
@@ -2,6 +2,7 @@ import {createContext, memo, useContext, useMemo} from "react"
2
2
  import BaseComponent from "./base-component"
3
3
  import FormDataObjectizer from "form-data-objectizer"
4
4
  import {Platform} from "react-native"
5
+ import PropTypes from "prop-types"
5
6
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
6
7
 
7
8
  const FormContext = createContext(null)
@@ -47,8 +48,15 @@ class FormInputs {
47
48
  }
48
49
 
49
50
  const Form = memo(shapeComponent(class Form extends BaseComponent {
51
+ static propTypes = {
52
+ children: PropTypes.node,
53
+ formRef: PropTypes.object,
54
+ onSubmit: PropTypes.func,
55
+ setForm: PropTypes.func
56
+ }
57
+
50
58
  render() {
51
- const {children, onSubmit, setForm, ...restProps} = this.props
59
+ const {children, formRef, onSubmit, setForm, ...restProps} = this.props
52
60
  const form = useMemo(() => new FormInputs({onSubmit}), [])
53
61
 
54
62
  useMemo(() => {
@@ -60,7 +68,7 @@ const Form = memo(shapeComponent(class Form extends BaseComponent {
60
68
  return (
61
69
  <FormContext.Provider value={form}>
62
70
  {Platform.OS == "web" &&
63
- <form onSubmit={this.tt.onFormSubmit} {...restProps}>
71
+ <form ref={formRef} onSubmit={this.tt.onFormSubmit} {...restProps}>
64
72
  {children}
65
73
  </form>
66
74
  }