@kaspernj/api-maker 1.0.394 → 1.0.396

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.394",
3
+ "version": "1.0.396",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -34,15 +34,18 @@ const ApiMakerInputsInput = memo(shapeComponent(class ApiMakerInputsInput extend
34
34
  }
35
35
 
36
36
  setup() {
37
+ const {inputProps} = this.p
38
+ const {defaultValue, name} = inputProps
39
+
37
40
  this.form = useForm()
38
41
  this.visibleInputRef = useRef()
39
42
 
40
43
  this.useStates({
41
- blankInputName: digg(this, "props", "inputProps", "type") == "file"
44
+ blankInputName: digg(inputProps, "type") == "file"
42
45
  })
43
46
  useMemo(() => {
44
- if ("defaultValue" in this.props) {
45
- this.tt.form?.setValue(this.props.defaultValue)
47
+ if (name) {
48
+ this.tt.form?.setValue(name, defaultValue)
46
49
  }
47
50
  }, [])
48
51
  }
@@ -1,9 +1,20 @@
1
1
  import BaseComponent from "../../base-component"
2
2
  import {memo} from "react"
3
+ import PropTypes from "prop-types"
4
+ import propTypesExact from "prop-types-exact"
3
5
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
6
+ import {useForm} from "../../form"
4
7
 
5
8
  export default memo(shapeComponent(class EditAttributeContent extends BaseComponent {
9
+ static propTypes = propTypesExact({
10
+ attribute: PropTypes.object.isRequired,
11
+ id: PropTypes.string.isRequired,
12
+ model: PropTypes.object.isRequired,
13
+ name: PropTypes.string.isRequired
14
+ })
15
+
6
16
  setup() {
17
+ this.form = useForm()
7
18
  this.useStates({
8
19
  value: () => this.defaultValue()
9
20
  })
@@ -33,5 +44,6 @@ export default memo(shapeComponent(class EditAttributeContent extends BaseCompon
33
44
 
34
45
  onChangeValue = (newValue) => {
35
46
  this.setState({value: newValue})
47
+ this.tt.form.setValue(this.p.name, newValue)
36
48
  }
37
49
  }))
@@ -8,6 +8,10 @@ import {useForm} from "../../form"
8
8
 
9
9
  export default memo(shapeComponent(class EditAttributeInput extends BaseComponent {
10
10
  static propTypes = propTypesExact({
11
+ attributeName: PropTypes.string.isRequired,
12
+ id: PropTypes.string.isRequired,
13
+ label: PropTypes.string.isRequired,
14
+ model: PropTypes.object.isRequired,
11
15
  name: PropTypes.string.isRequired
12
16
  })
13
17
 
@@ -11,7 +11,7 @@ import {shapeComponent} from "set-state-compare/src/shape-component.js"
11
11
 
12
12
  export default memo(shapeComponent(class EditAttribute extends BaseComponent {
13
13
  static propTypes = propTypesExact({
14
- attribute: PropTypes.string,
14
+ attribute: PropTypes.object.isRequired,
15
15
  model: PropTypes.object,
16
16
  modelClass: PropTypes.func
17
17
  })
@@ -3,7 +3,9 @@ import debounceFunction from "debounce"
3
3
  import ModelEvents from "./model-events.mjs"
4
4
  import useShape from "set-state-compare/src/use-shape.js"
5
5
 
6
- const apiMakerUseUpdatedEvent = (model, onUpdated, {active = true, debounce, onConnected, ...restProps}) => {
6
+ const apiMakerUseUpdatedEvent = (model, onUpdated, props = {}) => {
7
+ const {active = true, debounce, onConnected, ...restProps} = props
8
+
7
9
  if (Object.keys(restProps).length > 0) {
8
10
  throw new Error(`Unknown props given to useUpdatedEvent: ${Object.keys(restProps).join(", ")}`)
9
11
  }