@kaspernj/api-maker 1.0.390 → 1.0.392

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaspernj/api-maker",
3
- "version": "1.0.390",
3
+ "version": "1.0.392",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
package/src/form.jsx CHANGED
@@ -6,7 +6,7 @@ import {shapeComponent} from "set-state-compare/src/shape-component.js"
6
6
 
7
7
  const FormContext = createContext(null)
8
8
 
9
- class FormClass {
9
+ class FormInputs {
10
10
  constructor() {
11
11
  this.inputs = {}
12
12
  }
@@ -42,7 +42,7 @@ class FormClass {
42
42
  const Form = memo(shapeComponent(class Form extends BaseComponent {
43
43
  render() {
44
44
  const {children, setForm, ...restProps} = this.props
45
- const form = useMemo(() => new FormClass(), [])
45
+ const form = useMemo(() => new FormInputs(), [])
46
46
 
47
47
  useMemo(() => {
48
48
  if (setForm) {
@@ -65,4 +65,4 @@ const Form = memo(shapeComponent(class Form extends BaseComponent {
65
65
 
66
66
  const useForm = () => useContext(FormContext)
67
67
 
68
- export {Form, FormContext, useForm}
68
+ export {Form, FormContext, FormInputs, useForm}
@@ -40,6 +40,11 @@ const ApiMakerInputsInput = memo(shapeComponent(class ApiMakerInputsInput extend
40
40
  this.useStates({
41
41
  blankInputName: digg(this, "props", "inputProps", "type") == "file"
42
42
  })
43
+ useMemo(() => {
44
+ if ("defaultValue" in this.props) {
45
+ this.tt.form?.setValue(this.props.defaultValue)
46
+ }
47
+ }, [])
43
48
  }
44
49
 
45
50
  render () {
@@ -1,5 +1,4 @@
1
1
  import BaseComponent from "../../base-component"
2
- import {FormContext} from "../../form"
3
2
  import {memo} from "react"
4
3
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
5
4
 
@@ -7,17 +6,12 @@ export default memo(shapeComponent(class EditAttributeContent extends BaseCompon
7
6
  setup() {
8
7
  const {inputs, name} = this.p
9
8
 
10
- this.form = useContext(FormContext)
11
9
  this.useStates({
12
10
  value: () => this.defaultValue()
13
11
  })
14
12
 
15
13
  useMemo(() => {
16
14
  inputs[name] = this.s.value
17
-
18
- if (this.form) {
19
- this.form.setValue(name, this.s.value)
20
- }
21
15
  }, [])
22
16
  }
23
17
 
@@ -48,10 +42,6 @@ export default memo(shapeComponent(class EditAttributeContent extends BaseCompon
48
42
 
49
43
  inputs[name] = newValue
50
44
 
51
- if (this.form) {
52
- this.form.setValue(name, newValue)
53
- }
54
-
55
45
  this.setState({value: newValue})
56
46
  }
57
47
  }))