@kaspernj/api-maker 1.0.442 → 1.0.443
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 +1 -1
- package/src/inputs/checkbox.jsx +7 -2
- package/src/use-input.mjs +7 -3
package/package.json
CHANGED
package/src/inputs/checkbox.jsx
CHANGED
|
@@ -33,12 +33,19 @@ export default memo(shapeComponent(class ApiMakerInputsCheckbox extends BaseComp
|
|
|
33
33
|
|
|
34
34
|
setup() {
|
|
35
35
|
const {inputProps, restProps: useInputRestProps} = useInput({props: this.props, wrapperOptions: {type: "checkbox"}})
|
|
36
|
+
const {defaultValue, name} = inputProps
|
|
36
37
|
|
|
37
38
|
this.setInstance({
|
|
38
39
|
form: useForm(),
|
|
39
40
|
inputProps,
|
|
40
41
|
useInputRestProps
|
|
41
42
|
})
|
|
43
|
+
|
|
44
|
+
useMemo(() => {
|
|
45
|
+
if (name) {
|
|
46
|
+
this.tt.form?.setValue(name, defaultValue)
|
|
47
|
+
}
|
|
48
|
+
}, [])
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
render () {
|
|
@@ -59,8 +66,6 @@ export default memo(shapeComponent(class ApiMakerInputsCheckbox extends BaseComp
|
|
|
59
66
|
...restProps
|
|
60
67
|
} = useInputRestProps
|
|
61
68
|
|
|
62
|
-
console.log("ApiMakerInputsCheckbox", {inputProps, restProps})
|
|
63
|
-
|
|
64
69
|
return (
|
|
65
70
|
<>
|
|
66
71
|
{autoRefresh && model &&
|
package/src/use-input.mjs
CHANGED
|
@@ -6,7 +6,13 @@ import strftime from "strftime"
|
|
|
6
6
|
import useShape from "set-state-compare/src/use-shape.js"
|
|
7
7
|
import useValidationErrors from "./use-validation-errors.mjs"
|
|
8
8
|
|
|
9
|
-
const useInput = ({props, wrapperOptions}) => {
|
|
9
|
+
const useInput = ({props, wrapperOptions, ...useInputRestProps}) => {
|
|
10
|
+
const useInputRestPropsKeys = Object.keys(useInputRestProps)
|
|
11
|
+
|
|
12
|
+
if (useInputRestPropsKeys.length > 0) {
|
|
13
|
+
throw new Error(`Unknown props given to useInput: ${useInputRestPropsKeys.join(", ")}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
const s = useShape(props)
|
|
11
17
|
|
|
12
18
|
s.useStates({
|
|
@@ -71,8 +77,6 @@ const useInput = ({props, wrapperOptions}) => {
|
|
|
71
77
|
|
|
72
78
|
const inputType = useCallback(() => {
|
|
73
79
|
if ("type" in s.props) {
|
|
74
|
-
console.log("Type in props", s.p.type)
|
|
75
|
-
|
|
76
80
|
return s.props.type
|
|
77
81
|
} else if (s.m.isCheckbox) {
|
|
78
82
|
return "checkbox"
|